Index: /code/branches/physics/CMakeLists.txt
===================================================================
--- /code/branches/physics/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,134 @@
+PROJECT(Orxonox)
+
+cmake_minimum_required(VERSION 2.4)
+
+IF (COMMAND cmake_policy)
+  cmake_policy(SET CMP0003 NEW)
+ENDIF (COMMAND cmake_policy)
+
+# Allow for simple IF constructs (makes code a lot more readable)
+#SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+# This sets where to look for modules (e.g. "Find*.cmake" files)
+SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+
+# Check whether we are on a tardis box
+INCLUDE(CheckTardis)
+
+
+############## Testing options ##################
+
+OPTION(TESTING_ENABLED "Do you want to enable Testing")
+IF (TESTING_ENABLED)
+  ENABLE_TESTING()
+ENDIF(TESTING_ENABLED)
+
+OPTION (NETWORK_TESTING_ENABLED "Do you want to build network testing tools: i.e. chatclient chatserver and alike")
+OPTION (NETWORKTRAFFIC_TESTING_ENABLED "Do you want to build dummyserver4 and dummyclient4")
+
+
+########## Compiler/Linker options ##############
+
+# if on tardis change compiler and reset boost include directory
+IF(IS_TARDIS)
+  MESSAGE("System is a TARDIS: Setting Compiler to g++-4.1.1")
+  # Force-set the compiler on tardis machines, as default points to g++-3.3
+  SET(CMAKE_CXX_COMPILER "g++-4.1.1")
+  # Reset Boost serach path
+  SET(Boost_INCLUDE_DIR "/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/include")
+ELSE (IS_TARDIS)
+  IF (NOT WIN32)
+    SET(Boost_INCLUDE_DIR "/usr/include/boost")
+  ENDIF (NOT WIN32)
+ENDIF(IS_TARDIS)
+
+# Set binary output directories
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
+SET(LIBRARY_OUTPUT_PATH    ${PROJECT_SOURCE_DIR}/bin/lib)
+
+# Global compiler/linker flags. force -O2!
+SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O0 -Wall -g -ggdb")
+SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
+#SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O3 -s")
+#SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O3 -s")
+
+SET(CMAKE_LD_FLAGS "$ENV{LDFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS " --no-undefined")
+SET(CMAKE_SHARED_LINKER_FLAGS " --no-undefined")
+SET(CMAKE_MODULE_LINKER_FLAGS " --no-undefined")
+
+# Use 'cmake -D make_verb:1 path' to get verbose make output when compiling
+IF (MAKE_VERB)
+ SET(CMAKE_VERBOSE_MAKEFILE TRUE)
+ENDIF (MAKE_VERB)
+
+
+############### Library finding #################
+
+# Uncomment the following line if you want the include and library paths to be shown
+# Alternatively use the "-D VERBOSE_FIND:BOOL=true" option when executing cmake
+
+# SET (VERBOSE_FIND true)
+
+# Set the library directory when using precompiled tarballs for the dependencies under windows
+IF (WIN32)
+  IF (MSVC)
+    IF ($ENV{ORXONOX_DEV})
+      SET (DEPENDENCY_DIR ${CMAKE_SOURCE_DIR}/../lib_dist/dependencies/)
+    ELSE ($ENV{ORXONOX_DEV})
+      SET (DEPENDENCY_DIR ${CMAKE_SOURCE_DIR}/dependencies/)
+    ENDIF ($ENV{ORXONOX_DEV})
+    SET(Boost_LIB_SUFFIX_DEBUG vc80-mt-gd-1_35)
+  ENDIF (MSVC)
+ENDIF (WIN32)
+MESSAGE(STATUS ${DEPENDENCY_DIR})
+
+# Performs the search and sets the variables
+FIND_PACKAGE(OGRE)
+FIND_PACKAGE(CEGUI)
+# FIND_PACKAGE(CEGUI_OGRE)
+FIND_PACKAGE(ENet)
+FIND_PACKAGE(Boost REQUIRED thread filesystem)
+FIND_PACKAGE(OpenAL)
+FIND_PACKAGE(ALUT)
+FIND_PACKAGE(OggVorbis)
+FIND_PACKAGE(ZLIB)
+#FIND_PACKAGE(Lua)
+FIND_PACKAGE(TCL)
+FIND_PACKAGE(DirectX)
+FIND_PACKAGE(ODE)
+
+# Set the search paths for the linking
+LINK_DIRECTORIES(
+  ${OGRE_LIB_DIR}
+  ${CEGUI_LIB_DIR}
+#  ${CEGUI_SCRIPT_LIB_DIR}
+#  ${CEGUI_OGRE_LIB_DIR}
+  ${ENet_LIBRARY}
+  ${Boost_LIBRARY_DIRS}
+  ${Zlib_LIBRARY_DIR}
+  ${TCL_LIBRARY}
+  ${ODE_LIB_DIR}
+)
+
+# Set the search paths for include files
+INCLUDE_DIRECTORIES(
+  ${OGRE_INCLUDE_DIR}
+  ${CEGUI_INCLUDE_DIR}
+#  ${CEGUI_OGRE_INCLUDE_DIR}
+  ${ENet_INCLUDE_DIR}
+  ${Boost_INCLUDE_DIRS}
+  ${OPENAL_INCLUDE_DIR}
+  ${ALUT_INCLUDE_DIR}
+  ${VORBIS_INCLUDE_DIR}
+  ${OGG_INCLUDE_DIR}
+#  ${Lua_INCLUDE_DIR}
+  ${TCL_INCLUDE_PATH}
+  ${DirectX_INCLUDE_DIR}
+  ${ZLIB_INCLUDE_DIR}
+  ${ODE_INCLUDE_DIR}
+)
+
+# Add main source dir
+ADD_SUBDIRECTORY(src)
+
Index: /code/branches/physics/Doxyfile
===================================================================
--- /code/branches/physics/Doxyfile	(revision 2122)
+++ /code/branches/physics/Doxyfile	(revision 2122)
@@ -0,0 +1,280 @@
+# Doxyfile 1.5.1-KDevelop
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = Orxonox
+PROJECT_NUMBER         = 0.1.2_Bellatrix
+OUTPUT_DIRECTORY       =
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = YES
+STRIP_FROM_PATH        = /home/nicolasc/
+STRIP_FROM_INC_PATH    =
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 8
+ALIASES                =
+OPTIMIZE_OUTPUT_FOR_C  = NO
+OPTIMIZE_OUTPUT_JAVA   = NO
+BUILTIN_STL_SUPPORT    = NO
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = NO
+EXTRACT_STATIC         = NO
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = NO
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       =
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = NO
+FILE_VERSION_FILTER    =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = .
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py \
+                         *.C \
+                         *.CC \
+                         *.C++ \
+                         *.II \
+                         *.I++ \
+                         *.H \
+                         *.HH \
+                         *.H++ \
+                         *.CS \
+                         *.PHP \
+                         *.PHP3 \
+                         *.M \
+                         *.MM \
+                         *.PY \
+                         *.C \
+                         *.H \
+                         *.tlh \
+                         *.diff \
+                         *.patch \
+                         *.moc \
+                         *.xpm \
+                         *.dox
+RECURSIVE              = yes
+EXCLUDE                = .svn/
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       =
+EXAMPLE_PATH           =
+EXAMPLE_PATTERNS       = *
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             =
+INPUT_FILTER           =
+FILTER_PATTERNS        =
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION    = YES
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            =
+HTML_FOOTER            =
+HTML_STYLESHEET        =
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = NO
+CHM_FILE               =
+HHC_LOCATION           =
+GENERATE_CHI           = NO
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         =
+LATEX_HEADER           =
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = NO
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    =
+RTF_EXTENSIONS_FILE    =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             =
+XML_DTD                =
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           =
+INCLUDE_FILE_PATTERNS  =
+PREDEFINED             =
+EXPAND_AS_DEFINED      =
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES               =
+GENERATE_TAGFILE       = Orxonox.tag
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = NO
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = NO
+CALLER_GRAPH           = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               =
+DOTFILE_DIRS           =
+MAX_DOT_GRAPH_DEPTH    = 1000
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE           = YES
Index: /code/branches/physics/INSTALL
===================================================================
--- /code/branches/physics/INSTALL	(revision 2122)
+++ /code/branches/physics/INSTALL	(revision 2122)
@@ -0,0 +1,17 @@
+Here our installing directions
+
+requirements:
+ogre-1.4.5
+ois-1.0
+cegui-0.5.0b
+enet-1.1
+boost-1.34.1
+cmake-2.4.7
+openal-0.0.8
+freealut-1.1.0
+libvorbis-1.2.0
+(all named version were tested. lower version requirement may be possible)
+
+It is assumed, that you have a working graphical environment (i.e X11), including some sort of 3d acceleration (OpenGL, Direct3D)
+
+Further information about installing and running this application can be found on http://www.orxonox.net/wiki/Running
Index: /code/branches/physics/LICENSE
===================================================================
--- /code/branches/physics/LICENSE	(revision 2122)
+++ /code/branches/physics/LICENSE	(revision 2122)
@@ -0,0 +1,344 @@
+
+        GNU GENERAL PUBLIC LICENSE
+           Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+          Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+        GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software
+    interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Program does not specify a
+version number of this License, you may choose any version ever
+published by the Free Software Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+          NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+         END OF TERMS AND CONDITIONS
+
+      How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these
+terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Index: /code/branches/physics/README
===================================================================
--- /code/branches/physics/README	(revision 2122)
+++ /code/branches/physics/README	(revision 2122)
@@ -0,0 +1,20 @@
+Hi there,
+
+We are proud to present you Orxonox - the most ferious 3D space shooter ever to exist.
+
+This game is free, if you have paid for this, get your money back! The source code of this game is licensed under the GPL (GNU General Public License). 
+The game content is licensed under the Creative Commons Attribution-Sharealike 2.5 license. For more information read LICENSE in the same folder you found this file.
+
+For directions to install this game, please check out the file INSTALL or http://www.orxonox.net/wiki/Running
+
+This application uses the Ogre Graphics Engine (http://www.ogre3d.org), if you haven't already downloaded a precompiled version of Ogre with this package. Visit our webpage to get your Orxonox compatible version of the Ogre libraries.
+
+This is an open source game. If you want to contribute check out http://www.orxonox.net/wiki/development to find more information how you could help us making the game better. We are always looking for programmers and content designers, who like to contribute.
+
+We hope you have fun playing the game. Check out http://www.orxonox.net for news and newer versions of the game.
+
+Please contact us in our forum ( http://forum.orxonox.net ) or check out our contact page ( http://www.orxonox.net/wiki/about#Contact ). We hope to hear from you and are looking forward to your feedback.
+
+
+Cheers,
+The Orxonox Development Team
Index: /code/branches/physics/TODO
===================================================================
--- /code/branches/physics/TODO	(revision 2122)
+++ /code/branches/physics/TODO	(revision 2122)
@@ -0,0 +1,18 @@
+todo: 
+
+	bidirectional
+
+	minimize synchronisableHeader
+
+
+	!!! check that enet does not cause a packet traffic jam when a reliable packet gets missed !!!
+	!!! ensure that objects get synched, when newly created, even if not their tick
+
+	setvariable mode
+	objectmode
+	priorities (put into gamestatehandler)
+		manage delete object handling (only send deletes of acked objects)
+	static (sync once) & triggerSync
+
+REMARKS:
+	try to sort the bytestream before copy (putt all 0's in one place)
Index: /code/branches/physics/bin/Plugins.cfg
===================================================================
--- /code/branches/physics/bin/Plugins.cfg	(revision 2122)
+++ /code/branches/physics/bin/Plugins.cfg	(revision 2122)
@@ -0,0 +1,13 @@
+# Defines plugins to load
+
+# Define plugin folder
+PluginFolder=..\..\libs\ogre\Samples\Common\bin\Release
+
+# Define plugins
+Plugin=RenderSystem_Direct3D9
+Plugin=RenderSystem_GL
+Plugin=Plugin_ParticleFX
+Plugin=Plugin_BSPSceneManager
+Plugin=Plugin_OctreeSceneManager
+#Plugin=Plugin_CgProgramManager
+
Index: /code/branches/physics/bin/def_keybindings.ini
===================================================================
--- /code/branches/physics/bin/def_keybindings.ini	(revision 2122)
+++ /code/branches/physics/bin/def_keybindings.ini	(revision 2122)
@@ -0,0 +1,260 @@
+[Keys]
+KeyA="scale -1 moveRightLeft"
+KeyABNT_C1=
+KeyABNT_C2=
+KeyAT=
+KeyAX=
+KeyApostrophe=
+KeyApps=
+KeyB=
+KeyBack=
+KeyBackslash=
+KeyC=switchCamera
+KeyCalculator=
+KeyCapsLock=
+KeyColon=
+KeyComma=
+KeyConvert=
+KeyD="scale 1 moveRightLeft"
+KeyDelete=
+KeyDivide=
+KeyDown=
+KeyE="scale -1 rotateRoll"
+KeyEnd=
+KeyEquals=
+KeyEscape="exit"
+KeyF="scale -1 moveUpDown"
+KeyF1=
+KeyF10=
+KeyF11=
+KeyF12=
+KeyF13=
+KeyF14=
+KeyF15=
+KeyF2=
+KeyF3=
+KeyF4=
+KeyF5=
+KeyF6=
+KeyF7=
+KeyF8=
+KeyF9=
+KeyG=greet
+KeyGrave=
+KeyH=
+KeyHome=
+KeyI=
+KeyInsert=
+KeyJ=
+KeyK=
+KeyKana=
+KeyKanji=
+KeyL=
+KeyLeft=
+KeyLeftAlt=
+KeyLeftBracket=
+KeyLeftControl=
+KeyLeftShift=
+KeyLeftWindows=
+KeyLessThan=
+KeyM=
+KeyMail=
+KeyMediaSelect=
+KeyMediaStop=
+KeyMinus=
+KeyMultiply=
+KeyMute=
+KeyMyComputer=
+KeyN=
+KeyNextTrack=
+KeyNoConvert=
+KeyNumLock=
+KeyNumRow0=
+KeyNumRow1=
+KeyNumRow2=
+KeyNumRow3=
+KeyNumRow4=
+KeyNumRow5=
+KeyNumRow6=
+KeyNumRow7=
+KeyNumRow8=
+KeyNumRow9=
+KeyNumpad0=
+KeyNumpad1=
+KeyNumpad2=
+KeyNumpad3=
+KeyNumpad4=
+KeyNumpad5=
+KeyNumpad6=
+KeyNumpad7=
+KeyNumpad8=
+KeyNumpad9=
+KeyNumpadAdd=
+KeyNumpadComma=
+KeyNumpadEnter=
+KeyNumpadEquals=
+KeyNumpadPeriod=
+KeyNumpadSubtract=
+KeyO=
+KeyP=
+KeyPageDown=
+KeyPageUp=
+KeyPause=
+KeyPeriod=
+KeyPlayPause=
+KeyPower=
+KeyPreviousTrack=
+KeyQ="scale 1 rotateRoll"
+KeyR="scale 1 moveUpDown"
+KeyReturn=
+KeyRight=
+KeyRightAlt=
+KeyRightBracket=
+KeyRightControl=
+KeyRightShift=
+KeyRightWindows=
+KeyS="scale -1 moveFrontBack"
+KeyScrollLock=
+KeySemicolon=
+KeySlash=
+KeySleep=
+KeySpace=
+KeyStop=
+KeySystemRequest=
+KeyT=
+KeyTab="cycleNavigationFocus"
+KeyU=
+KeyUP=
+KeyUnassigned=
+KeyUnderline=
+KeyUnlabeled=
+KeyV=
+KeyVolumeDown=
+KeyVolumeUp=
+KeyW="scale 1 moveFrontBack"
+KeyWake=
+KeyWebBack=
+KeyWebFavorites=
+KeyWebForward=
+KeyWebHome=
+KeyWebRefresh=
+KeyWebSearch=
+KeyWebStop=
+KeyX=
+KeyY=
+KeyYen=
+KeyZ=
+Key_084=
+Key_085=
+Key_089=
+Key_090=
+Key_091=
+Key_092=
+Key_093=
+Key_094=
+Key_095=
+Key_096=
+Key_097=
+Key_098=
+Key_099=
+Key_103=
+Key_104=
+Key_105=
+Key_106=
+Key_107=
+Key_108=
+Key_109=
+Key_110=
+Key_111=
+Key_112=
+Key_114=
+Key_115=
+Key_117=
+Key_118=
+Key_119=
+Key_120=
+Key_121=
+Key_123=
+Key_125=
+Key_128=
+Key_129=
+Key_130=
+Key_131=
+Key_132=
+Key_133=
+Key_134=
+Key_135=
+Key_136=
+Key_137=
+Key_138=
+Key_139=
+Key_140=
+Key_141=
+Key_143=
+Key_144=
+Key_154=
+Key_155=
+Key_158=
+Key_159=
+Key_163=
+Key_165=
+Key_166=
+Key_167=
+Key_168=
+Key_169=
+Key_170=
+Key_171=
+Key_172=
+Key_173=
+Key_175=
+Key_177=
+Key_180=
+Key_182=
+Key_185=
+Key_186=
+Key_187=
+Key_188=
+Key_189=
+Key_190=
+Key_191=
+Key_192=
+Key_193=
+Key_194=
+Key_195=
+Key_196=
+Key_198=
+Key_202=
+Key_204=
+Key_206=
+Key_212=
+Key_213=
+Key_214=
+Key_215=
+Key_216=
+Key_217=
+Key_218=
+Key_224=
+Key_225=
+Key_226=
+Key_228=
+
+[MouseButtons]
+MouseButton3=
+MouseButton4=
+MouseButton5=
+MouseButton6=
+MouseButton7=
+MouseLeft="fire"
+MouseMiddle=
+MouseRight=
+MouseWheel1Down=
+MouseWheel1Up=
+MouseWheel2Down=
+MouseWheel2Up=
+
+[MouseAxes]
+MouseXNeg="scale -1 rotateYaw"
+MouseXPos="scale 1 rotateYaw"
+MouseYNeg="scale 1 rotatePitch"
+MouseYPos="scale -1 rotatePitch"
+
Index: /code/branches/physics/bin/def_masterKeybindings.ini
===================================================================
--- /code/branches/physics/bin/def_masterKeybindings.ini	(revision 2122)
+++ /code/branches/physics/bin/def_masterKeybindings.ini	(revision 2122)
@@ -0,0 +1,260 @@
+[Keys]
+KeyA=
+KeyABNT_C1=
+KeyABNT_C2=
+KeyAT=
+KeyAX=
+KeyApostrophe=
+KeyApps=
+KeyB=
+KeyBack=
+KeyBackslash=
+KeyC=
+KeyCalculator=
+KeyCapsLock=
+KeyColon=
+KeyComma=
+KeyConvert=
+KeyD=
+KeyDelete=
+KeyDivide=
+KeyDown=
+KeyE=
+KeyEnd=
+KeyEquals=
+KeyEscape=
+KeyF=
+KeyF1="OverlayGroup toggleVisibility Debug"
+KeyF10=
+KeyF11=
+KeyF12=
+KeyF13=
+KeyF14=
+KeyF15=
+KeyF2=
+KeyF3=
+KeyF4=
+KeyF5=
+KeyF6=
+KeyF7=
+KeyF8=
+KeyF9=
+KeyG=
+KeyGrave="openConsole"
+KeyH=
+KeyHome=
+KeyI=
+KeyInsert=
+KeyJ=
+KeyK=
+KeyKana=
+KeyKanji=
+KeyL=
+KeyLeft=
+KeyLeftAlt=
+KeyLeftBracket=
+KeyLeftControl=
+KeyLeftShift=
+KeyLeftWindows=
+KeyLessThan=
+KeyM=
+KeyMail=
+KeyMediaSelect=
+KeyMediaStop=
+KeyMinus=
+KeyMultiply=
+KeyMute=
+KeyMyComputer=
+KeyN=
+KeyNextTrack=
+KeyNoConvert=
+KeyNumLock=
+KeyNumRow0=
+KeyNumRow1=
+KeyNumRow2=
+KeyNumRow3=
+KeyNumRow4=
+KeyNumRow5=
+KeyNumRow6=
+KeyNumRow7=
+KeyNumRow8=
+KeyNumRow9=
+KeyNumpad0=
+KeyNumpad1=
+KeyNumpad2=
+KeyNumpad3=
+KeyNumpad4=
+KeyNumpad5=
+KeyNumpad6=
+KeyNumpad7=
+KeyNumpad8=
+KeyNumpad9=
+KeyNumpadAdd=
+KeyNumpadComma=
+KeyNumpadEnter=
+KeyNumpadEquals=
+KeyNumpadPeriod=
+KeyNumpadSubtract=
+KeyO=
+KeyP=
+KeyPageDown=
+KeyPageUp=
+KeyPause=
+KeyPeriod=
+KeyPlayPause=
+KeyPower=
+KeyPreviousTrack=
+KeyQ=
+KeyR=
+KeyReturn=
+KeyRight=
+KeyRightAlt=
+KeyRightBracket=
+KeyRightControl=
+KeyRightShift=
+KeyRightWindows=
+KeyS=
+KeyScrollLock=
+KeySemicolon=
+KeySlash=
+KeySleep=
+KeySpace=
+KeyStop=
+KeySystemRequest=
+KeyT=
+KeyTab=
+KeyU=
+KeyUP=
+KeyUnassigned=
+KeyUnderline=
+KeyUnlabeled=
+KeyV=
+KeyVolumeDown=
+KeyVolumeUp=
+KeyW=
+KeyWake=
+KeyWebBack=
+KeyWebFavorites=
+KeyWebForward=
+KeyWebHome=
+KeyWebRefresh=
+KeyWebSearch=
+KeyWebStop=
+KeyX=
+KeyY=
+KeyYen=
+KeyZ=
+Key_084=
+Key_085=
+Key_089=
+Key_090=
+Key_091=
+Key_092=
+Key_093=
+Key_094=
+Key_095=
+Key_096=
+Key_097=
+Key_098=
+Key_099=
+Key_103=
+Key_104=
+Key_105=
+Key_106=
+Key_107=
+Key_108=
+Key_109=
+Key_110=
+Key_111=
+Key_112=
+Key_114=
+Key_115=
+Key_117=
+Key_118=
+Key_119=
+Key_120=
+Key_121=
+Key_123=
+Key_125=
+Key_128=
+Key_129=
+Key_130=
+Key_131=
+Key_132=
+Key_133=
+Key_134=
+Key_135=
+Key_136=
+Key_137=
+Key_138=
+Key_139=
+Key_140=
+Key_141=
+Key_143=
+Key_144=
+Key_154=
+Key_155=
+Key_158=
+Key_159=
+Key_163=
+Key_165=
+Key_166=
+Key_167=
+Key_168=
+Key_169=
+Key_170=
+Key_171=
+Key_172=
+Key_173=
+Key_175=
+Key_177=
+Key_180=
+Key_182=
+Key_185=
+Key_186=
+Key_187=
+Key_188=
+Key_189=
+Key_190=
+Key_191=
+Key_192=
+Key_193=
+Key_194=
+Key_195=
+Key_196=
+Key_198=
+Key_202=
+Key_204=
+Key_206=
+Key_212=
+Key_213=
+Key_214=
+Key_215=
+Key_216=
+Key_217=
+Key_218=
+Key_224=
+Key_225=
+Key_226=
+Key_228=
+
+[MouseButtons]
+MouseButton3=
+MouseButton4=
+MouseButton5=
+MouseButton6=
+MouseButton7=
+MouseLeft=
+MouseMiddle=
+MouseRight=
+MouseWheel1Down=
+MouseWheel1Up=
+MouseWheel2Down=
+MouseWheel2Up=
+
+[MouseAxes]
+MouseXNeg=
+MouseXPos=
+MouseYNeg=
+MouseYPos=
+
Index: /code/branches/physics/bin/disco.txt
===================================================================
--- /code/branches/physics/bin/disco.txt	(revision 2122)
+++ /code/branches/physics/bin/disco.txt	(revision 2122)
@@ -0,0 +1,4 @@
+delay 0 Ambient setAmbientLightTest 1,0,0,1
+delay 0.2 Ambient setAmbientLightTest 0,1,0,1
+delay 0.4 Ambient setAmbientLightTest 0,0,1,1
+delay 0.6 source disco.txt
Index: /code/branches/physics/bin/irc.tcl
===================================================================
--- /code/branches/physics/bin/irc.tcl	(revision 2122)
+++ /code/branches/physics/bin/irc.tcl	(revision 2122)
@@ -0,0 +1,6 @@
+proc every {ms body} { eval $body; after $ms [list every $ms $body] }
+package require irk
+set conn [irk::connect orxonox $nickname]
+irk::join $conn #orxonox
+every 25 {}
+vwait termination
Index: /code/branches/physics/bin/ogre.cfg-init
===================================================================
--- /code/branches/physics/bin/ogre.cfg-init	(revision 2122)
+++ /code/branches/physics/bin/ogre.cfg-init	(revision 2122)
@@ -0,0 +1,7 @@
+Render System=OpenGL Rendering Subsystem
+
+[OpenGL Rendering Subsystem]
+FSAA=0
+Full Screen=No
+RTT Preferred Mode=FBO
+Video Mode=1024 x 768
Index: /code/branches/physics/bin/orxonox.bat
===================================================================
--- /code/branches/physics/bin/orxonox.bat	(revision 2122)
+++ /code/branches/physics/bin/orxonox.bat	(revision 2122)
@@ -0,0 +1,4 @@
+title Orxonox
+path lib;..\..\libs;%path%
+orxonox.exe
+pause
Index: /code/branches/physics/bin/plugins.cfg-init
===================================================================
--- /code/branches/physics/bin/plugins.cfg-init	(revision 2122)
+++ /code/branches/physics/bin/plugins.cfg-init	(revision 2122)
@@ -0,0 +1,14 @@
+# Defines plugins to load
+
+# Define plugin folder
+PluginFolder=/usr/lib/OGRE
+
+# Define plugins
+#Plugin=RenderSystem_Direct3D9
+Plugin=RenderSystem_GL
+Plugin=Plugin_ParticleFX
+Plugin=Plugin_BSPSceneManager
+Plugin=Plugin_OctreeSceneManager
+#Plugin=Plugin_CgProgramManager
+
+
Index: /code/branches/physics/bin/remote.tcl
===================================================================
--- /code/branches/physics/bin/remote.tcl	(revision 2122)
+++ /code/branches/physics/bin/remote.tcl	(revision 2122)
@@ -0,0 +1,2 @@
+set telnetserverthreadid [TclThreadManager create]
+TclThreadManager execute $telnetserverthreadid source telnet_server.tcl
Index: /code/branches/physics/bin/run-script
===================================================================
--- /code/branches/physics/bin/run-script	(revision 2122)
+++ /code/branches/physics/bin/run-script	(revision 2122)
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+if [[ !  -f orxonox ]] ; then
+	echo "orxonox does not exist"
+	echo "did you compile it?"
+
+	exit 1
+fi
+
+if [[ -ne orge.cfg ]] ; then
+	cp ogre.cfg-init ogre.cfg
+fi
+
+# check if plugins.cfg exists, and of not create it
+# and modify 
+if [[ ! -f plugins.cfg ]] ; then 
+	if uname -n | grep "tardis" > /dev/null ; then
+		sed -e 's:PluginFolder=/usr/lib/OGRE:PluginFolder=/usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/OGRE/:' \
+		-e 's:#Plugin=Plugin_CgProgramManager:Plugin=Plugin_CgProgramManager:' plugins.cfg-init > plugins.cfg
+	else
+                cp plugins.cfg-init plugins.cfg
+	fi
+fi
+
+trap "xset r && echo 'resetting autorepeat'" HUP INT TERM QUIT ABRT KILL ALRM
+./orxonox $@
Index: /code/branches/physics/bin/telnet_server.tcl
===================================================================
--- /code/branches/physics/bin/telnet_server.tcl	(revision 2122)
+++ /code/branches/physics/bin/telnet_server.tcl	(revision 2122)
@@ -0,0 +1,209 @@
+ #!/usr/bin/env tclsh
+ # Pseudo-telnet server.  Includes basic auth, but no separate identities
+ # or proper multi-threaded operation, so whoever runs this had better
+ # trust those he gives identities/passwords to and they had better trust
+ # each other too.  Note this script does not support command-line arguments.
+
+ ## The names of this array are IP addresses of hosts that are not permitted
+ ## to connect to any of our services.  Admin account(s) can change this
+ ## at run-time, though this info is not maintained across whole-server shutdowns.
+ array set denyHosts {}
+
+ ## Keep the Tcl-thread busy
+ proc every {ms body} { eval $body; after $ms [list every $ms $body] }
+ every 200 {}
+
+ ## Create a server on the given port with the given name/password map
+ ## and the given core interaction handler.
+ proc telnetServer {port {passmap} {handlerCmd remoteCommand}} {
+     if {$port == 0} {
+         return -code error "Only non-zero port numbers are supported"
+     }
+     set server [socket -server [list connect $port $handlerCmd] $port]
+     global passwords services
+     foreach {id pass} $passmap {set passwords($port,$id) $pass}
+     set services($server) $handlerCmd
+     return $server
+ }
+
+ ## Removes the server on the given port, cleaning up the extra state too.
+ proc closedownServer {server} {
+     global services passwords connections auth
+     set port [lindex [fconfigure $server -sockname] 2]
+     catch {close $server}
+     unset services($server)
+     foreach passmap [array names passwords $port,*] {
+         unset passwords($passmap)
+     }
+     # Hmph!  Have to remove unauthorized connections too, though any
+     # connection which has been authorized can continue safely.
+     foreach {client data} [array get connections] {
+         if {$port == [lindex $data 0] && !$auth($client)} {
+             disconnect $client
+         }
+     }
+ }
+
+ ## Handle an incoming connection to the given server
+ proc connect {serverport handlerCmd client clienthost clientport} {
+     global auth cmd denyHosts connections
+     if {[info exist denyHosts($clienthost)]} {
+         puts stdout "${clienthost}:${clientport} attempted connection"
+         catch {puts $client "Connection denied"}
+         catch {close $client}
+         return
+     }
+     puts stdout "${clienthost}:${clientport} connected on $client"
+     fileevent $client readable "handle $serverport $client"
+     set auth($client) 0
+     set cmd($client) $handlerCmd
+     set connections($client) [list $serverport $clienthost $clientport]
+     fconfigure $client -buffering none
+     catch {puts -nonewline $client "Login: "}
+ }
+
+ ## Disconnect the given client, cleaning up any connection-specific data
+ proc disconnect {client} {
+     catch {close $client}
+     global auth cmd connections
+     unset auth($client)
+     unset cmd($client)
+     unset connections($client)
+     puts stdout "$client disconnected"
+ }
+
+ ## Handle data sent from the client.  Log-in is handled directly by this
+ ## procedure, and requires the name and password on the same line
+ proc handle {serverport client} {
+     global passwords auth cmd
+     if {[gets $client line] < 0} {
+         disconnect $client
+         return
+     }
+     if {[string equal $line "quit"] || [string equal $line "exit"]} {
+         disconnect $client
+         return
+     }
+     if {$auth($client)} {
+         eval $cmd($client) [list $client $line 0]
+         eval $cmd($client) [list $client $line 1]
+         return
+     }
+     foreach {id pass} [split $line] {break}
+     if {![info exist pass]} {
+         catch {puts -nonewline $client "Login: "}
+         return
+     }
+     if {
+         [info exist passwords($serverport,$id)] &&
+         [string equal $passwords($serverport,$id) $pass]
+     } then {
+         set auth($client) 1
+         puts stdout "$id logged in on $client"
+         catch {puts $client "Welcome, $id!"}
+         eval $cmd($client) [list $client $line 1]
+         return
+     }
+     puts stdout "AUTH FAILURE ON $client"
+     catch {puts $client "Unknown name or password"}
+     disconnect $client
+ }
+
+ ## Standard handler for logged-in conversations and prompt-generation.
+ proc execCommand {client line prompt} {
+     global tcl_platform
+     if {$prompt} {
+         catch {puts -nonewline $client "\$ "}
+         return
+     }
+     switch $tcl_platform(platform) {
+         unix {
+             catch {exec sh -c $line <@$client >@$client 2>@$client}
+         }
+         default {
+             catch {exec $line} data
+             puts $client $data
+         }
+     }
+ }
+
+ ## Administration service handler.  Chains to the normal handler for
+ ## everything it doesn't recognise itself.
+ proc admin {client line prompt} {
+     if {$prompt} {
+         catch {puts -nonewline $client "# "}
+         return
+     }
+     set cmd [split $line]
+     global denyHosts connections services
+     if {[string equal $line "shutdown"]} {
+         set ::termination 1
+         puts stdout "Shutdown requested on $client"
+         catch {puts $client "System will shut down as soon as possible"}
+         return -code return "SHUTTING DOWN"
+     } elseif {[string equal [lindex $cmd 0] "deny"]} {
+         set denyHosts([lindex $cmd 1]) 1
+     } elseif {[string equal [lindex $cmd 0] "allow"]} {
+         catch {unset denyHosts([lindex $cmd 1])}
+     } elseif {[string equal $line "denied"]} {
+         foreach host [array names denyHosts] {
+             catch {puts $client $host}
+         }
+     } elseif {[string equal $line "connections"]} {
+         set len 0
+         foreach conn [array names connections] {
+             if {$len < [string length $conn]} {
+                 set len [string length $conn]
+             }
+         }
+         foreach {conn details} [array get connections] {
+             catch {puts $client [format "%-*s = %s" $len $conn $details]}
+         }
+     } elseif {[string equal [lindex $cmd 0] "close"]} {
+         set sock [lindex $cmd 1]
+         if {[info exist connections($sock)]} {
+             disconnect $sock
+         }
+     } elseif {[string equal $line "services"]} {
+         set len 0
+         foreach serv [array names services] {
+             if {$len < [string length $serv]} {
+                 set len [string length $serv]
+             }
+         }
+         foreach {serv handler} [array get services] {
+             set port [lindex [fconfigure $serv -sockname] 2]
+             catch {puts $client [format "%-*s (port %d) = handler %s" $len $serv $port $handler]}
+         }
+     } elseif {[string equal [lindex $cmd 0] "addService"]} {
+         set service [eval telnetServer [lrange $cmd 1 end]]
+         catch {puts $client "Created service as $service"}
+     } elseif {[string equal [lindex $cmd 0] "removeService"]} {
+         set service [lindex $cmd 1]
+         if {[info exist services($service)]} {
+             closedownServer $service
+         }
+     } else {
+         # CHAIN TO DEFAULT
+         execCommand $client $line 0
+     }
+ }
+ 
+ ## Executes a given command
+ proc remoteCommand {client line prompt} {
+     global tcl_platform
+     if {$prompt} {
+         catch {puts -nonewline $client "\$ "}
+         return
+     }
+     catch {eval $line} data
+     puts $client $data
+ }
+
+ telnetServer 2560 {orxonox rocks} remoteCommand
+ telnetServer 2561 {orxadmin *****} admin
+
+ puts stdout "Ready for service"
+
+ vwait termination
+ execute exit
Index: /code/branches/physics/cmake/CheckTardis.cmake
===================================================================
--- /code/branches/physics/cmake/CheckTardis.cmake	(revision 2122)
+++ /code/branches/physics/cmake/CheckTardis.cmake	(revision 2122)
@@ -0,0 +1,31 @@
+################# Tardis check ##################
+# This code checks whether the current machine  #
+# is an ETH tardis box.                         #
+#################################################
+
+# only run this test on a lunix/unix machine
+IF (UNIX)
+
+  FIND_PROGRAM(UNAME_CMD "uname"
+  PATHS "/usr/bin /bin")
+  IF(NOT UNAME_CMD)
+    MESSAGE(ERROR "Unable to find uname. Tardis-Check cannot be done.")
+  ENDIF(NOT UNAME_CMD)
+
+  # run uname -n to get nodename
+  EXECUTE_PROCESS(
+  COMMAND "${UNAME_CMD}" "-n"
+  RESULT_VARIABLE UNAME_RV
+  ERROR_VARIABLE UNAME_EV
+  OUTPUT_VARIABLE UNAME_OV)
+
+  IF (NOT "${UNAME_RV}" STREQUAL "0")
+    MESSAGE(ERROR "ERROR: uname terminated unclean.")
+  ENDIF (NOT "${UNAME_RV}" STREQUAL "0")
+
+  # check wheter we are on a tardis machine
+  IF ("${UNAME_OV}" MATCHES "tardis")
+    SET (IS_TARDIS ON)
+  ENDIF ("${UNAME_OV}" MATCHES "tardis")
+
+ENDIF (UNIX)
Index: /code/branches/physics/cmake/FindALUT.cmake
===================================================================
--- /code/branches/physics/cmake/FindALUT.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindALUT.cmake	(revision 2122)
@@ -0,0 +1,115 @@
+# - Locate FreeAlut
+# This module defines
+#  ALUT_LIBRARY
+#  ALUT_FOUND, if false, do not try to link to Alut
+#  ALUT_INCLUDE_DIR, where to find the headers
+#
+# $ALUTDIR is an environment variable that would
+# correspond to the ./configure --prefix=$ALUTDIR
+# used in building Alut.
+#
+# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of
+# ALUT_LIBRARY to override this selection.
+# Tiger will include OpenAL as part of the System.
+# But for now, we have to look around.
+# Other (Unix) systems should be able to utilize the non-framework paths.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+  SET (ALUT_FIND_QUIETLY TRUE)
+ENDIF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+
+FIND_PATH(ALUT_INCLUDE_DIR AL/alut.h
+  $ENV{ALUTDIR}/include
+  ~/Library/Frameworks/OpenAL.framework/Headers
+  /Library/Frameworks/OpenAL.framework/Headers
+  /System/Library/Frameworks/OpenAL.framework/Headers # Tiger
+  /usr/pack/openal-0.0.8-cl/include # Tardis specific hack
+  /usr/local/include/
+  /usr/local/include/OpenAL
+  /usr/local/include
+  /usr/include/
+  /usr/include/OpenAL
+  /usr/include
+  /sw/include/ # Fink
+  /sw/include/OpenAL
+  /sw/include
+  /opt/local/include/AL # DarwinPorts
+  /opt/local/include/OpenAL
+  /opt/local/include
+  /opt/csw/include/ # Blastwave
+  /opt/csw/include/OpenAL
+  /opt/csw/include
+  /opt/include/
+  /opt/include/OpenAL
+  /opt/include
+  ../libs/freealut-1.1.0/include
+  ${DEPENDENCY_DIR}/freealut-1.1.0/include
+  )
+
+# I'm not sure if I should do a special casing for Apple. It is
+# unlikely that other Unix systems will find the framework path.
+# But if they do ([Next|Open|GNU]Step?),
+# do they want the -framework option also?
+IF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" ALUT_FRAMEWORK_PATH_TMP ${ALUT_INCLUDE_DIR})
+  IF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is in default search path, don't need to use -F
+    SET (ALUT_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ELSE("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is not /Library/Frameworks, need to use -F
+    SET(ALUT_LIBRARY "-F${ALUT_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ENDIF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+    OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+    )
+  # Clear the temp variable so nobody can see it
+  SET(ALUT_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
+
+ELSE(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+  FIND_LIBRARY(ALUT_LIBRARY
+    NAMES alut
+    PATHS
+    $ENV{ALUTDIR}/lib
+    $ENV{ALUTDIR}/libs
+    /usr/pack/openal-0.0.8-cl/i686-debian-linux3.1/lib
+    /usr/local/lib
+    /usr/lib
+    /sw/lib
+    /opt/local/lib
+    /opt/csw/lib
+    /opt/lib
+    ../libs/freealut-1.1.0/src/.libs
+    ../libs/freealut-1.1.0/lib
+    ${DEPENDENCY_DIR}/freealut-1.1.0/lib
+    )
+ENDIF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+
+SET (ALUT_FOUND "NO")
+IF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+  SET (ALUT_FOUND "YES")
+  IF (NOT ALUT_FIND_QUIETLY)
+    MESSAGE (STATUS "FreeAlut was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${ALUT_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${ALUT_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    alut")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT ALUT_FIND_QUIETLY)
+ELSE (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+  IF (NOT ALUT_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "FreeAlut include path was not found.")
+  ENDIF (NOT ALUT_INCLUDE_DIR)
+  IF (NOT ALUT_LIBRARY)
+    MESSAGE (SEND_ERROR "FreeAlut library was not found.")
+  ENDIF (NOT ALUT_LIBRARY)
+ENDIF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+
+
Index: /code/branches/physics/cmake/FindBoost.cmake
===================================================================
--- /code/branches/physics/cmake/FindBoost.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindBoost.cmake	(revision 2122)
@@ -0,0 +1,316 @@
+# THIS FILE HAS BEEN MODIFIED TO WORK ON THE TARDIS INFRASTURUCTURE of THE ETH.
+# use with caution
+# Nicolas Schlumberger <nico AT orxonx DOT net> (C) 2007
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+#
+# - Find the Boost includes and libraries.
+# The following variables are set if Boost is found.  If Boost is not
+# found, Boost_FOUND is set to false.
+#  Boost_FOUND                  - True when the Boost include directory is found.
+#  Boost_INCLUDE_DIRS           - the path to where the boost include files are.
+#  Boost_LIBRARY_DIRS           - The path to where the boost library files are.
+#  Boost_LIB_DIAGNOSTIC_DEFINITIONS - Only set if using Windows.
+#  Boost_<library>_FOUND        - True if the Boost <library> is found.
+#  Boost_<library>_INCLUDE_DIRS - The include path for Boost <library>.
+#  Boost_<library>_LIBRARIES    - The libraries to link to to use Boost <library>.
+#  Boost_LIBRARIES              - The libraries to link to to use all Boost libraries.
+#
+# The following variables can be set to configure how Boost is found:
+#  Boost_LIB_PREFIX             - Look for Boost libraries prefixed with this, e.g. "lib"
+#  Boost_LIB_SUFFIX             - Look for Boost libraries ending with this, e.g. "vc80-mt"
+#  Boost_LIB_SUFFIX_DEBUG       - As for Boost_LIB_SUFFIX but for debug builds, e.g. "vs80-mt-gd"
+
+# ----------------------------------------------------------------------------
+# If you have installed Boost in a non-standard location or you have
+# just staged the boost files using bjam then you have three
+# options. In the following comments, it is assumed that <Your Path>
+# points to the root directory of the include directory of Boost. e.g
+# If you have put boost in C:\development\Boost then <Your Path> is
+# "C:/development/Boost" and in this directory there will be two
+# directories called "include" and "lib".
+# 1) After CMake runs, set Boost_INCLUDE_DIR to <Your Path>/include/boost<-version>
+# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/include. This will allow FIND_PATH()
+#    to locate Boost_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g.
+#    SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
+# 3) Set an environment variable called ${BOOST_ROOT} that points to the root of where you have
+#    installed Boost, e.g. <Your Path>. It is assumed that there is at least a subdirectory called
+#    include in this path.
+#
+# Note:
+#  1) If you are just using the boost headers, then you do not need to use
+#     Boost_LIBRARY_DIRS in your CMakeLists.txt file.
+#  2) If Boost has not been installed, then when setting Boost_LIBRARY_DIRS
+#     the script will look for /lib first and, if this fails, then for /stage/lib.
+#
+# Usage:
+# In your CMakeLists.txt file do something like this:
+# ...
+# # Boost
+# FIND_PACKAGE(Boost)
+# ...
+# INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
+# LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
+
+#
+# TODO:
+#
+# 1) Automatically find the Boost library files and eliminate the need
+#    to use Link Directories.
+#
+
+IF (Boost_INCLUDE_DIR)
+  SET (Boost_INCLUDE_FIND_QUIETLY TRUE)
+ENDIF (Boost_INCLUDE_DIR)
+
+IF(WIN32)
+# In windows, automatic linking is performed, so you do not have to specify the libraries.
+# If you are linking to a dynamic runtime, then you can choose to link to either a static or a
+# dynamic Boost library, the default is to do a static link.  You can alter this for a specific
+# library "whatever" by defining BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to
+# be linked dynamically.  Alternatively you can force all Boost libraries to dynamic link by
+# defining BOOST_ALL_DYN_LINK.
+
+# This feature can be disabled for Boost library "whatever" by defining BOOST_WHATEVER_NO_LIB,
+# or for all of Boost by defining BOOST_ALL_NO_LIB.
+
+# If you want to observe which libraries are being linked against then defining
+# BOOST_LIB_DIAGNOSTIC will cause the auto-linking code to emit a #pragma message each time
+# a library is selected for linking.
+#  SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC")
+#  SET(Boost_LIB_PREFIX "lib")
+#  SET(Boost_LIB_SUFFIX "gcc-mt-1_33_1.lib")
+ENDIF(WIN32)
+
+
+SET(BOOST_INCLUDE_PATH_DESCRIPTION "directory containing the boost include files.")
+
+SET(BOOST_DIR_MESSAGE "Set the Boost_INCLUDE_DIR cmake cache entry to the ${BOOST_INCLUDE_PATH_DESCRIPTION}")
+
+SET(BOOST_DIR_SEARCH $ENV{BOOST_ROOT})
+IF(BOOST_DIR_SEARCH)
+  FILE(TO_CMAKE_PATH ${BOOST_DIR_SEARCH} BOOST_DIR_SEARCH)
+  SET(BOOST_DIR_SEARCH ${BOOST_DIR_SEARCH}/include)
+ENDIF(BOOST_DIR_SEARCH)
+
+# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
+SET(SUFFIX_FOR_PATH
+ boost
+ boost-1_35_0
+ boost-1_35
+ boost-1_34_1
+ boost-1_34_0
+ boost-1_34
+ boost-1_33_1
+ boost-1_33_0
+)
+
+#
+# Look for an installation.
+#
+FIND_PATH(Boost_INCLUDE_DIR NAMES boost/config.hpp PATH_SUFFIXES ${SUFFIX_FOR_PATH} PATHS
+
+# Look in other places.
+  ${BOOST_DIR_SEARCH}
+
+#    ../libs/boost_1_33_1
+    ../libs/boost_1_34_1
+#    ../libs/boost-1_35_0
+    ${DEPENDENCY_DIR}/boost-1.35.0/include
+
+# Help the user find it if we cannot.
+  DOC "The ${BOOST_INCLUDE_PATH_DESCRIPTION}"
+)
+
+# Assume we didn't find it.
+SET(Boost_FOUND 0)
+
+# Now try to get the include and library path.
+IF(Boost_INCLUDE_DIR)
+
+# Look for the boost library path.
+# Note that the user may not have installed any libraries
+# so it is quite possible the Boost_LIBRARY_PATH may not exist.
+  SET(Boost_LIBRARY_DIR ${Boost_INCLUDE_DIR})
+
+  IF("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+")
+    GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH)
+  ENDIF ("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+")
+
+  IF("${Boost_LIBRARY_DIR}" MATCHES "/include$")
+# Strip off the trailing "/include" in the path.
+    GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH)
+  ENDIF("${Boost_LIBRARY_DIR}" MATCHES "/include$")
+
+  IF(EXISTS "${Boost_LIBRARY_DIR}/lib")
+    SET (Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/lib)
+  ELSEIF(EXISTS "${Boost_LIBRARY_DIR}/bin/boost/libs/thread/build/boost_thread.dll/gcc/release/threading-multi")
+    SET (Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/bin/boost/libs/thread/build/boost_thread.dll/gcc/release/threading-multi)
+  ELSE(EXISTS "${Boost_LIBRARY_DIR}/lib")
+    IF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
+      SET(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/stage/lib)
+    ELSE(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
+      IF(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
+        SET(Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR}/../../lib")
+      ELSE(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
+        SET(Boost_LIBRARY_DIR "")
+      ENDIF(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
+    ENDIF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
+  ENDIF(EXISTS "${Boost_LIBRARY_DIR}/lib")
+
+
+  IF(EXISTS "${Boost_INCLUDE_DIR}")
+    SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
+# We have found boost. It is possible that the user has not
+# compiled any libraries so we set Boost_FOUND to be true here.
+    SET(Boost_FOUND 1)
+    MARK_AS_ADVANCED(Boost_INCLUDE_DIR)
+  ENDIF(EXISTS "${Boost_INCLUDE_DIR}")
+  IF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}")
+    SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR})
+  ENDIF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}")
+ENDIF(Boost_INCLUDE_DIR)
+
+
+#
+# Find boost libraries
+#
+
+# List of library suffixes to search, e.g. libboost_date_time-gcc
+SET(BOOST_SUFFIX_SEARCH
+  mt
+  gcc41-mt
+  gcc
+  il
+  gcc-1_33_1
+  gcc-mt-1_33_1
+  mgw34-mt-1_34_1
+  mgw34-mt-1_35
+  vc80-mt-1_35
+  vc80-mt-gd-1_35
+)
+
+# List of all boost libraries
+SET(BOOST_ALL_LIBRARIES
+  date_time
+  filesystem
+  graph
+  iostreams
+  program_options
+  regex
+  serialization
+  signals
+  unit_test_framework
+  thread
+  wave
+)
+
+# Macro to find boost library called name
+MACRO(BOOST_FIND_LIBRARY name)
+
+# User can specify a particular build variant via the variables:
+#   Boost_LIB_PREFIX, Boost_LIB_SUFFIX, Boost_LIB_SUFFIX_DEBUG
+# otherwise we'll search the BOOST_SUFFIX_SEARCH list
+
+  SET(BOOST_LIB_NAMES ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX})
+  IF(NOT Boost_LIB_SUFFIX)
+    FOREACH(suffix ${BOOST_SUFFIX_SEARCH})
+      SET(BOOST_LIB_NAMES ${BOOST_LIB_NAMES} ${Boost_LIB_PREFIX}boost_${name}-${suffix})
+    ENDFOREACH(suffix)
+  ENDIF(NOT Boost_LIB_SUFFIX)
+
+# Find the library in the Boost_LIBRARY_DIRS
+  FIND_LIBRARY(Boost_${name}_LIBRARY
+    NAMES ${BOOST_LIB_NAMES}
+    PATHS ${Boost_LIBRARY_DIRS})
+
+# For MSVC builds find debug library
+  IF(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
+    FIND_LIBRARY(Boost_${name}_LIBRARY_DEBUG
+      NAMES ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX_DEBUG}
+      PATHS ${Boost_LIBRARY_DIRS})
+
+    IF(MSVC_IDE)
+      IF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
+        SET(Boost_${name}_LIBRARIES debug ${Boost_${name}_LIBRARY_DEBUG} optimized ${Boost_${name}_LIBRARY})
+      ELSE(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
+        MESSAGE(FATAL_ERROR "Could not find the debug and release version of Boost ${name} library.")
+      ENDIF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
+    ELSE(MSVC_IDE)
+      STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
+      IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+        SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY_DEBUG})
+      ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+        SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY})
+      ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+    ENDIF(MSVC_IDE)
+  ELSE(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
+    SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY})
+  ENDIF(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
+
+# If we've got it setup appropriate variables or issue error message
+  IF(Boost_${name}_LIBRARY)
+    SET(Boost_${name}_FOUND 1)
+    SET(Boost_${name}_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
+    MARK_AS_ADVANCED(Boost_${name}_LIBRARY Boost_${name}_LIBRARY_DEBUG)
+  ELSE(Boost_${name}_LIBRARY)
+    IF(NOT Boost_FIND_QUIETLY)
+      MESSAGE(SEND_ERROR "Boost ${name} library was not found.")
+    ELSE(NOT Boost_FIND_QUIETLY)
+      IF(Boost_FIND_REQUIRED_${name})
+        MESSAGE(FATAL_ERROR "Could NOT find required Boost ${name} library.")
+      ENDIF(Boost_FIND_REQUIRED_${name})
+    ENDIF(NOT Boost_FIND_QUIETLY)
+  ENDIF(Boost_${name}_LIBRARY)
+ENDMACRO(BOOST_FIND_LIBRARY)
+
+IF(Boost_LIBRARY_DIRS)
+
+# If the user specified required components e.g. via
+# FIND_PACKAGE(Boost REQUIRED date_time regex)
+# find (just) those libraries. Otherwise find all libraries.
+  IF(Boost_FIND_COMPONENTS)
+    SET(Boost_FIND_LIBRARIES ${Boost_FIND_COMPONENTS})
+  ELSE(Boost_FIND_COMPONENTS)
+    SET(Boost_FIND_LIBRARIES ${BOOST_ALL_LIBRARIES})
+  ENDIF(Boost_FIND_COMPONENTS)
+
+  SET(Boost_LIBRARIES)
+  FOREACH(library ${Boost_FIND_LIBRARIES})
+    IF (Boost_${library}_LIBRARY)
+      SET (Boost_${name}_LIBRARY_FIND_QUIETLY TRUE)
+    ENDIF (Boost_${library}_LIBRARY)
+
+    BOOST_FIND_LIBRARY(${library})
+    IF(Boost_${library}_FOUND)
+      SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${library}_LIBRARIES})
+      IF (NOT Boost_${name}_LIBRARY_FIND_QUIETLY)
+        MESSAGE(STATUS "Found BoostLibrary: ${library}")
+        IF (VERBOSE_FIND)
+          MESSAGE (STATUS "  library path: ${Boost_${library}_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+      ENDIF (NOT Boost_${name}_LIBRARY_FIND_QUIETLY)
+    ENDIF(Boost_${library}_FOUND)
+  ENDFOREACH(library)
+ELSE(Boost_LIBRARY_DIRS)
+  MESSAGE(SEND_ERROR "Boost libraries not found: ${Boost_FIND_COMPONENTS}")
+ENDIF(Boost_LIBRARY_DIRS)
+
+IF(NOT Boost_FOUND)
+  IF(NOT Boost_FIND_QUIETLY)
+    MESSAGE(SEND_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
+  ELSE(NOT Boost_FIND_QUIETLY)
+    IF(Boost_FIND_REQUIRED)
+      MESSAGE(SEND_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
+    ENDIF(Boost_FIND_REQUIRED)
+  ENDIF(NOT Boost_FIND_QUIETLY)
+ELSE(NOT Boost_FOUND)
+  IF (NOT Boost_INCLUDE_FIND_QUIETLY)
+    MESSAGE(STATUS "Boost include path was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${Boost_INCLUDE_DIR}")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT Boost_INCLUDE_FIND_QUIETLY)
+ENDIF(NOT Boost_FOUND)
+
Index: /code/branches/physics/cmake/FindCEGUI.cmake
===================================================================
--- /code/branches/physics/cmake/FindCEGUI.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindCEGUI.cmake	(revision 2122)
@@ -0,0 +1,113 @@
+# Find CEGUI includes and library
+#
+# This module defines
+#  CEGUI_INCLUDE_DIR
+#  CEGUI_LIBRARIES, the libraries to link against to use CEGUI.
+#  CEGUI_LIB_DIR, the location of the libraries
+#  CEGUI_FOUND, If false, do not try to use CEGUI
+#
+# Created by Matt Williams to find OGRE libraries
+# Copyright © 2007, Matt Williams
+#
+# Modified by Nicolas Schlumberger to find CEGUI libraries
+# and make it run on the Tardis-Infrastucture of the ETH Zurich
+# Copyright 2007, Nicolas Schlumberger
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
+    SET(CEGUI_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
+
+IF (WIN32) #Windows
+    FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h
+        ../libs/cegui-0.6.1/include
+        ${DEPENDENCY_DIR}/cegui-0.6.1/include
+    )
+
+    SET(CEGUI_LIBRARIES debug CEGUIBase_d optimized CEGUIBase)
+    FIND_LIBRARY(CEGUI_LIBDIR NAMES ${CEGUI_LIBRARIES} PATHS
+        ../libs/cegui-0.6.1/bin
+        ${DEPENDENCY_DIR}/cegui-0.6.1/lib
+    )
+
+    # Strip the filename from the path
+    IF (CEGUI_LIBDIR)
+        GET_FILENAME_COMPONENT(CEGUI_LIBDIR ${CEGUI_LIBDIR} PATH)
+        SET (CEGUI_LIB_DIR ${CEGUI_LIBDIR} CACHE FILEPATH "")
+    ENDIF (CEGUI_LIBDIR)
+
+#    IF (NOT CEGUI_SCRIPT_LIBDIR)
+#        # Search Lua script module
+#        SET(CEGUI_SCRIPT_LIBRARIES "CEGUILuaScriptModule")
+#        FIND_LIBRARY(CEGUI_SCRIPT_LIBDIR NAMES ${CEGUI_SCRIPT_LIBRARIES} PATHS
+#            ../libs/cegui-0.6.1/bin
+#        )
+#	IF (NOT CEGUI_SCRIPT_LIBDIR)
+#            SET(CEGUI_SCRIPT_LIBRARIES "CEGUILua")
+#            FIND_LIBRARY(CEGUI_SCRIPT_LIBDIR NAMES ${CEGUI_SCRIPT_LIBRARIES} PATHS
+#                ../libs/cegui-0.6.1/bin
+#            )
+#            IF (NOT CEGUI_SCRIPT_LIBDIR)
+#                SET(CEGUI_SCRIPT_LIBRARIES)
+#            ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
+#        ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
+#    ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
+
+#    # Strip the filename from the path
+#    IF (CEGUI_SCRIPT_LIBDIR)
+#        GET_FILENAME_COMPONENT(CEGUI_SCRIPT_LIBDIR ${CEGUI_SCRIPT_LIBDIR} PATH)
+#        SET (CEGUI_SCRIPT_LIB_DIR ${CEGUI_SCRIPT_LIBDIR} CACHE FILEPATH "")
+#    ENDIF (CEGUI_SCRIPT_LIBDIR)
+
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(CEGUI CEGUI /usr/pack/cegui-0.5.0-sd/i686-debian-linux3.1/lib/pkgconfig/CEGUI.pc) # tardis specific hack
+    SET(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIRS})
+    SET(CEGUI_LIB_DIR ${CEGUI_LIBDIR})
+    SET(CEGUI_LIBRARIES ${CEGUI_LIBRARIES} CACHE STRING "")
+#    SET(CEGUI_SCRIPT_LIBRARIES "CEGUILuaScriptModule")
+#    SET(CEGUI_SCRIPT_LIB_DIR)
+ENDIF (WIN32)
+
+IF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
+    SET(CEGUI_FOUND TRUE)
+
+    #Do some preparation
+    SEPARATE_ARGUMENTS(CEGUI_INCLUDE_DIR)
+    SEPARATE_ARGUMENTS(CEGUI_LIBRARIES)
+
+    SET(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIR} CACHE PATH "")
+    SET(CEGUI_LIBRARIES ${CEGUI_LIBRARIES} CACHE STRING "")
+    SET(CEGUI_LIB_DIR ${CEGUI_LIB_DIR} CACHE PATH "")
+#    SET(CEGUI_SCRIPT_LIBRARIES ${CEGUI_SCRIPT_LIBRARIES} CACHE PATH "")
+ENDIF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES AND CEGUI_LIB_DIR)# AND CEGUI_SCRIPT_LIBRARIES)
+
+IF (CEGUI_FOUND)
+    IF (NOT CEGUI_FIND_QUIETLY)
+        MESSAGE(STATUS "CEGUI was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${CEGUI_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${CEGUI_LIB_DIR}")
+            MESSAGE (STATUS "  libraries:    ${CEGUI_LIBRARIES}")
+#            MESSAGE (STATUS "           :    ${CEGUI_SCRIPT_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT CEGUI_FIND_QUIETLY)
+ELSE (CEGUI_FOUND)
+    IF (NOT CEGUI_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "CEGUI include path was not found.")
+    ENDIF (NOT CEGUI_INCLUDE_DIR)
+    IF (NOT CEGUI_LIB_DIR)
+        MESSAGE(SEND_ERROR "CEGUI library was not found.")
+    ENDIF (NOT CEGUI_LIB_DIR)
+    IF (NOT CEGUI_LIBRARIES)
+        MESSAGE(SEND_ERROR "CEGUI libraries not known.")
+    ENDIF (NOT CEGUI_LIBRARIES)
+#    IF (NOT CEGUI_SCRIPT_LIBRARIES)
+#        MESSAGE(SEND_ERROR "CEGUI Lua script module was not found.")
+#    ENDIF (NOT CEGUI_SCRIPT_LIBRARIES)
+ENDIF (CEGUI_FOUND)
+
Index: /code/branches/physics/cmake/FindCEGUI_OGRE.cmake
===================================================================
--- /code/branches/physics/cmake/FindCEGUI_OGRE.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindCEGUI_OGRE.cmake	(revision 2122)
@@ -0,0 +1,69 @@
+# Find CEGUI_OGRE includes and library
+#
+# This module defines
+#  CEGUI_OGRE_INCLUDE_DIR
+#  CEGUI_OGRE_LIBRARIES, the libraries to link against to use CEGUI_OGRE.
+#  CEGUI_OGRE_LIB_DIR, the location of the libraries
+#  CEGUI_OGRE_FOUND, If false, do not try to use CEGUI_OGRE
+#
+# Created by Matt Williams to find OGRE libraries
+# Copyright © 2007, Matt Williams
+#
+# Modified by Nicolas Schlumberger to find CEGUI-OGRE libraries
+# and make it run on the Tardis-Infrastucture of the ETH Zurich
+# Copyright 2007, Nicolas Schlumberger
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIB_DIR)
+    SET(CEGUI_OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIB_DIR)
+
+IF (WIN32) #Windows
+    MESSAGE(STATUS "Looking for CEGUI_OGRE")
+    SET(CEGUI_OGRE_INCLUDE_DIR ../libs/ogre/Samples/Common/CEGUIRenderer/include)
+    SET(CEGUI_OGRE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/ogre/Samples/Common/bin/Release/lib)
+    SET(CEGUI_OGRE_LIBRARIES debug OgreGUIRenderer_d optimized OgreGUIRenderer)
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(CEGUI_OGRE CEGUI-OGRE /usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/pkgconfig/CEGUI-OGRE.pc) # tardis specific hack
+    SET(CEGUI_OGRE_INCLUDE_DIR ${CEGUI_OGRE_INCLUDE_DIRS})
+    SET(CEGUI_OGRE_LIB_DIR ${CEGUI_OGRE_LIBDIR})
+    SET(CEGUI_OGRE_LIBRARIES ${CEGUI_OGRE_LIBRARIES} CACHE STRING "")
+ENDIF (WIN32)
+
+#Do some preparation
+SEPARATE_ARGUMENTS(CEGUI_OGRE_INCLUDE_DIR)
+SEPARATE_ARGUMENTS(CEGUI_OGRE_LIBRARIES)
+
+SET(CEGUI_OGRE_INCLUDE_DIR ${CEGUI_OGRE_INCLUDE_DIR} CACHE PATH "")
+SET(CEGUI_OGRE_LIBRARIES ${CEGUI_OGRE_LIBRARIES} CACHE STRING "")
+SET(CEGUI_OGRE_LIB_DIR ${CEGUI_OGRE_LIB_DIR} CACHE PATH "")
+
+IF (CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_LIB_DIR)
+    SET(CEGUI_OGRE_FOUND TRUE)
+ENDIF (CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_LIB_DIR)
+
+IF (CEGUI_OGRE_FOUND)
+    IF (NOT CEGUI_OGRE_FIND_QUIETLY)
+        MESSAGE(STATUS "CEGUI_Ogre was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${CEGUI_OGRE_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${CEGUI_OGRE_LIB_DIR}")
+            MESSAGE (STATUS "  libraries:    ${CEGUI_OGRE_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT CEGUI_OGRE_FIND_QUIETLY)
+ELSE (CEGUI_OGRE_FOUND)
+    IF (NOT CEGUI_OGRE_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "CEGUI_Ogre include path was not found.")
+    ENDIF (NOT CEGUI_OGRE_INCLUDE_DIR)
+    IF (NOT CEGUI_OGRE_LIB_DIR)
+        MESSAGE(SEND_ERROR "CEGUI_Ogre library was not found.")
+    ENDIF (NOT CEGUI_OGRE_LIB_DIR)
+    IF (NOT CEGUI_OGRE_LIBRARIES)
+        MESSAGE(SEND_ERROR "CEGUI_Ogre libraries not known.")
+    ENDIF (NOT CEGUI_OGRE_LIBRARIES)
+ENDIF (CEGUI_OGRE_FOUND)
Index: /code/branches/physics/cmake/FindDirectX.cmake
===================================================================
--- /code/branches/physics/cmake/FindDirectX.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindDirectX.cmake	(revision 2122)
@@ -0,0 +1,49 @@
+IF(WIN32)
+  # - Test for DirectX
+  # Once loaded this will define
+  #   DirectX_FOUND        - system has DirectX
+  #   DirectX_INCLUDE_DIR  - include directory for DirectX
+  #   DirectX_LIB_DIR      - lib directory for DirectX
+  #
+  # Several changes and additions by Fabian 'x3n' Landau
+  #                 > www.orxonox.net <
+
+  IF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+    SET(DirectX_FIND_QUIETLY TRUE)
+  ENDIF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+
+  set(DirectX_FOUND "NO")
+
+  FIND_PATH(DirectX_INCLUDE_DIR "dinput.h"
+    ../libs/DXSDK/Include
+    $ENV{DXSDK_DIR}/Include
+  )
+
+  FIND_PATH(DirectX_LIB_DIR "dinput8.lib"
+    ../libs/DXSDK/Lib
+    ../libs/DXSDK/Lib/x86
+    $ENV{DXSDK_DIR}/lib/x86
+  )
+
+  IF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+    SET (DirectX_FOUND "YES")
+  ENDIF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+
+  IF (DirectX_FOUND)
+    IF (NOT DirectX_FIND_QUIETLY)
+      MESSAGE(STATUS "DirectX was found.")
+      IF (VERBOSE_FIND)
+        MESSAGE (STATUS "  include path: ${DirectX_INCLUDE_DIR}")
+        MESSAGE (STATUS "  library path: ${DirectX_LIB_DIR}")
+        MESSAGE (STATUS "  libraries:    dinput8.lib")
+      ENDIF (VERBOSE_FIND)
+    ENDIF (NOT DirectX_FIND_QUIETLY)
+  ELSE (DirectX_FOUND)
+    IF (NOT DirectX_INCLUDE_DIR)
+      MESSAGE(SEND_ERROR "DirectX include path was not found.")
+    ENDIF (NOT DirectX_INCLUDE_DIR)
+    IF (NOT DirectX_LIB_DIR)
+      MESSAGE(SEND_ERROR "DirectX library was not found.")
+    ENDIF (NOT DirectX_LIB_DIR)
+  ENDIF (DirectX_FOUND)
+ENDIF(WIN32)
Index: /code/branches/physics/cmake/FindENet.cmake
===================================================================
--- /code/branches/physics/cmake/FindENet.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindENet.cmake	(revision 2122)
@@ -0,0 +1,65 @@
+# - Try to find enet
+# Once done this will define
+#
+#  ENET_FOUND - system has enet
+#  ENET_INCLUDE_DIR - the enet include directory
+#  ENET_LIBRARIES - the libraries needed to use enet
+#  ENET_DEFINITIONS - Compiler switches required for using enet
+#
+#  Borrowed from The Mana World
+#  http://themanaworld.org/
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+   SET(ENet_FIND_QUIETLY TRUE)
+ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+
+FIND_PATH(ENet_INCLUDE_DIR enet/enet.h
+    /usr/include
+    /usr/local/include
+    /usr/pack/enet-2007-sd/include
+    ../libs/enet-1.1/include
+    ${DEPENDENCY_DIR}/enet-1.2/include
+    )
+
+FIND_LIBRARY(ENet_LIBRARY
+    NAMES enet
+    PATHS /usr/lib /usr/local/lib /usr/pack/enet-2007-sd/i686-debian-linux3.1/lib/
+    ../libs/enet-1.1
+    ${DEPENDENCY_DIR}/enet-1.2/lib
+    )
+
+SET(ENET_FOUND FALSE)
+IF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+    SET(ENET_FOUND TRUE)
+    SET(ENET_INCLUDE_DIR ${ENet_INCLUDE_DIR})
+
+    IF(WIN32)
+        SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
+        SET(ENet_LIBRARY ${ENet_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
+    ENDIF(WIN32)
+
+    SET(ENET_LIBRARIES ${ENet_LIBRARY})
+ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+
+IF (ENET_FOUND)
+    IF (NOT ENet_FIND_QUIETLY)
+        MESSAGE(STATUS "ENet was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${ENet_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${ENet_LIBRARY}")
+            MESSAGE (STATUS "  libraries:    enet")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT ENet_FIND_QUIETLY)
+ELSE (ENET_FOUND)
+    IF (NOT ENet_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "ENet include path was not found.")
+    ENDIF (NOT ENet_INCLUDE_DIR)
+    IF (NOT ENet_LIBRARY)
+        MESSAGE(SEND_ERROR "ENet library was not found.")
+    ENDIF (NOT ENet_LIBRARY)
+ENDIF (ENET_FOUND)
+
+MARK_AS_ADVANCED(ENet_INCLUDE_DIR ENet_LIBRARY)
Index: /code/branches/physics/cmake/FindLua.cmake
===================================================================
--- /code/branches/physics/cmake/FindLua.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindLua.cmake	(revision 2122)
@@ -0,0 +1,101 @@
+#  Find Lua header and library files
+#
+#  When called, this script tries to define:
+#  Lua_INCLUDE_DIR    Header files directory
+#  Lua_LIBRARIES      library files (or file when using lua 5.1)
+#  Lua_FOUND          defined (true) if lua was found
+#  Lua_VERSION        either 5.1 or 5.0 or undefined
+#
+#  authors: Benjamin Knecht, Reto Grieder
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+
+  # Already in cache, be silent
+  SET(Lua_FOUND TRUE)
+  SET(Lua_FIND_QUIETLY TRUE) 
+#  MESSAGE(STATUS "Lua was found.")
+
+ELSE (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+
+  FIND_PATH(Lua_INCLUDE_DIR_51 lua.h
+    /usr/include/lua5.1
+    /usr/local/include/lua5.1
+    ../libs/lua-5.1.3/include)
+
+  FIND_PATH(Lua_INCLUDE_DIR_50 lua.h
+    /usr/include/lua50
+    /usr/local/include/lua50
+    /usr/pack/lua-5.0.3-sd/include)
+
+  FIND_LIBRARY(Lua_LIBRARY_51 NAMES lua5.1 lua PATHS
+    /usr/lib
+    /usr/local/lib
+    ../libs/lua-5.1.3/lib)
+
+  FIND_LIBRARY(Lua_LIBRARY_1_50 NAMES lua50 lua PATHS
+    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
+    /usr/lib
+    /usr/local/lib)
+
+  FIND_LIBRARY(Lua_LIBRARY_2_50 NAMES lualib50 lualib PATHS
+    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
+    /usr/lib
+    /usr/local/lib)
+
+
+  IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+
+    # Found newer lua 5.1 libs
+    SET(Lua_FOUND TRUE)
+    SET(Lua_VERSION "5.1" CACHE STRING "")
+    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_51} CACHE PATH "")
+    SET(Lua_LIBRARIES ${Lua_LIBRARY_51} CACHE FILEPATH "")
+    SET(Lua_LIBRARY_NAMES "lua5.1 lua")
+
+  ELSEIF(Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
+
+    # Found older lua 5.0 libs
+    SET(Lua_FOUND TRUE)
+    SET(Lua_VERSION "5.0" CACHE STRING "")
+    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_50} CACHE PATH "")
+    SET(Lua_LIBRARIES ${Lua_LIBRARY_1_50} ${Lua_LIBRARY_2_50} CACHE FILEPATH "")
+    SET(Lua_LIBRARY_NAMES "lua50 lua, lualib50 lualib")
+
+  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+	
+
+  IF (Lua_FOUND)
+    MESSAGE(STATUS "Lua was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${Lua_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${Lua_LIBRARIES}")
+      MESSAGE (STATUS "  libraries:    ${Lua_LIBRARY_NAMES}")
+    ENDIF (VERBOSE_FIND)
+  ELSE (Lua_FOUND)
+    IF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
+      MESSAGE(SEND_ERROR "Lua 5.1 library was not found")
+    ENDIF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
+    IF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+      MESSAGE(SEND_ERROR "Lua 5.1 include path was not found")
+    ENDIF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+
+    IF (Lua_INCLUDE_DIR_50)
+      IF (NOT Lua_LIBRARY_1_50)
+       MESSAGE(SEND_ERROR "Lua 5.0 library "lua" was not found")
+      ENDIF (NOT Lua_LIBRARY_1_50)
+      IF (NOT Lua_LIBRARY_2_50)
+       MESSAGE(SEND_ERROR "Lua 5.0 library "lualib" was not found")
+      ENDIF (NOT Lua_LIBRARY_2_50)
+    ENDIF (Lua_INCLUDE_DIR_50)
+    IF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
+      MESSAGE(SEND_ERROR "Lua 5.0 include path was not found")
+    ENDIF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
+
+    MESSAGE(SEND_ERROR "Lua was not found.")
+  ENDIF (Lua_FOUND)
+
+ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+
Index: /code/branches/physics/cmake/FindODE.cmake
===================================================================
--- /code/branches/physics/cmake/FindODE.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindODE.cmake	(revision 2122)
@@ -0,0 +1,78 @@
+# Find ODE includes and library
+#
+# This module defines
+#  ODE_INCLUDE_DIR
+#  ODE_LIBRARIES, the libraries to link against to use ODE.
+#  ODE_LIB_DIR, the location of the libraries
+#  ODE_FOUND, If false, do not try to use ODE
+#
+# Copyright © 2007, Matt Williams (version for FindOGRE)
+# Modified by Nicolas Schlumberger to make it work on the Tardis-Infrastucture of the ETH Zurich
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+# Adaption from FindOGRE to FindODE by Reto '1337' Grieder
+#                 > www.orxonox.net <
+
+IF (ODE_LIBRARIES AND ODE_INCLUDE_DIR AND ODE_LIB_DIR)
+    SET (ODE_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (ODE_LIBRARIES AND ODE_INCLUDE_DIR AND ODE_LIB_DIR)
+
+IF (WIN32) #Windows
+    FIND_PATH(ODE_INCLUDE_DIR ode/ode.h
+        ../libs/ode-0.10.1/include
+        ${DEPENDENCY_DIR}/ode-0.10.1/include
+    )
+
+    SET(ODE_LIBRARIES debug ode_singled optimized ode_single)
+    FIND_LIBRARY(ODE_LIBDIR NAMES ${ODE_LIBRARIES} PATHS
+        ../libs/ode-0.10.1/lib
+        ${DEPENDENCY_DIR}/ode-0.10.1/lib
+    )
+
+    # Strip the filename from the path
+    IF (ODE_LIBDIR)
+        GET_FILENAME_COMPONENT(ODE_LIBDIR ${ODE_LIBDIR} PATH)
+        SET (ODE_LIB_DIR ${ODE_LIBDIR} CACHE FILEPATH "")
+    ENDIF (ODE_LIBDIR)
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(ODE ODE /usr/pack/ode-0.9-sd/i686-debian-linux3.1/lib/pkgconfig/ode.pc) # tardis specific hack
+    SET(ODE_INCLUDE_DIR ${ODE_INCLUDE_DIRS})
+    SET(ODE_LIB_DIR ${ODE_LIBDIR})
+    SET(ODE_LIBRARIES ${ODE_LIBRARIES})
+ENDIF (WIN32)
+
+#Do some preparation
+SEPARATE_ARGUMENTS(ODE_INCLUDE_DIR)
+SEPARATE_ARGUMENTS(ODE_LIBRARIES)
+
+SET (ODE_INCLUDE_DIR ${ODE_INCLUDE_DIR} CACHE PATH "")
+SET (ODE_LIBRARIES ${ODE_LIBRARIES} CACHE STRING "")
+SET (ODE_LIB_DIR ${ODE_LIB_DIR} CACHE PATH "")
+
+IF (ODE_INCLUDE_DIR AND ODE_LIBRARIES AND ODE_LIB_DIR)
+    SET(ODE_FOUND TRUE)
+ENDIF (ODE_INCLUDE_DIR AND ODE_LIBRARIES AND ODE_LIB_DIR)
+
+IF (ODE_FOUND)
+    IF (NOT ODE_FIND_QUIETLY)
+        MESSAGE(STATUS "ODE was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${ODE_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${ODE_LIB_DIR}")
+            MESSAGE (STATUS "  libraries:    ${ODE_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT ODE_FIND_QUIETLY)
+ELSE (ODE_FOUND)
+    IF (NOT ODE_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "ODE include path was not found.")
+    ENDIF (NOT ODE_INCLUDE_DIR)
+    IF (NOT ODE_LIB_DIR)
+        MESSAGE(SEND_ERROR "ODE library was not found.")
+    ENDIF (NOT ODE_LIB_DIR)
+    IF (NOT ODE_LIBRARIES)
+        MESSAGE(SEND_ERROR "ODE libraries not known.")
+    ENDIF (NOT ODE_LIBRARIES)
+ENDIF (ODE_FOUND)
Index: /code/branches/physics/cmake/FindOGRE.cmake
===================================================================
--- /code/branches/physics/cmake/FindOGRE.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindOGRE.cmake	(revision 2122)
@@ -0,0 +1,77 @@
+# Find OGRE includes and library
+#
+# This module defines
+#  OGRE_INCLUDE_DIR
+#  OGRE_LIBRARIES, the libraries to link against to use OGRE.
+#  OGRE_LIB_DIR, the location of the libraries
+#  OGRE_FOUND, If false, do not try to use OGRE
+#
+# Copyright © 2007, Matt Williams
+# Modified by Nicolas Schlumberger to make it work on the Tardis-Infrastucture of the ETH Zurich
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR)
+    SET (OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR)
+
+IF (WIN32) #Windows
+    FIND_PATH(OGRE_INCLUDE_DIR Ogre.h
+        ../libs/ogre/OgreMain/include
+        ${DEPENDENCY_DIR}/ogre-1.4.9/include
+    )
+
+    SET(OGRE_LIBRARIES debug OgreMain_d optimized OgreMain)
+    FIND_LIBRARY(OGRE_LIBDIR NAMES ${OGRE_LIBRARIES} PATHS
+        ../libs/ogre/Samples/Common/bin/Release
+        ${DEPENDENCY_DIR}/ogre-1.4.9/lib
+    )
+
+    # Strip the filename from the path
+    IF (OGRE_LIBDIR)
+        GET_FILENAME_COMPONENT(OGRE_LIBDIR ${OGRE_LIBDIR} PATH)
+        SET (OGRE_LIB_DIR ${OGRE_LIBDIR} CACHE FILEPATH "")
+    ENDIF (OGRE_LIBDIR)
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(OGRE OGRE /usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/pkgconfig/OGRE.pc) # tardis specific hack
+    SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
+    SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
+    SET(OGRE_LIBRARIES ${OGRE_LIBRARIES})
+ENDIF (WIN32)
+
+#Do some preparation
+SEPARATE_ARGUMENTS(OGRE_INCLUDE_DIR)
+SEPARATE_ARGUMENTS(OGRE_LIBRARIES)
+
+SET (OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} CACHE PATH "")
+SET (OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
+SET (OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "")
+
+IF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES AND OGRE_LIB_DIR)
+    SET(OGRE_FOUND TRUE)
+ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES AND OGRE_LIB_DIR)
+
+IF (OGRE_FOUND)
+    IF (NOT OGRE_FIND_QUIETLY)
+        MESSAGE(STATUS "Ogre was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${OGRE_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${OGRE_LIB_DIR}")
+            MESSAGE (STATUS "  libraries:    ${OGRE_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT OGRE_FIND_QUIETLY)
+ELSE (OGRE_FOUND)
+    IF (NOT OGRE_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "Ogre include path was not found.")
+    ENDIF (NOT OGRE_INCLUDE_DIR)
+    IF (NOT OGRE_LIB_DIR)
+        MESSAGE(SEND_ERROR "Ogre library was not found.")
+    ENDIF (NOT OGRE_LIB_DIR)
+    IF (NOT OGRE_LIBRARIES)
+        MESSAGE(SEND_ERROR "Ogre libraries not known.")
+    ENDIF (NOT OGRE_LIBRARIES)
+ENDIF (OGRE_FOUND)
Index: /code/branches/physics/cmake/FindOggVorbis.cmake
===================================================================
--- /code/branches/physics/cmake/FindOggVorbis.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindOggVorbis.cmake	(revision 2122)
@@ -0,0 +1,156 @@
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+  SET(OGG_FIND_QUIETLY TRUE)
+ENDIF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+
+IF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY)
+  SET(VORBIS_FIND_QUIETLY TRUE)
+ENDIF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY) 
+
+
+#SET(OGGVORBIS_LIBRARY_DIR "/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/lib")
+#SET(OGGVORBIS_LIBRARY "-L ${OGGVORBIS_LIBRARY_DIR} -lvorbisenc -lvorbisfile -logg -lvorbis ")
+#SET(OGGVORBIS_INCLUDE_DIR "/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include")
+
+#
+# Includes
+#
+
+FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include 		# Tardis specific hack
+  /usr/local/include
+  /usr/include
+  /sw/include
+  /opt/local/include
+  /opt/csw/include
+  /opt/csw/include
+  /opt/include
+  ../libs/libogg-1.1.3/include
+  ${DEPENDENCY_DIR}/libogg-1.1.3/include
+  )
+
+FIND_PATH(VORBIS_INCLUDE_DIR vorbis/codec.h
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include 		# Tardis specific hack
+  /usr/local/include
+  /usr/include
+  /sw/include
+  /opt/local/include
+  /opt/csw/include
+  /opt/csw/include
+  /opt/include
+  ../libs/libvorbis-1.2.0/include
+  ${DEPENDENCY_DIR}/libvorbis-1.2.0/include
+  )
+
+#
+# Libs
+#
+
+FIND_LIBRARY(OGG_LIBRARY
+  NAMES ogg
+  PATHS
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+  /usr/local/lib
+  /usr/lib
+  /sw/lib
+  /opt/local/lib
+  /opt/csw/lib
+  /opt/lib
+  ../libs/libogg-1.1.3/src/.libs
+  ${DEPENDENCY_DIR}/libogg-1.1.3/lib
+  )
+
+FIND_LIBRARY(VORBIS_LIBRARY
+  NAMES vorbis
+  PATHS
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+  /usr/local/lib
+  /usr/lib
+  /sw/lib
+  /opt/local/lib
+  /opt/csw/lib
+  /opt/lib
+  ../libs/libvorbis-1.2.0/lib/.libs
+  ${DEPENDENCY_DIR}/libvorbis-1.2.0/lib
+  )
+
+#FIND_LIBRARY(VORBISENC_LIBRARY
+#  NAMES vorbisenc
+#  PATHS
+#  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+#  /usr/local/lib
+#  /usr/lib
+#  /sw/lib
+#  /opt/local/lib
+#  /opt/csw/lib
+#  /opt/lib
+#  ../libs/libvorbis-1.2.0/lib/.libs
+#  )
+
+FIND_LIBRARY(VORBISFILE_LIBRARY
+  NAMES vorbisfile
+  PATHS
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+  /usr/local/lib
+  /usr/lib
+  /sw/lib
+  /opt/local/lib
+  /opt/csw/lib
+  /opt/lib
+  ../libs/libvorbis-1.2.0/lib/.libs
+  ${DEPENDENCY_DIR}/libvorbis-1.2.0/lib
+  )
+
+SET (OGG_FOUND "NO")
+
+IF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+  SET (OGG_FOUND "YES")
+  IF (NOT OGG_FIND_QUIETLY)
+    MESSAGE (STATUS "Ogg was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${OGG_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${OGG_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    ogg")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT OGG_FIND_QUIETLY)
+ELSE (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+  IF (NOT OGG_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "Ogg include path was not found.")
+  ENDIF (NOT OGG_INCLUDE_DIR)
+  IF (NOT OGG_LIBRARY)
+    MESSAGE (SEND_ERROR "Ogg library was not found.")
+  ENDIF (NOT OGG_LIBRARY)
+ENDIF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+
+
+SET (VORBIS_FOUND "NO")
+
+IF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)# AND VORBISENC_LIBRARY)
+  SET (VORBIS_FOUND "YES")
+  IF (NOT VORBIS_FIND_QUIETLY)
+    MESSAGE (STATUS "Vorbis was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${VORBIS_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${VORBIS_LIBRARY}")
+      #MESSAGE (STATUS "  library path: ${VORBISENC_LIBRARY}")
+      MESSAGE (STATUS "  library path: ${VORBISFILE_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    vorbis vorbisenc vorbisfile")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT VORBIS_FIND_QUIETLY)
+ELSE (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)# AND VORBISENC_LIBRARY)
+  IF (NOT VORBIS_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "Vorbis include path was not found.")
+  ENDIF (NOT VORBIS_INCLUDE_DIR)
+  IF (NOT VORBIS_LIBRARY)
+    MESSAGE (SEND_ERROR "Vorbis library \"vorbis\" was not found.")
+  ENDIF (NOT VORBIS_LIBRARY)
+  #IF (NOT VORBISENC_LIBRARY)
+  #  MESSAGE (SEND_ERROR "Vorbis library \"vorbisenc\" was not found.")
+  #ENDIF (NOT VORBISENC_LIBRARY)
+  IF (NOT VORBISFILE_LIBRARY)
+    MESSAGE (SEND_ERROR "Vorbis library \"vorbisfile\" was not found.")
+  ENDIF (NOT VORBISFILE_LIBRARY)
+ENDIF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)# AND VORBISENC_LIBRARY)
+
Index: /code/branches/physics/cmake/FindOpenAL.cmake
===================================================================
--- /code/branches/physics/cmake/FindOpenAL.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindOpenAL.cmake	(revision 2122)
@@ -0,0 +1,113 @@
+# - Locate OpenAL
+# This module defines
+#  OPENAL_LIBRARY
+#  OPENAL_FOUND, if false, do not try to link to OpenAL
+#  OPENAL_INCLUDE_DIR, where to find the headers
+#
+# $OPENALDIR is an environment variable that would
+# correspond to the ./configure --prefix=$OPENALDIR
+# used in building OpenAL.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+  SET(OPENAL_FIND_QUIETLY TRUE)
+ENDIF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+
+# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of
+# OPENAL_LIBRARY to override this selection.
+# Tiger will include OpenAL as part of the System.
+# But for now, we have to look around.
+# Other (Unix) systems should be able to utilize the non-framework paths.
+FIND_PATH(OPENAL_INCLUDE_DIR AL/al.h
+  $ENV{OPENALDIR}/include
+  ~/Library/Frameworks/OpenAL.framework/Headers
+  /Library/Frameworks/OpenAL.framework/Headers
+  /System/Library/Frameworks/OpenAL.framework/Headers # Tiger
+  /usr/pack/openal-0.0.8-cl/include # Tardis specific hack
+  /usr/local/include/
+  /usr/local/include/OpenAL
+  /usr/local/include
+  /usr/include/
+  /usr/include/OpenAL
+  /usr/include
+  /sw/include # Fink
+  /sw/include/OpenAL
+  /sw/include
+  /opt/local/include # DarwinPorts
+  /opt/local/include/OpenAL
+  /opt/local/include
+  /opt/csw/include # Blastwave
+  /opt/csw/include/OpenAL
+  /opt/csw/include
+  /opt/include
+  /opt/include/OpenAL
+  /opt/include
+  ../libs/openal-0.0.8/common/include
+  ${DEPENDENCY_DIR}/openal-1.1/include
+  )
+# I'm not sure if I should do a special casing for Apple. It is
+# unlikely that other Unix systems will find the framework path.
+# But if they do ([Next|Open|GNU]Step?),
+# do they want the -framework option also?
+IF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" OPENAL_FRAMEWORK_PATH_TMP ${OPENAL_INCLUDE_DIR})
+  IF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is in default search path, don't need to use -F
+    SET (OPENAL_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ELSE("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is not /Library/Frameworks, need to use -F
+    SET(OPENAL_LIBRARY "-F${OPENAL_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ENDIF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+    OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+    )
+  # Clear the temp variable so nobody can see it
+  SET(OPENAL_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
+
+ELSE(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+  FIND_LIBRARY(OPENAL_LIBRARY
+    NAMES openal al OpenAL32
+    PATHS
+    $ENV{OPENALDIR}/lib
+    $ENV{OPENALDIR}/libs
+    /usr/pack/openal-0.0.8-cl/i686-debian-linux3.1/lib
+    /usr/local/lib
+    /usr/lib
+    /sw/lib
+    /opt/local/lib
+    /opt/csw/lib
+    /opt/lib
+    ../libs/openal-0.0.8/src/.libs
+    ${DEPENDENCY_DIR}/openal-1.1/lib
+    )
+ENDIF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+
+SET (OPENAL_FOUND "NO")
+
+IF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+  SET (OPENAL_FOUND "YES")
+  IF (NOT OPENAL_FIND_QUIETLY)
+    MESSAGE (STATUS "OpenAL was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${OPENAL_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${OPENAL_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    openal al OpenAL32")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT OPENAL_FIND_QUIETLY)
+ELSE (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+  IF (NOT OPENAL_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "OpenAL include path was not found.")
+  ENDIF (NOT OPENAL_INCLUDE_DIR)
+  IF (NOT OPENAL_LIBRARY)
+    MESSAGE (SEND_ERROR "OpenAL library was not found.")
+  ENDIF (NOT OPENAL_LIBRARY)
+ENDIF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+
+
Index: /code/branches/physics/cmake/FindPkgConfig.cmake
===================================================================
--- /code/branches/physics/cmake/FindPkgConfig.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindPkgConfig.cmake	(revision 2122)
@@ -0,0 +1,360 @@
+# - a pkg-config module for CMake
+#
+# Usage:
+#   pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+#     checks for all the given modules
+#
+#   pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+#     checks for given modules and uses the first working one
+#
+# When the 'REQUIRED' argument was set, macros will fail with an error
+# when module(s) could not be found
+#
+# It sets the following variables:
+#   PKG_CONFIG_FOUND         ... true iff pkg-config works on the system
+#   PKG_CONFIG_EXECUTABLE    ... pathname of the pkg-config program
+#   <PREFIX>_FOUND           ... set to 1 iff module(s) exist
+#
+# For the following variables two sets of values exist; first one is the
+# common one and has the given PREFIX. The second set contains flags
+# which are given out when pkgconfig was called with the '--static'
+# option.
+#   <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
+#   <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
+#   <XPREFIX>_LDFLAGS        ... all required linker flags
+#   <XPREFIX>_LDFLAGS_OTHERS ... all other linker flags
+#   <XPREFIX>_INCLUDE_DIRS   ... the '-I' preprocessor flags (w/o the '-I')
+#   <XPREFIX>_CFLAGS         ... all required cflags
+#   <XPREFIX>_CFLAGS_OTHERS  ... the other compiler flags
+#
+#   <XPREFIX> = <PREFIX>        for common case
+#   <XPREFIX> = <PREFIX>_STATIC for static linking
+#
+# There are some special variables whose prefix depends on the count
+# of given modules. When there is only one module, <PREFIX> stays
+# unchanged. When there are multiple modules, the prefix will be
+# changed to <PREFIX>_<MODNAME>:
+#   <XPREFIX>_VERSION    ... version of the module
+#   <XPREFIX>_PREFIX     ... prefix-directory of the module
+#   <XPREFIX>_INCLUDEDIR ... include-dir of the module
+#   <XPREFIX>_LIBDIR     ... lib-dir of the module
+#
+#   <XPREFIX> = <PREFIX>  when |MODULES| == 1, else
+#   <XPREFIX> = <PREFIX>_<MODNAME>
+#
+# A <MODULE> parameter can have the following formats:
+#   {MODNAME}            ... matches any version
+#   {MODNAME}>={VERSION} ... at least version <VERSION> is required
+#   {MODNAME}={VERSION}  ... exactly version <VERSION> is required
+#   {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
+#
+# Examples
+#   pkg_check_modules (GLIB2   glib-2.0)
+#
+#   pkg_check_modules (GLIB2   glib-2.0>=2.10)
+#     requires at least version 2.10 of glib2 and defines e.g.
+#       GLIB2_VERSION=2.10.3
+#
+#   pkg_check_modules (FOO     glib-2.0>=2.10 gtk+-2.0)
+#     requires both glib2 and gtk2, and defines e.g.
+#       FOO_glib-2.0_VERSION=2.10.3
+#       FOO_gtk+-2.0_VERSION=2.8.20
+#
+#   pkg_check_modules (XRENDER REQUIRED xrender)
+#     defines e.g.:
+#       XRENDER_LIBRARIES=Xrender;X11
+#       XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
+#
+#   pkg_search_module (BAR     libxml-2.0 libxml2 libxml>=2)
+
+
+# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+# Redistribution and use, with or without modification, are permitted
+# provided that the following conditions are met:
+# 
+#    1. Redistributions must retain the above copyright notice, this
+#       list of conditions and the following disclaimer.
+#    2. The name of the author may not be used to endorse or promote
+#       products derived from this software without specific prior
+#       written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+### Common stuff ####
+set(PKG_CONFIG_VERSION 1)
+set(PKG_CONFIG_FOUND   0)
+
+find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
+mark_as_advanced(PKG_CONFIG_EXECUTABLE)
+
+if(PKG_CONFIG_EXECUTABLE)
+  set(PKG_CONFIG_FOUND 1)
+endif(PKG_CONFIG_EXECUTABLE)
+
+
+# Unsets the given variables
+macro(_pkgconfig_unset var)
+  set(${var} "" CACHE INTERNAL "")
+endmacro(_pkgconfig_unset)
+
+macro(_pkgconfig_set var value)
+  set(${var} ${value} CACHE INTERNAL "")
+endmacro(_pkgconfig_set)
+
+# Invokes pkgconfig, cleans up the result and sets variables
+macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
+  set(_pkgconfig_invoke_result)
+
+  execute_process(
+    COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist}
+    OUTPUT_VARIABLE _pkgconfig_invoke_result
+    RESULT_VARIABLE _pkgconfig_failed)
+
+  if (_pkgconfig_failed)
+    set(_pkgconfig_${_varname} "")
+    _pkgconfig_unset(${_prefix}_${_varname})
+  else(_pkgconfig_failed)
+    string(REGEX REPLACE "[\r\n]"                  " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+    string(REGEX REPLACE " +$"                     ""  _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+
+    if (NOT ${_regexp} STREQUAL "")
+      string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+    endif(NOT ${_regexp} STREQUAL "")
+
+    separate_arguments(_pkgconfig_invoke_result)
+
+    #message(STATUS "  ${_varname} ... ${_pkgconfig_invoke_result}")
+    set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result})
+    _pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}")
+  endif(_pkgconfig_failed)
+endmacro(_pkgconfig_invoke)
+
+# Invokes pkgconfig two times; once without '--static' and once with
+# '--static'
+macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
+  _pkgconfig_invoke("${_pkglist}" ${_prefix}        ${_varname} "${cleanup_regexp}" ${ARGN})
+  _pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static  ${ARGN})
+endmacro(_pkgconfig_invoke_dyn)
+
+# Splits given arguments into options and a package list
+macro(_pkgconfig_parse_options _result _is_req)
+  set(${_is_req} 0)
+  
+  foreach(_pkg ${ARGN})
+    if (_pkg STREQUAL "REQUIRED")
+      set(${_is_req} 1)
+    endif (_pkg STREQUAL "REQUIRED")
+  endforeach(_pkg ${ARGN})
+
+  set(${_result} ${ARGN})
+  list(REMOVE_ITEM ${_result} "REQUIRED")
+endmacro(_pkgconfig_parse_options)
+
+###
+macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
+  _pkgconfig_unset(${_prefix}_FOUND)
+  _pkgconfig_unset(${_prefix}_VERSION)
+  _pkgconfig_unset(${_prefix}_PREFIX)
+  _pkgconfig_unset(${_prefix}_INCLUDEDIR)
+  _pkgconfig_unset(${_prefix}_LIBDIR)
+  _pkgconfig_unset(${_prefix}_LIBS)
+  _pkgconfig_unset(${_prefix}_LIBS_L)
+  _pkgconfig_unset(${_prefix}_LIBS_PATHS)
+  _pkgconfig_unset(${_prefix}_LIBS_OTHER)
+  _pkgconfig_unset(${_prefix}_CFLAGS)
+  _pkgconfig_unset(${_prefix}_CFLAGS_I)
+  _pkgconfig_unset(${_prefix}_CFLAGS_OTHER)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBDIR)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS_L)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER)
+  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS)
+  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I)
+  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER)
+
+  # create a better addressable variable of the modules and calculate its size
+  set(_pkg_check_modules_list ${ARGN})
+  list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt)
+
+  if(PKG_CONFIG_EXECUTABLE)
+    # give out status message telling checked module
+    if (NOT ${_is_silent})
+      if (_pkg_check_modules_cnt EQUAL 1)
+        message(STATUS "checking for module '${_pkg_check_modules_list}'")
+      else(_pkg_check_modules_cnt EQUAL 1)
+        message(STATUS "checking for modules '${_pkg_check_modules_list}'")
+      endif(_pkg_check_modules_cnt EQUAL 1)
+    endif(NOT ${_is_silent})
+    
+    set(_pkg_check_modules_packages)
+    set(_pkg_check_modules_failed)
+
+    # iterate through module list and check whether they exist and match the required version
+    foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
+      set(_pkg_check_modules_exist_query)
+
+      # check whether version is given
+      if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
+        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op   "${_pkg_check_modules_pkg}")
+        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver  "${_pkg_check_modules_pkg}")
+      else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+        set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
+        set(_pkg_check_modules_pkg_op)
+        set(_pkg_check_modules_pkg_ver)
+      endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+
+      # handle the operands
+      if (_pkg_check_modules_pkg_op STREQUAL ">=")
+        list(APPEND _pkg_check_modules_exist_query --atleast-version)
+      endif(_pkg_check_modules_pkg_op STREQUAL ">=")
+
+      if (_pkg_check_modules_pkg_op STREQUAL "=")
+        list(APPEND _pkg_check_modules_exist_query --exact-version)
+      endif(_pkg_check_modules_pkg_op STREQUAL "=")
+      
+      if (_pkg_check_modules_pkg_op STREQUAL "<=")
+        list(APPEND _pkg_check_modules_exist_query --max-version)
+      endif(_pkg_check_modules_pkg_op STREQUAL "<=")
+
+      # create the final query which is of the format:
+      # * --atleast-version <version> <pkg-name>
+      # * --exact-version <version> <pkg-name>      
+      # * --max-version <version> <pkg-name>
+      # * --exists <pkg-name>
+      if (_pkg_check_modules_pkg_op)
+        list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}")
+      else(_pkg_check_modules_pkg_op)
+        list(APPEND _pkg_check_modules_exist_query --exists)
+      endif(_pkg_check_modules_pkg_op)
+
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
+
+      list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
+      list(APPEND _pkg_check_modules_packages    "${_pkg_check_modules_pkg_name}")
+
+      # execute the query
+      execute_process(
+        COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query}
+        RESULT_VARIABLE _pkgconfig_retval)
+
+      # evaluate result and tell failures
+      if (_pkgconfig_retval)
+        if(NOT ${_is_silent})
+          message(STATUS "  package '${_pkg_check_modules_pkg}' not found")
+        endif(NOT ${_is_silent})
+
+        set(_pkg_check_modules_failed 1)
+      endif(_pkgconfig_retval)
+    endforeach(_pkg_check_modules_pkg)
+
+    if(_pkg_check_modules_failed)
+      # fail when requested
+      if (${_is_required})
+        message(SEND_ERROR "A required package was not found")
+      endif (${_is_required})
+    else(_pkg_check_modules_failed)
+      # when we are here, we checked whether requested modules
+      # exist. Now, go through them and set variables
+      
+      _pkgconfig_set(${_prefix}_FOUND 1)
+      list(LENGTH _pkg_check_modules_packages pkg_count)
+
+      # iterate through all modules again and set individual variables
+      foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages})
+        # handle case when there is only one package required
+        if (pkg_count EQUAL 1)
+          set(_pkg_check_prefix "${_prefix}")
+        else(pkg_count EQUAL 1)
+          set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}")
+        endif(pkg_count EQUAL 1)
+        
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION    ""   --modversion )
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX     ""   --variable=prefix )
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR ""   --variable=includedir )
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR     ""   --variable=libdir )
+
+        message(STATUS "  found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
+      endforeach(_pkg_check_modules_pkg)
+
+      # set variables which are combined for multiple modules
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES           "(^| )-l" --libs-only-l )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS        "(^| )-L" --libs-only-L )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS             ""        --libs )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER       ""        --libs-only-other )
+
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS        "(^| )-I" --cflags-only-I )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )
+    endif(_pkg_check_modules_failed)
+  else(PKG_CONFIG_EXECUTABLE)
+    if (${_is_required})
+      message(SEND_ERROR "pkg-config tool not found")
+    endif (${_is_required})
+  endif(PKG_CONFIG_EXECUTABLE)
+endmacro(_pkg_check_modules_internal)
+
+###
+### User visible macros start here
+###
+
+###
+macro(pkg_check_modules _prefix _module0)
+  # check cached value
+  if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+    _pkgconfig_parse_options   (_pkg_modules _pkg_is_required "${_module0}" ${ARGN})
+    _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules})
+
+    _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+  endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+endmacro(pkg_check_modules)
+
+###
+macro(pkg_search_module _prefix _module0)
+  # check cached value
+  if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+    set(_pkg_modules_found 0)
+    _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN})
+
+    message(STATUS "checking for one of the modules '${_pkg_modules_alt}'")
+
+    # iterate through all modules and stop at the first working one.
+    foreach(_pkg_alt ${_pkg_modules_alt})
+      if(NOT _pkg_modules_found)
+        _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}")
+      endif(NOT _pkg_modules_found)
+
+      if (${_prefix}_FOUND)
+        set(_pkg_modules_found 1)
+      endif(${_prefix}_FOUND)
+    endforeach(_pkg_alt)
+
+    if (NOT ${_prefix}_FOUND)
+      if(${_pkg_is_required})
+        message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found")
+      endif(${_pkg_is_required})
+    endif(NOT ${_prefix}_FOUND)
+    
+    _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+  endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})  
+endmacro(pkg_search_module)
+
+### Local Variables:
+### mode: cmake
+### End:
Index: /code/branches/physics/cmake/FindTCL.cmake
===================================================================
--- /code/branches/physics/cmake/FindTCL.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindTCL.cmake	(revision 2122)
@@ -0,0 +1,90 @@
+# - Find Tcl includes and libraries.
+# This module finds if TCL is installed and determines where the
+# include files and libraries are. It also determines what the name of
+# the library is. This code sets the following variables:
+#  TCL_LIBRARY        = path to Tcl library (tcl tcl80)
+#  TCL_LIBRARY_DEBUG  = path to Tcl library (debug)
+#  TCL_INCLUDE_PATH   = path to where tcl.h can be found
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+  SET(TCL_FIND_QUIETLY TRUE)
+ENDIF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+
+SET (TCLTK_POSSIBLE_LIB_PATHS
+  "${TCL_TCLSH_PATH}/../lib"
+  "${TK_WISH_PATH}/../lib"
+  "${TCL_INCLUDE_PATH}/../lib"
+  "${TK_INCLUDE_PATH}/../lib"
+  "$ENV{ProgramFiles}/Tcl/Lib"
+  "C:/Program Files/Tcl/lib" 
+  "C:/Tcl/lib" 
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib
+  /usr/lib 
+  /usr/local/lib
+  /usr/pack/tcltk-8.4.9.linux-mo/lib
+  ../libs/tcl8.5.2/win
+  ../libs/tcl8.5.2/unix
+  ../libs/tcl8.5.2/macosx
+  ${DEPENDENCY_DIR}/tcl-8.5.2/lib
+)
+
+FIND_LIBRARY(TCL_LIBRARY
+  NAMES tcl tcl85 tcl8.5 tcl84 tcl8.4 tcl85t
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TCL_LIBRARY_DEBUG
+  NAMES tcld tcl85d tcl8.5d tcl84d tcl8.4d
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+SET (TCLTK_POSSIBLE_INCLUDE_PATHS
+  ${TCL_TCLSH_PATH}/../include
+  ${TK_WISH_PATH}/../include
+  "${TCL_LIBRARY_PATH}/../include"
+  "${TK_LIBRARY_PATH}/../include"
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include
+  "$ENV{ProgramFiles}/Tcl/include"
+  "C:/Program Files/Tcl/include"
+  C:/Tcl/include
+  /usr/include
+  /usr/local/include
+  /usr/include/tcl8.5
+  /usr/include/tcl8.4
+  ../libs/tcl8.5.2/generic
+  ${DEPENDENCY_DIR}/tcl-8.5.2/include
+)
+
+FIND_PATH(TCL_INCLUDE_PATH tcl.h
+  ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+)
+
+
+IF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+  IF (NOT TCL_FIND_QUIETLY)
+    MESSAGE(STATUS "Tcl was found")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${TCL_INCLUDE_PATH}")
+      MESSAGE (STATUS "  library path: ${TCL_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    tcld tcl85d tcl8.5d tcl84d tcl8.4d")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT TCL_FIND_QUIETLY)
+ELSE (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+  IF (NOT TCL_INCLUDE_PATH)
+    MESSAGE(SEND_ERROR "Tcl include path was not found.")
+  ENDIF (NOT TCL_INCLUDE_PATH)
+  IF (NOT TCL_LIBRARY )
+    MESSAGE(SEND_ERROR "Tcl library was not found.")
+  ENDIF (NOT TCL_LIBRARY )
+ENDIF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+
+IF(TCL_INCLUDE_PATH)
+  IF(TCL_LIBRARY)
+    SET(TCL_FOUND 1)
+  ENDIF(TCL_LIBRARY)
+ENDIF(TCL_INCLUDE_PATH)
Index: /code/branches/physics/cmake/FindZLIB.cmake
===================================================================
--- /code/branches/physics/cmake/FindZLIB.cmake	(revision 2122)
+++ /code/branches/physics/cmake/FindZLIB.cmake	(revision 2122)
@@ -0,0 +1,76 @@
+# - Find zlib
+# Find the native ZLIB includes and library
+#
+#  ZLIB_INCLUDE_DIR - where to find zlib.h, etc.
+#  ZLIB_LIBRARY     - List of libraries when using zlib.
+#  ZLIB_FOUND       - True if zlib found.
+#
+#  Modified by Nicolas Schlumberger, (c) 2007
+#  to make it work on the Tardis Infrastucture of the ETH Zurich
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (ZLIB_INCLUDE_DIR)
+  SET(ZLIB_FIND_QUIETLY TRUE)
+ENDIF (ZLIB_INCLUDE_DIR)
+
+IF(UNIX)
+  FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
+    /usr/pack/zziplib-0.13.49-sd/include/
+    /usr/local/include
+    /usr/include
+  )
+
+  SET(ZLIB_NAMES z zlib zdll)
+  FIND_LIBRARY(ZLIB_LIBRARY
+    NAMES ${ZLIB_NAMES}
+    PATHS /usr/pack/zziplib-0.13.49-sd/i686-debian-linux3.1/lib/ /usr/lib /usr/local/lib
+  )
+ENDIF(UNIX)
+
+IF(WIN32)
+  IF(EXISTS "../libs/zlib")
+    SET (ZLIB_LIBRARY_DIR "../libs/zlib")
+  ENDIF(EXISTS "../libs/zlib")
+
+  FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
+    ../libs/zlib/include
+    ${DEPENDENCY_DIR}/zlib-1.2.3/include
+  )
+
+  FIND_LIBRARY(ZLIB_LIBRARY
+    NAMES zlib
+    PATHS ${ZLIB_LIBRARY_DIR}
+    ${DEPENDENCY_DIR}/zlib-1.2.3/lib
+  )
+ENDIF(WIN32)
+
+SET(ZLIB_FOUND FALSE)
+IF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+  SET(ZLIB_FOUND TRUE)
+ENDIF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+
+IF (ZLIB_FOUND)
+  IF (NOT ZLIB_FIND_QUIETLY)
+    MESSAGE(STATUS "ZLIB was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${ZLIB_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${ZLIB_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    zlib")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT ZLIB_FIND_QUIETLY)
+ELSE (ZLIB_FOUND)
+  IF (NOT ZLIB_INCLUDE_DIR)
+    MESSAGE(SEND_ERROR "ZLIB include path was not found.")
+  ENDIF (NOT ZLIB_INCLUDE_DIR)
+  IF (NOT ZLIB_LIBRARY)
+    MESSAGE(SEND_ERROR "ZLIB was not found.")
+    MESSAGE(STATUS "Looked for Z libraries named ${ZLIBS_NAMES}.")
+  ENDIF (NOT ZLIB_LIBRARY)
+ENDIF (ZLIB_FOUND)
+
+MARK_AS_ADVANCED(
+  ZLIB_LIBRARY
+  ZLIB_INCLUDE_DIR
+)
Index: /code/branches/physics/cmakeclearcache
===================================================================
--- /code/branches/physics/cmakeclearcache	(revision 2122)
+++ /code/branches/physics/cmakeclearcache	(revision 2122)
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Clears the cmake cache
+# Author: Nicolas Perrenoud <nicolape@ee.ethz.ch>
+# Co-Author: Nicolas Schlumberger <nico_at_orxonox.net>
+
+find . -name "CMakeCache.txt" -exec rm -f {} \;
+find . -name "cmake_install.cmake" -exec rm -f {} \;
+find . -name "CMakeFiles" -exec rm -fr {} \;
+find . -name "Makefile" -exec rm -fr {} \;
+
+echo "Cmake Cache cleared!"
Index: /code/branches/physics/init/common/def_keybindings.ini
===================================================================
--- /code/branches/physics/init/common/def_keybindings.ini	(revision 2122)
+++ /code/branches/physics/init/common/def_keybindings.ini	(revision 2122)
@@ -0,0 +1,260 @@
+[Keys]
+KeyA="scale -1 moveRightLeft"
+KeyABNT_C1=
+KeyABNT_C2=
+KeyAT=
+KeyAX=
+KeyApostrophe=
+KeyApps=
+KeyB=
+KeyBack=
+KeyBackslash=
+KeyC=switchCamera
+KeyCalculator=
+KeyCapsLock=
+KeyColon=
+KeyComma=
+KeyConvert=
+KeyD="scale 1 moveRightLeft"
+KeyDelete=
+KeyDivide=
+KeyDown=
+KeyE="scale -1 rotateRoll"
+KeyEnd=
+KeyEquals=
+KeyEscape="exit"
+KeyF="scale -1 moveUpDown"
+KeyF1=
+KeyF10=
+KeyF11=
+KeyF12=
+KeyF13=
+KeyF14=
+KeyF15=
+KeyF2=
+KeyF3=
+KeyF4=
+KeyF5=
+KeyF6=
+KeyF7=
+KeyF8=
+KeyF9=
+KeyG=greet
+KeyGrave=
+KeyH=
+KeyHome=
+KeyI=
+KeyInsert=
+KeyJ=
+KeyK=
+KeyKana=
+KeyKanji=
+KeyL=
+KeyLeft=
+KeyLeftAlt=
+KeyLeftBracket=
+KeyLeftControl=
+KeyLeftShift=
+KeyLeftWindows=
+KeyLessThan=
+KeyM=
+KeyMail=
+KeyMediaSelect=
+KeyMediaStop=
+KeyMinus=
+KeyMultiply=
+KeyMute=
+KeyMyComputer=
+KeyN=
+KeyNextTrack=
+KeyNoConvert=
+KeyNumLock=
+KeyNumRow0=
+KeyNumRow1=
+KeyNumRow2=
+KeyNumRow3=
+KeyNumRow4=
+KeyNumRow5=
+KeyNumRow6=
+KeyNumRow7=
+KeyNumRow8=
+KeyNumRow9=
+KeyNumpad0=
+KeyNumpad1=
+KeyNumpad2=
+KeyNumpad3=
+KeyNumpad4=
+KeyNumpad5=
+KeyNumpad6=
+KeyNumpad7=
+KeyNumpad8=
+KeyNumpad9=
+KeyNumpadAdd=
+KeyNumpadComma=
+KeyNumpadEnter=
+KeyNumpadEquals=
+KeyNumpadPeriod=
+KeyNumpadSubtract=
+KeyO=
+KeyP=
+KeyPageDown=
+KeyPageUp=
+KeyPause=
+KeyPeriod=
+KeyPlayPause=
+KeyPower=
+KeyPreviousTrack=
+KeyQ="scale 1 rotateRoll"
+KeyR="scale 1 moveUpDown"
+KeyReturn=
+KeyRight=
+KeyRightAlt=
+KeyRightBracket=
+KeyRightControl=
+KeyRightShift=
+KeyRightWindows=
+KeyS="scale -1 moveFrontBack"
+KeyScrollLock=
+KeySemicolon=
+KeySlash=
+KeySleep=
+KeySpace=
+KeyStop=
+KeySystemRequest=
+KeyT=
+KeyTab="cycleNavigationFocus"
+KeyU=
+KeyUP=
+KeyUnassigned=
+KeyUnderline=
+KeyUnlabeled=
+KeyV=
+KeyVolumeDown=
+KeyVolumeUp=
+KeyW="scale 1 moveFrontBack"
+KeyWake=
+KeyWebBack=
+KeyWebFavorites=
+KeyWebForward=
+KeyWebHome=
+KeyWebRefresh=
+KeyWebSearch=
+KeyWebStop=
+KeyX=
+KeyY=
+KeyYen=
+KeyZ=
+Key_084=
+Key_085=
+Key_089=
+Key_090=
+Key_091=
+Key_092=
+Key_093=
+Key_094=
+Key_095=
+Key_096=
+Key_097=
+Key_098=
+Key_099=
+Key_103=
+Key_104=
+Key_105=
+Key_106=
+Key_107=
+Key_108=
+Key_109=
+Key_110=
+Key_111=
+Key_112=
+Key_114=
+Key_115=
+Key_117=
+Key_118=
+Key_119=
+Key_120=
+Key_121=
+Key_123=
+Key_125=
+Key_128=
+Key_129=
+Key_130=
+Key_131=
+Key_132=
+Key_133=
+Key_134=
+Key_135=
+Key_136=
+Key_137=
+Key_138=
+Key_139=
+Key_140=
+Key_141=
+Key_143=
+Key_144=
+Key_154=
+Key_155=
+Key_158=
+Key_159=
+Key_163=
+Key_165=
+Key_166=
+Key_167=
+Key_168=
+Key_169=
+Key_170=
+Key_171=
+Key_172=
+Key_173=
+Key_175=
+Key_177=
+Key_180=
+Key_182=
+Key_185=
+Key_186=
+Key_187=
+Key_188=
+Key_189=
+Key_190=
+Key_191=
+Key_192=
+Key_193=
+Key_194=
+Key_195=
+Key_196=
+Key_198=
+Key_202=
+Key_204=
+Key_206=
+Key_212=
+Key_213=
+Key_214=
+Key_215=
+Key_216=
+Key_217=
+Key_218=
+Key_224=
+Key_225=
+Key_226=
+Key_228=
+
+[MouseButtons]
+MouseButton3=
+MouseButton4=
+MouseButton5=
+MouseButton6=
+MouseButton7=
+MouseLeft="fire"
+MouseMiddle=
+MouseRight=
+MouseWheel1Down=
+MouseWheel1Up=
+MouseWheel2Down=
+MouseWheel2Up=
+
+[MouseAxes]
+MouseXNeg="scale -1 rotateYaw"
+MouseXPos="scale 1 rotateYaw"
+MouseYNeg="scale 1 rotatePitch"
+MouseYPos="scale -1 rotatePitch"
+
Index: /code/branches/physics/init/common/def_masterKeybindings.ini
===================================================================
--- /code/branches/physics/init/common/def_masterKeybindings.ini	(revision 2122)
+++ /code/branches/physics/init/common/def_masterKeybindings.ini	(revision 2122)
@@ -0,0 +1,260 @@
+[Keys]
+KeyA=
+KeyABNT_C1=
+KeyABNT_C2=
+KeyAT=
+KeyAX=
+KeyApostrophe=
+KeyApps=
+KeyB=
+KeyBack=
+KeyBackslash=
+KeyC=
+KeyCalculator=
+KeyCapsLock=
+KeyColon=
+KeyComma=
+KeyConvert=
+KeyD=
+KeyDelete=
+KeyDivide=
+KeyDown=
+KeyE=
+KeyEnd=
+KeyEquals=
+KeyEscape=
+KeyF=
+KeyF1="OverlayGroup toggleVisibility Debug"
+KeyF10=
+KeyF11=
+KeyF12=
+KeyF13=
+KeyF14=
+KeyF15=
+KeyF2=
+KeyF3=
+KeyF4=
+KeyF5=
+KeyF6=
+KeyF7=
+KeyF8=
+KeyF9=
+KeyG=
+KeyGrave="openConsole"
+KeyH=
+KeyHome=
+KeyI=
+KeyInsert=
+KeyJ=
+KeyK=
+KeyKana=
+KeyKanji=
+KeyL=
+KeyLeft=
+KeyLeftAlt=
+KeyLeftBracket=
+KeyLeftControl=
+KeyLeftShift=
+KeyLeftWindows=
+KeyLessThan=
+KeyM=
+KeyMail=
+KeyMediaSelect=
+KeyMediaStop=
+KeyMinus=
+KeyMultiply=
+KeyMute=
+KeyMyComputer=
+KeyN=
+KeyNextTrack=
+KeyNoConvert=
+KeyNumLock=
+KeyNumRow0=
+KeyNumRow1=
+KeyNumRow2=
+KeyNumRow3=
+KeyNumRow4=
+KeyNumRow5=
+KeyNumRow6=
+KeyNumRow7=
+KeyNumRow8=
+KeyNumRow9=
+KeyNumpad0=
+KeyNumpad1=
+KeyNumpad2=
+KeyNumpad3=
+KeyNumpad4=
+KeyNumpad5=
+KeyNumpad6=
+KeyNumpad7=
+KeyNumpad8=
+KeyNumpad9=
+KeyNumpadAdd=
+KeyNumpadComma=
+KeyNumpadEnter=
+KeyNumpadEquals=
+KeyNumpadPeriod=
+KeyNumpadSubtract=
+KeyO=
+KeyP=
+KeyPageDown=
+KeyPageUp=
+KeyPause=
+KeyPeriod=
+KeyPlayPause=
+KeyPower=
+KeyPreviousTrack=
+KeyQ=
+KeyR=
+KeyReturn=
+KeyRight=
+KeyRightAlt=
+KeyRightBracket=
+KeyRightControl=
+KeyRightShift=
+KeyRightWindows=
+KeyS=
+KeyScrollLock=
+KeySemicolon=
+KeySlash=
+KeySleep=
+KeySpace=
+KeyStop=
+KeySystemRequest=
+KeyT=
+KeyTab=
+KeyU=
+KeyUP=
+KeyUnassigned=
+KeyUnderline=
+KeyUnlabeled=
+KeyV=
+KeyVolumeDown=
+KeyVolumeUp=
+KeyW=
+KeyWake=
+KeyWebBack=
+KeyWebFavorites=
+KeyWebForward=
+KeyWebHome=
+KeyWebRefresh=
+KeyWebSearch=
+KeyWebStop=
+KeyX=
+KeyY=
+KeyYen=
+KeyZ=
+Key_084=
+Key_085=
+Key_089=
+Key_090=
+Key_091=
+Key_092=
+Key_093=
+Key_094=
+Key_095=
+Key_096=
+Key_097=
+Key_098=
+Key_099=
+Key_103=
+Key_104=
+Key_105=
+Key_106=
+Key_107=
+Key_108=
+Key_109=
+Key_110=
+Key_111=
+Key_112=
+Key_114=
+Key_115=
+Key_117=
+Key_118=
+Key_119=
+Key_120=
+Key_121=
+Key_123=
+Key_125=
+Key_128=
+Key_129=
+Key_130=
+Key_131=
+Key_132=
+Key_133=
+Key_134=
+Key_135=
+Key_136=
+Key_137=
+Key_138=
+Key_139=
+Key_140=
+Key_141=
+Key_143=
+Key_144=
+Key_154=
+Key_155=
+Key_158=
+Key_159=
+Key_163=
+Key_165=
+Key_166=
+Key_167=
+Key_168=
+Key_169=
+Key_170=
+Key_171=
+Key_172=
+Key_173=
+Key_175=
+Key_177=
+Key_180=
+Key_182=
+Key_185=
+Key_186=
+Key_187=
+Key_188=
+Key_189=
+Key_190=
+Key_191=
+Key_192=
+Key_193=
+Key_194=
+Key_195=
+Key_196=
+Key_198=
+Key_202=
+Key_204=
+Key_206=
+Key_212=
+Key_213=
+Key_214=
+Key_215=
+Key_216=
+Key_217=
+Key_218=
+Key_224=
+Key_225=
+Key_226=
+Key_228=
+
+[MouseButtons]
+MouseButton3=
+MouseButton4=
+MouseButton5=
+MouseButton6=
+MouseButton7=
+MouseLeft=
+MouseMiddle=
+MouseRight=
+MouseWheel1Down=
+MouseWheel1Up=
+MouseWheel2Down=
+MouseWheel2Up=
+
+[MouseAxes]
+MouseXNeg=
+MouseXPos=
+MouseYNeg=
+MouseYPos=
+
Index: /code/branches/physics/init/common/irc.tcl
===================================================================
--- /code/branches/physics/init/common/irc.tcl	(revision 2122)
+++ /code/branches/physics/init/common/irc.tcl	(revision 2122)
@@ -0,0 +1,6 @@
+proc every {ms body} { eval $body; after $ms [list every $ms $body] }
+package require irk
+set conn [irk::connect orxonox $nickname]
+irk::join $conn #orxonox
+every 25 {}
+vwait termination
Index: /code/branches/physics/init/common/remote.tcl
===================================================================
--- /code/branches/physics/init/common/remote.tcl	(revision 2122)
+++ /code/branches/physics/init/common/remote.tcl	(revision 2122)
@@ -0,0 +1,2 @@
+set telnetserverthreadid [TclThreadManager create]
+TclThreadManager execute $telnetserverthreadid source telnet_server.tcl
Index: /code/branches/physics/init/common/telnet_server.tcl
===================================================================
--- /code/branches/physics/init/common/telnet_server.tcl	(revision 2122)
+++ /code/branches/physics/init/common/telnet_server.tcl	(revision 2122)
@@ -0,0 +1,209 @@
+ #!/usr/bin/env tclsh
+ # Pseudo-telnet server.  Includes basic auth, but no separate identities
+ # or proper multi-threaded operation, so whoever runs this had better
+ # trust those he gives identities/passwords to and they had better trust
+ # each other too.  Note this script does not support command-line arguments.
+
+ ## The names of this array are IP addresses of hosts that are not permitted
+ ## to connect to any of our services.  Admin account(s) can change this
+ ## at run-time, though this info is not maintained across whole-server shutdowns.
+ array set denyHosts {}
+
+ ## Keep the Tcl-thread busy
+ proc every {ms body} { eval $body; after $ms [list every $ms $body] }
+ every 200 {}
+
+ ## Create a server on the given port with the given name/password map
+ ## and the given core interaction handler.
+ proc telnetServer {port {passmap} {handlerCmd remoteCommand}} {
+     if {$port == 0} {
+         return -code error "Only non-zero port numbers are supported"
+     }
+     set server [socket -server [list connect $port $handlerCmd] $port]
+     global passwords services
+     foreach {id pass} $passmap {set passwords($port,$id) $pass}
+     set services($server) $handlerCmd
+     return $server
+ }
+
+ ## Removes the server on the given port, cleaning up the extra state too.
+ proc closedownServer {server} {
+     global services passwords connections auth
+     set port [lindex [fconfigure $server -sockname] 2]
+     catch {close $server}
+     unset services($server)
+     foreach passmap [array names passwords $port,*] {
+         unset passwords($passmap)
+     }
+     # Hmph!  Have to remove unauthorized connections too, though any
+     # connection which has been authorized can continue safely.
+     foreach {client data} [array get connections] {
+         if {$port == [lindex $data 0] && !$auth($client)} {
+             disconnect $client
+         }
+     }
+ }
+
+ ## Handle an incoming connection to the given server
+ proc connect {serverport handlerCmd client clienthost clientport} {
+     global auth cmd denyHosts connections
+     if {[info exist denyHosts($clienthost)]} {
+         puts stdout "${clienthost}:${clientport} attempted connection"
+         catch {puts $client "Connection denied"}
+         catch {close $client}
+         return
+     }
+     puts stdout "${clienthost}:${clientport} connected on $client"
+     fileevent $client readable "handle $serverport $client"
+     set auth($client) 0
+     set cmd($client) $handlerCmd
+     set connections($client) [list $serverport $clienthost $clientport]
+     fconfigure $client -buffering none
+     catch {puts -nonewline $client "Login: "}
+ }
+
+ ## Disconnect the given client, cleaning up any connection-specific data
+ proc disconnect {client} {
+     catch {close $client}
+     global auth cmd connections
+     unset auth($client)
+     unset cmd($client)
+     unset connections($client)
+     puts stdout "$client disconnected"
+ }
+
+ ## Handle data sent from the client.  Log-in is handled directly by this
+ ## procedure, and requires the name and password on the same line
+ proc handle {serverport client} {
+     global passwords auth cmd
+     if {[gets $client line] < 0} {
+         disconnect $client
+         return
+     }
+     if {[string equal $line "quit"] || [string equal $line "exit"]} {
+         disconnect $client
+         return
+     }
+     if {$auth($client)} {
+         eval $cmd($client) [list $client $line 0]
+         eval $cmd($client) [list $client $line 1]
+         return
+     }
+     foreach {id pass} [split $line] {break}
+     if {![info exist pass]} {
+         catch {puts -nonewline $client "Login: "}
+         return
+     }
+     if {
+         [info exist passwords($serverport,$id)] &&
+         [string equal $passwords($serverport,$id) $pass]
+     } then {
+         set auth($client) 1
+         puts stdout "$id logged in on $client"
+         catch {puts $client "Welcome, $id!"}
+         eval $cmd($client) [list $client $line 1]
+         return
+     }
+     puts stdout "AUTH FAILURE ON $client"
+     catch {puts $client "Unknown name or password"}
+     disconnect $client
+ }
+
+ ## Standard handler for logged-in conversations and prompt-generation.
+ proc execCommand {client line prompt} {
+     global tcl_platform
+     if {$prompt} {
+         catch {puts -nonewline $client "\$ "}
+         return
+     }
+     switch $tcl_platform(platform) {
+         unix {
+             catch {exec sh -c $line <@$client >@$client 2>@$client}
+         }
+         default {
+             catch {exec $line} data
+             puts $client $data
+         }
+     }
+ }
+
+ ## Administration service handler.  Chains to the normal handler for
+ ## everything it doesn't recognise itself.
+ proc admin {client line prompt} {
+     if {$prompt} {
+         catch {puts -nonewline $client "# "}
+         return
+     }
+     set cmd [split $line]
+     global denyHosts connections services
+     if {[string equal $line "shutdown"]} {
+         set ::termination 1
+         puts stdout "Shutdown requested on $client"
+         catch {puts $client "System will shut down as soon as possible"}
+         return -code return "SHUTTING DOWN"
+     } elseif {[string equal [lindex $cmd 0] "deny"]} {
+         set denyHosts([lindex $cmd 1]) 1
+     } elseif {[string equal [lindex $cmd 0] "allow"]} {
+         catch {unset denyHosts([lindex $cmd 1])}
+     } elseif {[string equal $line "denied"]} {
+         foreach host [array names denyHosts] {
+             catch {puts $client $host}
+         }
+     } elseif {[string equal $line "connections"]} {
+         set len 0
+         foreach conn [array names connections] {
+             if {$len < [string length $conn]} {
+                 set len [string length $conn]
+             }
+         }
+         foreach {conn details} [array get connections] {
+             catch {puts $client [format "%-*s = %s" $len $conn $details]}
+         }
+     } elseif {[string equal [lindex $cmd 0] "close"]} {
+         set sock [lindex $cmd 1]
+         if {[info exist connections($sock)]} {
+             disconnect $sock
+         }
+     } elseif {[string equal $line "services"]} {
+         set len 0
+         foreach serv [array names services] {
+             if {$len < [string length $serv]} {
+                 set len [string length $serv]
+             }
+         }
+         foreach {serv handler} [array get services] {
+             set port [lindex [fconfigure $serv -sockname] 2]
+             catch {puts $client [format "%-*s (port %d) = handler %s" $len $serv $port $handler]}
+         }
+     } elseif {[string equal [lindex $cmd 0] "addService"]} {
+         set service [eval telnetServer [lrange $cmd 1 end]]
+         catch {puts $client "Created service as $service"}
+     } elseif {[string equal [lindex $cmd 0] "removeService"]} {
+         set service [lindex $cmd 1]
+         if {[info exist services($service)]} {
+             closedownServer $service
+         }
+     } else {
+         # CHAIN TO DEFAULT
+         execCommand $client $line 0
+     }
+ }
+ 
+ ## Executes a given command
+ proc remoteCommand {client line prompt} {
+     global tcl_platform
+     if {$prompt} {
+         catch {puts -nonewline $client "\$ "}
+         return
+     }
+     catch {eval $line} data
+     puts $client $data
+ }
+
+ telnetServer 2560 {orxonox rocks} remoteCommand
+ telnetServer 2561 {orxadmin *****} admin
+
+ puts stdout "Ready for service"
+
+ vwait termination
+ execute exit
Index: /code/branches/physics/init/orxonox_vc8/debug/orxonox.ini
===================================================================
--- /code/branches/physics/init/orxonox_vc8/debug/orxonox.ini	(revision 2122)
+++ /code/branches/physics/init/orxonox_vc8/debug/orxonox.ini	(revision 2122)
@@ -0,0 +1,2 @@
+[Settings]
+dataPath_=../../../../media/
Index: /code/branches/physics/init/orxonox_vc8/debug/plugins.cfg
===================================================================
--- /code/branches/physics/init/orxonox_vc8/debug/plugins.cfg	(revision 2122)
+++ /code/branches/physics/init/orxonox_vc8/debug/plugins.cfg	(revision 2122)
@@ -0,0 +1,13 @@
+# Defines plugins to load
+
+# Define plugin folder
+PluginFolder=.
+
+# Define plugins
+Plugin=RenderSystem_Direct3D9_d
+Plugin=RenderSystem_GL_d
+Plugin=Plugin_ParticleFX_d
+#Plugin=Plugin_BSPSceneManager_d
+#Plugin=Plugin_OctreeSceneManager_d
+#Plugin=Plugin_CgProgramManager_d
+
Index: /code/branches/physics/init/orxonox_vc8/release/orxonox.ini
===================================================================
--- /code/branches/physics/init/orxonox_vc8/release/orxonox.ini	(revision 2122)
+++ /code/branches/physics/init/orxonox_vc8/release/orxonox.ini	(revision 2122)
@@ -0,0 +1,2 @@
+[Settings]
+dataPath_=../../../../media/
Index: /code/branches/physics/init/orxonox_vc8/release/plugins.cfg
===================================================================
--- /code/branches/physics/init/orxonox_vc8/release/plugins.cfg	(revision 2122)
+++ /code/branches/physics/init/orxonox_vc8/release/plugins.cfg	(revision 2122)
@@ -0,0 +1,13 @@
+# Defines plugins to load
+
+# Define plugin folder
+PluginFolder=.
+
+# Define plugins
+Plugin=RenderSystem_Direct3D9
+Plugin=RenderSystem_GL
+Plugin=Plugin_ParticleFX
+#Plugin=Plugin_BSPSceneManager
+#Plugin=Plugin_OctreeSceneManager
+#Plugin=Plugin_CgProgramManager
+
Index: /code/branches/physics/run
===================================================================
--- /code/branches/physics/run	(revision 2122)
+++ /code/branches/physics/run	(revision 2122)
@@ -0,0 +1,4 @@
+#!/bin/bash
+cd bin
+./run-script $@
+cd ..
Index: /code/branches/physics/src/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,41 @@
+INCLUDE_DIRECTORIES(.)
+INCLUDE_DIRECTORIES(..)
+INCLUDE_DIRECTORIES(orxonox)
+INCLUDE_DIRECTORIES(bullet)
+INCLUDE_DIRECTORIES(ogrebullet/Dynamics)
+INCLUDE_DIRECTORIES(ogrebullet/Collisions)
+
+ADD_SUBDIRECTORY(cpptcl)
+ADD_SUBDIRECTORY(ois)
+ADD_SUBDIRECTORY(tinyxml)
+ADD_SUBDIRECTORY(bullet)
+ADD_SUBDIRECTORY(ogrebullet)
+# ADD_SUBDIRECTORY(ogreode)
+ADD_SUBDIRECTORY(lua)
+ADD_SUBDIRECTORY(tolua)
+
+# Some people may not have CEGUILua installed, espc. with version 0.5
+# And we don't know what lua version it was linked against, so we compile
+# it ourselves.
+# So first, find out what CEGUI version we have.
+
+IF (WIN32)
+    ADD_SUBDIRECTORY(ceguilua-0.6.1/ceguilua)
+    INCLUDE_DIRECTORIES(ceguilua-0.6.1)
+ELSE (WIN32)
+    IF (${CEGUI_VERSION} LESS 0.6.0)
+        ADD_SUBDIRECTORY(ceguilua-0.5.0b/ceguilua)
+        INCLUDE_DIRECTORIES(ceguilua-0.5.0b)
+    ELSE (${CEGUI_VERSION} LESS 0.6.0)
+        ADD_SUBDIRECTORY(ceguilua-0.6.1/ceguilua)
+        INCLUDE_DIRECTORIES(ceguilua-0.6.1)
+    ENDIF (${CEGUI_VERSION} LESS 0.6.0)
+ENDIF (WIN32)
+
+
+# Our own libraries
+ADD_SUBDIRECTORY(util)
+ADD_SUBDIRECTORY(core)
+ADD_SUBDIRECTORY(audio)
+ADD_SUBDIRECTORY(network)
+ADD_SUBDIRECTORY(orxonox)
Index: /code/branches/physics/src/audio/AudioBuffer.cc
===================================================================
--- /code/branches/physics/src/audio/AudioBuffer.cc	(revision 2122)
+++ /code/branches/physics/src/audio/AudioBuffer.cc	(revision 2122)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioBuffer.h"
+
+namespace audio
+{
+    AudioBuffer::AudioBuffer(std::string filename)
+    {
+        // Load wav data into buffers.
+        alGenBuffers(1, &buffer);
+
+        if (alGetError() != AL_NO_ERROR)
+            loaded=AL_FALSE;
+
+        //FIXME deprecated; seems unneeded
+//        alutLoadWAVFile((ALbyte*)filename.c_str(), &format, &data, &size, &freq, &loop);
+        alBufferData(buffer, format, data, size, freq);
+        //FIXME deprecated; seems unneeded
+//        alutUnloadWAV(format, data, size, freq);
+
+        // Do another error check and return.
+        if (alGetError() != AL_NO_ERROR)
+            loaded=AL_FALSE;
+        else
+              loaded=AL_TRUE;
+    }
+
+    AudioBuffer::~AudioBuffer()
+    {
+
+    }
+}
Index: /code/branches/physics/src/audio/AudioBuffer.h
===================================================================
--- /code/branches/physics/src/audio/AudioBuffer.h	(revision 2122)
+++ /code/branches/physics/src/audio/AudioBuffer.h	(revision 2122)
@@ -0,0 +1,61 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioBuffer_H__
+#define _AudioBuffer_H__
+
+#include "AudioPrereqs.h"
+
+#include <string>
+#include <AL/al.h>
+
+namespace audio
+{
+    class _AudioExport AudioBuffer
+    {
+    public:
+        AudioBuffer(std::string filename);
+        ~AudioBuffer();
+
+    private:
+        // Buffers hold sound data.
+        ALuint buffer;
+        // Identifier
+        std::string name;
+        // True if AL was able to load data
+        ALboolean loaded;
+
+        ALenum format;
+        ALsizei size;
+        ALvoid* data;
+        ALsizei freq;
+        ALboolean loop;
+    };
+}
+
+#endif /* _AudioBuffer_H__ */
Index: /code/branches/physics/src/audio/AudioIncludes.h
===================================================================
--- /code/branches/physics/src/audio/AudioIncludes.h	(revision 2122)
+++ /code/branches/physics/src/audio/AudioIncludes.h	(revision 2122)
@@ -0,0 +1,47 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Various headers used in the audio lib. Avoid including this to
+         increase accuracy of header file dependencies.
+*/
+
+#include "AudioPrereqs.h"
+
+#include <iostream>
+#include <vector>
+#include <string>
+
+#include <AL/al.h>
+#include <AL/alc.h>
+#include <AL/alut.h>
+#include <ogg/ogg.h>
+#include <vorbis/codec.h>
+#include <vorbis/vorbisenc.h>
+#include <vorbis/vorbisfile.h>
Index: /code/branches/physics/src/audio/AudioManager.cc
===================================================================
--- /code/branches/physics/src/audio/AudioManager.cc	(revision 2122)
+++ /code/branches/physics/src/audio/AudioManager.cc	(revision 2122)
@@ -0,0 +1,145 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioManager.h"
+
+#include <cstdlib>
+#include <AL/alut.h>
+
+#include "util/Debug.h"
+#include "AudioBuffer.h"
+#include "AudioSource.h"
+#include "AudioStream.h"
+
+namespace audio
+{
+    AudioManager::AudioManager()
+    {
+        ambientPath = "audio/ambient";
+
+        alutInit(NULL, 0);
+    }
+
+    AudioManager::~AudioManager()
+    {
+        for (unsigned int i=0;i<bgSounds.size();i++)
+        {
+            bgSounds[i]->release();
+        }
+        alutExit();
+    }
+
+    void AudioManager::ambientStart()
+    {
+// 		currentBgSound = 0;
+        if (bgSounds.size() > 0)
+        {
+            currentBgSound = rand() % bgSounds.size();
+            if(!bgSounds[currentBgSound]->playback())
+            {
+                COUT(2) << "AudioManager: Ogg refused to play." << std::endl;
+            }
+            else
+            {
+                COUT(3) << "Info: Started playing background sound" << std::endl;
+            }
+        }
+    }
+
+    void AudioManager::ambientStop()
+    {
+        COUT(3) << "Info: Stopped playing background sound" << std::endl;
+    }
+
+    void AudioManager::ambientAdd(std::string file)
+    {
+        std::string path = ambientPath + "/" + file + ".ogg";
+        AudioStream* tmp = new AudioStream(path);
+        tmp->open();
+        if (tmp->isLoaded())
+        {
+            bgSounds.push_back(tmp);
+            COUT(3) << "Info: Added background sound " << file << std::endl;
+        }
+    }
+
+    void AudioManager::tick(float dt)
+    {
+        if (bgSounds.size() > 0)
+        {
+            if (bgSounds[currentBgSound]->isLoaded())
+            {
+                bool playing = bgSounds[currentBgSound]->update();
+                if (!bgSounds[currentBgSound]->playing() && playing)
+                {
+                    if (!bgSounds[currentBgSound]->playback())
+                        COUT(2) << "AudioManager: Ogg abruptly stopped." << std::endl;
+                    else
+                        COUT(2) << "AudioManager: Ogg stream was interrupted." << std::endl;
+
+                }
+                if (!playing)
+                {
+//                    if (currentBgSound < bgSounds.size()-1)
+//                    {
+//                        currentBgSound++;
+//                    }
+//                    else
+//                    {
+//                        currentBgSound=0;
+//                    }
+                    // switch to next sound in list/array
+                    currentBgSound = ++currentBgSound % bgSounds.size();
+
+                    if (!bgSounds[currentBgSound]->isLoaded())
+                    {
+                        bgSounds[currentBgSound]->release();
+                        bgSounds[currentBgSound]->open();
+                    }
+                    bgSounds[currentBgSound]->playback();
+                    COUT(3) << "Info: Playing next background sound" << std::endl;
+                }
+            }
+        }
+    }
+
+    void AudioManager::setPos(std::vector<float> newPosition)
+    {
+
+    }
+
+    void AudioManager::setSpeed(std::vector<float> newSpeed)
+    {
+
+    }
+
+    void AudioManager::setOri(std::vector<float> at, std::vector<float> up)
+    {
+
+    }
+}
Index: /code/branches/physics/src/audio/AudioManager.h
===================================================================
--- /code/branches/physics/src/audio/AudioManager.h	(revision 2122)
+++ /code/branches/physics/src/audio/AudioManager.h	(revision 2122)
@@ -0,0 +1,88 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioManager_H__
+#define _AudioManager_H__
+
+#include "AudioPrereqs.h"
+
+#include <vector>
+#include <string>
+
+namespace audio
+{
+    class _AudioExport AudioManager
+    {
+    public:
+        // Init audio
+        AudioManager();
+
+        // Kill audio and set buffers, sources and memory free
+        ~AudioManager();
+
+        // Set listener position
+        void setPos(std::vector<float> newPosition);
+
+        // Set listener speed
+        void setSpeed(std::vector<float> newSpeed);
+
+        // Set listener orientation (first is direction
+        // the listener looks at, the second is the direction
+        // upwards the listener)
+        void setOri(std::vector<float> at, std::vector<float> up);
+
+        // Update
+        void tick(float dt);
+
+        void ambientAdd(std::string file);
+        void ambientStart();
+        void ambientStop();
+
+    private:
+        // Background sound
+        std::vector<AudioStream*> bgSounds;
+        int currentBgSound;
+
+
+        std::string ambientPath;
+
+        // Vector containing all audio files
+        std::vector<AudioBuffer*> buffers;
+        // Vector containing all audio sources which referer to one buffer
+        std::vector<AudioSource*> sources;
+        // The ambient background sound
+        AudioSource* ambient;
+
+        std::vector<float> listenerPosition;
+        std::vector<float> listenerSpeed;
+        std::vector<float> listenerAt;
+        std::vector<float> listenerup;
+    };
+}
+
+#endif /* _AudioManager_H__ */
Index: /code/branches/physics/src/audio/AudioPrereqs.h
===================================================================
--- /code/branches/physics/src/audio/AudioPrereqs.h	(revision 2122)
+++ /code/branches/physics/src/audio/AudioPrereqs.h	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _AudioPrereqs_H__
+#define _AudioPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( AUDIO_STATIC_BUILD )
+#  ifdef AUDIO_SHARED_BUILD
+#    define _AudioExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _AudioExport
+#    else
+#      define _AudioExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _AudioExport  __attribute__ ((visibility("default")))
+#else
+#  define _AudioExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace audio
+{
+  class AudioBuffer;
+  class AudioManager;
+  class AudioSource;
+  class AudioStream;
+}
+
+//-----------------------------------------------------------------------
+// Warnings
+//-----------------------------------------------------------------------
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+
+// set to 4: conversion from 'ogg_int64_t' to 'long', possible loss of data
+#pragma warning (4 : 4244)
+
+#endif
+
+
+#endif /* _AudioPrereqs_H__ */
Index: /code/branches/physics/src/audio/AudioSource.cc
===================================================================
--- /code/branches/physics/src/audio/AudioSource.cc	(revision 2122)
+++ /code/branches/physics/src/audio/AudioSource.cc	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioSource.h"
+
+namespace audio
+{
+    AudioSource::AudioSource()
+    {
+
+    }
+
+    AudioSource::~AudioSource()
+    {
+
+    }
+}
Index: /code/branches/physics/src/audio/AudioSource.h
===================================================================
--- /code/branches/physics/src/audio/AudioSource.h	(revision 2122)
+++ /code/branches/physics/src/audio/AudioSource.h	(revision 2122)
@@ -0,0 +1,46 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioSource_H__
+#define _AudioSource_H__
+
+#include "AudioPrereqs.h"
+
+namespace audio
+{
+    class _AudioExport AudioSource
+    {
+    public:
+        AudioSource();
+        ~AudioSource();
+
+    private:
+    };
+}
+
+#endif /* _AudioSource_H__ */
Index: /code/branches/physics/src/audio/AudioStream.cc
===================================================================
--- /code/branches/physics/src/audio/AudioStream.cc	(revision 2122)
+++ /code/branches/physics/src/audio/AudioStream.cc	(revision 2122)
@@ -0,0 +1,272 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioStream.h"
+#include "util/Debug.h"
+
+namespace audio
+{
+    AudioStream::AudioStream(std::string path)
+    {
+        this->path = path;
+        loaded = false;
+    }
+
+    void AudioStream::open()
+    {
+        int result;
+
+        oggFile = fopen(path.c_str(), "rb");
+        if (!oggFile)
+        {
+            COUT(2) << "AudioStream: Could not open Ogg file " << path << std::endl;
+            return;
+        }
+
+        if ((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)
+        {
+            fclose(oggFile);
+            COUT(2) << "AudioStream: Could not open Ogg stream. " << errorString(result) << std::endl;
+            return;
+        }
+
+        loaded = true;
+
+        vorbisInfo = ov_info(&oggStream, -1);
+        vorbisComment = ov_comment(&oggStream, -1);
+
+        if (vorbisInfo->channels == 1)
+            format = AL_FORMAT_MONO16;
+        else
+            format = AL_FORMAT_STEREO16;
+
+
+        alGenBuffers(2, buffers);
+        check();
+        alGenSources(1, &source);
+        check();
+
+        alSource3f(source, AL_POSITION,        0.0, 0.0, 0.0);
+        alSource3f(source, AL_VELOCITY,        0.0, 0.0, 0.0);
+        alSource3f(source, AL_DIRECTION,       0.0, 0.0, 0.0);
+        alSourcef (source, AL_ROLLOFF_FACTOR,  0.0          );
+        alSourcei (source, AL_SOURCE_RELATIVE, AL_FALSE     );
+    }
+
+
+
+    void AudioStream::release()
+    {
+        alSourceStop(source);
+        empty();
+        alDeleteSources(1, &source);
+        check();
+        alDeleteBuffers(1, buffers);
+        check();
+
+        ov_clear(&oggStream);
+        loaded = false;
+    }
+
+
+
+    void AudioStream::display()
+    {
+        if (loaded)
+        {
+            COUT(3)
+                << "version         " << vorbisInfo->version         << std::endl
+                << "channels        " << vorbisInfo->channels        << std::endl
+                << "rate (hz)       " << vorbisInfo->rate            << std::endl
+                << "bitrate upper   " << vorbisInfo->bitrate_upper   << std::endl
+                << "bitrate nominal " << vorbisInfo->bitrate_nominal << std::endl
+                << "bitrate lower   " << vorbisInfo->bitrate_lower   << std::endl
+                << "bitrate window  " << vorbisInfo->bitrate_window  << std::endl
+                << std::endl
+                << "vendor " << vorbisComment->vendor << std::endl;
+
+            for (int i = 0; i < vorbisComment->comments; i++)
+            {
+                COUT(3) << "   " << vorbisComment->user_comments[i] << std::endl;
+            }
+
+            COUT(3) << std::endl;
+        }
+    }
+
+
+
+    bool AudioStream::playback()
+    {
+        if (!loaded)
+        {
+            return false;
+        }
+
+        if (playing())
+            return true;
+
+        if (!stream(buffers[0]))
+            return false;
+
+        if (!stream(buffers[1]))
+            return false;
+
+        alSourceQueueBuffers(source, 2, buffers);
+        alSourcePlay(source);
+
+        return true;
+    }
+
+
+
+
+    bool AudioStream::playing()
+    {
+        if (!loaded)
+        {
+            return false;
+        }
+
+        ALenum state;
+        alGetSourcei(source, AL_SOURCE_STATE, &state);
+        return (state == AL_PLAYING);
+    }
+
+
+
+
+    bool AudioStream::update()
+    {
+        int processed;
+        bool active = true;
+
+        alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
+
+        while (processed--)
+        {
+            ALuint buffer;
+
+            alSourceUnqueueBuffers(source, 1, &buffer);
+            check();
+
+            active = stream(buffer);
+
+            alSourceQueueBuffers(source, 1, &buffer);
+            check();
+        }
+
+        if (active==false)
+        {
+            loaded = false;
+        }
+        return active;
+    }
+
+
+
+
+    bool AudioStream::stream(ALuint buffer)
+    {
+        char pcm[BUFFER_SIZE];
+        int  size = 0;
+        int  section;
+        int  result;
+
+        while (size < BUFFER_SIZE)
+        {
+            result = ov_read(&oggStream, pcm + size, BUFFER_SIZE - size, 0, 2, 1, &section);
+
+            if (result > 0)
+                size += result;
+            else
+                if (result < 0)
+                    COUT(2) << "AudioStream: " << errorString(result) << std::endl;
+                else
+                    break;
+        }
+
+        if (size == 0)
+            return false;
+
+        alBufferData(buffer, format, pcm, size, vorbisInfo->rate);
+        check();
+
+        return true;
+    }
+
+
+
+    void AudioStream::empty()
+    {
+        int queued;
+
+        alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
+
+        while (queued--)
+        {
+            ALuint buffer;
+
+            alSourceUnqueueBuffers(source, 1, &buffer);
+            check();
+        }
+    }
+
+
+
+
+    void AudioStream::check()
+    {
+        int error = alGetError();
+
+        if (error != AL_NO_ERROR)
+            COUT(2) << "AudioStream: OpenAL error was raised." << std::endl;
+    }
+
+
+
+    std::string AudioStream::errorString(int code)
+    {
+        switch (code)
+        {
+            case OV_EREAD:
+                return std::string("Read from media.");
+            case OV_ENOTVORBIS:
+                return std::string("Not Vorbis data.");
+            case OV_EVERSION:
+                return std::string("Vorbis version mismatch.");
+            case OV_EBADHEADER:
+                return std::string("Invalid Vorbis header.");
+            case OV_EFAULT:
+                return std::string("Internal logic fault (bug or heap/stack corruption.");
+            default:
+                return std::string("Unknown Ogg error.");
+        }
+    }
+}
+
Index: /code/branches/physics/src/audio/AudioStream.h
===================================================================
--- /code/branches/physics/src/audio/AudioStream.h	(revision 2122)
+++ /code/branches/physics/src/audio/AudioStream.h	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioStream_H__
+#define _AudioStream_H__
+
+#include "AudioPrereqs.h"
+
+#include <string>
+#include <iostream>
+#include <AL/al.h>
+#include <vorbis/vorbisfile.h>
+#include <vorbis/codec.h>
+
+
+namespace audio
+{
+    const int BUFFER_SIZE = 4096 * 4;
+
+    class _AudioExport AudioStream
+    {
+    public:
+        AudioStream(std::string path);
+        void open();
+        void release();
+        void display();
+        bool playback();
+        bool playing();
+        bool update();
+        inline bool isLoaded() { return loaded; }
+
+    protected:
+        bool stream(ALuint buffer);
+        void empty();
+        void check();
+        std::string errorString(int code);
+
+    private:
+        std::string path;
+
+        FILE*           oggFile;
+        OggVorbis_File  oggStream;
+        vorbis_info*    vorbisInfo;
+        vorbis_comment* vorbisComment;
+        bool loaded;
+
+        ALuint buffers[2];
+        ALuint source;
+        ALenum format;
+    };
+}
+
+#endif /* _AudioStream_H__ */
Index: /code/branches/physics/src/audio/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/audio/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/audio/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,23 @@
+SET ( AUDIO_SRC_FILES
+  AudioBuffer.cc
+  AudioManager.cc
+  AudioSource.cc
+  AudioStream.cc
+)
+
+IF (WIN32)
+  ADD_LIBRARY( audio ${AUDIO_SRC_FILES} )
+ELSE (WIN32)
+  ADD_LIBRARY( audio SHARED ${AUDIO_SRC_FILES} )
+ENDIF (WIN32)
+
+TARGET_LINK_LIBRARIES( audio
+  ${OPENAL_LIBRARY}
+  ${ALUT_LIBRARY}
+  ${VORBISFILE_LIBRARY}
+  ${VORBIS_LIBRARY}
+  ${OGG_LIBRARY}
+  core
+)
+
+
Index: /code/branches/physics/src/bullet/AUTHORS
===================================================================
--- /code/branches/physics/src/bullet/AUTHORS	(revision 2122)
+++ /code/branches/physics/src/bullet/AUTHORS	(revision 2122)
@@ -0,0 +1,22 @@
+
+Bullet Physics Library is an open source project with help from the community at the Physics Forum
+See the forum at http://bulletphysics.com
+
+The project was started by Erwin Coumans
+
+Following people contributed to Bullet
+(random order, please let us know on the forum if your name should be in this list)
+
+Gino van den Bergen: LinearMath classes
+Christer Ericson: parts of the voronoi simplex solver
+Simon Hobbs: 3d axis sweep and prune, Extras/SATCollision, separating axis theorem + SIMD code
+Dirk Gregorius: generic D6 constraint
+Erin Catto: accumulated impulse in sequential impulse
+Nathanael Presson: EPA penetration depth calculation
+Francisco Leon: GIMPACT Concave Concave collision
+Joerg Henrichs: make buildsystem (work in progress)
+Eric Sunshine: jam + msvcgen buildsystem
+Steve Baker: GPU physics and general implementation improvements
+Jay Lee: Double precision support
+KleMiX, aka Vsevolod Klementjev, managed version, rewritten in C# for XNA
+Erwin Coumans: most other source code
Index: /code/branches/physics/src/bullet/Bullet-C-Api.h
===================================================================
--- /code/branches/physics/src/bullet/Bullet-C-Api.h	(revision 2122)
+++ /code/branches/physics/src/bullet/Bullet-C-Api.h	(revision 2122)
@@ -0,0 +1,175 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+	Draft high-level generic physics C-API. For low-level access, use the physics SDK native API's.
+	Work in progress, functionality will be added on demand.
+
+	If possible, use the richer Bullet C++ API, by including "btBulletDynamicsCommon.h"
+*/
+
+#ifndef BULLET_C_API_H
+#define BULLET_C_API_H
+
+#define PL_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
+
+#ifdef BT_USE_DOUBLE_PRECISION
+typedef double	plReal;
+#else
+typedef float	plReal;
+#endif
+
+typedef plReal	plVector3[3];
+typedef plReal	plQuaternion[4];
+
+#ifdef __cplusplus
+extern "C" { 
+#endif
+
+/*	Particular physics SDK */
+	PL_DECLARE_HANDLE(plPhysicsSdkHandle);
+
+/* 	Dynamics world, belonging to some physics SDK */
+	PL_DECLARE_HANDLE(plDynamicsWorldHandle);
+
+/* Rigid Body that can be part of a Dynamics World */	
+	PL_DECLARE_HANDLE(plRigidBodyHandle);
+
+/* 	Collision Shape/Geometry, property of a Rigid Body */
+	PL_DECLARE_HANDLE(plCollisionShapeHandle);
+
+/* Constraint for Rigid Bodies */
+	PL_DECLARE_HANDLE(plConstraintHandle);
+
+/* Triangle Mesh interface */
+	PL_DECLARE_HANDLE(plMeshInterfaceHandle);
+
+/* Broadphase Scene/Proxy Handles */
+	PL_DECLARE_HANDLE(plCollisionBroadphaseHandle);
+	PL_DECLARE_HANDLE(plBroadphaseProxyHandle);
+	PL_DECLARE_HANDLE(plCollisionWorldHandle);
+
+/*
+	Create and Delete a Physics SDK	
+*/
+
+	extern	plPhysicsSdkHandle	plNewBulletSdk(); //this could be also another sdk, like ODE, PhysX etc.
+	extern	void		plDeletePhysicsSdk(plPhysicsSdkHandle	physicsSdk);
+
+/* Collision World, not strictly necessary, you can also just create a Dynamics World with Rigid Bodies which internally manages the Collision World with Collision Objects */
+
+	typedef void(*btBroadphaseCallback)(void* clientData, void* object1,void* object2);
+
+	extern plCollisionBroadphaseHandle	plCreateSapBroadphase(btBroadphaseCallback beginCallback,btBroadphaseCallback endCallback);
+
+	extern void	plDestroyBroadphase(plCollisionBroadphaseHandle bp);
+
+	extern 	plBroadphaseProxyHandle plCreateProxy(plCollisionBroadphaseHandle bp, void* clientData, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ);
+
+	extern void plDestroyProxy(plCollisionBroadphaseHandle bp, plBroadphaseProxyHandle proxyHandle);
+
+	extern void plSetBoundingBox(plBroadphaseProxyHandle proxyHandle, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ);
+
+/* todo: add pair cache support with queries like add/remove/find pair */
+	
+	extern plCollisionWorldHandle plCreateCollisionWorld(plPhysicsSdkHandle physicsSdk);
+
+/* todo: add/remove objects */
+	
+
+/* Dynamics World */
+
+	extern  plDynamicsWorldHandle plCreateDynamicsWorld(plPhysicsSdkHandle physicsSdk);
+
+	extern  void           plDeleteDynamicsWorld(plDynamicsWorldHandle world);
+
+	extern	void	plStepSimulation(plDynamicsWorldHandle,	plReal	timeStep);
+
+	extern  void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object);
+
+	extern  void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object);
+
+
+/* Rigid Body  */
+
+	extern  plRigidBodyHandle plCreateRigidBody(	void* user_data,  float mass, plCollisionShapeHandle cshape );
+
+	extern  void plDeleteRigidBody(plRigidBodyHandle body);
+
+
+/* Collision Shape definition */
+
+	extern  plCollisionShapeHandle plNewSphereShape(plReal radius);
+	extern  plCollisionShapeHandle plNewBoxShape(plReal x, plReal y, plReal z);
+	extern  plCollisionShapeHandle plNewCapsuleShape(plReal radius, plReal height);	
+	extern  plCollisionShapeHandle plNewConeShape(plReal radius, plReal height);
+	extern  plCollisionShapeHandle plNewCylinderShape(plReal radius, plReal height);
+	extern	plCollisionShapeHandle plNewCompoundShape();
+	extern	void	plAddChildShape(plCollisionShapeHandle compoundShape,plCollisionShapeHandle childShape, plVector3 childPos,plQuaternion childOrn);
+
+	extern  void plDeleteShape(plCollisionShapeHandle shape);
+
+	/* Convex Meshes */
+	extern  plCollisionShapeHandle plNewConvexHullShape();
+	extern  void		plAddVertex(plCollisionShapeHandle convexHull, plReal x,plReal y,plReal z);
+/* Concave static triangle meshes */
+	extern  plMeshInterfaceHandle		   plNewMeshInterface();
+	extern  void		plAddTriangle(plMeshInterfaceHandle meshHandle, plVector3 v0,plVector3 v1,plVector3 v2);
+	extern  plCollisionShapeHandle plNewStaticTriangleMeshShape(plMeshInterfaceHandle);
+
+	extern  void plSetScaling(plCollisionShapeHandle shape, plVector3 scaling);
+
+/* SOLID has Response Callback/Table/Management */
+/* PhysX has Triggers, User Callbacks and filtering */
+/* ODE has the typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2); */
+
+/*	typedef void plUpdatedPositionCallback(void* userData, plRigidBodyHandle	rbHandle, plVector3 pos); */
+/*	typedef void plUpdatedOrientationCallback(void* userData, plRigidBodyHandle	rbHandle, plQuaternion orientation); */
+
+	/* get world transform */
+	extern void	plGetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix);
+	extern void	plGetPosition(plRigidBodyHandle object,plVector3 position);
+	extern void plGetOrientation(plRigidBodyHandle object,plQuaternion orientation);
+
+	/* set world transform (position/orientation) */
+	extern  void plSetPosition(plRigidBodyHandle object, const plVector3 position);
+	extern  void plSetOrientation(plRigidBodyHandle object, const plQuaternion orientation);
+	extern	void plSetEuler(plReal yaw,plReal pitch,plReal roll, plQuaternion orient);
+
+	typedef struct plRayCastResult {
+		plRigidBodyHandle		m_body;  
+		plCollisionShapeHandle	m_shape; 		
+		plVector3				m_positionWorld; 		
+		plVector3				m_normalWorld;
+	} plRayCastResult;
+
+	extern  int plRayCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plRayCastResult res);
+
+	/* Sweep API */
+
+	/* extern  plRigidBodyHandle plObjectCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal); */
+
+	/* Continuous Collision Detection API */
+	
+	// needed for source/blender/blenkernel/intern/collision.c
+	double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float q2[3], float q3[3], float *pa, float *pb, float normal[3]);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif //BULLET_C_API_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp	(revision 2122)
@@ -0,0 +1,38 @@
+
+//Bullet Continuous Collision Detection and Physics Library
+//Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+
+//
+// btAxisSweep3
+//
+// Copyright (c) 2006 Simon Hobbs
+//
+// This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+#include "btAxisSweep3.h"
+
+#include <assert.h>
+
+btAxisSweep3::btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache)
+:btAxisSweep3Internal<unsigned short int>(worldAabbMin,worldAabbMax,0xfffe,0xffff,maxHandles,pairCache)
+{
+	// 1 handle is reserved as sentinel
+	btAssert(maxHandles > 1 && maxHandles < 32767);
+
+}
+
+
+bt32BitAxisSweep3::bt32BitAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, unsigned int maxHandles , btOverlappingPairCache* pairCache )
+:btAxisSweep3Internal<unsigned int>(worldAabbMin,worldAabbMax,0xfffffffe,0x7fffffff,maxHandles,pairCache)
+{
+	// 1 handle is reserved as sentinel
+	btAssert(maxHandles > 1 && maxHandles < 2147483647);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h	(revision 2122)
@@ -0,0 +1,918 @@
+//Bullet Continuous Collision Detection and Physics Library
+//Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+//
+// btAxisSweep3.h
+//
+// Copyright (c) 2006 Simon Hobbs
+//
+// This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+
+#ifndef AXIS_SWEEP_3_H
+#define AXIS_SWEEP_3_H
+
+#include "LinearMath/btPoint3.h"
+#include "LinearMath/btVector3.h"
+#include "btOverlappingPairCache.h"
+#include "btBroadphaseInterface.h"
+#include "btBroadphaseProxy.h"
+#include "btOverlappingPairCallback.h"
+
+//#define DEBUG_BROADPHASE 1
+#define USE_OVERLAP_TEST_ON_REMOVES 1
+
+/// The internal templace class btAxisSweep3Internal implements the sweep and prune broadphase.
+/// It uses quantized integers to represent the begin and end points for each of the 3 axis.
+/// Dont use this class directly, use btAxisSweep3 or bt32BitAxisSweep3 instead.
+template <typename BP_FP_INT_TYPE>
+class btAxisSweep3Internal : public btBroadphaseInterface
+{
+protected:
+
+	BP_FP_INT_TYPE	m_bpHandleMask;
+	BP_FP_INT_TYPE	m_handleSentinel;
+
+public:
+	
+
+	class Edge
+	{
+	public:
+		BP_FP_INT_TYPE m_pos;			// low bit is min/max
+		BP_FP_INT_TYPE m_handle;
+
+		BP_FP_INT_TYPE IsMax() const {return static_cast<BP_FP_INT_TYPE>(m_pos & 1);}
+	};
+
+public:
+	class	Handle : public btBroadphaseProxy
+	{
+	public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+	
+		// indexes into the edge arrays
+		BP_FP_INT_TYPE m_minEdges[3], m_maxEdges[3];		// 6 * 2 = 12
+//		BP_FP_INT_TYPE m_uniqueId;
+		BP_FP_INT_TYPE m_pad;
+		
+		//void* m_pOwner; this is now in btBroadphaseProxy.m_clientObject
+	
+		SIMD_FORCE_INLINE void SetNextFree(BP_FP_INT_TYPE next) {m_minEdges[0] = next;}
+		SIMD_FORCE_INLINE BP_FP_INT_TYPE GetNextFree() const {return m_minEdges[0];}
+	};		// 24 bytes + 24 for Edge structures = 44 bytes total per entry
+
+	
+protected:
+	btPoint3 m_worldAabbMin;						// overall system bounds
+	btPoint3 m_worldAabbMax;						// overall system bounds
+
+	btVector3 m_quantize;						// scaling factor for quantization
+
+	BP_FP_INT_TYPE m_numHandles;						// number of active handles
+	BP_FP_INT_TYPE m_maxHandles;						// max number of handles
+	Handle* m_pHandles;						// handles pool
+	
+	BP_FP_INT_TYPE m_firstFreeHandle;		// free handles list
+
+	Edge* m_pEdges[3];						// edge arrays for the 3 axes (each array has m_maxHandles * 2 + 2 sentinel entries)
+	void* m_pEdgesRawPtr[3];
+
+	btOverlappingPairCache* m_pairCache;
+
+	///btOverlappingPairCallback is an additional optional user callback for adding/removing overlapping pairs, similar interface to btOverlappingPairCache.
+	btOverlappingPairCallback* m_userPairCallback;
+	
+	bool	m_ownsPairCache;
+
+	int	m_invalidPair;
+
+	// allocation/deallocation
+	BP_FP_INT_TYPE allocHandle();
+	void freeHandle(BP_FP_INT_TYPE handle);
+	
+
+	bool testOverlap2D(const Handle* pHandleA, const Handle* pHandleB,int axis0,int axis1);
+
+#ifdef DEBUG_BROADPHASE
+	void debugPrintAxis(int axis,bool checkCardinality=true);
+#endif //DEBUG_BROADPHASE
+
+	//Overlap* AddOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB);
+	//void RemoveOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB);
+
+	void quantize(BP_FP_INT_TYPE* out, const btPoint3& point, int isMax) const;
+
+	void sortMinDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps );
+	void sortMinUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps );
+	void sortMaxDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps );
+	void sortMaxUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps );
+
+public:
+
+	btAxisSweep3Internal(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel, BP_FP_INT_TYPE maxHandles = 16384, btOverlappingPairCache* pairCache=0);
+
+	virtual	~btAxisSweep3Internal();
+
+	BP_FP_INT_TYPE getNumHandles() const
+	{
+		return m_numHandles;
+	}
+
+	virtual void	calculateOverlappingPairs(btDispatcher* dispatcher);
+	
+	BP_FP_INT_TYPE addHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
+	void removeHandle(BP_FP_INT_TYPE handle,btDispatcher* dispatcher);
+	void updateHandle(BP_FP_INT_TYPE handle, const btPoint3& aabbMin,const btPoint3& aabbMax,btDispatcher* dispatcher);
+	SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {return m_pHandles + index;}
+
+	void	processAllOverlappingPairs(btOverlapCallback* callback);
+
+	//Broadphase Interface
+	virtual btBroadphaseProxy*	createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
+	virtual void	destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+	virtual void	setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
+	
+	bool	testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
+
+	btOverlappingPairCache*	getOverlappingPairCache()
+	{
+		return m_pairCache;
+	}
+	const btOverlappingPairCache*	getOverlappingPairCache() const
+	{
+		return m_pairCache;
+	}
+
+	void	setOverlappingPairUserCallback(btOverlappingPairCallback* pairCallback)
+	{
+		m_userPairCallback = pairCallback;
+	}
+	const btOverlappingPairCallback*	getOverlappingPairUserCallback() const
+	{
+		return m_userPairCallback;
+	}
+
+	///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
+	///will add some transform later
+	virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
+	{
+		aabbMin = m_worldAabbMin;
+		aabbMax = m_worldAabbMax;
+	}
+
+	virtual void	printStats()
+	{
+/*		printf("btAxisSweep3.h\n");
+		printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
+		printf("aabbMin=%f,%f,%f,aabbMax=%f,%f,%f\n",m_worldAabbMin.getX(),m_worldAabbMin.getY(),m_worldAabbMin.getZ(),
+			m_worldAabbMax.getX(),m_worldAabbMax.getY(),m_worldAabbMax.getZ());
+			*/
+
+	}
+
+};
+
+////////////////////////////////////////////////////////////////////
+
+
+
+
+#ifdef DEBUG_BROADPHASE
+#include <stdio.h>
+
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3<BP_FP_INT_TYPE>::debugPrintAxis(int axis, bool checkCardinality)
+{
+	int numEdges = m_pHandles[0].m_maxEdges[axis];
+	printf("SAP Axis %d, numEdges=%d\n",axis,numEdges);
+
+	int i;
+	for (i=0;i<numEdges+1;i++)
+	{
+		Edge* pEdge = m_pEdges[axis] + i;
+		Handle* pHandlePrev = getHandle(pEdge->m_handle);
+		int handleIndex = pEdge->IsMax()? pHandlePrev->m_maxEdges[axis] : pHandlePrev->m_minEdges[axis];
+		char beginOrEnd;
+		beginOrEnd=pEdge->IsMax()?'E':'B';
+		printf("	[%c,h=%d,p=%x,i=%d]\n",beginOrEnd,pEdge->m_handle,pEdge->m_pos,handleIndex);
+	}
+
+	if (checkCardinality)
+		assert(numEdges == m_numHandles*2+1);
+}
+#endif //DEBUG_BROADPHASE
+
+template <typename BP_FP_INT_TYPE>
+btBroadphaseProxy*	btAxisSweep3Internal<BP_FP_INT_TYPE>::createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy)
+{
+		(void)shapeType;
+		BP_FP_INT_TYPE handleId = addHandle(aabbMin,aabbMax, userPtr,collisionFilterGroup,collisionFilterMask,dispatcher,multiSapProxy);
+		
+		Handle* handle = getHandle(handleId);
+				
+		return handle;
+}
+
+
+
+template <typename BP_FP_INT_TYPE>
+void	btAxisSweep3Internal<BP_FP_INT_TYPE>::destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
+{
+	Handle* handle = static_cast<Handle*>(proxy);
+	removeHandle(static_cast<BP_FP_INT_TYPE>(handle->m_uniqueId), dispatcher);
+}
+
+template <typename BP_FP_INT_TYPE>
+void	btAxisSweep3Internal<BP_FP_INT_TYPE>::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher)
+{
+	Handle* handle = static_cast<Handle*>(proxy);
+	updateHandle(static_cast<BP_FP_INT_TYPE>(handle->m_uniqueId), aabbMin, aabbMax,dispatcher);
+
+}
+
+
+
+
+
+template <typename BP_FP_INT_TYPE>
+btAxisSweep3Internal<BP_FP_INT_TYPE>::btAxisSweep3Internal(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel,BP_FP_INT_TYPE userMaxHandles, btOverlappingPairCache* pairCache )
+:m_bpHandleMask(handleMask),
+m_handleSentinel(handleSentinel),
+m_pairCache(pairCache),
+m_userPairCallback(0),
+m_ownsPairCache(false),
+m_invalidPair(0)
+{
+	BP_FP_INT_TYPE maxHandles = static_cast<BP_FP_INT_TYPE>(userMaxHandles+1);//need to add one sentinel handle
+
+	if (!m_pairCache)
+	{
+		void* ptr = btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16);
+		m_pairCache = new(ptr) btHashedOverlappingPairCache();
+		m_ownsPairCache = true;
+	}
+
+	//assert(bounds.HasVolume());
+
+	// init bounds
+	m_worldAabbMin = worldAabbMin;
+	m_worldAabbMax = worldAabbMax;
+
+	btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;
+
+	BP_FP_INT_TYPE	maxInt = m_handleSentinel;
+
+	m_quantize = btVector3(btScalar(maxInt),btScalar(maxInt),btScalar(maxInt)) / aabbSize;
+
+	// allocate handles buffer, using btAlignedAlloc, and put all handles on free list
+	m_pHandles = new Handle[maxHandles];
+	
+	m_maxHandles = maxHandles;
+	m_numHandles = 0;
+
+	// handle 0 is reserved as the null index, and is also used as the sentinel
+	m_firstFreeHandle = 1;
+	{
+		for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < maxHandles; i++)
+			m_pHandles[i].SetNextFree(static_cast<BP_FP_INT_TYPE>(i + 1));
+		m_pHandles[maxHandles - 1].SetNextFree(0);
+	}
+
+	{
+		// allocate edge buffers
+		for (int i = 0; i < 3; i++)
+		{
+			m_pEdgesRawPtr[i] = btAlignedAlloc(sizeof(Edge)*maxHandles*2,16);
+			m_pEdges[i] = new(m_pEdgesRawPtr[i]) Edge[maxHandles * 2];
+		}
+	}
+	//removed overlap management
+
+	// make boundary sentinels
+	
+	m_pHandles[0].m_clientObject = 0;
+
+	for (int axis = 0; axis < 3; axis++)
+	{
+		m_pHandles[0].m_minEdges[axis] = 0;
+		m_pHandles[0].m_maxEdges[axis] = 1;
+
+		m_pEdges[axis][0].m_pos = 0;
+		m_pEdges[axis][0].m_handle = 0;
+		m_pEdges[axis][1].m_pos = m_handleSentinel;
+		m_pEdges[axis][1].m_handle = 0;
+#ifdef DEBUG_BROADPHASE
+		debugPrintAxis(axis);
+#endif //DEBUG_BROADPHASE
+
+	}
+
+}
+
+template <typename BP_FP_INT_TYPE>
+btAxisSweep3Internal<BP_FP_INT_TYPE>::~btAxisSweep3Internal()
+{
+	
+	for (int i = 2; i >= 0; i--)
+	{
+		btAlignedFree(m_pEdgesRawPtr[i]);
+	}
+	delete [] m_pHandles;
+
+	if (m_ownsPairCache)
+	{
+		m_pairCache->~btOverlappingPairCache();
+		btAlignedFree(m_pairCache);
+	}
+}
+
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::quantize(BP_FP_INT_TYPE* out, const btPoint3& point, int isMax) const
+{
+#ifdef OLD_CLAMPING_METHOD
+	///problem with this clamping method is that the floating point during quantization might still go outside the range [(0|isMax) .. (m_handleSentinel&m_bpHandleMask]|isMax]
+	///see http://code.google.com/p/bullet/issues/detail?id=87
+	btPoint3 clampedPoint(point);
+	clampedPoint.setMax(m_worldAabbMin);
+	clampedPoint.setMin(m_worldAabbMax);
+	btVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize;
+	out[0] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getX() & m_bpHandleMask) | isMax);
+	out[1] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getY() & m_bpHandleMask) | isMax);
+	out[2] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getZ() & m_bpHandleMask) | isMax);
+#else
+	btVector3 v = (point - m_worldAabbMin) * m_quantize;
+	out[0]=(v[0]<=0)?(BP_FP_INT_TYPE)isMax:(v[0]>=m_handleSentinel)?(BP_FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[0]&m_bpHandleMask)|isMax);
+	out[1]=(v[1]<=0)?(BP_FP_INT_TYPE)isMax:(v[1]>=m_handleSentinel)?(BP_FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[1]&m_bpHandleMask)|isMax);
+	out[2]=(v[2]<=0)?(BP_FP_INT_TYPE)isMax:(v[2]>=m_handleSentinel)?(BP_FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[2]&m_bpHandleMask)|isMax);
+#endif //OLD_CLAMPING_METHOD
+}
+
+
+template <typename BP_FP_INT_TYPE>
+BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle()
+{
+	assert(m_firstFreeHandle);
+
+	BP_FP_INT_TYPE handle = m_firstFreeHandle;
+	m_firstFreeHandle = getHandle(handle)->GetNextFree();
+	m_numHandles++;
+
+	return handle;
+}
+
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle)
+{
+	assert(handle > 0 && handle < m_maxHandles);
+
+	getHandle(handle)->SetNextFree(m_firstFreeHandle);
+	m_firstFreeHandle = handle;
+
+	m_numHandles--;
+}
+
+
+template <typename BP_FP_INT_TYPE>
+BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::addHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy)
+{
+	// quantize the bounds
+	BP_FP_INT_TYPE min[3], max[3];
+	quantize(min, aabbMin, 0);
+	quantize(max, aabbMax, 1);
+
+	// allocate a handle
+	BP_FP_INT_TYPE handle = allocHandle();
+	
+
+	Handle* pHandle = getHandle(handle);
+	
+	pHandle->m_uniqueId = static_cast<int>(handle);
+	//pHandle->m_pOverlaps = 0;
+	pHandle->m_clientObject = pOwner;
+	pHandle->m_collisionFilterGroup = collisionFilterGroup;
+	pHandle->m_collisionFilterMask = collisionFilterMask;
+	pHandle->m_multiSapParentProxy = multiSapProxy;
+
+	// compute current limit of edge arrays
+	BP_FP_INT_TYPE limit = static_cast<BP_FP_INT_TYPE>(m_numHandles * 2);
+
+	
+	// insert new edges just inside the max boundary edge
+	for (BP_FP_INT_TYPE axis = 0; axis < 3; axis++)
+	{
+
+		m_pHandles[0].m_maxEdges[axis] += 2;
+
+		m_pEdges[axis][limit + 1] = m_pEdges[axis][limit - 1];
+
+		m_pEdges[axis][limit - 1].m_pos = min[axis];
+		m_pEdges[axis][limit - 1].m_handle = handle;
+
+		m_pEdges[axis][limit].m_pos = max[axis];
+		m_pEdges[axis][limit].m_handle = handle;
+
+		pHandle->m_minEdges[axis] = static_cast<BP_FP_INT_TYPE>(limit - 1);
+		pHandle->m_maxEdges[axis] = limit;
+	}
+
+	// now sort the new edges to their correct position
+	sortMinDown(0, pHandle->m_minEdges[0], dispatcher,false);
+	sortMaxDown(0, pHandle->m_maxEdges[0], dispatcher,false);
+	sortMinDown(1, pHandle->m_minEdges[1], dispatcher,false);
+	sortMaxDown(1, pHandle->m_maxEdges[1], dispatcher,false);
+	sortMinDown(2, pHandle->m_minEdges[2], dispatcher,true);
+	sortMaxDown(2, pHandle->m_maxEdges[2], dispatcher,true);
+
+
+	return handle;
+}
+
+
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::removeHandle(BP_FP_INT_TYPE handle,btDispatcher* dispatcher)
+{
+
+	Handle* pHandle = getHandle(handle);
+
+	//explicitly remove the pairs containing the proxy
+	//we could do it also in the sortMinUp (passing true)
+	//todo: compare performance
+	if (!m_pairCache->hasDeferredRemoval())
+	{
+		m_pairCache->removeOverlappingPairsContainingProxy(pHandle,dispatcher);
+	}
+
+	// compute current limit of edge arrays
+	int limit = static_cast<int>(m_numHandles * 2);
+	
+	int axis;
+
+	for (axis = 0;axis<3;axis++)
+	{
+		m_pHandles[0].m_maxEdges[axis] -= 2;
+	}
+
+	// remove the edges by sorting them up to the end of the list
+	for ( axis = 0; axis < 3; axis++)
+	{
+		Edge* pEdges = m_pEdges[axis];
+		BP_FP_INT_TYPE max = pHandle->m_maxEdges[axis];
+		pEdges[max].m_pos = m_handleSentinel;
+
+		sortMaxUp(axis,max,dispatcher,false);
+
+
+		BP_FP_INT_TYPE i = pHandle->m_minEdges[axis];
+		pEdges[i].m_pos = m_handleSentinel;
+
+
+		sortMinUp(axis,i,dispatcher,false);
+
+		pEdges[limit-1].m_handle = 0;
+		pEdges[limit-1].m_pos = m_handleSentinel;
+		
+#ifdef DEBUG_BROADPHASE
+			debugPrintAxis(axis,false);
+#endif //DEBUG_BROADPHASE
+
+
+	}
+
+
+	// free the handle
+	freeHandle(handle);
+
+	
+}
+
+extern int gOverlappingPairs;
+//#include <stdio.h>
+
+template <typename BP_FP_INT_TYPE>
+void	btAxisSweep3Internal<BP_FP_INT_TYPE>::calculateOverlappingPairs(btDispatcher* dispatcher)
+{
+
+	if (m_pairCache->hasDeferredRemoval())
+	{
+	
+		btBroadphasePairArray&	overlappingPairArray = m_pairCache->getOverlappingPairArray();
+
+		//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
+		overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
+
+		overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
+		m_invalidPair = 0;
+
+		
+		int i;
+
+		btBroadphasePair previousPair;
+		previousPair.m_pProxy0 = 0;
+		previousPair.m_pProxy1 = 0;
+		previousPair.m_algorithm = 0;
+		
+		
+		for (i=0;i<overlappingPairArray.size();i++)
+		{
+		
+			btBroadphasePair& pair = overlappingPairArray[i];
+
+			bool isDuplicate = (pair == previousPair);
+
+			previousPair = pair;
+
+			bool needsRemoval = false;
+
+			if (!isDuplicate)
+			{
+				bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
+
+				if (hasOverlap)
+				{
+					needsRemoval = false;//callback->processOverlap(pair);
+				} else
+				{
+					needsRemoval = true;
+				}
+			} else
+			{
+				//remove duplicate
+				needsRemoval = true;
+				//should have no algorithm
+				btAssert(!pair.m_algorithm);
+			}
+			
+			if (needsRemoval)
+			{
+				m_pairCache->cleanOverlappingPair(pair,dispatcher);
+
+		//		m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
+		//		m_overlappingPairArray.pop_back();
+				pair.m_pProxy0 = 0;
+				pair.m_pProxy1 = 0;
+				m_invalidPair++;
+				gOverlappingPairs--;
+			} 
+			
+		}
+
+	///if you don't like to skip the invalid pairs in the array, execute following code:
+	#define CLEAN_INVALID_PAIRS 1
+	#ifdef CLEAN_INVALID_PAIRS
+
+		//perform a sort, to sort 'invalid' pairs to the end
+		overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
+
+		overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
+		m_invalidPair = 0;
+	#endif//CLEAN_INVALID_PAIRS
+		
+		//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
+	}
+
+
+
+	
+
+}
+
+
+template <typename BP_FP_INT_TYPE>
+bool btAxisSweep3Internal<BP_FP_INT_TYPE>::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
+{
+	const Handle* pHandleA = static_cast<Handle*>(proxy0);
+	const Handle* pHandleB = static_cast<Handle*>(proxy1);
+	
+	//optimization 1: check the array index (memory address), instead of the m_pos
+
+	for (int axis = 0; axis < 3; axis++)
+	{ 
+		if (pHandleA->m_maxEdges[axis] < pHandleB->m_minEdges[axis] || 
+			pHandleB->m_maxEdges[axis] < pHandleA->m_minEdges[axis]) 
+		{ 
+			return false; 
+		} 
+	} 
+	return true;
+}
+
+template <typename BP_FP_INT_TYPE>
+bool btAxisSweep3Internal<BP_FP_INT_TYPE>::testOverlap2D(const Handle* pHandleA, const Handle* pHandleB,int axis0,int axis1)
+{
+	//optimization 1: check the array index (memory address), instead of the m_pos
+
+	if (pHandleA->m_maxEdges[axis0] < pHandleB->m_minEdges[axis0] || 
+		pHandleB->m_maxEdges[axis0] < pHandleA->m_minEdges[axis0] ||
+		pHandleA->m_maxEdges[axis1] < pHandleB->m_minEdges[axis1] ||
+		pHandleB->m_maxEdges[axis1] < pHandleA->m_minEdges[axis1]) 
+	{ 
+		return false; 
+	} 
+	return true;
+}
+
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE handle, const btPoint3& aabbMin,const btPoint3& aabbMax,btDispatcher* dispatcher)
+{
+//	assert(bounds.IsFinite());
+	//assert(bounds.HasVolume());
+
+	Handle* pHandle = getHandle(handle);
+
+	// quantize the new bounds
+	BP_FP_INT_TYPE min[3], max[3];
+	quantize(min, aabbMin, 0);
+	quantize(max, aabbMax, 1);
+
+	// update changed edges
+	for (int axis = 0; axis < 3; axis++)
+	{
+		BP_FP_INT_TYPE emin = pHandle->m_minEdges[axis];
+		BP_FP_INT_TYPE emax = pHandle->m_maxEdges[axis];
+
+		int dmin = (int)min[axis] - (int)m_pEdges[axis][emin].m_pos;
+		int dmax = (int)max[axis] - (int)m_pEdges[axis][emax].m_pos;
+
+		m_pEdges[axis][emin].m_pos = min[axis];
+		m_pEdges[axis][emax].m_pos = max[axis];
+
+		// expand (only adds overlaps)
+		if (dmin < 0)
+			sortMinDown(axis, emin,dispatcher,true);
+
+		if (dmax > 0)
+			sortMaxUp(axis, emax,dispatcher,true);
+
+		// shrink (only removes overlaps)
+		if (dmin > 0)
+			sortMinUp(axis, emin,dispatcher,true);
+
+		if (dmax < 0)
+			sortMaxDown(axis, emax,dispatcher,true);
+
+#ifdef DEBUG_BROADPHASE
+	debugPrintAxis(axis);
+#endif //DEBUG_BROADPHASE
+	}
+
+	
+}
+
+
+
+
+// sorting a min edge downwards can only ever *add* overlaps
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMinDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* /* dispatcher */, bool updateOverlaps)
+{
+
+	Edge* pEdge = m_pEdges[axis] + edge;
+	Edge* pPrev = pEdge - 1;
+	Handle* pHandleEdge = getHandle(pEdge->m_handle);
+
+	while (pEdge->m_pos < pPrev->m_pos)
+	{
+		Handle* pHandlePrev = getHandle(pPrev->m_handle);
+
+		if (pPrev->IsMax())
+		{
+			// if previous edge is a maximum check the bounds and add an overlap if necessary
+			const int axis1 = (1  << axis) & 3;
+			const int axis2 = (1  << axis1) & 3;
+			if (updateOverlaps && testOverlap2D(pHandleEdge, pHandlePrev,axis1,axis2))
+			{
+				m_pairCache->addOverlappingPair(pHandleEdge,pHandlePrev);
+				if (m_userPairCallback)
+					m_userPairCallback->addOverlappingPair(pHandleEdge,pHandlePrev);
+
+				//AddOverlap(pEdge->m_handle, pPrev->m_handle);
+
+			}
+
+			// update edge reference in other handle
+			pHandlePrev->m_maxEdges[axis]++;
+		}
+		else
+			pHandlePrev->m_minEdges[axis]++;
+
+		pHandleEdge->m_minEdges[axis]--;
+
+		// swap the edges
+		Edge swap = *pEdge;
+		*pEdge = *pPrev;
+		*pPrev = swap;
+
+		// decrement
+		pEdge--;
+		pPrev--;
+	}
+
+#ifdef DEBUG_BROADPHASE
+	debugPrintAxis(axis);
+#endif //DEBUG_BROADPHASE
+
+}
+
+// sorting a min edge upwards can only ever *remove* overlaps
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMinUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps)
+{
+	Edge* pEdge = m_pEdges[axis] + edge;
+	Edge* pNext = pEdge + 1;
+	Handle* pHandleEdge = getHandle(pEdge->m_handle);
+
+	while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos))
+	{
+		Handle* pHandleNext = getHandle(pNext->m_handle);
+
+		if (pNext->IsMax())
+		{
+			Handle* handle0 = getHandle(pEdge->m_handle);
+			Handle* handle1 = getHandle(pNext->m_handle);
+			const int axis1 = (1  << axis) & 3;
+			const int axis2 = (1  << axis1) & 3;
+			
+			// if next edge is maximum remove any overlap between the two handles
+			if (updateOverlaps 
+#ifdef USE_OVERLAP_TEST_ON_REMOVES
+				&& testOverlap2D(handle0,handle1,axis1,axis2)
+#endif //USE_OVERLAP_TEST_ON_REMOVES
+				)
+			{
+				
+
+				m_pairCache->removeOverlappingPair(handle0,handle1,dispatcher);	
+				if (m_userPairCallback)
+					m_userPairCallback->removeOverlappingPair(handle0,handle1,dispatcher);
+				
+			}
+
+
+			// update edge reference in other handle
+			pHandleNext->m_maxEdges[axis]--;
+		}
+		else
+			pHandleNext->m_minEdges[axis]--;
+
+		pHandleEdge->m_minEdges[axis]++;
+
+		// swap the edges
+		Edge swap = *pEdge;
+		*pEdge = *pNext;
+		*pNext = swap;
+
+		// increment
+		pEdge++;
+		pNext++;
+	}
+
+
+}
+
+// sorting a max edge downwards can only ever *remove* overlaps
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMaxDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps)
+{
+
+	Edge* pEdge = m_pEdges[axis] + edge;
+	Edge* pPrev = pEdge - 1;
+	Handle* pHandleEdge = getHandle(pEdge->m_handle);
+
+	while (pEdge->m_pos < pPrev->m_pos)
+	{
+		Handle* pHandlePrev = getHandle(pPrev->m_handle);
+
+		if (!pPrev->IsMax())
+		{
+			// if previous edge was a minimum remove any overlap between the two handles
+			Handle* handle0 = getHandle(pEdge->m_handle);
+			Handle* handle1 = getHandle(pPrev->m_handle);
+			const int axis1 = (1  << axis) & 3;
+			const int axis2 = (1  << axis1) & 3;
+
+			if (updateOverlaps  
+#ifdef USE_OVERLAP_TEST_ON_REMOVES
+				&& testOverlap2D(handle0,handle1,axis1,axis2)
+#endif //USE_OVERLAP_TEST_ON_REMOVES
+				)
+			{
+				//this is done during the overlappingpairarray iteration/narrowphase collision
+
+				
+				m_pairCache->removeOverlappingPair(handle0,handle1,dispatcher);
+				if (m_userPairCallback)
+					m_userPairCallback->removeOverlappingPair(handle0,handle1,dispatcher);
+			
+
+
+			}
+
+			// update edge reference in other handle
+			pHandlePrev->m_minEdges[axis]++;;
+		}
+		else
+			pHandlePrev->m_maxEdges[axis]++;
+
+		pHandleEdge->m_maxEdges[axis]--;
+
+		// swap the edges
+		Edge swap = *pEdge;
+		*pEdge = *pPrev;
+		*pPrev = swap;
+
+		// decrement
+		pEdge--;
+		pPrev--;
+	}
+
+	
+#ifdef DEBUG_BROADPHASE
+	debugPrintAxis(axis);
+#endif //DEBUG_BROADPHASE
+
+}
+
+// sorting a max edge upwards can only ever *add* overlaps
+template <typename BP_FP_INT_TYPE>
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMaxUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* /* dispatcher */, bool updateOverlaps)
+{
+	Edge* pEdge = m_pEdges[axis] + edge;
+	Edge* pNext = pEdge + 1;
+	Handle* pHandleEdge = getHandle(pEdge->m_handle);
+
+	while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos))
+	{
+		Handle* pHandleNext = getHandle(pNext->m_handle);
+
+		const int axis1 = (1  << axis) & 3;
+		const int axis2 = (1  << axis1) & 3;
+
+		if (!pNext->IsMax())
+		{
+			// if next edge is a minimum check the bounds and add an overlap if necessary
+			if (updateOverlaps && testOverlap2D(pHandleEdge, pHandleNext,axis1,axis2))
+			{
+				Handle* handle0 = getHandle(pEdge->m_handle);
+				Handle* handle1 = getHandle(pNext->m_handle);
+				m_pairCache->addOverlappingPair(handle0,handle1);
+				if (m_userPairCallback)
+					m_userPairCallback->addOverlappingPair(handle0,handle1);
+			}
+
+			// update edge reference in other handle
+			pHandleNext->m_minEdges[axis]--;
+		}
+		else
+			pHandleNext->m_maxEdges[axis]--;
+
+		pHandleEdge->m_maxEdges[axis]++;
+
+		// swap the edges
+		Edge swap = *pEdge;
+		*pEdge = *pNext;
+		*pNext = swap;
+
+		// increment
+		pEdge++;
+		pNext++;
+	}
+	
+}
+
+
+
+////////////////////////////////////////////////////////////////////
+
+
+/// The btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase.
+/// It uses arrays rather then lists for storage of the 3 axis. Also it operates using 16 bit integer coordinates instead of floats.
+/// For large worlds and many objects, use bt32BitAxisSweep3 or btDbvtBroadphase instead. bt32BitAxisSweep3 has higher precision and allows more then 16384 objects at the cost of more memory and bit of performance.
+class btAxisSweep3 : public btAxisSweep3Internal<unsigned short int>
+{
+public:
+
+	btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, unsigned short int maxHandles = 16384, btOverlappingPairCache* pairCache = 0);
+
+};
+
+/// The bt32BitAxisSweep3 allows higher precision quantization and more objects compared to the btAxisSweep3 sweep and prune.
+/// This comes at the cost of more memory per handle, and a bit slower performance.
+/// It uses arrays rather then lists for storage of the 3 axis.
+class bt32BitAxisSweep3 : public btAxisSweep3Internal<unsigned int>
+{
+public:
+
+	bt32BitAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, unsigned int maxHandles = 1500000, btOverlappingPairCache* pairCache = 0);
+
+};
+
+#endif
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef		BROADPHASE_INTERFACE_H
+#define 	BROADPHASE_INTERFACE_H
+
+
+
+struct btDispatcherInfo;
+class btDispatcher;
+#include "btBroadphaseProxy.h"
+class btOverlappingPairCache;
+
+#include "LinearMath/btVector3.h"
+
+///The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
+///Some implementations for this broadphase interface include btAxisSweep3, bt32BitAxisSweep3 and btDbvtBroadphase.
+///The actual overlapping pair management, storage, adding and removing of pairs is dealt by the btOverlappingPairCache class.
+class btBroadphaseInterface
+{
+public:
+	virtual ~btBroadphaseInterface() {}
+
+	virtual btBroadphaseProxy*	createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy) =0;
+	virtual void	destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)=0;
+	virtual void	setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher)=0;
+	
+	///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
+	virtual void	calculateOverlappingPairs(btDispatcher* dispatcher)=0;
+
+	virtual	btOverlappingPairCache*	getOverlappingPairCache()=0;
+	virtual	const btOverlappingPairCache*	getOverlappingPairCache() const =0;
+
+	///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
+	///will add some transform later
+	virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const =0;
+
+	virtual void	printStats() = 0;
+
+};
+
+#endif //BROADPHASE_INTERFACE_H
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp	(revision 2122)
@@ -0,0 +1,17 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btBroadphaseProxy.h"
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h	(revision 2122)
@@ -0,0 +1,238 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BROADPHASE_PROXY_H
+#define BROADPHASE_PROXY_H
+
+#include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE
+#include "LinearMath/btAlignedAllocator.h"
+
+
+/// btDispatcher uses these types
+/// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave
+/// to facilitate type checking
+enum BroadphaseNativeTypes
+{
+	// polyhedral convex shapes
+	BOX_SHAPE_PROXYTYPE,
+	TRIANGLE_SHAPE_PROXYTYPE,
+	TETRAHEDRAL_SHAPE_PROXYTYPE,
+	CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
+	CONVEX_HULL_SHAPE_PROXYTYPE,
+	CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
+//implicit convex shapes
+IMPLICIT_CONVEX_SHAPES_START_HERE,
+	SPHERE_SHAPE_PROXYTYPE,
+	MULTI_SPHERE_SHAPE_PROXYTYPE,
+	CAPSULE_SHAPE_PROXYTYPE,
+	CONE_SHAPE_PROXYTYPE,
+	CONVEX_SHAPE_PROXYTYPE,
+	CYLINDER_SHAPE_PROXYTYPE,
+	UNIFORM_SCALING_SHAPE_PROXYTYPE,
+	MINKOWSKI_SUM_SHAPE_PROXYTYPE,
+	MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
+//concave shapes
+CONCAVE_SHAPES_START_HERE,
+	//keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
+	TRIANGLE_MESH_SHAPE_PROXYTYPE,
+	SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
+	///used for demo integration FAST/Swift collision library and Bullet
+	FAST_CONCAVE_MESH_PROXYTYPE,
+	//terrain
+	TERRAIN_SHAPE_PROXYTYPE,
+///Used for GIMPACT Trimesh integration
+	GIMPACT_SHAPE_PROXYTYPE,
+///Multimaterial mesh
+    MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
+	
+	EMPTY_SHAPE_PROXYTYPE,
+	STATIC_PLANE_PROXYTYPE,
+CONCAVE_SHAPES_END_HERE,
+
+	COMPOUND_SHAPE_PROXYTYPE,
+
+	SOFTBODY_SHAPE_PROXYTYPE,
+
+	INVALID_SHAPE_PROXYTYPE,
+
+	MAX_BROADPHASE_COLLISION_TYPES
+	
+};
+
+
+///The btBroadphaseProxy is the main class that can be used with the Bullet broadphases. 
+///It stores collision shape type information, collision filter information and a client object, typically a btCollisionObject or btRigidBody.
+ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy
+{
+
+BT_DECLARE_ALIGNED_ALLOCATOR();
+	
+	///optional filtering to cull potential collisions
+	enum CollisionFilterGroups
+	{
+	        DefaultFilter = 1,
+	        StaticFilter = 2,
+	        KinematicFilter = 4,
+	        DebrisFilter = 8,
+			SensorTrigger = 16,
+	        AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
+	};
+
+	//Usually the client btCollisionObject or Rigidbody class
+	void*	m_clientObject;
+
+	short int m_collisionFilterGroup;
+	short int m_collisionFilterMask;
+
+	void*	m_multiSapParentProxy;		
+
+
+	int			m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
+
+	SIMD_FORCE_INLINE int getUid() const
+	{
+		return m_uniqueId;
+	}
+
+	//used for memory pools
+	btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
+	{
+	}
+
+	btBroadphaseProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
+		:m_clientObject(userPtr),
+		m_collisionFilterGroup(collisionFilterGroup),
+		m_collisionFilterMask(collisionFilterMask)
+	{
+		m_multiSapParentProxy = multiSapParentProxy;
+	}
+
+	
+
+	static SIMD_FORCE_INLINE bool isPolyhedral(int proxyType)
+	{
+		return (proxyType  < IMPLICIT_CONVEX_SHAPES_START_HERE);
+	}
+
+	static SIMD_FORCE_INLINE bool	isConvex(int proxyType)
+	{
+		return (proxyType < CONCAVE_SHAPES_START_HERE);
+	}
+
+	static SIMD_FORCE_INLINE bool	isConcave(int proxyType)
+	{
+		return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
+			(proxyType < CONCAVE_SHAPES_END_HERE));
+	}
+	static SIMD_FORCE_INLINE bool	isCompound(int proxyType)
+	{
+		return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
+	}
+	static SIMD_FORCE_INLINE bool isInfinite(int proxyType)
+	{
+		return (proxyType == STATIC_PLANE_PROXYTYPE);
+	}
+	
+}
+;
+
+class btCollisionAlgorithm;
+
+struct btBroadphaseProxy;
+
+
+
+///The btBroadphasePair class contains a pair of aabb-overlapping objects.
+///A btDispatcher can search a btCollisionAlgorithm that performs exact/narrowphase collision detection on the actual collision shapes.
+ATTRIBUTE_ALIGNED16(struct) btBroadphasePair
+{
+	btBroadphasePair ()
+		:
+	m_pProxy0(0),
+		m_pProxy1(0),
+		m_algorithm(0),
+		m_userInfo(0)
+	{
+	}
+
+BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btBroadphasePair(const btBroadphasePair& other)
+		:		m_pProxy0(other.m_pProxy0),
+				m_pProxy1(other.m_pProxy1),
+				m_algorithm(other.m_algorithm),
+				m_userInfo(other.m_userInfo)
+	{
+	}
+	btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
+	{
+
+		//keep them sorted, so the std::set operations work
+		if (&proxy0 < &proxy1)
+        { 
+            m_pProxy0 = &proxy0; 
+            m_pProxy1 = &proxy1; 
+        }
+        else 
+        { 
+			m_pProxy0 = &proxy1; 
+            m_pProxy1 = &proxy0; 
+        }
+
+		m_algorithm = 0;
+		m_userInfo = 0;
+
+	}
+	
+	btBroadphaseProxy* m_pProxy0;
+	btBroadphaseProxy* m_pProxy1;
+	
+	mutable btCollisionAlgorithm* m_algorithm;
+	mutable void* m_userInfo;
+
+};
+
+/*
+//comparison for set operation, see Solid DT_Encounter
+SIMD_FORCE_INLINE bool operator<(const btBroadphasePair& a, const btBroadphasePair& b) 
+{ 
+    return a.m_pProxy0 < b.m_pProxy0 || 
+        (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1); 
+}
+*/
+
+
+
+class btBroadphasePairSortPredicate
+{
+	public:
+
+		bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
+		{
+			 return a.m_pProxy0 > b.m_pProxy0 || 
+				(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 > b.m_pProxy1) ||
+				(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm); 
+		}
+};
+
+
+SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b) 
+{
+	 return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
+}
+
+
+#endif //BROADPHASE_PROXY_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,23 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btCollisionAlgorithm.h"
+#include "btDispatcher.h"
+
+btCollisionAlgorithm::btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
+{
+	m_dispatcher = ci.m_dispatcher1;
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,80 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COLLISION_ALGORITHM_H
+#define COLLISION_ALGORITHM_H
+
+#include "LinearMath/btScalar.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+struct btBroadphaseProxy;
+class btDispatcher;
+class btManifoldResult;
+class btCollisionObject;
+struct btDispatcherInfo;
+class	btPersistentManifold;
+
+typedef btAlignedObjectArray<btPersistentManifold*>	btManifoldArray;
+
+struct btCollisionAlgorithmConstructionInfo
+{
+	btCollisionAlgorithmConstructionInfo()
+		:m_dispatcher1(0),
+		m_manifold(0)
+	{
+	}
+	btCollisionAlgorithmConstructionInfo(btDispatcher* dispatcher,int temp)
+		:m_dispatcher1(dispatcher)
+	{
+		(void)temp;
+	}
+
+	btDispatcher*	m_dispatcher1;
+	btPersistentManifold*	m_manifold;
+
+	int	getDispatcherId();
+
+};
+
+
+///btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatcher.
+///It is persistent over frames
+class btCollisionAlgorithm
+{
+
+protected:
+
+	btDispatcher*	m_dispatcher;
+
+protected:
+	int	getDispatcherId();
+	
+public:
+
+	btCollisionAlgorithm() {};
+
+	btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci);
+
+	virtual ~btCollisionAlgorithm() {};
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray) = 0;
+};
+
+
+#endif //COLLISION_ALGORITHM_H
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp	(revision 2122)
@@ -0,0 +1,1289 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btDbvt implementation by Nathanael Presson
+
+#include "btDbvt.h"
+
+//
+typedef btAlignedObjectArray<btDbvtNode*>			tNodeArray;
+typedef btAlignedObjectArray<const btDbvtNode*>	tConstNodeArray;
+
+//
+struct btDbvtNodeEnumerator : btDbvt::ICollide
+{
+tConstNodeArray	nodes;
+void Process(const btDbvtNode* n) { nodes.push_back(n); }
+};
+
+//
+static DBVT_INLINE int			indexof(const btDbvtNode* node)
+{
+return(node->parent->childs[1]==node);
+}
+
+//
+static DBVT_INLINE btDbvtVolume	merge(	const btDbvtVolume& a,
+										const btDbvtVolume& b)
+{
+#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
+DBVT_ALIGN char locals[sizeof(btDbvtAabbMm)];
+btDbvtVolume&	res=*(btDbvtVolume*)locals;
+#else
+btDbvtVolume	res;
+#endif
+Merge(a,b,res);
+return(res);
+}
+
+// volume+edge lengths
+static DBVT_INLINE btScalar		size(const btDbvtVolume& a)
+{
+const btVector3	edges=a.Lengths();
+return(	edges.x()*edges.y()*edges.z()+
+		edges.x()+edges.y()+edges.z());
+}
+
+//
+static void						getmaxdepth(const btDbvtNode* node,int depth,int& maxdepth)
+{
+if(node->isinternal())
+	{
+	getmaxdepth(node->childs[0],depth+1,maxdepth);
+	getmaxdepth(node->childs[0],depth+1,maxdepth);
+	} else maxdepth=btMax(maxdepth,depth);
+}
+
+//
+static DBVT_INLINE void			deletenode(	btDbvt* pdbvt,
+											btDbvtNode* node)
+{
+btAlignedFree(pdbvt->m_free);
+pdbvt->m_free=node;
+}
+	
+//
+static void						recursedeletenode(	btDbvt* pdbvt,
+													btDbvtNode* node)
+{
+if(!node->isleaf())
+	{
+	recursedeletenode(pdbvt,node->childs[0]);
+	recursedeletenode(pdbvt,node->childs[1]);
+	}
+if(node==pdbvt->m_root) pdbvt->m_root=0;
+deletenode(pdbvt,node);
+}
+
+//
+static DBVT_INLINE btDbvtNode*	createnode(	btDbvt* pdbvt,
+											btDbvtNode* parent,
+											void* data)
+{
+btDbvtNode*	node;
+if(pdbvt->m_free)
+	{ node=pdbvt->m_free;pdbvt->m_free=0; }
+	else
+	{ node=new(btAlignedAlloc(sizeof(btDbvtNode),16)) btDbvtNode(); }
+node->parent	=	parent;
+node->data		=	data;
+node->childs[1]	=	0;
+return(node);
+}
+
+//
+static DBVT_INLINE btDbvtNode*	createnode(	btDbvt* pdbvt,
+											btDbvtNode* parent,
+											const btDbvtVolume& volume,
+											void* data)
+{
+btDbvtNode*	node=createnode(pdbvt,parent,data);
+node->volume=volume;
+return(node);
+}
+
+//
+static DBVT_INLINE btDbvtNode*	createnode(	btDbvt* pdbvt,
+											btDbvtNode* parent,
+											const btDbvtVolume& volume0,
+											const btDbvtVolume& volume1,
+											void* data)
+{
+btDbvtNode*	node=createnode(pdbvt,parent,data);
+Merge(volume0,volume1,node->volume);
+return(node);
+}
+
+//
+static void						insertleaf(	btDbvt* pdbvt,
+											btDbvtNode* root,
+											btDbvtNode* leaf)
+{
+if(!pdbvt->m_root)
+	{
+	pdbvt->m_root	=	leaf;
+	leaf->parent	=	0;
+	}
+	else
+	{
+	if(!root->isleaf())
+		{
+		do	{
+			root=root->childs[Select(	leaf->volume,
+										root->childs[0]->volume,
+										root->childs[1]->volume)];
+			} while(!root->isleaf());
+		}
+	btDbvtNode*	prev=root->parent;
+	btDbvtNode*	node=createnode(pdbvt,prev,leaf->volume,root->volume,0);
+	if(prev)
+		{
+		prev->childs[indexof(root)]	=	node;
+		node->childs[0]				=	root;root->parent=node;
+		node->childs[1]				=	leaf;leaf->parent=node;
+		do	{
+			if(!prev->volume.Contain(node->volume))
+				Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
+				else
+				break;
+			node=prev;
+			} while(0!=(prev=node->parent));
+		}
+		else
+		{
+		node->childs[0]	=	root;root->parent=node;
+		node->childs[1]	=	leaf;leaf->parent=node;
+		pdbvt->m_root	=	node;
+		}
+	}
+}
+	
+//
+static btDbvtNode*				removeleaf(	btDbvt* pdbvt,
+											btDbvtNode* leaf)
+{
+if(leaf==pdbvt->m_root)
+	{
+	pdbvt->m_root=0;
+	return(0);
+	}
+	else
+	{
+	btDbvtNode*	parent=leaf->parent;
+	btDbvtNode*	prev=parent->parent;
+	btDbvtNode*	sibling=parent->childs[1-indexof(leaf)];			
+	if(prev)
+		{
+		prev->childs[indexof(parent)]=sibling;
+		sibling->parent=prev;
+		deletenode(pdbvt,parent);
+		while(prev)
+			{
+			const btDbvtVolume	pb=prev->volume;
+			Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
+			if(NotEqual(pb,prev->volume))
+				{
+				prev=prev->parent;
+				} else break;
+			}
+		return(prev?prev:pdbvt->m_root);
+		}
+		else
+		{								
+		pdbvt->m_root=sibling;
+		sibling->parent=0;
+		deletenode(pdbvt,parent);
+		return(pdbvt->m_root);
+		}			
+	}
+}
+
+//
+static void						fetchleaves(btDbvt* pdbvt,
+											btDbvtNode* root,
+											tNodeArray& leaves,
+											int depth=-1)
+{
+if(root->isinternal()&&depth)
+	{
+	fetchleaves(pdbvt,root->childs[0],leaves,depth-1);
+	fetchleaves(pdbvt,root->childs[1],leaves,depth-1);
+	deletenode(pdbvt,root);
+	}
+	else
+	{
+	leaves.push_back(root);
+	}
+}
+
+//
+static void						split(	const tNodeArray& leaves,
+										tNodeArray& left,
+										tNodeArray& right,
+										const btVector3& org,
+										const btVector3& axis)
+{
+left.resize(0);
+right.resize(0);
+for(int i=0,ni=leaves.size();i<ni;++i)
+	{
+	if(dot(axis,leaves[i]->volume.Center()-org)<0)
+		left.push_back(leaves[i]);
+		else
+		right.push_back(leaves[i]);
+	}
+}
+
+//
+static btDbvtVolume				bounds(	const tNodeArray& leaves)
+{
+#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
+DBVT_ALIGN char	locals[sizeof(btDbvtVolume)];
+btDbvtVolume&	volume=*(btDbvtVolume*)locals;
+volume=leaves[0]->volume;
+#else
+btDbvtVolume volume=leaves[0]->volume;
+#endif
+for(int i=1,ni=leaves.size();i<ni;++i)
+	{
+	Merge(volume,leaves[i]->volume,volume);
+	}
+return(volume);
+}
+
+//
+static void						bottomup(	btDbvt* pdbvt,
+											tNodeArray& leaves)
+{
+while(leaves.size()>1)
+	{
+	btScalar	minsize=SIMD_INFINITY;
+	int			minidx[2]={-1,-1};
+	for(int i=0;i<leaves.size();++i)
+		{
+		for(int j=i+1;j<leaves.size();++j)
+			{
+			const btScalar	sz=size(merge(leaves[i]->volume,leaves[j]->volume));
+			if(sz<minsize)
+				{
+				minsize		=	sz;
+				minidx[0]	=	i;
+				minidx[1]	=	j;
+				}
+			}
+		}
+	btDbvtNode*	n[]	=	{leaves[minidx[0]],leaves[minidx[1]]};
+	btDbvtNode*	p	=	createnode(pdbvt,0,n[0]->volume,n[1]->volume,0);
+	p->childs[0]		=	n[0];
+	p->childs[1]		=	n[1];
+	n[0]->parent		=	p;
+	n[1]->parent		=	p;
+	leaves[minidx[0]]	=	p;
+	leaves.swap(minidx[1],leaves.size()-1);
+	leaves.pop_back();
+	}
+}
+
+//
+static btDbvtNode*			topdown(btDbvt* pdbvt,
+									tNodeArray& leaves,
+									int bu_treshold)
+{
+static const btVector3	axis[]={btVector3(1,0,0),
+								btVector3(0,1,0),
+								btVector3(0,0,1)};
+if(leaves.size()>1)
+	{
+	if(leaves.size()>bu_treshold)
+		{
+		const btDbvtVolume	vol=bounds(leaves);
+		const btVector3			org=vol.Center();
+		tNodeArray				sets[2];
+		int						bestaxis=-1;
+		int						bestmidp=leaves.size();
+		int						splitcount[3][2]={{0,0},{0,0},{0,0}};
+		int i;
+		for( i=0;i<leaves.size();++i)
+			{
+			const btVector3	x=leaves[i]->volume.Center()-org;
+			for(int j=0;j<3;++j)
+				{
+				++splitcount[j][dot(x,axis[j])>0?1:0];
+				}
+			}
+		for( i=0;i<3;++i)
+			{
+			if((splitcount[i][0]>0)&&(splitcount[i][1]>0))
+				{
+				const int	midp=(int)btFabs(btScalar(splitcount[i][0]-splitcount[i][1]));
+				if(midp<bestmidp)
+					{
+					bestaxis=i;
+					bestmidp=midp;
+					}
+				}
+			}
+		if(bestaxis>=0)
+			{
+			sets[0].reserve(splitcount[bestaxis][0]);
+			sets[1].reserve(splitcount[bestaxis][1]);
+			split(leaves,sets[0],sets[1],org,axis[bestaxis]);
+			}
+			else
+			{
+			sets[0].reserve(leaves.size()/2+1);
+			sets[1].reserve(leaves.size()/2);
+			for(int i=0,ni=leaves.size();i<ni;++i)
+				{
+				sets[i&1].push_back(leaves[i]);
+				}
+			}
+		btDbvtNode*	node=createnode(pdbvt,0,vol,0);
+		node->childs[0]=topdown(pdbvt,sets[0],bu_treshold);
+		node->childs[1]=topdown(pdbvt,sets[1],bu_treshold);
+		node->childs[0]->parent=node;
+		node->childs[1]->parent=node;
+		return(node);
+		}
+		else
+		{
+		bottomup(pdbvt,leaves);
+		return(leaves[0]);
+		}
+	}
+return(leaves[0]);
+}
+
+//
+static DBVT_INLINE btDbvtNode*	sort(btDbvtNode* n,btDbvtNode*& r)
+{
+btDbvtNode*	p=n->parent;
+btAssert(n->isinternal());
+if(p>n)
+	{
+	const int		i=indexof(n);
+	const int		j=1-i;
+	btDbvtNode*	s=p->childs[j];
+	btDbvtNode*	q=p->parent;
+	btAssert(n==p->childs[i]);
+	if(q) q->childs[indexof(p)]=n; else r=n;
+	s->parent=n;
+	p->parent=n;
+	n->parent=q;
+	p->childs[0]=n->childs[0];
+	p->childs[1]=n->childs[1];
+	n->childs[0]->parent=p;
+	n->childs[1]->parent=p;
+	n->childs[i]=p;
+	n->childs[j]=s;
+	btSwap(p->volume,n->volume);
+	return(p);
+	}
+return(n);
+}
+
+//
+static DBVT_INLINE btDbvtNode*	walkup(btDbvtNode* n,int count)
+{
+while(n&&(count--)) n=n->parent;
+return(n);
+}
+
+//
+// Api
+//
+
+//
+				btDbvt::btDbvt()
+{
+m_root		=	0;
+m_free		=	0;
+m_lkhd		=	-1;
+m_leaves	=	0;
+m_opath		=	0;
+}
+
+//
+				btDbvt::~btDbvt()
+{
+clear();
+}
+
+//
+void			btDbvt::clear()
+{
+if(m_root)	recursedeletenode(this,m_root);
+btAlignedFree(m_free);
+m_free=0;
+}
+
+//
+void			btDbvt::optimizeBottomUp()
+{
+if(m_root)
+	{
+	tNodeArray leaves;
+	leaves.reserve(m_leaves);
+	fetchleaves(this,m_root,leaves);
+	bottomup(this,leaves);
+	m_root=leaves[0];
+	}
+}
+
+//
+void			btDbvt::optimizeTopDown(int bu_treshold)
+{
+if(m_root)
+	{
+	tNodeArray	leaves;
+	leaves.reserve(m_leaves);
+	fetchleaves(this,m_root,leaves);
+	m_root=topdown(this,leaves,bu_treshold);
+	}
+}
+
+//
+void			btDbvt::optimizeIncremental(int passes)
+{
+if(passes<0) passes=m_leaves;
+if(m_root&&(passes>0))
+	{
+	do	{
+		btDbvtNode*		node=m_root;
+		unsigned	bit=0;
+		while(node->isinternal())
+			{
+			node=sort(node,m_root)->childs[(m_opath>>bit)&1];
+			bit=(bit+1)&(sizeof(unsigned)*8-1);
+			}
+		update(node);
+		++m_opath;
+		} while(--passes);
+	}
+}
+
+//
+btDbvtNode*	btDbvt::insert(const btDbvtVolume& volume,void* data)
+{
+btDbvtNode*	leaf=createnode(this,0,volume,data);
+insertleaf(this,m_root,leaf);
+++m_leaves;
+return(leaf);
+}
+
+//
+void			btDbvt::update(btDbvtNode* leaf,int lookahead)
+{
+btDbvtNode*	root=removeleaf(this,leaf);
+if(root)
+	{
+	if(lookahead>=0)
+		{
+		for(int i=0;(i<lookahead)&&root->parent;++i)
+			{
+			root=root->parent;
+			}
+		} else root=m_root;
+	}
+insertleaf(this,root,leaf);
+}
+
+//
+void			btDbvt::update(btDbvtNode* leaf,const btDbvtVolume& volume)
+{
+btDbvtNode*	root=removeleaf(this,leaf);
+if(root)
+	{
+	if(m_lkhd>=0)
+		{
+		for(int i=0;(i<m_lkhd)&&root->parent;++i)
+			{
+			root=root->parent;
+			}
+		} else root=m_root;
+	}
+leaf->volume=volume;
+insertleaf(this,root,leaf);
+}
+
+//
+bool			btDbvt::update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity,btScalar margin)
+{
+if(leaf->volume.Contain(volume)) return(false);
+volume.Expand(btVector3(margin,margin,margin));
+volume.SignedExpand(velocity);
+update(leaf,volume);
+return(true);
+}
+
+//
+bool			btDbvt::update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity)
+{
+if(leaf->volume.Contain(volume)) return(false);
+volume.SignedExpand(velocity);
+update(leaf,volume);
+return(true);
+}
+
+//
+bool			btDbvt::update(btDbvtNode* leaf,btDbvtVolume volume,btScalar margin)
+{
+if(leaf->volume.Contain(volume)) return(false);
+volume.Expand(btVector3(margin,margin,margin));
+update(leaf,volume);
+return(true);
+}
+
+//
+void			btDbvt::remove(btDbvtNode* leaf)
+{
+removeleaf(this,leaf);
+deletenode(this,leaf);
+--m_leaves;
+}
+
+//
+void			btDbvt::write(IWriter* iwriter) const
+{
+btDbvtNodeEnumerator	nodes;
+nodes.nodes.reserve(m_leaves*2);
+enumNodes(m_root,nodes);
+iwriter->Prepare(m_root,nodes.nodes.size());
+for(int i=0;i<nodes.nodes.size();++i)
+	{
+	const btDbvtNode* n=nodes.nodes[i];
+	int			p=-1;
+	if(n->parent) p=nodes.nodes.findLinearSearch(n->parent);
+	if(n->isinternal())
+		{
+		const int	c0=nodes.nodes.findLinearSearch(n->childs[0]);
+		const int	c1=nodes.nodes.findLinearSearch(n->childs[1]);
+		iwriter->WriteNode(n,i,p,c0,c1);
+		}
+		else
+		{
+		iwriter->WriteLeaf(n,i,p);
+		}	
+	}
+}
+
+//
+void			btDbvt::clone(btDbvt& dest,IClone* iclone) const
+{
+dest.clear();
+if(m_root!=0)
+	{	
+	btAlignedObjectArray<sStkCLN>	stack;
+	stack.reserve(m_leaves);
+	stack.push_back(sStkCLN(m_root,0));
+	do	{
+		const int		i=stack.size()-1;
+		const sStkCLN	e=stack[i];
+		btDbvtNode*			n=createnode(&dest,e.parent,e.node->volume,e.node->data);
+		stack.pop_back();
+		if(e.parent!=0)
+			e.parent->childs[i&1]=n;
+			else
+			dest.m_root=n;
+		if(e.node->isinternal())
+			{
+			stack.push_back(sStkCLN(e.node->childs[0],n));
+			stack.push_back(sStkCLN(e.node->childs[1],n));
+			}
+			else
+			{
+			iclone->CloneLeaf(n);
+			}
+		} while(stack.size()>0);
+	}
+}
+
+//
+int				btDbvt::maxdepth(const btDbvtNode* node)
+{
+int	depth=0;
+if(node) getmaxdepth(node,1,depth);
+return(depth);
+}
+
+//
+int				btDbvt::countLeaves(const btDbvtNode* node)
+{
+if(node->isinternal())
+	return(countLeaves(node->childs[0])+countLeaves(node->childs[1]));
+	else
+	return(1);
+}
+
+//
+void			btDbvt::extractLeaves(const btDbvtNode* node,btAlignedObjectArray<const btDbvtNode*>& leaves)
+{
+if(node->isinternal())
+	{
+	extractLeaves(node->childs[0],leaves);
+	extractLeaves(node->childs[1],leaves);
+	}
+	else
+	{
+	leaves.push_back(node);
+	}	
+}
+
+//
+#if DBVT_ENABLE_BENCHMARK
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "LinearMath/btQuickProf.h"
+
+/*
+q6600,2.4ghz
+
+/Ox /Ob2 /Oi /Ot /I "." /I "..\.." /I "..\..\src" /D "NDEBUG" /D "_LIB" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32"
+/GF /FD /MT /GS- /Gy /arch:SSE2 /Zc:wchar_t- /Fp"..\..\out\release8\build\libbulletcollision\libbulletcollision.pch"
+/Fo"..\..\out\release8\build\libbulletcollision\\"
+/Fd"..\..\out\release8\build\libbulletcollision\bulletcollision.pdb"
+/W3 /nologo /c /Wp64 /Zi /errorReport:prompt
+
+Benchmarking dbvt...
+        World scale: 100.000000
+        Extents base: 1.000000
+        Extents range: 4.000000
+        Leaves: 8192
+        sizeof(btDbvtVolume): 32 bytes
+        sizeof(btDbvtNode):   44 bytes
+[1] btDbvtVolume intersections: 3499 ms (-1%)
+[2] btDbvtVolume merges: 1934 ms (0%)
+[3] btDbvt::collideTT: 5485 ms (-21%)
+[4] btDbvt::collideTT self: 2814 ms (-20%)
+[5] btDbvt::collideTT xform: 7379 ms (-1%)
+[6] btDbvt::collideTT xform,self: 7270 ms (-2%)
+[7] btDbvt::collideRAY: 6314 ms (0%),(332143 r/s)
+[8] insert/remove: 2093 ms (0%),(1001983 ir/s)
+[9] updates (teleport): 1879 ms (-3%),(1116100 u/s)
+[10] updates (jitter): 1244 ms (-4%),(1685813 u/s)
+[11] optimize (incremental): 2514 ms (0%),(1668000 o/s)
+[12] btDbvtVolume notequal: 3659 ms (0%)
+[13] culling(OCL+fullsort): 2218 ms (0%),(461 t/s)
+[14] culling(OCL+qsort): 3688 ms (5%),(2221 t/s)
+[15] culling(KDOP+qsort): 1139 ms (-1%),(7192 t/s)
+[16] insert/remove batch(256): 5092 ms (0%),(823704 bir/s)
+[17] btDbvtVolume select: 3419 ms (0%)
+*/
+
+struct btDbvtBenchmark
+{
+struct NilPolicy : btDbvt::ICollide
+	{
+	NilPolicy() : m_pcount(0),m_depth(-SIMD_INFINITY),m_checksort(true)		{}
+	void	Process(const btDbvtNode*,const btDbvtNode*)				{ ++m_pcount; }
+	void	Process(const btDbvtNode*)									{ ++m_pcount; }
+	void	Process(const btDbvtNode*,btScalar depth)
+		{
+		++m_pcount;
+		if(m_checksort)
+			{ if(depth>=m_depth) m_depth=depth; else printf("wrong depth: %f (should be >= %f)\r\n",depth,m_depth); }
+		}
+	int			m_pcount;
+	btScalar	m_depth;
+	bool		m_checksort;
+	};
+struct P14 : btDbvt::ICollide
+	{
+	struct Node
+		{
+		const btDbvtNode*	leaf;
+		btScalar			depth;
+		};
+	void Process(const btDbvtNode* leaf,btScalar depth)
+		{
+		Node	n;
+		n.leaf	=	leaf;
+		n.depth	=	depth;
+		}
+	static int sortfnc(const Node& a,const Node& b)
+		{
+		if(a.depth<b.depth) return(+1);
+		if(a.depth>b.depth) return(-1);
+		return(0);
+		}
+	btAlignedObjectArray<Node>		m_nodes;
+	};
+struct P15 : btDbvt::ICollide
+	{
+	struct Node
+		{
+		const btDbvtNode*	leaf;
+		btScalar			depth;
+		};
+	void Process(const btDbvtNode* leaf)
+		{
+		Node	n;
+		n.leaf	=	leaf;
+		n.depth	=	dot(leaf->volume.Center(),m_axis);
+		}
+	static int sortfnc(const Node& a,const Node& b)
+		{
+		if(a.depth<b.depth) return(+1);
+		if(a.depth>b.depth) return(-1);
+		return(0);
+		}
+	btAlignedObjectArray<Node>		m_nodes;
+	btVector3						m_axis;
+	};
+static btScalar			RandUnit()
+	{
+	return(rand()/(btScalar)RAND_MAX);
+	}
+static btVector3		RandVector3()
+	{
+	return(btVector3(RandUnit(),RandUnit(),RandUnit()));
+	}
+static btVector3		RandVector3(btScalar cs)
+	{
+	return(RandVector3()*cs-btVector3(cs,cs,cs)/2);
+	}
+static btDbvtVolume	RandVolume(btScalar cs,btScalar eb,btScalar es)
+	{
+	return(btDbvtVolume::FromCE(RandVector3(cs),btVector3(eb,eb,eb)+RandVector3()*es));
+	}
+static btTransform		RandTransform(btScalar cs)
+	{
+	btTransform	t;
+	t.setOrigin(RandVector3(cs));
+	t.setRotation(btQuaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized());
+	return(t);
+	}
+static void				RandTree(btScalar cs,btScalar eb,btScalar es,int leaves,btDbvt& dbvt)
+	{
+	dbvt.clear();
+	for(int i=0;i<leaves;++i)
+		{
+		dbvt.insert(RandVolume(cs,eb,es),0);
+		}
+	}
+};
+
+void			btDbvt::benchmark()
+{
+static const btScalar	cfgVolumeCenterScale		=	100;
+static const btScalar	cfgVolumeExentsBase			=	1;
+static const btScalar	cfgVolumeExentsScale		=	4;
+static const int		cfgLeaves					=	8192;
+static const bool		cfgEnable					=	true;
+
+//[1] btDbvtVolume intersections
+bool					cfgBenchmark1_Enable		=	cfgEnable;
+static const int		cfgBenchmark1_Iterations	=	8;
+static const int		cfgBenchmark1_Reference		=	3499;
+//[2] btDbvtVolume merges
+bool					cfgBenchmark2_Enable		=	cfgEnable;
+static const int		cfgBenchmark2_Iterations	=	4;
+static const int		cfgBenchmark2_Reference		=	1945;
+//[3] btDbvt::collideTT
+bool					cfgBenchmark3_Enable		=	cfgEnable;
+static const int		cfgBenchmark3_Iterations	=	512;
+static const int		cfgBenchmark3_Reference		=	5485;
+//[4] btDbvt::collideTT self
+bool					cfgBenchmark4_Enable		=	cfgEnable;
+static const int		cfgBenchmark4_Iterations	=	512;
+static const int		cfgBenchmark4_Reference		=	2814;
+//[5] btDbvt::collideTT xform
+bool					cfgBenchmark5_Enable		=	cfgEnable;
+static const int		cfgBenchmark5_Iterations	=	512;
+static const btScalar	cfgBenchmark5_OffsetScale	=	2;
+static const int		cfgBenchmark5_Reference		=	7379;
+//[6] btDbvt::collideTT xform,self
+bool					cfgBenchmark6_Enable		=	cfgEnable;
+static const int		cfgBenchmark6_Iterations	=	512;
+static const btScalar	cfgBenchmark6_OffsetScale	=	2;
+static const int		cfgBenchmark6_Reference		=	7270;
+//[7] btDbvt::collideRAY
+bool					cfgBenchmark7_Enable		=	cfgEnable;
+static const int		cfgBenchmark7_Passes		=	32;
+static const int		cfgBenchmark7_Iterations	=	65536;
+static const int		cfgBenchmark7_Reference		=	6307;
+//[8] insert/remove
+bool					cfgBenchmark8_Enable		=	cfgEnable;
+static const int		cfgBenchmark8_Passes		=	32;
+static const int		cfgBenchmark8_Iterations	=	65536;
+static const int		cfgBenchmark8_Reference		=	2105;
+//[9] updates (teleport)
+bool					cfgBenchmark9_Enable		=	cfgEnable;
+static const int		cfgBenchmark9_Passes		=	32;
+static const int		cfgBenchmark9_Iterations	=	65536;
+static const int		cfgBenchmark9_Reference		=	1879;
+//[10] updates (jitter)
+bool					cfgBenchmark10_Enable		=	cfgEnable;
+static const btScalar	cfgBenchmark10_Scale		=	cfgVolumeCenterScale/10000;
+static const int		cfgBenchmark10_Passes		=	32;
+static const int		cfgBenchmark10_Iterations	=	65536;
+static const int		cfgBenchmark10_Reference	=	1244;
+//[11] optimize (incremental)
+bool					cfgBenchmark11_Enable		=	cfgEnable;
+static const int		cfgBenchmark11_Passes		=	64;
+static const int		cfgBenchmark11_Iterations	=	65536;
+static const int		cfgBenchmark11_Reference	=	2510;
+//[12] btDbvtVolume notequal
+bool					cfgBenchmark12_Enable		=	cfgEnable;
+static const int		cfgBenchmark12_Iterations	=	32;
+static const int		cfgBenchmark12_Reference	=	3677;
+//[13] culling(OCL+fullsort)
+bool					cfgBenchmark13_Enable		=	cfgEnable;
+static const int		cfgBenchmark13_Iterations	=	1024;
+static const int		cfgBenchmark13_Reference	=	2231;
+//[14] culling(OCL+qsort)
+bool					cfgBenchmark14_Enable		=	cfgEnable;
+static const int		cfgBenchmark14_Iterations	=	8192;
+static const int		cfgBenchmark14_Reference	=	3500;
+//[15] culling(KDOP+qsort)
+bool					cfgBenchmark15_Enable		=	cfgEnable;
+static const int		cfgBenchmark15_Iterations	=	8192;
+static const int		cfgBenchmark15_Reference	=	1151;
+//[16] insert/remove batch
+bool					cfgBenchmark16_Enable		=	cfgEnable;
+static const int		cfgBenchmark16_BatchCount	=	256;
+static const int		cfgBenchmark16_Passes		=	16384;
+static const int		cfgBenchmark16_Reference	=	5138;
+//[17] select
+bool					cfgBenchmark17_Enable		=	cfgEnable;
+static const int		cfgBenchmark17_Iterations	=	4;
+static const int		cfgBenchmark17_Reference	=	3390;
+
+btClock					wallclock;
+printf("Benchmarking dbvt...\r\n");
+printf("\tWorld scale: %f\r\n",cfgVolumeCenterScale);
+printf("\tExtents base: %f\r\n",cfgVolumeExentsBase);
+printf("\tExtents range: %f\r\n",cfgVolumeExentsScale);
+printf("\tLeaves: %u\r\n",cfgLeaves);
+printf("\tsizeof(btDbvtVolume): %u bytes\r\n",sizeof(btDbvtVolume));
+printf("\tsizeof(btDbvtNode):   %u bytes\r\n",sizeof(btDbvtNode));
+if(cfgBenchmark1_Enable)
+	{// Benchmark 1	
+	srand(380843);
+	btAlignedObjectArray<btDbvtVolume>	volumes;
+	btAlignedObjectArray<bool>			results;
+	volumes.resize(cfgLeaves);
+	results.resize(cfgLeaves);
+	for(int i=0;i<cfgLeaves;++i)
+		{
+		volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
+		}
+	printf("[1] btDbvtVolume intersections: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark1_Iterations;++i)
+		{
+		for(int j=0;j<cfgLeaves;++j)
+			{
+			for(int k=0;k<cfgLeaves;++k)
+				{
+				results[k]=Intersect(volumes[j],volumes[k]);
+				}
+			}
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark1_Reference)*100/time);
+	}
+if(cfgBenchmark2_Enable)
+	{// Benchmark 2	
+	srand(380843);
+	btAlignedObjectArray<btDbvtVolume>	volumes;
+	btAlignedObjectArray<btDbvtVolume>	results;
+	volumes.resize(cfgLeaves);
+	results.resize(cfgLeaves);
+	for(int i=0;i<cfgLeaves;++i)
+		{
+		volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
+		}
+	printf("[2] btDbvtVolume merges: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark2_Iterations;++i)
+		{
+		for(int j=0;j<cfgLeaves;++j)
+			{
+			for(int k=0;k<cfgLeaves;++k)
+				{
+				Merge(volumes[j],volumes[k],results[k]);
+				}
+			}
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark2_Reference)*100/time);
+	}
+if(cfgBenchmark3_Enable)
+	{// Benchmark 3	
+	srand(380843);
+	btDbvt						dbvt[2];
+	btDbvtBenchmark::NilPolicy	policy;
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[0]);
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[1]);
+	dbvt[0].optimizeTopDown();
+	dbvt[1].optimizeTopDown();
+	printf("[3] btDbvt::collideTT: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark3_Iterations;++i)
+		{
+		btDbvt::collideTT(dbvt[0].m_root,dbvt[1].m_root,policy);
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark3_Reference)*100/time);
+	}
+if(cfgBenchmark4_Enable)
+	{// Benchmark 4
+	srand(380843);
+	btDbvt						dbvt;
+	btDbvtBenchmark::NilPolicy	policy;
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	printf("[4] btDbvt::collideTT self: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark4_Iterations;++i)
+		{
+		btDbvt::collideTT(dbvt.m_root,dbvt.m_root,policy);
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark4_Reference)*100/time);
+	}
+if(cfgBenchmark5_Enable)
+	{// Benchmark 5	
+	srand(380843);
+	btDbvt								dbvt[2];
+	btAlignedObjectArray<btTransform>	transforms;
+	btDbvtBenchmark::NilPolicy			policy;
+	transforms.resize(cfgBenchmark5_Iterations);
+	for(int i=0;i<transforms.size();++i)
+		{
+		transforms[i]=btDbvtBenchmark::RandTransform(cfgVolumeCenterScale*cfgBenchmark5_OffsetScale);
+		}
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[0]);
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[1]);
+	dbvt[0].optimizeTopDown();
+	dbvt[1].optimizeTopDown();
+	printf("[5] btDbvt::collideTT xform: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark5_Iterations;++i)
+		{
+		btDbvt::collideTT(dbvt[0].m_root,dbvt[1].m_root,transforms[i],policy);
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark5_Reference)*100/time);
+	}
+if(cfgBenchmark6_Enable)
+	{// Benchmark 6	
+	srand(380843);
+	btDbvt								dbvt;
+	btAlignedObjectArray<btTransform>	transforms;
+	btDbvtBenchmark::NilPolicy			policy;
+	transforms.resize(cfgBenchmark6_Iterations);
+	for(int i=0;i<transforms.size();++i)
+		{
+		transforms[i]=btDbvtBenchmark::RandTransform(cfgVolumeCenterScale*cfgBenchmark6_OffsetScale);
+		}
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	printf("[6] btDbvt::collideTT xform,self: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark6_Iterations;++i)
+		{
+		btDbvt::collideTT(dbvt.m_root,dbvt.m_root,transforms[i],policy);		
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark6_Reference)*100/time);
+	}
+if(cfgBenchmark7_Enable)
+	{// Benchmark 7	
+	srand(380843);
+	btDbvt								dbvt;
+	btAlignedObjectArray<btVector3>		rayorg;
+	btAlignedObjectArray<btVector3>		raydir;
+	btDbvtBenchmark::NilPolicy			policy;
+	rayorg.resize(cfgBenchmark7_Iterations);
+	raydir.resize(cfgBenchmark7_Iterations);
+	for(int i=0;i<rayorg.size();++i)
+		{
+		rayorg[i]=btDbvtBenchmark::RandVector3(cfgVolumeCenterScale*2);
+		raydir[i]=btDbvtBenchmark::RandVector3(cfgVolumeCenterScale*2);
+		}
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	printf("[7] btDbvt::collideRAY: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark7_Passes;++i)
+		{
+		for(int j=0;j<cfgBenchmark7_Iterations;++j)
+			{
+			btDbvt::collideRAY(dbvt.m_root,rayorg[j],raydir[j],policy);
+			}
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	unsigned	rays=cfgBenchmark7_Passes*cfgBenchmark7_Iterations;
+	printf("%u ms (%i%%),(%u r/s)\r\n",time,(time-cfgBenchmark7_Reference)*100/time,(rays*1000)/time);
+	}
+if(cfgBenchmark8_Enable)
+	{// Benchmark 8	
+	srand(380843);
+	btDbvt								dbvt;
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	printf("[8] insert/remove: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark8_Passes;++i)
+		{
+		for(int j=0;j<cfgBenchmark8_Iterations;++j)
+			{
+			dbvt.remove(dbvt.insert(btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale),0));
+			}
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	ir=cfgBenchmark8_Passes*cfgBenchmark8_Iterations;
+	printf("%u ms (%i%%),(%u ir/s)\r\n",time,(time-cfgBenchmark8_Reference)*100/time,ir*1000/time);
+	}
+if(cfgBenchmark9_Enable)
+	{// Benchmark 9	
+	srand(380843);
+	btDbvt										dbvt;
+	btAlignedObjectArray<const btDbvtNode*>	leaves;
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	dbvt.extractLeaves(dbvt.m_root,leaves);
+	printf("[9] updates (teleport): ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark9_Passes;++i)
+		{
+		for(int j=0;j<cfgBenchmark9_Iterations;++j)
+			{
+			dbvt.update(const_cast<btDbvtNode*>(leaves[rand()%cfgLeaves]),
+						btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale));
+			}
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	up=cfgBenchmark9_Passes*cfgBenchmark9_Iterations;
+	printf("%u ms (%i%%),(%u u/s)\r\n",time,(time-cfgBenchmark9_Reference)*100/time,up*1000/time);
+	}
+if(cfgBenchmark10_Enable)
+	{// Benchmark 10	
+	srand(380843);
+	btDbvt										dbvt;
+	btAlignedObjectArray<const btDbvtNode*>	leaves;
+	btAlignedObjectArray<btVector3>				vectors;
+	vectors.resize(cfgBenchmark10_Iterations);
+	for(int i=0;i<vectors.size();++i)
+		{
+		vectors[i]=(btDbvtBenchmark::RandVector3()*2-btVector3(1,1,1))*cfgBenchmark10_Scale;
+		}
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	dbvt.extractLeaves(dbvt.m_root,leaves);
+	printf("[10] updates (jitter): ");
+	wallclock.reset();
+	
+	for(int i=0;i<cfgBenchmark10_Passes;++i)
+		{
+		for(int j=0;j<cfgBenchmark10_Iterations;++j)
+			{			
+			const btVector3&	d=vectors[j];
+			btDbvtNode*		l=const_cast<btDbvtNode*>(leaves[rand()%cfgLeaves]);
+			btDbvtVolume		v=btDbvtVolume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d);
+			dbvt.update(l,v);
+			}
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	up=cfgBenchmark10_Passes*cfgBenchmark10_Iterations;
+	printf("%u ms (%i%%),(%u u/s)\r\n",time,(time-cfgBenchmark10_Reference)*100/time,up*1000/time);
+	}
+if(cfgBenchmark11_Enable)
+	{// Benchmark 11	
+	srand(380843);
+	btDbvt										dbvt;
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	printf("[11] optimize (incremental): ");
+	wallclock.reset();	
+	for(int i=0;i<cfgBenchmark11_Passes;++i)
+		{
+		dbvt.optimizeIncremental(cfgBenchmark11_Iterations);
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	op=cfgBenchmark11_Passes*cfgBenchmark11_Iterations;
+	printf("%u ms (%i%%),(%u o/s)\r\n",time,(time-cfgBenchmark11_Reference)*100/time,op/time*1000);
+	}
+if(cfgBenchmark12_Enable)
+	{// Benchmark 12	
+	srand(380843);
+	btAlignedObjectArray<btDbvtVolume>	volumes;
+	btAlignedObjectArray<bool>				results;
+	volumes.resize(cfgLeaves);
+	results.resize(cfgLeaves);
+	for(int i=0;i<cfgLeaves;++i)
+		{
+		volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
+		}
+	printf("[12] btDbvtVolume notequal: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark12_Iterations;++i)
+		{
+		for(int j=0;j<cfgLeaves;++j)
+			{
+			for(int k=0;k<cfgLeaves;++k)
+				{
+				results[k]=NotEqual(volumes[j],volumes[k]);
+				}
+			}
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark12_Reference)*100/time);
+	}
+if(cfgBenchmark13_Enable)
+	{// Benchmark 13	
+	srand(380843);
+	btDbvt								dbvt;
+	btAlignedObjectArray<btVector3>		vectors;
+	btDbvtBenchmark::NilPolicy			policy;
+	vectors.resize(cfgBenchmark13_Iterations);
+	for(int i=0;i<vectors.size();++i)
+		{
+		vectors[i]=(btDbvtBenchmark::RandVector3()*2-btVector3(1,1,1)).normalized();
+		}
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	printf("[13] culling(OCL+fullsort): ");
+	wallclock.reset();	
+	for(int i=0;i<cfgBenchmark13_Iterations;++i)
+		{
+		static const btScalar	offset=0;
+		policy.m_depth=-SIMD_INFINITY;
+		dbvt.collideOCL(dbvt.m_root,&vectors[i],&offset,vectors[i],1,policy);
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	t=cfgBenchmark13_Iterations;
+	printf("%u ms (%i%%),(%u t/s)\r\n",time,(time-cfgBenchmark13_Reference)*100/time,(t*1000)/time);
+	}
+if(cfgBenchmark14_Enable)
+	{// Benchmark 14	
+	srand(380843);
+	btDbvt								dbvt;
+	btAlignedObjectArray<btVector3>		vectors;
+	btDbvtBenchmark::P14				policy;
+	vectors.resize(cfgBenchmark14_Iterations);
+	for(int i=0;i<vectors.size();++i)
+		{
+		vectors[i]=(btDbvtBenchmark::RandVector3()*2-btVector3(1,1,1)).normalized();
+		}
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	policy.m_nodes.reserve(cfgLeaves);
+	printf("[14] culling(OCL+qsort): ");
+	wallclock.reset();	
+	for(int i=0;i<cfgBenchmark14_Iterations;++i)
+		{
+		static const btScalar	offset=0;
+		policy.m_nodes.resize(0);
+		dbvt.collideOCL(dbvt.m_root,&vectors[i],&offset,vectors[i],1,policy,false);
+		policy.m_nodes.quickSort(btDbvtBenchmark::P14::sortfnc);
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	t=cfgBenchmark14_Iterations;
+	printf("%u ms (%i%%),(%u t/s)\r\n",time,(time-cfgBenchmark14_Reference)*100/time,(t*1000)/time);
+	}
+if(cfgBenchmark15_Enable)
+	{// Benchmark 15	
+	srand(380843);
+	btDbvt								dbvt;
+	btAlignedObjectArray<btVector3>		vectors;
+	btDbvtBenchmark::P15				policy;
+	vectors.resize(cfgBenchmark15_Iterations);
+	for(int i=0;i<vectors.size();++i)
+		{
+		vectors[i]=(btDbvtBenchmark::RandVector3()*2-btVector3(1,1,1)).normalized();
+		}
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	policy.m_nodes.reserve(cfgLeaves);
+	printf("[15] culling(KDOP+qsort): ");
+	wallclock.reset();	
+	for(int i=0;i<cfgBenchmark15_Iterations;++i)
+		{
+		static const btScalar	offset=0;
+		policy.m_nodes.resize(0);
+		policy.m_axis=vectors[i];
+		dbvt.collideKDOP(dbvt.m_root,&vectors[i],&offset,1,policy);
+		policy.m_nodes.quickSort(btDbvtBenchmark::P15::sortfnc);
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	t=cfgBenchmark15_Iterations;
+	printf("%u ms (%i%%),(%u t/s)\r\n",time,(time-cfgBenchmark15_Reference)*100/time,(t*1000)/time);
+	}
+if(cfgBenchmark16_Enable)
+	{// Benchmark 16	
+	srand(380843);
+	btDbvt								dbvt;
+	btAlignedObjectArray<btDbvtNode*>	batch;
+	btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
+	dbvt.optimizeTopDown();
+	batch.reserve(cfgBenchmark16_BatchCount);
+	printf("[16] insert/remove batch(%u): ",cfgBenchmark16_BatchCount);
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark16_Passes;++i)
+		{
+		for(int j=0;j<cfgBenchmark16_BatchCount;++j)
+			{
+			batch.push_back(dbvt.insert(btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale),0));
+			}
+		for(int j=0;j<cfgBenchmark16_BatchCount;++j)
+			{
+			dbvt.remove(batch[j]);
+			}
+		batch.resize(0);
+		}
+	const int	time=(int)wallclock.getTimeMilliseconds();
+	const int	ir=cfgBenchmark16_Passes*cfgBenchmark16_BatchCount;
+	printf("%u ms (%i%%),(%u bir/s)\r\n",time,(time-cfgBenchmark16_Reference)*100/time,int(ir*1000.0/time));
+	}
+if(cfgBenchmark17_Enable)
+	{// Benchmark 17
+	srand(380843);
+	btAlignedObjectArray<btDbvtVolume>	volumes;
+	btAlignedObjectArray<int>			results;
+	btAlignedObjectArray<int>			indices;
+	volumes.resize(cfgLeaves);
+	results.resize(cfgLeaves);
+	indices.resize(cfgLeaves);
+	for(int i=0;i<cfgLeaves;++i)
+		{
+		indices[i]=i;
+		volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
+		}
+	for(int i=0;i<cfgLeaves;++i)
+		{
+		btSwap(indices[i],indices[rand()%cfgLeaves]);
+		}
+	printf("[17] btDbvtVolume select: ");
+	wallclock.reset();
+	for(int i=0;i<cfgBenchmark17_Iterations;++i)
+		{
+		for(int j=0;j<cfgLeaves;++j)
+			{
+			for(int k=0;k<cfgLeaves;++k)
+				{
+				const int idx=indices[k];
+				results[idx]=Select(volumes[idx],volumes[j],volumes[k]);
+				}
+			}
+		}
+	const int time=(int)wallclock.getTimeMilliseconds();
+	printf("%u ms (%i%%)\r\n",time,(time-cfgBenchmark17_Reference)*100/time);
+	}
+printf("\r\n\r\n");
+}
+#endif
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h	(revision 2122)
@@ -0,0 +1,1113 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btDbvt implementation by Nathanael Presson
+
+#ifndef BT_DYNAMIC_BOUNDING_VOLUME_TREE_H
+#define BT_DYNAMIC_BOUNDING_VOLUME_TREE_H
+
+#include "LinearMath/btAlignedObjectArray.h"
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+
+//
+// Compile time configuration
+//
+
+
+// Implementation profiles
+#define DBVT_IMPL_GENERIC		0	// Generic implementation	
+#define DBVT_IMPL_SSE			1	// SSE
+
+// Template implementation of ICollide
+#ifdef WIN32
+	#if (defined (_MSC_VER) && _MSC_VER >= 1400)
+	#define	DBVT_USE_TEMPLATE		1
+	#else
+	#define	DBVT_USE_TEMPLATE		0
+#endif
+#else
+#define	DBVT_USE_TEMPLATE		0
+#endif
+
+// Use only intrinsics instead of inline asm
+#define DBVT_USE_INTRINSIC_SSE	1
+
+// Using memmov for collideOCL
+#define DBVT_USE_MEMMOVE		1
+
+// Enable benchmarking code
+#define	DBVT_ENABLE_BENCHMARK	0
+
+// Inlining
+#define DBVT_INLINE				SIMD_FORCE_INLINE
+// Align
+#ifdef WIN32
+#define DBVT_ALIGN				__declspec(align(16))
+#else
+#define DBVT_ALIGN
+#endif
+
+// Specific methods implementation
+
+//SSE gives errors on a MSVC 7.1
+#if (defined (WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))
+#define DBVT_SELECT_IMPL		DBVT_IMPL_SSE
+#define DBVT_MERGE_IMPL			DBVT_IMPL_SSE
+#define DBVT_INT0_IMPL			DBVT_IMPL_SSE
+#else
+#define DBVT_SELECT_IMPL		DBVT_IMPL_GENERIC
+#define DBVT_MERGE_IMPL			DBVT_IMPL_GENERIC
+#define DBVT_INT0_IMPL			DBVT_IMPL_GENERIC
+#endif
+
+#if	(DBVT_SELECT_IMPL==DBVT_IMPL_SSE)||	\
+	(DBVT_MERGE_IMPL==DBVT_IMPL_SSE)||	\
+	(DBVT_INT0_IMPL==DBVT_IMPL_SSE)
+#include <emmintrin.h>
+#endif
+
+//
+// Auto config and checks
+//
+
+#if DBVT_USE_TEMPLATE
+#define	DBVT_VIRTUAL
+#define DBVT_VIRTUAL_DTOR(a)
+#define DBVT_PREFIX					template <typename T>
+#define DBVT_IPOLICY				T& policy
+#define DBVT_CHECKTYPE				static const ICollide&	typechecker=*(T*)0;
+#else
+#define	DBVT_VIRTUAL_DTOR(a)		virtual ~a() {}
+#define DBVT_VIRTUAL				virtual
+#define DBVT_PREFIX
+#define DBVT_IPOLICY				ICollide& policy
+#define DBVT_CHECKTYPE
+#endif
+
+#if DBVT_USE_MEMMOVE
+#ifndef __CELLOS_LV2__
+#include <memory.h>
+#endif
+#include <string.h>
+#endif
+
+#ifndef DBVT_USE_TEMPLATE
+#error "DBVT_USE_TEMPLATE undefined"
+#endif
+
+#ifndef DBVT_USE_MEMMOVE
+#error "DBVT_USE_MEMMOVE undefined"
+#endif
+
+#ifndef DBVT_ENABLE_BENCHMARK
+#error "DBVT_ENABLE_BENCHMARK undefined"
+#endif
+
+#ifndef DBVT_SELECT_IMPL
+#error "DBVT_SELECT_IMPL undefined"
+#endif
+
+#ifndef DBVT_MERGE_IMPL
+#error "DBVT_MERGE_IMPL undefined"
+#endif
+
+#ifndef DBVT_INT0_IMPL
+#error "DBVT_INT0_IMPL undefined"
+#endif
+
+//
+// Defaults volumes
+//
+
+/* btDbvtAabbMm			*/ 
+struct	btDbvtAabbMm
+{
+DBVT_INLINE btVector3			Center() const	{ return((mi+mx)/2); }
+DBVT_INLINE btVector3			Lengths() const	{ return(mx-mi); }
+DBVT_INLINE btVector3			Extents() const	{ return((mx-mi)/2); }
+DBVT_INLINE const btVector3&	Mins() const	{ return(mi); }
+DBVT_INLINE const btVector3&	Maxs() const	{ return(mx); }
+static inline btDbvtAabbMm		FromCE(const btVector3& c,const btVector3& e);
+static inline btDbvtAabbMm		FromCR(const btVector3& c,btScalar r);
+static inline btDbvtAabbMm		FromMM(const btVector3& mi,const btVector3& mx);
+static inline btDbvtAabbMm		FromPoints(const btVector3* pts,int n);
+static inline btDbvtAabbMm		FromPoints(const btVector3** ppts,int n);
+DBVT_INLINE void				Expand(const btVector3& e);
+DBVT_INLINE void				SignedExpand(const btVector3& e);
+DBVT_INLINE bool				Contain(const btDbvtAabbMm& a) const;
+DBVT_INLINE int					Classify(const btVector3& n,btScalar o,int s) const;
+DBVT_INLINE btScalar			ProjectMinimum(const btVector3& v,unsigned signs) const;
+DBVT_INLINE friend bool			Intersect(	const btDbvtAabbMm& a,
+											const btDbvtAabbMm& b);
+DBVT_INLINE friend bool			Intersect(	const btDbvtAabbMm& a,
+											const btDbvtAabbMm& b,
+											const btTransform& xform);
+DBVT_INLINE friend bool			Intersect(	const btDbvtAabbMm& a,
+											const btVector3& b);
+DBVT_INLINE friend bool			Intersect(	const btDbvtAabbMm& a,
+											const btVector3& org,
+											const btVector3& invdir,
+											const unsigned* signs);
+DBVT_INLINE friend btScalar		Proximity(	const btDbvtAabbMm& a,
+											const btDbvtAabbMm& b);
+DBVT_INLINE friend int			Select(		const btDbvtAabbMm& o,
+											const btDbvtAabbMm& a,
+											const btDbvtAabbMm& b);
+DBVT_INLINE friend void			Merge(		const btDbvtAabbMm& a,
+											const btDbvtAabbMm& b,
+											btDbvtAabbMm& r);
+DBVT_INLINE friend bool			NotEqual(	const btDbvtAabbMm& a,
+											const btDbvtAabbMm& b);
+private:
+DBVT_INLINE void				AddSpan(const btVector3& d,btScalar& smi,btScalar& smx) const;
+private:
+btVector3	mi,mx;
+};
+
+// Types	
+typedef	btDbvtAabbMm	btDbvtVolume;
+
+/* btDbvtNode				*/ 
+struct	btDbvtNode
+{
+	btDbvtVolume	volume;
+	btDbvtNode*		parent;
+	DBVT_INLINE bool	isleaf() const		{ return(childs[1]==0); }
+	DBVT_INLINE bool	isinternal() const	{ return(!isleaf()); }
+	union	{
+			btDbvtNode*	childs[2];
+			void*	data;
+			int		dataAsInt;
+			};
+};
+
+///The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes (aabb tree).
+///This btDbvt is used for soft body collision detection and for the btDbvtBroadphase. It has a fast insert, remove and update of nodes.
+///Unlike the btQuantizedBvh, nodes can be dynamically moved around, which allows for change in topology of the underlying data structure.
+struct	btDbvt
+	{
+	/* Stack element	*/ 
+	struct	sStkNN
+		{
+		const btDbvtNode*	a;
+		const btDbvtNode*	b;
+		sStkNN() {}
+		sStkNN(const btDbvtNode* na,const btDbvtNode* nb) : a(na),b(nb) {}
+		};
+	struct	sStkNP
+		{
+		const btDbvtNode*	node;
+		int			mask;
+		sStkNP(const btDbvtNode* n,unsigned m) : node(n),mask(m) {}
+		};
+	struct	sStkNPS
+		{
+		const btDbvtNode*	node;
+		int			mask;
+		btScalar	value;
+		sStkNPS() {}
+		sStkNPS(const btDbvtNode* n,unsigned m,btScalar v) : node(n),mask(m),value(v) {}
+		};
+	struct	sStkCLN
+		{
+		const btDbvtNode*	node;
+		btDbvtNode*		parent;
+		sStkCLN(const btDbvtNode* n,btDbvtNode* p) : node(n),parent(p) {}
+		};
+	// Policies/Interfaces
+			
+	/* ICollide	*/ 
+	struct	ICollide
+		{		
+		DBVT_VIRTUAL_DTOR(ICollide)
+		DBVT_VIRTUAL void	Process(const btDbvtNode*,const btDbvtNode*)		{}
+		DBVT_VIRTUAL void	Process(const btDbvtNode*)					{}
+		DBVT_VIRTUAL void	Process(const btDbvtNode* n,btScalar)			{ Process(n); }
+		DBVT_VIRTUAL bool	Descent(const btDbvtNode*)					{ return(true); }
+		DBVT_VIRTUAL bool	AllLeaves(const btDbvtNode*)					{ return(true); }
+		};
+	/* IWriter	*/ 
+	struct	IWriter
+		{
+		virtual ~IWriter() {}
+		virtual void		Prepare(const btDbvtNode* root,int numnodes)=0;
+		virtual void		WriteNode(const btDbvtNode*,int index,int parent,int child0,int child1)=0;
+		virtual void		WriteLeaf(const btDbvtNode*,int index,int parent)=0;
+		};
+	/* IClone	*/ 
+	struct	IClone
+		{
+		virtual ~IClone()	{}
+		virtual void		CloneLeaf(btDbvtNode*) {}
+		};
+		
+	// Constants
+	enum	{
+			SIMPLE_STACKSIZE	=	64,
+			DOUBLE_STACKSIZE	=	SIMPLE_STACKSIZE*2
+			};
+		
+	// Fields
+	btDbvtNode*		m_root;
+	btDbvtNode*		m_free;
+	int				m_lkhd;
+	int				m_leaves;
+	unsigned		m_opath;
+	// Methods
+					btDbvt();
+					~btDbvt();
+	void			clear();
+	bool			empty() const { return(0==m_root); }
+	void			optimizeBottomUp();
+	void			optimizeTopDown(int bu_treshold=128);
+	void			optimizeIncremental(int passes);
+	btDbvtNode*		insert(const btDbvtVolume& box,void* data);
+	void			update(btDbvtNode* leaf,int lookahead=-1);
+	void			update(btDbvtNode* leaf,const btDbvtVolume& volume);
+	bool			update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity,btScalar margin);
+	bool			update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity);
+	bool			update(btDbvtNode* leaf,btDbvtVolume volume,btScalar margin);	
+	void			remove(btDbvtNode* leaf);
+	void			write(IWriter* iwriter) const;
+	void			clone(btDbvt& dest,IClone* iclone=0) const;
+	static int		maxdepth(const btDbvtNode* node);
+	static int		countLeaves(const btDbvtNode* node);
+	static void		extractLeaves(const btDbvtNode* node,btAlignedObjectArray<const btDbvtNode*>& leaves);
+	#if DBVT_ENABLE_BENCHMARK
+	static void		benchmark();
+	#else
+	static void		benchmark(){}
+	#endif
+	// DBVT_IPOLICY must support ICollide policy/interface
+	DBVT_PREFIX
+	static void		enumNodes(	const btDbvtNode* root,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		enumLeaves(	const btDbvtNode* root,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		collideTT(	const btDbvtNode* root0,
+								const btDbvtNode* root1,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		collideTT(	const btDbvtNode* root0,
+								const btDbvtNode* root1,
+								const btTransform& xform,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		collideTT(	const btDbvtNode* root0,
+								const btTransform& xform0,
+								const btDbvtNode* root1,
+								const btTransform& xform1,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		collideTV(	const btDbvtNode* root,
+								const btDbvtVolume& volume,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		collideRAY(	const btDbvtNode* root,
+								const btVector3& origin,
+								const btVector3& direction,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		collideKDOP(const btDbvtNode* root,
+								const btVector3* normals,
+								const btScalar* offsets,
+								int count,
+								DBVT_IPOLICY);
+	DBVT_PREFIX
+	static void		collideOCL(	const btDbvtNode* root,
+								const btVector3* normals,
+								const btScalar* offsets,
+								const btVector3& sortaxis,
+								int count,								
+								DBVT_IPOLICY,
+								bool fullsort=true);
+	DBVT_PREFIX
+	static void		collideTU(	const btDbvtNode* root,
+								DBVT_IPOLICY);
+	// Helpers	
+	static DBVT_INLINE int	nearest(const int* i,const btDbvt::sStkNPS* a,btScalar v,int l,int h)
+		{
+		int	m=0;
+		while(l<h)
+			{
+			m=(l+h)>>1;
+			if(a[i[m]].value>=v) l=m+1; else h=m;
+			}
+		return(h);
+		}
+	static DBVT_INLINE int	allocate(	btAlignedObjectArray<int>& ifree,
+										btAlignedObjectArray<sStkNPS>& stock,
+										const sStkNPS& value)
+		{
+		int	i;
+		if(ifree.size()>0)
+			{ i=ifree[ifree.size()-1];ifree.pop_back();stock[i]=value; }
+			else
+			{ i=stock.size();stock.push_back(value); }
+		return(i); 
+		}
+	//
+	private:
+					btDbvt(const btDbvt&)	{}	
+	};
+
+//
+// Inline's
+//
+
+//
+inline btDbvtAabbMm			btDbvtAabbMm::FromCE(const btVector3& c,const btVector3& e)
+{
+btDbvtAabbMm box;
+box.mi=c-e;box.mx=c+e;
+return(box);
+}
+	
+//
+inline btDbvtAabbMm			btDbvtAabbMm::FromCR(const btVector3& c,btScalar r)
+{
+return(FromCE(c,btVector3(r,r,r)));
+}
+	
+//
+inline btDbvtAabbMm			btDbvtAabbMm::FromMM(const btVector3& mi,const btVector3& mx)
+{
+btDbvtAabbMm box;
+box.mi=mi;box.mx=mx;
+return(box);
+}
+	
+//
+inline btDbvtAabbMm			btDbvtAabbMm::FromPoints(const btVector3* pts,int n)
+{
+btDbvtAabbMm box;
+box.mi=box.mx=pts[0];
+for(int i=1;i<n;++i)
+	{
+	box.mi.setMin(pts[i]);
+	box.mx.setMax(pts[i]);
+	}
+return(box);
+}
+
+//
+inline btDbvtAabbMm			btDbvtAabbMm::FromPoints(const btVector3** ppts,int n)
+{
+btDbvtAabbMm box;
+box.mi=box.mx=*ppts[0];
+for(int i=1;i<n;++i)
+	{
+	box.mi.setMin(*ppts[i]);
+	box.mx.setMax(*ppts[i]);
+	}
+return(box);
+}
+
+//
+DBVT_INLINE void		btDbvtAabbMm::Expand(const btVector3& e)
+{
+mi-=e;mx+=e;
+}
+	
+//
+DBVT_INLINE void		btDbvtAabbMm::SignedExpand(const btVector3& e)
+{
+if(e.x()>0) mx.setX(mx.x()+e[0]); else mi.setX(mi.x()+e[0]);
+if(e.y()>0) mx.setY(mx.y()+e[1]); else mi.setY(mi.y()+e[1]);
+if(e.z()>0) mx.setZ(mx.z()+e[2]); else mi.setZ(mi.z()+e[2]);
+}
+	
+//
+DBVT_INLINE bool		btDbvtAabbMm::Contain(const btDbvtAabbMm& a) const
+{
+return(	(mi.x()<=a.mi.x())&&
+		(mi.y()<=a.mi.y())&&
+		(mi.z()<=a.mi.z())&&
+		(mx.x()>=a.mx.x())&&
+		(mx.y()>=a.mx.y())&&
+		(mx.z()>=a.mx.z()));
+}
+
+//
+DBVT_INLINE int		btDbvtAabbMm::Classify(const btVector3& n,btScalar o,int s) const
+{
+btVector3			pi,px;
+switch(s)
+	{
+	case	(0+0+0):	px=btVector3(mi.x(),mi.y(),mi.z());
+						pi=btVector3(mx.x(),mx.y(),mx.z());break;
+	case	(1+0+0):	px=btVector3(mx.x(),mi.y(),mi.z());
+						pi=btVector3(mi.x(),mx.y(),mx.z());break;
+	case	(0+2+0):	px=btVector3(mi.x(),mx.y(),mi.z());
+						pi=btVector3(mx.x(),mi.y(),mx.z());break;
+	case	(1+2+0):	px=btVector3(mx.x(),mx.y(),mi.z());
+						pi=btVector3(mi.x(),mi.y(),mx.z());break;
+	case	(0+0+4):	px=btVector3(mi.x(),mi.y(),mx.z());
+						pi=btVector3(mx.x(),mx.y(),mi.z());break;
+	case	(1+0+4):	px=btVector3(mx.x(),mi.y(),mx.z());
+						pi=btVector3(mi.x(),mx.y(),mi.z());break;
+	case	(0+2+4):	px=btVector3(mi.x(),mx.y(),mx.z());
+						pi=btVector3(mx.x(),mi.y(),mi.z());break;
+	case	(1+2+4):	px=btVector3(mx.x(),mx.y(),mx.z());
+						pi=btVector3(mi.x(),mi.y(),mi.z());break;
+	}
+if((dot(n,px)+o)<0)		return(-1);
+if((dot(n,pi)+o)>=0)	return(+1);
+return(0);
+}
+
+//
+DBVT_INLINE btScalar	btDbvtAabbMm::ProjectMinimum(const btVector3& v,unsigned signs) const
+{
+const btVector3*	b[]={&mx,&mi};
+const btVector3		p(	b[(signs>>0)&1]->x(),
+						b[(signs>>1)&1]->y(),
+						b[(signs>>2)&1]->z());
+return(dot(p,v));
+}
+
+//
+DBVT_INLINE void		btDbvtAabbMm::AddSpan(const btVector3& d,btScalar& smi,btScalar& smx) const
+{
+for(int i=0;i<3;++i)
+	{
+	if(d[i]<0)
+		{ smi+=mx[i]*d[i];smx+=mi[i]*d[i]; }
+		else
+		{ smi+=mi[i]*d[i];smx+=mx[i]*d[i]; }
+	}
+}
+	
+//
+DBVT_INLINE bool		Intersect(	const btDbvtAabbMm& a,
+									const btDbvtAabbMm& b)
+{
+#if	DBVT_INT0_IMPL == DBVT_IMPL_SSE
+const __m128	rt(_mm_or_ps(	_mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)),
+								_mm_cmplt_ps(_mm_load_ps(a.mx),_mm_load_ps(b.mi))));
+const __int32*	pu((const __int32*)&rt);
+return((pu[0]|pu[1]|pu[2])==0);
+#else
+return(	(a.mi.x()<=b.mx.x())&&
+		(a.mx.x()>=b.mi.x())&&
+		(a.mi.y()<=b.mx.y())&&
+		(a.mx.y()>=b.mi.y())&&
+		(a.mi.z()<=b.mx.z())&&		
+		(a.mx.z()>=b.mi.z()));
+#endif
+}
+
+//
+DBVT_INLINE bool		Intersect(	const btDbvtAabbMm& a,
+									const btDbvtAabbMm& b,
+									const btTransform& xform)
+{
+const btVector3		d0=xform*b.Center()-a.Center();
+const btVector3		d1=d0*xform.getBasis();
+btScalar			s0[2]={0,0};
+btScalar			s1[2]={dot(xform.getOrigin(),d0),s1[0]};
+a.AddSpan(d0,s0[0],s0[1]);
+b.AddSpan(d1,s1[0],s1[1]);
+if(s0[0]>(s1[1])) return(false);
+if(s0[1]<(s1[0])) return(false);
+return(true);
+}
+
+//
+DBVT_INLINE bool		Intersect(	const btDbvtAabbMm& a,
+									const btVector3& b)
+{
+return(	(b.x()>=a.mi.x())&&
+		(b.y()>=a.mi.y())&&
+		(b.z()>=a.mi.z())&&
+		(b.x()<=a.mx.x())&&
+		(b.y()<=a.mx.y())&&
+		(b.z()<=a.mx.z()));
+}
+
+//
+DBVT_INLINE bool		Intersect(	const btDbvtAabbMm& a,
+									const btVector3& org,
+									const btVector3& invdir,
+									const unsigned* signs)
+{
+#if 0
+const btVector3		b0((a.mi-org)*invdir);
+const btVector3		b1((a.mx-org)*invdir);
+const btVector3		tmin(btMin(b0[0],b1[0]),btMin(b0[1],b1[1]),btMin(b0[2],b1[2]));
+const btVector3		tmax(btMax(b0[0],b1[0]),btMax(b0[1],b1[1]),btMax(b0[2],b1[2]));
+const btScalar		tin=btMax(tmin[0],btMax(tmin[1],tmin[2]));
+const btScalar		tout=btMin(tmax[0],btMin(tmax[1],tmax[2]));
+return(tin<tout);
+#else
+const btVector3*	bounds[2]={&a.mi,&a.mx};
+btScalar			txmin=(bounds[  signs[0]]->x()-org[0])*invdir[0];
+btScalar			txmax=(bounds[1-signs[0]]->x()-org[0])*invdir[0];
+const btScalar		tymin=(bounds[  signs[1]]->y()-org[1])*invdir[1];
+const btScalar		tymax=(bounds[1-signs[1]]->y()-org[1])*invdir[1];
+if((txmin>tymax)||(tymin>txmax)) return(false);
+if(tymin>txmin) txmin=tymin;
+if(tymax<txmax) txmax=tymax;
+const btScalar		tzmin=(bounds[  signs[2]]->z()-org[2])*invdir[2];
+const btScalar		tzmax=(bounds[1-signs[2]]->z()-org[2])*invdir[2];
+if((txmin>tzmax)||(tzmin>txmax)) return(false);
+if(tzmin>txmin) txmin=tzmin;
+if(tzmax<txmax) txmax=tzmax;
+return(txmax>0);
+#endif
+}
+	
+//
+DBVT_INLINE btScalar	Proximity(	const btDbvtAabbMm& a,
+									const btDbvtAabbMm& b)
+{
+const btVector3	d=(a.mi+a.mx)-(b.mi+b.mx);
+return(btFabs(d.x())+btFabs(d.y())+btFabs(d.z()));
+}
+
+//
+DBVT_INLINE int			Select(	const btDbvtAabbMm& o,
+								const btDbvtAabbMm& a,
+								const btDbvtAabbMm& b)
+{
+#if	DBVT_SELECT_IMPL == DBVT_IMPL_SSE
+static DBVT_ALIGN const unsigned __int32	mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff};
+	// TODO: the intrinsic version is 11% slower
+	#if DBVT_USE_INTRINSIC_SSE
+	__m128	omi(_mm_load_ps(o.mi));
+	omi=_mm_add_ps(omi,_mm_load_ps(o.mx));
+	__m128	ami(_mm_load_ps(a.mi));
+	ami=_mm_add_ps(ami,_mm_load_ps(a.mx));
+	ami=_mm_sub_ps(ami,omi);
+	ami=_mm_and_ps(ami,_mm_load_ps((const float*)mask));
+	__m128	bmi(_mm_load_ps(b.mi));
+	bmi=_mm_add_ps(bmi,_mm_load_ps(b.mx));
+	bmi=_mm_sub_ps(bmi,omi);
+	bmi=_mm_and_ps(bmi,_mm_load_ps((const float*)mask));
+	__m128	t0(_mm_movehl_ps(ami,ami));
+	ami=_mm_add_ps(ami,t0);
+	ami=_mm_add_ss(ami,_mm_shuffle_ps(ami,ami,1));
+	__m128	t1(_mm_movehl_ps(bmi,bmi));
+	bmi=_mm_add_ps(bmi,t1);
+	bmi=_mm_add_ss(bmi,_mm_shuffle_ps(bmi,bmi,1));
+	return(_mm_cmple_ss(bmi,ami).m128_u32[0]&1);
+	#else
+	DBVT_ALIGN __int32	r[1];
+	__asm
+		{
+		mov		eax,o
+		mov		ecx,a
+		mov		edx,b
+		movaps	xmm0,[eax]
+		movaps	xmm5,mask
+		addps	xmm0,[eax+16]	
+		movaps	xmm1,[ecx]
+		movaps	xmm2,[edx]
+		addps	xmm1,[ecx+16]
+		addps	xmm2,[edx+16]
+		subps	xmm1,xmm0
+		subps	xmm2,xmm0
+		andps	xmm1,xmm5
+		andps	xmm2,xmm5
+		movhlps	xmm3,xmm1
+		movhlps	xmm4,xmm2
+		addps	xmm1,xmm3
+		addps	xmm2,xmm4
+		pshufd	xmm3,xmm1,1
+		pshufd	xmm4,xmm2,1
+		addss	xmm1,xmm3
+		addss	xmm2,xmm4
+		cmpless	xmm2,xmm1
+		movss	r,xmm2
+		}
+	return(r[0]&1);
+	#endif
+#else
+return(Proximity(o,a)<Proximity(o,b)?0:1);
+#endif
+}
+
+//
+DBVT_INLINE void		Merge(	const btDbvtAabbMm& a,
+								const btDbvtAabbMm& b,
+								btDbvtAabbMm& r)
+{
+#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
+__m128	ami(_mm_load_ps(a.mi));
+__m128	amx(_mm_load_ps(a.mx));
+__m128	bmi(_mm_load_ps(b.mi));
+__m128	bmx(_mm_load_ps(b.mx));
+ami=_mm_min_ps(ami,bmi);
+amx=_mm_max_ps(amx,bmx);
+_mm_store_ps(r.mi,ami);
+_mm_store_ps(r.mx,amx);
+#else
+for(int i=0;i<3;++i)
+	{
+	if(a.mi[i]<b.mi[i]) r.mi[i]=a.mi[i]; else r.mi[i]=b.mi[i];
+	if(a.mx[i]>b.mx[i]) r.mx[i]=a.mx[i]; else r.mx[i]=b.mx[i];
+	}
+#endif
+}
+
+//
+DBVT_INLINE bool		NotEqual(	const btDbvtAabbMm& a,
+									const btDbvtAabbMm& b)
+{
+return(	(a.mi.x()!=b.mi.x())||
+		(a.mi.y()!=b.mi.y())||
+		(a.mi.z()!=b.mi.z())||
+		(a.mx.x()!=b.mx.x())||
+		(a.mx.y()!=b.mx.y())||
+		(a.mx.z()!=b.mx.z()));
+}
+
+//
+// Inline's
+//
+
+//
+DBVT_PREFIX
+inline void		btDbvt::enumNodes(	const btDbvtNode* root,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+policy.Process(root);
+if(root->isinternal())
+	{
+	enumNodes(root->childs[0],policy);
+	enumNodes(root->childs[1],policy);
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::enumLeaves(	const btDbvtNode* root,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+if(root->isinternal())
+	{
+	enumLeaves(root->childs[0],policy);
+	enumLeaves(root->childs[1],policy);
+	}
+	else
+	{
+	policy.Process(root);
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideTT(	const btDbvtNode* root0,
+									const btDbvtNode* root1,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+if(root0&&root1)
+	{
+	btAlignedObjectArray<sStkNN>	stack;
+	int								depth=1;
+	int								treshold=DOUBLE_STACKSIZE-4;
+	stack.resize(DOUBLE_STACKSIZE);
+	stack[0]=sStkNN(root0,root1);
+	do	{		
+		sStkNN	p=stack[--depth];
+		if(depth>treshold)
+			{
+			stack.resize(stack.size()*2);
+			treshold=stack.size()-4;
+			}
+		if(p.a==p.b)
+			{
+			if(p.a->isinternal())
+				{
+				stack[depth++]=sStkNN(p.a->childs[0],p.a->childs[0]);
+				stack[depth++]=sStkNN(p.a->childs[1],p.a->childs[1]);
+				stack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]);
+				}
+			}
+		else if(Intersect(p.a->volume,p.b->volume))
+			{
+			if(p.a->isinternal())
+				{
+				if(p.b->isinternal())
+					{
+					stack[depth++]=sStkNN(p.a->childs[0],p.b->childs[0]);
+					stack[depth++]=sStkNN(p.a->childs[1],p.b->childs[0]);
+					stack[depth++]=sStkNN(p.a->childs[0],p.b->childs[1]);
+					stack[depth++]=sStkNN(p.a->childs[1],p.b->childs[1]);
+					}
+					else
+					{
+					stack[depth++]=sStkNN(p.a->childs[0],p.b);
+					stack[depth++]=sStkNN(p.a->childs[1],p.b);
+					}
+				}
+				else
+				{
+				if(p.b->isinternal())
+					{
+					stack[depth++]=sStkNN(p.a,p.b->childs[0]);
+					stack[depth++]=sStkNN(p.a,p.b->childs[1]);
+					}
+					else
+					{
+					policy.Process(p.a,p.b);
+					}
+				}
+			}
+		} while(depth);
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideTT(	const btDbvtNode* root0,
+									const btDbvtNode* root1,
+									const btTransform& xform,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+if(root0&&root1)
+	{
+	btAlignedObjectArray<sStkNN>	stack;
+	int								depth=1;
+	int								treshold=DOUBLE_STACKSIZE-4;
+	stack.resize(DOUBLE_STACKSIZE);
+	stack[0]=sStkNN(root0,root1);
+	do	{
+		sStkNN	p=stack[--depth];
+		if(Intersect(p.a->volume,p.b->volume,xform))
+			{
+			if(depth>treshold)
+				{
+				stack.resize(stack.size()*2);
+				treshold=stack.size()-4;
+				}
+			if(p.a->isinternal())
+				{
+				if(p.b->isinternal())
+					{					
+					stack[depth++]=sStkNN(p.a->childs[0],p.b->childs[0]);
+					stack[depth++]=sStkNN(p.a->childs[1],p.b->childs[0]);
+					stack[depth++]=sStkNN(p.a->childs[0],p.b->childs[1]);
+					stack[depth++]=sStkNN(p.a->childs[1],p.b->childs[1]);
+					}
+					else
+					{
+					stack[depth++]=sStkNN(p.a->childs[0],p.b);
+					stack[depth++]=sStkNN(p.a->childs[1],p.b);
+					}
+				}
+				else
+				{
+				if(p.b->isinternal())
+					{
+					stack[depth++]=sStkNN(p.a,p.b->childs[0]);
+					stack[depth++]=sStkNN(p.a,p.b->childs[1]);
+					}
+					else
+					{
+					policy.Process(p.a,p.b);
+					}
+				}
+			}
+		} while(depth);
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideTT(	const btDbvtNode* root0,
+									const btTransform& xform0,
+									const btDbvtNode* root1,
+									const btTransform& xform1,
+									DBVT_IPOLICY)
+{
+const btTransform	xform=xform0.inverse()*xform1;
+collideTT(root0,root1,xform,policy);
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideTV(	const btDbvtNode* root,
+									const btDbvtVolume& vol,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+if(root)
+	{
+	ATTRIBUTE_ALIGNED16(btDbvtVolume)		volume(vol);
+	btAlignedObjectArray<const btDbvtNode*>	stack;
+	stack.reserve(SIMPLE_STACKSIZE);
+	stack.push_back(root);
+	do	{
+		const btDbvtNode*	n=stack[stack.size()-1];
+		stack.pop_back();
+		if(Intersect(n->volume,volume))
+			{
+			if(n->isinternal())
+				{
+				stack.push_back(n->childs[0]);
+				stack.push_back(n->childs[1]);
+				}
+				else
+				{
+				policy.Process(n);
+				}
+			}
+		} while(stack.size()>0);
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideRAY(	const btDbvtNode* root,
+									const btVector3& origin,
+									const btVector3& direction,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+if(root)
+	{
+	const btVector3	normal=direction.normalized();
+	const btVector3	invdir(	1/normal.x(),
+							1/normal.y(),
+							1/normal.z());
+	const unsigned	signs[]={	direction.x()<0,
+								direction.y()<0,
+								direction.z()<0};
+	btAlignedObjectArray<const btDbvtNode*>	stack;
+	stack.reserve(SIMPLE_STACKSIZE);
+	stack.push_back(root);
+	do	{
+		const btDbvtNode*	node=stack[stack.size()-1];
+		stack.pop_back();
+		if(Intersect(node->volume,origin,invdir,signs))
+			{
+			if(node->isinternal())
+				{
+				stack.push_back(node->childs[0]);
+				stack.push_back(node->childs[1]);
+				}
+				else
+				{
+				policy.Process(node);
+				}
+			}
+		} while(stack.size());
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideKDOP(const btDbvtNode* root,
+									const btVector3* normals,
+									const btScalar* offsets,
+									int count,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+if(root)
+	{
+	const int						inside=(1<<count)-1;
+	btAlignedObjectArray<sStkNP>	stack;
+	int								signs[sizeof(unsigned)*8];
+	btAssert(count<int (sizeof(signs)/sizeof(signs[0])));
+	for(int i=0;i<count;++i)
+		{
+		signs[i]=	((normals[i].x()>=0)?1:0)+
+					((normals[i].y()>=0)?2:0)+
+					((normals[i].z()>=0)?4:0);
+		}
+	stack.reserve(SIMPLE_STACKSIZE);
+	stack.push_back(sStkNP(root,0));
+	do	{
+		sStkNP	se=stack[stack.size()-1];
+		bool	out=false;
+		stack.pop_back();
+		for(int i=0,j=1;(!out)&&(i<count);++i,j<<=1)
+			{
+			if(0==(se.mask&j))
+				{
+				const int	side=se.node->volume.Classify(normals[i],offsets[i],signs[i]);
+				switch(side)
+					{
+					case	-1:	out=true;break;
+					case	+1:	se.mask|=j;break;
+					}
+				}
+			}
+		if(!out)
+			{
+			if((se.mask!=inside)&&(se.node->isinternal()))
+				{
+				stack.push_back(sStkNP(se.node->childs[0],se.mask));
+				stack.push_back(sStkNP(se.node->childs[1],se.mask));
+				}
+				else
+				{
+				if(policy.AllLeaves(se.node)) enumLeaves(se.node,policy);
+				}
+			}
+		} while(stack.size());
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideOCL(	const btDbvtNode* root,
+									const btVector3* normals,
+									const btScalar* offsets,
+									const btVector3& sortaxis,
+									int count,
+									DBVT_IPOLICY,
+									bool fsort)
+{
+DBVT_CHECKTYPE
+if(root)
+	{
+	const unsigned					srtsgns=(sortaxis[0]>=0?1:0)+
+											(sortaxis[1]>=0?2:0)+
+											(sortaxis[2]>=0?4:0);
+	const int						inside=(1<<count)-1;
+	btAlignedObjectArray<sStkNPS>	stock;
+	btAlignedObjectArray<int>		ifree;
+	btAlignedObjectArray<int>		stack;
+	int								signs[sizeof(unsigned)*8];
+	btAssert(count<int (sizeof(signs)/sizeof(signs[0])));
+	for(int i=0;i<count;++i)
+		{
+		signs[i]=	((normals[i].x()>=0)?1:0)+
+					((normals[i].y()>=0)?2:0)+
+					((normals[i].z()>=0)?4:0);
+		}
+	stock.reserve(SIMPLE_STACKSIZE);
+	stack.reserve(SIMPLE_STACKSIZE);
+	ifree.reserve(SIMPLE_STACKSIZE);
+	stack.push_back(allocate(ifree,stock,sStkNPS(root,0,root->volume.ProjectMinimum(sortaxis,srtsgns))));
+	do	{
+		const int	id=stack[stack.size()-1];
+		sStkNPS		se=stock[id];
+		stack.pop_back();ifree.push_back(id);
+		if(se.mask!=inside)
+			{
+			bool	out=false;
+			for(int i=0,j=1;(!out)&&(i<count);++i,j<<=1)
+				{
+				if(0==(se.mask&j))
+					{
+					const int	side=se.node->volume.Classify(normals[i],offsets[i],signs[i]);
+					switch(side)
+						{
+						case	-1:	out=true;break;
+						case	+1:	se.mask|=j;break;
+						}
+					}
+				}
+			if(out) continue;
+			}
+		if(policy.Descent(se.node))
+			{
+			if(se.node->isinternal())
+				{
+				const btDbvtNode* pns[]={	se.node->childs[0],se.node->childs[1]};
+				sStkNPS		nes[]={	sStkNPS(pns[0],se.mask,pns[0]->volume.ProjectMinimum(sortaxis,srtsgns)),
+									sStkNPS(pns[1],se.mask,pns[1]->volume.ProjectMinimum(sortaxis,srtsgns))};
+				const int	q=nes[0].value<nes[1].value?1:0;				
+				int			j=stack.size();
+				if(fsort&&(j>0))
+					{
+					/* Insert 0	*/ 
+					j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size());
+					stack.push_back(0);
+					#if DBVT_USE_MEMMOVE
+					memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
+					#else
+					for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
+					#endif
+					stack[j]=allocate(ifree,stock,nes[q]);
+					/* Insert 1	*/ 
+					j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size());
+					stack.push_back(0);
+					#if DBVT_USE_MEMMOVE
+					memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
+					#else
+					for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
+					#endif
+					stack[j]=allocate(ifree,stock,nes[1-q]);
+					}
+					else
+					{
+					stack.push_back(allocate(ifree,stock,nes[q]));
+					stack.push_back(allocate(ifree,stock,nes[1-q]));
+					}
+				}
+				else
+				{
+				policy.Process(se.node,se.value);
+				}
+			}
+		} while(stack.size());
+	}
+}
+
+//
+DBVT_PREFIX
+inline void		btDbvt::collideTU(	const btDbvtNode* root,
+									DBVT_IPOLICY)
+{
+DBVT_CHECKTYPE
+if(root)
+	{
+	btAlignedObjectArray<const btDbvtNode*>	stack;
+	stack.reserve(SIMPLE_STACKSIZE);
+	stack.push_back(root);
+	do	{
+		const btDbvtNode*	n=stack[stack.size()-1];
+		stack.pop_back();
+		if(policy.Descent(n))
+			{
+			if(n->isinternal())
+				{ stack.push_back(n->childs[0]);stack.push_back(n->childs[1]); }
+				else
+				{ policy.Process(n); }
+			}
+		} while(stack.size()>0);
+	}
+}
+
+//
+// PP Cleanup
+//
+
+#undef DBVT_USE_MEMMOVE
+#undef DBVT_USE_TEMPLATE
+#undef DBVT_VIRTUAL_DTOR
+#undef DBVT_VIRTUAL
+#undef DBVT_PREFIX
+#undef DBVT_IPOLICY
+#undef DBVT_CHECKTYPE
+#undef DBVT_IMPL_GENERIC
+#undef DBVT_IMPL_SSE
+#undef DBVT_USE_INTRINSIC_SSE
+#undef DBVT_SELECT_IMPL
+#undef DBVT_MERGE_IMPL
+#undef DBVT_INT0_IMPL
+
+#endif
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp	(revision 2122)
@@ -0,0 +1,548 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btDbvtBroadphase implementation by Nathanael Presson
+
+#include "btDbvtBroadphase.h"
+
+//
+// Profiling
+//
+
+#if DBVT_BP_PROFILE||DBVT_BP_ENABLE_BENCHMARK
+#include <stdio.h>
+#endif
+
+#if DBVT_BP_PROFILE
+struct	ProfileScope
+	{
+	__forceinline ProfileScope(btClock& clock,unsigned long& value) :
+		m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds())
+		{
+		}
+	__forceinline ~ProfileScope()
+		{
+		(*m_value)+=m_clock->getTimeMicroseconds()-m_base;
+		}
+	btClock*		m_clock;
+	unsigned long*	m_value;
+	unsigned long	m_base;
+	};
+#define	SPC(_value_)	ProfileScope	spc_scope(m_clock,_value_)
+#else
+#define	SPC(_value_)
+#endif
+
+//
+// Helpers
+//
+
+//
+template <typename T>
+static inline void	listappend(T* item,T*& list)
+{
+item->links[0]=0;
+item->links[1]=list;
+if(list) list->links[0]=item;
+list=item;
+}
+
+//
+template <typename T>
+static inline void	listremove(T* item,T*& list)
+{
+if(item->links[0]) item->links[0]->links[1]=item->links[1]; else list=item->links[1];
+if(item->links[1]) item->links[1]->links[0]=item->links[0];
+}
+
+//
+template <typename T>
+static inline int	listcount(T* root)
+{
+int	n=0;
+while(root) { ++n;root=root->links[1]; }
+return(n);
+}
+
+//
+template <typename T>
+static inline void	clear(T& value)
+{
+static const struct ZeroDummy : T {} zerodummy;
+value=zerodummy;
+}
+
+//
+// Colliders
+//
+
+/* Tree collider	*/ 
+struct	btDbvtTreeCollider : btDbvt::ICollide
+{
+btDbvtBroadphase*	pbp;
+btDbvtProxy*		proxy;
+		btDbvtTreeCollider(btDbvtBroadphase* p) : pbp(p) {}
+void	Process(const btDbvtNode* na,const btDbvtNode* nb)
+	{
+	if(na!=nb)
+		{
+		btDbvtProxy*	pa=(btDbvtProxy*)na->data;
+		btDbvtProxy*	pb=(btDbvtProxy*)nb->data;
+		#if DBVT_BP_SORTPAIRS
+		if(pa>pb) btSwap(pa,pb);
+		#endif
+		pbp->m_paircache->addOverlappingPair(pa,pb);
+		++pbp->m_newpairs;
+		}
+	}
+void	Process(const btDbvtNode* n)
+	{
+	Process(n,proxy->leaf);
+	}
+};
+
+//
+// btDbvtBroadphase
+//
+
+//
+btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache* paircache)
+{
+m_deferedcollide	=	false;
+m_needcleanup		=	true;
+m_releasepaircache	=	(paircache!=0)?false:true;
+m_prediction		=	1/(btScalar)2;
+m_stageCurrent		=	0;
+m_fixedleft			=	0;
+m_fupdates			=	1;
+m_dupdates			=	0;
+m_cupdates			=	10;
+m_newpairs			=	1;
+m_updates_call		=	0;
+m_updates_done		=	0;
+m_updates_ratio		=	0;
+m_paircache			=	paircache?
+						paircache	:
+						new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
+m_gid				=	0;
+m_pid				=	0;
+m_cid				=	0;
+for(int i=0;i<=STAGECOUNT;++i)
+	{
+	m_stageRoots[i]=0;
+	}
+#if DBVT_BP_PROFILE
+clear(m_profiling);
+#endif
+}
+
+//
+btDbvtBroadphase::~btDbvtBroadphase()
+{
+if(m_releasepaircache) 
+{
+	m_paircache->~btOverlappingPairCache();
+	btAlignedFree(m_paircache);
+}
+}
+
+//
+btBroadphaseProxy*				btDbvtBroadphase::createProxy(	const btVector3& aabbMin,
+																const btVector3& aabbMax,
+																int /*shapeType*/,
+																void* userPtr,
+																short int collisionFilterGroup,
+																short int collisionFilterMask,
+																btDispatcher* /*dispatcher*/,
+																void* /*multiSapProxy*/)
+{
+btDbvtProxy*		proxy=new(btAlignedAlloc(sizeof(btDbvtProxy),16)) btDbvtProxy(	userPtr,
+																					collisionFilterGroup,
+																					collisionFilterMask);
+proxy->aabb			=	btDbvtVolume::FromMM(aabbMin,aabbMax);
+proxy->stage		=	m_stageCurrent;
+proxy->m_uniqueId	=	++m_gid;
+proxy->leaf			=	m_sets[0].insert(proxy->aabb,proxy);
+listappend(proxy,m_stageRoots[m_stageCurrent]);
+if(!m_deferedcollide)
+	{
+	btDbvtTreeCollider	collider(this);
+	collider.proxy=proxy;
+	btDbvt::collideTV(m_sets[0].m_root,proxy->aabb,collider);
+	btDbvt::collideTV(m_sets[1].m_root,proxy->aabb,collider);
+	}
+return(proxy);
+}
+
+//
+void							btDbvtBroadphase::destroyProxy(	btBroadphaseProxy* absproxy,
+																btDispatcher* dispatcher)
+{
+btDbvtProxy*	proxy=(btDbvtProxy*)absproxy;
+if(proxy->stage==STAGECOUNT)
+	m_sets[1].remove(proxy->leaf);
+	else
+	m_sets[0].remove(proxy->leaf);
+listremove(proxy,m_stageRoots[proxy->stage]);
+m_paircache->removeOverlappingPairsContainingProxy(proxy,dispatcher);
+btAlignedFree(proxy);
+m_needcleanup=true;
+}
+
+//
+void							btDbvtBroadphase::setAabb(		btBroadphaseProxy* absproxy,
+																const btVector3& aabbMin,
+																const btVector3& aabbMax,
+																btDispatcher* /*dispatcher*/)
+{
+btDbvtProxy*						proxy=(btDbvtProxy*)absproxy;
+ATTRIBUTE_ALIGNED16(btDbvtVolume)	aabb=btDbvtVolume::FromMM(aabbMin,aabbMax);
+#if DBVT_BP_PREVENTFALSEUPDATE
+if(NotEqual(aabb,proxy->leaf->volume))
+#endif
+	{
+	bool	docollide=false;
+	if(proxy->stage==STAGECOUNT)
+		{/* fixed -> dynamic set	*/ 
+		m_sets[1].remove(proxy->leaf);
+		proxy->leaf=m_sets[0].insert(aabb,proxy);
+		docollide=true;
+		}
+		else
+		{/* dynamic set				*/ 
+		++m_updates_call;
+		if(Intersect(proxy->leaf->volume,aabb))
+			{/* Moving				*/ 
+			const btVector3	delta=aabbMin-proxy->aabb.Mins();
+			btVector3		velocity(aabb.Extents()*m_prediction);
+			if(delta[0]<0) velocity[0]=-velocity[0];
+			if(delta[1]<0) velocity[1]=-velocity[1];
+			if(delta[2]<0) velocity[2]=-velocity[2];
+			if	(
+				#ifdef DBVT_BP_MARGIN				
+				m_sets[0].update(proxy->leaf,aabb,velocity,DBVT_BP_MARGIN)
+				#else
+				m_sets[0].update(proxy->leaf,aabb,velocity)
+				#endif
+				)
+				{
+				++m_updates_done;
+				docollide=true;
+				}
+			}
+			else
+			{/* Teleporting			*/ 
+			m_sets[0].update(proxy->leaf,aabb);
+			++m_updates_done;
+			docollide=true;
+			}	
+		}
+	listremove(proxy,m_stageRoots[proxy->stage]);
+	proxy->aabb		=	aabb;
+	proxy->stage	=	m_stageCurrent;
+	listappend(proxy,m_stageRoots[m_stageCurrent]);
+	if(docollide)
+		{
+		m_needcleanup=true;
+		if(!m_deferedcollide)
+			{
+			btDbvtTreeCollider	collider(this);
+			btDbvt::collideTT(m_sets[1].m_root,proxy->leaf,collider);
+			btDbvt::collideTT(m_sets[0].m_root,proxy->leaf,collider);
+			}
+		}	
+	}
+}
+
+//
+void							btDbvtBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
+{
+collide(dispatcher);
+#if DBVT_BP_PROFILE
+if(0==(m_pid%DBVT_BP_PROFILING_RATE))
+	{	
+	printf("fixed(%u) dynamics(%u) pairs(%u)\r\n",m_sets[1].m_leaves,m_sets[0].m_leaves,m_paircache->getNumOverlappingPairs());
+	unsigned int	total=m_profiling.m_total;
+	if(total<=0) total=1;
+	printf("ddcollide: %u%% (%uus)\r\n",(50+m_profiling.m_ddcollide*100)/total,m_profiling.m_ddcollide/DBVT_BP_PROFILING_RATE);
+	printf("fdcollide: %u%% (%uus)\r\n",(50+m_profiling.m_fdcollide*100)/total,m_profiling.m_fdcollide/DBVT_BP_PROFILING_RATE);
+	printf("cleanup:   %u%% (%uus)\r\n",(50+m_profiling.m_cleanup*100)/total,m_profiling.m_cleanup/DBVT_BP_PROFILING_RATE);
+	printf("total:     %uus\r\n",total/DBVT_BP_PROFILING_RATE);
+	const unsigned long	sum=m_profiling.m_ddcollide+
+							m_profiling.m_fdcollide+
+							m_profiling.m_cleanup;
+	printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/DBVT_BP_PROFILING_RATE);
+	printf("job counts: %u%%\r\n",(m_profiling.m_jobcount*100)/((m_sets[0].m_leaves+m_sets[1].m_leaves)*DBVT_BP_PROFILING_RATE));
+	clear(m_profiling);
+	m_clock.reset();
+	}
+#endif
+}
+
+//
+void							btDbvtBroadphase::collide(btDispatcher* dispatcher)
+{
+SPC(m_profiling.m_total);
+/* optimize				*/ 
+m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100);
+if(m_fixedleft)
+	{
+	const int count=1+(m_sets[1].m_leaves*m_fupdates)/100;
+	m_sets[1].optimizeIncremental(1+(m_sets[1].m_leaves*m_fupdates)/100);
+	m_fixedleft=btMax<int>(0,m_fixedleft-count);
+	}
+/* dynamic -> fixed set	*/ 
+m_stageCurrent=(m_stageCurrent+1)%STAGECOUNT;
+btDbvtProxy*	current=m_stageRoots[m_stageCurrent];
+if(current)
+	{
+	btDbvtTreeCollider	collider(this);
+	do	{
+		btDbvtProxy*	next=current->links[1];
+		listremove(current,m_stageRoots[current->stage]);
+		listappend(current,m_stageRoots[STAGECOUNT]);
+		#if DBVT_BP_ACCURATESLEEPING
+		m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher);
+		collider.proxy=current;
+		btDbvt::collideTV(m_sets[0].m_root,current->aabb,collider);
+		btDbvt::collideTV(m_sets[1].m_root,current->aabb,collider);
+		#endif
+		m_sets[0].remove(current->leaf);
+		current->leaf	=	m_sets[1].insert(current->aabb,current);
+		current->stage	=	STAGECOUNT;	
+		current			=	next;
+		} while(current);
+	m_fixedleft=m_sets[1].m_leaves;
+	m_needcleanup=true;
+	}
+/* collide dynamics		*/ 
+	{
+	btDbvtTreeCollider	collider(this);
+	if(m_deferedcollide)
+		{
+		SPC(m_profiling.m_fdcollide);
+		btDbvt::collideTT(m_sets[0].m_root,m_sets[1].m_root,collider);
+		}
+	if(m_deferedcollide)
+		{
+		SPC(m_profiling.m_ddcollide);
+		btDbvt::collideTT(m_sets[0].m_root,m_sets[0].m_root,collider);
+		}
+	}
+/* clean up				*/ 
+if(m_needcleanup)
+	{
+	SPC(m_profiling.m_cleanup);
+	btBroadphasePairArray&	pairs=m_paircache->getOverlappingPairArray();
+	if(pairs.size()>0)
+		{
+		const int	ci=pairs.size();
+		int			ni=btMin(ci,btMax<int>(m_newpairs,(ci*m_cupdates)/100));
+		for(int i=0;i<ni;++i)
+			{
+			btBroadphasePair&	p=pairs[(m_cid+i)%ci];
+			btDbvtProxy*		pa=(btDbvtProxy*)p.m_pProxy0;
+			btDbvtProxy*		pb=(btDbvtProxy*)p.m_pProxy1;
+			if(!Intersect(pa->leaf->volume,pb->leaf->volume))
+				{
+				#if DBVT_BP_SORTPAIRS
+				if(pa>pb) btSwap(pa,pb);
+				#endif
+				m_paircache->removeOverlappingPair(pa,pb,dispatcher);
+				--ni;--i;
+				}
+			}
+		if(pairs.size()>0) m_cid=(m_cid+ni)%pairs.size(); else m_cid=0;
+		}
+	}
+++m_pid;
+m_newpairs=1;
+m_needcleanup=false;
+if(m_updates_call>0)
+	{ m_updates_ratio=m_updates_done/(btScalar)m_updates_call; }
+	else
+	{ m_updates_ratio=0; }
+m_updates_done/=2;
+m_updates_call/=2;
+}
+
+//
+void							btDbvtBroadphase::optimize()
+{
+m_sets[0].optimizeTopDown();
+m_sets[1].optimizeTopDown();
+}
+
+//
+btOverlappingPairCache*			btDbvtBroadphase::getOverlappingPairCache()
+{
+return(m_paircache);
+}
+
+//
+const btOverlappingPairCache*	btDbvtBroadphase::getOverlappingPairCache() const
+{
+return(m_paircache);
+}
+
+//
+void							btDbvtBroadphase::getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
+{
+
+	ATTRIBUTE_ALIGNED16(btDbvtVolume)	bounds;
+
+if(!m_sets[0].empty())
+	if(!m_sets[1].empty())	Merge(	m_sets[0].m_root->volume,
+									m_sets[1].m_root->volume,bounds);
+							else
+							bounds=m_sets[0].m_root->volume;
+else if(!m_sets[1].empty())	bounds=m_sets[1].m_root->volume;
+							else
+							bounds=btDbvtVolume::FromCR(btVector3(0,0,0),0);
+aabbMin=bounds.Mins();
+aabbMax=bounds.Maxs();
+}
+
+//
+void							btDbvtBroadphase::printStats()
+{}
+
+//
+#if DBVT_BP_ENABLE_BENCHMARK
+
+struct	btBroadphaseBenchmark
+	{
+	struct	Experiment
+		{
+		const char*			name;
+		int					object_count;
+		int					update_count;
+		int					spawn_count;
+		int					iterations;
+		btScalar			speed;
+		btScalar			amplitude;
+		};
+	struct	Object
+		{
+		btVector3			center;
+		btVector3			extents;
+		btBroadphaseProxy*	proxy;
+		btScalar			time;
+		void				update(btScalar speed,btScalar amplitude,btBroadphaseInterface* pbi)
+			{
+			time		+=	speed;
+			center[0]	=	btCos(time*(btScalar)2.17)*amplitude+
+							btSin(time)*amplitude/2;
+			center[1]	=	btCos(time*(btScalar)1.38)*amplitude+
+							btSin(time)*amplitude;
+			center[2]	=	btSin(time*(btScalar)0.777)*amplitude;
+			pbi->setAabb(proxy,center-extents,center+extents,0);
+			}
+		};
+	static int		UnsignedRand(int range=RAND_MAX-1)	{ return(rand()%(range+1)); }
+	static btScalar	UnitRand()							{ return(UnsignedRand(16384)/(btScalar)16384); }
+	static void		OutputTime(const char* name,btClock& c,unsigned count=0)
+		{
+		const unsigned long	us=c.getTimeMicroseconds();
+		const unsigned long	ms=(us+500)/1000;
+		const btScalar		sec=us/(btScalar)(1000*1000);
+		if(count>0)
+			printf("%s : %u us (%u ms), %.2f/s\r\n",name,us,ms,count/sec);
+			else
+			printf("%s : %u us (%u ms)\r\n",name,us,ms);
+		}
+	};
+
+void							btDbvtBroadphase::benchmark(btBroadphaseInterface* pbi)
+{
+static const btBroadphaseBenchmark::Experiment		experiments[]=
+	{
+	{"1024o.10%",1024,10,0,8192,(btScalar)0.005,(btScalar)100},
+	/*{"4096o.10%",4096,10,0,8192,(btScalar)0.005,(btScalar)100},
+	{"8192o.10%",8192,10,0,8192,(btScalar)0.005,(btScalar)100},*/
+	};
+static const int										nexperiments=sizeof(experiments)/sizeof(experiments[0]);
+btAlignedObjectArray<btBroadphaseBenchmark::Object*>	objects;
+btClock													wallclock;
+/* Begin			*/ 
+for(int iexp=0;iexp<nexperiments;++iexp)
+	{
+	const btBroadphaseBenchmark::Experiment&	experiment=experiments[iexp];
+	const int									object_count=experiment.object_count;
+	const int									update_count=(object_count*experiment.update_count)/100;
+	const int									spawn_count=(object_count*experiment.spawn_count)/100;
+	const btScalar								speed=experiment.speed;	
+	const btScalar								amplitude=experiment.amplitude;
+	printf("Experiment #%u '%s':\r\n",iexp,experiment.name);
+	printf("\tObjects: %u\r\n",object_count);
+	printf("\tUpdate: %u\r\n",update_count);
+	printf("\tSpawn: %u\r\n",spawn_count);
+	printf("\tSpeed: %f\r\n",speed);
+	printf("\tAmplitude: %f\r\n",amplitude);
+	srand(180673);
+	/* Create objects	*/ 
+	wallclock.reset();
+	objects.reserve(object_count);
+	for(int i=0;i<object_count;++i)
+		{
+		btBroadphaseBenchmark::Object*	po=new btBroadphaseBenchmark::Object();
+		po->center[0]=btBroadphaseBenchmark::UnitRand()*50;
+		po->center[1]=btBroadphaseBenchmark::UnitRand()*50;
+		po->center[2]=btBroadphaseBenchmark::UnitRand()*50;
+		po->extents[0]=btBroadphaseBenchmark::UnitRand()*2+2;
+		po->extents[1]=btBroadphaseBenchmark::UnitRand()*2+2;
+		po->extents[2]=btBroadphaseBenchmark::UnitRand()*2+2;
+		po->time=btBroadphaseBenchmark::UnitRand()*2000;
+		po->proxy=pbi->createProxy(po->center-po->extents,po->center+po->extents,0,po,1,1,0,0);
+		objects.push_back(po);
+		}
+	btBroadphaseBenchmark::OutputTime("\tInitialization",wallclock);
+	/* First update		*/ 
+	wallclock.reset();
+	for(int i=0;i<objects.size();++i)
+		{
+		objects[i]->update(speed,amplitude,pbi);
+		}
+	btBroadphaseBenchmark::OutputTime("\tFirst update",wallclock);
+	/* Updates			*/ 
+	wallclock.reset();
+	for(int i=0;i<experiment.iterations;++i)
+		{
+		for(int j=0;j<update_count;++j)
+			{				
+			objects[j]->update(speed,amplitude,pbi);
+			}
+		pbi->calculateOverlappingPairs(0);
+		}
+	btBroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations);
+	/* Clean up			*/ 
+	wallclock.reset();
+	for(int i=0;i<objects.size();++i)
+		{
+		pbi->destroyProxy(objects[i]->proxy,0);
+		delete objects[i];
+		}
+	objects.resize(0);
+	btBroadphaseBenchmark::OutputTime("\tRelease",wallclock);
+	}
+
+}
+#else
+void							btDbvtBroadphase::benchmark(btBroadphaseInterface*)
+{}
+#endif
+
+#if DBVT_BP_PROFILE
+#undef	SPC
+#endif
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h	(revision 2122)
@@ -0,0 +1,116 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btDbvtBroadphase implementation by Nathanael Presson
+#ifndef BT_DBVT_BROADPHASE_H
+#define BT_DBVT_BROADPHASE_H
+
+#include "BulletCollision/BroadphaseCollision/btDbvt.h"
+#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
+
+//
+// Compile time config
+//
+
+#define	DBVT_BP_PROFILE					0
+#define DBVT_BP_SORTPAIRS				1
+#define DBVT_BP_PREVENTFALSEUPDATE		0
+#define DBVT_BP_ACCURATESLEEPING		0
+#define DBVT_BP_ENABLE_BENCHMARK		0
+#define DBVT_BP_MARGIN					(btScalar)0.05
+
+#if DBVT_BP_PROFILE
+	#define	DBVT_BP_PROFILING_RATE	256
+	#include "LinearMath/btQuickprof.h"
+#endif
+
+//
+// btDbvtProxy
+//
+struct btDbvtProxy : btBroadphaseProxy
+{
+/* Fields		*/ 
+btDbvtAabbMm	aabb;
+btDbvtNode*		leaf;
+btDbvtProxy*	links[2];
+int				stage;
+/* ctor			*/ 
+btDbvtProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
+	btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask)
+	{
+	links[0]=links[1]=0;
+	}
+};
+
+typedef btAlignedObjectArray<btDbvtProxy*>	btDbvtProxyArray;
+
+///The btDbvtBroadphase implements a broadphase using two dynamic AABB bounding volume hierarchies/trees (see btDbvt).
+///One tree is used for static/non-moving objects, and another tree is used for dynamic objects. Objects can move from one tree to the other.
+///This is a very fast broadphase, especially for very dynamic worlds where many objects are moving. Its insert/add and remove of objects is generally faster than the sweep and prune broadphases btAxisSweep3 and bt32BitAxisSweep3.
+struct	btDbvtBroadphase : btBroadphaseInterface
+{
+/* Config		*/ 
+enum	{
+		DYNAMIC_SET			=	0,	/* Dynamic set index	*/ 
+		FIXED_SET			=	1,	/* Fixed set index		*/ 
+		STAGECOUNT			=	2	/* Number of stages		*/ 
+		};
+/* Fields		*/ 
+btDbvt					m_sets[2];					// Dbvt sets
+btDbvtProxy*			m_stageRoots[STAGECOUNT+1];	// Stages list
+btOverlappingPairCache*	m_paircache;				// Pair cache
+btScalar				m_prediction;				// Velocity prediction
+int						m_stageCurrent;				// Current stage
+int						m_fupdates;					// % of fixed updates per frame
+int						m_dupdates;					// % of dynamic updates per frame
+int						m_cupdates;					// % of cleanup updates per frame
+int						m_newpairs;					// Number of pairs created
+int						m_fixedleft;				// Fixed optimization left
+unsigned				m_updates_call;				// Number of updates call
+unsigned				m_updates_done;				// Number of updates done
+btScalar				m_updates_ratio;			// m_updates_done/m_updates_call
+int						m_pid;						// Parse id
+int						m_cid;						// Cleanup index
+int						m_gid;						// Gen id
+bool					m_releasepaircache;			// Release pair cache on delete
+bool					m_deferedcollide;			// Defere dynamic/static collision to collide call
+bool					m_needcleanup;				// Need to run cleanup?
+#if DBVT_BP_PROFILE
+btClock					m_clock;
+struct	{
+		unsigned long		m_total;
+		unsigned long		m_ddcollide;
+		unsigned long		m_fdcollide;
+		unsigned long		m_cleanup;
+		unsigned long		m_jobcount;
+		}				m_profiling;
+#endif
+/* Methods		*/ 
+btDbvtBroadphase(btOverlappingPairCache* paircache=0);
+~btDbvtBroadphase();
+void							collide(btDispatcher* dispatcher);
+void							optimize();
+/* btBroadphaseInterface Implementation	*/ 
+btBroadphaseProxy*				createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
+void							destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+void							setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
+void							calculateOverlappingPairs(btDispatcher* dispatcher);
+btOverlappingPairCache*			getOverlappingPairCache();
+const btOverlappingPairCache*	getOverlappingPairCache() const;
+void							getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const;
+void							printStats();
+static void						benchmark(btBroadphaseInterface*);
+};
+
+#endif
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDispatcher.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDispatcher.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDispatcher.cpp	(revision 2122)
@@ -0,0 +1,22 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btDispatcher.h"
+
+btDispatcher::~btDispatcher()
+{
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDispatcher.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDispatcher.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDispatcher.h	(revision 2122)
@@ -0,0 +1,103 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef _DISPATCHER_H
+#define _DISPATCHER_H
+
+#include "LinearMath/btScalar.h"
+
+class btCollisionAlgorithm;
+struct btBroadphaseProxy;
+class btRigidBody;
+class	btCollisionObject;
+class btOverlappingPairCache;
+
+
+class btPersistentManifold;
+class btStackAlloc;
+
+struct btDispatcherInfo
+{
+	enum DispatchFunc
+	{
+		DISPATCH_DISCRETE = 1,
+		DISPATCH_CONTINUOUS
+	};
+	btDispatcherInfo()
+		:m_timeStep(btScalar(0.)),
+		m_stepCount(0),
+		m_dispatchFunc(DISPATCH_DISCRETE),
+		m_timeOfImpact(btScalar(1.)),
+		m_useContinuous(false),
+		m_debugDraw(0),
+		m_enableSatConvex(false),
+		m_enableSPU(true),
+		m_useEpa(true),
+		m_allowedCcdPenetration(btScalar(0.04)),
+		m_stackAllocator(0)
+	{
+
+	}
+	btScalar	m_timeStep;
+	int		m_stepCount;
+	int		m_dispatchFunc;
+	mutable btScalar	m_timeOfImpact;
+	bool	m_useContinuous;
+	class btIDebugDraw*	m_debugDraw;
+	bool	m_enableSatConvex;
+	bool	m_enableSPU;
+	bool	m_useEpa;
+	btScalar	m_allowedCcdPenetration;
+	btStackAlloc*	m_stackAllocator;
+	
+};
+
+///The btDispatcher interface class can be used in combination with broadphase to dispatch calculations for overlapping pairs.
+///For example for pairwise collision detection, calculating contact points stored in btPersistentManifold or user callbacks (game logic).
+class btDispatcher
+{
+
+
+public:
+	virtual ~btDispatcher() ;
+
+	virtual btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold=0) = 0;
+
+	virtual btPersistentManifold*	getNewManifold(void* body0,void* body1)=0;
+
+	virtual void releaseManifold(btPersistentManifold* manifold)=0;
+
+	virtual void clearManifold(btPersistentManifold* manifold)=0;
+
+	virtual bool	needsCollision(btCollisionObject* body0,btCollisionObject* body1) = 0;
+
+	virtual bool	needsResponse(btCollisionObject* body0,btCollisionObject* body1)=0;
+
+	virtual void	dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher)  =0;
+
+	virtual int getNumManifolds() const = 0;
+
+	virtual btPersistentManifold* getManifoldByIndexInternal(int index) = 0;
+
+	virtual	btPersistentManifold**	getInternalManifoldPointer() = 0;
+
+	virtual	void* allocateCollisionAlgorithm(int size)  = 0;
+
+	virtual	void freeCollisionAlgorithm(void* ptr) = 0;
+
+};
+
+
+#endif //_DISPATCHER_H
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp	(revision 2122)
@@ -0,0 +1,466 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btMultiSapBroadphase.h"
+
+#include "btSimpleBroadphase.h"
+#include "LinearMath/btAabbUtil2.h"
+#include "btQuantizedBvh.h"
+
+///	btSapBroadphaseArray	m_sapBroadphases;
+
+///	btOverlappingPairCache*	m_overlappingPairs;
+extern int gOverlappingPairs;
+
+/*
+class btMultiSapSortedOverlappingPairCache : public btSortedOverlappingPairCache
+{
+public:
+
+	virtual btBroadphasePair*	addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
+	{
+		return btSortedOverlappingPairCache::addOverlappingPair((btBroadphaseProxy*)proxy0->m_multiSapParentProxy,(btBroadphaseProxy*)proxy1->m_multiSapParentProxy);
+	}
+};
+
+*/
+
+btMultiSapBroadphase::btMultiSapBroadphase(int /*maxProxies*/,btOverlappingPairCache* pairCache)
+:m_overlappingPairs(pairCache),
+m_optimizedAabbTree(0),
+m_ownsPairCache(false),
+m_invalidPair(0)
+{
+	if (!m_overlappingPairs)
+	{
+		m_ownsPairCache = true;
+		void* mem = btAlignedAlloc(sizeof(btSortedOverlappingPairCache),16);
+		m_overlappingPairs = new (mem)btSortedOverlappingPairCache();
+	}
+
+	struct btMultiSapOverlapFilterCallback : public btOverlapFilterCallback
+	{
+		virtual ~btMultiSapOverlapFilterCallback()
+		{}
+		// return true when pairs need collision
+		virtual bool	needBroadphaseCollision(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1) const
+		{
+			btBroadphaseProxy* multiProxy0 = (btBroadphaseProxy*)childProxy0->m_multiSapParentProxy;
+			btBroadphaseProxy* multiProxy1 = (btBroadphaseProxy*)childProxy1->m_multiSapParentProxy;
+			
+			bool collides = (multiProxy0->m_collisionFilterGroup & multiProxy1->m_collisionFilterMask) != 0;
+			collides = collides && (multiProxy1->m_collisionFilterGroup & multiProxy0->m_collisionFilterMask);
+	
+			return collides;
+		}
+	};
+
+	void* mem = btAlignedAlloc(sizeof(btMultiSapOverlapFilterCallback),16);
+	m_filterCallback = new (mem)btMultiSapOverlapFilterCallback();
+
+	m_overlappingPairs->setOverlapFilterCallback(m_filterCallback);
+//	mem = btAlignedAlloc(sizeof(btSimpleBroadphase),16);
+//	m_simpleBroadphase = new (mem) btSimpleBroadphase(maxProxies,m_overlappingPairs);
+}
+
+btMultiSapBroadphase::~btMultiSapBroadphase()
+{
+	if (m_ownsPairCache)
+	{
+		m_overlappingPairs->~btOverlappingPairCache();
+		btAlignedFree(m_overlappingPairs);
+	}
+}
+
+
+void	btMultiSapBroadphase::buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax)
+{
+	m_optimizedAabbTree = new btQuantizedBvh();
+	m_optimizedAabbTree->setQuantizationValues(bvhAabbMin,bvhAabbMax);
+	QuantizedNodeArray&	nodes = m_optimizedAabbTree->getLeafNodeArray();
+	for (int i=0;i<m_sapBroadphases.size();i++)
+	{
+		btQuantizedBvhNode node;
+		btVector3 aabbMin,aabbMax;
+		m_sapBroadphases[i]->getBroadphaseAabb(aabbMin,aabbMax);
+		m_optimizedAabbTree->quantize(&node.m_quantizedAabbMin[0],aabbMin,0);
+		m_optimizedAabbTree->quantize(&node.m_quantizedAabbMax[0],aabbMax,1);
+		int partId = 0;
+		node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | i;
+		nodes.push_back(node);
+	}
+	m_optimizedAabbTree->buildInternal();
+}
+
+btBroadphaseProxy*	btMultiSapBroadphase::createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* /*ignoreMe*/)
+{
+	//void* ignoreMe -> we could think of recursive multi-sap, if someone is interested
+
+	void* mem = btAlignedAlloc(sizeof(btMultiSapProxy),16);
+	btMultiSapProxy* proxy = new (mem)btMultiSapProxy(aabbMin,  aabbMax,shapeType,userPtr, collisionFilterGroup,collisionFilterMask);
+	m_multiSapProxies.push_back(proxy);
+
+	///this should deal with inserting/removal into child broadphases
+	setAabb(proxy,aabbMin,aabbMax,dispatcher);
+	return proxy;
+}
+
+void	btMultiSapBroadphase::destroyProxy(btBroadphaseProxy* /*proxy*/,btDispatcher* /*dispatcher*/)
+{
+	///not yet
+	btAssert(0);
+
+}
+
+
+void	btMultiSapBroadphase::addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface*	childBroadphase)
+{
+	void* mem = btAlignedAlloc(sizeof(btBridgeProxy),16);
+	btBridgeProxy* bridgeProxyRef = new(mem) btBridgeProxy;
+	bridgeProxyRef->m_childProxy = childProxy;
+	bridgeProxyRef->m_childBroadphase = childBroadphase;
+	parentMultiSapProxy->m_bridgeProxies.push_back(bridgeProxyRef);
+}
+
+
+bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax);
+bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax)
+{
+return
+amin.getX() >= bmin.getX() && amax.getX() <= bmax.getX() &&
+amin.getY() >= bmin.getY() && amax.getY() <= bmax.getY() &&
+amin.getZ() >= bmin.getZ() && amax.getZ() <= bmax.getZ();
+}
+
+
+
+
+
+
+//#include <stdio.h>
+
+void	btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher)
+{
+	btMultiSapProxy* multiProxy = static_cast<btMultiSapProxy*>(proxy);
+	multiProxy->m_aabbMin = aabbMin;
+	multiProxy->m_aabbMax = aabbMax;
+	
+	
+//	bool fullyContained = false;
+//	bool alreadyInSimple = false;
+	
+
+
+	
+	struct MyNodeOverlapCallback : public btNodeOverlapCallback
+	{
+		btMultiSapBroadphase*	m_multiSap;
+		btMultiSapProxy*		m_multiProxy;
+		btDispatcher*			m_dispatcher;
+
+		MyNodeOverlapCallback(btMultiSapBroadphase* multiSap,btMultiSapProxy* multiProxy,btDispatcher* dispatcher)
+			:m_multiSap(multiSap),
+			m_multiProxy(multiProxy),
+			m_dispatcher(dispatcher)
+		{
+
+		}
+
+		virtual void processNode(int /*nodeSubPart*/, int broadphaseIndex)
+		{
+			btBroadphaseInterface* childBroadphase = m_multiSap->getBroadphaseArray()[broadphaseIndex];
+
+			int containingBroadphaseIndex = -1;
+			//already found?
+			for (int i=0;i<m_multiProxy->m_bridgeProxies.size();i++)
+			{
+
+				if (m_multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase)
+				{
+					containingBroadphaseIndex = i;
+					break;
+				}
+			}
+			if (containingBroadphaseIndex<0)
+			{
+				//add it
+				btBroadphaseProxy* childProxy = childBroadphase->createProxy(m_multiProxy->m_aabbMin,m_multiProxy->m_aabbMax,m_multiProxy->m_shapeType,m_multiProxy->m_clientObject,m_multiProxy->m_collisionFilterGroup,m_multiProxy->m_collisionFilterMask, m_dispatcher,m_multiProxy);
+				m_multiSap->addToChildBroadphase(m_multiProxy,childProxy,childBroadphase);
+
+			}
+		}
+	};
+
+	MyNodeOverlapCallback	myNodeCallback(this,multiProxy,dispatcher);
+
+
+
+	
+	m_optimizedAabbTree->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax);
+	int i;
+
+	for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
+	{
+		btVector3 worldAabbMin,worldAabbMax;
+		multiProxy->m_bridgeProxies[i]->m_childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
+		bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
+		if (!overlapsBroadphase)
+		{
+			//remove it now
+			btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[i];
+
+			btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy;
+			bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher);
+			
+			multiProxy->m_bridgeProxies.swap( i,multiProxy->m_bridgeProxies.size()-1);
+			multiProxy->m_bridgeProxies.pop_back();
+
+		}
+	}
+
+
+	/*
+
+	if (1)
+	{
+
+		//find broadphase that contain this multiProxy
+		int numChildBroadphases = getBroadphaseArray().size();
+		for (int i=0;i<numChildBroadphases;i++)
+		{
+			btBroadphaseInterface* childBroadphase = getBroadphaseArray()[i];
+			btVector3 worldAabbMin,worldAabbMax;
+			childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
+			bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
+			
+		//	fullyContained = fullyContained || boxIsContainedWithinBox(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
+			int containingBroadphaseIndex = -1;
+			
+			//if already contains this
+			
+			for (int i=0;i<multiProxy->m_bridgeProxies.size();i++)
+			{
+				if (multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase)
+				{
+					containingBroadphaseIndex = i;
+				}
+				alreadyInSimple = alreadyInSimple || (multiProxy->m_bridgeProxies[i]->m_childBroadphase == m_simpleBroadphase);
+			}
+
+			if (overlapsBroadphase)
+			{
+				if (containingBroadphaseIndex<0)
+				{
+					btBroadphaseProxy* childProxy = childBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
+					childProxy->m_multiSapParentProxy = multiProxy;
+					addToChildBroadphase(multiProxy,childProxy,childBroadphase);
+				}
+			} else
+			{
+				if (containingBroadphaseIndex>=0)
+				{
+					//remove
+					btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[containingBroadphaseIndex];
+
+					btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy;
+					bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher);
+					
+					multiProxy->m_bridgeProxies.swap( containingBroadphaseIndex,multiProxy->m_bridgeProxies.size()-1);
+					multiProxy->m_bridgeProxies.pop_back();
+				}
+			}
+		}
+
+
+		///If we are in no other child broadphase, stick the proxy in the global 'simple' broadphase (brute force)
+		///hopefully we don't end up with many entries here (can assert/provide feedback on stats)
+		if (0)//!multiProxy->m_bridgeProxies.size())
+		{
+			///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision
+			///this is needed to be able to calculate the aabb overlap
+			btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
+			childProxy->m_multiSapParentProxy = multiProxy;
+			addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase);
+		}
+	}
+
+	if (!multiProxy->m_bridgeProxies.size())
+	{
+		///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision
+		///this is needed to be able to calculate the aabb overlap
+		btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
+		childProxy->m_multiSapParentProxy = multiProxy;
+		addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase);
+	}
+*/
+
+
+	//update
+	for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
+	{
+		btBridgeProxy* bridgeProxyRef = multiProxy->m_bridgeProxies[i];
+		bridgeProxyRef->m_childBroadphase->setAabb(bridgeProxyRef->m_childProxy,aabbMin,aabbMax,dispatcher);
+	}
+
+}
+bool stopUpdating=false;
+
+
+
+class btMultiSapBroadphasePairSortPredicate
+{
+	public:
+
+		bool operator() ( const btBroadphasePair& a1, const btBroadphasePair& b1 )
+		{
+				btMultiSapBroadphase::btMultiSapProxy* aProxy0 = a1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy0->m_multiSapParentProxy : 0;
+				btMultiSapBroadphase::btMultiSapProxy* aProxy1 = a1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy1->m_multiSapParentProxy : 0;
+				btMultiSapBroadphase::btMultiSapProxy* bProxy0 = b1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy0->m_multiSapParentProxy : 0;
+				btMultiSapBroadphase::btMultiSapProxy* bProxy1 = b1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy1->m_multiSapParentProxy : 0;
+
+				 return aProxy0 > bProxy0 || 
+					(aProxy0 == bProxy0 && aProxy1 > bProxy1) ||
+					(aProxy0 == bProxy0 && aProxy1 == bProxy1 && a1.m_algorithm > b1.m_algorithm); 
+		}
+};
+
+
+        ///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
+void    btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
+{
+
+//	m_simpleBroadphase->calculateOverlappingPairs(dispatcher);
+
+	if (!stopUpdating && getOverlappingPairCache()->hasDeferredRemoval())
+	{
+	
+		btBroadphasePairArray&	overlappingPairArray = getOverlappingPairCache()->getOverlappingPairArray();
+
+	//	quicksort(overlappingPairArray,0,overlappingPairArray.size());
+
+		overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate());
+
+		//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
+	//	overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate());
+
+		overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
+		m_invalidPair = 0;
+
+		
+		int i;
+
+		btBroadphasePair previousPair;
+		previousPair.m_pProxy0 = 0;
+		previousPair.m_pProxy1 = 0;
+		previousPair.m_algorithm = 0;
+		
+		
+		for (i=0;i<overlappingPairArray.size();i++)
+		{
+		
+			btBroadphasePair& pair = overlappingPairArray[i];
+
+			btMultiSapProxy* aProxy0 = pair.m_pProxy0 ? (btMultiSapProxy*)pair.m_pProxy0->m_multiSapParentProxy : 0;
+			btMultiSapProxy* aProxy1 = pair.m_pProxy1 ? (btMultiSapProxy*)pair.m_pProxy1->m_multiSapParentProxy : 0;
+			btMultiSapProxy* bProxy0 = previousPair.m_pProxy0 ? (btMultiSapProxy*)previousPair.m_pProxy0->m_multiSapParentProxy : 0;
+			btMultiSapProxy* bProxy1 = previousPair.m_pProxy1 ? (btMultiSapProxy*)previousPair.m_pProxy1->m_multiSapParentProxy : 0;
+
+			bool isDuplicate = (aProxy0 == bProxy0) && (aProxy1 == bProxy1);
+			
+			previousPair = pair;
+
+			bool needsRemoval = false;
+
+			if (!isDuplicate)
+			{
+				bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
+
+				if (hasOverlap)
+				{
+					needsRemoval = false;//callback->processOverlap(pair);
+				} else
+				{
+					needsRemoval = true;
+				}
+			} else
+			{
+				//remove duplicate
+				needsRemoval = true;
+				//should have no algorithm
+				btAssert(!pair.m_algorithm);
+			}
+			
+			if (needsRemoval)
+			{
+				getOverlappingPairCache()->cleanOverlappingPair(pair,dispatcher);
+
+		//		m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
+		//		m_overlappingPairArray.pop_back();
+				pair.m_pProxy0 = 0;
+				pair.m_pProxy1 = 0;
+				m_invalidPair++;
+				gOverlappingPairs--;
+			} 
+			
+		}
+
+	///if you don't like to skip the invalid pairs in the array, execute following code:
+	#define CLEAN_INVALID_PAIRS 1
+	#ifdef CLEAN_INVALID_PAIRS
+
+		//perform a sort, to sort 'invalid' pairs to the end
+		//overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate());
+		overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate());
+
+		overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
+		m_invalidPair = 0;
+	#endif//CLEAN_INVALID_PAIRS
+		
+		//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
+	}
+
+
+}
+
+
+bool	btMultiSapBroadphase::testAabbOverlap(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1)
+{
+	btMultiSapProxy* multiSapProxy0 = (btMultiSapProxy*)childProxy0->m_multiSapParentProxy;
+		btMultiSapProxy* multiSapProxy1 = (btMultiSapProxy*)childProxy1->m_multiSapParentProxy;
+
+		return	TestAabbAgainstAabb2(multiSapProxy0->m_aabbMin,multiSapProxy0->m_aabbMax,
+			multiSapProxy1->m_aabbMin,multiSapProxy1->m_aabbMax);
+		
+}
+
+
+void	btMultiSapBroadphase::printStats()
+{
+/*	printf("---------------------------------\n");
+	
+		printf("btMultiSapBroadphase.h\n");
+		printf("numHandles = %d\n",m_multiSapProxies.size());
+			//find broadphase that contain this multiProxy
+		int numChildBroadphases = getBroadphaseArray().size();
+		for (int i=0;i<numChildBroadphases;i++)
+		{
+
+			btBroadphaseInterface* childBroadphase = getBroadphaseArray()[i];
+			childBroadphase->printStats();
+
+		}
+		*/
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h	(revision 2122)
@@ -0,0 +1,144 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef BT_MULTI_SAP_BROADPHASE
+#define BT_MULTI_SAP_BROADPHASE
+
+#include "btBroadphaseInterface.h"
+#include "LinearMath/btAlignedObjectArray.h"
+#include "btOverlappingPairCache.h"
+
+
+class btBroadphaseInterface;
+class btSimpleBroadphase;
+
+
+typedef btAlignedObjectArray<btBroadphaseInterface*> btSapBroadphaseArray;
+
+///The btMultiSapBroadphase is a broadphase that contains multiple SAP broadphases.
+///The user can add SAP broadphases that cover the world. A btBroadphaseProxy can be in multiple child broadphases at the same time.
+///A btQuantizedBvh acceleration structures finds overlapping SAPs for each btBroadphaseProxy.
+///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=328
+///and http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
+class btMultiSapBroadphase :public btBroadphaseInterface
+{
+	btSapBroadphaseArray	m_sapBroadphases;
+	
+	btSimpleBroadphase*		m_simpleBroadphase;
+
+	btOverlappingPairCache*	m_overlappingPairs;
+
+	class btQuantizedBvh*			m_optimizedAabbTree;
+
+
+	bool					m_ownsPairCache;
+	
+	btOverlapFilterCallback*	m_filterCallback;
+
+	int			m_invalidPair;
+
+	struct	btBridgeProxy
+	{
+		btBroadphaseProxy*		m_childProxy;
+		btBroadphaseInterface*	m_childBroadphase;
+	};
+
+
+public:
+
+	struct	btMultiSapProxy	: public btBroadphaseProxy
+	{
+
+		///array with all the entries that this proxy belongs to
+		btAlignedObjectArray<btBridgeProxy*> m_bridgeProxies;
+		btVector3	m_aabbMin;
+		btVector3	m_aabbMax;
+
+		int	m_shapeType;
+
+/*		void*	m_userPtr;
+		short int	m_collisionFilterGroup;
+		short int	m_collisionFilterMask;
+*/
+		btMultiSapProxy(const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask)
+			:btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask),
+			m_aabbMin(aabbMin),
+			m_aabbMax(aabbMax),
+			m_shapeType(shapeType)
+		{
+			m_multiSapParentProxy =this;
+		}
+
+		
+	};
+
+protected:
+
+
+	btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
+
+public:
+
+	btMultiSapBroadphase(int maxProxies = 16384,btOverlappingPairCache* pairCache=0);
+
+
+	btSapBroadphaseArray&	getBroadphaseArray()
+	{
+		return m_sapBroadphases;
+	}
+
+	const btSapBroadphaseArray&	getBroadphaseArray() const
+	{
+		return m_sapBroadphases;
+	}
+
+	virtual ~btMultiSapBroadphase();
+
+	virtual btBroadphaseProxy*	createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
+	virtual void	destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+	virtual void	setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
+
+	void	addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface*	childBroadphase);
+
+	///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
+	virtual void	calculateOverlappingPairs(btDispatcher* dispatcher);
+
+	bool	testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
+
+	virtual	btOverlappingPairCache*	getOverlappingPairCache()
+	{
+		return m_overlappingPairs;
+	}
+	virtual	const btOverlappingPairCache*	getOverlappingPairCache() const
+	{
+		return m_overlappingPairs;
+	}
+
+	///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
+	///will add some transform later
+	virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
+	{
+		aabbMin.setValue(-1e30f,-1e30f,-1e30f);
+		aabbMax.setValue(1e30f,1e30f,1e30f);
+	}
+
+	void	buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax);
+
+	virtual void	printStats();
+
+	void quicksort (btBroadphasePairArray& a, int lo, int hi);
+
+};
+
+#endif //BT_MULTI_SAP_BROADPHASE
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp	(revision 2122)
@@ -0,0 +1,579 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#include "btOverlappingPairCache.h"
+
+#include "btDispatcher.h"
+#include "btCollisionAlgorithm.h"
+
+#include <stdio.h>
+
+int	gOverlappingPairs = 0;
+
+int gRemovePairs =0;
+int gAddedPairs =0;
+int gFindPairs =0;
+
+
+
+
+btHashedOverlappingPairCache::btHashedOverlappingPairCache():
+	m_overlapFilterCallback(0),
+	m_blockedForChanges(false)
+{
+	int initialAllocatedSize= 2;
+	m_overlappingPairArray.reserve(initialAllocatedSize);
+	growTables();
+}
+
+
+
+
+btHashedOverlappingPairCache::~btHashedOverlappingPairCache()
+{
+	//todo/test: show we erase/delete data, or is it automatic
+}
+
+
+
+void	btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher)
+{
+	if (pair.m_algorithm)
+	{
+		{
+			pair.m_algorithm->~btCollisionAlgorithm();
+			dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
+			pair.m_algorithm=0;
+		}
+	}
+}
+
+
+
+
+void	btHashedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
+{
+
+	class	CleanPairCallback : public btOverlapCallback
+	{
+		btBroadphaseProxy* m_cleanProxy;
+		btOverlappingPairCache*	m_pairCache;
+		btDispatcher* m_dispatcher;
+
+	public:
+		CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher)
+			:m_cleanProxy(cleanProxy),
+			m_pairCache(pairCache),
+			m_dispatcher(dispatcher)
+		{
+		}
+		virtual	bool	processOverlap(btBroadphasePair& pair)
+		{
+			if ((pair.m_pProxy0 == m_cleanProxy) ||
+				(pair.m_pProxy1 == m_cleanProxy))
+			{
+				m_pairCache->cleanOverlappingPair(pair,m_dispatcher);
+			}
+			return false;
+		}
+		
+	};
+
+	CleanPairCallback cleanPairs(proxy,this,dispatcher);
+
+	processAllOverlappingPairs(&cleanPairs,dispatcher);
+
+}
+
+
+
+
+void	btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
+{
+
+	class	RemovePairCallback : public btOverlapCallback
+	{
+		btBroadphaseProxy* m_obsoleteProxy;
+
+	public:
+		RemovePairCallback(btBroadphaseProxy* obsoleteProxy)
+			:m_obsoleteProxy(obsoleteProxy)
+		{
+		}
+		virtual	bool	processOverlap(btBroadphasePair& pair)
+		{
+			return ((pair.m_pProxy0 == m_obsoleteProxy) ||
+				(pair.m_pProxy1 == m_obsoleteProxy));
+		}
+		
+	};
+
+
+	RemovePairCallback removeCallback(proxy);
+
+	processAllOverlappingPairs(&removeCallback,dispatcher);
+}
+
+
+
+
+
+btBroadphasePair* btHashedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
+{
+	gFindPairs++;
+	if(proxy0>proxy1) btSwap(proxy0,proxy1);
+	int proxyId1 = proxy0->getUid();
+	int proxyId2 = proxy1->getUid();
+
+	/*if (proxyId1 > proxyId2) 
+		btSwap(proxyId1, proxyId2);*/
+
+	int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
+
+	if (hash >= m_hashTable.size())
+	{
+		return NULL;
+	}
+
+	int index = m_hashTable[hash];
+	while (index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
+	{
+		index = m_next[index];
+	}
+
+	if (index == BT_NULL_PAIR)
+	{
+		return NULL;
+	}
+
+	btAssert(index < m_overlappingPairArray.size());
+
+	return &m_overlappingPairArray[index];
+}
+
+//#include <stdio.h>
+
+void	btHashedOverlappingPairCache::growTables()
+{
+
+	int newCapacity = m_overlappingPairArray.capacity();
+
+	if (m_hashTable.size() < newCapacity)
+	{
+		//grow hashtable and next table
+		int curHashtableSize = m_hashTable.size();
+
+		m_hashTable.resize(newCapacity);
+		m_next.resize(newCapacity);
+
+
+		int i;
+
+		for (i= 0; i < newCapacity; ++i)
+		{
+			m_hashTable[i] = BT_NULL_PAIR;
+		}
+		for (i = 0; i < newCapacity; ++i)
+		{
+			m_next[i] = BT_NULL_PAIR;
+		}
+
+		for(i=0;i<curHashtableSize;i++)
+		{
+	
+			const btBroadphasePair& pair = m_overlappingPairArray[i];
+			int proxyId1 = pair.m_pProxy0->getUid();
+			int proxyId2 = pair.m_pProxy1->getUid();
+			/*if (proxyId1 > proxyId2) 
+				btSwap(proxyId1, proxyId2);*/
+			int	hashValue = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));	// New hash value with new mask
+			m_next[i] = m_hashTable[hashValue];
+			m_hashTable[hashValue] = i;
+		}
+
+
+	}
+}
+
+btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
+{
+	if(proxy0>proxy1) btSwap(proxy0,proxy1);
+	int proxyId1 = proxy0->getUid();
+	int proxyId2 = proxy1->getUid();
+
+	/*if (proxyId1 > proxyId2) 
+		btSwap(proxyId1, proxyId2);*/
+
+	int	hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));	// New hash value with new mask
+
+
+	btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
+	if (pair != NULL)
+	{
+		return pair;
+	}
+	/*for(int i=0;i<m_overlappingPairArray.size();++i)
+		{
+		if(	(m_overlappingPairArray[i].m_pProxy0==proxy0)&&
+			(m_overlappingPairArray[i].m_pProxy1==proxy1))
+			{
+			printf("Adding duplicated %u<>%u\r\n",proxyId1,proxyId2);
+			internalFindPair(proxy0, proxy1, hash);
+			}
+		}*/
+	int count = m_overlappingPairArray.size();
+	int oldCapacity = m_overlappingPairArray.capacity();
+	void* mem = &m_overlappingPairArray.expand();
+	int newCapacity = m_overlappingPairArray.capacity();
+
+	if (oldCapacity < newCapacity)
+	{
+		growTables();
+		//hash with new capacity
+		hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
+	}
+	
+	pair = new (mem) btBroadphasePair(*proxy0,*proxy1);
+//	pair->m_pProxy0 = proxy0;
+//	pair->m_pProxy1 = proxy1;
+	pair->m_algorithm = 0;
+	pair->m_userInfo = 0;
+	
+
+	m_next[count] = m_hashTable[hash];
+	m_hashTable[hash] = count;
+
+	return pair;
+}
+
+
+
+void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1,btDispatcher* dispatcher)
+{
+	gRemovePairs++;
+	if(proxy0>proxy1) btSwap(proxy0,proxy1);
+	int proxyId1 = proxy0->getUid();
+	int proxyId2 = proxy1->getUid();
+
+	/*if (proxyId1 > proxyId2) 
+		btSwap(proxyId1, proxyId2);*/
+
+	int	hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
+
+	btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
+	if (pair == NULL)
+	{
+		return 0;
+	}
+
+	cleanOverlappingPair(*pair,dispatcher);
+
+	void* userData = pair->m_userInfo;
+
+	btAssert(pair->m_pProxy0->getUid() == proxyId1);
+	btAssert(pair->m_pProxy1->getUid() == proxyId2);
+
+	int pairIndex = int(pair - &m_overlappingPairArray[0]);
+	btAssert(pairIndex < m_overlappingPairArray.size());
+
+	// Remove the pair from the hash table.
+	int index = m_hashTable[hash];
+	btAssert(index != BT_NULL_PAIR);
+
+	int previous = BT_NULL_PAIR;
+	while (index != pairIndex)
+	{
+		previous = index;
+		index = m_next[index];
+	}
+
+	if (previous != BT_NULL_PAIR)
+	{
+		btAssert(m_next[previous] == pairIndex);
+		m_next[previous] = m_next[pairIndex];
+	}
+	else
+	{
+		m_hashTable[hash] = m_next[pairIndex];
+	}
+
+	// We now move the last pair into spot of the
+	// pair being removed. We need to fix the hash
+	// table indices to support the move.
+
+	int lastPairIndex = m_overlappingPairArray.size() - 1;
+
+	// If the removed pair is the last pair, we are done.
+	if (lastPairIndex == pairIndex)
+	{
+		m_overlappingPairArray.pop_back();
+		return userData;
+	}
+
+	// Remove the last pair from the hash table.
+	const btBroadphasePair* last = &m_overlappingPairArray[lastPairIndex];
+		/* missing swap here too, Nat. */ 
+	int lastHash = static_cast<int>(getHash(static_cast<unsigned int>(last->m_pProxy0->getUid()), static_cast<unsigned int>(last->m_pProxy1->getUid())) & (m_overlappingPairArray.capacity()-1));
+
+	index = m_hashTable[lastHash];
+	btAssert(index != BT_NULL_PAIR);
+
+	previous = BT_NULL_PAIR;
+	while (index != lastPairIndex)
+	{
+		previous = index;
+		index = m_next[index];
+	}
+
+	if (previous != BT_NULL_PAIR)
+	{
+		btAssert(m_next[previous] == lastPairIndex);
+		m_next[previous] = m_next[lastPairIndex];
+	}
+	else
+	{
+		m_hashTable[lastHash] = m_next[lastPairIndex];
+	}
+
+	// Copy the last pair into the remove pair's spot.
+	m_overlappingPairArray[pairIndex] = m_overlappingPairArray[lastPairIndex];
+
+	// Insert the last pair into the hash table
+	m_next[pairIndex] = m_hashTable[lastHash];
+	m_hashTable[lastHash] = pairIndex;
+
+	m_overlappingPairArray.pop_back();
+
+	return userData;
+}
+//#include <stdio.h>
+
+void	btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher)
+{
+
+	int i;
+
+//	printf("m_overlappingPairArray.size()=%d\n",m_overlappingPairArray.size());
+	for (i=0;i<m_overlappingPairArray.size();)
+	{
+	
+		btBroadphasePair* pair = &m_overlappingPairArray[i];
+		if (callback->processOverlap(*pair))
+		{
+			removeOverlappingPair(pair->m_pProxy0,pair->m_pProxy1,dispatcher);
+
+			gOverlappingPairs--;
+		} else
+		{
+			i++;
+		}
+	}
+}
+
+
+
+void*	btSortedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1, btDispatcher* dispatcher )
+{
+	if (!hasDeferredRemoval())
+	{
+		btBroadphasePair findPair(*proxy0,*proxy1);
+
+		int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
+		if (findIndex < m_overlappingPairArray.size())
+		{
+			gOverlappingPairs--;
+			btBroadphasePair& pair = m_overlappingPairArray[findIndex];
+			void* userData = pair.m_userInfo;
+			cleanOverlappingPair(pair,dispatcher);
+			
+			m_overlappingPairArray.swap(findIndex,m_overlappingPairArray.capacity()-1);
+			m_overlappingPairArray.pop_back();
+			return userData;
+		}
+	}
+
+	return 0;
+}
+
+
+
+
+
+
+
+
+btBroadphasePair*	btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
+{
+	//don't add overlap with own
+	assert(proxy0 != proxy1);
+
+	if (!needsBroadphaseCollision(proxy0,proxy1))
+		return 0;
+	
+	void* mem = &m_overlappingPairArray.expand();
+	btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0,*proxy1);
+	gOverlappingPairs++;
+	gAddedPairs++;
+	return pair;
+	
+}
+
+///this findPair becomes really slow. Either sort the list to speedup the query, or
+///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed.
+///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address)
+///Also we can use a 2D bitmap, which can be useful for a future GPU implementation
+ btBroadphasePair*	btSortedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
+{
+	if (!needsBroadphaseCollision(proxy0,proxy1))
+		return 0;
+
+	btBroadphasePair tmpPair(*proxy0,*proxy1);
+	int findIndex = m_overlappingPairArray.findLinearSearch(tmpPair);
+
+	if (findIndex < m_overlappingPairArray.size())
+	{
+		//assert(it != m_overlappingPairSet.end());
+		 btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
+		return pair;
+	}
+	return 0;
+}
+
+
+
+
+
+
+
+
+
+
+//#include <stdio.h>
+
+void	btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher)
+{
+
+	int i;
+
+	for (i=0;i<m_overlappingPairArray.size();)
+	{
+	
+		btBroadphasePair* pair = &m_overlappingPairArray[i];
+		if (callback->processOverlap(*pair))
+		{
+			cleanOverlappingPair(*pair,dispatcher);
+
+			m_overlappingPairArray.swap(i,m_overlappingPairArray.capacity()-1);
+			m_overlappingPairArray.pop_back();
+			gOverlappingPairs--;
+		} else
+		{
+			i++;
+		}
+	}
+}
+
+
+
+
+btSortedOverlappingPairCache::btSortedOverlappingPairCache():
+	m_blockedForChanges(false),
+	m_hasDeferredRemoval(true),
+	m_overlapFilterCallback(0)
+{
+	int initialAllocatedSize= 2;
+	m_overlappingPairArray.reserve(initialAllocatedSize);
+}
+
+btSortedOverlappingPairCache::~btSortedOverlappingPairCache()
+{
+	//todo/test: show we erase/delete data, or is it automatic
+}
+
+void	btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher)
+{
+	if (pair.m_algorithm)
+	{
+		{
+			pair.m_algorithm->~btCollisionAlgorithm();
+			dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
+			pair.m_algorithm=0;
+			gRemovePairs--;
+		}
+	}
+}
+
+
+void	btSortedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
+{
+
+	class	CleanPairCallback : public btOverlapCallback
+	{
+		btBroadphaseProxy* m_cleanProxy;
+		btOverlappingPairCache*	m_pairCache;
+		btDispatcher* m_dispatcher;
+
+	public:
+		CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher)
+			:m_cleanProxy(cleanProxy),
+			m_pairCache(pairCache),
+			m_dispatcher(dispatcher)
+		{
+		}
+		virtual	bool	processOverlap(btBroadphasePair& pair)
+		{
+			if ((pair.m_pProxy0 == m_cleanProxy) ||
+				(pair.m_pProxy1 == m_cleanProxy))
+			{
+				m_pairCache->cleanOverlappingPair(pair,m_dispatcher);
+			}
+			return false;
+		}
+		
+	};
+
+	CleanPairCallback cleanPairs(proxy,this,dispatcher);
+
+	processAllOverlappingPairs(&cleanPairs,dispatcher);
+
+}
+
+
+void	btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
+{
+
+	class	RemovePairCallback : public btOverlapCallback
+	{
+		btBroadphaseProxy* m_obsoleteProxy;
+
+	public:
+		RemovePairCallback(btBroadphaseProxy* obsoleteProxy)
+			:m_obsoleteProxy(obsoleteProxy)
+		{
+		}
+		virtual	bool	processOverlap(btBroadphasePair& pair)
+		{
+			return ((pair.m_pProxy0 == m_obsoleteProxy) ||
+				(pair.m_pProxy1 == m_obsoleteProxy));
+		}
+		
+	};
+
+	RemovePairCallback removeCallback(proxy);
+
+	processAllOverlappingPairs(&removeCallback,dispatcher);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h	(revision 2122)
@@ -0,0 +1,437 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef OVERLAPPING_PAIR_CACHE_H
+#define OVERLAPPING_PAIR_CACHE_H
+
+
+#include "btBroadphaseInterface.h"
+#include "btBroadphaseProxy.h"
+#include "btOverlappingPairCallback.h"
+
+#include "LinearMath/btPoint3.h"
+#include "LinearMath/btAlignedObjectArray.h"
+class btDispatcher;
+
+typedef btAlignedObjectArray<btBroadphasePair>	btBroadphasePairArray;
+
+struct	btOverlapCallback
+{
+	virtual ~btOverlapCallback()
+	{}
+	//return true for deletion of the pair
+	virtual bool	processOverlap(btBroadphasePair& pair) = 0;
+
+};
+
+struct btOverlapFilterCallback
+{
+	virtual ~btOverlapFilterCallback()
+	{}
+	// return true when pairs need collision
+	virtual bool	needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const = 0;
+};
+
+
+
+
+
+
+
+extern int gRemovePairs;
+extern int gAddedPairs;
+extern int gFindPairs;
+
+const int BT_NULL_PAIR=0xffffffff;
+
+///The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
+///The btHashedOverlappingPairCache and btSortedOverlappingPairCache classes are two implementations.
+class btOverlappingPairCache : public btOverlappingPairCallback
+{
+public:
+	virtual ~btOverlappingPairCache() {} // this is needed so we can get to the derived class destructor
+
+	virtual btBroadphasePair*	getOverlappingPairArrayPtr() = 0;
+	
+	virtual const btBroadphasePair*	getOverlappingPairArrayPtr() const = 0;
+
+	virtual btBroadphasePairArray&	getOverlappingPairArray() = 0;
+
+	virtual	void	cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) = 0;
+
+	virtual int getNumOverlappingPairs() const = 0;
+
+	virtual void	cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher) = 0;
+
+	virtual	void setOverlapFilterCallback(btOverlapFilterCallback* callback) = 0;
+
+	virtual void	processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher) = 0;
+
+	virtual btBroadphasePair* findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) = 0;
+
+	virtual bool	hasDeferredRemoval() = 0;
+
+};
+
+/// Hash-space based Pair Cache, thanks to Erin Catto, Box2D, http://www.box2d.org, and Pierre Terdiman, Codercorner, http://codercorner.com
+class btHashedOverlappingPairCache : public btOverlappingPairCache
+{
+	btBroadphasePairArray	m_overlappingPairArray;
+	btOverlapFilterCallback* m_overlapFilterCallback;
+	bool		m_blockedForChanges;
+
+
+public:
+	btHashedOverlappingPairCache();
+	virtual ~btHashedOverlappingPairCache();
+
+	
+	void	removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+
+	virtual void*	removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher);
+	
+	SIMD_FORCE_INLINE bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
+	{
+		if (m_overlapFilterCallback)
+			return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
+
+		bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
+		collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
+		
+		return collides;
+	}
+
+	// Add a pair and return the new pair. If the pair already exists,
+	// no new pair is created and the old one is returned.
+	virtual btBroadphasePair* 	addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
+	{
+		gAddedPairs++;
+
+		if (!needsBroadphaseCollision(proxy0,proxy1))
+			return 0;
+
+		return internalAddPair(proxy0,proxy1);
+	}
+
+	
+
+	void	cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+
+	
+	virtual void	processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
+
+	virtual btBroadphasePair*	getOverlappingPairArrayPtr()
+	{
+		return &m_overlappingPairArray[0];
+	}
+
+	const btBroadphasePair*	getOverlappingPairArrayPtr() const
+	{
+		return &m_overlappingPairArray[0];
+	}
+
+	btBroadphasePairArray&	getOverlappingPairArray()
+	{
+		return m_overlappingPairArray;
+	}
+
+	const btBroadphasePairArray&	getOverlappingPairArray() const
+	{
+		return m_overlappingPairArray;
+	}
+
+	void	cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
+
+
+
+	btBroadphasePair* findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1);
+
+	int GetCount() const { return m_overlappingPairArray.size(); }
+//	btBroadphasePair* GetPairs() { return m_pairs; }
+
+	btOverlapFilterCallback* getOverlapFilterCallback()
+	{
+		return m_overlapFilterCallback;
+	}
+
+	void setOverlapFilterCallback(btOverlapFilterCallback* callback)
+	{
+		m_overlapFilterCallback = callback;
+	}
+
+	int	getNumOverlappingPairs() const
+	{
+		return m_overlappingPairArray.size();
+	}
+private:
+	
+	btBroadphasePair* 	internalAddPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
+
+	void	growTables();
+
+	SIMD_FORCE_INLINE bool equalsPair(const btBroadphasePair& pair, int proxyId1, int proxyId2)
+	{	
+		return pair.m_pProxy0->getUid() == proxyId1 && pair.m_pProxy1->getUid() == proxyId2;
+	}
+
+	/*
+	// Thomas Wang's hash, see: http://www.concentric.net/~Ttwang/tech/inthash.htm
+	// This assumes proxyId1 and proxyId2 are 16-bit.
+	SIMD_FORCE_INLINE int getHash(int proxyId1, int proxyId2)
+	{
+		int key = (proxyId2 << 16) | proxyId1;
+		key = ~key + (key << 15);
+		key = key ^ (key >> 12);
+		key = key + (key << 2);
+		key = key ^ (key >> 4);
+		key = key * 2057;
+		key = key ^ (key >> 16);
+		return key;
+	}
+	*/
+
+
+	
+	SIMD_FORCE_INLINE	unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2)
+	{
+		int key = static_cast<int>(((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16));
+		// Thomas Wang's hash
+
+		key += ~(key << 15);
+		key ^=  (key >> 10);
+		key +=  (key << 3);
+		key ^=  (key >> 6);
+		key += ~(key << 11);
+		key ^=  (key >> 16);
+		return static_cast<unsigned int>(key);
+	}
+	
+
+
+
+
+	SIMD_FORCE_INLINE btBroadphasePair* internalFindPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1, int hash)
+	{
+		int proxyId1 = proxy0->getUid();
+		int proxyId2 = proxy1->getUid();
+		#if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat.
+		if (proxyId1 > proxyId2) 
+			btSwap(proxyId1, proxyId2);
+		#endif
+
+		int index = m_hashTable[hash];
+		
+		while( index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
+		{
+			index = m_next[index];
+		}
+
+		if ( index == BT_NULL_PAIR )
+		{
+			return NULL;
+		}
+
+		btAssert(index < m_overlappingPairArray.size());
+
+		return &m_overlappingPairArray[index];
+	}
+
+	virtual bool	hasDeferredRemoval()
+	{
+		return false;
+	}
+
+public:
+	
+	btAlignedObjectArray<int>	m_hashTable;
+	btAlignedObjectArray<int>	m_next;
+	
+};
+
+
+
+
+///btSortedOverlappingPairCache maintains the objects with overlapping AABB
+///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase
+class	btSortedOverlappingPairCache : public btOverlappingPairCache
+{
+	protected:
+		//avoid brute-force finding all the time
+		btBroadphasePairArray	m_overlappingPairArray;
+
+		//during the dispatch, check that user doesn't destroy/create proxy
+		bool		m_blockedForChanges;
+
+		///by default, do the removal during the pair traversal
+		bool		m_hasDeferredRemoval;
+		
+		//if set, use the callback instead of the built in filter in needBroadphaseCollision
+		btOverlapFilterCallback* m_overlapFilterCallback;
+
+	public:
+			
+		btSortedOverlappingPairCache();	
+		virtual ~btSortedOverlappingPairCache();
+
+		virtual void	processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
+
+		void*	removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher);
+
+		void	cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
+		
+		btBroadphasePair*	addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
+
+		btBroadphasePair*	findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
+			
+		
+		void	cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+
+		void	removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+
+
+		inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
+		{
+			if (m_overlapFilterCallback)
+				return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
+
+			bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
+			collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
+			
+			return collides;
+		}
+		
+		btBroadphasePairArray&	getOverlappingPairArray()
+		{
+			return m_overlappingPairArray;
+		}
+
+		const btBroadphasePairArray&	getOverlappingPairArray() const
+		{
+			return m_overlappingPairArray;
+		}
+
+		
+
+
+		btBroadphasePair*	getOverlappingPairArrayPtr()
+		{
+			return &m_overlappingPairArray[0];
+		}
+
+		const btBroadphasePair*	getOverlappingPairArrayPtr() const
+		{
+			return &m_overlappingPairArray[0];
+		}
+
+		int	getNumOverlappingPairs() const
+		{
+			return m_overlappingPairArray.size();
+		}
+		
+		btOverlapFilterCallback* getOverlapFilterCallback()
+		{
+			return m_overlapFilterCallback;
+		}
+
+		void setOverlapFilterCallback(btOverlapFilterCallback* callback)
+		{
+			m_overlapFilterCallback = callback;
+		}
+
+		virtual bool	hasDeferredRemoval()
+		{
+			return m_hasDeferredRemoval;
+		}
+
+
+};
+
+
+
+///btNullPairCache skips add/removal of overlapping pairs. Userful for benchmarking and testing.
+class btNullPairCache : public btOverlappingPairCache
+{
+
+	btBroadphasePairArray	m_overlappingPairArray;
+
+public:
+
+	virtual btBroadphasePair*	getOverlappingPairArrayPtr()
+	{
+		return &m_overlappingPairArray[0];
+	}
+	const btBroadphasePair*	getOverlappingPairArrayPtr() const
+	{
+		return &m_overlappingPairArray[0];
+	}
+	btBroadphasePairArray&	getOverlappingPairArray()
+	{
+		return m_overlappingPairArray;
+	}
+	
+	virtual	void	cleanOverlappingPair(btBroadphasePair& /*pair*/,btDispatcher* /*dispatcher*/)
+	{
+
+	}
+
+	virtual int getNumOverlappingPairs() const
+	{
+		return 0;
+	}
+
+	virtual void	cleanProxyFromPairs(btBroadphaseProxy* /*proxy*/,btDispatcher* /*dispatcher*/)
+	{
+
+	}
+
+	virtual	void setOverlapFilterCallback(btOverlapFilterCallback* /*callback*/)
+	{
+	}
+
+	virtual void	processAllOverlappingPairs(btOverlapCallback*,btDispatcher* /*dispatcher*/)
+	{
+	}
+
+	virtual btBroadphasePair* findPair(btBroadphaseProxy* /*proxy0*/, btBroadphaseProxy* /*proxy1*/)
+	{
+		return 0;
+	}
+
+	virtual bool	hasDeferredRemoval()
+	{
+		return true;
+	}
+
+	virtual btBroadphasePair*	addOverlappingPair(btBroadphaseProxy* /*proxy0*/,btBroadphaseProxy* /*proxy1*/)
+	{
+		return 0;
+	}
+
+	virtual void*	removeOverlappingPair(btBroadphaseProxy* /*proxy0*/,btBroadphaseProxy* /*proxy1*/,btDispatcher* /*dispatcher*/)
+	{
+		return 0;
+	}
+
+	virtual void	removeOverlappingPairsContainingProxy(btBroadphaseProxy* /*proxy0*/,btDispatcher* /*dispatcher*/)
+	{
+	}
+
+
+};
+
+
+#endif //OVERLAPPING_PAIR_CACHE_H
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h	(revision 2122)
@@ -0,0 +1,40 @@
+
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef OVERLAPPING_PAIR_CALLBACK_H
+#define OVERLAPPING_PAIR_CALLBACK_H
+
+class btDispatcher;
+struct  btBroadphasePair;
+
+///The btOverlappingPairCallback class is an additional optional broadphase user callback for adding/removing overlapping pairs, similar interface to btOverlappingPairCache.
+class btOverlappingPairCallback
+{
+public:
+	virtual ~btOverlappingPairCallback()
+	{
+
+	}
+	
+	virtual btBroadphasePair*	addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) = 0;
+
+	virtual void*	removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher) = 0;
+
+	virtual void	removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy0,btDispatcher* dispatcher) = 0;
+
+};
+
+#endif //OVERLAPPING_PAIR_CALLBACK_H
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp	(revision 2122)
@@ -0,0 +1,1047 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btQuantizedBvh.h"
+
+#include "LinearMath/btAabbUtil2.h"
+#include "LinearMath/btIDebugDraw.h"
+
+
+btQuantizedBvh::btQuantizedBvh() : m_useQuantization(false), 
+					//m_traversalMode(TRAVERSAL_STACKLESS_CACHE_FRIENDLY)
+					m_traversalMode(TRAVERSAL_STACKLESS)
+					//m_traversalMode(TRAVERSAL_RECURSIVE)
+					,m_subtreeHeaderCount(0) //PCK: add this line
+{ 
+
+}
+
+
+
+
+
+void btQuantizedBvh::buildInternal()
+{
+	///assumes that caller filled in the m_quantizedLeafNodes
+	m_useQuantization = true;
+	int numLeafNodes = 0;
+	
+	if (m_useQuantization)
+	{
+		//now we have an array of leafnodes in m_leafNodes
+		numLeafNodes = m_quantizedLeafNodes.size();
+
+		m_quantizedContiguousNodes.resize(2*numLeafNodes);
+
+	}
+
+	m_curNodeIndex = 0;
+
+	buildTree(0,numLeafNodes);
+
+	///if the entire tree is small then subtree size, we need to create a header info for the tree
+	if(m_useQuantization && !m_SubtreeHeaders.size())
+	{
+		btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
+		subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]);
+		subtree.m_rootNodeIndex = 0;
+		subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex();
+	}
+
+	//PCK: update the copy of the size
+	m_subtreeHeaderCount = m_SubtreeHeaders.size();
+
+	//PCK: clear m_quantizedLeafNodes and m_leafNodes, they are temporary
+	m_quantizedLeafNodes.clear();
+	m_leafNodes.clear();
+}
+
+
+
+///just for debugging, to visualize the individual patches/subtrees
+#ifdef DEBUG_PATCH_COLORS
+btVector3 color[4]=
+{
+	btVector3(255,0,0),
+	btVector3(0,255,0),
+	btVector3(0,0,255),
+	btVector3(0,255,255)
+};
+#endif //DEBUG_PATCH_COLORS
+
+
+
+void	btQuantizedBvh::setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin)
+{
+	//enlarge the AABB to avoid division by zero when initializing the quantization values
+	btVector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin);
+	m_bvhAabbMin = bvhAabbMin - clampValue;
+	m_bvhAabbMax = bvhAabbMax + clampValue;
+	btVector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin;
+	m_bvhQuantization = btVector3(btScalar(65533.0),btScalar(65533.0),btScalar(65533.0)) / aabbSize;
+	m_useQuantization = true;
+}
+
+
+
+
+btQuantizedBvh::~btQuantizedBvh()
+{
+}
+
+#ifdef DEBUG_TREE_BUILDING
+int gStackDepth = 0;
+int gMaxStackDepth = 0;
+#endif //DEBUG_TREE_BUILDING
+
+void	btQuantizedBvh::buildTree	(int startIndex,int endIndex)
+{
+#ifdef DEBUG_TREE_BUILDING
+	gStackDepth++;
+	if (gStackDepth > gMaxStackDepth)
+		gMaxStackDepth = gStackDepth;
+#endif //DEBUG_TREE_BUILDING
+
+
+	int splitAxis, splitIndex, i;
+	int numIndices =endIndex-startIndex;
+	int curIndex = m_curNodeIndex;
+
+	assert(numIndices>0);
+
+	if (numIndices==1)
+	{
+#ifdef DEBUG_TREE_BUILDING
+		gStackDepth--;
+#endif //DEBUG_TREE_BUILDING
+		
+		assignInternalNodeFromLeafNode(m_curNodeIndex,startIndex);
+
+		m_curNodeIndex++;
+		return;	
+	}
+	//calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'.
+	
+	splitAxis = calcSplittingAxis(startIndex,endIndex);
+
+	splitIndex = sortAndCalcSplittingIndex(startIndex,endIndex,splitAxis);
+
+	int internalNodeIndex = m_curNodeIndex;
+	
+	setInternalNodeAabbMax(m_curNodeIndex,m_bvhAabbMin);
+	setInternalNodeAabbMin(m_curNodeIndex,m_bvhAabbMax);
+	
+	for (i=startIndex;i<endIndex;i++)
+	{
+		mergeInternalNodeAabb(m_curNodeIndex,getAabbMin(i),getAabbMax(i));
+	}
+
+	m_curNodeIndex++;
+	
+
+	//internalNode->m_escapeIndex;
+	
+	int leftChildNodexIndex = m_curNodeIndex;
+
+	//build left child tree
+	buildTree(startIndex,splitIndex);
+
+	int rightChildNodexIndex = m_curNodeIndex;
+	//build right child tree
+	buildTree(splitIndex,endIndex);
+
+#ifdef DEBUG_TREE_BUILDING
+	gStackDepth--;
+#endif //DEBUG_TREE_BUILDING
+
+	int escapeIndex = m_curNodeIndex - curIndex;
+
+	if (m_useQuantization)
+	{
+		//escapeIndex is the number of nodes of this subtree
+		const int sizeQuantizedNode =sizeof(btQuantizedBvhNode);
+		const int treeSizeInBytes = escapeIndex * sizeQuantizedNode;
+		if (treeSizeInBytes > MAX_SUBTREE_SIZE_IN_BYTES)
+		{
+			updateSubtreeHeaders(leftChildNodexIndex,rightChildNodexIndex);
+		}
+	}
+
+	setInternalNodeEscapeIndex(internalNodeIndex,escapeIndex);
+
+}
+
+void	btQuantizedBvh::updateSubtreeHeaders(int leftChildNodexIndex,int rightChildNodexIndex)
+{
+	btAssert(m_useQuantization);
+
+	btQuantizedBvhNode& leftChildNode = m_quantizedContiguousNodes[leftChildNodexIndex];
+	int leftSubTreeSize = leftChildNode.isLeafNode() ? 1 : leftChildNode.getEscapeIndex();
+	int leftSubTreeSizeInBytes =  leftSubTreeSize * static_cast<int>(sizeof(btQuantizedBvhNode));
+	
+	btQuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex];
+	int rightSubTreeSize = rightChildNode.isLeafNode() ? 1 : rightChildNode.getEscapeIndex();
+	int rightSubTreeSizeInBytes =  rightSubTreeSize *  static_cast<int>(sizeof(btQuantizedBvhNode));
+
+	if(leftSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES)
+	{
+		btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
+		subtree.setAabbFromQuantizeNode(leftChildNode);
+		subtree.m_rootNodeIndex = leftChildNodexIndex;
+		subtree.m_subtreeSize = leftSubTreeSize;
+	}
+
+	if(rightSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES)
+	{
+		btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
+		subtree.setAabbFromQuantizeNode(rightChildNode);
+		subtree.m_rootNodeIndex = rightChildNodexIndex;
+		subtree.m_subtreeSize = rightSubTreeSize;
+	}
+
+	//PCK: update the copy of the size
+	m_subtreeHeaderCount = m_SubtreeHeaders.size();
+}
+
+
+int	btQuantizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis)
+{
+	int i;
+	int splitIndex =startIndex;
+	int numIndices = endIndex - startIndex;
+	btScalar splitValue;
+
+	btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
+		means+=center;
+	}
+	means *= (btScalar(1.)/(btScalar)numIndices);
+	
+	splitValue = means[splitAxis];
+	
+	//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
+		if (center[splitAxis] > splitValue)
+		{
+			//swap
+			swapLeafNodes(i,splitIndex);
+			splitIndex++;
+		}
+	}
+
+	//if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex
+	//otherwise the tree-building might fail due to stack-overflows in certain cases.
+	//unbalanced1 is unsafe: it can cause stack overflows
+	//bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1)));
+
+	//unbalanced2 should work too: always use center (perfect balanced trees)	
+	//bool unbalanced2 = true;
+
+	//this should be safe too:
+	int rangeBalancedIndices = numIndices/3;
+	bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices)));
+	
+	if (unbalanced)
+	{
+		splitIndex = startIndex+ (numIndices>>1);
+	}
+
+	bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
+	(void)unbal;
+	btAssert(!unbal);
+
+	return splitIndex;
+}
+
+
+int	btQuantizedBvh::calcSplittingAxis(int startIndex,int endIndex)
+{
+	int i;
+
+	btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
+	btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
+	int numIndices = endIndex-startIndex;
+
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
+		means+=center;
+	}
+	means *= (btScalar(1.)/(btScalar)numIndices);
+		
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
+		btVector3 diff2 = center-means;
+		diff2 = diff2 * diff2;
+		variance += diff2;
+	}
+	variance *= (btScalar(1.)/	((btScalar)numIndices-1)	);
+	
+	return variance.maxAxis();
+}
+
+
+
+void	btQuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	//either choose recursive traversal (walkTree) or stackless (walkStacklessTree)
+
+	if (m_useQuantization)
+	{
+		///quantize query AABB
+		unsigned short int quantizedQueryAabbMin[3];
+		unsigned short int quantizedQueryAabbMax[3];
+		quantizeWithClamp(quantizedQueryAabbMin,aabbMin,0);
+		quantizeWithClamp(quantizedQueryAabbMax,aabbMax,1);
+
+		switch (m_traversalMode)
+		{
+		case TRAVERSAL_STACKLESS:
+				walkStacklessQuantizedTree(nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax,0,m_curNodeIndex);
+			break;
+		case TRAVERSAL_STACKLESS_CACHE_FRIENDLY:
+				walkStacklessQuantizedTreeCacheFriendly(nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
+			break;
+		case TRAVERSAL_RECURSIVE:
+			{
+				const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[0];
+				walkRecursiveQuantizedTreeAgainstQueryAabb(rootNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
+			}
+			break;
+		default:
+			//unsupported
+			btAssert(0);
+		}
+	} else
+	{
+		walkStacklessTree(nodeCallback,aabbMin,aabbMax);
+	}
+}
+
+
+int maxIterations = 0;
+
+void	btQuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	btAssert(!m_useQuantization);
+
+	const btOptimizedBvhNode* rootNode = &m_contiguousNodes[0];
+	int escapeIndex, curIndex = 0;
+	int walkIterations = 0;
+	bool isLeafNode;
+	//PCK: unsigned instead of bool
+	unsigned aabbOverlap;
+
+	while (curIndex < m_curNodeIndex)
+	{
+		//catch bugs in tree data
+		assert (walkIterations < m_curNodeIndex);
+
+		walkIterations++;
+		aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg);
+		isLeafNode = rootNode->m_escapeIndex == -1;
+		
+		//PCK: unsigned instead of bool
+		if (isLeafNode && (aabbOverlap != 0))
+		{
+			nodeCallback->processNode(rootNode->m_subPart,rootNode->m_triangleIndex);
+		} 
+		
+		//PCK: unsigned instead of bool
+		if ((aabbOverlap != 0) || isLeafNode)
+		{
+			rootNode++;
+			curIndex++;
+		} else
+		{
+			escapeIndex = rootNode->m_escapeIndex;
+			rootNode += escapeIndex;
+			curIndex += escapeIndex;
+		}
+	}
+	if (maxIterations < walkIterations)
+		maxIterations = walkIterations;
+
+}
+
+/*
+///this was the original recursive traversal, before we optimized towards stackless traversal
+void	btQuantizedBvh::walkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	bool isLeafNode, aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
+	if (aabbOverlap)
+	{
+		isLeafNode = (!rootNode->m_leftChild && !rootNode->m_rightChild);
+		if (isLeafNode)
+		{
+			nodeCallback->processNode(rootNode);
+		} else
+		{
+			walkTree(rootNode->m_leftChild,nodeCallback,aabbMin,aabbMax);
+			walkTree(rootNode->m_rightChild,nodeCallback,aabbMin,aabbMax);
+		}
+	}
+
+}
+*/
+
+void btQuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
+{
+	btAssert(m_useQuantization);
+	
+	bool isLeafNode;
+	//PCK: unsigned instead of bool
+	unsigned aabbOverlap;
+
+	//PCK: unsigned instead of bool
+	aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,currentNode->m_quantizedAabbMin,currentNode->m_quantizedAabbMax);
+	isLeafNode = currentNode->isLeafNode();
+		
+	//PCK: unsigned instead of bool
+	if (aabbOverlap != 0)
+	{
+		if (isLeafNode)
+		{
+			nodeCallback->processNode(currentNode->getPartId(),currentNode->getTriangleIndex());
+		} else
+		{
+			//process left and right children
+			const btQuantizedBvhNode* leftChildNode = currentNode+1;
+			walkRecursiveQuantizedTreeAgainstQueryAabb(leftChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
+
+			const btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? leftChildNode+1:leftChildNode+leftChildNode->getEscapeIndex();
+			walkRecursiveQuantizedTreeAgainstQueryAabb(rightChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
+		}
+	}		
+}
+
+
+
+
+
+void	btQuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const
+{
+	btAssert(m_useQuantization);
+	
+	int curIndex = startNodeIndex;
+	int walkIterations = 0;
+	int subTreeSize = endNodeIndex - startNodeIndex;
+	(void)subTreeSize;
+
+	const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
+	int escapeIndex;
+	
+	bool isLeafNode;
+	//PCK: unsigned instead of bool
+	unsigned boxBoxOverlap = 0;
+	unsigned rayBoxOverlap = 0;
+
+	btScalar lambda_max = 1.0;
+#define RAYAABB2
+#ifdef RAYAABB2
+	btVector3 rayFrom = raySource;
+	btVector3 rayDirection = (rayTarget-raySource);
+	rayDirection.normalize ();
+	lambda_max = rayDirection.dot(rayTarget-raySource);
+	///what about division by zero? --> just set rayDirection[i] to 1.0
+	rayDirection[0] = rayDirection[0] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDirection[0];
+	rayDirection[1] = rayDirection[1] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDirection[1];
+	rayDirection[2] = rayDirection[2] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDirection[2];
+	unsigned int sign[3] = { rayDirection[0] < 0.0, rayDirection[1] < 0.0, rayDirection[2] < 0.0};
+#endif
+
+	/* Quick pruning by quantized box */
+	btVector3 rayAabbMin = raySource;
+	btVector3 rayAabbMax = raySource;
+	rayAabbMin.setMin(rayTarget);
+	rayAabbMax.setMax(rayTarget);
+
+	/* Add box cast extents to bounding box */
+	rayAabbMin += aabbMin;
+	rayAabbMax += aabbMax;
+
+	unsigned short int quantizedQueryAabbMin[3];
+	unsigned short int quantizedQueryAabbMax[3];
+	quantizeWithClamp(quantizedQueryAabbMin,rayAabbMin,0);
+	quantizeWithClamp(quantizedQueryAabbMax,rayAabbMax,1);
+
+	while (curIndex < endNodeIndex)
+	{
+
+//#define VISUALLY_ANALYZE_BVH 1
+#ifdef VISUALLY_ANALYZE_BVH
+		//some code snippet to debugDraw aabb, to visually analyze bvh structure
+		static int drawPatch = 0;
+		//need some global access to a debugDrawer
+		extern btIDebugDraw* debugDrawerPtr;
+		if (curIndex==drawPatch)
+		{
+			btVector3 aabbMin,aabbMax;
+			aabbMin = unQuantize(rootNode->m_quantizedAabbMin);
+			aabbMax = unQuantize(rootNode->m_quantizedAabbMax);
+			btVector3	color(1,0,0);
+			debugDrawerPtr->drawAabb(aabbMin,aabbMax,color);
+		}
+#endif//VISUALLY_ANALYZE_BVH
+
+		//catch bugs in tree data
+		assert (walkIterations < subTreeSize);
+
+		walkIterations++;
+		//PCK: unsigned instead of bool
+		// only interested if this is closer than any previous hit
+		btScalar param = 1.0;
+		rayBoxOverlap = 0;
+		boxBoxOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax);
+		isLeafNode = rootNode->isLeafNode();
+		if (boxBoxOverlap)
+		{
+			btVector3 bounds[2];
+			bounds[0] = unQuantize(rootNode->m_quantizedAabbMin);
+			bounds[1] = unQuantize(rootNode->m_quantizedAabbMax);
+			/* Add box cast extents */
+			bounds[0] += aabbMin;
+			bounds[1] += aabbMax;
+			btVector3 normal;
+#if 0
+			bool ra2 = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max);
+			bool ra = btRayAabb (raySource, rayTarget, bounds[0], bounds[1], param, normal);
+			if (ra2 != ra)
+			{
+				printf("functions don't match\n");
+			}
+#endif
+#ifdef RAYAABB2
+			///careful with this check: need to check division by zero (above) and fix the unQuantize method
+			///thanks Joerg/hiker for the reproduction case!
+			///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858
+
+			rayBoxOverlap = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0f, lambda_max);
+#else
+			rayBoxOverlap = true;//btRayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal);
+#endif
+		}
+		
+		if (isLeafNode && rayBoxOverlap)
+		{
+			nodeCallback->processNode(rootNode->getPartId(),rootNode->getTriangleIndex());
+		}
+		
+		//PCK: unsigned instead of bool
+		if ((rayBoxOverlap != 0) || isLeafNode)
+		{
+			rootNode++;
+			curIndex++;
+		} else
+		{
+			escapeIndex = rootNode->getEscapeIndex();
+			rootNode += escapeIndex;
+			curIndex += escapeIndex;
+		}
+	}
+	if (maxIterations < walkIterations)
+		maxIterations = walkIterations;
+
+}
+
+void	btQuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const
+{
+	btAssert(m_useQuantization);
+	
+	int curIndex = startNodeIndex;
+	int walkIterations = 0;
+	int subTreeSize = endNodeIndex - startNodeIndex;
+	(void)subTreeSize;
+
+	const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
+	int escapeIndex;
+	
+	bool isLeafNode;
+	//PCK: unsigned instead of bool
+	unsigned aabbOverlap;
+
+	while (curIndex < endNodeIndex)
+	{
+
+//#define VISUALLY_ANALYZE_BVH 1
+#ifdef VISUALLY_ANALYZE_BVH
+		//some code snippet to debugDraw aabb, to visually analyze bvh structure
+		static int drawPatch = 0;
+		//need some global access to a debugDrawer
+		extern btIDebugDraw* debugDrawerPtr;
+		if (curIndex==drawPatch)
+		{
+			btVector3 aabbMin,aabbMax;
+			aabbMin = unQuantize(rootNode->m_quantizedAabbMin);
+			aabbMax = unQuantize(rootNode->m_quantizedAabbMax);
+			btVector3	color(1,0,0);
+			debugDrawerPtr->drawAabb(aabbMin,aabbMax,color);
+		}
+#endif//VISUALLY_ANALYZE_BVH
+
+		//catch bugs in tree data
+		assert (walkIterations < subTreeSize);
+
+		walkIterations++;
+		//PCK: unsigned instead of bool
+		aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax);
+		isLeafNode = rootNode->isLeafNode();
+		
+		if (isLeafNode && aabbOverlap)
+		{
+			nodeCallback->processNode(rootNode->getPartId(),rootNode->getTriangleIndex());
+		} 
+		
+		//PCK: unsigned instead of bool
+		if ((aabbOverlap != 0) || isLeafNode)
+		{
+			rootNode++;
+			curIndex++;
+		} else
+		{
+			escapeIndex = rootNode->getEscapeIndex();
+			rootNode += escapeIndex;
+			curIndex += escapeIndex;
+		}
+	}
+	if (maxIterations < walkIterations)
+		maxIterations = walkIterations;
+
+}
+
+//This traversal can be called from Playstation 3 SPU
+void	btQuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
+{
+	btAssert(m_useQuantization);
+
+	int i;
+
+
+	for (i=0;i<this->m_SubtreeHeaders.size();i++)
+	{
+		const btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
+
+		//PCK: unsigned instead of bool
+		unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);
+		if (overlap != 0)
+		{
+			walkStacklessQuantizedTree(nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax,
+				subtree.m_rootNodeIndex,
+				subtree.m_rootNodeIndex+subtree.m_subtreeSize);
+		}
+	}
+}
+
+
+void	btQuantizedBvh::reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const
+{
+	bool fast_path = m_useQuantization && m_traversalMode == TRAVERSAL_STACKLESS;
+	if (fast_path)
+	{
+		walkStacklessQuantizedTreeAgainstRay(nodeCallback, raySource, rayTarget, btVector3(0, 0, 0), btVector3(0, 0, 0), 0, m_curNodeIndex);
+	} else {
+		/* Otherwise fallback to AABB overlap test */
+		btVector3 aabbMin = raySource;
+		btVector3 aabbMax = raySource;
+		aabbMin.setMin(rayTarget);
+		aabbMax.setMax(rayTarget);
+		reportAabbOverlappingNodex(nodeCallback,aabbMin,aabbMax);
+	}
+}
+
+
+void	btQuantizedBvh::reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	bool fast_path = m_useQuantization && m_traversalMode == TRAVERSAL_STACKLESS;
+	if (fast_path)
+	{
+		walkStacklessQuantizedTreeAgainstRay(nodeCallback, raySource, rayTarget, aabbMin, aabbMax, 0, m_curNodeIndex);
+	} else {
+		/* Slow path:
+		   Construct the bounding box for the entire box cast and send that down the tree */
+		btVector3 qaabbMin = raySource;
+		btVector3 qaabbMax = raySource;
+		qaabbMin.setMin(rayTarget);
+		qaabbMax.setMax(rayTarget);
+		qaabbMin += aabbMin;
+		qaabbMax += aabbMax;
+		reportAabbOverlappingNodex(nodeCallback,qaabbMin,qaabbMax);
+	}
+}
+
+
+void	btQuantizedBvh::swapLeafNodes(int i,int splitIndex)
+{
+	if (m_useQuantization)
+	{
+			btQuantizedBvhNode tmp = m_quantizedLeafNodes[i];
+			m_quantizedLeafNodes[i] = m_quantizedLeafNodes[splitIndex];
+			m_quantizedLeafNodes[splitIndex] = tmp;
+	} else
+	{
+			btOptimizedBvhNode tmp = m_leafNodes[i];
+			m_leafNodes[i] = m_leafNodes[splitIndex];
+			m_leafNodes[splitIndex] = tmp;
+	}
+}
+
+void	btQuantizedBvh::assignInternalNodeFromLeafNode(int internalNode,int leafNodeIndex)
+{
+	if (m_useQuantization)
+	{
+		m_quantizedContiguousNodes[internalNode] = m_quantizedLeafNodes[leafNodeIndex];
+	} else
+	{
+		m_contiguousNodes[internalNode] = m_leafNodes[leafNodeIndex];
+	}
+}
+
+//PCK: include
+#include <new>
+
+//PCK: consts
+static const unsigned BVH_ALIGNMENT = 16;
+static const unsigned BVH_ALIGNMENT_MASK = BVH_ALIGNMENT-1;
+
+static const unsigned BVH_ALIGNMENT_BLOCKS = 2;
+
+
+
+unsigned int btQuantizedBvh::getAlignmentSerializationPadding()
+{
+	// I changed this to 0 since the extra padding is not needed or used.
+	return 0;//BVH_ALIGNMENT_BLOCKS * BVH_ALIGNMENT;
+}
+
+unsigned btQuantizedBvh::calculateSerializeBufferSize()
+{
+	unsigned baseSize = sizeof(btQuantizedBvh) + getAlignmentSerializationPadding();
+	baseSize += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount;
+	if (m_useQuantization)
+	{
+		return baseSize + m_curNodeIndex * sizeof(btQuantizedBvhNode);
+	}
+	return baseSize + m_curNodeIndex * sizeof(btOptimizedBvhNode);
+}
+
+bool btQuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBufferSize */, bool i_swapEndian)
+{
+	assert(m_subtreeHeaderCount == m_SubtreeHeaders.size());
+	m_subtreeHeaderCount = m_SubtreeHeaders.size();
+
+/*	if (i_dataBufferSize < calculateSerializeBufferSize() || o_alignedDataBuffer == NULL || (((unsigned)o_alignedDataBuffer & BVH_ALIGNMENT_MASK) != 0))
+	{
+		///check alignedment for buffer?
+		btAssert(0);
+		return false;
+	}
+*/
+
+	btQuantizedBvh *targetBvh = (btQuantizedBvh *)o_alignedDataBuffer;
+
+	// construct the class so the virtual function table, etc will be set up
+	// Also, m_leafNodes and m_quantizedLeafNodes will be initialized to default values by the constructor
+	new (targetBvh) btQuantizedBvh;
+
+	if (i_swapEndian)
+	{
+		targetBvh->m_curNodeIndex = static_cast<int>(btSwapEndian(m_curNodeIndex));
+
+
+		btSwapVector3Endian(m_bvhAabbMin,targetBvh->m_bvhAabbMin);
+		btSwapVector3Endian(m_bvhAabbMax,targetBvh->m_bvhAabbMax);
+		btSwapVector3Endian(m_bvhQuantization,targetBvh->m_bvhQuantization);
+
+		targetBvh->m_traversalMode = (btTraversalMode)btSwapEndian(m_traversalMode);
+		targetBvh->m_subtreeHeaderCount = static_cast<int>(btSwapEndian(m_subtreeHeaderCount));
+	}
+	else
+	{
+		targetBvh->m_curNodeIndex = m_curNodeIndex;
+		targetBvh->m_bvhAabbMin = m_bvhAabbMin;
+		targetBvh->m_bvhAabbMax = m_bvhAabbMax;
+		targetBvh->m_bvhQuantization = m_bvhQuantization;
+		targetBvh->m_traversalMode = m_traversalMode;
+		targetBvh->m_subtreeHeaderCount = m_subtreeHeaderCount;
+	}
+
+	targetBvh->m_useQuantization = m_useQuantization;
+
+	unsigned char *nodeData = (unsigned char *)targetBvh;
+	nodeData += sizeof(btQuantizedBvh);
+	
+	unsigned sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK;
+	nodeData += sizeToAdd;
+	
+	int nodeCount = m_curNodeIndex;
+
+	if (m_useQuantization)
+	{
+		targetBvh->m_quantizedContiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount);
+
+		if (i_swapEndian)
+		{
+			for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
+			{
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
+
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
+
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
+			}
+		}
+		else
+		{
+			for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
+			{
+	
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0];
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1];
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2];
+
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0];
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1];
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2];
+
+				targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex;
+
+
+			}
+		}
+		nodeData += sizeof(btQuantizedBvhNode) * nodeCount;
+
+		// this clears the pointer in the member variable it doesn't really do anything to the data
+		// it does call the destructor on the contained objects, but they are all classes with no destructor defined
+		// so the memory (which is not freed) is left alone
+		targetBvh->m_quantizedContiguousNodes.initializeFromBuffer(NULL, 0, 0);
+	}
+	else
+	{
+		targetBvh->m_contiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount);
+
+		if (i_swapEndian)
+		{
+			for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
+			{
+				btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMinOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
+				btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMaxOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
+
+				targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex));
+				targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_subPart));
+				targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_triangleIndex));
+			}
+		}
+		else
+		{
+			for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
+			{
+				targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg = m_contiguousNodes[nodeIndex].m_aabbMinOrg;
+				targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg = m_contiguousNodes[nodeIndex].m_aabbMaxOrg;
+
+				targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = m_contiguousNodes[nodeIndex].m_escapeIndex;
+				targetBvh->m_contiguousNodes[nodeIndex].m_subPart = m_contiguousNodes[nodeIndex].m_subPart;
+				targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = m_contiguousNodes[nodeIndex].m_triangleIndex;
+			}
+		}
+		nodeData += sizeof(btOptimizedBvhNode) * nodeCount;
+
+		// this clears the pointer in the member variable it doesn't really do anything to the data
+		// it does call the destructor on the contained objects, but they are all classes with no destructor defined
+		// so the memory (which is not freed) is left alone
+		targetBvh->m_contiguousNodes.initializeFromBuffer(NULL, 0, 0);
+	}
+
+	sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK;
+	nodeData += sizeToAdd;
+
+	// Now serialize the subtree headers
+	targetBvh->m_SubtreeHeaders.initializeFromBuffer(nodeData, m_subtreeHeaderCount, m_subtreeHeaderCount);
+	if (i_swapEndian)
+	{
+		for (int i = 0; i < m_subtreeHeaderCount; i++)
+		{
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
+
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
+
+			targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(btSwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex));
+			targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(btSwapEndian(m_SubtreeHeaders[i].m_subtreeSize));
+		}
+	}
+	else
+	{
+		for (int i = 0; i < m_subtreeHeaderCount; i++)
+		{
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = (m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = (m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = (m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
+
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = (m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = (m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
+			targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = (m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
+
+			targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = (m_SubtreeHeaders[i].m_rootNodeIndex);
+			targetBvh->m_SubtreeHeaders[i].m_subtreeSize = (m_SubtreeHeaders[i].m_subtreeSize);
+
+			// need to clear padding in destination buffer
+			targetBvh->m_SubtreeHeaders[i].m_padding[0] = 0;
+			targetBvh->m_SubtreeHeaders[i].m_padding[1] = 0;
+			targetBvh->m_SubtreeHeaders[i].m_padding[2] = 0;
+		}
+	}
+	nodeData += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount;
+
+	// this clears the pointer in the member variable it doesn't really do anything to the data
+	// it does call the destructor on the contained objects, but they are all classes with no destructor defined
+	// so the memory (which is not freed) is left alone
+	targetBvh->m_SubtreeHeaders.initializeFromBuffer(NULL, 0, 0);
+
+	// this wipes the virtual function table pointer at the start of the buffer for the class
+	*((void**)o_alignedDataBuffer) = NULL;
+
+	return true;
+}
+
+btQuantizedBvh *btQuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian)
+{
+
+	if (i_alignedDataBuffer == NULL)// || (((unsigned)i_alignedDataBuffer & BVH_ALIGNMENT_MASK) != 0))
+	{
+		return NULL;
+	}
+	btQuantizedBvh *bvh = (btQuantizedBvh *)i_alignedDataBuffer;
+
+	if (i_swapEndian)
+	{
+		bvh->m_curNodeIndex = static_cast<int>(btSwapEndian(bvh->m_curNodeIndex));
+
+		btUnSwapVector3Endian(bvh->m_bvhAabbMin);
+		btUnSwapVector3Endian(bvh->m_bvhAabbMax);
+		btUnSwapVector3Endian(bvh->m_bvhQuantization);
+
+		bvh->m_traversalMode = (btTraversalMode)btSwapEndian(bvh->m_traversalMode);
+		bvh->m_subtreeHeaderCount = static_cast<int>(btSwapEndian(bvh->m_subtreeHeaderCount));
+	}
+
+	unsigned int calculatedBufSize = bvh->calculateSerializeBufferSize();
+	btAssert(calculatedBufSize <= i_dataBufferSize);
+
+	if (calculatedBufSize > i_dataBufferSize)
+	{
+		return NULL;
+	}
+
+	unsigned char *nodeData = (unsigned char *)bvh;
+	nodeData += sizeof(btQuantizedBvh);
+	
+	unsigned sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK;
+	nodeData += sizeToAdd;
+	
+	int nodeCount = bvh->m_curNodeIndex;
+
+	// Must call placement new to fill in virtual function table, etc, but we don't want to overwrite most data, so call a special version of the constructor
+	// Also, m_leafNodes and m_quantizedLeafNodes will be initialized to default values by the constructor
+	new (bvh) btQuantizedBvh(*bvh, false);
+
+	if (bvh->m_useQuantization)
+	{
+		bvh->m_quantizedContiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount);
+
+		if (i_swapEndian)
+		{
+			for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
+			{
+				bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
+				bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
+				bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
+
+				bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
+				bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
+				bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
+
+				bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
+			}
+		}
+		nodeData += sizeof(btQuantizedBvhNode) * nodeCount;
+	}
+	else
+	{
+		bvh->m_contiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount);
+
+		if (i_swapEndian)
+		{
+			for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
+			{
+				btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
+				btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
+				
+				bvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex));
+				bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart));
+				bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_triangleIndex));
+			}
+		}
+		nodeData += sizeof(btOptimizedBvhNode) * nodeCount;
+	}
+
+	sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK;
+	nodeData += sizeToAdd;
+
+	// Now serialize the subtree headers
+	bvh->m_SubtreeHeaders.initializeFromBuffer(nodeData, bvh->m_subtreeHeaderCount, bvh->m_subtreeHeaderCount);
+	if (i_swapEndian)
+	{
+		for (int i = 0; i < bvh->m_subtreeHeaderCount; i++)
+		{
+			bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
+			bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
+			bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
+
+			bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
+			bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
+			bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
+
+			bvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(btSwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex));
+			bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(btSwapEndian(bvh->m_SubtreeHeaders[i].m_subtreeSize));
+		}
+	}
+
+	return bvh;
+}
+
+// Constructor that prevents btVector3's default constructor from being called
+btQuantizedBvh::btQuantizedBvh(btQuantizedBvh &self, bool /* ownsMemory */) :
+m_bvhAabbMin(self.m_bvhAabbMin),
+m_bvhAabbMax(self.m_bvhAabbMax),
+m_bvhQuantization(self.m_bvhQuantization)
+{
+
+
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h	(revision 2122)
@@ -0,0 +1,486 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef QUANTIZED_BVH_H
+#define QUANTIZED_BVH_H
+
+//#define DEBUG_CHECK_DEQUANTIZATION 1
+#ifdef DEBUG_CHECK_DEQUANTIZATION
+#ifdef __SPU__
+#define printf spu_printf
+#endif //__SPU__
+
+#include <stdio.h>
+#include <stdlib.h>
+#endif //DEBUG_CHECK_DEQUANTIZATION
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btAlignedAllocator.h"
+
+
+//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf__m128.asp
+
+
+//Note: currently we have 16 bytes per quantized node
+#define MAX_SUBTREE_SIZE_IN_BYTES  2048
+
+// 10 gives the potential for 1024 parts, with at most 2^21 (2097152) (minus one
+// actually) triangles each (since the sign bit is reserved
+#define MAX_NUM_PARTS_IN_BITS 10
+
+///btQuantizedBvhNode is a compressed aabb node, 16 bytes.
+///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
+ATTRIBUTE_ALIGNED16	(struct) btQuantizedBvhNode
+{
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	//12 bytes
+	unsigned short int	m_quantizedAabbMin[3];
+	unsigned short int	m_quantizedAabbMax[3];
+	//4 bytes
+	int	m_escapeIndexOrTriangleIndex;
+
+	bool isLeafNode() const
+	{
+		//skipindex is negative (internal node), triangleindex >=0 (leafnode)
+		return (m_escapeIndexOrTriangleIndex >= 0);
+	}
+	int getEscapeIndex() const
+	{
+		btAssert(!isLeafNode());
+		return -m_escapeIndexOrTriangleIndex;
+	}
+	int	getTriangleIndex() const
+	{
+		btAssert(isLeafNode());
+		// Get only the lower bits where the triangle index is stored
+		return (m_escapeIndexOrTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS)));
+	}
+	int	getPartId() const
+	{
+		btAssert(isLeafNode());
+		// Get only the highest bits where the part index is stored
+		return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));
+	}
+}
+;
+
+/// btOptimizedBvhNode contains both internal and leaf node information.
+/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
+ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
+{
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	//32 bytes
+	btVector3	m_aabbMinOrg;
+	btVector3	m_aabbMaxOrg;
+
+	//4
+	int	m_escapeIndex;
+
+	//8
+	//for child nodes
+	int	m_subPart;
+	int	m_triangleIndex;
+	int	m_padding[5];//bad, due to alignment
+
+
+};
+
+
+///btBvhSubtreeInfo provides info to gather a subtree of limited size
+ATTRIBUTE_ALIGNED16(class) btBvhSubtreeInfo
+{
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	//12 bytes
+	unsigned short int	m_quantizedAabbMin[3];
+	unsigned short int	m_quantizedAabbMax[3];
+	//4 bytes, points to the root of the subtree
+	int			m_rootNodeIndex;
+	//4 bytes
+	int			m_subtreeSize;
+	int			m_padding[3];
+
+	btBvhSubtreeInfo()
+	{
+		//memset(&m_padding[0], 0, sizeof(m_padding));
+	}
+
+
+	void	setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode)
+	{
+		m_quantizedAabbMin[0] = quantizedNode.m_quantizedAabbMin[0];
+		m_quantizedAabbMin[1] = quantizedNode.m_quantizedAabbMin[1];
+		m_quantizedAabbMin[2] = quantizedNode.m_quantizedAabbMin[2];
+		m_quantizedAabbMax[0] = quantizedNode.m_quantizedAabbMax[0];
+		m_quantizedAabbMax[1] = quantizedNode.m_quantizedAabbMax[1];
+		m_quantizedAabbMax[2] = quantizedNode.m_quantizedAabbMax[2];
+	}
+}
+;
+
+
+class btNodeOverlapCallback
+{
+public:
+	virtual ~btNodeOverlapCallback() {};
+
+	virtual void processNode(int subPart, int triangleIndex) = 0;
+};
+
+#include "LinearMath/btAlignedAllocator.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+
+
+///for code readability:
+typedef btAlignedObjectArray<btOptimizedBvhNode>	NodeArray;
+typedef btAlignedObjectArray<btQuantizedBvhNode>	QuantizedNodeArray;
+typedef btAlignedObjectArray<btBvhSubtreeInfo>		BvhSubtreeInfoArray;
+
+
+///The btQuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
+///It is used by the btBvhTriangleMeshShape as midphase, and by the btMultiSapBroadphase.
+///It is recommended to use quantization for better performance and lower memory requirements.
+ATTRIBUTE_ALIGNED16(class) btQuantizedBvh
+{
+protected:
+
+	NodeArray			m_leafNodes;
+	NodeArray			m_contiguousNodes;
+
+	QuantizedNodeArray	m_quantizedLeafNodes;
+	
+	QuantizedNodeArray	m_quantizedContiguousNodes;
+	
+	int					m_curNodeIndex;
+
+
+	//quantization data
+	bool				m_useQuantization;
+	btVector3			m_bvhAabbMin;
+	btVector3			m_bvhAabbMax;
+	btVector3			m_bvhQuantization;
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	enum btTraversalMode
+	{
+		TRAVERSAL_STACKLESS = 0,
+		TRAVERSAL_STACKLESS_CACHE_FRIENDLY,
+		TRAVERSAL_RECURSIVE
+	};
+protected:
+
+	btTraversalMode	m_traversalMode;
+	
+	BvhSubtreeInfoArray		m_SubtreeHeaders;
+
+	//This is only used for serialization so we don't have to add serialization directly to btAlignedObjectArray
+	int m_subtreeHeaderCount;
+
+
+	///two versions, one for quantized and normal nodes. This allows code-reuse while maintaining readability (no template/macro!)
+	///this might be refactored into a virtual, it is usually not calculated at run-time
+	void	setInternalNodeAabbMin(int nodeIndex, const btVector3& aabbMin)
+	{
+		if (m_useQuantization)
+		{
+			quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] ,aabbMin,0);
+		} else
+		{
+			m_contiguousNodes[nodeIndex].m_aabbMinOrg = aabbMin;
+
+		}
+	}
+	void	setInternalNodeAabbMax(int nodeIndex,const btVector3& aabbMax)
+	{
+		if (m_useQuantization)
+		{
+			quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0],aabbMax,1);
+		} else
+		{
+			m_contiguousNodes[nodeIndex].m_aabbMaxOrg = aabbMax;
+		}
+	}
+
+	btVector3 getAabbMin(int nodeIndex) const
+	{
+		if (m_useQuantization)
+		{
+			return unQuantize(&m_quantizedLeafNodes[nodeIndex].m_quantizedAabbMin[0]);
+		}
+		//non-quantized
+		return m_leafNodes[nodeIndex].m_aabbMinOrg;
+
+	}
+	btVector3 getAabbMax(int nodeIndex) const
+	{
+		if (m_useQuantization)
+		{
+			return unQuantize(&m_quantizedLeafNodes[nodeIndex].m_quantizedAabbMax[0]);
+		} 
+		//non-quantized
+		return m_leafNodes[nodeIndex].m_aabbMaxOrg;
+		
+	}
+
+	
+	void	setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex)
+	{
+		if (m_useQuantization)
+		{
+			m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = -escapeIndex;
+		} 
+		else
+		{
+			m_contiguousNodes[nodeIndex].m_escapeIndex = escapeIndex;
+		}
+
+	}
+
+	void mergeInternalNodeAabb(int nodeIndex,const btVector3& newAabbMin,const btVector3& newAabbMax) 
+	{
+		if (m_useQuantization)
+		{
+			unsigned short int quantizedAabbMin[3];
+			unsigned short int quantizedAabbMax[3];
+			quantize(quantizedAabbMin,newAabbMin,0);
+			quantize(quantizedAabbMax,newAabbMax,1);
+			for (int i=0;i<3;i++)
+			{
+				if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] > quantizedAabbMin[i])
+					m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] = quantizedAabbMin[i];
+
+				if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] < quantizedAabbMax[i])
+					m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] = quantizedAabbMax[i];
+
+			}
+		} else
+		{
+			//non-quantized
+			m_contiguousNodes[nodeIndex].m_aabbMinOrg.setMin(newAabbMin);
+			m_contiguousNodes[nodeIndex].m_aabbMaxOrg.setMax(newAabbMax);		
+		}
+	}
+
+	void	swapLeafNodes(int firstIndex,int secondIndex);
+
+	void	assignInternalNodeFromLeafNode(int internalNode,int leafNodeIndex);
+
+protected:
+
+	
+
+	void	buildTree	(int startIndex,int endIndex);
+
+	int	calcSplittingAxis(int startIndex,int endIndex);
+
+	int	sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis);
+	
+	void	walkStacklessTree(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+	void	walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
+	void	walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const;
+
+	///tree traversal designed for small-memory processors like PS3 SPU
+	void	walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
+
+	///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
+	void	walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
+
+	///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
+	void	walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode* treeNodeA,const btQuantizedBvhNode* treeNodeB,btNodeOverlapCallback* nodeCallback) const;
+	
+
+#define USE_BANCHLESS 1
+#ifdef USE_BANCHLESS
+	//This block replaces the block below and uses no branches, and replaces the 8 bit return with a 32 bit return for improved performance (~3x on XBox 360)
+	SIMD_FORCE_INLINE unsigned testQuantizedAabbAgainstQuantizedAabb(unsigned short int* aabbMin1,unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) const
+	{		
+		return static_cast<unsigned int>(btSelect((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0])
+			& (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2])
+			& (aabbMin1[1] <= aabbMax2[1]) & (aabbMax1[1] >= aabbMin2[1])),
+			1, 0));
+	}
+#else
+	SIMD_FORCE_INLINE bool testQuantizedAabbAgainstQuantizedAabb(unsigned short int* aabbMin1,unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) const
+	{
+		bool overlap = true;
+		overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
+		overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap;
+		overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap;
+		return overlap;
+	}
+#endif //USE_BANCHLESS
+
+	void	updateSubtreeHeaders(int leftChildNodexIndex,int rightChildNodexIndex);
+
+public:
+	btQuantizedBvh();
+
+	virtual ~btQuantizedBvh();
+
+	
+	///***************************************** expert/internal use only *************************
+	void	setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.0));
+	QuantizedNodeArray&	getLeafNodeArray() {			return	m_quantizedLeafNodes;	}
+	///buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialized
+	void	buildInternal();
+	///***************************************** expert/internal use only *************************
+
+	void	reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+	void	reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const;
+	void	reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+		SIMD_FORCE_INLINE void quantize(unsigned short* out, const btVector3& point,int isMax) const
+	{
+
+		btAssert(m_useQuantization);
+
+		btAssert(point.getX() <= m_bvhAabbMax.getX());
+		btAssert(point.getY() <= m_bvhAabbMax.getY());
+		btAssert(point.getZ() <= m_bvhAabbMax.getZ());
+
+		btAssert(point.getX() >= m_bvhAabbMin.getX());
+		btAssert(point.getY() >= m_bvhAabbMin.getY());
+		btAssert(point.getZ() >= m_bvhAabbMin.getZ());
+
+		btVector3 v = (point - m_bvhAabbMin) * m_bvhQuantization;
+		///Make sure rounding is done in a way that unQuantize(quantizeWithClamp(...)) is conservative
+		///end-points always set the first bit, so that they are sorted properly (so that neighbouring AABBs overlap properly)
+		///todo: double-check this
+		if (isMax)
+		{
+			out[0] = (unsigned short) (((unsigned short)(v.getX()+btScalar(1.)) | 1));
+			out[1] = (unsigned short) (((unsigned short)(v.getY()+btScalar(1.)) | 1));
+			out[2] = (unsigned short) (((unsigned short)(v.getZ()+btScalar(1.)) | 1));
+		} else
+		{
+			out[0] = (unsigned short) (((unsigned short)(v.getX()) & 0xfffe));
+			out[1] = (unsigned short) (((unsigned short)(v.getY()) & 0xfffe));
+			out[2] = (unsigned short) (((unsigned short)(v.getZ()) & 0xfffe));
+		}
+
+
+#ifdef DEBUG_CHECK_DEQUANTIZATION
+		btVector3 newPoint = unQuantize(out);
+		if (isMax)
+		{
+			if (newPoint.getX() < point.getX())
+			{
+				printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n",newPoint.getX()-point.getX(), newPoint.getX(),point.getX());
+			}
+			if (newPoint.getY() < point.getY())
+			{
+				printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n",newPoint.getY()-point.getY(), newPoint.getY(),point.getY());
+			}
+			if (newPoint.getZ() < point.getZ())
+			{
+
+				printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n",newPoint.getZ()-point.getZ(), newPoint.getZ(),point.getZ());
+			}
+		} else
+		{
+			if (newPoint.getX() > point.getX())
+			{
+				printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n",newPoint.getX()-point.getX(), newPoint.getX(),point.getX());
+			}
+			if (newPoint.getY() > point.getY())
+			{
+				printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n",newPoint.getY()-point.getY(), newPoint.getY(),point.getY());
+			}
+			if (newPoint.getZ() > point.getZ())
+			{
+				printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n",newPoint.getZ()-point.getZ(), newPoint.getZ(),point.getZ());
+			}
+		}
+#endif //DEBUG_CHECK_DEQUANTIZATION
+
+	}
+
+
+	SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point2,int isMax) const
+	{
+
+		btAssert(m_useQuantization);
+
+		btVector3 clampedPoint(point2);
+		clampedPoint.setMax(m_bvhAabbMin);
+		clampedPoint.setMin(m_bvhAabbMax);
+
+		quantize(out,clampedPoint,isMax);
+
+	}
+	
+	SIMD_FORCE_INLINE btVector3	unQuantize(const unsigned short* vecIn) const
+	{
+			btVector3	vecOut;
+			vecOut.setValue(
+			(btScalar)(vecIn[0]) / (m_bvhQuantization.getX()),
+			(btScalar)(vecIn[1]) / (m_bvhQuantization.getY()),
+			(btScalar)(vecIn[2]) / (m_bvhQuantization.getZ()));
+			vecOut += m_bvhAabbMin;
+			return vecOut;
+	}
+
+	///setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees.
+	void	setTraversalMode(btTraversalMode	traversalMode)
+	{
+		m_traversalMode = traversalMode;
+	}
+
+
+	SIMD_FORCE_INLINE QuantizedNodeArray&	getQuantizedNodeArray()
+	{	
+		return	m_quantizedContiguousNodes;
+	}
+
+
+	SIMD_FORCE_INLINE BvhSubtreeInfoArray&	getSubtreeInfoArray()
+	{
+		return m_SubtreeHeaders;
+	}
+
+
+	/////Calculate space needed to store BVH for serialization
+	unsigned calculateSerializeBufferSize();
+
+	/// Data buffer MUST be 16 byte aligned
+	virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian);
+
+	///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
+	static btQuantizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian);
+
+	static unsigned int getAlignmentSerializationPadding();
+
+	SIMD_FORCE_INLINE bool isQuantized()
+	{
+		return m_useQuantization;
+	}
+
+private:
+	// Special "copy" constructor that allows for in-place deserialization
+	// Prevents btVector3's default constructor from being called, but doesn't inialize much else
+	// ownsMemory should most likely be false if deserializing, and if you are not, don't call this (it also changes the function signature, which we need)
+	btQuantizedBvh(btQuantizedBvh &other, bool ownsMemory);
+
+}
+;
+
+
+#endif //QUANTIZED_BVH_H
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp	(revision 2122)
@@ -0,0 +1,300 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSimpleBroadphase.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btMatrix3x3.h"
+#include <new>
+
+extern int gOverlappingPairs;
+
+void	btSimpleBroadphase::validate()
+{
+	for (int i=0;i<m_numHandles;i++)
+	{
+		for (int j=i+1;j<m_numHandles;j++)
+		{
+			btAssert(&m_pHandles[i] != &m_pHandles[j]);
+		}
+	}
+	
+}
+
+btSimpleBroadphase::btSimpleBroadphase(int maxProxies, btOverlappingPairCache* overlappingPairCache)
+	:m_pairCache(overlappingPairCache),
+	m_ownsPairCache(false),
+	m_invalidPair(0)
+{
+
+	if (!overlappingPairCache)
+	{
+		void* mem = btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16);
+		m_pairCache = new (mem)btHashedOverlappingPairCache();
+		m_ownsPairCache = true;
+	}
+
+	// allocate handles buffer and put all handles on free list
+	m_pHandlesRawPtr = btAlignedAlloc(sizeof(btSimpleBroadphaseProxy)*maxProxies,16);
+	m_pHandles = new(m_pHandlesRawPtr) btSimpleBroadphaseProxy[maxProxies];
+	m_maxHandles = maxProxies;
+	m_numHandles = 0;
+	m_firstFreeHandle = 0;
+	
+
+	{
+		for (int i = m_firstFreeHandle; i < maxProxies; i++)
+		{
+			m_pHandles[i].SetNextFree(i + 1);
+			m_pHandles[i].m_uniqueId = i+2;//any UID will do, we just avoid too trivial values (0,1) for debugging purposes
+		}
+		m_pHandles[maxProxies - 1].SetNextFree(0);
+	
+	}
+
+}
+
+btSimpleBroadphase::~btSimpleBroadphase()
+{
+	btAlignedFree(m_pHandlesRawPtr);
+
+	if (m_ownsPairCache)
+	{
+		m_pairCache->~btOverlappingPairCache();
+		btAlignedFree(m_pairCache);
+	}
+}
+
+
+btBroadphaseProxy*	btSimpleBroadphase::createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* /*dispatcher*/,void* multiSapProxy)
+{
+	if (m_numHandles >= m_maxHandles)
+	{
+		btAssert(0);
+		return 0; //should never happen, but don't let the game crash ;-)
+	}
+	assert(aabbMin[0]<= aabbMax[0] && aabbMin[1]<= aabbMax[1] && aabbMin[2]<= aabbMax[2]);
+
+	int newHandleIndex = allocHandle();
+	btSimpleBroadphaseProxy* proxy = new (&m_pHandles[newHandleIndex])btSimpleBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy);
+
+	return proxy;
+}
+
+class	RemovingOverlapCallback : public btOverlapCallback
+{
+protected:
+	virtual bool	processOverlap(btBroadphasePair& pair)
+	{
+		(void)pair;
+		btAssert(0);
+		return false;
+	}
+};
+
+class RemovePairContainingProxy
+{
+
+	btBroadphaseProxy*	m_targetProxy;
+	public:
+	virtual ~RemovePairContainingProxy()
+	{
+	}
+protected:
+	virtual bool processOverlap(btBroadphasePair& pair)
+	{
+		btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0);
+		btSimpleBroadphaseProxy* proxy1 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1);
+
+		return ((m_targetProxy == proxy0 || m_targetProxy == proxy1));
+	};
+};
+
+void	btSimpleBroadphase::destroyProxy(btBroadphaseProxy* proxyOrg,btDispatcher* dispatcher)
+{
+		
+		btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxyOrg);
+		freeHandle(proxy0);
+
+		m_pairCache->removeOverlappingPairsContainingProxy(proxyOrg,dispatcher);
+
+		//validate();
+		
+}
+
+void	btSimpleBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* /*dispatcher*/)
+{
+	btSimpleBroadphaseProxy* sbp = getSimpleProxyFromProxy(proxy);
+	sbp->m_min = aabbMin;
+	sbp->m_max = aabbMax;
+}
+
+
+
+
+
+	
+
+
+
+bool	btSimpleBroadphase::aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1)
+{
+	return proxy0->m_min[0] <= proxy1->m_max[0] && proxy1->m_min[0] <= proxy0->m_max[0] && 
+		   proxy0->m_min[1] <= proxy1->m_max[1] && proxy1->m_min[1] <= proxy0->m_max[1] &&
+		   proxy0->m_min[2] <= proxy1->m_max[2] && proxy1->m_min[2] <= proxy0->m_max[2];
+
+}
+
+
+
+//then remove non-overlapping ones
+class CheckOverlapCallback : public btOverlapCallback
+{
+public:
+	virtual bool processOverlap(btBroadphasePair& pair)
+	{
+		return (!btSimpleBroadphase::aabbOverlap(static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0),static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1)));
+	}
+};
+
+void	btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
+{
+	//first check for new overlapping pairs
+	int i,j;
+
+	if (m_numHandles >= 0)
+	{
+
+		for (i=0;i<m_numHandles;i++)
+		{
+			btSimpleBroadphaseProxy* proxy0 = &m_pHandles[i];
+
+			for (j=i+1;j<m_numHandles;j++)
+			{
+				btSimpleBroadphaseProxy* proxy1 = &m_pHandles[j];
+				btAssert(proxy0 != proxy1);
+
+				btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0);
+				btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1);
+
+				if (aabbOverlap(p0,p1))
+				{
+					if ( !m_pairCache->findPair(proxy0,proxy1))
+					{
+						m_pairCache->addOverlappingPair(proxy0,proxy1);
+					}
+				} else
+				{
+					if (!m_pairCache->hasDeferredRemoval())
+					{
+						if ( m_pairCache->findPair(proxy0,proxy1))
+						{
+							m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher);
+						}
+					}
+				}
+			}
+		}
+
+		if (m_ownsPairCache && m_pairCache->hasDeferredRemoval())
+		{
+
+			btBroadphasePairArray&	overlappingPairArray = m_pairCache->getOverlappingPairArray();
+
+			//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
+			overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
+
+			overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
+			m_invalidPair = 0;
+
+
+			btBroadphasePair previousPair;
+			previousPair.m_pProxy0 = 0;
+			previousPair.m_pProxy1 = 0;
+			previousPair.m_algorithm = 0;
+
+
+			for (i=0;i<overlappingPairArray.size();i++)
+			{
+
+				btBroadphasePair& pair = overlappingPairArray[i];
+
+				bool isDuplicate = (pair == previousPair);
+
+				previousPair = pair;
+
+				bool needsRemoval = false;
+
+				if (!isDuplicate)
+				{
+					bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
+
+					if (hasOverlap)
+					{
+						needsRemoval = false;//callback->processOverlap(pair);
+					} else
+					{
+						needsRemoval = true;
+					}
+				} else
+				{
+					//remove duplicate
+					needsRemoval = true;
+					//should have no algorithm
+					btAssert(!pair.m_algorithm);
+				}
+
+				if (needsRemoval)
+				{
+					m_pairCache->cleanOverlappingPair(pair,dispatcher);
+
+					//		m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
+					//		m_overlappingPairArray.pop_back();
+					pair.m_pProxy0 = 0;
+					pair.m_pProxy1 = 0;
+					m_invalidPair++;
+					gOverlappingPairs--;
+				} 
+
+			}
+
+			///if you don't like to skip the invalid pairs in the array, execute following code:
+#define CLEAN_INVALID_PAIRS 1
+#ifdef CLEAN_INVALID_PAIRS
+
+			//perform a sort, to sort 'invalid' pairs to the end
+			overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
+
+			overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
+			m_invalidPair = 0;
+#endif//CLEAN_INVALID_PAIRS
+
+		}
+	}
+}
+
+
+bool btSimpleBroadphase::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
+{
+	btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0);
+	btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1);
+	return aabbOverlap(p0,p1);
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h	(revision 2122)
@@ -0,0 +1,151 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SIMPLE_BROADPHASE_H
+#define SIMPLE_BROADPHASE_H
+
+
+#include "btOverlappingPairCache.h"
+
+
+struct btSimpleBroadphaseProxy : public btBroadphaseProxy
+{
+	btVector3	m_min;
+	btVector3	m_max;
+	int			m_nextFree;
+	
+//	int			m_handleId;
+
+	
+	btSimpleBroadphaseProxy() {};
+
+	btSimpleBroadphaseProxy(const btPoint3& minpt,const btPoint3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,void* multiSapProxy)
+	:btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy),
+	m_min(minpt),m_max(maxpt)		
+	{
+		(void)shapeType;
+	}
+	
+	
+	SIMD_FORCE_INLINE void SetNextFree(int next) {m_nextFree = next;}
+	SIMD_FORCE_INLINE int GetNextFree() const {return m_nextFree;}
+
+	
+
+
+};
+
+///The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase, so use those classes instead.
+///It is a brute force aabb culling broadphase based on O(n^2) aabb checks
+class btSimpleBroadphase : public btBroadphaseInterface
+{
+
+protected:
+
+	int		m_numHandles;						// number of active handles
+	int		m_maxHandles;						// max number of handles
+	
+	btSimpleBroadphaseProxy* m_pHandles;						// handles pool
+
+	void* m_pHandlesRawPtr;
+	int		m_firstFreeHandle;		// free handles list
+	
+	int allocHandle()
+	{
+		btAssert(m_numHandles < m_maxHandles);
+		int freeHandle = m_firstFreeHandle;
+		m_firstFreeHandle = m_pHandles[freeHandle].GetNextFree();
+		m_numHandles++;
+		return freeHandle;
+	}
+
+	void freeHandle(btSimpleBroadphaseProxy* proxy)
+	{
+		int handle = int(proxy-m_pHandles);
+		btAssert(handle >= 0 && handle < m_maxHandles);
+
+		proxy->SetNextFree(m_firstFreeHandle);
+		m_firstFreeHandle = handle;
+
+		m_numHandles--;
+	}
+
+	btOverlappingPairCache*	m_pairCache;
+	bool	m_ownsPairCache;
+
+	int	m_invalidPair;
+
+	
+	
+	inline btSimpleBroadphaseProxy*	getSimpleProxyFromProxy(btBroadphaseProxy* proxy)
+	{
+		btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy);
+		return proxy0;
+	}
+
+
+	void	validate();
+
+protected:
+
+
+	
+
+public:
+	btSimpleBroadphase(int maxProxies=16384,btOverlappingPairCache* overlappingPairCache=0);
+	virtual ~btSimpleBroadphase();
+
+
+		static bool	aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1);
+
+
+	virtual btBroadphaseProxy*	createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
+
+	virtual void	calculateOverlappingPairs(btDispatcher* dispatcher);
+
+	virtual void	destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
+	virtual void	setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
+		
+	btOverlappingPairCache*	getOverlappingPairCache()
+	{
+		return m_pairCache;
+	}
+	const btOverlappingPairCache*	getOverlappingPairCache() const
+	{
+		return m_pairCache;
+	}
+
+	bool	testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
+
+
+	///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
+	///will add some transform later
+	virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
+	{
+		aabbMin.setValue(-1e30f,-1e30f,-1e30f);
+		aabbMax.setValue(1e30f,1e30f,1e30f);
+	}
+
+	virtual void	printStats()
+	{
+//		printf("btSimpleBroadphase.h\n");
+//		printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
+	}
+};
+
+
+
+#endif //SIMPLE_BROADPHASE_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,150 @@
+ADD_LIBRARY(LibBulletCollision SHARED
+				BroadphaseCollision/btAxisSweep3.cpp
+				BroadphaseCollision/btAxisSweep3.h
+				BroadphaseCollision/btBroadphaseProxy.cpp
+				BroadphaseCollision/btBroadphaseProxy.h
+				BroadphaseCollision/btCollisionAlgorithm.cpp
+				BroadphaseCollision/btCollisionAlgorithm.h
+				BroadphaseCollision/btDispatcher.cpp
+				BroadphaseCollision/btDispatcher.h
+				BroadphaseCollision/btDbvtBroadphase.cpp
+				BroadphaseCollision/btDbvtBroadphase.h
+				BroadphaseCollision/btDbvt.cpp
+				BroadphaseCollision/btDbvt.h
+				BroadphaseCollision/btMultiSapBroadphase.cpp
+				BroadphaseCollision/btMultiSapBroadphase.h
+				BroadphaseCollision/btOverlappingPairCache.cpp
+				BroadphaseCollision/btOverlappingPairCache.h
+				BroadphaseCollision/btOverlappingPairCallback.h
+				BroadphaseCollision/btQuantizedBvh.cpp
+				BroadphaseCollision/btQuantizedBvh.h
+				BroadphaseCollision/btSimpleBroadphase.cpp
+				BroadphaseCollision/btSimpleBroadphase.h
+				CollisionDispatch/btCollisionDispatcher.cpp
+				CollisionDispatch/btCollisionDispatcher.h
+				CollisionDispatch/btCollisionObject.cpp
+				CollisionDispatch/btCollisionObject.h
+				CollisionDispatch/btCollisionWorld.cpp
+				CollisionDispatch/btCollisionWorld.h
+				CollisionDispatch/btCompoundCollisionAlgorithm.cpp
+				CollisionDispatch/btCompoundCollisionAlgorithm.h
+				CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
+				CollisionDispatch/btConvexConcaveCollisionAlgorithm.h
+				CollisionDispatch/btDefaultCollisionConfiguration.cpp
+				CollisionDispatch/btDefaultCollisionConfiguration.h
+				CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp
+				CollisionDispatch/btSphereSphereCollisionAlgorithm.h
+				CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp
+				CollisionDispatch/btBoxBoxCollisionAlgorithm.h
+				CollisionDispatch/btBoxBoxDetector.cpp
+				CollisionDispatch/btBoxBoxDetector.h
+				CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
+				CollisionDispatch/btSphereBoxCollisionAlgorithm.h
+				CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp
+				CollisionDispatch/btConvexPlaneCollisionAlgorithm.h
+				CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
+				CollisionDispatch/btSphereTriangleCollisionAlgorithm.h
+				CollisionDispatch/btConvexConvexAlgorithm.cpp
+				CollisionDispatch/btConvexConvexAlgorithm.h
+				CollisionDispatch/btEmptyCollisionAlgorithm.cpp
+				CollisionDispatch/btEmptyCollisionAlgorithm.h
+				CollisionDispatch/btManifoldResult.cpp
+				CollisionDispatch/btManifoldResult.h
+				CollisionDispatch/btSimulationIslandManager.cpp
+				CollisionDispatch/btSimulationIslandManager.h
+				CollisionDispatch/btUnionFind.cpp
+				CollisionDispatch/btUnionFind.h
+				CollisionDispatch/SphereTriangleDetector.cpp
+				CollisionDispatch/SphereTriangleDetector.h
+				CollisionShapes/btBoxShape.cpp
+				CollisionShapes/btBoxShape.h
+				CollisionShapes/btBvhTriangleMeshShape.cpp
+				CollisionShapes/btBvhTriangleMeshShape.h
+				CollisionShapes/btCapsuleShape.cpp
+				CollisionShapes/btCapsuleShape.h
+				CollisionShapes/btCollisionShape.cpp
+				CollisionShapes/btCollisionShape.h
+				CollisionShapes/btCompoundShape.cpp
+				CollisionShapes/btCompoundShape.h
+				CollisionShapes/btConcaveShape.cpp
+				CollisionShapes/btConcaveShape.h
+				CollisionShapes/btConeShape.cpp
+				CollisionShapes/btConeShape.h
+				CollisionShapes/btConvexHullShape.cpp
+				CollisionShapes/btConvexHullShape.h
+				CollisionShapes/btConvexPointCloudShape.cpp
+				CollisionShapes/btConvexPointCloudShape.h
+				CollisionShapes/btConvexShape.cpp
+				CollisionShapes/btConvexShape.h
+				CollisionShapes/btConvexInternalShape.cpp
+				CollisionShapes/btConvexInternalShape.h
+				CollisionShapes/btConvexTriangleMeshShape.cpp
+				CollisionShapes/btConvexTriangleMeshShape.h
+				CollisionShapes/btCylinderShape.cpp
+				CollisionShapes/btCylinderShape.h
+				CollisionShapes/btEmptyShape.cpp
+				CollisionShapes/btEmptyShape.h
+				CollisionShapes/btHeightfieldTerrainShape.cpp
+				CollisionShapes/btHeightfieldTerrainShape.h
+				CollisionShapes/btMinkowskiSumShape.cpp
+				CollisionShapes/btMinkowskiSumShape.h
+				CollisionShapes/btMaterial.h
+				CollisionShapes/btMultimaterialTriangleMeshShape.cpp
+				CollisionShapes/btMultimaterialTriangleMeshShape.h
+				CollisionShapes/btMultiSphereShape.cpp
+				CollisionShapes/btMultiSphereShape.h
+				CollisionShapes/btOptimizedBvh.cpp
+				CollisionShapes/btOptimizedBvh.h
+				CollisionShapes/btPolyhedralConvexShape.cpp
+				CollisionShapes/btPolyhedralConvexShape.h
+				CollisionShapes/btScaledBvhTriangleMeshShape.cpp
+				CollisionShapes/btScaledBvhTriangleMeshShape.h
+				CollisionShapes/btTetrahedronShape.cpp
+				CollisionShapes/btTetrahedronShape.h
+				CollisionShapes/btSphereShape.cpp
+				CollisionShapes/btSphereShape.h
+				CollisionShapes/btShapeHull.h
+				CollisionShapes/btShapeHull.cpp
+				CollisionShapes/btStaticPlaneShape.cpp
+				CollisionShapes/btStaticPlaneShape.h
+				CollisionShapes/btStridingMeshInterface.cpp
+				CollisionShapes/btStridingMeshInterface.h
+				CollisionShapes/btTriangleCallback.cpp
+				CollisionShapes/btTriangleCallback.h
+				CollisionShapes/btTriangleBuffer.cpp
+				CollisionShapes/btTriangleBuffer.h
+				CollisionShapes/btTriangleIndexVertexArray.cpp
+				CollisionShapes/btTriangleIndexVertexArray.h
+				CollisionShapes/btTriangleIndexVertexMaterialArray.h
+				CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
+				CollisionShapes/btTriangleMesh.cpp
+				CollisionShapes/btTriangleMesh.h
+				CollisionShapes/btTriangleMeshShape.cpp
+				CollisionShapes/btTriangleMeshShape.h
+				CollisionShapes/btUniformScalingShape.cpp
+				CollisionShapes/btUniformScalingShape.h
+				NarrowPhaseCollision/btContinuousConvexCollision.cpp
+				NarrowPhaseCollision/btContinuousConvexCollision.h
+				NarrowPhaseCollision/btGjkEpa.cpp
+				NarrowPhaseCollision/btGjkEpa.h
+				NarrowPhaseCollision/btGjkEpa2.cpp
+				NarrowPhaseCollision/btGjkEpa2.h
+				NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
+				NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
+				NarrowPhaseCollision/btConvexCast.cpp
+				NarrowPhaseCollision/btConvexCast.h
+				NarrowPhaseCollision/btGjkConvexCast.cpp
+				NarrowPhaseCollision/btGjkConvexCast.h
+				NarrowPhaseCollision/btGjkPairDetector.cpp
+				NarrowPhaseCollision/btGjkPairDetector.h
+				NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
+				NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
+				NarrowPhaseCollision/btPersistentManifold.cpp
+				NarrowPhaseCollision/btPersistentManifold.h
+				NarrowPhaseCollision/btRaycastCallback.cpp
+				NarrowPhaseCollision/btRaycastCallback.h
+				NarrowPhaseCollision/btSubSimplexConvexCast.cpp
+				NarrowPhaseCollision/btSubSimplexConvexCast.h
+				NarrowPhaseCollision/btVoronoiSimplexSolver.cpp
+				NarrowPhaseCollision/btVoronoiSimplexSolver.h
+)
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp	(revision 2122)
@@ -0,0 +1,211 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "LinearMath/btScalar.h"
+#include "SphereTriangleDetector.h"
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+
+
+SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle)
+:m_sphere(sphere),
+m_triangle(triangle)
+{
+
+}
+
+void	SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults)
+{
+
+	(void)debugDraw;
+	const btTransform& transformA = input.m_transformA;
+	const btTransform& transformB = input.m_transformB;
+
+	btVector3 point,normal;
+	btScalar timeOfImpact = btScalar(1.);
+	btScalar depth = btScalar(0.);
+//	output.m_distance = btScalar(1e30);
+	//move sphere into triangle space
+	btTransform	sphereInTr = transformB.inverseTimes(transformA);
+
+	if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact))
+	{
+		if (swapResults)
+		{
+			btVector3 normalOnB = transformB.getBasis()*normal;
+			btVector3 normalOnA = -normalOnB;
+			btVector3 pointOnA = transformB*point+normalOnB*depth;
+			output.addContactPoint(normalOnA,pointOnA,depth);
+		} else
+		{
+			output.addContactPoint(transformB.getBasis()*normal,transformB*point,depth);
+		}
+	}
+
+}
+
+#define MAX_OVERLAP btScalar(0.)
+
+
+
+// See also geometrictools.com
+// Basic idea: D = |p - (lo + t0*lv)| where t0 = lv . (p - lo) / lv . lv
+btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest);
+
+btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest) {
+	btVector3 diff = p - from;
+	btVector3 v = to - from;
+	btScalar t = v.dot(diff);
+	
+	if (t > 0) {
+		btScalar dotVV = v.dot(v);
+		if (t < dotVV) {
+			t /= dotVV;
+			diff -= t*v;
+		} else {
+			t = 1;
+			diff -= v;
+		}
+	} else
+		t = 0;
+
+	nearest = from + t*v;
+	return diff.dot(diff);	
+}
+
+bool SphereTriangleDetector::facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal)  {
+	btVector3 lp(p);
+	btVector3 lnormal(normal);
+	
+	return pointInTriangle(vertices, lnormal, &lp);
+}
+
+///combined discrete/continuous sphere-triangle
+bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact)
+{
+
+	const btVector3* vertices = &m_triangle->getVertexPtr(0);
+	const btVector3& c = sphereCenter;
+	btScalar r = m_sphere->getRadius();
+
+	btVector3 delta (0,0,0);
+
+	btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
+	normal.normalize();
+	btVector3 p1ToCentre = c - vertices[0];
+	btScalar distanceFromPlane = p1ToCentre.dot(normal);
+
+	if (distanceFromPlane < btScalar(0.))
+	{
+		//triangle facing the other way
+	
+		distanceFromPlane *= btScalar(-1.);
+		normal *= btScalar(-1.);
+	}
+
+	///todo: move this gContactBreakingThreshold into a proper structure
+	extern btScalar gContactBreakingThreshold;
+
+	btScalar contactMargin = gContactBreakingThreshold;
+	bool isInsideContactPlane = distanceFromPlane < r + contactMargin;
+	bool isInsideShellPlane = distanceFromPlane < r;
+	
+	btScalar deltaDotNormal = delta.dot(normal);
+	if (!isInsideShellPlane && deltaDotNormal >= btScalar(0.0))
+		return false;
+
+	// Check for contact / intersection
+	bool hasContact = false;
+	btVector3 contactPoint;
+	if (isInsideContactPlane) {
+		if (facecontains(c,vertices,normal)) {
+			// Inside the contact wedge - touches a point on the shell plane
+			hasContact = true;
+			contactPoint = c - normal*distanceFromPlane;
+		} else {
+			// Could be inside one of the contact capsules
+			btScalar contactCapsuleRadiusSqr = (r + contactMargin) * (r + contactMargin);
+			btVector3 nearestOnEdge;
+			for (int i = 0; i < m_triangle->getNumEdges(); i++) {
+				
+				btPoint3 pa;
+				btPoint3 pb;
+				
+				m_triangle->getEdge(i,pa,pb);
+
+				btScalar distanceSqr = SegmentSqrDistance(pa,pb,c, nearestOnEdge);
+				if (distanceSqr < contactCapsuleRadiusSqr) {
+					// Yep, we're inside a capsule
+					hasContact = true;
+					contactPoint = nearestOnEdge;
+				}
+				
+			}
+		}
+	}
+
+	if (hasContact) {
+		btVector3 contactToCentre = c - contactPoint;
+		btScalar distanceSqr = contactToCentre.length2();
+		if (distanceSqr < (r - MAX_OVERLAP)*(r - MAX_OVERLAP)) {
+			btScalar distance = btSqrt(distanceSqr);
+			resultNormal = contactToCentre;
+			resultNormal.normalize();
+			point = contactPoint;
+			depth = -(r-distance);
+			return true;
+		}
+
+		if (delta.dot(contactToCentre) >= btScalar(0.0)) 
+			return false;
+		
+		// Moving towards the contact point -> collision
+		point = contactPoint;
+		timeOfImpact = btScalar(0.0);
+		return true;
+	}
+	
+	return false;
+}
+
+
+bool SphereTriangleDetector::pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p )
+{
+	const btVector3* p1 = &vertices[0];
+	const btVector3* p2 = &vertices[1];
+	const btVector3* p3 = &vertices[2];
+
+	btVector3 edge1( *p2 - *p1 );
+	btVector3 edge2( *p3 - *p2 );
+	btVector3 edge3( *p1 - *p3 );
+
+	btVector3 p1_to_p( *p - *p1 );
+	btVector3 p2_to_p( *p - *p2 );
+	btVector3 p3_to_p( *p - *p3 );
+
+	btVector3 edge1_normal( edge1.cross(normal));
+	btVector3 edge2_normal( edge2.cross(normal));
+	btVector3 edge3_normal( edge3.cross(normal));
+	
+	btScalar r1, r2, r3;
+	r1 = edge1_normal.dot( p1_to_p );
+	r2 = edge2_normal.dot( p2_to_p );
+	r3 = edge3_normal.dot( p3_to_p );
+	if ( ( r1 > 0 && r2 > 0 && r3 > 0 ) ||
+	     ( r1 <= 0 && r2 <= 0 && r3 <= 0 ) )
+		return true;
+	return false;
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h	(revision 2122)
@@ -0,0 +1,49 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SPHERE_TRIANGLE_DETECTOR_H
+#define SPHERE_TRIANGLE_DETECTOR_H
+
+#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
+#include "LinearMath/btPoint3.h"
+
+
+class btSphereShape;
+class btTriangleShape;
+
+
+
+/// sphere-triangle to match the btDiscreteCollisionDetectorInterface
+struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface
+{
+	virtual void	getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
+
+	SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle);
+
+	virtual ~SphereTriangleDetector() {};
+
+private:
+
+	bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact);
+	bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
+	bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
+
+	btSphereShape* m_sphere;
+	btTriangleShape* m_triangle;
+
+	
+};
+#endif //SPHERE_TRIANGLE_DETECTOR_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,85 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btBoxBoxCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "btBoxBoxDetector.h"
+
+#define USE_PERSISTENT_CONTACTS 1
+
+btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* obj0,btCollisionObject* obj1)
+: btCollisionAlgorithm(ci),
+m_ownManifold(false),
+m_manifoldPtr(mf)
+{
+	if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0,obj1))
+	{
+		m_manifoldPtr = m_dispatcher->getNewManifold(obj0,obj1);
+		m_ownManifold = true;
+	}
+}
+
+btBoxBoxCollisionAlgorithm::~btBoxBoxCollisionAlgorithm()
+{
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr)
+			m_dispatcher->releaseManifold(m_manifoldPtr);
+	}
+}
+
+void btBoxBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	if (!m_manifoldPtr)
+		return;
+
+	btCollisionObject*	col0 = body0;
+	btCollisionObject*	col1 = body1;
+	btBoxShape* box0 = (btBoxShape*)col0->getCollisionShape();
+	btBoxShape* box1 = (btBoxShape*)col1->getCollisionShape();
+
+
+
+	/// report a contact. internally this will be kept persistent, and contact reduction is done
+	resultOut->setPersistentManifold(m_manifoldPtr);
+#ifndef USE_PERSISTENT_CONTACTS	
+	m_manifoldPtr->clearManifold();
+#endif //USE_PERSISTENT_CONTACTS
+
+	btDiscreteCollisionDetectorInterface::ClosestPointInput input;
+	input.m_maximumDistanceSquared = 1e30f;
+	input.m_transformA = body0->getWorldTransform();
+	input.m_transformB = body1->getWorldTransform();
+
+	btBoxBoxDetector detector(box0,box1);
+	detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
+
+#ifdef USE_PERSISTENT_CONTACTS
+	//  refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added
+	if (m_ownManifold)
+	{
+		resultOut->refreshContactPoints();
+	}
+#endif //USE_PERSISTENT_CONTACTS
+
+}
+
+btScalar btBoxBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/,btCollisionObject* /*body1*/,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/)
+{
+	//not yet
+	return 1.f;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,66 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BOX_BOX__COLLISION_ALGORITHM_H
+#define BOX_BOX__COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+
+class btPersistentManifold;
+
+///box-box collision detection
+class btBoxBoxCollisionAlgorithm : public btCollisionAlgorithm
+{
+	bool	m_ownManifold;
+	btPersistentManifold*	m_manifoldPtr;
+	
+public:
+	btBoxBoxCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
+		: btCollisionAlgorithm(ci) {}
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+
+	virtual ~btBoxBoxCollisionAlgorithm();
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		if (m_manifoldPtr && m_ownManifold)
+		{
+			manifoldArray.push_back(m_manifoldPtr);
+		}
+	}
+
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			int bbsize = sizeof(btBoxBoxCollisionAlgorithm);
+			void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
+			return new(ptr) btBoxBoxCollisionAlgorithm(0,ci,body0,body1);
+		}
+	};
+
+};
+
+#endif //BOX_BOX__COLLISION_ALGORITHM_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp	(revision 2122)
@@ -0,0 +1,683 @@
+
+/*
+ * Box-Box collision detection re-distributed under the ZLib license with permission from Russell L. Smith
+ * Original version is from Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.
+ * All rights reserved.  Email: russ@q12.org   Web: www.q12.org
+ Bullet Continuous Collision Detection and Physics Library
+ Bullet is Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///ODE box-box collision detection is adapted to work with Bullet
+
+#include "btBoxBoxDetector.h"
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+
+#include <float.h>
+#include <string.h>
+
+btBoxBoxDetector::btBoxBoxDetector(btBoxShape* box1,btBoxShape* box2)
+: m_box1(box1),
+m_box2(box2)
+{
+
+}
+
+
+// given two boxes (p1,R1,side1) and (p2,R2,side2), collide them together and
+// generate contact points. this returns 0 if there is no contact otherwise
+// it returns the number of contacts generated.
+// `normal' returns the contact normal.
+// `depth' returns the maximum penetration depth along that normal.
+// `return_code' returns a number indicating the type of contact that was
+// detected:
+//        1,2,3 = box 2 intersects with a face of box 1
+//        4,5,6 = box 1 intersects with a face of box 2
+//        7..15 = edge-edge contact
+// `maxc' is the maximum number of contacts allowed to be generated, i.e.
+// the size of the `contact' array.
+// `contact' and `skip' are the contact array information provided to the
+// collision functions. this function only fills in the position and depth
+// fields.
+struct dContactGeom;
+#define dDOTpq(a,b,p,q) ((a)[0]*(b)[0] + (a)[p]*(b)[q] + (a)[2*(p)]*(b)[2*(q)])
+#define dInfinity FLT_MAX
+
+
+/*PURE_INLINE btScalar dDOT   (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,1); }
+PURE_INLINE btScalar dDOT13 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,3); }
+PURE_INLINE btScalar dDOT31 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,3,1); }
+PURE_INLINE btScalar dDOT33 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,3,3); }
+*/
+static btScalar dDOT   (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,1); }
+static btScalar dDOT44 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,4,4); }
+static btScalar dDOT41 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,4,1); }
+static btScalar dDOT14 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,4); }
+#define dMULTIPLYOP1_331(A,op,B,C) \
+{\
+  (A)[0] op dDOT41((B),(C)); \
+  (A)[1] op dDOT41((B+1),(C)); \
+  (A)[2] op dDOT41((B+2),(C)); \
+}
+
+#define dMULTIPLYOP0_331(A,op,B,C) \
+{ \
+  (A)[0] op dDOT((B),(C)); \
+  (A)[1] op dDOT((B+4),(C)); \
+  (A)[2] op dDOT((B+8),(C)); \
+} 
+
+#define dMULTIPLY1_331(A,B,C) dMULTIPLYOP1_331(A,=,B,C)
+#define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C)
+
+typedef btScalar dMatrix3[4*3];
+
+void dLineClosestApproach (const btVector3& pa, const btVector3& ua,
+			   const btVector3& pb, const btVector3& ub,
+			   btScalar *alpha, btScalar *beta);
+void dLineClosestApproach (const btVector3& pa, const btVector3& ua,
+			   const btVector3& pb, const btVector3& ub,
+			   btScalar *alpha, btScalar *beta)
+{
+  btVector3 p;
+  p[0] = pb[0] - pa[0];
+  p[1] = pb[1] - pa[1];
+  p[2] = pb[2] - pa[2];
+  btScalar uaub = dDOT(ua,ub);
+  btScalar q1 =  dDOT(ua,p);
+  btScalar q2 = -dDOT(ub,p);
+  btScalar d = 1-uaub*uaub;
+  if (d <= btScalar(0.0001f)) {
+    // @@@ this needs to be made more robust
+    *alpha = 0;
+    *beta  = 0;
+  }
+  else {
+    d = 1.f/d;
+    *alpha = (q1 + uaub*q2)*d;
+    *beta  = (uaub*q1 + q2)*d;
+  }
+}
+
+
+
+// find all the intersection points between the 2D rectangle with vertices
+// at (+/-h[0],+/-h[1]) and the 2D quadrilateral with vertices (p[0],p[1]),
+// (p[2],p[3]),(p[4],p[5]),(p[6],p[7]).
+//
+// the intersection points are returned as x,y pairs in the 'ret' array.
+// the number of intersection points is returned by the function (this will
+// be in the range 0 to 8).
+
+static int intersectRectQuad2 (btScalar h[2], btScalar p[8], btScalar ret[16])
+{
+  // q (and r) contain nq (and nr) coordinate points for the current (and
+  // chopped) polygons
+  int nq=4,nr=0;
+  btScalar buffer[16];
+  btScalar *q = p;
+  btScalar *r = ret;
+  for (int dir=0; dir <= 1; dir++) {
+    // direction notation: xy[0] = x axis, xy[1] = y axis
+    for (int sign=-1; sign <= 1; sign += 2) {
+      // chop q along the line xy[dir] = sign*h[dir]
+      btScalar *pq = q;
+      btScalar *pr = r;
+      nr = 0;
+      for (int i=nq; i > 0; i--) {
+	// go through all points in q and all lines between adjacent points
+	if (sign*pq[dir] < h[dir]) {
+	  // this point is inside the chopping line
+	  pr[0] = pq[0];
+	  pr[1] = pq[1];
+	  pr += 2;
+	  nr++;
+	  if (nr & 8) {
+	    q = r;
+	    goto done;
+	  }
+	}
+	btScalar *nextq = (i > 1) ? pq+2 : q;
+	if ((sign*pq[dir] < h[dir]) ^ (sign*nextq[dir] < h[dir])) {
+	  // this line crosses the chopping line
+	  pr[1-dir] = pq[1-dir] + (nextq[1-dir]-pq[1-dir]) /
+	    (nextq[dir]-pq[dir]) * (sign*h[dir]-pq[dir]);
+	  pr[dir] = sign*h[dir];
+	  pr += 2;
+	  nr++;
+	  if (nr & 8) {
+	    q = r;
+	    goto done;
+	  }
+	}
+	pq += 2;
+      }
+      q = r;
+      r = (q==ret) ? buffer : ret;
+      nq = nr;
+    }
+  }
+ done:
+  if (q != ret) memcpy (ret,q,nr*2*sizeof(btScalar));
+  return nr;
+}
+
+
+#define M__PI 3.14159265f
+
+// given n points in the plane (array p, of size 2*n), generate m points that
+// best represent the whole set. the definition of 'best' here is not
+// predetermined - the idea is to select points that give good box-box
+// collision detection behavior. the chosen point indexes are returned in the
+// array iret (of size m). 'i0' is always the first entry in the array.
+// n must be in the range [1..8]. m must be in the range [1..n]. i0 must be
+// in the range [0..n-1].
+
+void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[]);
+void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[])
+{
+  // compute the centroid of the polygon in cx,cy
+  int i,j;
+  btScalar a,cx,cy,q;
+  if (n==1) {
+    cx = p[0];
+    cy = p[1];
+  }
+  else if (n==2) {
+    cx = btScalar(0.5)*(p[0] + p[2]);
+    cy = btScalar(0.5)*(p[1] + p[3]);
+  }
+  else {
+    a = 0;
+    cx = 0;
+    cy = 0;
+    for (i=0; i<(n-1); i++) {
+      q = p[i*2]*p[i*2+3] - p[i*2+2]*p[i*2+1];
+      a += q;
+      cx += q*(p[i*2]+p[i*2+2]);
+      cy += q*(p[i*2+1]+p[i*2+3]);
+    }
+    q = p[n*2-2]*p[1] - p[0]*p[n*2-1];
+    a = 1.f/(btScalar(3.0)*(a+q));
+    cx = a*(cx + q*(p[n*2-2]+p[0]));
+    cy = a*(cy + q*(p[n*2-1]+p[1]));
+  }
+
+  // compute the angle of each point w.r.t. the centroid
+  btScalar A[8];
+  for (i=0; i<n; i++) A[i] = btAtan2(p[i*2+1]-cy,p[i*2]-cx);
+
+  // search for points that have angles closest to A[i0] + i*(2*pi/m).
+  int avail[8];
+  for (i=0; i<n; i++) avail[i] = 1;
+  avail[i0] = 0;
+  iret[0] = i0;
+  iret++;
+  for (j=1; j<m; j++) {
+    a = btScalar(j)*(2*M__PI/m) + A[i0];
+    if (a > M__PI) a -= 2*M__PI;
+    btScalar maxdiff=1e9,diff;
+
+    *iret = i0;			// iret is not allowed to keep this value, but it sometimes does, when diff=#QNAN0
+
+    for (i=0; i<n; i++) {
+      if (avail[i]) {
+	diff = btFabs (A[i]-a);
+	if (diff > M__PI) diff = 2*M__PI - diff;
+	if (diff < maxdiff) {
+	  maxdiff = diff;
+	  *iret = i;
+	}
+      }
+    }
+#if defined(DEBUG) || defined (_DEBUG)
+    btAssert (*iret != i0);	// ensure iret got set
+#endif
+    avail[*iret] = 0;
+    iret++;
+  }
+}
+
+
+
+int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
+	     const btVector3& side1, const btVector3& p2,
+	     const dMatrix3 R2, const btVector3& side2,
+	     btVector3& normal, btScalar *depth, int *return_code,
+		 int maxc, dContactGeom * /*contact*/, int /*skip*/,btDiscreteCollisionDetectorInterface::Result& output);
+int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
+	     const btVector3& side1, const btVector3& p2,
+	     const dMatrix3 R2, const btVector3& side2,
+	     btVector3& normal, btScalar *depth, int *return_code,
+		 int maxc, dContactGeom * /*contact*/, int /*skip*/,btDiscreteCollisionDetectorInterface::Result& output)
+{
+  const btScalar fudge_factor = btScalar(1.05);
+  btVector3 p,pp,normalC;
+  const btScalar *normalR = 0;
+  btScalar A[3],B[3],R11,R12,R13,R21,R22,R23,R31,R32,R33,
+    Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33,s,s2,l;
+  int i,j,invert_normal,code;
+
+  // get vector from centers of box 1 to box 2, relative to box 1
+  p = p2 - p1;
+  dMULTIPLY1_331 (pp,R1,p);		// get pp = p relative to body 1
+
+  // get side lengths / 2
+  A[0] = side1[0]*btScalar(0.5);
+  A[1] = side1[1]*btScalar(0.5);
+  A[2] = side1[2]*btScalar(0.5);
+  B[0] = side2[0]*btScalar(0.5);
+  B[1] = side2[1]*btScalar(0.5);
+  B[2] = side2[2]*btScalar(0.5);
+
+  // Rij is R1'*R2, i.e. the relative rotation between R1 and R2
+  R11 = dDOT44(R1+0,R2+0); R12 = dDOT44(R1+0,R2+1); R13 = dDOT44(R1+0,R2+2);
+  R21 = dDOT44(R1+1,R2+0); R22 = dDOT44(R1+1,R2+1); R23 = dDOT44(R1+1,R2+2);
+  R31 = dDOT44(R1+2,R2+0); R32 = dDOT44(R1+2,R2+1); R33 = dDOT44(R1+2,R2+2);
+
+  Q11 = btFabs(R11); Q12 = btFabs(R12); Q13 = btFabs(R13);
+  Q21 = btFabs(R21); Q22 = btFabs(R22); Q23 = btFabs(R23);
+  Q31 = btFabs(R31); Q32 = btFabs(R32); Q33 = btFabs(R33);
+
+  // for all 15 possible separating axes:
+  //   * see if the axis separates the boxes. if so, return 0.
+  //   * find the depth of the penetration along the separating axis (s2)
+  //   * if this is the largest depth so far, record it.
+  // the normal vector will be set to the separating axis with the smallest
+  // depth. note: normalR is set to point to a column of R1 or R2 if that is
+  // the smallest depth normal so far. otherwise normalR is 0 and normalC is
+  // set to a vector relative to body 1. invert_normal is 1 if the sign of
+  // the normal should be flipped.
+
+#define TST(expr1,expr2,norm,cc) \
+  s2 = btFabs(expr1) - (expr2); \
+  if (s2 > 0) return 0; \
+  if (s2 > s) { \
+    s = s2; \
+    normalR = norm; \
+    invert_normal = ((expr1) < 0); \
+    code = (cc); \
+  }
+
+  s = -dInfinity;
+  invert_normal = 0;
+  code = 0;
+
+  // separating axis = u1,u2,u3
+  TST (pp[0],(A[0] + B[0]*Q11 + B[1]*Q12 + B[2]*Q13),R1+0,1);
+  TST (pp[1],(A[1] + B[0]*Q21 + B[1]*Q22 + B[2]*Q23),R1+1,2);
+  TST (pp[2],(A[2] + B[0]*Q31 + B[1]*Q32 + B[2]*Q33),R1+2,3);
+
+  // separating axis = v1,v2,v3
+  TST (dDOT41(R2+0,p),(A[0]*Q11 + A[1]*Q21 + A[2]*Q31 + B[0]),R2+0,4);
+  TST (dDOT41(R2+1,p),(A[0]*Q12 + A[1]*Q22 + A[2]*Q32 + B[1]),R2+1,5);
+  TST (dDOT41(R2+2,p),(A[0]*Q13 + A[1]*Q23 + A[2]*Q33 + B[2]),R2+2,6);
+
+  // note: cross product axes need to be scaled when s is computed.
+  // normal (n1,n2,n3) is relative to box 1.
+#undef TST
+#define TST(expr1,expr2,n1,n2,n3,cc) \
+  s2 = btFabs(expr1) - (expr2); \
+  if (s2 > 0) return 0; \
+  l = btSqrt((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \
+  if (l > 0) { \
+    s2 /= l; \
+    if (s2*fudge_factor > s) { \
+      s = s2; \
+      normalR = 0; \
+      normalC[0] = (n1)/l; normalC[1] = (n2)/l; normalC[2] = (n3)/l; \
+      invert_normal = ((expr1) < 0); \
+      code = (cc); \
+    } \
+  }
+
+  // separating axis = u1 x (v1,v2,v3)
+  TST(pp[2]*R21-pp[1]*R31,(A[1]*Q31+A[2]*Q21+B[1]*Q13+B[2]*Q12),0,-R31,R21,7);
+  TST(pp[2]*R22-pp[1]*R32,(A[1]*Q32+A[2]*Q22+B[0]*Q13+B[2]*Q11),0,-R32,R22,8);
+  TST(pp[2]*R23-pp[1]*R33,(A[1]*Q33+A[2]*Q23+B[0]*Q12+B[1]*Q11),0,-R33,R23,9);
+
+  // separating axis = u2 x (v1,v2,v3)
+  TST(pp[0]*R31-pp[2]*R11,(A[0]*Q31+A[2]*Q11+B[1]*Q23+B[2]*Q22),R31,0,-R11,10);
+  TST(pp[0]*R32-pp[2]*R12,(A[0]*Q32+A[2]*Q12+B[0]*Q23+B[2]*Q21),R32,0,-R12,11);
+  TST(pp[0]*R33-pp[2]*R13,(A[0]*Q33+A[2]*Q13+B[0]*Q22+B[1]*Q21),R33,0,-R13,12);
+
+  // separating axis = u3 x (v1,v2,v3)
+  TST(pp[1]*R11-pp[0]*R21,(A[0]*Q21+A[1]*Q11+B[1]*Q33+B[2]*Q32),-R21,R11,0,13);
+  TST(pp[1]*R12-pp[0]*R22,(A[0]*Q22+A[1]*Q12+B[0]*Q33+B[2]*Q31),-R22,R12,0,14);
+  TST(pp[1]*R13-pp[0]*R23,(A[0]*Q23+A[1]*Q13+B[0]*Q32+B[1]*Q31),-R23,R13,0,15);
+
+#undef TST
+
+  if (!code) return 0;
+
+  // if we get to this point, the boxes interpenetrate. compute the normal
+  // in global coordinates.
+  if (normalR) {
+    normal[0] = normalR[0];
+    normal[1] = normalR[4];
+    normal[2] = normalR[8];
+  }
+  else {
+    dMULTIPLY0_331 (normal,R1,normalC);
+  }
+  if (invert_normal) {
+    normal[0] = -normal[0];
+    normal[1] = -normal[1];
+    normal[2] = -normal[2];
+  }
+  *depth = -s;
+
+  // compute contact point(s)
+
+  if (code > 6) {
+    // an edge from box 1 touches an edge from box 2.
+    // find a point pa on the intersecting edge of box 1
+    btVector3 pa;
+    btScalar sign;
+    for (i=0; i<3; i++) pa[i] = p1[i];
+    for (j=0; j<3; j++) {
+      sign = (dDOT14(normal,R1+j) > 0) ? btScalar(1.0) : btScalar(-1.0);
+      for (i=0; i<3; i++) pa[i] += sign * A[j] * R1[i*4+j];
+    }
+
+    // find a point pb on the intersecting edge of box 2
+    btVector3 pb;
+    for (i=0; i<3; i++) pb[i] = p2[i];
+    for (j=0; j<3; j++) {
+      sign = (dDOT14(normal,R2+j) > 0) ? btScalar(-1.0) : btScalar(1.0);
+      for (i=0; i<3; i++) pb[i] += sign * B[j] * R2[i*4+j];
+    }
+
+    btScalar alpha,beta;
+    btVector3 ua,ub;
+    for (i=0; i<3; i++) ua[i] = R1[((code)-7)/3 + i*4];
+    for (i=0; i<3; i++) ub[i] = R2[((code)-7)%3 + i*4];
+
+    dLineClosestApproach (pa,ua,pb,ub,&alpha,&beta);
+    for (i=0; i<3; i++) pa[i] += ua[i]*alpha;
+    for (i=0; i<3; i++) pb[i] += ub[i]*beta;
+
+	{
+		
+		//contact[0].pos[i] = btScalar(0.5)*(pa[i]+pb[i]);
+		//contact[0].depth = *depth;
+		btVector3 pointInWorld;
+
+#ifdef USE_CENTER_POINT
+	    for (i=0; i<3; i++) 
+			pointInWorld[i] = (pa[i]+pb[i])*btScalar(0.5);
+		output.addContactPoint(-normal,pointInWorld,-*depth);
+#else
+		output.addContactPoint(-normal,pb,-*depth);
+#endif //
+		*return_code = code;
+	}
+    return 1;
+  }
+
+  // okay, we have a face-something intersection (because the separating
+  // axis is perpendicular to a face). define face 'a' to be the reference
+  // face (i.e. the normal vector is perpendicular to this) and face 'b' to be
+  // the incident face (the closest face of the other box).
+
+  const btScalar *Ra,*Rb,*pa,*pb,*Sa,*Sb;
+  if (code <= 3) {
+    Ra = R1;
+    Rb = R2;
+    pa = p1;
+    pb = p2;
+    Sa = A;
+    Sb = B;
+  }
+  else {
+    Ra = R2;
+    Rb = R1;
+    pa = p2;
+    pb = p1;
+    Sa = B;
+    Sb = A;
+  }
+
+  // nr = normal vector of reference face dotted with axes of incident box.
+  // anr = absolute values of nr.
+  btVector3 normal2,nr,anr;
+  if (code <= 3) {
+    normal2[0] = normal[0];
+    normal2[1] = normal[1];
+    normal2[2] = normal[2];
+  }
+  else {
+    normal2[0] = -normal[0];
+    normal2[1] = -normal[1];
+    normal2[2] = -normal[2];
+  }
+  dMULTIPLY1_331 (nr,Rb,normal2);
+  anr[0] = btFabs (nr[0]);
+  anr[1] = btFabs (nr[1]);
+  anr[2] = btFabs (nr[2]);
+
+  // find the largest compontent of anr: this corresponds to the normal
+  // for the indident face. the other axis numbers of the indicent face
+  // are stored in a1,a2.
+  int lanr,a1,a2;
+  if (anr[1] > anr[0]) {
+    if (anr[1] > anr[2]) {
+      a1 = 0;
+      lanr = 1;
+      a2 = 2;
+    }
+    else {
+      a1 = 0;
+      a2 = 1;
+      lanr = 2;
+    }
+  }
+  else {
+    if (anr[0] > anr[2]) {
+      lanr = 0;
+      a1 = 1;
+      a2 = 2;
+    }
+    else {
+      a1 = 0;
+      a2 = 1;
+      lanr = 2;
+    }
+  }
+
+  // compute center point of incident face, in reference-face coordinates
+  btVector3 center;
+  if (nr[lanr] < 0) {
+    for (i=0; i<3; i++) center[i] = pb[i] - pa[i] + Sb[lanr] * Rb[i*4+lanr];
+  }
+  else {
+    for (i=0; i<3; i++) center[i] = pb[i] - pa[i] - Sb[lanr] * Rb[i*4+lanr];
+  }
+
+  // find the normal and non-normal axis numbers of the reference box
+  int codeN,code1,code2;
+  if (code <= 3) codeN = code-1; else codeN = code-4;
+  if (codeN==0) {
+    code1 = 1;
+    code2 = 2;
+  }
+  else if (codeN==1) {
+    code1 = 0;
+    code2 = 2;
+  }
+  else {
+    code1 = 0;
+    code2 = 1;
+  }
+
+  // find the four corners of the incident face, in reference-face coordinates
+  btScalar quad[8];	// 2D coordinate of incident face (x,y pairs)
+  btScalar c1,c2,m11,m12,m21,m22;
+  c1 = dDOT14 (center,Ra+code1);
+  c2 = dDOT14 (center,Ra+code2);
+  // optimize this? - we have already computed this data above, but it is not
+  // stored in an easy-to-index format. for now it's quicker just to recompute
+  // the four dot products.
+  m11 = dDOT44 (Ra+code1,Rb+a1);
+  m12 = dDOT44 (Ra+code1,Rb+a2);
+  m21 = dDOT44 (Ra+code2,Rb+a1);
+  m22 = dDOT44 (Ra+code2,Rb+a2);
+  {
+    btScalar k1 = m11*Sb[a1];
+    btScalar k2 = m21*Sb[a1];
+    btScalar k3 = m12*Sb[a2];
+    btScalar k4 = m22*Sb[a2];
+    quad[0] = c1 - k1 - k3;
+    quad[1] = c2 - k2 - k4;
+    quad[2] = c1 - k1 + k3;
+    quad[3] = c2 - k2 + k4;
+    quad[4] = c1 + k1 + k3;
+    quad[5] = c2 + k2 + k4;
+    quad[6] = c1 + k1 - k3;
+    quad[7] = c2 + k2 - k4;
+  }
+
+  // find the size of the reference face
+  btScalar rect[2];
+  rect[0] = Sa[code1];
+  rect[1] = Sa[code2];
+
+  // intersect the incident and reference faces
+  btScalar ret[16];
+  int n = intersectRectQuad2 (rect,quad,ret);
+  if (n < 1) return 0;		// this should never happen
+
+  // convert the intersection points into reference-face coordinates,
+  // and compute the contact position and depth for each point. only keep
+  // those points that have a positive (penetrating) depth. delete points in
+  // the 'ret' array as necessary so that 'point' and 'ret' correspond.
+  btScalar point[3*8];		// penetrating contact points
+  btScalar dep[8];			// depths for those points
+  btScalar det1 = 1.f/(m11*m22 - m12*m21);
+  m11 *= det1;
+  m12 *= det1;
+  m21 *= det1;
+  m22 *= det1;
+  int cnum = 0;			// number of penetrating contact points found
+  for (j=0; j < n; j++) {
+    btScalar k1 =  m22*(ret[j*2]-c1) - m12*(ret[j*2+1]-c2);
+    btScalar k2 = -m21*(ret[j*2]-c1) + m11*(ret[j*2+1]-c2);
+    for (i=0; i<3; i++) point[cnum*3+i] =
+			  center[i] + k1*Rb[i*4+a1] + k2*Rb[i*4+a2];
+    dep[cnum] = Sa[codeN] - dDOT(normal2,point+cnum*3);
+    if (dep[cnum] >= 0) {
+      ret[cnum*2] = ret[j*2];
+      ret[cnum*2+1] = ret[j*2+1];
+      cnum++;
+    }
+  }
+  if (cnum < 1) return 0;	// this should never happen
+
+  // we can't generate more contacts than we actually have
+  if (maxc > cnum) maxc = cnum;
+  if (maxc < 1) maxc = 1;
+
+  if (cnum <= maxc) {
+    // we have less contacts than we need, so we use them all
+    for (j=0; j < cnum; j++) {
+
+		//AddContactPoint...
+
+		//dContactGeom *con = CONTACT(contact,skip*j);
+      //for (i=0; i<3; i++) con->pos[i] = point[j*3+i] + pa[i];
+      //con->depth = dep[j];
+
+		btVector3 pointInWorld;
+		for (i=0; i<3; i++) 
+			pointInWorld[i] = point[j*3+i] + pa[i];
+		output.addContactPoint(-normal,pointInWorld,-dep[j]);
+
+    }
+  }
+  else {
+    // we have more contacts than are wanted, some of them must be culled.
+    // find the deepest point, it is always the first contact.
+    int i1 = 0;
+    btScalar maxdepth = dep[0];
+    for (i=1; i<cnum; i++) {
+      if (dep[i] > maxdepth) {
+	maxdepth = dep[i];
+	i1 = i;
+      }
+    }
+
+    int iret[8];
+    cullPoints2 (cnum,ret,maxc,i1,iret);
+
+    for (j=0; j < maxc; j++) {
+//      dContactGeom *con = CONTACT(contact,skip*j);
+  //    for (i=0; i<3; i++) con->pos[i] = point[iret[j]*3+i] + pa[i];
+    //  con->depth = dep[iret[j]];
+
+		btVector3 posInWorld;
+		for (i=0; i<3; i++) 
+			posInWorld[i] = point[iret[j]*3+i] + pa[i];
+		output.addContactPoint(-normal,posInWorld,-dep[iret[j]]);
+    }
+    cnum = maxc;
+  }
+
+  *return_code = code;
+  return cnum;
+}
+
+void	btBoxBoxDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* /*debugDraw*/,bool /*swapResults*/)
+{
+	
+	const btTransform& transformA = input.m_transformA;
+	const btTransform& transformB = input.m_transformB;
+	
+	int skip = 0;
+	dContactGeom *contact = 0;
+
+	dMatrix3 R1;
+	dMatrix3 R2;
+
+	for (int j=0;j<3;j++)
+	{
+		R1[0+4*j] = transformA.getBasis()[j].x();
+		R2[0+4*j] = transformB.getBasis()[j].x();
+
+		R1[1+4*j] = transformA.getBasis()[j].y();
+		R2[1+4*j] = transformB.getBasis()[j].y();
+
+
+		R1[2+4*j] = transformA.getBasis()[j].z();
+		R2[2+4*j] = transformB.getBasis()[j].z();
+
+	}
+
+	
+
+	btVector3 normal;
+	btScalar depth;
+	int return_code;
+	int maxc = 4;
+
+
+	dBoxBox2 (transformA.getOrigin(), 
+	R1,
+	2.f*m_box1->getHalfExtentsWithMargin(),
+	transformB.getOrigin(),
+	R2, 
+	2.f*m_box2->getHalfExtentsWithMargin(),
+	normal, &depth, &return_code,
+	maxc, contact, skip,
+	output
+	);
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.h	(revision 2122)
@@ -0,0 +1,44 @@
+/*
+ * Box-Box collision detection re-distributed under the ZLib license with permission from Russell L. Smith
+ * Original version is from Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.
+ * All rights reserved.  Email: russ@q12.org   Web: www.q12.org
+
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef BOX_BOX_DETECTOR_H
+#define BOX_BOX_DETECTOR_H
+
+
+class btBoxShape;
+#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
+
+
+/// btBoxBoxDetector wraps the ODE box-box collision detector
+/// re-distributed under the Zlib license with permission from Russell L. Smith
+struct btBoxBoxDetector : public btDiscreteCollisionDetectorInterface
+{
+	btBoxShape* m_box1;
+	btBoxShape* m_box2;
+
+public:
+
+	btBoxBoxDetector(btBoxShape* box1,btBoxShape* box2);
+
+	virtual ~btBoxBoxDetector() {};
+
+	virtual void	getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
+
+};
+
+#endif //BT_BOX_BOX_DETECTOR_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h	(revision 2122)
@@ -0,0 +1,47 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_COLLISION_CONFIGURATION
+#define BT_COLLISION_CONFIGURATION
+struct btCollisionAlgorithmCreateFunc;
+
+class btStackAlloc;
+class btPoolAllocator;
+
+///btCollisionConfiguration allows to configure Bullet collision detection
+///stack allocator size, default collision algorithms and persistent manifold pool size
+///todo: describe the meaning
+class	btCollisionConfiguration
+{
+
+public:
+
+	virtual ~btCollisionConfiguration()
+	{
+	}
+
+	///memory pools
+	virtual btPoolAllocator* getPersistentManifoldPool() = 0;
+
+	virtual btPoolAllocator* getCollisionAlgorithmPool() = 0;
+
+	virtual btStackAlloc*	getStackAllocator() = 0;
+
+	virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1) =0;
+
+};
+
+#endif //BT_COLLISION_CONFIGURATION
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h	(revision 2122)
@@ -0,0 +1,46 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COLLISION_CREATE_FUNC
+#define COLLISION_CREATE_FUNC
+
+#include "LinearMath/btAlignedObjectArray.h"
+typedef btAlignedObjectArray<class btCollisionObject*> btCollisionObjectArray;
+class btCollisionAlgorithm;
+class btCollisionObject;
+
+struct btCollisionAlgorithmConstructionInfo;
+
+///Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm
+struct btCollisionAlgorithmCreateFunc
+{
+	bool m_swapped;
+	
+	btCollisionAlgorithmCreateFunc()
+		:m_swapped(false)
+	{
+	}
+	virtual ~btCollisionAlgorithmCreateFunc(){};
+
+	virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& , btCollisionObject* body0,btCollisionObject* body1)
+	{
+		
+		(void)body0;
+		(void)body1;
+		return 0;
+	}
+};
+#endif //COLLISION_CREATE_FUNC
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp	(revision 2122)
@@ -0,0 +1,298 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#include "btCollisionDispatcher.h"
+
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
+#include "LinearMath/btPoolAllocator.h"
+#include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
+
+int gNumManifold = 0;
+
+#ifdef BT_DEBUG
+#include <stdio.h>
+#endif
+
+
+btCollisionDispatcher::btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration): 
+	m_count(0),
+	m_useIslands(true),
+	m_staticWarningReported(false),
+	m_collisionConfiguration(collisionConfiguration)
+{
+	int i;
+
+	setNearCallback(defaultNearCallback);
+	
+	m_collisionAlgorithmPoolAllocator = collisionConfiguration->getCollisionAlgorithmPool();
+
+	m_persistentManifoldPoolAllocator = collisionConfiguration->getPersistentManifoldPool();
+
+	for (i=0;i<MAX_BROADPHASE_COLLISION_TYPES;i++)
+	{
+		for (int j=0;j<MAX_BROADPHASE_COLLISION_TYPES;j++)
+		{
+			m_doubleDispatch[i][j] = m_collisionConfiguration->getCollisionAlgorithmCreateFunc(i,j);
+			assert(m_doubleDispatch[i][j]);
+		}
+	}
+	
+	
+};
+
+
+void btCollisionDispatcher::registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
+{
+	m_doubleDispatch[proxyType0][proxyType1] = createFunc;
+}
+
+btCollisionDispatcher::~btCollisionDispatcher()
+{
+}
+
+btPersistentManifold*	btCollisionDispatcher::getNewManifold(void* b0,void* b1) 
+{ 
+	gNumManifold++;
+	
+	//btAssert(gNumManifold < 65535);
+	
+
+	btCollisionObject* body0 = (btCollisionObject*)b0;
+	btCollisionObject* body1 = (btCollisionObject*)b1;
+	
+	void* mem = 0;
+	
+	if (m_persistentManifoldPoolAllocator->getFreeCount())
+	{
+		mem = m_persistentManifoldPoolAllocator->allocate(sizeof(btPersistentManifold));
+	} else
+	{
+		mem = btAlignedAlloc(sizeof(btPersistentManifold),16);
+
+	}
+	btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0);
+	manifold->m_index1a = m_manifoldsPtr.size();
+	m_manifoldsPtr.push_back(manifold);
+
+	return manifold;
+}
+
+void btCollisionDispatcher::clearManifold(btPersistentManifold* manifold)
+{
+	manifold->clearManifold();
+}
+
+	
+void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
+{
+	
+	gNumManifold--;
+
+	//printf("releaseManifold: gNumManifold %d\n",gNumManifold);
+	clearManifold(manifold);
+
+	int findIndex = manifold->m_index1a;
+	btAssert(findIndex < m_manifoldsPtr.size());
+	m_manifoldsPtr.swap(findIndex,m_manifoldsPtr.size()-1);
+	m_manifoldsPtr[findIndex]->m_index1a = findIndex;
+	m_manifoldsPtr.pop_back();
+
+	manifold->~btPersistentManifold();
+	if (m_persistentManifoldPoolAllocator->validPtr(manifold))
+	{
+		m_persistentManifoldPoolAllocator->freeMemory(manifold);
+	} else
+	{
+		btAlignedFree(manifold);
+	}
+	
+}
+
+	
+
+btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
+{
+	
+	btCollisionAlgorithmConstructionInfo ci;
+
+	ci.m_dispatcher1 = this;
+	ci.m_manifold = sharedManifold;
+	btCollisionAlgorithm* algo = m_doubleDispatch[body0->getCollisionShape()->getShapeType()][body1->getCollisionShape()->getShapeType()]->CreateCollisionAlgorithm(ci,body0,body1);
+
+	return algo;
+}
+
+
+
+
+
+bool	btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
+{
+	//here you can do filtering
+	bool hasResponse = 
+		(body0->hasContactResponse() && body1->hasContactResponse());
+	//no response between two static/kinematic bodies:
+	hasResponse = hasResponse &&
+		((!body0->isStaticOrKinematicObject()) ||(! body1->isStaticOrKinematicObject()));
+	return hasResponse;
+}
+
+bool	btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1)
+{
+	assert(body0);
+	assert(body1);
+
+	bool needsCollision = true;
+
+#ifdef BT_DEBUG
+	if (!m_staticWarningReported)
+	{
+		//broadphase filtering already deals with this
+		if ((body0->isStaticObject() || body0->isKinematicObject()) &&
+			(body1->isStaticObject() || body1->isKinematicObject()))
+		{
+			m_staticWarningReported = true;
+			printf("warning btCollisionDispatcher::needsCollision: static-static collision!\n");
+		}
+	}
+#endif //BT_DEBUG
+
+	if ((!body0->isActive()) && (!body1->isActive()))
+		needsCollision = false;
+	else if (!body0->checkCollideWith(body1))
+		needsCollision = false;
+	
+	return needsCollision ;
+
+}
+
+
+
+///interface for iterating all overlapping collision pairs, no matter how those pairs are stored (array, set, map etc)
+///this is useful for the collision dispatcher.
+class btCollisionPairCallback : public btOverlapCallback
+{
+	const btDispatcherInfo& m_dispatchInfo;
+	btCollisionDispatcher*	m_dispatcher;
+
+public:
+
+	btCollisionPairCallback(const btDispatcherInfo& dispatchInfo,btCollisionDispatcher*	dispatcher)
+	:m_dispatchInfo(dispatchInfo),
+	m_dispatcher(dispatcher)
+	{
+	}
+
+	/*btCollisionPairCallback& operator=(btCollisionPairCallback& other)
+	{
+		m_dispatchInfo = other.m_dispatchInfo;
+		m_dispatcher = other.m_dispatcher;
+		return *this;
+	}
+	*/
+
+
+	virtual ~btCollisionPairCallback() {}
+
+
+	virtual bool	processOverlap(btBroadphasePair& pair)
+	{
+		(*m_dispatcher->getNearCallback())(pair,*m_dispatcher,m_dispatchInfo);
+
+		return false;
+	}
+};
+
+
+
+void	btCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) 
+{
+	//m_blockedForChanges = true;
+
+	btCollisionPairCallback	collisionCallback(dispatchInfo,this);
+
+	pairCache->processAllOverlappingPairs(&collisionCallback,dispatcher);
+
+	//m_blockedForChanges = false;
+
+}
+
+
+
+
+//by default, Bullet will use this near callback
+void btCollisionDispatcher::defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo)
+{
+		btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
+		btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
+
+		if (dispatcher.needsCollision(colObj0,colObj1))
+		{
+			//dispatcher will keep algorithms persistent in the collision pair
+			if (!collisionPair.m_algorithm)
+			{
+				collisionPair.m_algorithm = dispatcher.findAlgorithm(colObj0,colObj1);
+			}
+
+			if (collisionPair.m_algorithm)
+			{
+				btManifoldResult contactPointResult(colObj0,colObj1);
+				
+				if (dispatchInfo.m_dispatchFunc == 		btDispatcherInfo::DISPATCH_DISCRETE)
+				{
+					//discrete collision detection query
+					collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult);
+				} else
+				{
+					//continuous collision detection query, time of impact (toi)
+					btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
+					if (dispatchInfo.m_timeOfImpact > toi)
+						dispatchInfo.m_timeOfImpact = toi;
+
+				}
+			}
+		}
+
+}
+
+
+void* btCollisionDispatcher::allocateCollisionAlgorithm(int size)
+{
+	if (m_collisionAlgorithmPoolAllocator->getFreeCount())
+	{
+		return m_collisionAlgorithmPoolAllocator->allocate(size);
+	}
+	
+	//warn user for overflow?
+	return	btAlignedAlloc(static_cast<size_t>(size), 16);
+}
+
+void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr)
+{
+	if (m_collisionAlgorithmPoolAllocator->validPtr(ptr))
+	{
+		m_collisionAlgorithmPoolAllocator->freeMemory(ptr);
+	} else
+	{
+		btAlignedFree(ptr);
+	}
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.h	(revision 2122)
@@ -0,0 +1,147 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COLLISION__DISPATCHER_H
+#define COLLISION__DISPATCHER_H
+
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+
+#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
+
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+class btIDebugDraw;
+class btOverlappingPairCache;
+class btPoolAllocator;
+class btCollisionConfiguration;
+
+#include "btCollisionCreateFunc.h"
+
+#define USE_DISPATCH_REGISTRY_ARRAY 1
+
+class btCollisionDispatcher;
+///user can override this nearcallback for collision filtering and more finegrained control over collision detection
+typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
+
+
+///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
+///Time of Impact, Closest Points and Penetration Depth.
+class btCollisionDispatcher : public btDispatcher
+{
+	int m_count;
+	
+	btAlignedObjectArray<btPersistentManifold*>	m_manifoldsPtr;
+
+	bool m_useIslands;
+
+	bool	m_staticWarningReported;
+	
+	btManifoldResult	m_defaultManifoldResult;
+
+	btNearCallback		m_nearCallback;
+	
+	btPoolAllocator*	m_collisionAlgorithmPoolAllocator;
+
+	btPoolAllocator*	m_persistentManifoldPoolAllocator;
+
+	btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
+	
+
+	btCollisionConfiguration*	m_collisionConfiguration;
+
+
+public:
+
+	///registerCollisionCreateFunc allows registration of custom/alternative collision create functions
+	void	registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
+
+	int	getNumManifolds() const
+	{ 
+		return int( m_manifoldsPtr.size());
+	}
+
+	btPersistentManifold**	getInternalManifoldPointer()
+	{
+		return &m_manifoldsPtr[0];
+	}
+
+	 btPersistentManifold* getManifoldByIndexInternal(int index)
+	{
+		return m_manifoldsPtr[index];
+	}
+
+	 const btPersistentManifold* getManifoldByIndexInternal(int index) const
+	{
+		return m_manifoldsPtr[index];
+	}
+
+	btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration);
+
+	virtual ~btCollisionDispatcher();
+
+	virtual btPersistentManifold*	getNewManifold(void* b0,void* b1);
+	
+	virtual void releaseManifold(btPersistentManifold* manifold);
+
+
+	virtual void clearManifold(btPersistentManifold* manifold);
+
+			
+	btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
+		
+	virtual bool	needsCollision(btCollisionObject* body0,btCollisionObject* body1);
+	
+	virtual bool	needsResponse(btCollisionObject* body0,btCollisionObject* body1);
+	
+	virtual void	dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
+
+	void	setNearCallback(btNearCallback	nearCallback)
+	{
+		m_nearCallback = nearCallback; 
+	}
+
+	btNearCallback	getNearCallback() const
+	{
+		return m_nearCallback;
+	}
+
+	//by default, Bullet will use this near callback
+	static void  defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
+
+	virtual	void* allocateCollisionAlgorithm(int size);
+
+	virtual	void freeCollisionAlgorithm(void* ptr);
+
+	btCollisionConfiguration*	getCollisionConfiguration()
+	{
+		return m_collisionConfiguration;
+	}
+
+	const btCollisionConfiguration*	getCollisionConfiguration() const
+	{
+		return m_collisionConfiguration;
+	}
+
+	void	setCollisionConfiguration(btCollisionConfiguration* config)
+	{
+		m_collisionConfiguration = config;
+	}
+
+};
+
+#endif //COLLISION__DISPATCHER_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp	(revision 2122)
@@ -0,0 +1,65 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btCollisionObject.h"
+
+btCollisionObject::btCollisionObject()
+	:	m_broadphaseHandle(0),
+		m_collisionShape(0),
+		m_rootCollisionShape(0),
+		m_collisionFlags(btCollisionObject::CF_STATIC_OBJECT),
+		m_islandTag1(-1),
+		m_companionId(-1),
+		m_activationState1(1),
+		m_deactivationTime(btScalar(0.)),
+		m_friction(btScalar(0.5)),
+		m_restitution(btScalar(0.)),
+		m_userObjectPointer(0),
+		m_internalType(CO_COLLISION_OBJECT),
+		m_hitFraction(btScalar(1.)),
+		m_ccdSweptSphereRadius(btScalar(0.)),
+		m_ccdMotionThreshold(btScalar(0.)),
+		m_checkCollideWith(false)
+{
+	
+}
+
+btCollisionObject::~btCollisionObject()
+{
+}
+
+void btCollisionObject::setActivationState(int newState) 
+{ 
+	if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION))
+		m_activationState1 = newState;
+}
+
+void btCollisionObject::forceActivationState(int newState)
+{
+	m_activationState1 = newState;
+}
+
+void btCollisionObject::activate(bool forceActivation)
+{
+	if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
+	{
+		setActivationState(ACTIVE_TAG);
+		m_deactivationTime = btScalar(0.);
+	}
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h	(revision 2122)
@@ -0,0 +1,384 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COLLISION_OBJECT_H
+#define COLLISION_OBJECT_H
+
+#include "LinearMath/btTransform.h"
+
+//island management, m_activationState1
+#define ACTIVE_TAG 1
+#define ISLAND_SLEEPING 2
+#define WANTS_DEACTIVATION 3
+#define DISABLE_DEACTIVATION 4
+#define DISABLE_SIMULATION 5
+
+struct	btBroadphaseProxy;
+class	btCollisionShape;
+#include "LinearMath/btMotionState.h"
+#include "LinearMath/btAlignedAllocator.h"
+
+
+
+/// btCollisionObject can be used to manage collision detection objects. 
+/// btCollisionObject maintains all information that is needed for a collision detection: Shape, Transform and AABB proxy.
+/// They can be added to the btCollisionWorld.
+ATTRIBUTE_ALIGNED16(class)	btCollisionObject
+{
+
+protected:
+
+	btTransform	m_worldTransform;
+
+	///m_interpolationWorldTransform is used for CCD and interpolation
+	///it can be either previous or future (predicted) transform
+	btTransform	m_interpolationWorldTransform;
+	//those two are experimental: just added for bullet time effect, so you can still apply impulses (directly modifying velocities) 
+	//without destroying the continuous interpolated motion (which uses this interpolation velocities)
+	btVector3	m_interpolationLinearVelocity;
+	btVector3	m_interpolationAngularVelocity;
+	btBroadphaseProxy*		m_broadphaseHandle;
+	btCollisionShape*		m_collisionShape;
+	
+	///m_rootCollisionShape is temporarily used to store the original collision shape
+	///The m_collisionShape might be temporarily replaced by a child collision shape during collision detection purposes
+	///If it is NULL, the m_collisionShape is not temporarily replaced.
+	btCollisionShape*		m_rootCollisionShape;
+
+	int				m_collisionFlags;
+
+	int				m_islandTag1;
+	int				m_companionId;
+
+	int				m_activationState1;
+	btScalar			m_deactivationTime;
+
+	btScalar		m_friction;
+	btScalar		m_restitution;
+
+	///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer
+	void*			m_userObjectPointer;
+
+	///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody etc.
+	///do not assign your own m_internalType unless you write a new dynamics object class.
+	int				m_internalType;
+
+	///time of impact calculation
+	btScalar		m_hitFraction; 
+	
+	///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
+	btScalar		m_ccdSweptSphereRadius;
+
+	/// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
+	btScalar		m_ccdMotionThreshold;
+	
+	/// If some object should have elaborate collision filtering by sub-classes
+	bool			m_checkCollideWith;
+
+	char	m_pad[7];
+
+	virtual bool	checkCollideWithOverride(btCollisionObject* /* co */)
+	{
+		return true;
+	}
+
+public:
+
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	enum CollisionFlags
+	{
+		CF_STATIC_OBJECT= 1,
+		CF_KINEMATIC_OBJECT= 2,
+		CF_NO_CONTACT_RESPONSE = 4,
+		CF_CUSTOM_MATERIAL_CALLBACK = 8//this allows per-triangle material (friction/restitution)
+	};
+
+	enum	CollisionObjectTypes
+	{
+		CO_COLLISION_OBJECT =1,
+		CO_RIGID_BODY,
+		CO_SOFT_BODY
+	};
+
+	SIMD_FORCE_INLINE bool mergesSimulationIslands() const
+	{
+		///static objects, kinematic and object without contact response don't merge islands
+		return  ((m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATIC_OBJECT | CF_NO_CONTACT_RESPONSE) )==0);
+	}
+
+
+	SIMD_FORCE_INLINE bool		isStaticObject() const {
+		return (m_collisionFlags & CF_STATIC_OBJECT) != 0;
+	}
+
+	SIMD_FORCE_INLINE bool		isKinematicObject() const
+	{
+		return (m_collisionFlags & CF_KINEMATIC_OBJECT) != 0;
+	}
+
+	SIMD_FORCE_INLINE bool		isStaticOrKinematicObject() const
+	{
+		return (m_collisionFlags & (CF_KINEMATIC_OBJECT | CF_STATIC_OBJECT)) != 0 ;
+	}
+
+	SIMD_FORCE_INLINE bool		hasContactResponse() const {
+		return (m_collisionFlags & CF_NO_CONTACT_RESPONSE)==0;
+	}
+
+	
+	btCollisionObject();
+
+	virtual ~btCollisionObject();
+
+	virtual void	setCollisionShape(btCollisionShape* collisionShape)
+	{
+		m_collisionShape = collisionShape;
+		m_rootCollisionShape = collisionShape;
+	}
+
+	SIMD_FORCE_INLINE const btCollisionShape*	getCollisionShape() const
+	{
+		return m_collisionShape;
+	}
+
+	SIMD_FORCE_INLINE btCollisionShape*	getCollisionShape()
+	{
+		return m_collisionShape;
+	}
+
+	SIMD_FORCE_INLINE const btCollisionShape*	getRootCollisionShape() const
+	{
+		return m_rootCollisionShape;
+	}
+
+	SIMD_FORCE_INLINE btCollisionShape*	getRootCollisionShape()
+	{
+		return m_rootCollisionShape;
+	}
+
+	///Avoid using this internal API call
+	///internalSetTemporaryCollisionShape is used to temporary replace the actual collision shape by a child collision shape.
+	void	internalSetTemporaryCollisionShape(btCollisionShape* collisionShape)
+	{
+		m_collisionShape = collisionShape;
+	}
+
+	int	getActivationState() const { return m_activationState1;}
+	
+	void setActivationState(int newState);
+
+	void	setDeactivationTime(btScalar time)
+	{
+		m_deactivationTime = time;
+	}
+	btScalar	getDeactivationTime() const
+	{
+		return m_deactivationTime;
+	}
+
+	void forceActivationState(int newState);
+
+	void	activate(bool forceActivation = false);
+
+	inline bool isActive() const
+	{
+		return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION));
+	}
+
+	void	setRestitution(btScalar rest)
+	{
+		m_restitution = rest;
+	}
+	btScalar	getRestitution() const
+	{
+		return m_restitution;
+	}
+	void	setFriction(btScalar frict)
+	{
+		m_friction = frict;
+	}
+	btScalar	getFriction() const
+	{
+		return m_friction;
+	}
+
+	///reserved for Bullet internal usage
+	int	getInternalType() const
+	{
+		return m_internalType;
+	}
+
+	btTransform&	getWorldTransform()
+	{
+		return m_worldTransform;
+	}
+
+	const btTransform&	getWorldTransform() const
+	{
+		return m_worldTransform;
+	}
+
+	void	setWorldTransform(const btTransform& worldTrans)
+	{
+		m_worldTransform = worldTrans;
+	}
+
+
+	btBroadphaseProxy*	getBroadphaseHandle()
+	{
+		return m_broadphaseHandle;
+	}
+
+	const btBroadphaseProxy*	getBroadphaseHandle() const
+	{
+		return m_broadphaseHandle;
+	}
+
+	void	setBroadphaseHandle(btBroadphaseProxy* handle)
+	{
+		m_broadphaseHandle = handle;
+	}
+
+
+	const btTransform&	getInterpolationWorldTransform() const
+	{
+		return m_interpolationWorldTransform;
+	}
+
+	btTransform&	getInterpolationWorldTransform()
+	{
+		return m_interpolationWorldTransform;
+	}
+
+	void	setInterpolationWorldTransform(const btTransform&	trans)
+	{
+		m_interpolationWorldTransform = trans;
+	}
+
+	void	setInterpolationLinearVelocity(const btVector3& linvel)
+	{
+		m_interpolationLinearVelocity = linvel;
+	}
+
+	void	setInterpolationAngularVelocity(const btVector3& angvel)
+	{
+		m_interpolationAngularVelocity = angvel;
+	}
+
+	const btVector3&	getInterpolationLinearVelocity() const
+	{
+		return m_interpolationLinearVelocity;
+	}
+
+	const btVector3&	getInterpolationAngularVelocity() const
+	{
+		return m_interpolationAngularVelocity;
+	}
+
+	const int getIslandTag() const
+	{
+		return	m_islandTag1;
+	}
+
+	void	setIslandTag(int tag)
+	{
+		m_islandTag1 = tag;
+	}
+
+	const int getCompanionId() const
+	{
+		return	m_companionId;
+	}
+
+	void	setCompanionId(int id)
+	{
+		m_companionId = id;
+	}
+
+	const btScalar			getHitFraction() const
+	{
+		return m_hitFraction; 
+	}
+
+	void	setHitFraction(btScalar hitFraction)
+	{
+		m_hitFraction = hitFraction;
+	}
+
+	
+	const int	getCollisionFlags() const
+	{
+		return m_collisionFlags;
+	}
+
+	void	setCollisionFlags(int flags)
+	{
+		m_collisionFlags = flags;
+	}
+	
+	///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
+	btScalar			getCcdSweptSphereRadius() const
+	{
+		return m_ccdSweptSphereRadius;
+	}
+
+	///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
+	void	setCcdSweptSphereRadius(btScalar radius)
+	{
+		m_ccdSweptSphereRadius = radius;
+	}
+
+	btScalar 	getCcdMotionThreshold() const
+	{
+		return m_ccdMotionThreshold;
+	}
+
+	btScalar 	getCcdSquareMotionThreshold() const
+	{
+		return m_ccdMotionThreshold*m_ccdMotionThreshold;
+	}
+
+
+
+	/// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
+	void	setCcdMotionThreshold(btScalar ccdMotionThreshold)
+	{
+		m_ccdMotionThreshold = ccdMotionThreshold*ccdMotionThreshold;
+	}
+
+	///users can point to their objects, userPointer is not used by Bullet
+	void*	getUserPointer() const
+	{
+		return m_userObjectPointer;
+	}
+	
+	///users can point to their objects, userPointer is not used by Bullet
+	void	setUserPointer(void* userPointer)
+	{
+		m_userObjectPointer = userPointer;
+	}
+
+
+	inline bool checkCollideWith(btCollisionObject* co)
+	{
+		if (m_checkCollideWith)
+			return checkCollideWithOverride(co);
+
+		return true;
+	}
+};
+
+#endif //COLLISION_OBJECT_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp	(revision 2122)
@@ -0,0 +1,684 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btCollisionWorld.h"
+#include "btCollisionDispatcher.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h" //for raycasting
+#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" //for raycasting
+#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
+#include "BulletCollision/CollisionShapes/btCompoundShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
+#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
+
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+#include "LinearMath/btAabbUtil2.h"
+#include "LinearMath/btQuickprof.h"
+#include "LinearMath/btStackAlloc.h"
+
+
+//When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor)
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
+#include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
+
+
+btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache, btCollisionConfiguration* collisionConfiguration)
+:m_dispatcher1(dispatcher),
+m_broadphasePairCache(pairCache),
+m_debugDrawer(0)
+{
+	m_stackAlloc = collisionConfiguration->getStackAllocator();
+	m_dispatchInfo.m_stackAllocator = m_stackAlloc;
+}
+
+
+btCollisionWorld::~btCollisionWorld()
+{
+
+	//clean up remaining objects
+	int i;
+	for (i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* collisionObject= m_collisionObjects[i];
+
+		btBroadphaseProxy* bp = collisionObject->getBroadphaseHandle();
+		if (bp)
+		{
+			//
+			// only clear the cached algorithms
+			//
+			getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
+			getBroadphase()->destroyProxy(bp,m_dispatcher1);
+		}
+	}
+
+
+}
+
+
+
+
+
+
+
+
+
+
+void	btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
+{
+
+	//check that the object isn't already added
+		btAssert( m_collisionObjects.findLinearSearch(collisionObject)  == m_collisionObjects.size());
+
+		m_collisionObjects.push_back(collisionObject);
+
+		//calculate new AABB
+		btTransform trans = collisionObject->getWorldTransform();
+
+		btVector3	minAabb;
+		btVector3	maxAabb;
+		collisionObject->getCollisionShape()->getAabb(trans,minAabb,maxAabb);
+
+		int type = collisionObject->getCollisionShape()->getShapeType();
+		collisionObject->setBroadphaseHandle( getBroadphase()->createProxy(
+			minAabb,
+			maxAabb,
+			type,
+			collisionObject,
+			collisionFilterGroup,
+			collisionFilterMask,
+			m_dispatcher1,0
+			))	;
+
+
+
+
+
+}
+
+void	btCollisionWorld::updateAabbs()
+{
+	BT_PROFILE("updateAabbs");
+
+	btTransform predictedTrans;
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+
+		//only update aabb of active objects
+		if (colObj->isActive())
+		{
+			btPoint3 minAabb,maxAabb;
+			colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
+			//need to increase the aabb for contact thresholds
+			btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
+			minAabb -= contactThreshold;
+			maxAabb += contactThreshold;
+
+			btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
+
+			//moving objects should be moderately sized, probably something wrong if not
+			if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
+			{
+				bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
+			} else
+			{
+				//something went wrong, investigate
+				//this assert is unwanted in 3D modelers (danger of loosing work)
+				colObj->setActivationState(DISABLE_SIMULATION);
+
+				static bool reportMe = true;
+				if (reportMe && m_debugDrawer)
+				{
+					reportMe = false;
+					m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
+					m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
+					m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
+					m_debugDrawer->reportErrorWarning("Thanks.\n");
+				}
+			}
+		}
+	}
+
+}
+
+
+
+void	btCollisionWorld::performDiscreteCollisionDetection()
+{
+	BT_PROFILE("performDiscreteCollisionDetection");
+
+	btDispatcherInfo& dispatchInfo = getDispatchInfo();
+
+	updateAabbs();
+
+	{
+		BT_PROFILE("calculateOverlappingPairs");
+		m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1);
+	}
+
+
+	btDispatcher* dispatcher = getDispatcher();
+	{
+		BT_PROFILE("dispatchAllCollisionPairs");
+		if (dispatcher)
+			dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1);
+	}
+
+}
+
+
+
+void	btCollisionWorld::removeCollisionObject(btCollisionObject* collisionObject)
+{
+
+
+	//bool removeFromBroadphase = false;
+
+	{
+
+		btBroadphaseProxy* bp = collisionObject->getBroadphaseHandle();
+		if (bp)
+		{
+			//
+			// only clear the cached algorithms
+			//
+			getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
+			getBroadphase()->destroyProxy(bp,m_dispatcher1);
+			collisionObject->setBroadphaseHandle(0);
+		}
+	}
+
+
+	//swapremove
+	m_collisionObjects.remove(collisionObject);
+
+}
+
+
+
+void	btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
+					  btCollisionObject* collisionObject,
+					  const btCollisionShape* collisionShape,
+					  const btTransform& colObjWorldTransform,
+					  RayResultCallback& resultCallback)
+{
+	btSphereShape pointShape(btScalar(0.0));
+	pointShape.setMargin(0.f);
+	const btConvexShape* castShape = &pointShape;
+
+	if (collisionShape->isConvex())
+	{
+		btConvexCast::CastResult castResult;
+		castResult.m_fraction = resultCallback.m_closestHitFraction;
+
+		btConvexShape* convexShape = (btConvexShape*) collisionShape;
+		btVoronoiSimplexSolver	simplexSolver;
+#define USE_SUBSIMPLEX_CONVEX_CAST 1
+#ifdef USE_SUBSIMPLEX_CONVEX_CAST
+		btSubsimplexConvexCast convexCaster(castShape,convexShape,&simplexSolver);
+#else
+		//btGjkConvexCast	convexCaster(castShape,convexShape,&simplexSolver);
+		//btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
+#endif //#USE_SUBSIMPLEX_CONVEX_CAST
+
+		if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
+		{
+			//add hit
+			if (castResult.m_normal.length2() > btScalar(0.0001))
+			{
+				if (castResult.m_fraction < resultCallback.m_closestHitFraction)
+				{
+#ifdef USE_SUBSIMPLEX_CONVEX_CAST
+					//rotate normal into worldspace
+					castResult.m_normal = rayFromTrans.getBasis() * castResult.m_normal;
+#endif //USE_SUBSIMPLEX_CONVEX_CAST
+
+					castResult.m_normal.normalize();
+					btCollisionWorld::LocalRayResult localRayResult
+						(
+							collisionObject,
+							0,
+							castResult.m_normal,
+							castResult.m_fraction
+						);
+
+					bool normalInWorldSpace = true;
+					resultCallback.addSingleResult(localRayResult, normalInWorldSpace);
+
+				}
+			}
+		}
+	} else {
+		if (collisionShape->isConcave())
+		{
+			if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
+			{
+				///optimized version for btBvhTriangleMeshShape
+				btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
+				btTransform worldTocollisionObject = colObjWorldTransform.inverse();
+				btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
+				btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
+
+				//ConvexCast::CastResult
+				struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
+				{
+					btCollisionWorld::RayResultCallback* m_resultCallback;
+					btCollisionObject*	m_collisionObject;
+					btTriangleMeshShape*	m_triangleMesh;
+
+					BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
+						btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*	triangleMesh):
+						btTriangleRaycastCallback(from,to),
+							m_resultCallback(resultCallback),
+							m_collisionObject(collisionObject),
+							m_triangleMesh(triangleMesh)
+						{
+						}
+
+
+					virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
+					{
+						btCollisionWorld::LocalShapeInfo	shapeInfo;
+						shapeInfo.m_shapePart = partId;
+						shapeInfo.m_triangleIndex = triangleIndex;
+
+						btCollisionWorld::LocalRayResult rayResult
+						(m_collisionObject,
+							&shapeInfo,
+							hitNormalLocal,
+							hitFraction);
+
+						bool	normalInWorldSpace = false;
+						return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace);
+					}
+
+				};
+
+				BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,triangleMesh);
+				rcb.m_hitFraction = resultCallback.m_closestHitFraction;
+				triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal);
+			} else
+			{
+				btTriangleMeshShape* triangleMesh = (btTriangleMeshShape*)collisionShape;
+
+				btTransform worldTocollisionObject = colObjWorldTransform.inverse();
+
+				btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
+				btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
+
+				//ConvexCast::CastResult
+
+				struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
+				{
+					btCollisionWorld::RayResultCallback* m_resultCallback;
+					btCollisionObject*	m_collisionObject;
+					btTriangleMeshShape*	m_triangleMesh;
+
+					BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
+						btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*	triangleMesh):
+						btTriangleRaycastCallback(from,to),
+							m_resultCallback(resultCallback),
+							m_collisionObject(collisionObject),
+							m_triangleMesh(triangleMesh)
+						{
+						}
+
+
+					virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
+					{
+						btCollisionWorld::LocalShapeInfo	shapeInfo;
+						shapeInfo.m_shapePart = partId;
+						shapeInfo.m_triangleIndex = triangleIndex;
+
+						btCollisionWorld::LocalRayResult rayResult
+						(m_collisionObject,
+							&shapeInfo,
+							hitNormalLocal,
+							hitFraction);
+
+						bool	normalInWorldSpace = false;
+						return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace);
+
+
+					}
+
+				};
+
+
+				BridgeTriangleRaycastCallback	rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,triangleMesh);
+				rcb.m_hitFraction = resultCallback.m_closestHitFraction;
+
+				btVector3 rayAabbMinLocal = rayFromLocal;
+				rayAabbMinLocal.setMin(rayToLocal);
+				btVector3 rayAabbMaxLocal = rayFromLocal;
+				rayAabbMaxLocal.setMax(rayToLocal);
+
+				triangleMesh->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);
+			}
+		} else {
+			//todo: use AABB tree or other BVH acceleration structure!
+			if (collisionShape->isCompound())
+			{
+				const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
+				int i=0;
+				for (i=0;i<compoundShape->getNumChildShapes();i++)
+				{
+					btTransform childTrans = compoundShape->getChildTransform(i);
+					const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
+					btTransform childWorldTrans = colObjWorldTransform * childTrans;
+					// replace collision shape so that callback can determine the triangle
+					btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape();
+					collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
+					rayTestSingle(rayFromTrans,rayToTrans,
+						collisionObject,
+						childCollisionShape,
+						childWorldTrans,
+						resultCallback);
+					// restore
+					collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
+				}
+			}
+		}
+	}
+}
+
+void	btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const btTransform& convexFromTrans,const btTransform& convexToTrans,
+					  btCollisionObject* collisionObject,
+					  const btCollisionShape* collisionShape,
+					  const btTransform& colObjWorldTransform,
+					  ConvexResultCallback& resultCallback, btScalar allowedPenetration)
+{
+	if (collisionShape->isConvex())
+	{
+		btConvexCast::CastResult castResult;
+		castResult.m_allowedPenetration = allowedPenetration;
+		castResult.m_fraction = btScalar(1.);//??
+
+		btConvexShape* convexShape = (btConvexShape*) collisionShape;
+		btVoronoiSimplexSolver	simplexSolver;
+		btGjkEpaPenetrationDepthSolver	gjkEpaPenetrationSolver;
+		
+		btContinuousConvexCollision convexCaster1(castShape,convexShape,&simplexSolver,&gjkEpaPenetrationSolver);
+		//btGjkConvexCast convexCaster2(castShape,convexShape,&simplexSolver);
+		//btSubsimplexConvexCast convexCaster3(castShape,convexShape,&simplexSolver);
+
+		btConvexCast* castPtr = &convexCaster1;
+	
+	
+		
+		if (castPtr->calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
+		{
+			//add hit
+			if (castResult.m_normal.length2() > btScalar(0.0001))
+			{
+				if (castResult.m_fraction < resultCallback.m_closestHitFraction)
+				{
+					castResult.m_normal.normalize();
+					btCollisionWorld::LocalConvexResult localConvexResult
+								(
+									collisionObject,
+									0,
+									castResult.m_normal,
+									castResult.m_hitPoint,
+									castResult.m_fraction
+								);
+
+					bool normalInWorldSpace = true;
+					resultCallback.addSingleResult(localConvexResult, normalInWorldSpace);
+
+				}
+			}
+		}
+	} else {
+		if (collisionShape->isConcave())
+		{
+			if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
+			{
+				btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
+				btTransform worldTocollisionObject = colObjWorldTransform.inverse();
+				btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
+				btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
+				// rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
+				btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
+
+				//ConvexCast::CastResult
+				struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
+				{
+					btCollisionWorld::ConvexResultCallback* m_resultCallback;
+					btCollisionObject*	m_collisionObject;
+					btTriangleMeshShape*	m_triangleMesh;
+
+					BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
+						btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*	triangleMesh, const btTransform& triangleToWorld):
+						btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
+							m_resultCallback(resultCallback),
+							m_collisionObject(collisionObject),
+							m_triangleMesh(triangleMesh)
+						{
+						}
+
+
+					virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex )
+					{
+						btCollisionWorld::LocalShapeInfo	shapeInfo;
+						shapeInfo.m_shapePart = partId;
+						shapeInfo.m_triangleIndex = triangleIndex;
+						if (hitFraction <= m_resultCallback->m_closestHitFraction)
+						{
+
+							btCollisionWorld::LocalConvexResult convexResult
+							(m_collisionObject,
+								&shapeInfo,
+								hitNormalLocal,
+								hitPointLocal,
+								hitFraction);
+
+							bool	normalInWorldSpace = true;
+
+
+							return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
+						}
+						return hitFraction;
+					}
+
+				};
+
+				BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform);
+				tccb.m_hitFraction = resultCallback.m_closestHitFraction;
+				btVector3 boxMinLocal, boxMaxLocal;
+				castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal);
+				triangleMesh->performConvexcast(&tccb,convexFromLocal,convexToLocal,boxMinLocal, boxMaxLocal);
+			} else
+			{
+				btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
+				btTransform worldTocollisionObject = colObjWorldTransform.inverse();
+				btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
+				btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
+				// rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
+				btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
+
+				//ConvexCast::CastResult
+				struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
+				{
+					btCollisionWorld::ConvexResultCallback* m_resultCallback;
+					btCollisionObject*	m_collisionObject;
+					btTriangleMeshShape*	m_triangleMesh;
+
+					BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
+						btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*	triangleMesh, const btTransform& triangleToWorld):
+						btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
+							m_resultCallback(resultCallback),
+							m_collisionObject(collisionObject),
+							m_triangleMesh(triangleMesh)
+						{
+						}
+
+
+					virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex )
+					{
+						btCollisionWorld::LocalShapeInfo	shapeInfo;
+						shapeInfo.m_shapePart = partId;
+						shapeInfo.m_triangleIndex = triangleIndex;
+						if (hitFraction <= m_resultCallback->m_closestHitFraction)
+						{
+
+							btCollisionWorld::LocalConvexResult convexResult
+							(m_collisionObject,
+								&shapeInfo,
+								hitNormalLocal,
+								hitPointLocal,
+								hitFraction);
+
+							bool	normalInWorldSpace = false;
+
+							return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
+						}
+						return hitFraction;
+					}
+
+				};
+
+				BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform);
+				tccb.m_hitFraction = resultCallback.m_closestHitFraction;
+				btVector3 boxMinLocal, boxMaxLocal;
+				castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal);
+
+				btVector3 rayAabbMinLocal = convexFromLocal;
+				rayAabbMinLocal.setMin(convexToLocal);
+				btVector3 rayAabbMaxLocal = convexFromLocal;
+				rayAabbMaxLocal.setMax(convexToLocal);
+				rayAabbMinLocal += boxMinLocal;
+				rayAabbMaxLocal += boxMaxLocal;
+				triangleMesh->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);
+			}
+		} else {
+			//todo: use AABB tree or other BVH acceleration structure!
+			if (collisionShape->isCompound())
+			{
+				const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
+				int i=0;
+				for (i=0;i<compoundShape->getNumChildShapes();i++)
+				{
+					btTransform childTrans = compoundShape->getChildTransform(i);
+					const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
+					btTransform childWorldTrans = colObjWorldTransform * childTrans;
+					// replace collision shape so that callback can determine the triangle
+					btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape();
+					collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
+					objectQuerySingle(castShape, convexFromTrans,convexToTrans,
+						collisionObject,
+						childCollisionShape,
+						childWorldTrans,
+						resultCallback, allowedPenetration);
+					// restore
+					collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
+				}
+			}
+		}
+	}
+}
+
+void	btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const
+{
+
+
+	btTransform	rayFromTrans,rayToTrans;
+	rayFromTrans.setIdentity();
+	rayFromTrans.setOrigin(rayFromWorld);
+	rayToTrans.setIdentity();
+
+	rayToTrans.setOrigin(rayToWorld);
+
+	/// go over all objects, and if the ray intersects their aabb, do a ray-shape query using convexCaster (CCD)
+
+	int i;
+	for (i=0;i<m_collisionObjects.size();i++)
+	{
+		///terminate further ray tests, once the closestHitFraction reached zero
+		if (resultCallback.m_closestHitFraction == btScalar(0.f))
+			break;
+
+		btCollisionObject*	collisionObject= m_collisionObjects[i];
+		//only perform raycast if filterMask matches
+		if(resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
+			//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
+			btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
+			collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
+
+			btScalar hitLambda = resultCallback.m_closestHitFraction;
+			btVector3 hitNormal;
+			if (btRayAabb(rayFromWorld,rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
+			{
+				rayTestSingle(rayFromTrans,rayToTrans,
+					collisionObject,
+						collisionObject->getCollisionShape(),
+						collisionObject->getWorldTransform(),
+						resultCallback);
+			}
+		}
+
+	}
+
+}
+
+void	btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, ConvexResultCallback& resultCallback) const
+{
+	btTransform	convexFromTrans,convexToTrans;
+	convexFromTrans = convexFromWorld;
+	convexToTrans = convexToWorld;
+	btVector3 castShapeAabbMin, castShapeAabbMax;
+	/* Compute AABB that encompasses angular movement */
+	{
+		btVector3 linVel, angVel;
+		btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0, linVel, angVel);
+		btTransform R;
+		R.setIdentity ();
+		R.setRotation (convexFromTrans.getRotation());
+		castShape->calculateTemporalAabb (R, linVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax);
+	}
+
+	/// go over all objects, and if the ray intersects their aabb + cast shape aabb,
+	// do a ray-shape query using convexCaster (CCD)
+	int i;
+	for (i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject*	collisionObject= m_collisionObjects[i];
+		//only perform raycast if filterMask matches
+		if(resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
+			//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
+			btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
+			collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
+			AabbExpand (collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
+			btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
+			btVector3 hitNormal;
+			if (btRayAabb(convexFromWorld.getOrigin(),convexToWorld.getOrigin(),collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
+			{
+				objectQuerySingle(castShape, convexFromTrans,convexToTrans,
+					collisionObject,
+						collisionObject->getCollisionShape(),
+						collisionObject->getWorldTransform(),
+						resultCallback,
+						getDispatchInfo().m_allowedCcdPenetration);
+			}
+		}
+	}
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h	(revision 2122)
@@ -0,0 +1,399 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+/**
+ * @mainpage Bullet Documentation
+ *
+ * @section intro_sec Introduction
+ * Bullet Collision Detection & Physics SDK
+ *
+ * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ).
+ *
+ * There is the Physics Forum for Feedback and bteral Collision Detection and Physics discussions.
+ * Please visit http://www.continuousphysics.com/Bullet/phpBB2/index.php
+ *
+ * @section install_sec Installation
+ *
+ * @subsection step1 Step 1: Download
+ * You can download the Bullet Physics Library from our website: http://www.continuousphysics.com/Bullet/
+ * @subsection step2 Step 2: Building
+ * Bullet comes with autogenerated Project Files for Microsoft Visual Studio 6, 7, 7.1 and 8.
+ * The main Workspace/Solution is located in Bullet/msvc/8/wksbullet.sln (replace 8 with your version).
+ * 
+ * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org, or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet.
+ * So if you are not using MSVC or cmake, you can run ./autogen.sh ./configure to create both Makefile and Jamfile and then run make or jam.
+ * Jam is a build system that can build the library, demos and also autogenerate the MSVC Project Files.
+ * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/pub/jam/
+ * 
+ * @subsection step3 Step 3: Testing demos
+ * Try to run and experiment with BasicDemo executable as a starting point.
+ * Bullet can be used in several ways, as Full Rigid Body simulation, as Collision Detector Library or Low Level / Snippets like the GJK Closest Point calculation.
+ * The Dependencies can be seen in this documentation under Directories
+ * 
+ * @subsection step4 Step 4: Integrating in your application, full Rigid Body and Soft Body simulation
+ * Check out BasicDemo how to create a btDynamicsWorld, btRigidBody and btCollisionShape, Stepping the simulation and synchronizing your graphics object transform.
+ * Check out SoftDemo how to use soft body dynamics, using btSoftRigidDynamicsWorld.
+ * @subsection step5 Step 5 : Integrate the Collision Detection Library (without Dynamics and other Extras)
+ * Bullet Collision Detection can also be used without the Dynamics/Extras.
+ * Check out btCollisionWorld and btCollisionObject, and the CollisionInterfaceDemo.
+ * @subsection step6 Step 6 : Use Snippets like the GJK Closest Point calculation.
+ * Bullet has been designed in a modular way keeping dependencies to a minimum. The ConvexHullDistance demo demonstrates direct use of btGjkPairDetector.
+ *
+ * @section copyright Copyright
+ * Copyright (C) 2005-2008 Erwin Coumans, some contributions Copyright Gino van den Bergen, Christer Ericson, Simon Hobbs, Ricardo Padrela, F Richter(res), Stephane Redon
+ * Special thanks to all visitors of the Bullet Physics forum, and in particular above contributors, John McCutchan, Nathanael Presson, Dave Eberle, Dirk Gregorius, Erin Catto, Dave Eberle, Adam Moravanszky,
+ * Pierre Terdiman, Kenny Erleben, Russell Smith, Oliver Strunk, Jan Paul van Waveren, Marten Svanfeldt.
+ * 
+ */
+ 
+ 
+
+#ifndef COLLISION_WORLD_H
+#define COLLISION_WORLD_H
+
+class btStackAlloc;
+class btCollisionShape;
+class btConvexShape;
+class btBroadphaseInterface;
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+#include "btCollisionObject.h"
+#include "btCollisionDispatcher.h" //for definition of btCollisionObjectArray
+#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+///CollisionWorld is interface and container for the collision detection
+class btCollisionWorld
+{
+
+	
+protected:
+
+	btAlignedObjectArray<btCollisionObject*>	m_collisionObjects;
+	
+	btDispatcher*	m_dispatcher1;
+
+	btDispatcherInfo	m_dispatchInfo;
+
+	btStackAlloc*	m_stackAlloc;
+
+	btBroadphaseInterface*	m_broadphasePairCache;
+
+	btIDebugDraw*	m_debugDrawer;
+
+	
+public:
+
+	//this constructor doesn't own the dispatcher and paircache/broadphase
+	btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphasePairCache, btCollisionConfiguration* collisionConfiguration);
+
+	virtual ~btCollisionWorld();
+
+	void	setBroadphase(btBroadphaseInterface*	pairCache)
+	{
+		m_broadphasePairCache = pairCache;
+	}
+
+	btBroadphaseInterface*	getBroadphase()
+	{
+		return m_broadphasePairCache;
+	}
+
+	btOverlappingPairCache*	getPairCache()
+	{
+		return m_broadphasePairCache->getOverlappingPairCache();
+	}
+
+
+	btDispatcher*	getDispatcher()
+	{
+		return m_dispatcher1;
+	}
+
+	const btDispatcher*	getDispatcher() const
+	{
+		return m_dispatcher1;
+	}
+
+	virtual void	updateAabbs();
+
+	virtual void	setDebugDrawer(btIDebugDraw*	debugDrawer)
+	{
+			m_debugDrawer = debugDrawer;
+	}
+
+	virtual btIDebugDraw*	getDebugDrawer()
+	{
+		return m_debugDrawer;
+	}
+
+
+	///LocalShapeInfo gives extra information for complex shapes
+	///Currently, only btTriangleMeshShape is available, so it just contains triangleIndex and subpart
+	struct	LocalShapeInfo
+	{
+		int	m_shapePart;
+		int	m_triangleIndex;
+		
+		//const btCollisionShape*	m_shapeTemp;
+		//const btTransform*	m_shapeLocalTransform;
+	};
+
+	struct	LocalRayResult
+	{
+		LocalRayResult(btCollisionObject*	collisionObject, 
+			LocalShapeInfo*	localShapeInfo,
+			const btVector3&		hitNormalLocal,
+			btScalar hitFraction)
+		:m_collisionObject(collisionObject),
+		m_localShapeInfo(localShapeInfo),
+		m_hitNormalLocal(hitNormalLocal),
+		m_hitFraction(hitFraction)
+		{
+		}
+
+		btCollisionObject*		m_collisionObject;
+		LocalShapeInfo*			m_localShapeInfo;
+		btVector3				m_hitNormalLocal;
+		btScalar				m_hitFraction;
+
+	};
+
+	///RayResultCallback is used to report new raycast results
+	struct	RayResultCallback
+	{
+		btScalar	m_closestHitFraction;
+		btCollisionObject*		m_collisionObject;
+		short int	m_collisionFilterGroup;
+		short int	m_collisionFilterMask;
+
+		virtual ~RayResultCallback()
+		{
+		}
+		bool	hasHit() const
+		{
+			return (m_collisionObject != 0);
+		}
+
+		RayResultCallback()
+			:m_closestHitFraction(btScalar(1.)),
+			m_collisionObject(0),
+			m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
+			m_collisionFilterMask(btBroadphaseProxy::AllFilter)
+		{
+		}
+
+		virtual bool needsCollision(btBroadphaseProxy* proxy0) const
+		{
+			bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0;
+			collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask);
+			return collides;
+		}
+
+
+		virtual	btScalar	addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace) = 0;
+	};
+
+	struct	ClosestRayResultCallback : public RayResultCallback
+	{
+		ClosestRayResultCallback(const btVector3&	rayFromWorld,const btVector3&	rayToWorld)
+		:m_rayFromWorld(rayFromWorld),
+		m_rayToWorld(rayToWorld)
+		{
+		}
+
+		btVector3	m_rayFromWorld;//used to calculate hitPointWorld from hitFraction
+		btVector3	m_rayToWorld;
+
+		btVector3	m_hitNormalWorld;
+		btVector3	m_hitPointWorld;
+			
+		virtual	btScalar	addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace)
+		{
+			//caller already does the filter on the m_closestHitFraction
+			btAssert(rayResult.m_hitFraction <= m_closestHitFraction);
+			
+			m_closestHitFraction = rayResult.m_hitFraction;
+			m_collisionObject = rayResult.m_collisionObject;
+			if (normalInWorldSpace)
+			{
+				m_hitNormalWorld = rayResult.m_hitNormalLocal;
+			} else
+			{
+				///need to transform normal into worldspace
+				m_hitNormalWorld = m_collisionObject->getWorldTransform().getBasis()*rayResult.m_hitNormalLocal;
+			}
+			m_hitPointWorld.setInterpolate3(m_rayFromWorld,m_rayToWorld,rayResult.m_hitFraction);
+			return rayResult.m_hitFraction;
+		}
+	};
+
+
+	struct LocalConvexResult
+	{
+		LocalConvexResult(btCollisionObject*	hitCollisionObject, 
+			LocalShapeInfo*	localShapeInfo,
+			const btVector3&		hitNormalLocal,
+			const btVector3&		hitPointLocal,
+			btScalar hitFraction
+			)
+		:m_hitCollisionObject(hitCollisionObject),
+		m_localShapeInfo(localShapeInfo),
+		m_hitNormalLocal(hitNormalLocal),
+		m_hitPointLocal(hitPointLocal),
+		m_hitFraction(hitFraction)
+		{
+		}
+
+		btCollisionObject*		m_hitCollisionObject;
+		LocalShapeInfo*			m_localShapeInfo;
+		btVector3				m_hitNormalLocal;
+		btVector3				m_hitPointLocal;
+		btScalar				m_hitFraction;
+	};
+
+	///RayResultCallback is used to report new raycast results
+	struct	ConvexResultCallback
+	{
+		btScalar	m_closestHitFraction;
+		short int	m_collisionFilterGroup;
+		short int	m_collisionFilterMask;
+		
+		ConvexResultCallback()
+			:m_closestHitFraction(btScalar(1.)),
+			m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
+			m_collisionFilterMask(btBroadphaseProxy::AllFilter)
+		{
+		}
+
+		virtual ~ConvexResultCallback()
+		{
+		}
+		
+		bool	hasHit() const
+		{
+			return (m_closestHitFraction < btScalar(1.));
+		}
+
+		
+
+		virtual bool needsCollision(btBroadphaseProxy* proxy0) const
+		{
+			bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0;
+			collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask);
+			return collides;
+		}
+
+		virtual	btScalar	addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace) = 0;
+	};
+
+	struct	ClosestConvexResultCallback : public ConvexResultCallback
+	{
+		ClosestConvexResultCallback(const btVector3&	convexFromWorld,const btVector3&	convexToWorld)
+		:m_convexFromWorld(convexFromWorld),
+		m_convexToWorld(convexToWorld),
+		m_hitCollisionObject(0)
+		{
+		}
+
+		btVector3	m_convexFromWorld;//used to calculate hitPointWorld from hitFraction
+		btVector3	m_convexToWorld;
+
+		btVector3	m_hitNormalWorld;
+		btVector3	m_hitPointWorld;
+		btCollisionObject*	m_hitCollisionObject;
+		
+		virtual	btScalar	addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace)
+		{
+//caller already does the filter on the m_closestHitFraction
+			btAssert(convexResult.m_hitFraction <= m_closestHitFraction);
+						
+			m_closestHitFraction = convexResult.m_hitFraction;
+			m_hitCollisionObject = convexResult.m_hitCollisionObject;
+			if (normalInWorldSpace)
+			{
+				m_hitNormalWorld = convexResult.m_hitNormalLocal;
+			} else
+			{
+				///need to transform normal into worldspace
+				m_hitNormalWorld = m_hitCollisionObject->getWorldTransform().getBasis()*convexResult.m_hitNormalLocal;
+			}
+			m_hitPointWorld = convexResult.m_hitPointLocal;
+			return convexResult.m_hitFraction;
+		}
+	};
+
+	int	getNumCollisionObjects() const
+	{
+		return int(m_collisionObjects.size());
+	}
+
+	/// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
+	/// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
+	void	rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const; 
+
+	// convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback
+	// This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.
+	void    convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback) const;
+
+
+	/// rayTestSingle performs a raycast call and calls the resultCallback. It is used internally by rayTest.
+	/// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape.
+	/// This allows more customization.
+	static void	rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
+					  btCollisionObject* collisionObject,
+					  const btCollisionShape* collisionShape,
+					  const btTransform& colObjWorldTransform,
+					  RayResultCallback& resultCallback);
+
+	/// objectQuerySingle performs a collision detection query and calls the resultCallback. It is used internally by rayTest.
+	static void	objectQuerySingle(const btConvexShape* castShape, const btTransform& rayFromTrans,const btTransform& rayToTrans,
+					  btCollisionObject* collisionObject,
+					  const btCollisionShape* collisionShape,
+					  const btTransform& colObjWorldTransform,
+					  ConvexResultCallback& resultCallback, btScalar	allowedPenetration);
+
+	void	addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
+
+	btCollisionObjectArray& getCollisionObjectArray()
+	{
+		return m_collisionObjects;
+	}
+
+	const btCollisionObjectArray& getCollisionObjectArray() const
+	{
+		return m_collisionObjects;
+	}
+
+
+	void	removeCollisionObject(btCollisionObject* collisionObject);
+
+	virtual void	performDiscreteCollisionDetection();
+
+	btDispatcherInfo& getDispatchInfo()
+	{
+		return m_dispatchInfo;
+	}
+
+	const btDispatcherInfo& getDispatchInfo() const
+	{
+		return m_dispatchInfo;
+	}
+
+};
+
+
+#endif //COLLISION_WORLD_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,287 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btCompoundShape.h"
+#include "BulletCollision/BroadphaseCollision/btDbvt.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "LinearMath/btAabbUtil2.h"
+
+btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
+:btCollisionAlgorithm(ci),
+m_isSwapped(isSwapped),
+m_sharedManifold(ci.m_manifold)
+{
+	m_ownsManifold = false;
+
+	btCollisionObject* colObj = m_isSwapped? body1 : body0;
+	btCollisionObject* otherObj = m_isSwapped? body0 : body1;
+	assert (colObj->getCollisionShape()->isCompound());
+	
+	btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
+	int numChildren = compoundShape->getNumChildShapes();
+	int i;
+	
+	m_childCollisionAlgorithms.resize(numChildren);
+	for (i=0;i<numChildren;i++)
+	{
+		if (compoundShape->getDynamicAabbTree())
+		{
+			m_childCollisionAlgorithms[i] = 0;
+		} else
+		{
+			btCollisionShape* tmpShape = colObj->getCollisionShape();
+			btCollisionShape* childShape = compoundShape->getChildShape(i);
+			colObj->internalSetTemporaryCollisionShape( childShape );
+			m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj,m_sharedManifold);
+			colObj->internalSetTemporaryCollisionShape( tmpShape );
+		}
+	}
+}
+
+
+btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
+{
+	int numChildren = m_childCollisionAlgorithms.size();
+	int i;
+	for (i=0;i<numChildren;i++)
+	{
+		if (m_childCollisionAlgorithms[i])
+		{
+			m_childCollisionAlgorithms[i]->~btCollisionAlgorithm();
+			m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]);
+		}
+	}
+}
+
+
+
+
+struct	btCompoundLeafCallback : btDbvt::ICollide
+{
+
+public:
+
+	btCollisionObject* m_compoundColObj;
+	btCollisionObject* m_otherObj;
+	btDispatcher* m_dispatcher;
+	const btDispatcherInfo& m_dispatchInfo;
+	btManifoldResult*	m_resultOut;
+	btCollisionAlgorithm**	m_childCollisionAlgorithms;
+	btPersistentManifold*	m_sharedManifold;
+
+
+
+
+	btCompoundLeafCallback (btCollisionObject* compoundObj,btCollisionObject* otherObj,btDispatcher* dispatcher,const btDispatcherInfo& dispatchInfo,btManifoldResult*	resultOut,btCollisionAlgorithm**	childCollisionAlgorithms,btPersistentManifold*	sharedManifold)
+		:m_compoundColObj(compoundObj),m_otherObj(otherObj),m_dispatcher(dispatcher),m_dispatchInfo(dispatchInfo),m_resultOut(resultOut),
+		m_childCollisionAlgorithms(childCollisionAlgorithms),
+		m_sharedManifold(sharedManifold)
+	{
+
+	}
+
+
+	void	ProcessChildShape(btCollisionShape* childShape,int index)
+	{
+		
+		btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
+
+
+		//backup
+		btTransform	orgTrans = m_compoundColObj->getWorldTransform();
+		btTransform	orgInterpolationTrans = m_compoundColObj->getInterpolationWorldTransform();
+		const btTransform& childTrans = compoundShape->getChildTransform(index);
+		btTransform	newChildWorldTrans = orgTrans*childTrans ;
+
+		//perform an AABB check first
+		btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
+		childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
+		m_otherObj->getCollisionShape()->getAabb(m_otherObj->getWorldTransform(),aabbMin1,aabbMax1);
+
+		if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
+		{
+
+			m_compoundColObj->setWorldTransform( newChildWorldTrans);
+			m_compoundColObj->setInterpolationWorldTransform(newChildWorldTrans);
+
+			//the contactpoint is still projected back using the original inverted worldtrans
+			btCollisionShape* tmpShape = m_compoundColObj->getCollisionShape();
+			m_compoundColObj->internalSetTemporaryCollisionShape( childShape );
+
+			if (!m_childCollisionAlgorithms[index])
+				m_childCollisionAlgorithms[index] = m_dispatcher->findAlgorithm(m_compoundColObj,m_otherObj,m_sharedManifold);
+
+			m_childCollisionAlgorithms[index]->processCollision(m_compoundColObj,m_otherObj,m_dispatchInfo,m_resultOut);
+			if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
+			{
+				btVector3 worldAabbMin,worldAabbMax;
+				m_dispatchInfo.m_debugDraw->drawAabb(aabbMin0,aabbMax0,btVector3(1,1,1));
+				m_dispatchInfo.m_debugDraw->drawAabb(aabbMin1,aabbMax1,btVector3(1,1,1));
+			}
+			
+			//revert back transform
+			m_compoundColObj->internalSetTemporaryCollisionShape( tmpShape);
+			m_compoundColObj->setWorldTransform(  orgTrans );
+			m_compoundColObj->setInterpolationWorldTransform(orgInterpolationTrans);
+		}
+	}
+	void		Process(const btDbvtNode* leaf)
+	{
+		int index = leaf->dataAsInt;
+
+		btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
+		btCollisionShape* childShape = compoundShape->getChildShape(index);
+		if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
+		{
+			btVector3 worldAabbMin,worldAabbMax;
+			btTransform	orgTrans = m_compoundColObj->getWorldTransform();
+			btTransformAabb(leaf->volume.Mins(),leaf->volume.Maxs(),0.,orgTrans,worldAabbMin,worldAabbMax);
+			m_dispatchInfo.m_debugDraw->drawAabb(worldAabbMin,worldAabbMax,btVector3(1,0,0));
+		}
+		ProcessChildShape(childShape,index);
+
+	}
+};
+
+
+
+
+
+
+void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	btCollisionObject* colObj = m_isSwapped? body1 : body0;
+	btCollisionObject* otherObj = m_isSwapped? body0 : body1;
+
+	assert (colObj->getCollisionShape()->isCompound());
+	btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
+
+	btDbvt* tree = compoundShape->getDynamicAabbTree();
+	//use a dynamic aabb tree to cull potential child-overlaps
+	btCompoundLeafCallback  callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold);
+
+
+	if (tree)
+	{
+
+		btVector3 localAabbMin,localAabbMax;
+		btTransform otherInCompoundSpace;
+		otherInCompoundSpace = colObj->getWorldTransform().inverse() * otherObj->getWorldTransform();
+		otherObj->getCollisionShape()->getAabb(otherInCompoundSpace,localAabbMin,localAabbMax);
+
+		const ATTRIBUTE_ALIGNED16(btDbvtVolume)	bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
+		//process all children, that overlap with  the given AABB bounds
+		tree->collideTV(tree->m_root,bounds,callback);
+
+	} else
+	{
+		//iterate over all children, perform an AABB check inside ProcessChildShape
+		int numChildren = m_childCollisionAlgorithms.size();
+		int i;
+		for (i=0;i<numChildren;i++)
+		{
+			callback.ProcessChildShape(compoundShape->getChildShape(i),i);
+		}
+	}
+
+	{
+				//iterate over all children, perform an AABB check inside ProcessChildShape
+		int numChildren = m_childCollisionAlgorithms.size();
+		int i;
+		btManifoldArray	manifoldArray;
+
+		for (i=0;i<numChildren;i++)
+		{
+			if (m_childCollisionAlgorithms[i])
+			{
+				btCollisionShape* childShape = compoundShape->getChildShape(i);
+			//if not longer overlapping, remove the algorithm
+				btTransform	orgTrans = colObj->getWorldTransform();
+				btTransform	orgInterpolationTrans = colObj->getInterpolationWorldTransform();
+				const btTransform& childTrans = compoundShape->getChildTransform(i);
+				btTransform	newChildWorldTrans = orgTrans*childTrans ;
+
+				//perform an AABB check first
+				btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
+				childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
+				otherObj->getCollisionShape()->getAabb(otherObj->getWorldTransform(),aabbMin1,aabbMax1);
+
+				if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
+				{
+					m_childCollisionAlgorithms[i]->~btCollisionAlgorithm();
+					m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]);
+					m_childCollisionAlgorithms[i] = 0;
+				}
+
+			}
+			
+		}
+
+		
+
+	}
+}
+
+btScalar	btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+
+	btCollisionObject* colObj = m_isSwapped? body1 : body0;
+	btCollisionObject* otherObj = m_isSwapped? body0 : body1;
+
+	assert (colObj->getCollisionShape()->isCompound());
+	
+	btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
+
+	//We will use the OptimizedBVH, AABB tree to cull potential child-overlaps
+	//If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals
+	//given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means:
+	//determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1
+	//then use each overlapping node AABB against Tree0
+	//and vise versa.
+
+	btScalar hitFraction = btScalar(1.);
+
+	int numChildren = m_childCollisionAlgorithms.size();
+	int i;
+	for (i=0;i<numChildren;i++)
+	{
+		//temporarily exchange parent btCollisionShape with childShape, and recurse
+		btCollisionShape* childShape = compoundShape->getChildShape(i);
+
+		//backup
+		btTransform	orgTrans = colObj->getWorldTransform();
+	
+		const btTransform& childTrans = compoundShape->getChildTransform(i);
+		//btTransform	newChildWorldTrans = orgTrans*childTrans ;
+		colObj->setWorldTransform( orgTrans*childTrans );
+
+		btCollisionShape* tmpShape = colObj->getCollisionShape();
+		colObj->internalSetTemporaryCollisionShape( childShape );
+		btScalar frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut);
+		if (frac<hitFraction)
+		{
+			hitFraction = frac;
+		}
+		//revert back
+		colObj->internalSetTemporaryCollisionShape( tmpShape);
+		colObj->setWorldTransform( orgTrans);
+	}
+	return hitFraction;
+
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COMPOUND_COLLISION_ALGORITHM_H
+#define COMPOUND_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+class btDispatcher;
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "btCollisionCreateFunc.h"
+#include "LinearMath/btAlignedObjectArray.h"
+class btDispatcher;
+
+/// btCompoundCollisionAlgorithm  supports collision between CompoundCollisionShapes and other collision shapes
+class btCompoundCollisionAlgorithm  : public btCollisionAlgorithm
+{
+	btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms;
+	bool m_isSwapped;
+
+	class btPersistentManifold*	m_sharedManifold;
+	bool					m_ownsManifold;
+	
+public:
+
+	btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+
+	virtual ~btCompoundCollisionAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	btScalar	calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		int i;
+		for (i=0;i<m_childCollisionAlgorithms.size();i++)
+		{
+			if (m_childCollisionAlgorithms[i])
+				m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);
+		}
+	}
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm));
+			return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,false);
+		}
+	};
+
+	struct SwappedCreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm));
+			return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,true);
+		}
+	};
+
+};
+
+#endif //COMPOUND_COLLISION_ALGORITHM_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,317 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btConvexConcaveCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionShapes/btConcaveShape.h"
+#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
+#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+
+btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
+: btCollisionAlgorithm(ci),
+m_isSwapped(isSwapped),
+m_btConvexTriangleCallback(ci.m_dispatcher1,body0,body1,isSwapped)
+{
+}
+
+btConvexConcaveCollisionAlgorithm::~btConvexConcaveCollisionAlgorithm()
+{
+}
+
+void	btConvexConcaveCollisionAlgorithm::getAllContactManifolds(btManifoldArray&	manifoldArray)
+{
+	if (m_btConvexTriangleCallback.m_manifoldPtr)
+	{
+		manifoldArray.push_back(m_btConvexTriangleCallback.m_manifoldPtr);
+	}
+}
+
+
+btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher*  dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped):
+	  m_dispatcher(dispatcher),
+	m_dispatchInfoPtr(0)
+{
+	m_convexBody = isSwapped? body1:body0;
+	m_triBody = isSwapped? body0:body1;
+	
+	  //
+	  // create the manifold from the dispatcher 'manifold pool'
+	  //
+	  m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody);
+
+  	  clearCache();
+}
+
+btConvexTriangleCallback::~btConvexTriangleCallback()
+{
+	clearCache();
+	m_dispatcher->releaseManifold( m_manifoldPtr );
+  
+}
+  
+
+void	btConvexTriangleCallback::clearCache()
+{
+	m_dispatcher->clearManifold(m_manifoldPtr);
+};
+
+
+
+void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
+{
+ 
+	//just for debugging purposes
+	//printf("triangle %d",m_triangleCount++);
+
+
+	//aabb filter is already applied!	
+
+	btCollisionAlgorithmConstructionInfo ci;
+	ci.m_dispatcher1 = m_dispatcher;
+
+	btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
+
+
+	
+	///debug drawing of the overlapping triangles
+	if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
+	{
+		btVector3 color(255,255,0);
+		btTransform& tr = ob->getWorldTransform();
+		m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color);
+		m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color);
+		m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
+
+		//btVector3 center = triangle[0] + triangle[1]+triangle[2];
+		//center *= btScalar(0.333333);
+		//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
+		//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
+		//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
+
+	}
+
+
+	//btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
+	
+	if (m_convexBody->getCollisionShape()->isConvex())
+	{
+		btTriangleShape tm(triangle[0],triangle[1],triangle[2]);	
+		tm.setMargin(m_collisionMarginTriangle);
+		
+		btCollisionShape* tmpShape = ob->getCollisionShape();
+		ob->internalSetTemporaryCollisionShape( &tm );
+		
+		btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr);
+		///this should use the btDispatcher, so the actual registered algorithm is used
+		//		btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
+
+		m_resultOut->setShapeIdentifiers(-1,-1,partId,triangleIndex);
+	//	cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
+//		cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
+		colAlgo->processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
+		colAlgo->~btCollisionAlgorithm();
+		ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
+		ob->internalSetTemporaryCollisionShape( tmpShape);
+	}
+
+
+}
+
+
+
+void	btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	m_dispatchInfoPtr = &dispatchInfo;
+	m_collisionMarginTriangle = collisionMarginTriangle;
+	m_resultOut = resultOut;
+
+	//recalc aabbs
+	btTransform convexInTriangleSpace;
+	convexInTriangleSpace = m_triBody->getWorldTransform().inverse() * m_convexBody->getWorldTransform();
+	btCollisionShape* convexShape = static_cast<btCollisionShape*>(m_convexBody->getCollisionShape());
+	//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
+	convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
+	btScalar extraMargin = collisionMarginTriangle;
+	btVector3 extra(extraMargin,extraMargin,extraMargin);
+
+	m_aabbMax += extra;
+	m_aabbMin -= extra;
+	
+}
+
+void btConvexConcaveCollisionAlgorithm::clearCache()
+{
+	m_btConvexTriangleCallback.clearCache();
+
+}
+
+void btConvexConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	
+	
+	btCollisionObject* convexBody = m_isSwapped ? body1 : body0;
+	btCollisionObject* triBody = m_isSwapped ? body0 : body1;
+
+	if (triBody->getCollisionShape()->isConcave())
+	{
+
+
+		btCollisionObject*	triOb = triBody;
+		btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
+		
+		if (convexBody->getCollisionShape()->isConvex())
+		{
+			btScalar collisionMarginTriangle = concaveShape->getMargin();
+					
+			resultOut->setPersistentManifold(m_btConvexTriangleCallback.m_manifoldPtr);
+			m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
+
+			//Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
+			//m_dispatcher->clearManifold(m_btConvexTriangleCallback.m_manifoldPtr);
+
+			m_btConvexTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody);
+
+			concaveShape->processAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.getAabbMin(),m_btConvexTriangleCallback.getAabbMax());
+			
+			resultOut->refreshContactPoints();
+	
+		}
+	
+	}
+
+}
+
+
+btScalar btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)resultOut;
+	(void)dispatchInfo;
+	btCollisionObject* convexbody = m_isSwapped ? body1 : body0;
+	btCollisionObject* triBody = m_isSwapped ? body0 : body1;
+
+
+	//quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast)
+
+	//only perform CCD above a certain threshold, this prevents blocking on the long run
+	//because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame...
+	btScalar squareMot0 = (convexbody->getInterpolationWorldTransform().getOrigin() - convexbody->getWorldTransform().getOrigin()).length2();
+	if (squareMot0 < convexbody->getCcdSquareMotionThreshold())
+	{
+		return btScalar(1.);
+	}
+
+	//const btVector3& from = convexbody->m_worldTransform.getOrigin();
+	//btVector3 to = convexbody->m_interpolationWorldTransform.getOrigin();
+	//todo: only do if the motion exceeds the 'radius'
+
+	btTransform triInv = triBody->getWorldTransform().inverse();
+	btTransform convexFromLocal = triInv * convexbody->getWorldTransform();
+	btTransform convexToLocal = triInv * convexbody->getInterpolationWorldTransform();
+
+	struct LocalTriangleSphereCastCallback	: public btTriangleCallback
+	{
+		btTransform m_ccdSphereFromTrans;
+		btTransform m_ccdSphereToTrans;
+		btTransform	m_meshTransform;
+
+		btScalar	m_ccdSphereRadius;
+		btScalar	m_hitFraction;
+	
+
+		LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction)
+			:m_ccdSphereFromTrans(from),
+			m_ccdSphereToTrans(to),
+			m_ccdSphereRadius(ccdSphereRadius),
+			m_hitFraction(hitFraction)
+		{			
+		}
+		
+		
+		virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
+		{
+			(void)partId;
+			(void)triangleIndex;
+			//do a swept sphere for now
+			btTransform ident;
+			ident.setIdentity();
+			btConvexCast::CastResult castResult;
+			castResult.m_fraction = m_hitFraction;
+			btSphereShape	pointShape(m_ccdSphereRadius);
+			btTriangleShape	triShape(triangle[0],triangle[1],triangle[2]);
+			btVoronoiSimplexSolver	simplexSolver;
+			btSubsimplexConvexCast convexCaster(&pointShape,&triShape,&simplexSolver);
+			//GjkConvexCast	convexCaster(&pointShape,convexShape,&simplexSolver);
+			//ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0);
+			//local space?
+
+			if (convexCaster.calcTimeOfImpact(m_ccdSphereFromTrans,m_ccdSphereToTrans,
+				ident,ident,castResult))
+			{
+				if (m_hitFraction > castResult.m_fraction)
+					m_hitFraction = castResult.m_fraction;
+			}
+
+		}
+
+	};
+
+
+	
+
+	
+	if (triBody->getCollisionShape()->isConcave())
+	{
+		btVector3 rayAabbMin = convexFromLocal.getOrigin();
+		rayAabbMin.setMin(convexToLocal.getOrigin());
+		btVector3 rayAabbMax = convexFromLocal.getOrigin();
+		rayAabbMax.setMax(convexToLocal.getOrigin());
+		btScalar ccdRadius0 = convexbody->getCcdSweptSphereRadius();
+		rayAabbMin -= btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
+		rayAabbMax += btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
+
+		btScalar curHitFraction = btScalar(1.); //is this available?
+		LocalTriangleSphereCastCallback raycastCallback(convexFromLocal,convexToLocal,
+			convexbody->getCcdSweptSphereRadius(),curHitFraction);
+
+		raycastCallback.m_hitFraction = convexbody->getHitFraction();
+
+		btCollisionObject* concavebody = triBody;
+
+		btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape();
+		
+		if (triangleMesh)
+		{
+			triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
+		}
+	
+
+
+		if (raycastCallback.m_hitFraction < convexbody->getHitFraction())
+		{
+			convexbody->setHitFraction( raycastCallback.m_hitFraction);
+			return raycastCallback.m_hitFraction;
+		}
+	}
+
+	return btScalar(1.);
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,115 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONVEX_CONCAVE_COLLISION_ALGORITHM_H
+#define CONVEX_CONCAVE_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+#include "BulletCollision/CollisionShapes/btTriangleCallback.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+class btDispatcher;
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "btCollisionCreateFunc.h"
+
+///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), processTriangle is called.
+class btConvexTriangleCallback : public btTriangleCallback
+{
+	btCollisionObject* m_convexBody;
+	btCollisionObject* m_triBody;
+
+	btVector3	m_aabbMin;
+	btVector3	m_aabbMax ;
+
+	btManifoldResult* m_resultOut;
+
+	btDispatcher*	m_dispatcher;
+	const btDispatcherInfo* m_dispatchInfoPtr;
+	btScalar m_collisionMarginTriangle;
+	
+public:
+int	m_triangleCount;
+	
+	btPersistentManifold*	m_manifoldPtr;
+
+	btConvexTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+
+	void	setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual ~btConvexTriangleCallback();
+
+	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
+	
+	void clearCache();
+
+	SIMD_FORCE_INLINE const btVector3& getAabbMin() const
+	{
+		return m_aabbMin;
+	}
+	SIMD_FORCE_INLINE const btVector3& getAabbMax() const
+	{
+		return m_aabbMax;
+	}
+
+};
+
+
+
+
+/// btConvexConcaveCollisionAlgorithm  supports collision between convex shapes and (concave) trianges meshes.
+class btConvexConcaveCollisionAlgorithm  : public btCollisionAlgorithm
+{
+
+	bool	m_isSwapped;
+
+	btConvexTriangleCallback m_btConvexTriangleCallback;
+
+
+public:
+
+	btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+
+	virtual ~btConvexConcaveCollisionAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	btScalar	calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray);
+	
+	void	clearCache();
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm));
+			return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0,body1,false);
+		}
+	};
+
+	struct SwappedCreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm));
+			return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0,body1,true);
+		}
+	};
+
+};
+
+#endif //CONVEX_CONCAVE_COLLISION_ALGORITHM_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,248 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btConvexConvexAlgorithm.h"
+
+//#include <stdio.h>
+#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
+
+#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
+#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
+
+
+
+#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+
+#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
+
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
+
+
+
+
+
+
+
+
+
+btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface*			simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
+{
+	m_simplexSolver = simplexSolver;
+	m_pdSolver = pdSolver;
+}
+
+btConvexConvexAlgorithm::CreateFunc::~CreateFunc() 
+{ 
+}
+
+btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
+: btCollisionAlgorithm(ci),
+m_gjkPairDetector(0,0,simplexSolver,pdSolver),
+m_ownManifold (false),
+m_manifoldPtr(mf),
+m_lowLevelOfDetail(false)
+{
+	(void)body0;
+	(void)body1;
+
+
+}
+
+
+
+
+btConvexConvexAlgorithm::~btConvexConvexAlgorithm()
+{
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr)
+			m_dispatcher->releaseManifold(m_manifoldPtr);
+	}
+}
+
+void	btConvexConvexAlgorithm ::setLowLevelOfDetail(bool useLowLevel)
+{
+	m_lowLevelOfDetail = useLowLevel;
+}
+
+
+
+
+
+//
+// Convex-Convex collision algorithm
+//
+void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+
+	if (!m_manifoldPtr)
+	{
+		//swapped?
+		m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
+		m_ownManifold = true;
+	}
+	resultOut->setPersistentManifold(m_manifoldPtr);
+
+#ifdef USE_BT_GJKEPA
+	btConvexShape*				shape0(static_cast<btConvexShape*>(body0->getCollisionShape()));
+	btConvexShape*				shape1(static_cast<btConvexShape*>(body1->getCollisionShape()));
+	const btScalar				radialmargin(0/*shape0->getMargin()+shape1->getMargin()*/);
+	btGjkEpaSolver::sResults	results;
+	if(btGjkEpaSolver::Collide(	shape0,body0->getWorldTransform(),
+								shape1,body1->getWorldTransform(),
+								radialmargin,results))
+		{
+		dispatchInfo.m_debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
+		resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
+		}
+#else
+
+	btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
+	btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
+	
+	btGjkPairDetector::ClosestPointInput input;
+
+	//TODO: if (dispatchInfo.m_useContinuous)
+	m_gjkPairDetector.setMinkowskiA(min0);
+	m_gjkPairDetector.setMinkowskiB(min1);
+	input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
+	input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
+	input.m_stackAlloc = dispatchInfo.m_stackAllocator;
+
+//	input.m_maximumDistanceSquared = btScalar(1e30);
+	
+	input.m_transformA = body0->getWorldTransform();
+	input.m_transformB = body1->getWorldTransform();
+	
+	m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
+#endif
+
+	if (m_ownManifold)
+	{
+		resultOut->refreshContactPoints();
+	}
+
+}
+
+
+
+bool disableCcd = false;
+btScalar	btConvexConvexAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)resultOut;
+	(void)dispatchInfo;
+	///Rather then checking ALL pairs, only calculate TOI when motion exceeds threshold
+    
+	///Linear motion for one of objects needs to exceed m_ccdSquareMotionThreshold
+	///col0->m_worldTransform,
+	btScalar resultFraction = btScalar(1.);
+
+
+	btScalar squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).length2();
+	btScalar squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).length2();
+    
+	if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
+		squareMot1 < col1->getCcdSquareMotionThreshold())
+		return resultFraction;
+
+	if (disableCcd)
+		return btScalar(1.);
+
+
+	//An adhoc way of testing the Continuous Collision Detection algorithms
+	//One object is approximated as a sphere, to simplify things
+	//Starting in penetration should report no time of impact
+	//For proper CCD, better accuracy and handling of 'allowed' penetration should be added
+	//also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies)
+
+		
+	/// Convex0 against sphere for Convex1
+	{
+		btConvexShape* convex0 = static_cast<btConvexShape*>(col0->getCollisionShape());
+
+		btSphereShape	sphere1(col1->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation
+		btConvexCast::CastResult result;
+		btVoronoiSimplexSolver voronoiSimplex;
+		//SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
+		///Simplification, one object is simplified as a sphere
+		btGjkConvexCast ccd1( convex0 ,&sphere1,&voronoiSimplex);
+		//ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0);
+		if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(),
+			col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result))
+		{
+		
+			//store result.m_fraction in both bodies
+		
+			if (col0->getHitFraction()> result.m_fraction)
+				col0->setHitFraction( result.m_fraction );
+
+			if (col1->getHitFraction() > result.m_fraction)
+				col1->setHitFraction( result.m_fraction);
+
+			if (resultFraction > result.m_fraction)
+				resultFraction = result.m_fraction;
+
+		}
+		
+		
+
+
+	}
+
+	/// Sphere (for convex0) against Convex1
+	{
+		btConvexShape* convex1 = static_cast<btConvexShape*>(col1->getCollisionShape());
+
+		btSphereShape	sphere0(col0->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation
+		btConvexCast::CastResult result;
+		btVoronoiSimplexSolver voronoiSimplex;
+		//SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
+		///Simplification, one object is simplified as a sphere
+		btGjkConvexCast ccd1(&sphere0,convex1,&voronoiSimplex);
+		//ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0);
+		if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(),
+			col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result))
+		{
+		
+			//store result.m_fraction in both bodies
+		
+			if (col0->getHitFraction()	> result.m_fraction)
+				col0->setHitFraction( result.m_fraction);
+
+			if (col1->getHitFraction() > result.m_fraction)
+				col1->setHitFraction( result.m_fraction);
+
+			if (resultFraction > result.m_fraction)
+				resultFraction = result.m_fraction;
+
+		}
+	}
+	
+	return resultFraction;
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h	(revision 2122)
@@ -0,0 +1,85 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONVEX_CONVEX_ALGORITHM_H
+#define CONVEX_CONVEX_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
+#include "btCollisionCreateFunc.h"
+#include "btCollisionDispatcher.h"
+
+class btConvexPenetrationDepthSolver;
+
+///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
+class btConvexConvexAlgorithm : public btCollisionAlgorithm
+{
+	btGjkPairDetector m_gjkPairDetector;
+public:
+
+	bool	m_ownManifold;
+	btPersistentManifold*	m_manifoldPtr;
+	bool			m_lowLevelOfDetail;
+	
+
+public:
+
+	btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
+
+	virtual ~btConvexConvexAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		///should we use m_ownManifold to avoid adding duplicates?
+		if (m_manifoldPtr && m_ownManifold)
+			manifoldArray.push_back(m_manifoldPtr);
+	}
+
+
+	void	setLowLevelOfDetail(bool useLowLevel);
+
+
+	const btPersistentManifold*	getManifold()
+	{
+		return m_manifoldPtr;
+	}
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		btConvexPenetrationDepthSolver*		m_pdSolver;
+		btSimplexSolverInterface*			m_simplexSolver;
+		
+		CreateFunc(btSimplexSolverInterface*			simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
+		
+		virtual ~CreateFunc();
+
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm));
+			return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver);
+		}
+	};
+
+
+};
+
+#endif //CONVEX_CONVEX_ALGORITHM_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,108 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btConvexPlaneCollisionAlgorithm.h"
+
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
+
+//#include <stdio.h>
+
+btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
+: btCollisionAlgorithm(ci),
+m_ownManifold(false),
+m_manifoldPtr(mf),
+m_isSwapped(isSwapped)
+{
+	btCollisionObject* convexObj = m_isSwapped? col1 : col0;
+	btCollisionObject* planeObj = m_isSwapped? col0 : col1;
+	
+	if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj))
+	{
+		m_manifoldPtr = m_dispatcher->getNewManifold(convexObj,planeObj);
+		m_ownManifold = true;
+	}
+}
+
+
+btConvexPlaneCollisionAlgorithm::~btConvexPlaneCollisionAlgorithm()
+{
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr)
+			m_dispatcher->releaseManifold(m_manifoldPtr);
+	}
+}
+
+
+
+void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)dispatchInfo;
+	(void)resultOut;
+	if (!m_manifoldPtr)
+		return;
+
+	btCollisionObject* convexObj = m_isSwapped? body1 : body0;
+	btCollisionObject* planeObj = m_isSwapped? body0: body1;
+
+	btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
+	btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
+
+	bool hasCollision = false;
+	const btVector3& planeNormal = planeShape->getPlaneNormal();
+	const btScalar& planeConstant = planeShape->getPlaneConstant();
+	btTransform planeInConvex;
+	planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
+	btTransform convexInPlaneTrans;
+	convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();
+
+	btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
+	btVector3 vtxInPlane = convexInPlaneTrans(vtx);
+	btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
+
+	btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
+	btVector3 vtxInPlaneWorld = planeObj->getWorldTransform() * vtxInPlaneProjected;
+
+	hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
+	resultOut->setPersistentManifold(m_manifoldPtr);
+	if (hasCollision)
+	{
+		/// report a contact. internally this will be kept persistent, and contact reduction is done
+		btVector3 normalOnSurfaceB = planeObj->getWorldTransform().getBasis() * planeNormal;
+		btVector3 pOnB = vtxInPlaneWorld;
+		resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
+	}
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr->getNumContacts())
+		{
+			resultOut->refreshContactPoints();
+		}
+	}
+}
+
+btScalar btConvexPlaneCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)resultOut;
+	(void)dispatchInfo;
+	(void)col0;
+	(void)col1;
+
+	//not yet
+	return btScalar(1.);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,71 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONVEX_PLANE_COLLISION_ALGORITHM_H
+#define CONVEX_PLANE_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+class btPersistentManifold;
+#include "btCollisionDispatcher.h"
+
+#include "LinearMath/btVector3.h"
+
+/// btSphereBoxCollisionAlgorithm  provides sphere-box collision detection.
+/// Other features are frame-coherency (persistent data) and collision response.
+class btConvexPlaneCollisionAlgorithm : public btCollisionAlgorithm
+{
+	bool	m_ownManifold;
+	btPersistentManifold*	m_manifoldPtr;
+	bool	m_isSwapped;
+	
+public:
+
+	btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
+
+	virtual ~btConvexPlaneCollisionAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		if (m_manifoldPtr && m_ownManifold)
+		{
+			manifoldArray.push_back(m_manifoldPtr);
+		}
+	}
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexPlaneCollisionAlgorithm));
+			if (!m_swapped)
+			{
+				return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false);
+			} else
+			{
+				return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true);
+			}
+		}
+	};
+
+};
+
+#endif //CONVEX_PLANE_COLLISION_ALGORITHM_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp	(revision 2122)
@@ -0,0 +1,291 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btDefaultCollisionConfiguration.h"
+
+#include "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h"
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
+#include "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h"
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+#include "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
+
+
+
+#include "LinearMath/btStackAlloc.h"
+#include "LinearMath/btPoolAllocator.h"
+
+
+
+
+
+btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo)
+//btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc*	stackAlloc,btPoolAllocator*	persistentManifoldPool,btPoolAllocator*	collisionAlgorithmPool)
+{
+
+	void* mem = btAlignedAlloc(sizeof(btVoronoiSimplexSolver),16);
+	m_simplexSolver = new (mem)btVoronoiSimplexSolver();
+	
+#define USE_EPA 1
+#ifdef USE_EPA
+	mem = btAlignedAlloc(sizeof(btGjkEpaPenetrationDepthSolver),16);
+	m_pdSolver = new (mem)btGjkEpaPenetrationDepthSolver;
+#else
+	mem = btAlignedAlloc(sizeof(btMinkowskiPenetrationDepthSolver),16);
+	m_pdSolver = new (mem)btMinkowskiPenetrationDepthSolver;
+#endif//USE_EPA	
+	
+
+	//default CreationFunctions, filling the m_doubleDispatch table
+	mem = btAlignedAlloc(sizeof(btConvexConvexAlgorithm::CreateFunc),16);
+	m_convexConvexCreateFunc = new(mem) btConvexConvexAlgorithm::CreateFunc(m_simplexSolver,m_pdSolver);
+	mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16);
+	m_convexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::CreateFunc;
+	mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16);
+	m_swappedConvexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::SwappedCreateFunc;
+	mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::CreateFunc),16);
+	m_compoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::CreateFunc;
+	mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::SwappedCreateFunc),16);
+	m_swappedCompoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::SwappedCreateFunc;
+	mem = btAlignedAlloc(sizeof(btEmptyAlgorithm::CreateFunc),16);
+	m_emptyCreateFunc = new(mem) btEmptyAlgorithm::CreateFunc;
+	
+	mem = btAlignedAlloc(sizeof(btSphereSphereCollisionAlgorithm::CreateFunc),16);
+	m_sphereSphereCF = new(mem) btSphereSphereCollisionAlgorithm::CreateFunc;
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
+	mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
+	m_sphereBoxCF = new(mem) btSphereBoxCollisionAlgorithm::CreateFunc;
+	mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
+	m_boxSphereCF = new (mem)btSphereBoxCollisionAlgorithm::CreateFunc;
+	m_boxSphereCF->m_swapped = true;
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
+	mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
+	m_sphereTriangleCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc;
+	mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
+	m_triangleSphereCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc;
+	m_triangleSphereCF->m_swapped = true;
+	
+	mem = btAlignedAlloc(sizeof(btBoxBoxCollisionAlgorithm::CreateFunc),16);
+	m_boxBoxCF = new(mem)btBoxBoxCollisionAlgorithm::CreateFunc;
+
+	//convex versus plane
+	mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16);
+	m_convexPlaneCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc;
+	mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16);
+	m_planeConvexCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc;
+	m_planeConvexCF->m_swapped = true;
+	
+	///calculate maximum element size, big enough to fit any collision algorithm in the memory pool
+	int maxSize = sizeof(btConvexConvexAlgorithm);
+	int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm);
+	int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
+	int maxSize4 = sizeof(btEmptyAlgorithm);
+	
+	int	collisionAlgorithmMaxElementSize = btMax(maxSize,maxSize2);
+	collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
+	collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize4);
+
+	if (constructionInfo.m_stackAlloc)
+	{
+		m_ownsStackAllocator = false;
+		this->m_stackAlloc = constructionInfo.m_stackAlloc;
+	} else
+	{
+		m_ownsStackAllocator = true;
+		void* mem = btAlignedAlloc(sizeof(btStackAlloc),16);
+		m_stackAlloc = new(mem)btStackAlloc(constructionInfo.m_defaultStackAllocatorSize);
+	}
+		
+	if (constructionInfo.m_persistentManifoldPool)
+	{
+		m_ownsPersistentManifoldPool = false;
+		m_persistentManifoldPool = constructionInfo.m_persistentManifoldPool;
+	} else
+	{
+		m_ownsPersistentManifoldPool = true;
+		void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
+		m_persistentManifoldPool = new (mem) btPoolAllocator(sizeof(btPersistentManifold),constructionInfo.m_defaultMaxPersistentManifoldPoolSize);
+	}
+	
+	if (constructionInfo.m_collisionAlgorithmPool)
+	{
+		m_ownsCollisionAlgorithmPool = false;
+		m_collisionAlgorithmPool = constructionInfo.m_collisionAlgorithmPool;
+	} else
+	{
+		m_ownsCollisionAlgorithmPool = true;
+		void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
+		m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
+	}
+
+
+}
+
+btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration()
+{
+	if (m_ownsStackAllocator)
+	{
+		m_stackAlloc->destroy();
+		m_stackAlloc->~btStackAlloc();
+		btAlignedFree(m_stackAlloc);
+	}
+	if (m_ownsCollisionAlgorithmPool)
+	{
+		m_collisionAlgorithmPool->~btPoolAllocator();
+		btAlignedFree(m_collisionAlgorithmPool);
+	}
+	if (m_ownsPersistentManifoldPool)
+	{
+		m_persistentManifoldPool->~btPoolAllocator();
+		btAlignedFree(m_persistentManifoldPool);
+	}
+
+	m_convexConvexCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree(	m_convexConvexCreateFunc);
+
+	m_convexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_convexConcaveCreateFunc);
+	m_swappedConvexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_swappedConvexConcaveCreateFunc);
+
+	m_compoundCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_compoundCreateFunc);
+
+	m_swappedCompoundCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_swappedCompoundCreateFunc);
+
+	m_emptyCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_emptyCreateFunc);
+
+	m_sphereSphereCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_sphereSphereCF);
+
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
+	m_sphereBoxCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_sphereBoxCF);
+	m_boxSphereCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_boxSphereCF);
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
+	m_sphereTriangleCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_sphereTriangleCF);
+	m_triangleSphereCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_triangleSphereCF);
+	m_boxBoxCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_boxBoxCF);
+
+	m_convexPlaneCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_convexPlaneCF);
+	m_planeConvexCF->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree( m_planeConvexCF);
+
+	m_simplexSolver->~btVoronoiSimplexSolver();
+	btAlignedFree(m_simplexSolver);
+
+	m_pdSolver->~btConvexPenetrationDepthSolver();
+	
+	btAlignedFree(m_pdSolver);
+
+
+}
+
+
+btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1)
+{
+
+
+
+	if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
+	{
+		return	m_sphereSphereCF;
+	}
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
+	if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE))
+	{
+		return	m_sphereBoxCF;
+	}
+
+	if ((proxyType0 == BOX_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
+	{
+		return	m_boxSphereCF;
+	}
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
+
+	if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE))
+	{
+		return	m_sphereTriangleCF;
+	}
+
+	if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE  ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
+	{
+		return	m_triangleSphereCF;
+	} 
+
+	if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
+	{
+		return m_boxBoxCF;
+	}
+	
+	if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
+	{
+		return m_convexPlaneCF;
+	}
+
+	if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE))
+	{
+		return m_planeConvexCF;
+	}
+	
+
+
+	if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
+	{
+		return m_convexConvexCreateFunc;
+	}
+
+	if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
+	{
+		return m_convexConcaveCreateFunc;
+	}
+
+	if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
+	{
+		return m_swappedConvexConcaveCreateFunc;
+	}
+
+	if (btBroadphaseProxy::isCompound(proxyType0))
+	{
+		return m_compoundCreateFunc;
+	} else
+	{
+		if (btBroadphaseProxy::isCompound(proxyType1))
+		{
+			return m_swappedCompoundCreateFunc;
+		}
+	}
+
+	//failed to find an algorithm
+	return m_emptyCreateFunc;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h	(revision 2122)
@@ -0,0 +1,118 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_DEFAULT_COLLISION_CONFIGURATION
+#define BT_DEFAULT_COLLISION_CONFIGURATION
+
+#include "btCollisionConfiguration.h"
+class btVoronoiSimplexSolver;
+class btConvexPenetrationDepthSolver;
+
+struct	btDefaultCollisionConstructionInfo
+{
+	btStackAlloc*		m_stackAlloc;
+	btPoolAllocator*	m_persistentManifoldPool;
+	btPoolAllocator*	m_collisionAlgorithmPool;
+	int					m_defaultMaxPersistentManifoldPoolSize;
+	int					m_defaultMaxCollisionAlgorithmPoolSize;
+	int					m_defaultStackAllocatorSize;
+
+	btDefaultCollisionConstructionInfo()
+		:m_stackAlloc(0),
+		m_persistentManifoldPool(0),
+		m_collisionAlgorithmPool(0),
+		m_defaultMaxPersistentManifoldPoolSize(65535),
+		m_defaultMaxCollisionAlgorithmPoolSize(65535),
+		m_defaultStackAllocatorSize(5*1024*1024)
+	{
+	}
+};
+
+
+
+///btCollisionConfiguration allows to configure Bullet collision detection
+///stack allocator, pool memory allocators
+///todo: describe the meaning
+class	btDefaultCollisionConfiguration : public btCollisionConfiguration
+{
+
+protected:
+
+	int	m_persistentManifoldPoolSize;
+	
+	btStackAlloc*	m_stackAlloc;
+	bool	m_ownsStackAllocator;
+
+	btPoolAllocator*	m_persistentManifoldPool;
+	bool	m_ownsPersistentManifoldPool;
+
+
+	btPoolAllocator*	m_collisionAlgorithmPool;
+	bool	m_ownsCollisionAlgorithmPool;
+
+	//default simplex/penetration depth solvers
+	btVoronoiSimplexSolver*	m_simplexSolver;
+	btConvexPenetrationDepthSolver*	m_pdSolver;
+	
+	//default CreationFunctions, filling the m_doubleDispatch table
+	btCollisionAlgorithmCreateFunc*	m_convexConvexCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_convexConcaveCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_swappedConvexConcaveCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_compoundCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_swappedCompoundCreateFunc;
+	btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
+	btCollisionAlgorithmCreateFunc* m_sphereSphereCF;
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
+	btCollisionAlgorithmCreateFunc* m_sphereBoxCF;
+	btCollisionAlgorithmCreateFunc* m_boxSphereCF;
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
+	btCollisionAlgorithmCreateFunc* m_boxBoxCF;
+	btCollisionAlgorithmCreateFunc*	m_sphereTriangleCF;
+	btCollisionAlgorithmCreateFunc*	m_triangleSphereCF;
+	btCollisionAlgorithmCreateFunc*	m_planeConvexCF;
+	btCollisionAlgorithmCreateFunc*	m_convexPlaneCF;
+	
+public:
+
+
+	btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo());
+
+	virtual ~btDefaultCollisionConfiguration();
+
+		///memory pools
+	virtual btPoolAllocator* getPersistentManifoldPool()
+	{
+		return m_persistentManifoldPool;
+	}
+
+	virtual btPoolAllocator* getCollisionAlgorithmPool()
+	{
+		return m_collisionAlgorithmPool;
+	}
+
+	virtual btStackAlloc*	getStackAllocator()
+	{
+		return m_stackAlloc;
+	}
+
+
+	virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
+
+
+};
+
+#endif //BT_DEFAULT_COLLISION_CONFIGURATION
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,34 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btEmptyCollisionAlgorithm.h"
+
+
+
+btEmptyAlgorithm::btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
+	: btCollisionAlgorithm(ci)
+{
+}
+
+void btEmptyAlgorithm::processCollision (btCollisionObject* ,btCollisionObject* ,const btDispatcherInfo& ,btManifoldResult* )
+{
+}
+
+btScalar btEmptyAlgorithm::calculateTimeOfImpact(btCollisionObject* ,btCollisionObject* ,const btDispatcherInfo& ,btManifoldResult* )
+{
+	return btScalar(1.);
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef EMPTY_ALGORITH
+#define EMPTY_ALGORITH
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "btCollisionCreateFunc.h"
+#include "btCollisionDispatcher.h"
+
+#define ATTRIBUTE_ALIGNED(a)
+
+///EmptyAlgorithm is a stub for unsupported collision pairs.
+///The dispatcher can dispatch a persistent btEmptyAlgorithm to avoid a search every frame.
+class btEmptyAlgorithm : public btCollisionAlgorithm
+{
+
+public:
+	
+	btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci);
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+	}
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			(void)body0;
+			(void)body1;
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btEmptyAlgorithm));
+			return new(mem) btEmptyAlgorithm(ci);
+		}
+	};
+
+} ATTRIBUTE_ALIGNED(16);
+
+#endif //EMPTY_ALGORITH
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp	(revision 2122)
@@ -0,0 +1,119 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btManifoldResult.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+
+///This is to allow MaterialCombiner/Custom Friction/Restitution values
+ContactAddedCallback		gContactAddedCallback=0;
+
+///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback;
+inline btScalar	calculateCombinedFriction(const btCollisionObject* body0,const btCollisionObject* body1)
+{
+	btScalar friction = body0->getFriction() * body1->getFriction();
+
+	const btScalar MAX_FRICTION  = btScalar(10.);
+	if (friction < -MAX_FRICTION)
+		friction = -MAX_FRICTION;
+	if (friction > MAX_FRICTION)
+		friction = MAX_FRICTION;
+	return friction;
+
+}
+
+inline btScalar	calculateCombinedRestitution(const btCollisionObject* body0,const btCollisionObject* body1)
+{
+	return body0->getRestitution() * body1->getRestitution();
+}
+
+
+
+btManifoldResult::btManifoldResult(btCollisionObject* body0,btCollisionObject* body1)
+		:m_manifoldPtr(0),
+		m_body0(body0),
+		m_body1(body1)
+{
+	m_rootTransA = body0->getWorldTransform();
+	m_rootTransB = body1->getWorldTransform();
+}
+
+
+void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
+{
+	assert(m_manifoldPtr);
+	//order in manifold needs to match
+	
+	if (depth > m_manifoldPtr->getContactBreakingThreshold())
+		return;
+
+	bool isSwapped = m_manifoldPtr->getBody0() != m_body0;
+
+	btVector3 pointA = pointInWorld + normalOnBInWorld * depth;
+
+	btVector3 localA;
+	btVector3 localB;
+	
+	if (isSwapped)
+	{
+		localA = m_rootTransB.invXform(pointA );
+		localB = m_rootTransA.invXform(pointInWorld);
+	} else
+	{
+		localA = m_rootTransA.invXform(pointA );
+		localB = m_rootTransB.invXform(pointInWorld);
+	}
+
+	btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth);
+	newPt.m_positionWorldOnA = pointA;
+	newPt.m_positionWorldOnB = pointInWorld;
+	
+	int insertIndex = m_manifoldPtr->getCacheEntry(newPt);
+
+	newPt.m_combinedFriction = calculateCombinedFriction(m_body0,m_body1);
+	newPt.m_combinedRestitution = calculateCombinedRestitution(m_body0,m_body1);
+
+   //BP mod, store contact triangles.
+   newPt.m_partId0 = m_partId0;
+   newPt.m_partId1 = m_partId1;
+   newPt.m_index0  = m_index0;
+   newPt.m_index1  = m_index1;
+	
+	///todo, check this for any side effects
+	if (insertIndex >= 0)
+	{
+		//const btManifoldPoint& oldPoint = m_manifoldPtr->getContactPoint(insertIndex);
+		m_manifoldPtr->replaceContactPoint(newPt,insertIndex);
+	} else
+	{
+		insertIndex = m_manifoldPtr->addManifoldPoint(newPt);
+	}
+	
+	//User can override friction and/or restitution
+	if (gContactAddedCallback &&
+		//and if either of the two bodies requires custom material
+		 ((m_body0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK) ||
+		   (m_body1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)))
+	{
+		//experimental feature info, for per-triangle material etc.
+		btCollisionObject* obj0 = isSwapped? m_body1 : m_body0;
+		btCollisionObject* obj1 = isSwapped? m_body0 : m_body1;
+		(*gContactAddedCallback)(m_manifoldPtr->getContactPoint(insertIndex),obj0,m_partId0,m_index0,obj1,m_partId1,m_index1);
+	}
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h	(revision 2122)
@@ -0,0 +1,102 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef MANIFOLD_RESULT_H
+#define MANIFOLD_RESULT_H
+
+class btCollisionObject;
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+class btManifoldPoint;
+
+#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
+
+#include "LinearMath/btTransform.h"
+
+typedef bool (*ContactAddedCallback)(btManifoldPoint& cp,	const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1);
+extern ContactAddedCallback		gContactAddedCallback;
+
+
+
+///btManifoldResult is a helper class to manage  contact results.
+class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result
+{
+	btPersistentManifold* m_manifoldPtr;
+
+	//we need this for compounds
+	btTransform	m_rootTransA;
+	btTransform	m_rootTransB;
+
+	btCollisionObject* m_body0;
+	btCollisionObject* m_body1;
+	int	m_partId0;
+	int m_partId1;
+	int m_index0;
+	int m_index1;
+public:
+
+	btManifoldResult()
+	{
+	}
+
+	btManifoldResult(btCollisionObject* body0,btCollisionObject* body1);
+
+	virtual ~btManifoldResult() {};
+
+	void	setPersistentManifold(btPersistentManifold* manifoldPtr)
+	{
+		m_manifoldPtr = manifoldPtr;
+	}
+
+	const btPersistentManifold*	getPersistentManifold() const
+	{
+		return m_manifoldPtr;
+	}
+	btPersistentManifold*	getPersistentManifold()
+	{
+		return m_manifoldPtr;
+	}
+
+	virtual void setShapeIdentifiers(int partId0,int index0,	int partId1,int index1)
+	{
+			m_partId0=partId0;
+			m_partId1=partId1;
+			m_index0=index0;
+			m_index1=index1;		
+	}
+
+	virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
+
+	SIMD_FORCE_INLINE	void refreshContactPoints()
+	{
+		btAssert(m_manifoldPtr);
+		if (!m_manifoldPtr->getNumContacts())
+			return;
+
+		bool isSwapped = m_manifoldPtr->getBody0() != m_body0;
+
+		if (isSwapped)
+		{
+			m_manifoldPtr->refreshContactPoints(m_rootTransB,m_rootTransA);
+		} else
+		{
+			m_manifoldPtr->refreshContactPoints(m_rootTransA,m_rootTransB);
+		}
+	}
+
+
+};
+
+#endif //MANIFOLD_RESULT_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp	(revision 2122)
@@ -0,0 +1,384 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "LinearMath/btScalar.h"
+#include "btSimulationIslandManager.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
+
+//#include <stdio.h>
+#include "LinearMath/btQuickprof.h"
+
+btSimulationIslandManager::btSimulationIslandManager()
+{
+}
+
+btSimulationIslandManager::~btSimulationIslandManager()
+{
+}
+
+
+void btSimulationIslandManager::initUnionFind(int n)
+{
+		m_unionFind.reset(n);
+}
+		
+
+void btSimulationIslandManager::findUnions(btDispatcher* /* dispatcher */,btCollisionWorld* colWorld)
+{
+	
+	{
+		btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
+
+		for (int i=0;i<colWorld->getPairCache()->getNumOverlappingPairs();i++)
+		{
+			const btBroadphasePair& collisionPair = pairPtr[i];
+			btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
+			btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
+
+			if (((colObj0) && ((colObj0)->mergesSimulationIslands())) &&
+				((colObj1) && ((colObj1)->mergesSimulationIslands())))
+			{
+
+				m_unionFind.unite((colObj0)->getIslandTag(),
+					(colObj1)->getIslandTag());
+			}
+		}
+	}
+}
+
+
+void	btSimulationIslandManager::updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher)
+{
+	
+	initUnionFind( int (colWorld->getCollisionObjectArray().size()));
+	
+	// put the index into m_controllers into m_tag	
+	{
+		
+		int index = 0;
+		int i;
+		for (i=0;i<colWorld->getCollisionObjectArray().size(); i++)
+		{
+			btCollisionObject*	collisionObject= colWorld->getCollisionObjectArray()[i];
+			collisionObject->setIslandTag(index);
+			collisionObject->setCompanionId(-1);
+			collisionObject->setHitFraction(btScalar(1.));
+			index++;
+			
+		}
+	}
+	// do the union find
+	
+	findUnions(dispatcher,colWorld);
+	
+
+	
+}
+
+
+
+
+void	btSimulationIslandManager::storeIslandActivationState(btCollisionWorld* colWorld)
+{
+	// put the islandId ('find' value) into m_tag	
+	{
+		
+		
+		int index = 0;
+		int i;
+		for (i=0;i<colWorld->getCollisionObjectArray().size();i++)
+		{
+			btCollisionObject* collisionObject= colWorld->getCollisionObjectArray()[i];
+			if (!collisionObject->isStaticOrKinematicObject())
+			{
+				collisionObject->setIslandTag( m_unionFind.find(index) );
+				collisionObject->setCompanionId(-1);
+			} else
+			{
+				collisionObject->setIslandTag(-1);
+				collisionObject->setCompanionId(-2);
+			}
+			index++;
+		}
+	}
+}
+
+inline	int	getIslandId(const btPersistentManifold* lhs)
+{
+	int islandId;
+	const btCollisionObject* rcolObj0 = static_cast<const btCollisionObject*>(lhs->getBody0());
+	const btCollisionObject* rcolObj1 = static_cast<const btCollisionObject*>(lhs->getBody1());
+	islandId= rcolObj0->getIslandTag()>=0?rcolObj0->getIslandTag():rcolObj1->getIslandTag();
+	return islandId;
+
+}
+
+
+
+/// function object that routes calls to operator<
+class btPersistentManifoldSortPredicate
+{
+	public:
+
+		SIMD_FORCE_INLINE bool operator() ( const btPersistentManifold* lhs, const btPersistentManifold* rhs )
+		{
+			return getIslandId(lhs) < getIslandId(rhs);
+		}
+};
+
+
+void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects)
+{
+
+	BT_PROFILE("islandUnionFindAndQuickSort");
+	
+	m_islandmanifold.resize(0);
+
+	//we are going to sort the unionfind array, and store the element id in the size
+	//afterwards, we clean unionfind, to make sure no-one uses it anymore
+	
+	getUnionFind().sortIslands();
+	int numElem = getUnionFind().getNumElements();
+
+	int endIslandIndex=1;
+	int startIslandIndex;
+
+
+	//update the sleeping state for bodies, if all are sleeping
+	for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
+	{
+		int islandId = getUnionFind().getElement(startIslandIndex).m_id;
+		for (endIslandIndex = startIslandIndex+1;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
+		{
+		}
+
+		//int numSleeping = 0;
+
+		bool allSleeping = true;
+
+		int idx;
+		for (idx=startIslandIndex;idx<endIslandIndex;idx++)
+		{
+			int i = getUnionFind().getElement(idx).m_sz;
+
+			btCollisionObject* colObj0 = collisionObjects[i];
+			if ((colObj0->getIslandTag() != islandId) && (colObj0->getIslandTag() != -1))
+			{
+//				printf("error in island management\n");
+			}
+
+			assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+			if (colObj0->getIslandTag() == islandId)
+			{
+				if (colObj0->getActivationState()== ACTIVE_TAG)
+				{
+					allSleeping = false;
+				}
+				if (colObj0->getActivationState()== DISABLE_DEACTIVATION)
+				{
+					allSleeping = false;
+				}
+			}
+		}
+			
+
+		if (allSleeping)
+		{
+			int idx;
+			for (idx=startIslandIndex;idx<endIslandIndex;idx++)
+			{
+				int i = getUnionFind().getElement(idx).m_sz;
+				btCollisionObject* colObj0 = collisionObjects[i];
+				if ((colObj0->getIslandTag() != islandId) && (colObj0->getIslandTag() != -1))
+				{
+//					printf("error in island management\n");
+				}
+
+				assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+
+				if (colObj0->getIslandTag() == islandId)
+				{
+					colObj0->setActivationState( ISLAND_SLEEPING );
+				}
+			}
+		} else
+		{
+
+			int idx;
+			for (idx=startIslandIndex;idx<endIslandIndex;idx++)
+			{
+				int i = getUnionFind().getElement(idx).m_sz;
+
+				btCollisionObject* colObj0 = collisionObjects[i];
+				if ((colObj0->getIslandTag() != islandId) && (colObj0->getIslandTag() != -1))
+				{
+//					printf("error in island management\n");
+				}
+
+				assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+
+				if (colObj0->getIslandTag() == islandId)
+				{
+					if ( colObj0->getActivationState() == ISLAND_SLEEPING)
+					{
+						colObj0->setActivationState( WANTS_DEACTIVATION);
+					}
+				}
+			}
+		}
+	}
+
+	
+	int i;
+	int maxNumManifolds = dispatcher->getNumManifolds();
+
+#define SPLIT_ISLANDS 1
+#ifdef SPLIT_ISLANDS
+
+	
+#endif //SPLIT_ISLANDS
+
+	
+	for (i=0;i<maxNumManifolds ;i++)
+	{
+		 btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
+		 
+		 btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->getBody0());
+		 btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->getBody1());
+		
+		 //todo: check sleeping conditions!
+		 if (((colObj0) && colObj0->getActivationState() != ISLAND_SLEEPING) ||
+			((colObj1) && colObj1->getActivationState() != ISLAND_SLEEPING))
+		{
+		
+			//kinematic objects don't merge islands, but wake up all connected objects
+			if (colObj0->isKinematicObject() && colObj0->getActivationState() != ISLAND_SLEEPING)
+			{
+				colObj1->activate();
+			}
+			if (colObj1->isKinematicObject() && colObj1->getActivationState() != ISLAND_SLEEPING)
+			{
+				colObj0->activate();
+			}
+#ifdef SPLIT_ISLANDS
+	//		//filtering for response
+			if (dispatcher->needsResponse(colObj0,colObj1))
+				m_islandmanifold.push_back(manifold);
+#endif //SPLIT_ISLANDS
+		}
+	}
+}
+
+
+
+//
+// todo: this is random access, it can be walked 'cache friendly'!
+//
+void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback)
+{
+
+	buildIslands(dispatcher,collisionObjects);
+
+	int endIslandIndex=1;
+	int startIslandIndex;
+	int numElem = getUnionFind().getNumElements();
+
+	BT_PROFILE("processIslands");
+
+#ifndef SPLIT_ISLANDS
+	btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
+	
+	callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
+#else
+	// Sort manifolds, based on islands
+	// Sort the vector using predicate and std::sort
+	//std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);
+
+	int numManifolds = int (m_islandmanifold.size());
+
+	//we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
+	m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());
+
+	//now process all active islands (sets of manifolds for now)
+
+	int startManifoldIndex = 0;
+	int endManifoldIndex = 1;
+
+	//int islandId;
+
+	
+
+//	printf("Start Islands\n");
+
+	//traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
+	for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
+	{
+		int islandId = getUnionFind().getElement(startIslandIndex).m_id;
+
+
+	       bool islandSleeping = false;
+                
+                for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
+                {
+                        int i = getUnionFind().getElement(endIslandIndex).m_sz;
+                        btCollisionObject* colObj0 = collisionObjects[i];
+						m_islandBodies.push_back(colObj0);
+                        if (!colObj0->isActive())
+                                islandSleeping = true;
+                }
+                
+
+		//find the accompanying contact manifold for this islandId
+		int numIslandManifolds = 0;
+		btPersistentManifold** startManifold = 0;
+
+		if (startManifoldIndex<numManifolds)
+		{
+			int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
+			if (curIslandId == islandId)
+			{
+				startManifold = &m_islandmanifold[startManifoldIndex];
+			
+				for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
+				{
+
+				}
+				/// Process the actual simulation, only if not sleeping/deactivated
+				numIslandManifolds = endManifoldIndex-startManifoldIndex;
+			}
+
+		}
+
+		if (!islandSleeping)
+		{
+			callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
+//			printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
+		}
+		
+		if (numIslandManifolds)
+		{
+			startManifoldIndex = endManifoldIndex;
+		}
+
+		m_islandBodies.resize(0);
+	}
+#endif //SPLIT_ISLANDS
+
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h	(revision 2122)
@@ -0,0 +1,71 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SIMULATION_ISLAND_MANAGER_H
+#define SIMULATION_ISLAND_MANAGER_H
+
+#include "BulletCollision/CollisionDispatch/btUnionFind.h"
+#include "btCollisionCreateFunc.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+
+class btCollisionObject;
+class btCollisionWorld;
+class btDispatcher;
+class btPersistentManifold;
+
+
+///SimulationIslandManager creates and handles simulation islands, using btUnionFind
+class btSimulationIslandManager
+{
+	btUnionFind m_unionFind;
+
+	btAlignedObjectArray<btPersistentManifold*>  m_islandmanifold;
+	btAlignedObjectArray<btCollisionObject* >  m_islandBodies;
+	
+	
+public:
+	btSimulationIslandManager();
+	virtual ~btSimulationIslandManager();
+
+
+	void initUnionFind(int n);	
+	
+		
+	btUnionFind& getUnionFind() { return m_unionFind;}
+
+	virtual	void	updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher);
+	virtual	void	storeIslandActivationState(btCollisionWorld* world);
+
+
+	void	findUnions(btDispatcher* dispatcher,btCollisionWorld* colWorld);
+
+	
+
+	struct	IslandCallback
+	{
+		virtual ~IslandCallback() {};
+
+		virtual	void	ProcessIsland(btCollisionObject** bodies,int numBodies,class btPersistentManifold**	manifolds,int numManifolds, int islandId) = 0;
+	};
+
+	void	buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
+
+	void buildIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects);
+
+};
+
+#endif //SIMULATION_ISLAND_MANAGER_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,260 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSphereBoxCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+//#include <stdio.h>
+
+btSphereBoxCollisionAlgorithm::btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
+: btCollisionAlgorithm(ci),
+m_ownManifold(false),
+m_manifoldPtr(mf),
+m_isSwapped(isSwapped)
+{
+	btCollisionObject* sphereObj = m_isSwapped? col1 : col0;
+	btCollisionObject* boxObj = m_isSwapped? col0 : col1;
+	
+	if (!m_manifoldPtr && m_dispatcher->needsCollision(sphereObj,boxObj))
+	{
+		m_manifoldPtr = m_dispatcher->getNewManifold(sphereObj,boxObj);
+		m_ownManifold = true;
+	}
+}
+
+
+btSphereBoxCollisionAlgorithm::~btSphereBoxCollisionAlgorithm()
+{
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr)
+			m_dispatcher->releaseManifold(m_manifoldPtr);
+	}
+}
+
+
+
+void btSphereBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)dispatchInfo;
+	(void)resultOut;
+	if (!m_manifoldPtr)
+		return;
+
+	btCollisionObject* sphereObj = m_isSwapped? body1 : body0;
+	btCollisionObject* boxObj = m_isSwapped? body0 : body1;
+
+
+	btSphereShape* sphere0 = (btSphereShape*)sphereObj->getCollisionShape();
+
+	btVector3 normalOnSurfaceB;
+	btVector3 pOnBox,pOnSphere;
+	btVector3 sphereCenter = sphereObj->getWorldTransform().getOrigin();
+	btScalar radius = sphere0->getRadius();
+	
+	btScalar dist = getSphereDistance(boxObj,pOnBox,pOnSphere,sphereCenter,radius);
+
+	resultOut->setPersistentManifold(m_manifoldPtr);
+
+	if (dist < SIMD_EPSILON)
+	{
+		btVector3 normalOnSurfaceB = (pOnBox- pOnSphere).normalize();
+
+		/// report a contact. internally this will be kept persistent, and contact reduction is done
+
+		resultOut->addContactPoint(normalOnSurfaceB,pOnBox,dist);
+		
+	}
+
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr->getNumContacts())
+		{
+			resultOut->refreshContactPoints();
+		}
+	}
+
+}
+
+btScalar btSphereBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)resultOut;
+	(void)dispatchInfo;
+	(void)col0;
+	(void)col1;
+
+	//not yet
+	return btScalar(1.);
+}
+
+
+btScalar btSphereBoxCollisionAlgorithm::getSphereDistance(btCollisionObject* boxObj, btVector3& pointOnBox, btVector3& v3PointOnSphere, const btVector3& sphereCenter, btScalar fRadius ) 
+{
+
+	btScalar margins;
+	btVector3 bounds[2];
+	btBoxShape* boxShape= (btBoxShape*)boxObj->getCollisionShape();
+	
+	bounds[0] = -boxShape->getHalfExtentsWithoutMargin();
+	bounds[1] = boxShape->getHalfExtentsWithoutMargin();
+
+	margins = boxShape->getMargin();//also add sphereShape margin?
+
+	const btTransform&	m44T = boxObj->getWorldTransform();
+
+	btVector3	boundsVec[2];
+	btScalar	fPenetration;
+
+	boundsVec[0] = bounds[0];
+	boundsVec[1] = bounds[1];
+
+	btVector3	marginsVec( margins, margins, margins );
+
+	// add margins
+	bounds[0] += marginsVec;
+	bounds[1] -= marginsVec;
+
+	/////////////////////////////////////////////////
+
+	btVector3	tmp, prel, n[6], normal, v3P;
+	btScalar   fSep = btScalar(10000000.0), fSepThis;
+
+	n[0].setValue( btScalar(-1.0),  btScalar(0.0),  btScalar(0.0) );
+	n[1].setValue(  btScalar(0.0), btScalar(-1.0),  btScalar(0.0) );
+	n[2].setValue(  btScalar(0.0),  btScalar(0.0), btScalar(-1.0) );
+	n[3].setValue(  btScalar(1.0),  btScalar(0.0),  btScalar(0.0) );
+	n[4].setValue(  btScalar(0.0),  btScalar(1.0),  btScalar(0.0) );
+	n[5].setValue(  btScalar(0.0),  btScalar(0.0),  btScalar(1.0) );
+
+	// convert  point in local space
+	prel = m44T.invXform( sphereCenter);
+	
+	bool	bFound = false;
+
+	v3P = prel;
+
+	for (int i=0;i<6;i++)
+	{
+		int j = i<3? 0:1;
+		if ( (fSepThis = ((v3P-bounds[j]) .dot(n[i]))) > btScalar(0.0) )
+		{
+			v3P = v3P - n[i]*fSepThis;		
+			bFound = true;
+		}
+	}
+	
+	//
+
+	if ( bFound )
+	{
+		bounds[0] = boundsVec[0];
+		bounds[1] = boundsVec[1];
+
+		normal = (prel - v3P).normalize();
+		pointOnBox = v3P + normal*margins;
+		v3PointOnSphere = prel - normal*fRadius;
+
+		if ( ((v3PointOnSphere - pointOnBox) .dot (normal)) > btScalar(0.0) )
+		{
+			return btScalar(1.0);
+		}
+
+		// transform back in world space
+		tmp = m44T( pointOnBox);
+		pointOnBox    = tmp;
+		tmp  = m44T( v3PointOnSphere);		
+		v3PointOnSphere = tmp;
+		btScalar fSeps2 = (pointOnBox-v3PointOnSphere).length2();
+		
+		//if this fails, fallback into deeper penetration case, below
+		if (fSeps2 > SIMD_EPSILON)
+		{
+			fSep = - btSqrt(fSeps2);
+			normal = (pointOnBox-v3PointOnSphere);
+			normal *= btScalar(1.)/fSep;
+		}
+
+		return fSep;
+	}
+
+	//////////////////////////////////////////////////
+	// Deep penetration case
+
+	fPenetration = getSpherePenetration( boxObj,pointOnBox, v3PointOnSphere, sphereCenter, fRadius,bounds[0],bounds[1] );
+
+	bounds[0] = boundsVec[0];
+	bounds[1] = boundsVec[1];
+
+	if ( fPenetration <= btScalar(0.0) )
+		return (fPenetration-margins);
+	else
+		return btScalar(1.0);
+}
+
+btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btCollisionObject* boxObj,btVector3& pointOnBox, btVector3& v3PointOnSphere, const btVector3& sphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax) 
+{
+
+	btVector3 bounds[2];
+
+	bounds[0] = aabbMin;
+	bounds[1] = aabbMax;
+
+	btVector3	p0, tmp, prel, n[6], normal;
+	btScalar   fSep = btScalar(-10000000.0), fSepThis;
+
+	// set p0 and normal to a default value to shup up GCC
+	p0.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
+	normal.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
+
+	n[0].setValue( btScalar(-1.0),  btScalar(0.0),  btScalar(0.0) );
+	n[1].setValue(  btScalar(0.0), btScalar(-1.0),  btScalar(0.0) );
+	n[2].setValue(  btScalar(0.0),  btScalar(0.0), btScalar(-1.0) );
+	n[3].setValue(  btScalar(1.0),  btScalar(0.0),  btScalar(0.0) );
+	n[4].setValue(  btScalar(0.0),  btScalar(1.0),  btScalar(0.0) );
+	n[5].setValue(  btScalar(0.0),  btScalar(0.0),  btScalar(1.0) );
+
+	const btTransform&	m44T = boxObj->getWorldTransform();
+
+	// convert  point in local space
+	prel = m44T.invXform( sphereCenter);
+
+	///////////
+
+	for (int i=0;i<6;i++)
+	{
+		int j = i<3 ? 0:1;
+		if ( (fSepThis = ((prel-bounds[j]) .dot( n[i]))-fRadius) > btScalar(0.0) )	return btScalar(1.0);
+		if ( fSepThis > fSep )
+		{
+			p0 = bounds[j];	normal = (btVector3&)n[i];
+			fSep = fSepThis;
+		}
+	}
+
+	pointOnBox = prel - normal*(normal.dot((prel-p0)));
+	v3PointOnSphere = pointOnBox + normal*fSep;
+
+	// transform back in world space
+	tmp  = m44T( pointOnBox);		
+	pointOnBox    = tmp;
+	tmp  = m44T( v3PointOnSphere);		v3PointOnSphere = tmp;
+	normal = (pointOnBox-v3PointOnSphere).normalize();
+
+	return fSep;
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,75 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SPHERE_BOX_COLLISION_ALGORITHM_H
+#define SPHERE_BOX_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+class btPersistentManifold;
+#include "btCollisionDispatcher.h"
+
+#include "LinearMath/btVector3.h"
+
+/// btSphereBoxCollisionAlgorithm  provides sphere-box collision detection.
+/// Other features are frame-coherency (persistent data) and collision response.
+class btSphereBoxCollisionAlgorithm : public btCollisionAlgorithm
+{
+	bool	m_ownManifold;
+	btPersistentManifold*	m_manifoldPtr;
+	bool	m_isSwapped;
+	
+public:
+
+	btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
+
+	virtual ~btSphereBoxCollisionAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		if (m_manifoldPtr && m_ownManifold)
+		{
+			manifoldArray.push_back(m_manifoldPtr);
+		}
+	}
+
+	btScalar getSphereDistance( btCollisionObject* boxObj,btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius );
+
+	btScalar getSpherePenetration( btCollisionObject* boxObj, btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax);
+	
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereBoxCollisionAlgorithm));
+			if (!m_swapped)
+			{
+				return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,false);
+			} else
+			{
+				return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,true);
+			}
+		}
+	};
+
+};
+
+#endif //SPHERE_BOX_COLLISION_ALGORITHM_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,105 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSphereSphereCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1)
+: btCollisionAlgorithm(ci),
+m_ownManifold(false),
+m_manifoldPtr(mf)
+{
+	if (!m_manifoldPtr)
+	{
+		m_manifoldPtr = m_dispatcher->getNewManifold(col0,col1);
+		m_ownManifold = true;
+	}
+}
+
+btSphereSphereCollisionAlgorithm::~btSphereSphereCollisionAlgorithm()
+{
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr)
+			m_dispatcher->releaseManifold(m_manifoldPtr);
+	}
+}
+
+void btSphereSphereCollisionAlgorithm::processCollision (btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)dispatchInfo;
+
+	if (!m_manifoldPtr)
+		return;
+
+	resultOut->setPersistentManifold(m_manifoldPtr);
+
+	btSphereShape* sphere0 = (btSphereShape*)col0->getCollisionShape();
+	btSphereShape* sphere1 = (btSphereShape*)col1->getCollisionShape();
+
+	btVector3 diff = col0->getWorldTransform().getOrigin()-  col1->getWorldTransform().getOrigin();
+	btScalar len = diff.length();
+	btScalar radius0 = sphere0->getRadius();
+	btScalar radius1 = sphere1->getRadius();
+
+#ifdef CLEAR_MANIFOLD
+	m_manifoldPtr->clearManifold(); //don't do this, it disables warmstarting
+#endif
+
+	///iff distance positive, don't generate a new contact
+	if ( len > (radius0+radius1))
+	{
+#ifndef CLEAR_MANIFOLD
+		resultOut->refreshContactPoints();
+#endif //CLEAR_MANIFOLD
+		return;
+	}
+	///distance (negative means penetration)
+	btScalar dist = len - (radius0+radius1);
+
+	btVector3 normalOnSurfaceB(1,0,0);
+	if (len > SIMD_EPSILON)
+	{
+		normalOnSurfaceB = diff / len;
+	}
+
+	///point on A (worldspace)
+	btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
+	///point on B (worldspace)
+	btVector3 pos1 = col1->getWorldTransform().getOrigin() + radius1* normalOnSurfaceB;
+
+	/// report a contact. internally this will be kept persistent, and contact reduction is done
+	
+	
+	resultOut->addContactPoint(normalOnSurfaceB,pos1,dist);
+
+#ifndef CLEAR_MANIFOLD
+	resultOut->refreshContactPoints();
+#endif //CLEAR_MANIFOLD
+
+}
+
+btScalar btSphereSphereCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)col0;
+	(void)col1;
+	(void)dispatchInfo;
+	(void)resultOut;
+
+	//not yet
+	return btScalar(1.);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,66 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SPHERE_SPHERE_COLLISION_ALGORITHM_H
+#define SPHERE_SPHERE_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+#include "btCollisionDispatcher.h"
+
+class btPersistentManifold;
+
+/// btSphereSphereCollisionAlgorithm  provides sphere-sphere collision detection.
+/// Other features are frame-coherency (persistent data) and collision response.
+/// Also provides the most basic sample for custom/user btCollisionAlgorithm
+class btSphereSphereCollisionAlgorithm : public btCollisionAlgorithm
+{
+	bool	m_ownManifold;
+	btPersistentManifold*	m_manifoldPtr;
+	
+public:
+	btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+
+	btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
+		: btCollisionAlgorithm(ci) {}
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		if (m_manifoldPtr && m_ownManifold)
+		{
+			manifoldArray.push_back(m_manifoldPtr);
+		}
+	}
+	
+	virtual ~btSphereSphereCollisionAlgorithm();
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereSphereCollisionAlgorithm));
+			return new(mem) btSphereSphereCollisionAlgorithm(0,ci,body0,body1);
+		}
+	};
+
+};
+
+#endif //SPHERE_SPHERE_COLLISION_ALGORITHM_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btSphereTriangleCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "SphereTriangleDetector.h"
+
+
+btSphereTriangleCollisionAlgorithm::btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1,bool swapped)
+: btCollisionAlgorithm(ci),
+m_ownManifold(false),
+m_manifoldPtr(mf),
+m_swapped(swapped)
+{
+	if (!m_manifoldPtr)
+	{
+		m_manifoldPtr = m_dispatcher->getNewManifold(col0,col1);
+		m_ownManifold = true;
+	}
+}
+
+btSphereTriangleCollisionAlgorithm::~btSphereTriangleCollisionAlgorithm()
+{
+	if (m_ownManifold)
+	{
+		if (m_manifoldPtr)
+			m_dispatcher->releaseManifold(m_manifoldPtr);
+	}
+}
+
+void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	if (!m_manifoldPtr)
+		return;
+
+	btCollisionObject* sphereObj = m_swapped? col1 : col0;
+	btCollisionObject* triObj = m_swapped? col0 : col1;
+
+	btSphereShape* sphere = (btSphereShape*)sphereObj->getCollisionShape();
+	btTriangleShape* triangle = (btTriangleShape*)triObj->getCollisionShape();
+	
+	/// report a contact. internally this will be kept persistent, and contact reduction is done
+	resultOut->setPersistentManifold(m_manifoldPtr);
+	SphereTriangleDetector detector(sphere,triangle);
+	
+	btDiscreteCollisionDetectorInterface::ClosestPointInput input;
+	input.m_maximumDistanceSquared = btScalar(1e30);//todo: tighter bounds
+	input.m_transformA = sphereObj->getWorldTransform();
+	input.m_transformB = triObj->getWorldTransform();
+
+	bool swapResults = m_swapped;
+
+	detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw,swapResults);
+
+	if (m_ownManifold)
+		resultOut->refreshContactPoints();
+	
+}
+
+btScalar btSphereTriangleCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)resultOut;
+	(void)dispatchInfo;
+	(void)col0;
+	(void)col1;
+
+	//not yet
+	return btScalar(1.);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
+#define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+class btPersistentManifold;
+#include "btCollisionDispatcher.h"
+
+/// btSphereSphereCollisionAlgorithm  provides sphere-sphere collision detection.
+/// Other features are frame-coherency (persistent data) and collision response.
+/// Also provides the most basic sample for custom/user btCollisionAlgorithm
+class btSphereTriangleCollisionAlgorithm : public btCollisionAlgorithm
+{
+	bool	m_ownManifold;
+	btPersistentManifold*	m_manifoldPtr;
+	bool	m_swapped;
+	
+public:
+	btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool swapped);
+
+	btSphereTriangleCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
+		: btCollisionAlgorithm(ci) {}
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		if (m_manifoldPtr && m_ownManifold)
+		{
+			manifoldArray.push_back(m_manifoldPtr);
+		}
+	}
+	
+	virtual ~btSphereTriangleCollisionAlgorithm();
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereTriangleCollisionAlgorithm));
+
+			return new(mem) btSphereTriangleCollisionAlgorithm(ci.m_manifold,ci,body0,body1,m_swapped);
+		}
+	};
+
+};
+
+#endif //SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp	(revision 2122)
@@ -0,0 +1,83 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btUnionFind.h"
+#include <assert.h>
+
+
+
+
+btUnionFind::~btUnionFind()
+{
+	Free();
+
+}
+
+btUnionFind::btUnionFind()
+{ 
+
+}
+
+void	btUnionFind::allocate(int N)
+{
+	m_elements.resize(N);
+}
+void	btUnionFind::Free()
+{
+	m_elements.clear();
+}
+
+
+void	btUnionFind::reset(int N)
+{
+	allocate(N);
+
+	for (int i = 0; i < N; i++) 
+	{ 
+		m_elements[i].m_id = i; m_elements[i].m_sz = 1; 
+	} 
+}
+
+
+class btUnionFindElementSortPredicate
+{
+	public:
+
+		bool operator() ( const btElement& lhs, const btElement& rhs )
+		{
+			return lhs.m_id < rhs.m_id;
+		}
+};
+
+///this is a special operation, destroying the content of btUnionFind.
+///it sorts the elements, based on island id, in order to make it easy to iterate over islands
+void	btUnionFind::sortIslands()
+{
+
+	//first store the original body index, and islandId
+	int numElements = m_elements.size();
+	
+	for (int i=0;i<numElements;i++)
+	{
+		m_elements[i].m_id = find(i);
+		m_elements[i].m_sz = i;
+	}
+	
+	 // Sort the vector using predicate and std::sort
+	  //std::sort(m_elements.begin(), m_elements.end(), btUnionFindElementSortPredicate);
+	  m_elements.quickSort(btUnionFindElementSortPredicate());
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h	(revision 2122)
@@ -0,0 +1,124 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef UNION_FIND_H
+#define UNION_FIND_H
+
+#include "LinearMath/btAlignedObjectArray.h"
+
+	#define USE_PATH_COMPRESSION 1
+
+struct	btElement
+{
+	int	m_id;
+	int	m_sz;
+};
+
+///UnionFind calculates connected subsets
+// Implements weighted Quick Union with path compression
+// optimization: could use short ints instead of ints (halving memory, would limit the number of rigid bodies to 64k, sounds reasonable)
+class btUnionFind
+  {
+    private:
+		btAlignedObjectArray<btElement>	m_elements;
+
+    public:
+	  
+		btUnionFind();
+		~btUnionFind();
+
+	
+		//this is a special operation, destroying the content of btUnionFind.
+		//it sorts the elements, based on island id, in order to make it easy to iterate over islands
+		void	sortIslands();
+
+	  void	reset(int N);
+
+	  SIMD_FORCE_INLINE int	getNumElements() const
+	  {
+		  return int(m_elements.size());
+	  }
+	  SIMD_FORCE_INLINE bool  isRoot(int x) const
+	  {
+		  return (x == m_elements[x].m_id);
+	  }
+
+	  btElement&	getElement(int index)
+	  {
+		  return m_elements[index];
+	  }
+	  const btElement& getElement(int index) const
+	  {
+		  return m_elements[index];
+	  }
+   
+	  void	allocate(int N);
+	  void	Free();
+
+
+
+
+	  int find(int p, int q)
+		{ 
+			return (find(p) == find(q)); 
+		}
+
+		void unite(int p, int q)
+		{
+			int i = find(p), j = find(q);
+			if (i == j) 
+				return;
+
+#ifndef USE_PATH_COMPRESSION
+			//weighted quick union, this keeps the 'trees' balanced, and keeps performance of unite O( log(n) )
+			if (m_elements[i].m_sz < m_elements[j].m_sz)
+			{ 
+				m_elements[i].m_id = j; m_elements[j].m_sz += m_elements[i].m_sz; 
+			}
+			else 
+			{ 
+				m_elements[j].m_id = i; m_elements[i].m_sz += m_elements[j].m_sz; 
+			}
+#else
+			m_elements[i].m_id = j; m_elements[j].m_sz += m_elements[i].m_sz; 
+#endif //USE_PATH_COMPRESSION
+		}
+
+		int find(int x)
+		{ 
+			//assert(x < m_N);
+			//assert(x >= 0);
+
+			while (x != m_elements[x].m_id) 
+			{
+		//not really a reason not to use path compression, and it flattens the trees/improves find performance dramatically
+	
+		#ifdef USE_PATH_COMPRESSION
+				//
+				m_elements[x].m_id = m_elements[m_elements[x].m_id].m_id;
+		#endif //
+				x = m_elements[x].m_id;
+				//assert(x < m_N);
+				//assert(x >= 0);
+
+			}
+			return x; 
+		}
+
+
+  };
+
+
+#endif //UNION_FIND_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBoxShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBoxShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBoxShape.cpp	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btBoxShape.h"
+
+
+//{ 
+
+
+void btBoxShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	btTransformAabb(getHalfExtentsWithoutMargin(),getMargin(),t,aabbMin,aabbMax);
+}
+
+
+void	btBoxShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	//btScalar margin = btScalar(0.);
+	btVector3 halfExtents = getHalfExtentsWithMargin();
+
+	btScalar lx=btScalar(2.)*(halfExtents.x());
+	btScalar ly=btScalar(2.)*(halfExtents.y());
+	btScalar lz=btScalar(2.)*(halfExtents.z());
+
+	inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz),
+					mass/(btScalar(12.0)) * (lx*lx + lz*lz),
+					mass/(btScalar(12.0)) * (lx*lx + ly*ly));
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h	(revision 2122)
@@ -0,0 +1,323 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef OBB_BOX_MINKOWSKI_H
+#define OBB_BOX_MINKOWSKI_H
+
+#include "btPolyhedralConvexShape.h"
+#include "btCollisionMargin.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "LinearMath/btPoint3.h"
+#include "LinearMath/btMinMax.h"
+
+///The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by half extents, in local shape coordinates. When used as part of a btCollisionObject or btRigidBody it will be an oriented box in world space.
+class btBoxShape: public btPolyhedralConvexShape
+{
+
+	//btVector3	m_boxHalfExtents1; //use m_implicitShapeDimensions instead
+
+
+public:
+
+	btVector3 getHalfExtentsWithMargin() const
+	{
+		btVector3 halfExtents = getHalfExtentsWithoutMargin();
+		btVector3 margin(getMargin(),getMargin(),getMargin());
+		halfExtents += margin;
+		return halfExtents;
+	}
+	
+	const btVector3& getHalfExtentsWithoutMargin() const
+	{
+		return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included
+	}
+	
+
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec) const
+	{
+		btVector3 halfExtents = getHalfExtentsWithoutMargin();
+		btVector3 margin(getMargin(),getMargin(),getMargin());
+		halfExtents += margin;
+		
+		return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
+			btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
+			btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
+	}
+
+	SIMD_FORCE_INLINE  btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+	{
+		const btVector3& halfExtents = getHalfExtentsWithoutMargin();
+		
+		return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
+			btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
+			btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
+	}
+
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+	{
+		const btVector3& halfExtents = getHalfExtentsWithoutMargin();
+	
+		for (int i=0;i<numVectors;i++)
+		{
+			const btVector3& vec = vectors[i];
+			supportVerticesOut[i].setValue(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
+				btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
+				btFsels(vec.z(), halfExtents.z(), -halfExtents.z())); 
+		}
+
+	}
+
+
+	btBoxShape( const btVector3& boxHalfExtents) 
+		: btPolyhedralConvexShape()
+	{
+		m_shapeType = BOX_SHAPE_PROXYTYPE;
+		btVector3 margin(getMargin(),getMargin(),getMargin());
+		m_implicitShapeDimensions = (boxHalfExtents * m_localScaling) - margin;
+	};
+
+	virtual void setMargin(btScalar collisionMargin)
+	{
+		//correct the m_implicitShapeDimensions for the margin
+		btVector3 oldMargin(getMargin(),getMargin(),getMargin());
+		btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
+		
+		btConvexInternalShape::setMargin(collisionMargin);
+		btVector3 newMargin(getMargin(),getMargin(),getMargin());
+		m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
+
+	}
+	virtual void	setLocalScaling(const btVector3& scaling)
+	{
+		btVector3 oldMargin(getMargin(),getMargin(),getMargin());
+		btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
+		btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;
+
+		btConvexInternalShape::setLocalScaling(scaling);
+
+		m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;
+
+	}
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const
+	{
+		//this plane might not be aligned...
+		btVector4 plane ;
+		getPlaneEquation(plane,i);
+		planeNormal = btVector3(plane.getX(),plane.getY(),plane.getZ());
+		planeSupport = localGetSupportingVertex(-planeNormal);
+	}
+
+	
+	virtual int getNumPlanes() const
+	{
+		return 6;
+	}	
+	
+	virtual int	getNumVertices() const 
+	{
+		return 8;
+	}
+
+	virtual int getNumEdges() const
+	{
+		return 12;
+	}
+
+
+	virtual void getVertex(int i,btVector3& vtx) const
+	{
+		btVector3 halfExtents = getHalfExtentsWithoutMargin();
+
+		vtx = btVector3(
+				halfExtents.x() * (1-(i&1)) - halfExtents.x() * (i&1),
+				halfExtents.y() * (1-((i&2)>>1)) - halfExtents.y() * ((i&2)>>1),
+				halfExtents.z() * (1-((i&4)>>2)) - halfExtents.z() * ((i&4)>>2));
+	}
+	
+
+	virtual void	getPlaneEquation(btVector4& plane,int i) const
+	{
+		btVector3 halfExtents = getHalfExtentsWithoutMargin();
+
+		switch (i)
+		{
+		case 0:
+			plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
+			plane[3] = -halfExtents.x();
+			break;
+		case 1:
+			plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
+			plane[3] = -halfExtents.x();
+			break;
+		case 2:
+			plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
+			plane[3] = -halfExtents.y();
+			break;
+		case 3:
+			plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
+			plane[3] = -halfExtents.y();
+			break;
+		case 4:
+			plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
+			plane[3] = -halfExtents.z();
+			break;
+		case 5:
+			plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
+			plane[3] = -halfExtents.z();
+			break;
+		default:
+			assert(0);
+		}
+	}
+
+	
+	virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const
+	//virtual void getEdge(int i,Edge& edge) const
+	{
+		int edgeVert0 = 0;
+		int edgeVert1 = 0;
+
+		switch (i)
+		{
+		case 0:
+				edgeVert0 = 0;
+				edgeVert1 = 1;
+			break;
+		case 1:
+				edgeVert0 = 0;
+				edgeVert1 = 2;
+			break;
+		case 2:
+			edgeVert0 = 1;
+			edgeVert1 = 3;
+
+			break;
+		case 3:
+			edgeVert0 = 2;
+			edgeVert1 = 3;
+			break;
+		case 4:
+			edgeVert0 = 0;
+			edgeVert1 = 4;
+			break;
+		case 5:
+			edgeVert0 = 1;
+			edgeVert1 = 5;
+
+			break;
+		case 6:
+			edgeVert0 = 2;
+			edgeVert1 = 6;
+			break;
+		case 7:
+			edgeVert0 = 3;
+			edgeVert1 = 7;
+			break;
+		case 8:
+			edgeVert0 = 4;
+			edgeVert1 = 5;
+			break;
+		case 9:
+			edgeVert0 = 4;
+			edgeVert1 = 6;
+			break;
+		case 10:
+			edgeVert0 = 5;
+			edgeVert1 = 7;
+			break;
+		case 11:
+			edgeVert0 = 6;
+			edgeVert1 = 7;
+			break;
+		default:
+			btAssert(0);
+
+		}
+
+		getVertex(edgeVert0,pa );
+		getVertex(edgeVert1,pb );
+	}
+
+
+
+
+	
+	virtual	bool isInside(const btPoint3& pt,btScalar tolerance) const
+	{
+		btVector3 halfExtents = getHalfExtentsWithoutMargin();
+
+		//btScalar minDist = 2*tolerance;
+		
+		bool result =	(pt.x() <= (halfExtents.x()+tolerance)) &&
+						(pt.x() >= (-halfExtents.x()-tolerance)) &&
+						(pt.y() <= (halfExtents.y()+tolerance)) &&
+						(pt.y() >= (-halfExtents.y()-tolerance)) &&
+						(pt.z() <= (halfExtents.z()+tolerance)) &&
+						(pt.z() >= (-halfExtents.z()-tolerance));
+		
+		return result;
+	}
+
+
+	//debugging
+	virtual const char*	getName()const
+	{
+		return "Box";
+	}
+
+	virtual int		getNumPreferredPenetrationDirections() const
+	{
+		return 6;
+	}
+	
+	virtual void	getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+	{
+		switch (index)
+		{
+		case 0:
+			penetrationVector.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
+			break;
+		case 1:
+			penetrationVector.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
+			break;
+		case 2:
+			penetrationVector.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
+			break;
+		case 3:
+			penetrationVector.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
+			break;
+		case 4:
+			penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
+			break;
+		case 5:
+			penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
+			break;
+		default:
+			assert(0);
+		}
+	}
+
+};
+
+#endif //OBB_BOX_MINKOWSKI_H
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp	(revision 2122)
@@ -0,0 +1,344 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+//#define DISABLE_BVH
+
+#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btOptimizedBvh.h"
+
+///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization.
+///Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
+btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh)
+:btTriangleMeshShape(meshInterface),
+m_bvh(0),
+m_useQuantizedAabbCompression(useQuantizedAabbCompression),
+m_ownsBvh(false)
+{
+	m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;
+	//construct bvh from meshInterface
+#ifndef DISABLE_BVH
+
+	btVector3 bvhAabbMin,bvhAabbMax;
+	if(meshInterface->hasPremadeAabb())
+	{
+		meshInterface->getPremadeAabb(&bvhAabbMin, &bvhAabbMax);
+	}
+	else
+	{
+		meshInterface->calculateAabbBruteForce(bvhAabbMin,bvhAabbMax);
+	}
+	
+	if (buildBvh)
+	{
+		void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
+		m_bvh = new (mem) btOptimizedBvh();
+		m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax);
+		m_ownsBvh = true;
+	}
+
+#endif //DISABLE_BVH
+
+}
+
+btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,bool buildBvh)
+:btTriangleMeshShape(meshInterface),
+m_bvh(0),
+m_useQuantizedAabbCompression(useQuantizedAabbCompression),
+m_ownsBvh(false)
+{
+	m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;
+	//construct bvh from meshInterface
+#ifndef DISABLE_BVH
+
+	if (buildBvh)
+	{
+		void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
+		m_bvh = new (mem) btOptimizedBvh();
+		
+		m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax);
+		m_ownsBvh = true;
+	}
+
+#endif //DISABLE_BVH
+
+}
+
+void	btBvhTriangleMeshShape::partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax)
+{
+	m_bvh->refitPartial( m_meshInterface,aabbMin,aabbMax );
+	
+	m_localAabbMin.setMin(aabbMin);
+	m_localAabbMax.setMax(aabbMax);
+}
+
+
+void	btBvhTriangleMeshShape::refitTree(const btVector3& aabbMin,const btVector3& aabbMax)
+{
+	m_bvh->refit( m_meshInterface, aabbMin,aabbMax );
+	
+	recalcLocalAabb();
+}
+
+btBvhTriangleMeshShape::~btBvhTriangleMeshShape()
+{
+	if (m_ownsBvh)
+	{
+		m_bvh->~btOptimizedBvh();
+		btAlignedFree(m_bvh);
+	}
+}
+
+void	btBvhTriangleMeshShape::performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget)
+{
+	struct	MyNodeOverlapCallback : public btNodeOverlapCallback
+	{
+		btStridingMeshInterface*	m_meshInterface;
+		btTriangleCallback* m_callback;
+
+		MyNodeOverlapCallback(btTriangleCallback* callback,btStridingMeshInterface* meshInterface)
+			:m_meshInterface(meshInterface),
+			m_callback(callback)
+		{
+		}
+				
+		virtual void processNode(int nodeSubPart, int nodeTriangleIndex)
+		{
+			btVector3 m_triangle[3];
+			const unsigned char *vertexbase;
+			int numverts;
+			PHY_ScalarType type;
+			int stride;
+			const unsigned char *indexbase;
+			int indexstride;
+			int numfaces;
+			PHY_ScalarType indicestype;
+
+			m_meshInterface->getLockedReadOnlyVertexIndexBase(
+				&vertexbase,
+				numverts,
+				type,
+				stride,
+				&indexbase,
+				indexstride,
+				numfaces,
+				indicestype,
+				nodeSubPart);
+
+			unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
+			btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
+	
+			const btVector3& meshScaling = m_meshInterface->getScaling();
+			for (int j=2;j>=0;j--)
+			{
+				int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
+
+				btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
+
+				m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());		
+			}
+
+			/* Perform ray vs. triangle collision here */
+			m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex);
+			m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart);
+		}
+	};
+
+	MyNodeOverlapCallback	myNodeCallback(callback,m_meshInterface);
+
+	m_bvh->reportRayOverlappingNodex(&myNodeCallback,raySource,rayTarget);
+}
+
+void	btBvhTriangleMeshShape::performConvexcast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax)
+{
+	struct	MyNodeOverlapCallback : public btNodeOverlapCallback
+	{
+		btStridingMeshInterface*	m_meshInterface;
+		btTriangleCallback* m_callback;
+
+		MyNodeOverlapCallback(btTriangleCallback* callback,btStridingMeshInterface* meshInterface)
+			:m_meshInterface(meshInterface),
+			m_callback(callback)
+		{
+		}
+				
+		virtual void processNode(int nodeSubPart, int nodeTriangleIndex)
+		{
+			btVector3 m_triangle[3];
+			const unsigned char *vertexbase;
+			int numverts;
+			PHY_ScalarType type;
+			int stride;
+			const unsigned char *indexbase;
+			int indexstride;
+			int numfaces;
+			PHY_ScalarType indicestype;
+
+			m_meshInterface->getLockedReadOnlyVertexIndexBase(
+				&vertexbase,
+				numverts,
+				type,
+				stride,
+				&indexbase,
+				indexstride,
+				numfaces,
+				indicestype,
+				nodeSubPart);
+
+			unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
+			btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
+	
+			const btVector3& meshScaling = m_meshInterface->getScaling();
+			for (int j=2;j>=0;j--)
+			{
+				int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
+
+				btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
+
+				m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());		
+			}
+
+			/* Perform ray vs. triangle collision here */
+			m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex);
+			m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart);
+		}
+	};
+
+	MyNodeOverlapCallback	myNodeCallback(callback,m_meshInterface);
+
+	m_bvh->reportBoxCastOverlappingNodex (&myNodeCallback, raySource, rayTarget, aabbMin, aabbMax);
+}
+
+//perform bvh tree traversal and report overlapping triangles to 'callback'
+void	btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+
+#ifdef DISABLE_BVH
+	//brute force traverse all triangles
+	btTriangleMeshShape::processAllTriangles(callback,aabbMin,aabbMax);
+#else
+
+	//first get all the nodes
+
+	
+	struct	MyNodeOverlapCallback : public btNodeOverlapCallback
+	{
+		btStridingMeshInterface*	m_meshInterface;
+		btTriangleCallback*		m_callback;
+		btVector3				m_triangle[3];
+
+
+		MyNodeOverlapCallback(btTriangleCallback* callback,btStridingMeshInterface* meshInterface)
+			:m_meshInterface(meshInterface),
+			m_callback(callback)
+		{
+		}
+				
+		virtual void processNode(int nodeSubPart, int nodeTriangleIndex)
+		{
+			const unsigned char *vertexbase;
+			int numverts;
+			PHY_ScalarType type;
+			int stride;
+			const unsigned char *indexbase;
+			int indexstride;
+			int numfaces;
+			PHY_ScalarType indicestype;
+			
+
+			m_meshInterface->getLockedReadOnlyVertexIndexBase(
+				&vertexbase,
+				numverts,
+				type,
+				stride,
+				&indexbase,
+				indexstride,
+				numfaces,
+				indicestype,
+				nodeSubPart);
+
+			unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
+			btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
+	
+			const btVector3& meshScaling = m_meshInterface->getScaling();
+			for (int j=2;j>=0;j--)
+			{
+				
+				int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
+
+
+#ifdef DEBUG_TRIANGLE_MESH
+				printf("%d ,",graphicsindex);
+#endif //DEBUG_TRIANGLE_MESH
+				btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
+
+				m_triangle[j] = btVector3(
+					graphicsbase[0]*meshScaling.getX(),
+					graphicsbase[1]*meshScaling.getY(),
+					graphicsbase[2]*meshScaling.getZ());
+#ifdef DEBUG_TRIANGLE_MESH
+				printf("triangle vertices:%f,%f,%f\n",triangle[j].x(),triangle[j].y(),triangle[j].z());
+#endif //DEBUG_TRIANGLE_MESH
+			}
+
+			m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex);
+			m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart);
+		}
+
+	};
+
+	MyNodeOverlapCallback	myNodeCallback(callback,m_meshInterface);
+
+	m_bvh->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax);
+
+
+#endif//DISABLE_BVH
+
+
+}
+
+void   btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling)
+{
+   if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON)
+   {
+      btTriangleMeshShape::setLocalScaling(scaling);
+      if (m_ownsBvh)
+      {
+         m_bvh->~btOptimizedBvh();
+         btAlignedFree(m_bvh);
+      }
+      ///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work
+      void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
+      m_bvh = new(mem) btOptimizedBvh();
+      //rebuild the bvh...
+      m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax);
+      m_ownsBvh = true;
+   }
+}
+
+void   btBvhTriangleMeshShape::setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& scaling)
+{
+   btAssert(!m_bvh);
+   btAssert(!m_ownsBvh);
+
+   m_bvh = bvh;
+   m_ownsBvh = false;
+   // update the scaling without rebuilding the bvh
+   if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON)
+   {
+      btTriangleMeshShape::setLocalScaling(scaling);
+   }
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h	(revision 2122)
@@ -0,0 +1,86 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BVH_TRIANGLE_MESH_SHAPE_H
+#define BVH_TRIANGLE_MESH_SHAPE_H
+
+#include "btTriangleMeshShape.h"
+#include "btOptimizedBvh.h"
+#include "LinearMath/btAlignedAllocator.h"
+
+
+///The btBvhTriangleMeshShape is a static-triangle mesh shape with several optimizations, such as bounding volume hierarchy and cache friendly traversal for PlayStation 3 Cell SPU. It is recommended to enable useQuantizedAabbCompression for better memory usage.
+///It takes a triangle mesh as input, for example a btTriangleMesh or btTriangleIndexVertexArray. The btBvhTriangleMeshShape class allows for triangle mesh deformations by a refit or partialRefit method.
+///Instead of building the bounding volume hierarchy acceleration structure, it is also possible to serialize (save) and deserialize (load) the structure from disk.
+///See Demos\ConcaveDemo\ConcavePhysicsDemo.cpp for an example.
+ATTRIBUTE_ALIGNED16(class) btBvhTriangleMeshShape : public btTriangleMeshShape
+{
+
+	btOptimizedBvh*	m_bvh;
+	bool m_useQuantizedAabbCompression;
+	bool m_ownsBvh;
+	bool m_pad[11];////need padding due to alignment
+
+public:
+
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
+	btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
+
+	///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
+	btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true);
+	
+	virtual ~btBvhTriangleMeshShape();
+
+	bool getOwnsBvh () const
+	{
+		return m_ownsBvh;
+	}
+
+
+	
+	void performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget);
+	void performConvexcast (btTriangleCallback* callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax);
+
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+	void	refitTree(const btVector3& aabbMin,const btVector3& aabbMax);
+
+	///for a fast incremental refit of parts of the tree. Note: the entire AABB of the tree will become more conservative, it never shrinks
+	void	partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax);
+
+	//debugging
+	virtual const char*	getName()const {return "BVHTRIANGLEMESH";}
+
+
+	virtual void	setLocalScaling(const btVector3& scaling);
+	
+	btOptimizedBvh*	getOptimizedBvh()
+	{
+		return m_bvh;
+	}
+
+
+	void	setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));
+
+	bool	usesQuantizedAabbCompression() const
+	{
+		return	m_useQuantizedAabbCompression;
+	}
+}
+;
+
+#endif //BVH_TRIANGLE_MESH_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCapsuleShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCapsuleShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCapsuleShape.cpp	(revision 2122)
@@ -0,0 +1,171 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btCapsuleShape.h"
+
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+#include "LinearMath/btQuaternion.h"
+
+btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInternalShape ()
+{
+	m_shapeType = CAPSULE_SHAPE_PROXYTYPE;
+	m_upAxis = 1;
+	m_implicitShapeDimensions.setValue(radius,0.5f*height,radius);
+}
+
+ 
+ btVector3	btCapsuleShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+{
+
+	btVector3 supVec(0,0,0);
+
+	btScalar maxDot(btScalar(-1e30));
+
+	btVector3 vec = vec0;
+	btScalar lenSqr = vec.length2();
+	if (lenSqr < btScalar(0.0001))
+	{
+		vec.setValue(1,0,0);
+	} else
+	{
+		btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+		vec *= rlen;
+	}
+
+	btVector3 vtx;
+	btScalar newDot;
+	
+	btScalar radius = getRadius();
+
+
+	{
+		btVector3 pos(0,0,0);
+		pos[getUpAxis()] = getHalfHeight();
+
+		vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
+		newDot = vec.dot(vtx);
+		if (newDot > maxDot)
+		{
+			maxDot = newDot;
+			supVec = vtx;
+		}
+	}
+	{
+		btVector3 pos(0,0,0);
+		pos[getUpAxis()] = -getHalfHeight();
+
+		vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
+		newDot = vec.dot(vtx);
+		if (newDot > maxDot)
+		{
+			maxDot = newDot;
+			supVec = vtx;
+		}
+	}
+
+	return supVec;
+
+}
+
+ void	btCapsuleShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+
+	
+	btScalar radius = getRadius();
+
+	for (int j=0;j<numVectors;j++)
+	{
+		btScalar maxDot(btScalar(-1e30));
+		const btVector3& vec = vectors[j];
+
+		btVector3 vtx;
+		btScalar newDot;
+		{
+			btVector3 pos(0,0,0);
+			pos[getUpAxis()] = getHalfHeight();
+			vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
+			newDot = vec.dot(vtx);
+			if (newDot > maxDot)
+			{
+				maxDot = newDot;
+				supportVerticesOut[j] = vtx;
+			}
+		}
+		{
+			btVector3 pos(0,0,0);
+			pos[getUpAxis()] = -getHalfHeight();
+			vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
+			newDot = vec.dot(vtx);
+			if (newDot > maxDot)
+			{
+				maxDot = newDot;
+				supportVerticesOut[j] = vtx;
+			}
+		}
+		
+	}
+}
+
+
+void	btCapsuleShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	//as an approximation, take the inertia of the box that bounds the spheres
+
+	btTransform ident;
+	ident.setIdentity();
+
+	
+	btScalar radius = getRadius();
+
+	btVector3 halfExtents(radius,radius,radius);
+	halfExtents[getUpAxis()]+=getHalfHeight();
+
+	btScalar margin = CONVEX_DISTANCE_MARGIN;
+
+	btScalar lx=btScalar(2.)*(halfExtents[0]+margin);
+	btScalar ly=btScalar(2.)*(halfExtents[1]+margin);
+	btScalar lz=btScalar(2.)*(halfExtents[2]+margin);
+	const btScalar x2 = lx*lx;
+	const btScalar y2 = ly*ly;
+	const btScalar z2 = lz*lz;
+	const btScalar scaledmass = mass * btScalar(.08333333);
+
+	inertia[0] = scaledmass * (y2+z2);
+	inertia[1] = scaledmass * (x2+z2);
+	inertia[2] = scaledmass * (x2+y2);
+
+}
+
+btCapsuleShapeX::btCapsuleShapeX(btScalar radius,btScalar height)
+{
+	m_upAxis = 0;
+	m_implicitShapeDimensions.setValue(0.5f*height, radius,radius);
+}
+
+
+
+
+
+
+btCapsuleShapeZ::btCapsuleShapeZ(btScalar radius,btScalar height)
+{
+	m_upAxis = 2;
+	m_implicitShapeDimensions.setValue(radius,radius,0.5f*height);
+}
+
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCapsuleShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCapsuleShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCapsuleShape.h	(revision 2122)
@@ -0,0 +1,118 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_CAPSULE_SHAPE_H
+#define BT_CAPSULE_SHAPE_H
+
+#include "btConvexInternalShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+
+
+///The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned around the X axis and btCapsuleShapeZ around the Z axis.
+///The total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.
+///The btCapsuleShape is a convex hull of two spheres. The btMultiSphereShape is a more general collision shape that takes the convex hull of multiple sphere, so it can also represent a capsule when just using two spheres.
+class btCapsuleShape : public btConvexInternalShape
+{
+protected:
+	int	m_upAxis;
+
+protected:
+	///only used for btCapsuleShapeZ and btCapsuleShapeX subclasses.
+	btCapsuleShape() : btConvexInternalShape() {m_shapeType = CAPSULE_SHAPE_PROXYTYPE;};
+
+public:
+	btCapsuleShape(btScalar radius,btScalar height);
+
+	///CollisionShape Interface
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	/// btConvexShape Interface
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+	
+	virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
+	{
+			btVector3 halfExtents(getRadius(),getRadius(),getRadius());
+			halfExtents[m_upAxis] = getRadius() + getHalfHeight();
+			halfExtents += btVector3(getMargin(),getMargin(),getMargin());
+			btMatrix3x3 abs_b = t.getBasis().absolute();  
+			btPoint3 center = t.getOrigin();
+			btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));		  
+			
+			aabbMin = center - extent;
+			aabbMax = center + extent;
+	}
+
+	virtual const char*	getName()const 
+	{
+		return "CapsuleShape";
+	}
+
+	int	getUpAxis() const
+	{
+		return m_upAxis;
+	}
+
+	btScalar	getRadius() const
+	{
+		int radiusAxis = (m_upAxis+2)%3;
+		return m_implicitShapeDimensions[radiusAxis];
+	}
+
+	btScalar	getHalfHeight() const
+	{
+		return m_implicitShapeDimensions[m_upAxis];
+	}
+
+};
+
+///btCapsuleShapeX represents a capsule around the Z axis
+///the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.
+class btCapsuleShapeX : public btCapsuleShape
+{
+public:
+
+	btCapsuleShapeX(btScalar radius,btScalar height);
+		
+	//debugging
+	virtual const char*	getName()const
+	{
+		return "CapsuleX";
+	}
+
+	
+
+};
+
+///btCapsuleShapeZ represents a capsule around the Z axis
+///the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.
+class btCapsuleShapeZ : public btCapsuleShape
+{
+public:
+	btCapsuleShapeZ(btScalar radius,btScalar height);
+
+		//debugging
+	virtual const char*	getName()const
+	{
+		return "CapsuleZ";
+	}
+
+	
+};
+
+
+
+#endif //BT_CAPSULE_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h	(revision 2122)
@@ -0,0 +1,26 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COLLISION_MARGIN_H
+#define COLLISION_MARGIN_H
+
+//used by Gjk and some other algorithms
+
+#define CONVEX_DISTANCE_MARGIN btScalar(0.04)// btScalar(0.1)//;//btScalar(0.01)
+
+
+
+#endif //COLLISION_MARGIN_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp	(revision 2122)
@@ -0,0 +1,90 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+
+
+/*
+  Make sure this dummy function never changes so that it
+  can be used by probes that are checking whether the
+  library is actually installed.
+*/
+extern "C" 
+{
+void btBulletCollisionProbe ();
+
+void btBulletCollisionProbe () {}
+}
+
+
+
+void	btCollisionShape::getBoundingSphere(btVector3& center,btScalar& radius) const
+{
+	btTransform tr;
+	tr.setIdentity();
+	btVector3 aabbMin,aabbMax;
+
+	getAabb(tr,aabbMin,aabbMax);
+
+	radius = (aabbMax-aabbMin).length()*btScalar(0.5);
+	center = (aabbMin+aabbMax)*btScalar(0.5);
+}
+
+btScalar	btCollisionShape::getAngularMotionDisc() const
+{
+	btVector3	center;
+	btScalar disc;
+	getBoundingSphere(center,disc);
+	disc += (center).length();
+	return disc;
+}
+
+void btCollisionShape::calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const
+{
+	//start with static aabb
+	getAabb(curTrans,temporalAabbMin,temporalAabbMax);
+
+	btScalar temporalAabbMaxx = temporalAabbMax.getX();
+	btScalar temporalAabbMaxy = temporalAabbMax.getY();
+	btScalar temporalAabbMaxz = temporalAabbMax.getZ();
+	btScalar temporalAabbMinx = temporalAabbMin.getX();
+	btScalar temporalAabbMiny = temporalAabbMin.getY();
+	btScalar temporalAabbMinz = temporalAabbMin.getZ();
+
+	// add linear motion
+	btVector3 linMotion = linvel*timeStep;
+	//todo: simd would have a vector max/min operation, instead of per-element access
+	if (linMotion.x() > btScalar(0.))
+		temporalAabbMaxx += linMotion.x(); 
+	else
+		temporalAabbMinx += linMotion.x();
+	if (linMotion.y() > btScalar(0.))
+		temporalAabbMaxy += linMotion.y(); 
+	else
+		temporalAabbMiny += linMotion.y();
+	if (linMotion.z() > btScalar(0.))
+		temporalAabbMaxz += linMotion.z(); 
+	else
+		temporalAabbMinz += linMotion.z();
+
+	//add conservative angular motion
+	btScalar angularMotion = angvel.length() * getAngularMotionDisc() * timeStep;
+	btVector3 angularMotion3d(angularMotion,angularMotion,angularMotion);
+	temporalAabbMin = btVector3(temporalAabbMinx,temporalAabbMiny,temporalAabbMinz);
+	temporalAabbMax = btVector3(temporalAabbMaxx,temporalAabbMaxy,temporalAabbMaxz);
+
+	temporalAabbMin -= angularMotion3d;
+	temporalAabbMax += angularMotion3d;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.h	(revision 2122)
@@ -0,0 +1,111 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COLLISION_SHAPE_H
+#define COLLISION_SHAPE_H
+
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "LinearMath/btPoint3.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
+
+///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
+class btCollisionShape
+{
+protected:
+	int m_shapeType;
+	void* m_userPointer;
+
+public:
+
+	btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0)
+	{
+	}
+
+	virtual ~btCollisionShape()
+	{
+	}
+
+	///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
+
+	virtual void	getBoundingSphere(btVector3& center,btScalar& radius) const;
+
+	///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
+	virtual btScalar	getAngularMotionDisc() const;
+
+
+	///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep)
+	///result is conservative
+	void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const;
+
+#ifndef __SPU__
+
+	SIMD_FORCE_INLINE bool	isPolyhedral() const
+	{
+		return btBroadphaseProxy::isPolyhedral(getShapeType());
+	}
+
+	SIMD_FORCE_INLINE bool	isConvex() const
+	{
+		return btBroadphaseProxy::isConvex(getShapeType());
+	}
+	SIMD_FORCE_INLINE bool	isConcave() const
+	{
+		return btBroadphaseProxy::isConcave(getShapeType());
+	}
+	SIMD_FORCE_INLINE bool	isCompound() const
+	{
+		return btBroadphaseProxy::isCompound(getShapeType());
+	}
+
+	///isInfinite is used to catch simulation error (aabb check)
+	SIMD_FORCE_INLINE bool isInfinite() const
+	{
+		return btBroadphaseProxy::isInfinite(getShapeType());
+	}
+
+	
+	virtual void	setLocalScaling(const btVector3& scaling) =0;
+	virtual const btVector3& getLocalScaling() const =0;
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0;
+
+
+//debugging support
+	virtual const char*	getName()const =0 ;
+#endif //__SPU__
+
+	
+	int		getShapeType() const { return m_shapeType; }
+	virtual void	setMargin(btScalar margin) = 0;
+	virtual btScalar	getMargin() const = 0;
+
+	
+	///optional user data pointer
+	void	setUserPointer(void*  userPtr)
+	{
+		m_userPointer = userPtr;
+	}
+
+	void*	getUserPointer() const
+	{
+		return m_userPointer;
+	}
+
+};	
+
+#endif //COLLISION_SHAPE_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp	(revision 2122)
@@ -0,0 +1,232 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btCompoundShape.h"
+#include "btCollisionShape.h"
+#include "BulletCollision/BroadphaseCollision/btDbvt.h"
+
+btCompoundShape::btCompoundShape()
+: m_localAabbMin(btScalar(1e30),btScalar(1e30),btScalar(1e30)),
+m_localAabbMax(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)),
+m_collisionMargin(btScalar(0.)),
+m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
+m_dynamicAabbTree(0)
+{
+	m_shapeType = COMPOUND_SHAPE_PROXYTYPE;
+	void* mem = btAlignedAlloc(sizeof(btDbvt),16);
+	m_dynamicAabbTree = new(mem) btDbvt();
+	btAssert(mem==m_dynamicAabbTree);
+}
+
+
+btCompoundShape::~btCompoundShape()
+{
+	if (m_dynamicAabbTree)
+	{
+		m_dynamicAabbTree->~btDbvt();
+		btAlignedFree(m_dynamicAabbTree);
+	}
+}
+
+void	btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape)
+{
+	//m_childTransforms.push_back(localTransform);
+	//m_childShapes.push_back(shape);
+	btCompoundShapeChild child;
+	child.m_transform = localTransform;
+	child.m_childShape = shape;
+	child.m_childShapeType = shape->getShapeType();
+	child.m_childMargin = shape->getMargin();
+
+	m_children.push_back(child);
+
+	//extend the local aabbMin/aabbMax
+	btVector3 localAabbMin,localAabbMax;
+	shape->getAabb(localTransform,localAabbMin,localAabbMax);
+	for (int i=0;i<3;i++)
+	{
+		if (m_localAabbMin[i] > localAabbMin[i])
+		{
+			m_localAabbMin[i] = localAabbMin[i];
+		}
+		if (m_localAabbMax[i] < localAabbMax[i])
+		{
+			m_localAabbMax[i] = localAabbMax[i];
+		}
+
+	}
+	if (m_dynamicAabbTree)
+	{
+		const btDbvtVolume	bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
+		int index = m_children.size()-1;
+		child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index);
+	}
+
+}
+
+void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
+{
+	btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size());
+	if (m_dynamicAabbTree)
+	{
+		m_dynamicAabbTree->remove(m_children[childShapeIndex].m_node);
+	}
+	m_children.swap(childShapeIndex,m_children.size()-1);
+	m_children.pop_back();
+
+}
+
+void btCompoundShape::removeChildShape(btCollisionShape* shape)
+{
+	// Find the children containing the shape specified, and remove those children.
+	//note: there might be multiple children using the same shape!
+	for(int i = m_children.size()-1; i >= 0 ; i--)
+	{
+		if(m_children[i].m_childShape == shape)
+		{
+			m_children.swap(i,m_children.size()-1);
+			m_children.pop_back();
+			//remove it from the m_dynamicAabbTree too
+			//m_dynamicAabbTree->remove(m_aabbProxies[i]);
+			//m_aabbProxies.swap(i,m_children.size()-1);
+			//m_aabbProxies.pop_back();
+		}
+	}
+
+
+
+	recalculateLocalAabb();
+}
+
+void btCompoundShape::recalculateLocalAabb()
+{
+	// Recalculate the local aabb
+	// Brute force, it iterates over all the shapes left.
+	m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+	m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+
+	//extend the local aabbMin/aabbMax
+	for (int j = 0; j < m_children.size(); j++)
+	{
+		btVector3 localAabbMin,localAabbMax;
+		m_children[j].m_childShape->getAabb(m_children[j].m_transform, localAabbMin, localAabbMax);
+		for (int i=0;i<3;i++)
+		{
+			if (m_localAabbMin[i] > localAabbMin[i])
+				m_localAabbMin[i] = localAabbMin[i];
+			if (m_localAabbMax[i] < localAabbMax[i])
+				m_localAabbMax[i] = localAabbMax[i];
+		}
+	}
+}
+
+///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
+	localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
+	btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
+
+	btMatrix3x3 abs_b = trans.getBasis().absolute();  
+
+	btPoint3 center = trans(localCenter);
+
+	btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
+		abs_b[1].dot(localHalfExtents),
+		abs_b[2].dot(localHalfExtents));
+	aabbMin = center-extent;
+	aabbMax = center+extent;
+
+}
+
+void	btCompoundShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	//approximation: take the inertia from the aabb for now
+	btTransform ident;
+	ident.setIdentity();
+	btVector3 aabbMin,aabbMax;
+	getAabb(ident,aabbMin,aabbMax);
+
+	btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
+
+	btScalar lx=btScalar(2.)*(halfExtents.x());
+	btScalar ly=btScalar(2.)*(halfExtents.y());
+	btScalar lz=btScalar(2.)*(halfExtents.z());
+
+	inertia[0] = mass/(btScalar(12.0)) * (ly*ly + lz*lz);
+	inertia[1] = mass/(btScalar(12.0)) * (lx*lx + lz*lz);
+	inertia[2] = mass/(btScalar(12.0)) * (lx*lx + ly*ly);
+
+}
+
+
+
+
+void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const
+{
+	int n = m_children.size();
+
+	btScalar totalMass = 0;
+	btVector3 center(0, 0, 0);
+	for (int k = 0; k < n; k++)
+	{
+		center += m_children[k].m_transform.getOrigin() * masses[k];
+		totalMass += masses[k];
+	}
+	center /= totalMass;
+	principal.setOrigin(center);
+
+	btMatrix3x3 tensor(0, 0, 0, 0, 0, 0, 0, 0, 0);
+	for (int k = 0; k < n; k++)
+	{
+		btVector3 i;
+		m_children[k].m_childShape->calculateLocalInertia(masses[k], i);
+
+		const btTransform& t = m_children[k].m_transform;
+		btVector3 o = t.getOrigin() - center;
+
+		//compute inertia tensor in coordinate system of compound shape
+		btMatrix3x3 j = t.getBasis().transpose();
+		j[0] *= i[0];
+		j[1] *= i[1];
+		j[2] *= i[2];
+		j = t.getBasis() * j;
+
+		//add inertia tensor
+		tensor[0] += j[0];
+		tensor[1] += j[1];
+		tensor[2] += j[2];
+
+		//compute inertia tensor of pointmass at o
+		btScalar o2 = o.length2();
+		j[0].setValue(o2, 0, 0);
+		j[1].setValue(0, o2, 0);
+		j[2].setValue(0, 0, o2);
+		j[0] += o * -o.x(); 
+		j[1] += o * -o.y(); 
+		j[2] += o * -o.z();
+
+		//add inertia tensor of pointmass
+		tensor[0] += masses[k] * j[0];
+		tensor[1] += masses[k] * j[1];
+		tensor[2] += masses[k] * j[2];
+	}
+
+	tensor.diagonalize(principal.getBasis(), btScalar(0.00001), 20);
+	inertia.setValue(tensor[0][0], tensor[1][1], tensor[2][2]);
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h	(revision 2122)
@@ -0,0 +1,162 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef COMPOUND_SHAPE_H
+#define COMPOUND_SHAPE_H
+
+#include "btCollisionShape.h"
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "btCollisionMargin.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+//class btOptimizedBvh;
+struct btDbvt;
+
+ATTRIBUTE_ALIGNED16(struct) btCompoundShapeChild
+{
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btTransform			m_transform;
+	btCollisionShape*	m_childShape;
+	int					m_childShapeType;
+	btScalar			m_childMargin;
+	struct btDbvtNode*	m_node;
+};
+
+SIMD_FORCE_INLINE bool operator==(const btCompoundShapeChild& c1, const btCompoundShapeChild& c2)
+{
+	return  ( c1.m_transform      == c2.m_transform &&
+		c1.m_childShape     == c2.m_childShape &&
+		c1.m_childShapeType == c2.m_childShapeType &&
+		c1.m_childMargin    == c2.m_childMargin );
+}
+
+/// btCompoundShape allows to store multiple other btCollisionShapes
+/// This allows for moving concave collision objects. This is more general then the static concave btBvhTriangleMeshShape.
+ATTRIBUTE_ALIGNED16(class) btCompoundShape	: public btCollisionShape
+{
+	//btAlignedObjectArray<btTransform>		m_childTransforms;
+	//btAlignedObjectArray<btCollisionShape*>	m_childShapes;
+	btAlignedObjectArray<btCompoundShapeChild> m_children;
+	btVector3						m_localAabbMin;
+	btVector3						m_localAabbMax;
+
+	//btOptimizedBvh*					m_aabbTree;
+	btDbvt*							m_dynamicAabbTree;
+
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btCompoundShape();
+
+	virtual ~btCompoundShape();
+
+	void	addChildShape(const btTransform& localTransform,btCollisionShape* shape);
+
+	/// Remove all children shapes that contain the specified shape
+	virtual void removeChildShape(btCollisionShape* shape);
+
+	void removeChildShapeByIndex(int childShapeindex);
+
+
+	int		getNumChildShapes() const
+	{
+		return int (m_children.size());
+	}
+
+	btCollisionShape* getChildShape(int index)
+	{
+		return m_children[index].m_childShape;
+	}
+	const btCollisionShape* getChildShape(int index) const
+	{
+		return m_children[index].m_childShape;
+	}
+
+	btTransform	getChildTransform(int index)
+	{
+		return m_children[index].m_transform;
+	}
+	const btTransform	getChildTransform(int index) const
+	{
+		return m_children[index].m_transform;
+	}
+
+
+	btCompoundShapeChild* getChildList()
+	{
+		return &m_children[0];
+	}
+
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+	virtual	void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	/** Re-calculate the local Aabb. Is called at the end of removeChildShapes. 
+	Use this yourself if you modify the children or their transforms. */
+	virtual void recalculateLocalAabb(); 
+
+	virtual void	setLocalScaling(const btVector3& scaling)
+	{
+		m_localScaling = scaling;
+	}
+	virtual const btVector3& getLocalScaling() const 
+	{
+		return m_localScaling;
+	}
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual void	setMargin(btScalar margin)
+	{
+		m_collisionMargin = margin;
+	}
+	virtual btScalar	getMargin() const
+	{
+		return m_collisionMargin;
+	}
+	virtual const char*	getName()const
+	{
+		return "Compound";
+	}
+
+	//this is optional, but should make collision queries faster, by culling non-overlapping nodes
+	void	createAabbTreeFromChildren();
+
+	btDbvt*							getDynamicAabbTree()
+	{
+		return m_dynamicAabbTree;
+	}
+
+	///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia
+	///and the center of mass to the current coordinate system. "masses" points to an array of masses of the children. The resulting transform
+	///"principal" has to be applied inversely to all children transforms in order for the local coordinate system of the compound
+	///shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform
+	///of the collision object by the principal transform.
+	void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const;
+
+
+private:
+	btScalar	m_collisionMargin;
+protected:
+	btVector3	m_localScaling;
+
+};
+
+
+
+#endif //COMPOUND_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConcaveShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConcaveShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConcaveShape.cpp	(revision 2122)
@@ -0,0 +1,28 @@
+
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btConcaveShape.h"
+
+btConcaveShape::btConcaveShape() : m_collisionMargin(btScalar(0.))
+{
+
+}
+
+btConcaveShape::~btConcaveShape()
+{
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConcaveShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConcaveShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConcaveShape.h	(revision 2122)
@@ -0,0 +1,50 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONCAVE_SHAPE_H
+#define CONCAVE_SHAPE_H
+
+#include "btCollisionShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+#include "btTriangleCallback.h"
+
+
+///The btConcaveShape class provides an interface for non-moving (static) concave shapes.
+///It has been implemented by the btStaticPlaneShape, btBvhTriangleMeshShape and btHeightfieldTerrainShape.
+class btConcaveShape : public btCollisionShape
+{
+protected:
+	btScalar m_collisionMargin;
+
+public:
+	btConcaveShape();
+
+	virtual ~btConcaveShape();
+
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0;
+
+	virtual btScalar getMargin() const {
+		return m_collisionMargin;
+	}
+	virtual void setMargin(btScalar collisionMargin)
+	{
+		m_collisionMargin = collisionMargin;
+	}
+
+
+
+};
+
+#endif //CONCAVE_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp	(revision 2122)
@@ -0,0 +1,134 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btConeShape.h"
+#include "LinearMath/btPoint3.h"
+
+
+
+btConeShape::btConeShape (btScalar radius,btScalar height): btConvexInternalShape (),
+m_radius (radius),
+m_height(height)
+{
+	m_shapeType = CONE_SHAPE_PROXYTYPE;
+	setConeUpIndex(1);
+	btVector3 halfExtents;
+	m_sinAngle = (m_radius / btSqrt(m_radius * m_radius + m_height * m_height));
+}
+
+btConeShapeZ::btConeShapeZ (btScalar radius,btScalar height):
+btConeShape(radius,height)
+{
+	setConeUpIndex(2);
+}
+
+btConeShapeX::btConeShapeX (btScalar radius,btScalar height):
+btConeShape(radius,height)
+{
+	setConeUpIndex(0);
+}
+
+///choose upAxis index
+void	btConeShape::setConeUpIndex(int upIndex)
+{
+	switch (upIndex)
+	{
+	case 0:
+			m_coneIndices[0] = 1;
+			m_coneIndices[1] = 0;
+			m_coneIndices[2] = 2;
+		break;
+	case 1:
+			m_coneIndices[0] = 0;
+			m_coneIndices[1] = 1;
+			m_coneIndices[2] = 2;
+		break;
+	case 2:
+			m_coneIndices[0] = 0;
+			m_coneIndices[1] = 2;
+			m_coneIndices[2] = 1;
+		break;
+	default:
+		assert(0);
+	};
+}
+
+btVector3 btConeShape::coneLocalSupport(const btVector3& v) const
+{
+	
+	btScalar halfHeight = m_height * btScalar(0.5);
+
+ if (v[m_coneIndices[1]] > v.length() * m_sinAngle)
+ {
+	btVector3 tmp;
+
+	tmp[m_coneIndices[0]] = btScalar(0.);
+	tmp[m_coneIndices[1]] = halfHeight;
+	tmp[m_coneIndices[2]] = btScalar(0.);
+	return tmp;
+ }
+  else {
+    btScalar s = btSqrt(v[m_coneIndices[0]] * v[m_coneIndices[0]] + v[m_coneIndices[2]] * v[m_coneIndices[2]]);
+    if (s > SIMD_EPSILON) {
+      btScalar d = m_radius / s;
+	  btVector3 tmp;
+	  tmp[m_coneIndices[0]] = v[m_coneIndices[0]] * d;
+	  tmp[m_coneIndices[1]] = -halfHeight;
+	  tmp[m_coneIndices[2]] = v[m_coneIndices[2]] * d;
+	  return tmp;
+    }
+    else  {
+		btVector3 tmp;
+		tmp[m_coneIndices[0]] = btScalar(0.);
+		tmp[m_coneIndices[1]] = -halfHeight;
+		tmp[m_coneIndices[2]] = btScalar(0.);
+		return tmp;
+	}
+  }
+
+}
+
+btVector3	btConeShape::localGetSupportingVertexWithoutMargin(const btVector3& vec) const
+{
+		return coneLocalSupport(vec);
+}
+
+void	btConeShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	for (int i=0;i<numVectors;i++)
+	{
+		const btVector3& vec = vectors[i];
+		supportVerticesOut[i] = coneLocalSupport(vec);
+	}
+}
+
+
+btVector3	btConeShape::localGetSupportingVertex(const btVector3& vec)  const
+{
+	btVector3 supVertex = coneLocalSupport(vec);
+	if ( getMargin()!=btScalar(0.) )
+	{
+		btVector3 vecnorm = vec;
+		if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+		{
+			vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+		} 
+		vecnorm.normalize();
+		supVertex+= getMargin() * vecnorm;
+	}
+	return supVertex;
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConeShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConeShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConeShape.h	(revision 2122)
@@ -0,0 +1,100 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONE_MINKOWSKI_H
+#define CONE_MINKOWSKI_H
+
+#include "btConvexInternalShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+
+///The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y axis. The btConeShapeX is aligned around the X axis and btConeShapeZ around the Z axis.
+class btConeShape : public btConvexInternalShape
+
+{
+
+	btScalar m_sinAngle;
+	btScalar m_radius;
+	btScalar m_height;
+	int		m_coneIndices[3];
+	btVector3 coneLocalSupport(const btVector3& v) const;
+
+
+public:
+	btConeShape (btScalar radius,btScalar height);
+	
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec) const;
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec) const;
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
+	btScalar getRadius() const { return m_radius;}
+	btScalar getHeight() const { return m_height;}
+
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const
+	{
+		btTransform identity;
+		identity.setIdentity();
+		btVector3 aabbMin,aabbMax;
+		getAabb(identity,aabbMin,aabbMax);
+
+		btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
+
+		btScalar margin = getMargin();
+
+		btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
+		btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
+		btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
+		const btScalar x2 = lx*lx;
+		const btScalar y2 = ly*ly;
+		const btScalar z2 = lz*lz;
+		const btScalar scaledmass = mass * btScalar(0.08333333);
+
+		inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
+
+//		inertia.x() = scaledmass * (y2+z2);
+//		inertia.y() = scaledmass * (x2+z2);
+//		inertia.z() = scaledmass * (x2+y2);
+	}
+
+
+		virtual const char*	getName()const 
+		{
+			return "Cone";
+		}
+		
+		///choose upAxis index
+		void	setConeUpIndex(int upIndex);
+		
+		int	getConeUpIndex() const
+		{
+			return m_coneIndices[1];
+		}
+};
+
+///btConeShape implements a Cone shape, around the X axis
+class btConeShapeX : public btConeShape
+{
+	public:
+		btConeShapeX(btScalar radius,btScalar height);
+};
+
+///btConeShapeZ implements a Cone shape, around the Z axis
+class btConeShapeZ : public btConeShape
+{
+	public:
+		btConeShapeZ(btScalar radius,btScalar height);
+};
+#endif //CONE_MINKOWSKI_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp	(revision 2122)
@@ -0,0 +1,187 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btConvexHullShape.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+#include "LinearMath/btQuaternion.h"
+
+
+
+btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexShape ()
+{
+	m_shapeType = CONVEX_HULL_SHAPE_PROXYTYPE;
+	m_points.resize(numPoints);
+
+	unsigned char* pointsBaseAddress = (unsigned char*)points;
+
+	for (int i=0;i<numPoints;i++)
+	{
+		btPoint3* point = (btPoint3*)(pointsBaseAddress + i*stride);
+		m_points[i] = point[0];
+	}
+
+	recalcLocalAabb();
+
+}
+
+
+
+void btConvexHullShape::setLocalScaling(const btVector3& scaling)
+{
+	m_localScaling = scaling;
+	recalcLocalAabb();
+}
+
+void btConvexHullShape::addPoint(const btPoint3& point)
+{
+	m_points.push_back(point);
+	recalcLocalAabb();
+
+}
+
+btVector3	btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+{
+	btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
+	btScalar newDot,maxDot = btScalar(-1e30);
+
+	btVector3 vec = vec0;
+	btScalar lenSqr = vec.length2();
+	if (lenSqr < btScalar(0.0001))
+	{
+		vec.setValue(1,0,0);
+	} else
+	{
+		btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+		vec *= rlen;
+	}
+
+
+	for (int i=0;i<m_points.size();i++)
+	{
+		btPoint3 vtx = m_points[i] * m_localScaling;
+
+		newDot = vec.dot(vtx);
+		if (newDot > maxDot)
+		{
+			maxDot = newDot;
+			supVec = vtx;
+		}
+	}
+	return supVec;
+}
+
+void	btConvexHullShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	btScalar newDot;
+	//use 'w' component of supportVerticesOut?
+	{
+		for (int i=0;i<numVectors;i++)
+		{
+			supportVerticesOut[i][3] = btScalar(-1e30);
+		}
+	}
+	for (int i=0;i<m_points.size();i++)
+	{
+		btPoint3 vtx = m_points[i] * m_localScaling;
+
+		for (int j=0;j<numVectors;j++)
+		{
+			const btVector3& vec = vectors[j];
+			
+			newDot = vec.dot(vtx);
+			if (newDot > supportVerticesOut[j][3])
+			{
+				//WARNING: don't swap next lines, the w component would get overwritten!
+				supportVerticesOut[j] = vtx;
+				supportVerticesOut[j][3] = newDot;
+			}
+		}
+	}
+
+
+
+}
+	
+
+
+btVector3	btConvexHullShape::localGetSupportingVertex(const btVector3& vec)const
+{
+	btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
+
+	if ( getMargin()!=btScalar(0.) )
+	{
+		btVector3 vecnorm = vec;
+		if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+		{
+			vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+		} 
+		vecnorm.normalize();
+		supVertex+= getMargin() * vecnorm;
+	}
+	return supVertex;
+}
+
+
+
+
+
+
+
+
+
+//currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection
+//Please note that you can debug-draw btConvexHullShape with the Raytracer Demo
+int	btConvexHullShape::getNumVertices() const
+{
+	return m_points.size();
+}
+
+int btConvexHullShape::getNumEdges() const
+{
+	return m_points.size();
+}
+
+void btConvexHullShape::getEdge(int i,btPoint3& pa,btPoint3& pb) const
+{
+
+	int index0 = i%m_points.size();
+	int index1 = (i+1)%m_points.size();
+	pa = m_points[index0]*m_localScaling;
+	pb = m_points[index1]*m_localScaling;
+}
+
+void btConvexHullShape::getVertex(int i,btPoint3& vtx) const
+{
+	vtx = m_points[i]*m_localScaling;
+}
+
+int	btConvexHullShape::getNumPlanes() const
+{
+	return 0;
+}
+
+void btConvexHullShape::getPlane(btVector3& ,btPoint3& ,int ) const
+{
+
+	btAssert(0);
+}
+
+//not yet
+bool btConvexHullShape::isInside(const btPoint3& ,btScalar ) const
+{
+	assert(0);
+	return false;
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h	(revision 2122)
@@ -0,0 +1,80 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONVEX_HULL_SHAPE_H
+#define CONVEX_HULL_SHAPE_H
+
+#include "btPolyhedralConvexShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+#include "LinearMath/btAlignedObjectArray.h"
+
+///The btConvexHullShape implements an implicit convex hull of an array of vertices.
+///Bullet provides a general and fast collision detector for convex shapes based on GJK and EPA using localGetSupportingVertex.
+ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvexShape
+{
+	btAlignedObjectArray<btPoint3>	m_points;
+
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	
+	///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive btScalar (x,y,z), the striding defines the number of bytes between each point, in memory.
+	///It is easier to not pass any points in the constructor, and just add one point at a time, using addPoint.
+	///btConvexHullShape make an internal copy of the points.
+	btConvexHullShape(const btScalar* points=0,int numPoints=0, int stride=sizeof(btPoint3));
+
+	void addPoint(const btPoint3& point);
+
+	btPoint3* getPoints()
+	{
+		return &m_points[0];
+	}
+
+	const btPoint3* getPoints() const
+	{
+		return &m_points[0];
+	}
+
+	int getNumPoints() const 
+	{
+		return m_points.size();
+	}
+
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec)const;
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+	
+
+
+	//debugging
+	virtual const char*	getName()const {return "Convex";}
+
+	
+	virtual int	getNumVertices() const;
+	virtual int getNumEdges() const;
+	virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
+	virtual void getVertex(int i,btPoint3& vtx) const;
+	virtual int	getNumPlanes() const;
+	virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
+	virtual	bool isInside(const btPoint3& pt,btScalar tolerance) const;
+
+	///in case we receive negative scaling
+	virtual void	setLocalScaling(const btVector3& scaling);
+
+};
+
+
+#endif //CONVEX_HULL_SHAPE_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.cpp	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btConvexInternalShape.h"
+
+
+btConvexInternalShape::btConvexInternalShape()
+: btConvexShape (), m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
+m_collisionMargin(CONVEX_DISTANCE_MARGIN)
+{
+}
+
+
+void	btConvexInternalShape::setLocalScaling(const btVector3& scaling)
+{
+	m_localScaling = scaling.absolute();
+}
+
+
+
+void	btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const
+{
+
+	btScalar margin = getMargin();
+	for (int i=0;i<3;i++)
+	{
+		btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
+		vec[i] = btScalar(1.);
+
+		btVector3 sv = localGetSupportingVertex(vec*trans.getBasis());
+
+		btVector3 tmp = trans(sv);
+		maxAabb[i] = tmp[i]+margin;
+		vec[i] = btScalar(-1.);
+		tmp = trans(localGetSupportingVertex(vec*trans.getBasis()));
+		minAabb[i] = tmp[i]-margin;
+	}
+};
+
+
+btVector3	btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)const
+{
+#ifndef __SPU__
+
+	 btVector3	supVertex = localGetSupportingVertexWithoutMargin(vec);
+
+	if ( getMargin()!=btScalar(0.) )
+	{
+		btVector3 vecnorm = vec;
+		if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+		{
+			vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+		} 
+		vecnorm.normalize();
+		supVertex+= getMargin() * vecnorm;
+	}
+	return supVertex;
+
+#else
+	return btVector3(0,0,0);
+#endif //__SPU__
+
+ }
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h	(revision 2122)
@@ -0,0 +1,100 @@
+
+#ifndef BT_CONVEX_INTERNAL_SHAPE_H
+#define BT_CONVEX_INTERNAL_SHAPE_H
+
+#include "btConvexShape.h"
+
+///The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
+class btConvexInternalShape : public btConvexShape
+{
+
+	protected:
+
+	//local scaling. collisionMargin is not scaled !
+	btVector3	m_localScaling;
+
+	btVector3	m_implicitShapeDimensions;
+	
+	btScalar	m_collisionMargin;
+
+	btScalar	m_padding;
+
+	btConvexInternalShape();
+
+public:
+
+	
+
+	virtual ~btConvexInternalShape()
+	{
+
+	}
+
+
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec)const;
+#ifndef __SPU__
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec) const= 0;
+	
+	//notice that the vectors should be unit length
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const= 0;
+#endif //#ifndef __SPU__
+
+	const btVector3& getImplicitShapeDimensions() const
+	{
+		return m_implicitShapeDimensions;
+	}
+
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+	void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+	{
+		getAabbSlow(t,aabbMin,aabbMax);
+	}
+
+
+	
+	virtual void getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+
+	virtual void	setLocalScaling(const btVector3& scaling);
+	virtual const btVector3& getLocalScaling() const 
+	{
+		return m_localScaling;
+	}
+
+	const btVector3& getLocalScalingNV() const 
+	{
+		return m_localScaling;
+	}
+
+	virtual void	setMargin(btScalar margin)
+	{
+		m_collisionMargin = margin;
+	}
+	virtual btScalar	getMargin() const
+	{
+		return m_collisionMargin;
+	}
+
+	btScalar	getMarginNV() const
+	{
+		return m_collisionMargin;
+	}
+
+	virtual int		getNumPreferredPenetrationDirections() const
+	{
+		return 0;
+	}
+	
+	virtual void	getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+	{
+		(void)penetrationVector;
+		(void)index;
+		btAssert(0);
+	}
+
+
+	
+};
+
+
+#endif //BT_CONVEX_INTERNAL_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp	(revision 2122)
@@ -0,0 +1,173 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btConvexPointCloudShape.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+#include "LinearMath/btQuaternion.h"
+
+btConvexPointCloudShape::btConvexPointCloudShape (btVector3* points,int numPoints) : btPolyhedralConvexShape ()
+{
+	m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE;
+	m_points = points;
+	m_numPoints = numPoints;
+
+	recalcLocalAabb();
+}
+
+void btConvexPointCloudShape::setPoints (btVector3* points, int numPoints)
+{
+	m_points = points;
+	m_numPoints = numPoints;
+
+	recalcLocalAabb();
+}
+
+
+void btConvexPointCloudShape::setLocalScaling(const btVector3& scaling)
+{
+	m_localScaling = scaling;
+	recalcLocalAabb();
+}
+
+btVector3	btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+{
+	btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
+	btScalar newDot,maxDot = btScalar(-1e30);
+
+	btVector3 vec = vec0;
+	btScalar lenSqr = vec.length2();
+	if (lenSqr < btScalar(0.0001))
+	{
+		vec.setValue(1,0,0);
+	} else
+	{
+		btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+		vec *= rlen;
+	}
+
+
+	for (int i=0;i<m_numPoints;i++)
+	{
+		btPoint3 vtx = m_points[i] * m_localScaling;
+
+		newDot = vec.dot(vtx);
+		if (newDot > maxDot)
+		{
+			maxDot = newDot;
+			supVec = vtx;
+		}
+	}
+	return supVec;
+}
+
+void	btConvexPointCloudShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	btScalar newDot;
+	//use 'w' component of supportVerticesOut?
+	{
+		for (int i=0;i<numVectors;i++)
+		{
+			supportVerticesOut[i][3] = btScalar(-1e30);
+		}
+	}
+	for (int i=0;i<m_numPoints;i++)
+	{
+		btPoint3 vtx = m_points[i] * m_localScaling;
+
+		for (int j=0;j<numVectors;j++)
+		{
+			const btVector3& vec = vectors[j];
+			
+			newDot = vec.dot(vtx);
+			if (newDot > supportVerticesOut[j][3])
+			{
+				//WARNING: don't swap next lines, the w component would get overwritten!
+				supportVerticesOut[j] = vtx;
+				supportVerticesOut[j][3] = newDot;
+			}
+		}
+	}
+
+
+
+}
+	
+
+
+btVector3	btConvexPointCloudShape::localGetSupportingVertex(const btVector3& vec)const
+{
+	btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
+
+	if ( getMargin()!=btScalar(0.) )
+	{
+		btVector3 vecnorm = vec;
+		if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+		{
+			vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+		} 
+		vecnorm.normalize();
+		supVertex+= getMargin() * vecnorm;
+	}
+	return supVertex;
+}
+
+
+
+
+
+
+
+
+
+//currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection
+//Please note that you can debug-draw btConvexHullShape with the Raytracer Demo
+int	btConvexPointCloudShape::getNumVertices() const
+{
+	return m_numPoints;
+}
+
+int btConvexPointCloudShape::getNumEdges() const
+{
+	return 0;
+}
+
+void btConvexPointCloudShape::getEdge(int i,btPoint3& pa,btPoint3& pb) const
+{
+	btAssert (0);
+}
+
+void btConvexPointCloudShape::getVertex(int i,btPoint3& vtx) const
+{
+	vtx = m_points[i]*m_localScaling;
+}
+
+int	btConvexPointCloudShape::getNumPlanes() const
+{
+	return 0;
+}
+
+void btConvexPointCloudShape::getPlane(btVector3& ,btPoint3& ,int ) const
+{
+
+	btAssert(0);
+}
+
+//not yet
+bool btConvexPointCloudShape::isInside(const btPoint3& ,btScalar ) const
+{
+	assert(0);
+	return false;
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.h	(revision 2122)
@@ -0,0 +1,72 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_CONVEX_POINT_CLOUD_SHAPE_H
+#define BT_CONVEX_POINT_CLOUD_SHAPE_H
+
+#include "btPolyhedralConvexShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+#include "LinearMath/btAlignedObjectArray.h"
+
+///The btConvexPointCloudShape implements an implicit convex hull of an array of vertices.
+ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexShape
+{
+	btVector3* m_points;
+	int m_numPoints;
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btConvexPointCloudShape(btVector3* points,int numPoints);
+
+	void setPoints (btVector3* points, int numPoints);
+
+	btPoint3* getPoints()
+	{
+		return m_points;
+	}
+
+	const btPoint3* getPoints() const
+	{
+		return m_points;
+	}
+
+	int getNumPoints() const 
+	{
+		return m_numPoints;
+	}
+
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec)const;
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
+
+	//debugging
+	virtual const char*	getName()const {return "ConvexPointCloud";}
+
+	virtual int	getNumVertices() const;
+	virtual int getNumEdges() const;
+	virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
+	virtual void getVertex(int i,btPoint3& vtx) const;
+	virtual int	getNumPlanes() const;
+	virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
+	virtual	bool isInside(const btPoint3& pt,btScalar tolerance) const;
+
+	///in case we receive negative scaling
+	virtual void	setLocalScaling(const btVector3& scaling);
+};
+
+
+#endif //BT_CONVEX_POINT_CLOUD_SHAPE_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp	(revision 2122)
@@ -0,0 +1,551 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btConvexShape.h"
+#include "btConvexInternalShape.h"
+#include "btTriangleShape.h"
+#include "btSphereShape.h"
+#include "btCylinderShape.h"
+#include "btCapsuleShape.h"
+#include "btConvexHullShape.h"
+#include "btConvexPointCloudShape.h"
+
+static btVector3 convexHullSupport (const btVector3& localDir, const btVector3* points, int numPoints)
+{
+	btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
+	btScalar newDot,maxDot = btScalar(-1e30);
+
+	btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
+	btVector3 vec = vec0;
+	btScalar lenSqr = vec.length2();
+	if (lenSqr < btScalar(0.0001))
+	{
+		vec.setValue(1,0,0);
+	} else {
+		btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+		vec *= rlen;
+	}
+
+
+	for (int i=0;i<numPoints;i++)
+	{
+		btPoint3 vtx = points[i];// * m_localScaling;
+
+		newDot = vec.dot(vtx);
+		if (newDot > maxDot)
+		{
+			maxDot = newDot;
+			supVec = vtx;
+		}
+	}
+	return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());
+}
+
+btVector3 btConvexShape::localGetSupportVertexWithoutMarginNonVirtual (const btVector3& localDir) const
+{
+	switch (m_shapeType)
+	{
+    case SPHERE_SHAPE_PROXYTYPE:
+	{
+		return btVector3(0,0,0);
+    }
+	break;
+	case BOX_SHAPE_PROXYTYPE:
+	{
+		btConvexInternalShape* convexShape = (btConvexInternalShape*)this;
+		const btVector3& halfExtents = convexShape->getImplicitShapeDimensions();
+
+		return btVector3(btFsels(localDir.x(), halfExtents.x(), -halfExtents.x()),
+			btFsels(localDir.y(), halfExtents.y(), -halfExtents.y()),
+			btFsels(localDir.z(), halfExtents.z(), -halfExtents.z()));
+	}
+	break;
+	case TRIANGLE_SHAPE_PROXYTYPE:
+	{
+		btTriangleShape* triangleShape = (btTriangleShape*)this;
+		btVector3 dir(localDir.getX(),localDir.getY(),localDir.getZ());
+		btVector3* vertices = &triangleShape->m_vertices1[0];
+		btVector3 dots(dir.dot(vertices[0]), dir.dot(vertices[1]), dir.dot(vertices[2]));
+		btVector3 sup = vertices[dots.maxAxis()];
+		return btVector3(sup.getX(),sup.getY(),sup.getZ());
+	}
+	break;
+	case CYLINDER_SHAPE_PROXYTYPE:
+	{
+		btCylinderShape* cylShape = (btCylinderShape*)this;
+		//mapping of halfextents/dimension onto radius/height depends on how cylinder local orientation is (upAxis)
+
+		btVector3 halfExtents = cylShape->getImplicitShapeDimensions();
+		btVector3 v(localDir.getX(),localDir.getY(),localDir.getZ());
+		int cylinderUpAxis = cylShape->getUpAxis();
+		int XX(1),YY(0),ZZ(2);
+
+		switch (cylinderUpAxis)
+		{
+		case 0:
+		{
+			XX = 1;
+			YY = 0;
+			ZZ = 2;
+		}
+		break;
+		case 1:
+		{
+			XX = 0;
+			YY = 1;
+			ZZ = 2;	
+		}
+		break;
+		case 2:
+		{
+			XX = 0;
+			YY = 2;
+			ZZ = 1;
+			
+		}
+		break;
+		default:
+			btAssert(0);
+		break;
+		};
+
+		btScalar radius = halfExtents[XX];
+		btScalar halfHeight = halfExtents[cylinderUpAxis];
+
+		btVector3 tmp;
+		btScalar d ;
+
+		btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
+		if (s != btScalar(0.0))
+		{
+			d = radius / s;  
+			tmp[XX] = v[XX] * d;
+			tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+			tmp[ZZ] = v[ZZ] * d;
+			return btVector3(tmp.getX(),tmp.getY(),tmp.getZ());
+		} else {
+			tmp[XX] = radius;
+			tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+			tmp[ZZ] = btScalar(0.0);
+			return btVector3(tmp.getX(),tmp.getY(),tmp.getZ());
+		}
+	}
+	break;
+	case CAPSULE_SHAPE_PROXYTYPE:
+	{
+		btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
+
+		btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+		btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions();
+		btScalar halfHeight = capsuleShape->getHalfHeight();
+		int capsuleUpAxis = capsuleShape->getUpAxis();
+
+		btScalar radius = capsuleShape->getRadius();
+		btVector3 supVec(0,0,0);
+
+		btScalar maxDot(btScalar(-1e30));
+
+		btVector3 vec = vec0;
+		btScalar lenSqr = vec.length2();
+		if (lenSqr < btScalar(0.0001))
+		{
+			vec.setValue(1,0,0);
+		} else
+		{
+			btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+			vec *= rlen;
+		}
+		btVector3 vtx;
+		btScalar newDot;
+		{
+			btVector3 pos(0,0,0);
+			pos[capsuleUpAxis] = halfHeight;
+
+			//vtx = pos +vec*(radius);
+			vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV();
+			newDot = vec.dot(vtx);
+			
+
+			if (newDot > maxDot)
+			{
+				maxDot = newDot;
+				supVec = vtx;
+			}
+		}
+		{
+			btVector3 pos(0,0,0);
+			pos[capsuleUpAxis] = -halfHeight;
+
+			//vtx = pos +vec*(radius);
+			vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV();
+			newDot = vec.dot(vtx);
+			if (newDot > maxDot)
+			{
+				maxDot = newDot;
+				supVec = vtx;
+			}
+		}
+		return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());	
+	}
+	break;
+	case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
+	{
+		btConvexPointCloudShape* convexPointCloudShape = (btConvexPointCloudShape*)this;
+		btVector3* points = convexPointCloudShape->getPoints ();
+		int numPoints = convexPointCloudShape->getNumPoints ();
+		return convexHullSupport (localDir, points, numPoints);
+	}
+	case CONVEX_HULL_SHAPE_PROXYTYPE:
+	{
+		btConvexHullShape* convexHullShape = (btConvexHullShape*)this;
+		btPoint3* points = convexHullShape->getPoints ();
+		int numPoints = convexHullShape->getNumPoints ();
+		return convexHullSupport (localDir, points, numPoints);
+	}
+	break;
+    default:
+#ifndef __SPU__
+		return this->localGetSupportingVertexWithoutMargin (localDir);
+#else
+		btAssert (0);
+#endif
+	break;
+	}
+
+	// should never reach here
+	btAssert (0);
+	return btPoint3 (btScalar(0.0f), btScalar(0.0f), btScalar(0.0f));
+}
+
+btVector3 btConvexShape::localGetSupportVertexNonVirtual (const btVector3& localDir) const
+{
+	btVector3 localDirNorm = localDir;
+	if (localDirNorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+	{
+		localDirNorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+	}
+	localDirNorm.normalize ();
+	switch (m_shapeType)
+	{
+    case SPHERE_SHAPE_PROXYTYPE:
+	{
+		return btVector3(0,0,0) + getMarginNonVirtual() * localDirNorm;
+    }
+	break;
+	case BOX_SHAPE_PROXYTYPE:
+	{
+		btConvexInternalShape* convexShape = (btConvexInternalShape*)this;
+		const btVector3& halfExtents = convexShape->getImplicitShapeDimensions();
+
+		return btVector3(localDir.getX() < 0.0f ? -halfExtents.x() : halfExtents.x(),
+						localDir.getY() < 0.0f ? -halfExtents.y() : halfExtents.y(),
+						localDir.getZ() < 0.0f ? -halfExtents.z() : halfExtents.z()) + getMarginNonVirtual() * localDirNorm;
+	}
+	break;
+	case TRIANGLE_SHAPE_PROXYTYPE:
+	{
+		btTriangleShape* triangleShape = (btTriangleShape*)this;
+		btVector3 dir(localDir.getX(),localDir.getY(),localDir.getZ());
+		btVector3* vertices = &triangleShape->m_vertices1[0];
+		btVector3 dots(dir.dot(vertices[0]), dir.dot(vertices[1]), dir.dot(vertices[2]));
+		btVector3 sup = vertices[dots.maxAxis()];
+		return btVector3(sup.getX(),sup.getY(),sup.getZ()) + getMarginNonVirtual() * localDirNorm;
+	}
+	break;
+	case CYLINDER_SHAPE_PROXYTYPE:
+	{
+		btCylinderShape* cylShape = (btCylinderShape*)this;
+		//mapping of halfextents/dimension onto radius/height depends on how cylinder local orientation is (upAxis)
+
+		btVector3 halfExtents = cylShape->getImplicitShapeDimensions();
+		btVector3 v(localDir.getX(),localDir.getY(),localDir.getZ());
+		int cylinderUpAxis = cylShape->getUpAxis();
+		int XX(1),YY(0),ZZ(2);
+
+		switch (cylinderUpAxis)
+		{
+		case 0:
+		{
+			XX = 1;
+			YY = 0;
+			ZZ = 2;
+		}
+		break;
+		case 1:
+		{
+			XX = 0;
+			YY = 1;
+			ZZ = 2;	
+		}
+		break;
+		case 2:
+		{
+			XX = 0;
+			YY = 2;
+			ZZ = 1;
+			
+		}
+		break;
+		default:
+			btAssert(0);
+		break;
+		};
+
+		btScalar radius = halfExtents[XX];
+		btScalar halfHeight = halfExtents[cylinderUpAxis];
+
+		btVector3 tmp;
+		btScalar d ;
+
+		btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
+		if (s != btScalar(0.0))
+		{
+			d = radius / s;  
+			tmp[XX] = v[XX] * d;
+			tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+			tmp[ZZ] = v[ZZ] * d;
+			return btVector3(tmp.getX(),tmp.getY(),tmp.getZ()) + getMarginNonVirtual() * localDirNorm;
+		} else {
+			tmp[XX] = radius;
+			tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+			tmp[ZZ] = btScalar(0.0);
+			return btVector3(tmp.getX(),tmp.getY(),tmp.getZ()) + getMarginNonVirtual() * localDirNorm;
+		}
+	}
+	break;
+	case CAPSULE_SHAPE_PROXYTYPE:
+	{
+		btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
+
+		btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+		btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions();
+		btScalar halfHeight = capsuleShape->getHalfHeight();
+		int capsuleUpAxis = capsuleShape->getUpAxis();
+
+		btScalar radius = capsuleShape->getRadius();
+		btVector3 supVec(0,0,0);
+
+		btScalar maxDot(btScalar(-1e30));
+
+		btVector3 vec = vec0;
+		btScalar lenSqr = vec.length2();
+		if (lenSqr < btScalar(0.0001))
+		{
+			vec.setValue(1,0,0);
+		} else
+		{
+			btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+			vec *= rlen;
+		}
+		btVector3 vtx;
+		btScalar newDot;
+		{
+			btVector3 pos(0,0,0);
+			pos[capsuleUpAxis] = halfHeight;
+
+			vtx = pos +vec*(radius);
+			newDot = vec.dot(vtx);
+			if (newDot > maxDot)
+			{
+				maxDot = newDot;
+				supVec = vtx;
+			}
+		}
+		{
+			btVector3 pos(0,0,0);
+			pos[capsuleUpAxis] = -halfHeight;
+
+			vtx = pos +vec*(radius);
+			newDot = vec.dot(vtx);
+			if (newDot > maxDot)
+			{
+				maxDot = newDot;
+				supVec = vtx;
+			}
+		}
+		return btVector3(supVec.getX(),supVec.getY(),supVec.getZ()) + getMarginNonVirtual() * localDirNorm;
+	}
+	break;
+	case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
+	{
+		btConvexPointCloudShape* convexPointCloudShape = (btConvexPointCloudShape*)this;
+		btVector3* points = convexPointCloudShape->getPoints ();
+		int numPoints = convexPointCloudShape->getNumPoints ();
+		return convexHullSupport (localDir, points, numPoints) + getMarginNonVirtual() * localDirNorm;
+	}
+	case CONVEX_HULL_SHAPE_PROXYTYPE:
+	{
+		btConvexHullShape* convexHullShape = (btConvexHullShape*)this;
+		btPoint3* points = convexHullShape->getPoints ();
+		int numPoints = convexHullShape->getNumPoints ();
+		return convexHullSupport (localDir, points, numPoints) + getMarginNonVirtual() * localDirNorm;
+	}
+	break;
+    default:
+#ifndef __SPU__
+		return this->localGetSupportingVertex (localDir);
+#else
+		btAssert (0);
+#endif
+	break;
+	}
+
+	// should never reach here
+	btAssert (0);
+	return btPoint3 (btScalar(0.0f), btScalar(0.0f), btScalar(0.0f));
+}
+
+/* TODO: This should be bumped up to btCollisionShape () */
+btScalar btConvexShape::getMarginNonVirtual () const
+{
+	switch (m_shapeType)
+	{
+    case SPHERE_SHAPE_PROXYTYPE:
+	{
+		btSphereShape* sphereShape = (btSphereShape*)this;
+		return sphereShape->getRadius ();
+	}
+	break;
+	case BOX_SHAPE_PROXYTYPE:
+	{
+		btConvexInternalShape* convexShape = (btConvexInternalShape*)this;
+		return convexShape->getMarginNV ();
+	}
+	break;
+	case TRIANGLE_SHAPE_PROXYTYPE:
+	{
+		btTriangleShape* triangleShape = (btTriangleShape*)this;
+		return triangleShape->getMarginNV ();
+	}
+	break;
+	case CYLINDER_SHAPE_PROXYTYPE:
+	{
+		btCylinderShape* cylShape = (btCylinderShape*)this;
+		return cylShape->getMarginNV();
+	}
+	break;
+	case CAPSULE_SHAPE_PROXYTYPE:
+	{
+		btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+		return capsuleShape->getMarginNV();
+	}
+	break;
+	case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
+	/* fall through */
+	case CONVEX_HULL_SHAPE_PROXYTYPE:
+	{
+		btPolyhedralConvexShape* convexHullShape = (btPolyhedralConvexShape*)this;
+		return convexHullShape->getMarginNV();
+	}
+	break;
+    default:
+#ifndef __SPU__
+		return this->getMargin ();
+#else
+		btAssert (0);
+#endif
+	break;
+	}
+
+	// should never reach here
+	btAssert (0);
+	return btScalar(0.0f);
+}
+
+void btConvexShape::getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
+{
+	switch (m_shapeType)
+	{
+    case SPHERE_SHAPE_PROXYTYPE:
+	{
+		btSphereShape* sphereShape = (btSphereShape*)this;
+		float radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
+		float margin = radius + sphereShape->getMarginNonVirtual();
+		const btVector3& center = t.getOrigin();
+		btVector3 extent(margin,margin,margin);
+		aabbMin = center - extent;
+		aabbMax = center + extent;
+    }
+	break;
+	case CYLINDER_SHAPE_PROXYTYPE:
+	/* fall through */
+	case BOX_SHAPE_PROXYTYPE:
+	{
+		btConvexInternalShape* convexShape = (btConvexInternalShape*)this;
+		float margin=convexShape->getMarginNonVirtual();
+		btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
+		halfExtents += btVector3(margin,margin,margin);
+		btMatrix3x3 abs_b = t.getBasis().absolute();  
+		btPoint3 center = t.getOrigin();
+		btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
+		
+		aabbMin = center - extent;
+		aabbMax = center + extent;
+		break;
+	}
+	break;
+	case TRIANGLE_SHAPE_PROXYTYPE:
+	{
+		btTriangleShape* triangleShape = (btTriangleShape*)this;
+		btScalar margin = triangleShape->getMarginNonVirtual();
+		for (int i=0;i<3;i++)
+		{
+			btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
+			vec[i] = btScalar(1.);
+
+			btVector3 sv = localGetSupportVertexWithoutMarginNonVirtual(vec*t.getBasis());
+
+			btVector3 tmp = t(sv);
+			aabbMax[i] = tmp[i]+margin;
+			vec[i] = btScalar(-1.);
+			tmp = t(localGetSupportVertexWithoutMarginNonVirtual(vec*t.getBasis()));
+			aabbMin[i] = tmp[i]-margin;
+		}	
+	}
+	break;
+	case CAPSULE_SHAPE_PROXYTYPE:
+	{
+		btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+		btVector3 halfExtents(capsuleShape->getRadius(),capsuleShape->getRadius(),capsuleShape->getRadius());
+		int m_upAxis = capsuleShape->getUpAxis();
+		halfExtents[m_upAxis] = capsuleShape->getRadius() + capsuleShape->getHalfHeight();
+		halfExtents += btVector3(capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual());
+		btMatrix3x3 abs_b = t.getBasis().absolute();  
+		btPoint3 center = t.getOrigin();
+		btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));		  	
+		aabbMin = center - extent;
+		aabbMax = center + extent;
+	}
+	break;
+	case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
+	case CONVEX_HULL_SHAPE_PROXYTYPE:
+	{
+		btPolyhedralConvexShape* convexHullShape = (btPolyhedralConvexShape*)this;
+		btScalar margin = convexHullShape->getMarginNonVirtual();
+		convexHullShape->getNonvirtualAabb (t, aabbMin, aabbMax, margin);
+	}
+	break;
+    default:
+#ifndef __SPU__
+		this->getAabb (t, aabbMin, aabbMax);
+#else
+		btAssert (0);
+#endif
+	break;
+	}
+
+	// should never reach here
+	btAssert (0);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexShape.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONVEX_SHAPE_INTERFACE1
+#define CONVEX_SHAPE_INTERFACE1
+
+#include "btCollisionShape.h"
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "btCollisionMargin.h"
+#include "LinearMath/btAlignedAllocator.h"
+
+//todo: get rid of this btConvexCastResult thing!
+struct btConvexCastResult;
+#define MAX_PREFERRED_PENETRATION_DIRECTIONS 10
+
+/// The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape, btConvexHullShape etc.
+/// It describes general convex shapes using the localGetSupportingVertex interface, used by collision detectors such as btGjkPairDetector.
+ATTRIBUTE_ALIGNED16(class) btConvexShape : public btCollisionShape
+{
+
+
+public:
+
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btConvexShape ()
+	{
+	}
+
+	virtual ~btConvexShape()
+	{
+
+	}
+
+
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec)const =0;
+#ifndef __SPU__
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec) const= 0;
+	
+	//notice that the vectors should be unit length
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const= 0;
+#endif //#ifndef __SPU__
+
+	btVector3 localGetSupportVertexWithoutMarginNonVirtual (const btVector3& vec) const;
+	btVector3 localGetSupportVertexNonVirtual (const btVector3& vec) const;
+	btScalar getMarginNonVirtual () const;
+	void getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const;
+
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+	void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
+
+	virtual void getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
+
+	virtual void	setLocalScaling(const btVector3& scaling) =0;
+	virtual const btVector3& getLocalScaling() const =0;
+
+	virtual void	setMargin(btScalar margin)=0;
+
+	virtual btScalar	getMargin() const=0;
+
+	virtual int		getNumPreferredPenetrationDirections() const=0;
+	
+	virtual void	getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const=0;
+
+};
+
+
+
+#endif //CONVEX_SHAPE_INTERFACE1
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp	(revision 2122)
@@ -0,0 +1,317 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btConvexTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+#include "LinearMath/btQuaternion.h"
+#include "BulletCollision/CollisionShapes/btStridingMeshInterface.h"
+
+
+btConvexTriangleMeshShape ::btConvexTriangleMeshShape (btStridingMeshInterface* meshInterface, bool calcAabb)
+: btPolyhedralConvexShape(), m_stridingMesh(meshInterface)
+{
+	m_shapeType = CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE;
+	if ( calcAabb )
+		recalcLocalAabb();
+}
+
+
+
+
+///It's not nice to have all this virtual function overhead, so perhaps we can also gather the points once
+///but then we are duplicating
+class LocalSupportVertexCallback: public btInternalTriangleIndexCallback
+{
+
+	btVector3 m_supportVertexLocal;
+public:
+
+	btScalar m_maxDot;
+	btVector3 m_supportVecLocal;
+
+	LocalSupportVertexCallback(const btVector3& supportVecLocal)
+		: m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)),
+		m_maxDot(btScalar(-1e30)),
+                m_supportVecLocal(supportVecLocal)
+	{
+	}
+
+	virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int  triangleIndex)
+	{
+		(void)triangleIndex;
+		(void)partId;
+
+		for (int i=0;i<3;i++)
+		{
+			btScalar dot = m_supportVecLocal.dot(triangle[i]);
+			if (dot > m_maxDot)
+			{
+				m_maxDot = dot;
+				m_supportVertexLocal = triangle[i];
+			}
+		}
+	}
+	
+	btVector3	GetSupportVertexLocal()
+	{
+		return m_supportVertexLocal;
+	}
+
+};
+
+
+
+
+
+btVector3	btConvexTriangleMeshShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+{
+	btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
+
+	btVector3 vec = vec0;
+	btScalar lenSqr = vec.length2();
+	if (lenSqr < btScalar(0.0001))
+	{
+		vec.setValue(1,0,0);
+	} else
+	{
+		btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+		vec *= rlen;
+	}
+
+	LocalSupportVertexCallback	supportCallback(vec);
+	btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+	m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
+	supVec = supportCallback.GetSupportVertexLocal();
+
+	return supVec;
+}
+
+void	btConvexTriangleMeshShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	//use 'w' component of supportVerticesOut?
+	{
+		for (int i=0;i<numVectors;i++)
+		{
+			supportVerticesOut[i][3] = btScalar(-1e30);
+		}
+	}
+	
+	//todo: could do the batch inside the callback!
+
+
+	for (int j=0;j<numVectors;j++)
+	{
+		const btVector3& vec = vectors[j];
+		LocalSupportVertexCallback	supportCallback(vec);
+		btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+		m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
+		supportVerticesOut[j] = supportCallback.GetSupportVertexLocal();
+	}
+	
+}
+	
+
+
+btVector3	btConvexTriangleMeshShape::localGetSupportingVertex(const btVector3& vec)const
+{
+	btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
+
+	if ( getMargin()!=btScalar(0.) )
+	{
+		btVector3 vecnorm = vec;
+		if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+		{
+			vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+		} 
+		vecnorm.normalize();
+		supVertex+= getMargin() * vecnorm;
+	}
+	return supVertex;
+}
+
+
+
+
+
+
+
+
+
+//currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection
+//Please note that you can debug-draw btConvexTriangleMeshShape with the Raytracer Demo
+int	btConvexTriangleMeshShape::getNumVertices() const
+{
+	//cache this?
+	return 0;
+	
+}
+
+int btConvexTriangleMeshShape::getNumEdges() const
+{
+	return 0;
+}
+
+void btConvexTriangleMeshShape::getEdge(int ,btPoint3& ,btPoint3& ) const
+{
+	btAssert(0);	
+}
+
+void btConvexTriangleMeshShape::getVertex(int ,btPoint3& ) const
+{
+	btAssert(0);
+}
+
+int	btConvexTriangleMeshShape::getNumPlanes() const
+{
+	return 0;
+}
+
+void btConvexTriangleMeshShape::getPlane(btVector3& ,btPoint3& ,int  ) const
+{
+	btAssert(0);
+}
+
+//not yet
+bool btConvexTriangleMeshShape::isInside(const btPoint3& ,btScalar ) const
+{
+	btAssert(0);
+	return false;
+}
+
+
+
+void	btConvexTriangleMeshShape::setLocalScaling(const btVector3& scaling)
+{
+	m_stridingMesh->setScaling(scaling);
+	
+	recalcLocalAabb();
+	
+}
+
+
+const btVector3& btConvexTriangleMeshShape::getLocalScaling() const
+{
+	return m_stridingMesh->getScaling();
+}
+
+void btConvexTriangleMeshShape::calculatePrincipalAxisTransform(btTransform& principal, btVector3& inertia, btScalar& volume) const
+{
+   class CenterCallback: public btInternalTriangleIndexCallback
+   {
+      bool first;
+      btVector3 ref;
+      btVector3 sum;
+      btScalar volume;
+
+   public:
+
+      CenterCallback() : first(true), ref(0, 0, 0), sum(0, 0, 0), volume(0)
+      {
+      }
+
+      virtual void internalProcessTriangleIndex(btVector3* triangle, int partId, int triangleIndex)
+      {
+         (void) triangleIndex;
+         (void) partId;
+         if (first)
+         {
+            ref = triangle[0];
+            first = false;
+         }
+         else
+         {
+            btScalar vol = btFabs((triangle[0] - ref).triple(triangle[1] - ref, triangle[2] - ref));
+            sum += (btScalar(0.25) * vol) * ((triangle[0] + triangle[1] + triangle[2] + ref));
+            volume += vol;
+         }
+      }
+      
+      btVector3 getCenter()
+      {
+         return (volume > 0) ? sum / volume : ref;
+      }
+
+      btScalar getVolume()
+      {
+         return volume * btScalar(1. / 6);
+      }
+
+   };
+
+   class InertiaCallback: public btInternalTriangleIndexCallback
+   {
+      btMatrix3x3 sum;
+      btVector3 center;
+
+   public:
+
+      InertiaCallback(btVector3& center) : sum(0, 0, 0, 0, 0, 0, 0, 0, 0), center(center)
+      {
+      }
+
+      virtual void internalProcessTriangleIndex(btVector3* triangle, int partId, int triangleIndex)
+      {
+         (void) triangleIndex;
+         (void) partId;
+         btMatrix3x3 i;
+         btVector3 a = triangle[0] - center;
+         btVector3 b = triangle[1] - center;
+         btVector3 c = triangle[2] - center;
+         btVector3 abc = a + b + c;
+         btScalar volNeg = -btFabs(a.triple(b, c)) * btScalar(1. / 6);
+         for (int j = 0; j < 3; j++)
+         {
+            for (int k = 0; k <= j; k++)
+            {
+               i[j][k] = i[k][j] = volNeg * (center[j] * center[k]
+                 + btScalar(0.25) * (center[j] * abc[k] + center[k] * abc[j])
+                  + btScalar(0.1) * (a[j] * a[k] + b[j] * b[k] + c[j] * c[k])
+                  + btScalar(0.05) * (a[j] * b[k] + a[k] * b[j] + a[j] * c[k] + a[k] * c[j] + b[j] * c[k] + b[k] * c[j]));
+            }
+         }
+         btScalar i00 = -i[0][0];
+         btScalar i11 = -i[1][1];
+         btScalar i22 = -i[2][2];
+         i[0][0] = i11 + i22; 
+         i[1][1] = i22 + i00; 
+         i[2][2] = i00 + i11;
+         sum[0] += i[0];
+         sum[1] += i[1];
+         sum[2] += i[2];
+      }
+      
+      btMatrix3x3& getInertia()
+      {
+         return sum;
+      }
+
+   };
+
+   CenterCallback centerCallback;
+   btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+   m_stridingMesh->InternalProcessAllTriangles(&centerCallback, -aabbMax, aabbMax);
+   btVector3 center = centerCallback.getCenter();
+   principal.setOrigin(center);
+   volume = centerCallback.getVolume();
+
+   InertiaCallback inertiaCallback(center);
+   m_stridingMesh->InternalProcessAllTriangles(&inertiaCallback, -aabbMax, aabbMax);
+
+   btMatrix3x3& i = inertiaCallback.getInertia();
+   i.diagonalize(principal.getBasis(), btScalar(0.00001), 20);
+   inertia.setValue(i[0][0], i[1][1], i[2][2]);
+   inertia /= volume;
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h	(revision 2122)
@@ -0,0 +1,61 @@
+#ifndef CONVEX_TRIANGLEMESH_SHAPE_H
+#define CONVEX_TRIANGLEMESH_SHAPE_H
+
+
+#include "btPolyhedralConvexShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+
+
+/// The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good as btConvexHullShape.
+/// A small benefit of this class is that it uses the btStridingMeshInterface, so you can avoid the duplication of the triangle mesh data. Nevertheless, most users should use the much better performing btConvexHullShape instead.
+class btConvexTriangleMeshShape : public btPolyhedralConvexShape
+{
+
+	class btStridingMeshInterface*	m_stridingMesh;
+
+public:
+	btConvexTriangleMeshShape(btStridingMeshInterface* meshInterface, bool calcAabb = true);
+
+	class btStridingMeshInterface*	getMeshInterface()
+	{
+		return m_stridingMesh;
+	}
+	const class btStridingMeshInterface* getMeshInterface() const
+	{
+		return m_stridingMesh;
+	}
+	
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec)const;
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+	
+	//debugging
+	virtual const char*	getName()const {return "ConvexTrimesh";}
+	
+	virtual int	getNumVertices() const;
+	virtual int getNumEdges() const;
+	virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
+	virtual void getVertex(int i,btPoint3& vtx) const;
+	virtual int	getNumPlanes() const;
+	virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
+	virtual	bool isInside(const btPoint3& pt,btScalar tolerance) const;
+
+	
+	virtual void	setLocalScaling(const btVector3& scaling);
+	virtual const btVector3& getLocalScaling() const;
+
+	///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia
+	///and the center of mass to the current coordinate system. A mass of 1 is assumed, for other masses just multiply the computed "inertia"
+	///by the mass. The resulting transform "principal" has to be applied inversely to the mesh in order for the local coordinate system of the
+	///shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform
+	///of the collision object by the principal transform. This method also computes the volume of the convex mesh.
+	void calculatePrincipalAxisTransform(btTransform& principal, btVector3& inertia, btScalar& volume) const;
+
+};
+
+
+
+#endif //CONVEX_TRIANGLEMESH_SHAPE_H
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp	(revision 2122)
@@ -0,0 +1,207 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btCylinderShape.h"
+#include "LinearMath/btPoint3.h"
+
+btCylinderShape::btCylinderShape (const btVector3& halfExtents)
+:btBoxShape(halfExtents),
+m_upAxis(1)
+{
+	m_shapeType = CYLINDER_SHAPE_PROXYTYPE;
+	recalcLocalAabb();
+}
+
+
+btCylinderShapeX::btCylinderShapeX (const btVector3& halfExtents)
+:btCylinderShape(halfExtents)
+{
+	m_upAxis = 0;
+	recalcLocalAabb();
+}
+
+
+btCylinderShapeZ::btCylinderShapeZ (const btVector3& halfExtents)
+:btCylinderShape(halfExtents)
+{
+	m_upAxis = 2;
+	recalcLocalAabb();
+}
+
+void btCylinderShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	//skip the box 'getAabb'
+	btPolyhedralConvexShape::getAabb(t,aabbMin,aabbMax);
+}
+
+
+SIMD_FORCE_INLINE btVector3 CylinderLocalSupportX(const btVector3& halfExtents,const btVector3& v) 
+{
+const int cylinderUpAxis = 0;
+const int XX = 1;
+const int YY = 0;
+const int ZZ = 2;
+
+	//mapping depends on how cylinder local orientation is
+	// extents of the cylinder is: X,Y is for radius, and Z for height
+
+
+	btScalar radius = halfExtents[XX];
+	btScalar halfHeight = halfExtents[cylinderUpAxis];
+
+
+    btVector3 tmp;
+	btScalar d ;
+
+    btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
+    if (s != btScalar(0.0))
+	{
+        d = radius / s;  
+		tmp[XX] = v[XX] * d;
+		tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+		tmp[ZZ] = v[ZZ] * d;
+		return tmp;
+	}
+    else
+	{
+	    tmp[XX] = radius;
+		tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+		tmp[ZZ] = btScalar(0.0);
+		return tmp;
+    }
+
+
+}
+
+
+
+
+
+
+inline  btVector3 CylinderLocalSupportY(const btVector3& halfExtents,const btVector3& v) 
+{
+
+const int cylinderUpAxis = 1;
+const int XX = 0;
+const int YY = 1;
+const int ZZ = 2;
+
+
+	btScalar radius = halfExtents[XX];
+	btScalar halfHeight = halfExtents[cylinderUpAxis];
+
+
+    btVector3 tmp;
+	btScalar d ;
+
+    btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
+    if (s != btScalar(0.0))
+	{
+        d = radius / s;  
+		tmp[XX] = v[XX] * d;
+		tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+		tmp[ZZ] = v[ZZ] * d;
+		return tmp;
+	}
+    else
+	{
+	    tmp[XX] = radius;
+		tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+		tmp[ZZ] = btScalar(0.0);
+		return tmp;
+    }
+
+}
+
+inline btVector3 CylinderLocalSupportZ(const btVector3& halfExtents,const btVector3& v) 
+{
+const int cylinderUpAxis = 2;
+const int XX = 0;
+const int YY = 2;
+const int ZZ = 1;
+
+	//mapping depends on how cylinder local orientation is
+	// extents of the cylinder is: X,Y is for radius, and Z for height
+
+
+	btScalar radius = halfExtents[XX];
+	btScalar halfHeight = halfExtents[cylinderUpAxis];
+
+
+    btVector3 tmp;
+	btScalar d ;
+
+    btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
+    if (s != btScalar(0.0))
+	{
+        d = radius / s;  
+		tmp[XX] = v[XX] * d;
+		tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+		tmp[ZZ] = v[ZZ] * d;
+		return tmp;
+	}
+    else
+	{
+	    tmp[XX] = radius;
+		tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+		tmp[ZZ] = btScalar(0.0);
+		return tmp;
+    }
+
+
+}
+
+btVector3	btCylinderShapeX::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+{
+	return CylinderLocalSupportX(getHalfExtentsWithoutMargin(),vec);
+}
+
+
+btVector3	btCylinderShapeZ::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+{
+	return CylinderLocalSupportZ(getHalfExtentsWithoutMargin(),vec);
+}
+btVector3	btCylinderShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+{
+	return CylinderLocalSupportY(getHalfExtentsWithoutMargin(),vec);
+}
+
+void	btCylinderShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	for (int i=0;i<numVectors;i++)
+	{
+		supportVerticesOut[i] = CylinderLocalSupportY(getHalfExtentsWithoutMargin(),vectors[i]);
+	}
+}
+
+void	btCylinderShapeZ::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	for (int i=0;i<numVectors;i++)
+	{
+		supportVerticesOut[i] = CylinderLocalSupportZ(getHalfExtentsWithoutMargin(),vectors[i]);
+	}
+}
+
+
+
+
+void	btCylinderShapeX::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	for (int i=0;i<numVectors;i++)
+	{
+		supportVerticesOut[i] = CylinderLocalSupportX(getHalfExtentsWithoutMargin(),vectors[i]);
+	}
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCylinderShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCylinderShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCylinderShape.h	(revision 2122)
@@ -0,0 +1,134 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CYLINDER_MINKOWSKI_H
+#define CYLINDER_MINKOWSKI_H
+
+#include "btBoxShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+#include "LinearMath/btVector3.h"
+
+/// The btCylinderShape class implements a cylinder shape primitive, centered around the origin. Its central axis aligned with the Y axis. btCylinderShapeX is aligned with the X axis and btCylinderShapeZ around the Z axis.
+class btCylinderShape : public btBoxShape
+
+{
+
+protected:
+
+	int	m_upAxis;
+
+public:
+	btCylinderShape (const btVector3& halfExtents);
+	
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+	void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec) const
+	{
+
+		btVector3 supVertex;
+		supVertex = localGetSupportingVertexWithoutMargin(vec);
+		
+		if ( getMargin()!=btScalar(0.) )
+		{
+			btVector3 vecnorm = vec;
+			if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+			{
+				vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+			} 
+			vecnorm.normalize();
+			supVertex+= getMargin() * vecnorm;
+		}
+		return supVertex;
+	}
+
+
+	//use box inertia
+	//	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+
+	int	getUpAxis() const
+	{
+		return m_upAxis;
+	}
+
+	virtual btScalar getRadius() const
+	{
+		return getHalfExtentsWithMargin().getX();
+	}
+
+	//debugging
+	virtual const char*	getName()const
+	{
+		return "CylinderY";
+	}
+
+
+
+};
+
+class btCylinderShapeX : public btCylinderShape
+{
+public:
+	btCylinderShapeX (const btVector3& halfExtents);
+
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+	
+		//debugging
+	virtual const char*	getName()const
+	{
+		return "CylinderX";
+	}
+
+	virtual btScalar getRadius() const
+	{
+		return getHalfExtentsWithMargin().getY();
+	}
+
+};
+
+class btCylinderShapeZ : public btCylinderShape
+{
+public:
+	btCylinderShapeZ (const btVector3& halfExtents);
+
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
+	virtual int	getUpAxis() const
+	{
+		return 2;
+	}
+		//debugging
+	virtual const char*	getName()const
+	{
+		return "CylinderZ";
+	}
+
+	virtual btScalar getRadius() const
+	{
+		return getHalfExtentsWithMargin().getX();
+	}
+
+};
+
+
+#endif //CYLINDER_MINKOWSKI_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btEmptyShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btEmptyShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btEmptyShape.cpp	(revision 2122)
@@ -0,0 +1,50 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btEmptyShape.h"
+
+
+#include "btCollisionShape.h"
+
+
+btEmptyShape::btEmptyShape() : btConcaveShape ()
+{
+	m_shapeType = EMPTY_SHAPE_PROXYTYPE;
+}
+
+
+btEmptyShape::~btEmptyShape()
+{
+}
+
+
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+void btEmptyShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	btVector3 margin(getMargin(),getMargin(),getMargin());
+
+	aabbMin = t.getOrigin() - margin;
+
+	aabbMax = t.getOrigin() + margin;
+
+}
+
+void	btEmptyShape::calculateLocalInertia(btScalar ,btVector3& ) const
+{
+	btAssert(0);
+}
+
+	
+	
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btEmptyShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btEmptyShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btEmptyShape.h	(revision 2122)
@@ -0,0 +1,67 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef EMPTY_SHAPE_H
+#define EMPTY_SHAPE_H
+
+#include "btConcaveShape.h"
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "btCollisionMargin.h"
+
+
+
+
+/// The btEmptyShape is a collision shape without actual collision detection shape, so most users should ignore this class.
+/// It can be replaced by another shape during runtime, but the inertia tensor should be recomputed.
+class btEmptyShape	: public btConcaveShape
+{
+public:
+	btEmptyShape();
+
+	virtual ~btEmptyShape();
+
+
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+	void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+
+	virtual void	setLocalScaling(const btVector3& scaling)
+	{
+		m_localScaling = scaling;
+	}
+	virtual const btVector3& getLocalScaling() const 
+	{
+		return m_localScaling;
+	}
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+	
+	virtual const char*	getName()const
+	{
+		return "Empty";
+	}
+
+
+protected:
+	btVector3	m_localScaling;
+
+};
+
+
+
+#endif //EMPTY_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp	(revision 2122)
@@ -0,0 +1,336 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btHeightfieldTerrainShape.h"
+
+#include "LinearMath/btTransformUtil.h"
+
+
+btHeightfieldTerrainShape::btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength,void* heightfieldData,btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges)
+: btConcaveShape (), m_heightStickWidth(heightStickWidth),
+m_heightStickLength(heightStickLength),
+m_maxHeight(maxHeight),
+m_width((btScalar)heightStickWidth-1),
+m_length((btScalar)heightStickLength-1),
+m_heightfieldDataUnknown(heightfieldData),
+m_useFloatData(useFloatData),
+m_flipQuadEdges(flipQuadEdges),
+m_useDiamondSubdivision(false),
+m_upAxis(upAxis),
+m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.))
+{
+	m_shapeType = TERRAIN_SHAPE_PROXYTYPE;
+
+	btScalar	quantizationMargin = 1.f;
+
+	//enlarge the AABB to avoid division by zero when initializing the quantization values
+	btVector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin);
+
+	btVector3	halfExtents(0,0,0);
+
+	switch (m_upAxis)
+	{
+	case 0:
+		{
+			halfExtents.setValue(
+				btScalar(m_maxHeight),
+				btScalar(m_width), //?? don't know if this should change
+				btScalar(m_length));
+			break;
+		}
+	case 1:
+		{
+			halfExtents.setValue(
+				btScalar(m_width),
+				btScalar(m_maxHeight),
+				btScalar(m_length));
+			break;
+		};
+	case 2:
+		{
+			halfExtents.setValue(
+				btScalar(m_width),
+				btScalar(m_length),
+				btScalar(m_maxHeight)
+			);
+			break;
+		}
+	default:
+		{
+			//need to get valid m_upAxis
+			btAssert(0);
+		}
+	}
+
+	halfExtents*= btScalar(0.5);
+	
+	m_localAabbMin = -halfExtents - clampValue;
+	m_localAabbMax = halfExtents + clampValue;
+	btVector3 aabbSize = m_localAabbMax - m_localAabbMin;
+
+}
+
+
+btHeightfieldTerrainShape::~btHeightfieldTerrainShape()
+{
+}
+
+
+
+void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	btVector3 halfExtents = (m_localAabbMax-m_localAabbMin)* m_localScaling * btScalar(0.5);
+	halfExtents += btVector3(getMargin(),getMargin(),getMargin());
+
+	btMatrix3x3 abs_b = t.getBasis().absolute();  
+	btPoint3 center = t.getOrigin();
+	btVector3 extent = btVector3(abs_b[0].dot(halfExtents),
+		   abs_b[1].dot(halfExtents),
+		  abs_b[2].dot(halfExtents));
+	
+
+	aabbMin = center - extent;
+	aabbMax = center + extent;
+
+
+}
+
+btScalar	btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const
+{
+	btScalar val = 0.f;
+	if (m_useFloatData)
+	{
+		val = m_heightfieldDataFloat[(y*m_heightStickWidth)+x];
+	} else
+	{
+		//assume unsigned short int
+		unsigned char heightFieldValue = m_heightfieldDataUnsignedChar[(y*m_heightStickWidth)+x];
+		val = heightFieldValue* (m_maxHeight/btScalar(65535));
+	}
+	return val;
+}
+
+
+
+
+
+void	btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
+{
+
+	btAssert(x>=0);
+	btAssert(y>=0);
+	btAssert(x<m_heightStickWidth);
+	btAssert(y<m_heightStickLength);
+
+
+	btScalar	height = getHeightFieldValue(x,y);
+
+	switch (m_upAxis)
+	{
+	case 0:
+		{
+		vertex.setValue(
+			height,
+			(-m_width/btScalar(2.0)) + x,
+			(-m_length/btScalar(2.0) ) + y
+			);
+			break;
+		}
+	case 1:
+		{
+			vertex.setValue(
+			(-m_width/btScalar(2.0)) + x,
+			height,
+			(-m_length/btScalar(2.0)) + y
+			);
+			break;
+		};
+	case 2:
+		{
+			vertex.setValue(
+			(-m_width/btScalar(2.0)) + x,
+			(-m_length/btScalar(2.0)) + y,
+			height
+			);
+			break;
+		}
+	default:
+		{
+			//need to get valid m_upAxis
+			btAssert(0);
+		}
+	}
+
+	vertex*=m_localScaling;
+	
+}
+
+
+void btHeightfieldTerrainShape::quantizeWithClamp(int* out, const btVector3& point,int /*isMax*/) const
+{
+	btVector3 clampedPoint(point);
+	clampedPoint.setMax(m_localAabbMin);
+	clampedPoint.setMin(m_localAabbMax);
+
+	btVector3 v = (clampedPoint);// - m_bvhAabbMin) * m_bvhQuantization;
+
+	//TODO: optimization: check out how to removed this btFabs
+		
+	out[0] = (int)(v.getX() + v.getX() / btFabs(v.getX())* btScalar(0.5) );
+	out[1] = (int)(v.getY() + v.getY() / btFabs(v.getY())* btScalar(0.5) );
+	out[2] = (int)(v.getZ() + v.getZ() / btFabs(v.getZ())* btScalar(0.5) );
+	
+}
+
+
+void	btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	(void)callback;
+	(void)aabbMax;
+	(void)aabbMin;
+
+	//quantize the aabbMin and aabbMax, and adjust the start/end ranges
+
+	int	quantizedAabbMin[3];
+	int	quantizedAabbMax[3];
+
+	btVector3	localAabbMin = aabbMin*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
+	btVector3	localAabbMax = aabbMax*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
+	
+	quantizeWithClamp(quantizedAabbMin, localAabbMin,0);
+	quantizeWithClamp(quantizedAabbMax, localAabbMax,1);
+	
+	
+
+	int startX=0;
+	int endX=m_heightStickWidth-1;
+	int startJ=0;
+	int endJ=m_heightStickLength-1;
+
+	switch (m_upAxis)
+	{
+	case 0:
+		{
+			quantizedAabbMin[1]+=m_heightStickWidth/2-1;
+			quantizedAabbMax[1]+=m_heightStickWidth/2+1;
+			quantizedAabbMin[2]+=m_heightStickLength/2-1;
+			quantizedAabbMax[2]+=m_heightStickLength/2+1;
+
+			if (quantizedAabbMin[1]>startX)
+				startX = quantizedAabbMin[1];
+			if (quantizedAabbMax[1]<endX)
+				endX = quantizedAabbMax[1];
+			if (quantizedAabbMin[2]>startJ)
+				startJ = quantizedAabbMin[2];
+			if (quantizedAabbMax[2]<endJ)
+				endJ = quantizedAabbMax[2];
+			break;
+		}
+	case 1:
+		{
+			quantizedAabbMin[0]+=m_heightStickWidth/2-1;
+			quantizedAabbMax[0]+=m_heightStickWidth/2+1;
+			quantizedAabbMin[2]+=m_heightStickLength/2-1;
+			quantizedAabbMax[2]+=m_heightStickLength/2+1;
+
+			if (quantizedAabbMin[0]>startX)
+				startX = quantizedAabbMin[0];
+			if (quantizedAabbMax[0]<endX)
+				endX = quantizedAabbMax[0];
+			if (quantizedAabbMin[2]>startJ)
+				startJ = quantizedAabbMin[2];
+			if (quantizedAabbMax[2]<endJ)
+				endJ = quantizedAabbMax[2];
+			break;
+		};
+	case 2:
+		{
+			quantizedAabbMin[0]+=m_heightStickWidth/2-1;
+			quantizedAabbMax[0]+=m_heightStickWidth/2+1;
+			quantizedAabbMin[1]+=m_heightStickLength/2-1;
+			quantizedAabbMax[1]+=m_heightStickLength/2+1;
+
+			if (quantizedAabbMin[0]>startX)
+				startX = quantizedAabbMin[0];
+			if (quantizedAabbMax[0]<endX)
+				endX = quantizedAabbMax[0];
+			if (quantizedAabbMin[1]>startJ)
+				startJ = quantizedAabbMin[1];
+			if (quantizedAabbMax[1]<endJ)
+				endJ = quantizedAabbMax[1];
+			break;
+		}
+	default:
+		{
+			//need to get valid m_upAxis
+			btAssert(0);
+		}
+	}
+
+	
+  
+
+	for(int j=startJ; j<endJ; j++)
+	{
+		for(int x=startX; x<endX; x++)
+		{
+			btVector3 vertices[3];
+			if (m_flipQuadEdges || (m_useDiamondSubdivision && !((j+x) & 1)))
+			{
+        //first triangle
+        getVertex(x,j,vertices[0]);
+        getVertex(x+1,j,vertices[1]);
+        getVertex(x+1,j+1,vertices[2]);
+        callback->processTriangle(vertices,x,j);
+        //second triangle
+        getVertex(x,j,vertices[0]);
+        getVertex(x+1,j+1,vertices[1]);
+        getVertex(x,j+1,vertices[2]);
+        callback->processTriangle(vertices,x,j);				
+			} else
+			{
+        //first triangle
+        getVertex(x,j,vertices[0]);
+        getVertex(x,j+1,vertices[1]);
+        getVertex(x+1,j,vertices[2]);
+        callback->processTriangle(vertices,x,j);
+        //second triangle
+        getVertex(x+1,j,vertices[0]);
+        getVertex(x,j+1,vertices[1]);
+        getVertex(x+1,j+1,vertices[2]);
+        callback->processTriangle(vertices,x,j);
+			}
+		}
+	}
+
+	
+
+}
+
+void	btHeightfieldTerrainShape::calculateLocalInertia(btScalar ,btVector3& inertia) const
+{
+	//moving concave objects not supported
+	
+	inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+}
+
+void	btHeightfieldTerrainShape::setLocalScaling(const btVector3& scaling)
+{
+	m_localScaling = scaling;
+}
+const btVector3& btHeightfieldTerrainShape::getLocalScaling() const
+{
+	return m_localScaling;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h	(revision 2122)
@@ -0,0 +1,87 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef HEIGHTFIELD_TERRAIN_SHAPE_H
+#define HEIGHTFIELD_TERRAIN_SHAPE_H
+
+#include "btConcaveShape.h"
+
+///The btHeightfieldTerrainShape simulates a 2D heightfield terrain collision shape. You can also use the more general btBvhTriangleMeshShape instead.
+///An example implementation of btHeightfieldTerrainShape is provided in Demos/VehicleDemo/VehicleDemo.cpp
+class btHeightfieldTerrainShape : public btConcaveShape
+{
+protected:
+	btVector3	m_localAabbMin;
+	btVector3	m_localAabbMax;
+	
+	///terrain data
+	int	m_heightStickWidth;
+	int m_heightStickLength;
+	btScalar	m_maxHeight;
+	btScalar m_width;
+	btScalar m_length;
+	union
+	{
+		unsigned char*	m_heightfieldDataUnsignedChar;
+		btScalar*			m_heightfieldDataFloat;
+		void*			m_heightfieldDataUnknown;
+	};
+	
+	bool	m_useFloatData;
+	bool	m_flipQuadEdges;
+  bool  m_useDiamondSubdivision;
+
+	int	m_upAxis;
+	
+	btVector3	m_localScaling;
+
+	virtual btScalar	getHeightFieldValue(int x,int y) const;
+	void		quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
+	void		getVertex(int x,int y,btVector3& vertex) const;
+
+	inline bool testQuantizedAabbAgainstQuantizedAabb(int* aabbMin1, int* aabbMax1,const  int* aabbMin2,const  int* aabbMax2) const
+	{
+		bool overlap = true;
+		overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
+		overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap;
+		overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap;
+		return overlap;
+	}
+
+public:
+	btHeightfieldTerrainShape(int heightStickWidth,int heightStickHeight,void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges);
+
+	virtual ~btHeightfieldTerrainShape();
+
+
+	void setUseDiamondSubdivision(bool useDiamondSubdivision=true) { m_useDiamondSubdivision = useDiamondSubdivision;}
+
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual void	setLocalScaling(const btVector3& scaling);
+	
+	virtual const btVector3& getLocalScaling() const;
+	
+	//debugging
+	virtual const char*	getName()const {return "HEIGHTFIELD";}
+
+};
+
+#endif //HEIGHTFIELD_TERRAIN_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMaterial.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMaterial.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMaterial.h	(revision 2122)
@@ -0,0 +1,34 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/// This file was created by Alex Silverman
+
+#ifndef MATERIAL_H
+#define MATERIAL_H
+
+// Material class to be used by btMultimaterialTriangleMeshShape to store triangle properties
+class btMaterial
+{
+    // public members so that materials can change due to world events
+public:
+    btScalar m_friction;
+    btScalar m_restitution;
+    int pad[2];
+
+    btMaterial(){}
+    btMaterial(btScalar fric, btScalar rest) { m_friction = fric; m_restitution = rest; }
+};
+
+#endif // MATERIAL_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp	(revision 2122)
@@ -0,0 +1,59 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btMinkowskiSumShape.h"
+
+
+btMinkowskiSumShape::btMinkowskiSumShape(const btConvexShape* shapeA,const btConvexShape* shapeB)
+: btConvexInternalShape (),
+m_shapeA(shapeA),
+m_shapeB(shapeB)
+{
+	m_shapeType = MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE;
+	m_transA.setIdentity();
+	m_transB.setIdentity();
+}
+
+btVector3 btMinkowskiSumShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+{
+	btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(-vec*m_transA.getBasis()));
+	btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(vec*m_transB.getBasis()));
+	return  supVertexA - supVertexB;
+}
+
+void	btMinkowskiSumShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	//todo: could make recursive use of batching. probably this shape is not used frequently.
+	for (int i=0;i<numVectors;i++)
+	{
+		supportVerticesOut[i] = localGetSupportingVertexWithoutMargin(vectors[i]);
+	}
+
+}
+
+
+
+btScalar	btMinkowskiSumShape::getMargin() const
+{
+	return m_shapeA->getMargin() + m_shapeB->getMargin();
+}
+
+
+void	btMinkowskiSumShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	(void)mass;
+	btAssert(0);
+	inertia.setValue(0,0,0);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h	(revision 2122)
@@ -0,0 +1,60 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef MINKOWSKI_SUM_SHAPE_H
+#define MINKOWSKI_SUM_SHAPE_H
+
+#include "btConvexInternalShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+
+/// The btMinkowskiSumShape is only for advanced users. This shape represents implicit based minkowski sum of two convex implicit shapes.
+class btMinkowskiSumShape : public btConvexInternalShape
+{
+
+	btTransform	m_transA;
+	btTransform	m_transB;
+	const btConvexShape*	m_shapeA;
+	const btConvexShape*	m_shapeB;
+
+public:
+
+	btMinkowskiSumShape(const btConvexShape* shapeA,const btConvexShape* shapeB);
+
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	void	setTransformA(const btTransform&	transA) { m_transA = transA;}
+	void	setTransformB(const btTransform&	transB) { m_transB = transB;}
+
+	const btTransform& getTransformA()const  { return m_transA;}
+	const btTransform& GetTransformB()const  { return m_transB;}
+
+
+	virtual btScalar	getMargin() const;
+
+	const btConvexShape*	getShapeA() const { return m_shapeA;}
+	const btConvexShape*	getShapeB() const { return m_shapeB;}
+
+	virtual const char*	getName()const 
+	{
+		return "MinkowskiSum";
+	}
+};
+
+#endif //MINKOWSKI_SUM_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.cpp	(revision 2122)
@@ -0,0 +1,149 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btMultiSphereShape.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+#include "LinearMath/btQuaternion.h"
+
+btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres)
+:btConvexInternalShape (), m_inertiaHalfExtents(inertiaHalfExtents)
+{
+	m_shapeType = MULTI_SPHERE_SHAPE_PROXYTYPE;
+	btScalar startMargin = btScalar(1e30);
+
+	m_numSpheres = numSpheres;
+	for (int i=0;i<m_numSpheres;i++)
+	{
+		m_localPositions[i] = positions[i];
+		m_radi[i] = radi[i];
+		if (radi[i] < startMargin)
+			startMargin = radi[i];
+	}
+	setMargin(startMargin);
+
+}
+
+
+
+ 
+ btVector3	btMultiSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+{
+	int i;
+	btVector3 supVec(0,0,0);
+
+	btScalar maxDot(btScalar(-1e30));
+
+
+	btVector3 vec = vec0;
+	btScalar lenSqr = vec.length2();
+	if (lenSqr < (SIMD_EPSILON*SIMD_EPSILON))
+	{
+		vec.setValue(1,0,0);
+	} else
+	{
+		btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+		vec *= rlen;
+	}
+
+	btVector3 vtx;
+	btScalar newDot;
+
+	const btVector3* pos = &m_localPositions[0];
+	const btScalar* rad = &m_radi[0];
+
+	for (i=0;i<m_numSpheres;i++)
+	{
+		vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
+		pos++;
+		rad++;
+		newDot = vec.dot(vtx);
+		if (newDot > maxDot)
+		{
+			maxDot = newDot;
+			supVec = vtx;
+		}
+	}
+
+	return supVec;
+
+}
+
+ void	btMultiSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+
+	for (int j=0;j<numVectors;j++)
+	{
+		btScalar maxDot(btScalar(-1e30));
+
+		const btVector3& vec = vectors[j];
+
+		btVector3 vtx;
+		btScalar newDot;
+
+		const btVector3* pos = &m_localPositions[0];
+		const btScalar* rad = &m_radi[0];
+
+		for (int i=0;i<m_numSpheres;i++)
+		{
+			vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
+			pos++;
+			rad++;
+			newDot = vec.dot(vtx);
+			if (newDot > maxDot)
+			{
+				maxDot = newDot;
+				supportVerticesOut[j] = vtx;
+			}
+		}
+	}
+}
+
+
+
+
+
+
+
+
+void	btMultiSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	//as an approximation, take the inertia of the box that bounds the spheres
+
+	btTransform ident;
+	ident.setIdentity();
+//	btVector3 aabbMin,aabbMax;
+
+//	getAabb(ident,aabbMin,aabbMax);
+
+	btVector3 halfExtents = m_inertiaHalfExtents;//(aabbMax - aabbMin)* btScalar(0.5);
+
+	btScalar margin = CONVEX_DISTANCE_MARGIN;
+
+	btScalar lx=btScalar(2.)*(halfExtents[0]+margin);
+	btScalar ly=btScalar(2.)*(halfExtents[1]+margin);
+	btScalar lz=btScalar(2.)*(halfExtents[2]+margin);
+	const btScalar x2 = lx*lx;
+	const btScalar y2 = ly*ly;
+	const btScalar z2 = lz*lz;
+	const btScalar scaledmass = mass * btScalar(.08333333);
+
+	inertia[0] = scaledmass * (y2+z2);
+	inertia[1] = scaledmass * (x2+z2);
+	inertia[2] = scaledmass * (x2+y2);
+
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h	(revision 2122)
@@ -0,0 +1,74 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef MULTI_SPHERE_MINKOWSKI_H
+#define MULTI_SPHERE_MINKOWSKI_H
+
+#include "btConvexInternalShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+
+#define MAX_NUM_SPHERES 5
+
+///The btMultiSphereShape represents the convex hull of a collection of spheres. You can create special capsules or other smooth volumes.
+///It is possible to animate the spheres for deformation.
+class btMultiSphereShape : public btConvexInternalShape
+
+{
+	
+	btVector3 m_localPositions[MAX_NUM_SPHERES];
+	btScalar  m_radi[MAX_NUM_SPHERES];
+	btVector3	m_inertiaHalfExtents;
+
+	int m_numSpheres;
+	
+
+
+
+public:
+	btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres);
+
+	///CollisionShape Interface
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	/// btConvexShape Interface
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+	
+	int	getSphereCount() const
+	{
+		return m_numSpheres;
+	}
+
+	const btVector3&	getSpherePosition(int index) const
+	{
+		return m_localPositions[index];
+	}
+
+	btScalar	getSphereRadius(int index) const
+	{
+		return m_radi[index];
+	}
+
+
+	virtual const char*	getName()const 
+	{
+		return "MultiSphere";
+	}
+
+};
+
+
+#endif //MULTI_SPHERE_MINKOWSKI_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp	(revision 2122)
@@ -0,0 +1,45 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/// This file was created by Alex Silverman
+
+#include "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h"
+//#include "BulletCollision/CollisionShapes/btOptimizedBvh.h"
+
+
+///Obtains the material for a specific triangle
+const btMaterial * btMultimaterialTriangleMeshShape::getMaterialProperties(int partID, int triIndex)
+{
+    const unsigned char * materialBase = 0;
+    int numMaterials;
+    PHY_ScalarType materialType;
+    int materialStride;
+    const unsigned char * triangleMaterialBase = 0;
+    int numTriangles;
+    int triangleMaterialStride;
+    PHY_ScalarType triangleType;
+
+    ((btTriangleIndexVertexMaterialArray*)m_meshInterface)->getLockedReadOnlyMaterialBase(&materialBase, numMaterials, materialType, materialStride,
+        &triangleMaterialBase, numTriangles, triangleMaterialStride, triangleType, partID);
+
+    // return the pointer to the place with the friction for the triangle
+    // TODO: This depends on whether it's a moving mesh or not
+    // BUG IN GIMPACT
+    //return (btScalar*)(&materialBase[triangleMaterialBase[(triIndex-1) * triangleMaterialStride] * materialStride]);
+    int * matInd = (int *)(&(triangleMaterialBase[(triIndex * triangleMaterialStride)]));
+    btMaterial *matVal = (btMaterial *)(&(materialBase[*matInd * materialStride]));
+    return (matVal);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h	(revision 2122)
@@ -0,0 +1,124 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/// This file was created by Alex Silverman
+
+#ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
+#define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
+
+#include "btBvhTriangleMeshShape.h"
+#include "btMaterial.h"
+
+///The BvhTriangleMaterialMeshShape extends the btBvhTriangleMeshShape. Its main contribution is the interface into a material array, which allows per-triangle friction and restitution.
+ATTRIBUTE_ALIGNED16(class) btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
+{
+    btAlignedObjectArray <btMaterial*> m_materialList;
+    int ** m_triangleMaterials;
+
+public:
+
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {}
+    btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
+        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
+        {
+            btVector3 m_triangle[3];
+            const unsigned char *vertexbase;
+            int numverts;
+            PHY_ScalarType type;
+            int stride;
+            const unsigned char *indexbase;
+            int indexstride;
+            int numfaces;
+            PHY_ScalarType indicestype;
+
+            //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
+
+            for(int i = 0; i < meshInterface->getNumSubParts(); i++)
+            {
+                m_meshInterface->getLockedReadOnlyVertexIndexBase(
+                    &vertexbase,
+                    numverts,
+                    type,
+                    stride,
+                    &indexbase,
+                    indexstride,
+                    numfaces,
+                    indicestype,
+                    i);
+                //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
+            }
+        }
+
+	///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
+	btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
+        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
+        {
+            btVector3 m_triangle[3];
+            const unsigned char *vertexbase;
+            int numverts;
+            PHY_ScalarType type;
+            int stride;
+            const unsigned char *indexbase;
+            int indexstride;
+            int numfaces;
+            PHY_ScalarType indicestype;
+
+            //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
+
+            for(int i = 0; i < meshInterface->getNumSubParts(); i++)
+            {
+                m_meshInterface->getLockedReadOnlyVertexIndexBase(
+                    &vertexbase,
+                    numverts,
+                    type,
+                    stride,
+                    &indexbase,
+                    indexstride,
+                    numfaces,
+                    indicestype,
+                    i);
+                //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
+            }
+        }
+	
+    virtual ~btMultimaterialTriangleMeshShape()
+    {
+/*
+        for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
+        {
+            btAlignedFree(m_materialValues[i]);
+            m_materialLookup[i] = NULL;
+        }
+        btAlignedFree(m_materialValues);
+        m_materialLookup = NULL;
+*/
+    }
+	virtual int	getShapeType() const
+	{
+		return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
+	}
+	
+	//debugging
+	virtual const char*	getName()const {return "MULTIMATERIALTRIANGLEMESH";}
+
+    ///Obtains the material for a specific triangle
+    const btMaterial * getMaterialProperties(int partID, int triIndex);
+
+}
+;
+
+#endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.cpp	(revision 2122)
@@ -0,0 +1,390 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btOptimizedBvh.h"
+#include "btStridingMeshInterface.h"
+#include "LinearMath/btAabbUtil2.h"
+#include "LinearMath/btIDebugDraw.h"
+
+
+btOptimizedBvh::btOptimizedBvh()
+{ 
+}
+
+btOptimizedBvh::~btOptimizedBvh()
+{
+}
+
+
+void btOptimizedBvh::build(btStridingMeshInterface* triangles, bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax)
+{
+	m_useQuantization = useQuantizedAabbCompression;
+
+
+	// NodeArray	triangleNodes;
+
+	struct	NodeTriangleCallback : public btInternalTriangleIndexCallback
+	{
+
+		NodeArray&	m_triangleNodes;
+
+		NodeTriangleCallback& operator=(NodeTriangleCallback& other)
+		{
+			m_triangleNodes = other.m_triangleNodes;
+			return *this;
+		}
+		
+		NodeTriangleCallback(NodeArray&	triangleNodes)
+			:m_triangleNodes(triangleNodes)
+		{
+		}
+
+		virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int  triangleIndex)
+		{
+			btOptimizedBvhNode node;
+			btVector3	aabbMin,aabbMax;
+			aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+			aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)); 
+			aabbMin.setMin(triangle[0]);
+			aabbMax.setMax(triangle[0]);
+			aabbMin.setMin(triangle[1]);
+			aabbMax.setMax(triangle[1]);
+			aabbMin.setMin(triangle[2]);
+			aabbMax.setMax(triangle[2]);
+
+			//with quantization?
+			node.m_aabbMinOrg = aabbMin;
+			node.m_aabbMaxOrg = aabbMax;
+
+			node.m_escapeIndex = -1;
+	
+			//for child nodes
+			node.m_subPart = partId;
+			node.m_triangleIndex = triangleIndex;
+			m_triangleNodes.push_back(node);
+		}
+	};
+	struct	QuantizedNodeTriangleCallback : public btInternalTriangleIndexCallback
+	{
+		QuantizedNodeArray&	m_triangleNodes;
+		const btQuantizedBvh* m_optimizedTree; // for quantization
+
+		QuantizedNodeTriangleCallback& operator=(QuantizedNodeTriangleCallback& other)
+		{
+			m_triangleNodes = other.m_triangleNodes;
+			m_optimizedTree = other.m_optimizedTree;
+			return *this;
+		}
+
+		QuantizedNodeTriangleCallback(QuantizedNodeArray&	triangleNodes,const btQuantizedBvh* tree)
+			:m_triangleNodes(triangleNodes),m_optimizedTree(tree)
+		{
+		}
+
+		virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int  triangleIndex)
+		{
+			// The partId and triangle index must fit in the same (positive) integer
+			btAssert(partId < (1<<MAX_NUM_PARTS_IN_BITS));
+			btAssert(triangleIndex < (1<<(31-MAX_NUM_PARTS_IN_BITS)));
+			//negative indices are reserved for escapeIndex
+			btAssert(triangleIndex>=0);
+
+			btQuantizedBvhNode node;
+			btVector3	aabbMin,aabbMax;
+			aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+			aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)); 
+			aabbMin.setMin(triangle[0]);
+			aabbMax.setMax(triangle[0]);
+			aabbMin.setMin(triangle[1]);
+			aabbMax.setMax(triangle[1]);
+			aabbMin.setMin(triangle[2]);
+			aabbMax.setMax(triangle[2]);
+
+			//PCK: add these checks for zero dimensions of aabb
+			const btScalar MIN_AABB_DIMENSION = btScalar(0.002);
+			const btScalar MIN_AABB_HALF_DIMENSION = btScalar(0.001);
+			if (aabbMax.x() - aabbMin.x() < MIN_AABB_DIMENSION)
+			{
+				aabbMax.setX(aabbMax.x() + MIN_AABB_HALF_DIMENSION);
+				aabbMin.setX(aabbMin.x() - MIN_AABB_HALF_DIMENSION);
+			}
+			if (aabbMax.y() - aabbMin.y() < MIN_AABB_DIMENSION)
+			{
+				aabbMax.setY(aabbMax.y() + MIN_AABB_HALF_DIMENSION);
+				aabbMin.setY(aabbMin.y() - MIN_AABB_HALF_DIMENSION);
+			}
+			if (aabbMax.z() - aabbMin.z() < MIN_AABB_DIMENSION)
+			{
+				aabbMax.setZ(aabbMax.z() + MIN_AABB_HALF_DIMENSION);
+				aabbMin.setZ(aabbMin.z() - MIN_AABB_HALF_DIMENSION);
+			}
+
+			m_optimizedTree->quantize(&node.m_quantizedAabbMin[0],aabbMin,0);
+			m_optimizedTree->quantize(&node.m_quantizedAabbMax[0],aabbMax,1);
+
+			node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
+
+			m_triangleNodes.push_back(node);
+		}
+	};
+	
+
+
+	int numLeafNodes = 0;
+
+	
+	if (m_useQuantization)
+	{
+
+		//initialize quantization values
+		setQuantizationValues(bvhAabbMin,bvhAabbMax);
+
+		QuantizedNodeTriangleCallback	callback(m_quantizedLeafNodes,this);
+
+	
+		triangles->InternalProcessAllTriangles(&callback,m_bvhAabbMin,m_bvhAabbMax);
+
+		//now we have an array of leafnodes in m_leafNodes
+		numLeafNodes = m_quantizedLeafNodes.size();
+
+
+		m_quantizedContiguousNodes.resize(2*numLeafNodes);
+
+
+	} else
+	{
+		NodeTriangleCallback	callback(m_leafNodes);
+
+		btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+		btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+
+		triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax);
+
+		//now we have an array of leafnodes in m_leafNodes
+		numLeafNodes = m_leafNodes.size();
+
+		m_contiguousNodes.resize(2*numLeafNodes);
+	}
+
+	m_curNodeIndex = 0;
+
+	buildTree(0,numLeafNodes);
+
+	///if the entire tree is small then subtree size, we need to create a header info for the tree
+	if(m_useQuantization && !m_SubtreeHeaders.size())
+	{
+		btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
+		subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]);
+		subtree.m_rootNodeIndex = 0;
+		subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex();
+	}
+
+	//PCK: update the copy of the size
+	m_subtreeHeaderCount = m_SubtreeHeaders.size();
+
+	//PCK: clear m_quantizedLeafNodes and m_leafNodes, they are temporary
+	m_quantizedLeafNodes.clear();
+	m_leafNodes.clear();
+}
+
+
+
+
+void	btOptimizedBvh::refit(btStridingMeshInterface* meshInterface,const btVector3& aabbMin,const btVector3& aabbMax)
+{
+	if (m_useQuantization)
+	{
+
+		setQuantizationValues(aabbMin,aabbMax);
+
+		updateBvhNodes(meshInterface,0,m_curNodeIndex,0);
+
+		///now update all subtree headers
+
+		int i;
+		for (i=0;i<m_SubtreeHeaders.size();i++)
+		{
+			btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
+			subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[subtree.m_rootNodeIndex]);
+		}
+
+	} else
+	{
+
+	}
+}
+
+
+
+
+void	btOptimizedBvh::refitPartial(btStridingMeshInterface* meshInterface,const btVector3& aabbMin,const btVector3& aabbMax)
+{
+	//incrementally initialize quantization values
+	btAssert(m_useQuantization);
+
+	btAssert(aabbMin.getX() > m_bvhAabbMin.getX());
+	btAssert(aabbMin.getY() > m_bvhAabbMin.getY());
+	btAssert(aabbMin.getZ() > m_bvhAabbMin.getZ());
+
+	btAssert(aabbMax.getX() < m_bvhAabbMax.getX());
+	btAssert(aabbMax.getY() < m_bvhAabbMax.getY());
+	btAssert(aabbMax.getZ() < m_bvhAabbMax.getZ());
+
+	///we should update all quantization values, using updateBvhNodes(meshInterface);
+	///but we only update chunks that overlap the given aabb
+	
+	unsigned short	quantizedQueryAabbMin[3];
+	unsigned short	quantizedQueryAabbMax[3];
+
+	quantize(&quantizedQueryAabbMin[0],aabbMin,0);
+	quantize(&quantizedQueryAabbMax[0],aabbMax,1);
+
+	int i;
+	for (i=0;i<this->m_SubtreeHeaders.size();i++)
+	{
+		btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
+
+		//PCK: unsigned instead of bool
+		unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);
+		if (overlap != 0)
+		{
+			updateBvhNodes(meshInterface,subtree.m_rootNodeIndex,subtree.m_rootNodeIndex+subtree.m_subtreeSize,i);
+
+			subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[subtree.m_rootNodeIndex]);
+		}
+	}
+	
+}
+
+void	btOptimizedBvh::updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index)
+{
+	(void)index;
+
+	btAssert(m_useQuantization);
+
+	int curNodeSubPart=-1;
+
+	//get access info to trianglemesh data
+		const unsigned char *vertexbase = 0;
+		int numverts = 0;
+		PHY_ScalarType type = PHY_INTEGER;
+		int stride = 0;
+		const unsigned char *indexbase = 0;
+		int indexstride = 0;
+		int numfaces = 0;
+		PHY_ScalarType indicestype = PHY_INTEGER;
+
+		btVector3	triangleVerts[3];
+		btVector3	aabbMin,aabbMax;
+		const btVector3& meshScaling = meshInterface->getScaling();
+		
+		int i;
+		for (i=endNode-1;i>=firstNode;i--)
+		{
+
+
+			btQuantizedBvhNode& curNode = m_quantizedContiguousNodes[i];
+			if (curNode.isLeafNode())
+			{
+				//recalc aabb from triangle data
+				int nodeSubPart = curNode.getPartId();
+				int nodeTriangleIndex = curNode.getTriangleIndex();
+				if (nodeSubPart != curNodeSubPart)
+				{
+					if (curNodeSubPart >= 0)
+						meshInterface->unLockReadOnlyVertexBase(curNodeSubPart);
+					meshInterface->getLockedReadOnlyVertexIndexBase(&vertexbase,numverts,	type,stride,&indexbase,indexstride,numfaces,indicestype,nodeSubPart);
+
+					curNodeSubPart = nodeSubPart;
+					btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
+				}
+				//triangles->getLockedReadOnlyVertexIndexBase(vertexBase,numVerts,
+
+				unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
+				
+				
+				for (int j=2;j>=0;j--)
+				{
+					
+					int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
+					btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
+#ifdef DEBUG_PATCH_COLORS
+					btVector3 mycolor = color[index&3];
+					graphicsbase[8] = mycolor.getX();
+					graphicsbase[9] = mycolor.getY();
+					graphicsbase[10] = mycolor.getZ();
+#endif //DEBUG_PATCH_COLORS
+
+
+					triangleVerts[j] = btVector3(
+						graphicsbase[0]*meshScaling.getX(),
+						graphicsbase[1]*meshScaling.getY(),
+						graphicsbase[2]*meshScaling.getZ());
+				}
+
+
+				
+				aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+				aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)); 
+				aabbMin.setMin(triangleVerts[0]);
+				aabbMax.setMax(triangleVerts[0]);
+				aabbMin.setMin(triangleVerts[1]);
+				aabbMax.setMax(triangleVerts[1]);
+				aabbMin.setMin(triangleVerts[2]);
+				aabbMax.setMax(triangleVerts[2]);
+
+				quantize(&curNode.m_quantizedAabbMin[0],aabbMin,0);
+				quantize(&curNode.m_quantizedAabbMax[0],aabbMax,1);
+				
+			} else
+			{
+				//combine aabb from both children
+
+				btQuantizedBvhNode* leftChildNode = &m_quantizedContiguousNodes[i+1];
+				
+				btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? &m_quantizedContiguousNodes[i+2] :
+					&m_quantizedContiguousNodes[i+1+leftChildNode->getEscapeIndex()];
+				
+
+				{
+					for (int i=0;i<3;i++)
+					{
+						curNode.m_quantizedAabbMin[i] = leftChildNode->m_quantizedAabbMin[i];
+						if (curNode.m_quantizedAabbMin[i]>rightChildNode->m_quantizedAabbMin[i])
+							curNode.m_quantizedAabbMin[i]=rightChildNode->m_quantizedAabbMin[i];
+
+						curNode.m_quantizedAabbMax[i] = leftChildNode->m_quantizedAabbMax[i];
+						if (curNode.m_quantizedAabbMax[i] < rightChildNode->m_quantizedAabbMax[i])
+							curNode.m_quantizedAabbMax[i] = rightChildNode->m_quantizedAabbMax[i];
+					}
+				}
+			}
+
+		}
+
+		if (curNodeSubPart >= 0)
+			meshInterface->unLockReadOnlyVertexBase(curNodeSubPart);
+
+		
+}
+
+///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
+btOptimizedBvh* btOptimizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian)
+{
+	btQuantizedBvh* bvh = btQuantizedBvh::deSerializeInPlace(i_alignedDataBuffer,i_dataBufferSize,i_swapEndian);
+	
+	//we don't add additional data so just do a static upcast
+	return static_cast<btOptimizedBvh*>(bvh);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h	(revision 2122)
@@ -0,0 +1,63 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef OPTIMIZED_BVH_H
+#define OPTIMIZED_BVH_H
+
+#include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h"
+
+class btStridingMeshInterface;
+
+
+///The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes, through the btStridingMeshInterface.
+ATTRIBUTE_ALIGNED16(class) btOptimizedBvh : public btQuantizedBvh
+{
+	
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+protected:
+
+public:
+
+	btOptimizedBvh();
+
+	virtual ~btOptimizedBvh();
+
+	void	build(btStridingMeshInterface* triangles,bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax);
+
+	void	refit(btStridingMeshInterface* triangles,const btVector3& aabbMin,const btVector3& aabbMax);
+
+	void	refitPartial(btStridingMeshInterface* triangles,const btVector3& aabbMin, const btVector3& aabbMax);
+
+	void	updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index);
+
+	/// Data buffer MUST be 16 byte aligned
+	virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian)
+	{
+		return btQuantizedBvh::serialize(o_alignedDataBuffer,i_dataBufferSize,i_swapEndian);
+
+	}
+
+	///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
+	static btOptimizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian);
+
+
+};
+
+
+#endif //OPTIMIZED_BVH_H
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp	(revision 2122)
@@ -0,0 +1,187 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
+
+btPolyhedralConvexShape::btPolyhedralConvexShape()
+:btConvexInternalShape(),
+m_localAabbMin(1,1,1),
+m_localAabbMax(-1,-1,-1),
+m_isLocalAabbValid(false),
+m_optionalHull(0)
+{
+
+}
+
+
+
+btVector3	btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+{
+	int i;
+	btVector3 supVec(0,0,0);
+
+	btScalar maxDot(btScalar(-1e30));
+
+	btVector3 vec = vec0;
+	btScalar lenSqr = vec.length2();
+	if (lenSqr < btScalar(0.0001))
+	{
+		vec.setValue(1,0,0);
+	} else
+	{
+		btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+		vec *= rlen;
+	}
+
+	btVector3 vtx;
+	btScalar newDot;
+
+	for (i=0;i<getNumVertices();i++)
+	{
+		getVertex(i,vtx);
+		newDot = vec.dot(vtx);
+		if (newDot > maxDot)
+		{
+			maxDot = newDot;
+			supVec = vtx;
+		}
+	}
+
+	return supVec;
+
+}
+
+void	btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	int i;
+
+	btVector3 vtx;
+	btScalar newDot;
+
+	for (i=0;i<numVectors;i++)
+	{
+		supportVerticesOut[i][3] = btScalar(-1e30);
+	}
+
+	for (int j=0;j<numVectors;j++)
+	{
+	
+		const btVector3& vec = vectors[j];
+
+		for (i=0;i<getNumVertices();i++)
+		{
+			getVertex(i,vtx);
+			newDot = vec.dot(vtx);
+			if (newDot > supportVerticesOut[j][3])
+			{
+				//WARNING: don't swap next lines, the w component would get overwritten!
+				supportVerticesOut[j] = vtx;
+				supportVerticesOut[j][3] = newDot;
+			}
+		}
+	}
+}
+
+
+
+void	btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	//not yet, return box inertia
+
+	btScalar margin = getMargin();
+
+	btTransform ident;
+	ident.setIdentity();
+	btVector3 aabbMin,aabbMax;
+	getAabb(ident,aabbMin,aabbMax);
+	btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
+
+	btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
+	btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
+	btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
+	const btScalar x2 = lx*lx;
+	const btScalar y2 = ly*ly;
+	const btScalar z2 = lz*lz;
+	const btScalar scaledmass = mass * btScalar(0.08333333);
+
+	inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
+
+}
+
+
+
+void btPolyhedralConvexShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
+}
+
+
+
+void	btPolyhedralConvexShape::setLocalScaling(const btVector3& scaling)
+{
+	btConvexInternalShape::setLocalScaling(scaling);
+	recalcLocalAabb();
+}
+
+void	btPolyhedralConvexShape::recalcLocalAabb()
+{
+	m_isLocalAabbValid = true;
+	
+	#if 1
+	static const btVector3 _directions[] =
+	{
+		btVector3( 1.,  0.,  0.),
+		btVector3( 0.,  1.,  0.),
+		btVector3( 0.,  0.,  1.),
+		btVector3( -1., 0.,  0.),
+		btVector3( 0., -1.,  0.),
+		btVector3( 0.,  0., -1.)
+	};
+	
+	btVector3 _supporting[] =
+	{
+		btVector3( 0., 0., 0.),
+		btVector3( 0., 0., 0.),
+		btVector3( 0., 0., 0.),
+		btVector3( 0., 0., 0.),
+		btVector3( 0., 0., 0.),
+		btVector3( 0., 0., 0.)
+	};
+	
+	batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6);
+	
+	for ( int i = 0; i < 3; ++i )
+	{
+		m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
+		m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
+	}
+	
+	#else
+
+	for (int i=0;i<3;i++)
+	{
+		btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
+		vec[i] = btScalar(1.);
+		btVector3 tmp = localGetSupportingVertex(vec);
+		m_localAabbMax[i] = tmp[i]+m_collisionMargin;
+		vec[i] = btScalar(-1.);
+		tmp = localGetSupportingVertex(vec);
+		m_localAabbMin[i] = tmp[i]-m_collisionMargin;
+	}
+	#endif
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BU_SHAPE
+#define BU_SHAPE
+
+#include "LinearMath/btPoint3.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "LinearMath/btAabbUtil2.h"
+#include "btConvexInternalShape.h"
+
+
+///The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
+class btPolyhedralConvexShape : public btConvexInternalShape
+{
+
+protected:
+	btVector3	m_localAabbMin;
+	btVector3	m_localAabbMax;
+	bool		m_isLocalAabbValid;
+
+	btPolyhedralConvexShape();
+public:
+
+	
+
+	//brute force implementations
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+	
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+
+	inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
+	{
+
+		//lazy evaluation of local aabb
+		btAssert(m_isLocalAabbValid);
+		btTransformAabb(m_localAabbMin,m_localAabbMax,margin,trans,aabbMin,aabbMax);
+	}
+
+	
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	virtual void	setLocalScaling(const btVector3& scaling);
+
+	void	recalcLocalAabb();
+
+	virtual int	getNumVertices() const = 0 ;
+	virtual int getNumEdges() const = 0;
+	virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const = 0;
+	virtual void getVertex(int i,btPoint3& vtx) const = 0;
+	virtual int	getNumPlanes() const = 0;
+	virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const = 0;
+//	virtual int getIndex(int i) const = 0 ; 
+
+	virtual	bool isInside(const btPoint3& pt,btScalar tolerance) const = 0;
+	
+	/// optional Hull is for optional Separating Axis Test Hull collision detection, see Hull.cpp
+	class	Hull*	m_optionalHull;
+
+};
+
+#endif //BU_SHAPE
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp	(revision 2122)
@@ -0,0 +1,120 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btScaledBvhTriangleMeshShape.h"
+
+btScaledBvhTriangleMeshShape::btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,btVector3 localScaling)
+:m_localScaling(localScaling),m_bvhTriMeshShape(childShape)
+{
+	m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE;
+}
+
+btScaledBvhTriangleMeshShape::~btScaledBvhTriangleMeshShape()
+{
+}
+
+
+class btScaledTriangleCallback : public btTriangleCallback
+{
+	btTriangleCallback* m_originalCallback;
+
+	btVector3	m_localScaling;
+
+public:
+
+	btScaledTriangleCallback(btTriangleCallback* originalCallback,btVector3 localScaling)
+		:m_originalCallback(originalCallback),
+		m_localScaling(localScaling)
+	{
+	}
+
+	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
+	{
+		btVector3 newTriangle[3];
+		newTriangle[0] = triangle[0]*m_localScaling;
+		newTriangle[1] = triangle[1]*m_localScaling;
+		newTriangle[2] = triangle[2]*m_localScaling;
+		m_originalCallback->processTriangle(&newTriangle[0],partId,triangleIndex);
+	}
+};
+
+void	btScaledBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	btScaledTriangleCallback scaledCallback(callback,m_localScaling);
+	
+	btVector3 invLocalScaling(1.f/m_localScaling.getX(),1.f/m_localScaling.getY(),1.f/m_localScaling.getZ());
+	btVector3 scaledAabbMin,scaledAabbMax;
+
+	///support negative scaling
+	scaledAabbMin[0] = m_localScaling.getX() >= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0];
+	scaledAabbMin[1] = m_localScaling.getY() >= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1];
+	scaledAabbMin[2] = m_localScaling.getZ() >= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2];
+	
+	scaledAabbMax[0] = m_localScaling.getX() <= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0];
+	scaledAabbMax[1] = m_localScaling.getY() <= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1];
+	scaledAabbMax[2] = m_localScaling.getZ() <= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2];
+	
+	
+	m_bvhTriMeshShape->processAllTriangles(&scaledCallback,scaledAabbMin,scaledAabbMax);
+}
+
+
+void	btScaledBvhTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	btVector3 localAabbMin = m_bvhTriMeshShape->getLocalAabbMin();
+	btVector3 localAabbMax = m_bvhTriMeshShape->getLocalAabbMax();
+
+	btVector3 tmpLocalAabbMin = localAabbMin * m_localScaling;
+	btVector3 tmpLocalAabbMax = localAabbMax * m_localScaling;
+
+	localAabbMin[0] = (m_localScaling.getX() >= 0.) ? tmpLocalAabbMin[0] : tmpLocalAabbMax[0];
+	localAabbMin[1] = (m_localScaling.getY() >= 0.) ? tmpLocalAabbMin[1] : tmpLocalAabbMax[1];
+	localAabbMin[2] = (m_localScaling.getZ() >= 0.) ? tmpLocalAabbMin[2] : tmpLocalAabbMax[2];
+	localAabbMax[0] = (m_localScaling.getX() <= 0.) ? tmpLocalAabbMin[0] : tmpLocalAabbMax[0];
+	localAabbMax[1] = (m_localScaling.getY() <= 0.) ? tmpLocalAabbMin[1] : tmpLocalAabbMax[1];
+	localAabbMax[2] = (m_localScaling.getZ() <= 0.) ? tmpLocalAabbMin[2] : tmpLocalAabbMax[2];
+
+	btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin);
+	btScalar margin = m_bvhTriMeshShape->getMargin();
+	localHalfExtents += btVector3(margin,margin,margin);
+	btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin);
+	
+	btMatrix3x3 abs_b = trans.getBasis().absolute();  
+
+	btPoint3 center = trans(localCenter);
+
+	btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
+		   abs_b[1].dot(localHalfExtents),
+		  abs_b[2].dot(localHalfExtents));
+	aabbMin = center - extent;
+	aabbMax = center + extent;
+
+}
+
+void	btScaledBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling)
+{
+	m_localScaling = scaling;
+}
+
+const btVector3& btScaledBvhTriangleMeshShape::getLocalScaling() const
+{
+	return m_localScaling;
+}
+
+void	btScaledBvhTriangleMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	///don't make this a movable object!
+//	btAssert(0);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h	(revision 2122)
@@ -0,0 +1,62 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SCALED_BVH_TRIANGLE_MESH_SHAPE_H
+#define SCALED_BVH_TRIANGLE_MESH_SHAPE_H
+
+#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
+
+
+///The btScaledBvhTriangleMeshShape allows to instance a scaled version of an existing btBvhTriangleMeshShape.
+///Note that each btBvhTriangleMeshShape still can have its own local scaling, independent from this btScaledBvhTriangleMeshShape 'localScaling'
+ATTRIBUTE_ALIGNED16(class) btScaledBvhTriangleMeshShape : public btConcaveShape
+{
+	
+	
+	btVector3	m_localScaling;
+
+	btBvhTriangleMeshShape*	m_bvhTriMeshShape;
+
+public:
+
+
+	btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,btVector3 localScaling);
+
+	virtual ~btScaledBvhTriangleMeshShape();
+
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+	virtual void	setLocalScaling(const btVector3& scaling);
+	virtual const btVector3& getLocalScaling() const;
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+	btBvhTriangleMeshShape*	getChildShape()
+	{
+		return m_bvhTriMeshShape;
+	}
+
+	const btBvhTriangleMeshShape*	getChildShape() const
+	{
+		return m_bvhTriMeshShape;
+	}
+
+	//debugging
+	virtual const char*	getName()const {return "SCALEDBVHTRIANGLEMESH";}
+
+};
+
+#endif //BVH_TRIANGLE_MESH_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btShapeHull.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btShapeHull.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btShapeHull.cpp	(revision 2122)
@@ -0,0 +1,164 @@
+/*
+btbtShapeHull implemented by John McCutchan.
+
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://bulletphysics.com
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btShapeHull.h"
+#include "LinearMath/btConvexHull.h"
+
+#define NUM_UNITSPHERE_POINTS 42
+
+static btVector3 btUnitSpherePoints[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] = 
+{
+	btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)),
+	btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)),
+	btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)),
+	btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)),
+	btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)),
+	btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)),
+	btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)),
+	btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)),
+	btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)),
+	btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)),
+	btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)),
+	btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)),
+	btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)),
+	btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)),
+	btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)),
+	btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)),
+	btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)),
+	btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)),
+	btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)),
+	btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)),
+	btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)),
+	btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)),
+	btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)),
+	btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)),
+	btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)),
+	btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)),
+	btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)),
+	btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)),
+	btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)),
+	btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)),
+	btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)),
+	btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)),
+	btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)),
+	btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)),
+	btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)),
+	btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)),
+	btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)),
+	btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)),
+	btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)),
+	btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)),
+	btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)),
+	btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))
+};
+
+btShapeHull::btShapeHull (const btConvexShape* shape)
+{
+	m_shape = shape;
+	m_vertices.clear ();
+	m_indices.clear();
+	m_numIndices = 0;
+}
+
+btShapeHull::~btShapeHull ()
+{
+	m_indices.clear();	
+	m_vertices.clear ();
+}
+
+bool
+btShapeHull::buildHull (btScalar /*margin*/)
+{
+	int numSampleDirections = NUM_UNITSPHERE_POINTS;
+	{
+		int numPDA = m_shape->getNumPreferredPenetrationDirections();
+		if (numPDA)
+		{
+			for (int i=0;i<numPDA;i++)
+			{
+				btVector3 norm;
+				m_shape->getPreferredPenetrationDirection(i,norm);
+				btUnitSpherePoints[numSampleDirections] = norm;
+				numSampleDirections++;
+			}
+		}
+	}
+
+	btVector3 supportPoints[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2];
+	int i;
+	for (i = 0; i < numSampleDirections; i++)
+	{
+		supportPoints[i] = m_shape->localGetSupportingVertex(btUnitSpherePoints[i]);
+	}
+
+	HullDesc hd;
+	hd.mFlags = QF_TRIANGLES;
+	hd.mVcount = static_cast<unsigned int>(numSampleDirections);
+
+#ifdef BT_USE_DOUBLE_PRECISION
+	hd.mVertices = &supportPoints[0];
+	hd.mVertexStride = sizeof(btVector3);
+#else
+	hd.mVertices = &supportPoints[0];
+	hd.mVertexStride = sizeof (btVector3);
+#endif
+
+	HullLibrary hl;
+	HullResult hr;
+	if (hl.CreateConvexHull (hd, hr) == QE_FAIL)
+	{
+		return false;
+	}
+
+	m_vertices.resize (static_cast<int>(hr.mNumOutputVertices));
+
+
+	for (i = 0; i < static_cast<int>(hr.mNumOutputVertices); i++)
+	{
+		m_vertices[i] = hr.m_OutputVertices[i];
+	}
+	m_numIndices = hr.mNumIndices;
+	m_indices.resize(static_cast<int>(m_numIndices));
+	for (i = 0; i < static_cast<int>(m_numIndices); i++)
+	{
+		m_indices[i] = hr.m_Indices[i];
+	}
+
+	// free temporary hull result that we just copied
+	hl.ReleaseResult (hr);
+
+	return true;
+}
+
+int
+btShapeHull::numTriangles () const
+{
+	return static_cast<int>(m_numIndices / 3);
+}
+
+int
+btShapeHull::numVertices () const
+{
+	return m_vertices.size ();
+}
+
+int
+btShapeHull::numIndices () const
+{
+	return static_cast<int>(m_numIndices);
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btShapeHull.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btShapeHull.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btShapeHull.h	(revision 2122)
@@ -0,0 +1,56 @@
+/*
+btShapeHull implemented by John McCutchan.
+
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef _SHAPE_HULL_H
+#define _SHAPE_HULL_H
+
+#include "LinearMath/btAlignedObjectArray.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+
+
+///The btShapeHull class takes a btConvexShape, builds a simplified convex hull using btConvexHull and provides triangle indices and vertices.
+///It can be useful for to simplify a complex convex object and for visualization of a non-polyhedral convex object.
+///It approximates the convex hull using the supporting vertex of 42 directions.
+class btShapeHull
+{
+public:
+	btShapeHull (const btConvexShape* shape);
+	~btShapeHull ();
+
+	bool buildHull (btScalar margin);
+
+	int numTriangles () const;
+	int numVertices () const;
+	int numIndices () const;
+
+	const btVector3* getVertexPointer() const
+	{
+		return &m_vertices[0];
+	}
+	const unsigned int* getIndexPointer() const
+	{
+		return &m_indices[0];
+	}
+
+protected:
+	btAlignedObjectArray<btVector3> m_vertices;
+	btAlignedObjectArray<unsigned int> m_indices;
+	unsigned int m_numIndices;
+	const btConvexShape* m_shape;
+};
+
+#endif //_SHAPE_HULL_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btSphereShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btSphereShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btSphereShape.cpp	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSphereShape.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+#include "LinearMath/btQuaternion.h"
+
+
+btSphereShape ::btSphereShape (btScalar radius) : btConvexInternalShape ()
+{
+	m_shapeType = SPHERE_SHAPE_PROXYTYPE;
+	m_implicitShapeDimensions.setX(radius);
+	m_collisionMargin = radius;
+}
+
+btVector3	btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+{
+	(void)vec;
+	return btVector3(btScalar(0.),btScalar(0.),btScalar(0.));
+}
+
+void	btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	(void)vectors;
+
+	for (int i=0;i<numVectors;i++)
+	{
+		supportVerticesOut[i].setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+	}
+}
+
+
+btVector3	btSphereShape::localGetSupportingVertex(const btVector3& vec)const
+{
+	btVector3 supVertex;
+	supVertex = localGetSupportingVertexWithoutMargin(vec);
+
+	btVector3 vecnorm = vec;
+	if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+	{
+		vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+	} 
+	vecnorm.normalize();
+	supVertex+= getMargin() * vecnorm;
+	return supVertex;
+}
+
+
+//broken due to scaling
+void btSphereShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	const btVector3& center = t.getOrigin();
+	btVector3 extent(getMargin(),getMargin(),getMargin());
+	aabbMin = center - extent;
+	aabbMax = center + extent;
+}
+
+
+
+void	btSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	btScalar elem = btScalar(0.4) * mass * getMargin()*getMargin();
+	inertia.setValue(elem,elem,elem);
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SPHERE_MINKOWSKI_H
+#define SPHERE_MINKOWSKI_H
+
+#include "btConvexInternalShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+
+///The btSphereShape implements an implicit sphere, centered around a local origin with radius.
+ATTRIBUTE_ALIGNED16(class) btSphereShape : public btConvexInternalShape
+
+{
+	
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btSphereShape (btScalar radius);
+	
+	
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec)const;
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+	//notice that the vectors should be unit length
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+
+	btScalar	getRadius() const { return m_implicitShapeDimensions.getX() * m_localScaling.getX();}
+
+	//debugging
+	virtual const char*	getName()const {return "SPHERE";}
+
+	virtual void	setMargin(btScalar margin)
+	{
+		btConvexInternalShape::setMargin(margin);
+	}
+	virtual btScalar	getMargin() const
+	{
+		//to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
+		//this means, non-uniform scaling is not supported anymore
+		return getRadius();
+	}
+
+
+};
+
+
+#endif //SPHERE_MINKOWSKI_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btStaticPlaneShape.h"
+
+#include "LinearMath/btTransformUtil.h"
+
+
+btStaticPlaneShape::btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant)
+: btConcaveShape (), m_planeNormal(planeNormal.normalized()),
+m_planeConstant(planeConstant),
+m_localScaling(btScalar(0.),btScalar(0.),btScalar(0.))
+{
+	m_shapeType = STATIC_PLANE_PROXYTYPE;
+	//	btAssert( btFuzzyZero(m_planeNormal.length() - btScalar(1.)) );
+}
+
+
+btStaticPlaneShape::~btStaticPlaneShape()
+{
+}
+
+
+
+void btStaticPlaneShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	(void)t;
+	/*
+	btVector3 infvec (btScalar(1e30),btScalar(1e30),btScalar(1e30));
+
+	btVector3 center = m_planeNormal*m_planeConstant;
+	aabbMin = center + infvec*m_planeNormal;
+	aabbMax = aabbMin;
+	aabbMin.setMin(center - infvec*m_planeNormal);
+	aabbMax.setMax(center - infvec*m_planeNormal); 
+	*/
+
+	aabbMin.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+	aabbMax.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+
+}
+
+
+
+
+void	btStaticPlaneShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+
+	btVector3 halfExtents = (aabbMax - aabbMin) * btScalar(0.5);
+	btScalar radius = halfExtents.length();
+	btVector3 center = (aabbMax + aabbMin) * btScalar(0.5);
+	
+	//this is where the triangles are generated, given AABB and plane equation (normal/constant)
+
+	btVector3 tangentDir0,tangentDir1;
+
+	//tangentDir0/tangentDir1 can be precalculated
+	btPlaneSpace1(m_planeNormal,tangentDir0,tangentDir1);
+
+	btVector3 supVertex0,supVertex1;
+
+	btVector3 projectedCenter = center - (m_planeNormal.dot(center) - m_planeConstant)*m_planeNormal;
+	
+	btVector3 triangle[3];
+	triangle[0] = projectedCenter + tangentDir0*radius + tangentDir1*radius;
+	triangle[1] = projectedCenter + tangentDir0*radius - tangentDir1*radius;
+	triangle[2] = projectedCenter - tangentDir0*radius - tangentDir1*radius;
+
+	callback->processTriangle(triangle,0,0);
+
+	triangle[0] = projectedCenter - tangentDir0*radius - tangentDir1*radius;
+	triangle[1] = projectedCenter - tangentDir0*radius + tangentDir1*radius;
+	triangle[2] = projectedCenter + tangentDir0*radius + tangentDir1*radius;
+
+	callback->processTriangle(triangle,0,1);
+
+}
+
+void	btStaticPlaneShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	(void)mass;
+
+	//moving concave objects not supported
+	
+	inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+}
+
+void	btStaticPlaneShape::setLocalScaling(const btVector3& scaling)
+{
+	m_localScaling = scaling;
+}
+const btVector3& btStaticPlaneShape::getLocalScaling() const
+{
+	return m_localScaling;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef STATIC_PLANE_SHAPE_H
+#define STATIC_PLANE_SHAPE_H
+
+#include "btConcaveShape.h"
+
+
+///The btStaticPlaneShape simulates an infinite non-moving (static) collision plane.
+class btStaticPlaneShape : public btConcaveShape
+{
+protected:
+	btVector3	m_localAabbMin;
+	btVector3	m_localAabbMax;
+	
+	btVector3	m_planeNormal;
+	btScalar      m_planeConstant;
+	btVector3	m_localScaling;
+
+public:
+	btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant);
+
+	virtual ~btStaticPlaneShape();
+
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual void	setLocalScaling(const btVector3& scaling);
+	virtual const btVector3& getLocalScaling() const;
+	
+	const btVector3&	getPlaneNormal() const
+	{
+		return	m_planeNormal;
+	}
+
+	const btScalar&	getPlaneConstant() const
+	{
+		return	m_planeConstant;
+	}
+
+	//debugging
+	virtual const char*	getName()const {return "STATICPLANE";}
+
+
+};
+
+#endif //STATIC_PLANE_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp	(revision 2122)
@@ -0,0 +1,124 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btStridingMeshInterface.h"
+
+btStridingMeshInterface::~btStridingMeshInterface()
+{
+
+}
+
+
+void	btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	(void)aabbMin;
+	(void)aabbMax;
+	int numtotalphysicsverts = 0;
+	int part,graphicssubparts = getNumSubParts();
+	const unsigned char * vertexbase;
+	const unsigned char * indexbase;
+	int indexstride;
+	PHY_ScalarType type;
+	PHY_ScalarType gfxindextype;
+	int stride,numverts,numtriangles;
+	int gfxindex;
+	btVector3 triangle[3];
+	btScalar* graphicsbase;
+
+	btVector3 meshScaling = getScaling();
+
+	///if the number of parts is big, the performance might drop due to the innerloop switch on indextype
+	for (part=0;part<graphicssubparts ;part++)
+	{
+		getLockedReadOnlyVertexIndexBase(&vertexbase,numverts,type,stride,&indexbase,indexstride,numtriangles,gfxindextype,part);
+		numtotalphysicsverts+=numtriangles*3; //upper bound
+
+		switch (gfxindextype)
+		{
+		case PHY_INTEGER:
+			{
+				for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
+				{
+					unsigned int* tri_indices= (unsigned int*)(indexbase+gfxindex*indexstride);
+					graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
+					triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
+					graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
+					triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),	graphicsbase[2]*meshScaling.getZ());
+					graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
+					triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),	graphicsbase[2]*meshScaling.getZ());
+					callback->internalProcessTriangleIndex(triangle,part,gfxindex);
+				}
+				break;
+			}
+		case PHY_SHORT:
+			{
+				for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
+				{
+					unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
+					graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
+					triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
+					graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
+					triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),	graphicsbase[2]*meshScaling.getZ());
+					graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
+					triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),	graphicsbase[2]*meshScaling.getZ());
+					callback->internalProcessTriangleIndex(triangle,part,gfxindex);
+				}
+				break;
+			}
+		default:
+			btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
+		}
+
+		unLockReadOnlyVertexBase(part);
+	}
+}
+
+void	btStridingMeshInterface::calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax)
+{
+
+	struct	AabbCalculationCallback : public btInternalTriangleIndexCallback
+	{
+		btVector3	m_aabbMin;
+		btVector3	m_aabbMax;
+
+		AabbCalculationCallback()
+		{
+			m_aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+			m_aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+		}
+
+		virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int  triangleIndex)
+		{
+			(void)partId;
+			(void)triangleIndex;
+
+			m_aabbMin.setMin(triangle[0]);
+			m_aabbMax.setMax(triangle[0]);
+			m_aabbMin.setMin(triangle[1]);
+			m_aabbMax.setMax(triangle[1]);
+			m_aabbMin.setMin(triangle[2]);
+			m_aabbMax.setMax(triangle[2]);
+		}
+	};
+
+		//first calculate the total aabb for all triangles
+	AabbCalculationCallback	aabbCallback;
+	aabbMin.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+	aabbMax.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+	InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax);
+
+	aabbMin = aabbCallback.m_aabbMin;
+	aabbMax = aabbCallback.m_aabbMax;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h	(revision 2122)
@@ -0,0 +1,95 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef STRIDING_MESHINTERFACE_H
+#define STRIDING_MESHINTERFACE_H
+
+#include "LinearMath/btVector3.h"
+#include "btTriangleCallback.h"
+
+/// PHY_ScalarType enumerates possible scalar types.
+/// See the btStridingMeshInterface for its use
+typedef enum PHY_ScalarType {
+	PHY_FLOAT,
+	PHY_DOUBLE,
+	PHY_INTEGER,
+	PHY_SHORT,
+	PHY_FIXEDPOINT88
+} PHY_ScalarType;
+
+///	The btStridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes.
+/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
+/// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.
+class  btStridingMeshInterface
+{
+	protected:
+	
+		btVector3 m_scaling;
+
+	public:
+		btStridingMeshInterface() :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.))
+		{
+
+		}
+
+		virtual ~btStridingMeshInterface();
+
+
+
+		virtual void	InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+		///brute force method to calculate aabb
+		void	calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax);
+
+		/// get read and write access to a subpart of a triangle mesh
+		/// this subpart has a continuous array of vertices and indices
+		/// in this way the mesh can be handled as chunks of memory with striding
+		/// very similar to OpenGL vertexarray support
+		/// make a call to unLockVertexBase when the read and write access is finished	
+		virtual void	getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0)=0;
+		
+		virtual void	getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0) const=0;
+	
+		/// unLockVertexBase finishes the access to a subpart of the triangle mesh
+		/// make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished
+		virtual void	unLockVertexBase(int subpart)=0;
+
+		virtual void	unLockReadOnlyVertexBase(int subpart) const=0;
+
+
+		/// getNumSubParts returns the number of seperate subparts
+		/// each subpart has a continuous array of vertices and indices
+		virtual int		getNumSubParts() const=0;
+
+		virtual void	preallocateVertices(int numverts)=0;
+		virtual void	preallocateIndices(int numindices)=0;
+
+		virtual bool	hasPremadeAabb() const { return false; }
+		virtual void	setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const {}
+		virtual void	getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const {}
+
+		const btVector3&	getScaling() const {
+			return m_scaling;
+		}
+		void	setScaling(const btVector3& scaling)
+		{
+			m_scaling = scaling;
+		}
+
+	
+
+};
+
+#endif //STRIDING_MESHINTERFACE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.cpp	(revision 2122)
@@ -0,0 +1,200 @@
+
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btTetrahedronShape.h"
+#include "LinearMath/btMatrix3x3.h"
+
+btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexShape (),
+m_numVertices(0)
+{
+	m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
+}
+
+btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0) : btPolyhedralConvexShape (),
+m_numVertices(0)
+{
+	m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
+	addVertex(pt0);
+}
+
+btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1) : btPolyhedralConvexShape (),
+m_numVertices(0)
+{
+	m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
+	addVertex(pt0);
+	addVertex(pt1);
+}
+
+btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2) : btPolyhedralConvexShape (),
+m_numVertices(0)
+{
+	m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
+	addVertex(pt0);
+	addVertex(pt1);
+	addVertex(pt2);
+}
+
+btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2,const btPoint3& pt3) : btPolyhedralConvexShape (),
+m_numVertices(0)
+{
+	m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
+	addVertex(pt0);
+	addVertex(pt1);
+	addVertex(pt2);
+	addVertex(pt3);
+}
+
+
+
+
+
+void btBU_Simplex1to4::addVertex(const btPoint3& pt)
+{
+	m_vertices[m_numVertices++] = pt;
+
+	recalcLocalAabb();
+}
+
+
+int	btBU_Simplex1to4::getNumVertices() const
+{
+	return m_numVertices;
+}
+
+int btBU_Simplex1to4::getNumEdges() const
+{
+	//euler formula, F-E+V = 2, so E = F+V-2
+
+	switch (m_numVertices)
+	{
+	case 0:
+		return 0;
+	case 1: return 0;
+	case 2: return 1;
+	case 3: return 3;
+	case 4: return 6;
+
+
+	}
+
+	return 0;
+}
+
+void btBU_Simplex1to4::getEdge(int i,btPoint3& pa,btPoint3& pb) const
+{
+	
+    switch (m_numVertices)
+	{
+
+	case 2: 
+		pa = m_vertices[0];
+		pb = m_vertices[1];
+		break;
+	case 3:  
+		switch (i)
+		{
+		case 0:
+			pa = m_vertices[0];
+			pb = m_vertices[1];
+			break;
+		case 1:
+			pa = m_vertices[1];
+			pb = m_vertices[2];
+			break;
+		case 2:
+			pa = m_vertices[2];
+			pb = m_vertices[0];
+			break;
+
+		}
+		break;
+	case 4: 
+		switch (i)
+		{
+		case 0:
+			pa = m_vertices[0];
+			pb = m_vertices[1];
+			break;
+		case 1:
+			pa = m_vertices[1];
+			pb = m_vertices[2];
+			break;
+		case 2:
+			pa = m_vertices[2];
+			pb = m_vertices[0];
+			break;
+		case 3:
+			pa = m_vertices[0];
+			pb = m_vertices[3];
+			break;
+		case 4:
+			pa = m_vertices[1];
+			pb = m_vertices[3];
+			break;
+		case 5:
+			pa = m_vertices[2];
+			pb = m_vertices[3];
+			break;
+		}
+
+	}
+
+
+
+
+}
+
+void btBU_Simplex1to4::getVertex(int i,btPoint3& vtx) const
+{
+	vtx = m_vertices[i];
+}
+
+int	btBU_Simplex1to4::getNumPlanes() const
+{
+	switch (m_numVertices)
+	{
+	case 0:
+			return 0;
+	case 1:
+			return 0;
+	case 2:
+			return 0;
+	case 3:
+			return 2;
+	case 4:
+			return 4;
+	default:
+		{
+		}
+	}
+	return 0;
+}
+
+
+void btBU_Simplex1to4::getPlane(btVector3&, btPoint3& ,int ) const
+{
+	
+}
+
+int btBU_Simplex1to4::getIndex(int ) const
+{
+	return 0;
+}
+
+bool btBU_Simplex1to4::isInside(const btPoint3& ,btScalar ) const
+{
+	return false;
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h	(revision 2122)
@@ -0,0 +1,74 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BU_SIMPLEX_1TO4_SHAPE
+#define BU_SIMPLEX_1TO4_SHAPE
+
+
+#include "btPolyhedralConvexShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+
+
+///The btBU_Simplex1to4 implements tetrahedron, triangle, line, vertex collision shapes. In most cases it is better to use btConvexHullShape instead.
+class btBU_Simplex1to4 : public btPolyhedralConvexShape
+{
+protected:
+
+	int	m_numVertices;
+	btPoint3	m_vertices[4];
+
+public:
+	btBU_Simplex1to4();
+
+	btBU_Simplex1to4(const btPoint3& pt0);
+	btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1);
+	btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2);
+	btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2,const btPoint3& pt3);
+
+    
+	void	reset()
+	{
+		m_numVertices = 0;
+	}
+	
+
+
+	void addVertex(const btPoint3& pt);
+
+	//PolyhedralConvexShape interface
+
+	virtual int	getNumVertices() const;
+
+	virtual int getNumEdges() const;
+
+	virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
+	
+	virtual void getVertex(int i,btPoint3& vtx) const;
+
+	virtual int	getNumPlanes() const;
+
+	virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i) const;
+
+	virtual int getIndex(int i) const;
+
+	virtual	bool isInside(const btPoint3& pt,btScalar tolerance) const;
+
+
+	///getName is for debugging
+	virtual const char*	getName()const { return "btBU_Simplex1to4";}
+
+};
+
+#endif //BU_SIMPLEX_1TO4_SHAPE
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.cpp	(revision 2122)
@@ -0,0 +1,35 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btTriangleBuffer.h"
+
+
+
+
+
+
+
+void btTriangleBuffer::processTriangle(btVector3* triangle,int partId,int  triangleIndex)
+{
+		btTriangle	tri;
+		tri.m_vertex0 = triangle[0];
+		tri.m_vertex1 = triangle[1];
+		tri.m_vertex2 = triangle[2];
+		tri.m_partId = partId;
+		tri.m_triangleIndex = triangleIndex;
+			
+		m_triangleBuffer.push_back(tri);
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_TRIANGLE_BUFFER_H
+#define BT_TRIANGLE_BUFFER_H
+
+#include "btTriangleCallback.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+struct	btTriangle
+{
+	btVector3	m_vertex0;
+	btVector3	m_vertex1;
+	btVector3	m_vertex2;
+	int	m_partId;
+	int	m_triangleIndex;
+};
+
+///btTriangleBuffer can be useful to collect and store overlapping triangles between AABB and concave objects that support 'processAllTriangles'
+///Example usage of this class:
+///			btTriangleBuffer	triBuf;
+///			concaveShape->processAllTriangles(&triBuf,aabbMin, aabbMax);
+///			for (int i=0;i<triBuf.getNumTriangles();i++)
+///			{
+///				const btTriangle& tri = triBuf.getTriangle(i);
+///				//do something useful here with the triangle
+///			}
+class btTriangleBuffer : public btTriangleCallback
+{
+
+	btAlignedObjectArray<btTriangle>	m_triangleBuffer;
+	
+public:
+
+
+	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
+	
+	int	getNumTriangles() const
+	{
+		return int(m_triangleBuffer.size());
+	}
+	
+	const btTriangle&	getTriangle(int index) const
+	{
+		return m_triangleBuffer[index];
+	}
+
+	void	clearBuffer()
+	{
+		m_triangleBuffer.clear();
+	}
+	
+};
+
+
+#endif //BT_TRIANGLE_BUFFER_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleCallback.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleCallback.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleCallback.cpp	(revision 2122)
@@ -0,0 +1,28 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btTriangleCallback.h"
+
+btTriangleCallback::~btTriangleCallback()
+{
+
+}
+
+
+btInternalTriangleIndexCallback::~btInternalTriangleIndexCallback()
+{
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef TRIANGLE_CALLBACK_H
+#define TRIANGLE_CALLBACK_H
+
+#include "LinearMath/btVector3.h"
+
+
+///The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTriangles.
+///This callback is called by processAllTriangles for all btConcaveShape derived class, such as  btBvhTriangleMeshShape, btStaticPlaneShape and btHeightfieldTerrainShape.
+class btTriangleCallback
+{
+public:
+
+	virtual ~btTriangleCallback();
+	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex) = 0;
+};
+
+class btInternalTriangleIndexCallback
+{
+public:
+
+	virtual ~btInternalTriangleIndexCallback();
+	virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int  triangleIndex) = 0;
+};
+
+
+
+#endif //TRIANGLE_CALLBACK_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp	(revision 2122)
@@ -0,0 +1,97 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btTriangleIndexVertexArray.h"
+
+btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride)
+: m_hasAabb(0)
+{
+	btIndexedMesh mesh;
+
+	mesh.m_numTriangles = numTriangles;
+	mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
+	mesh.m_triangleIndexStride = triangleIndexStride;
+	mesh.m_numVertices = numVertices;
+	mesh.m_vertexBase = (const unsigned char *)vertexBase;
+	mesh.m_vertexStride = vertexStride;
+
+	addIndexedMesh(mesh);
+
+}
+
+btTriangleIndexVertexArray::~btTriangleIndexVertexArray()
+{
+
+}
+
+void	btTriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
+{
+	btAssert(subpart< getNumSubParts() );
+
+	btIndexedMesh& mesh = m_indexedMeshes[subpart];
+
+	numverts = mesh.m_numVertices;
+	(*vertexbase) = (unsigned char *) mesh.m_vertexBase;
+	#ifdef BT_USE_DOUBLE_PRECISION
+	type = PHY_DOUBLE;
+	#else
+	type = PHY_FLOAT;
+	#endif
+	vertexStride = mesh.m_vertexStride;
+
+	numfaces = mesh.m_numTriangles;
+
+	(*indexbase) = (unsigned char *)mesh.m_triangleIndexBase;
+	indexstride = mesh.m_triangleIndexStride;
+	indicestype = mesh.m_indexType;
+}
+
+void	btTriangleIndexVertexArray::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const
+{
+	const btIndexedMesh& mesh = m_indexedMeshes[subpart];
+
+	numverts = mesh.m_numVertices;
+	(*vertexbase) = (const unsigned char *)mesh.m_vertexBase;
+	#ifdef BT_USE_DOUBLE_PRECISION
+	type = PHY_DOUBLE;
+	#else
+	type = PHY_FLOAT;
+	#endif
+	vertexStride = mesh.m_vertexStride;
+
+	numfaces = mesh.m_numTriangles;
+	(*indexbase) = (const unsigned char *)mesh.m_triangleIndexBase;
+	indexstride = mesh.m_triangleIndexStride;
+	indicestype = mesh.m_indexType;
+}
+
+bool	btTriangleIndexVertexArray::hasPremadeAabb() const
+{
+	return (m_hasAabb == 1);
+}
+
+void	btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax )
+{
+	m_aabbMin = aabbMin;
+	m_aabbMax = aabbMax;
+	m_hasAabb = 1; // this is intentionally an int see notes in header
+}
+
+void	btTriangleIndexVertexArray::getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const
+{
+	*aabbMin = m_aabbMin;
+	*aabbMax = m_aabbMax;
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h	(revision 2122)
@@ -0,0 +1,115 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
+#define BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
+
+#include "btStridingMeshInterface.h"
+#include "LinearMath/btAlignedObjectArray.h"
+#include "LinearMath/btScalar.h"
+
+
+///The btIndexedMesh indexes a single vertex and index array. Multiple btIndexedMesh objects can be passed into a btTriangleIndexVertexArray using addIndexedMesh.
+///Instead of the number of indices, we pass the number of triangles.
+ATTRIBUTE_ALIGNED16( struct)	btIndexedMesh
+{
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	int			m_numTriangles;
+	const unsigned char *		m_triangleIndexBase;
+	int			m_triangleIndexStride;
+	int			m_numVertices;
+	const unsigned char *		m_vertexBase;
+	int			m_vertexStride;
+	// The index type is set when adding an indexed mesh to the
+	// btTriangleIndexVertexArray, do not set it manually
+	PHY_ScalarType		m_indexType;
+	int			pad;
+}
+;
+
+
+typedef btAlignedObjectArray<btIndexedMesh>	IndexedMeshArray;
+
+///The btTriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing triangle/index arrays.
+///Additional meshes can be added using addIndexedMesh
+///No duplcate is made of the vertex/index data, it only indexes into external vertex/index arrays.
+///So keep those arrays around during the lifetime of this btTriangleIndexVertexArray.
+ATTRIBUTE_ALIGNED16( class) btTriangleIndexVertexArray : public btStridingMeshInterface
+{
+protected:
+	IndexedMeshArray	m_indexedMeshes;
+	int m_pad[2];
+	int m_hasAabb; // using int instead of bool to maintain alignment
+	btVector3 m_aabbMin;
+	btVector3 m_aabbMax;
+
+public:
+
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btTriangleIndexVertexArray() : m_hasAabb(0)
+	{
+	}
+
+	virtual ~btTriangleIndexVertexArray();
+
+	//just to be backwards compatible
+	btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride);
+	
+	void	addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
+	{
+		m_indexedMeshes.push_back(mesh);
+		m_indexedMeshes[m_indexedMeshes.size()-1].m_indexType = indexType;
+	}
+	
+	
+	virtual void	getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0);
+
+	virtual void	getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0) const;
+
+	/// unLockVertexBase finishes the access to a subpart of the triangle mesh
+	/// make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished
+	virtual void	unLockVertexBase(int subpart) {(void)subpart;}
+
+	virtual void	unLockReadOnlyVertexBase(int subpart) const {(void)subpart;}
+
+	/// getNumSubParts returns the number of seperate subparts
+	/// each subpart has a continuous array of vertices and indices
+	virtual int		getNumSubParts() const { 
+		return (int)m_indexedMeshes.size();
+	}
+
+	IndexedMeshArray&	getIndexedMeshArray()
+	{
+		return m_indexedMeshes;
+	}
+
+	const IndexedMeshArray&	getIndexedMeshArray() const
+	{
+		return m_indexedMeshes;
+	}
+
+	virtual void	preallocateVertices(int numverts){(void) numverts;}
+	virtual void	preallocateIndices(int numindices){(void) numindices;}
+
+	virtual bool	hasPremadeAabb() const;
+	virtual void	setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax );
+	virtual void	getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const;
+
+}
+;
+
+#endif //BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp	(revision 2122)
@@ -0,0 +1,86 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///This file was created by Alex Silverman
+
+#include "btTriangleIndexVertexMaterialArray.h"
+
+btTriangleIndexVertexMaterialArray::btTriangleIndexVertexMaterialArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,
+                                   int numVertices,btScalar* vertexBase,int vertexStride,
+                                   int numMaterials, unsigned char* materialBase, int materialStride,
+                                   int* triangleMaterialsBase, int materialIndexStride) :
+btTriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride)
+{
+    btMaterialProperties mat;
+
+    mat.m_numMaterials = numMaterials;
+    mat.m_materialBase = materialBase;
+    mat.m_materialStride = materialStride;
+#ifdef BT_USE_DOUBLE_PRECISION
+    mat.m_materialType = PHY_DOUBLE;
+#else
+    mat.m_materialType = PHY_FLOAT;
+#endif
+
+    mat.m_numTriangles = numTriangles;
+    mat.m_triangleMaterialsBase = (unsigned char *)triangleMaterialsBase;
+    mat.m_triangleMaterialStride = materialIndexStride;
+    mat.m_triangleType = PHY_INTEGER;
+
+    addMaterialProperties(mat);
+}
+
+
+void btTriangleIndexVertexMaterialArray::getLockedMaterialBase(unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride,
+                                   unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart)
+{
+    btAssert(subpart< getNumSubParts() );
+
+    btMaterialProperties& mats = m_materials[subpart];
+
+    numMaterials = mats.m_numMaterials;
+    (*materialBase) = (unsigned char *) mats.m_materialBase;
+#ifdef BT_USE_DOUBLE_PRECISION
+    materialType = PHY_DOUBLE;
+#else
+    materialType = PHY_FLOAT;
+#endif
+    materialStride = mats.m_materialStride;
+
+    numTriangles = mats.m_numTriangles;
+    (*triangleMaterialBase) = (unsigned char *)mats.m_triangleMaterialsBase;
+    triangleMaterialStride = mats.m_triangleMaterialStride;
+    triangleType = mats.m_triangleType;
+}
+
+void btTriangleIndexVertexMaterialArray::getLockedReadOnlyMaterialBase(const unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride,
+                                           const unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart)
+{
+    btMaterialProperties& mats = m_materials[subpart];
+
+    numMaterials = mats.m_numMaterials;
+    (*materialBase) = (const unsigned char *) mats.m_materialBase;
+#ifdef BT_USE_DOUBLE_PRECISION
+    materialType = PHY_DOUBLE;
+#else
+    materialType = PHY_FLOAT;
+#endif
+    materialStride = mats.m_materialStride;
+
+    numTriangles = mats.m_numTriangles;
+    (*triangleMaterialBase) = (const unsigned char *)mats.m_triangleMaterialsBase;
+    triangleMaterialStride = mats.m_triangleMaterialStride;
+    triangleType = mats.m_triangleType;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///This file was created by Alex Silverman
+
+#ifndef BT_MULTIMATERIAL_TRIANGLE_INDEX_VERTEX_ARRAY_H
+#define BT_MULTIMATERIAL_TRIANGLE_INDEX_VERTEX_ARRAY_H
+
+#include "btTriangleIndexVertexArray.h"
+
+
+ATTRIBUTE_ALIGNED16( struct)	btMaterialProperties
+{
+    ///m_materialBase ==========> 2 btScalar values make up one material, friction then restitution
+    int m_numMaterials;
+    const unsigned char * m_materialBase;
+    int m_materialStride;
+    PHY_ScalarType m_materialType;
+    ///m_numTriangles <=========== This exists in the btIndexedMesh object for the same subpart, but since we're
+    ///                           padding the structure, it can be reproduced at no real cost
+    ///m_triangleMaterials =====> 1 integer value makes up one entry
+    ///                           eg: m_triangleMaterials[1] = 5; // This will set triangle 2 to use material 5
+    int m_numTriangles; 
+    const unsigned char * m_triangleMaterialsBase;
+    int m_triangleMaterialStride;
+    ///m_triangleType <========== Automatically set in addMaterialProperties
+    PHY_ScalarType m_triangleType;
+};
+
+typedef btAlignedObjectArray<btMaterialProperties>	MaterialArray;
+
+///Teh btTriangleIndexVertexMaterialArray is built on TriangleIndexVertexArray
+///The addition of a material array allows for the utilization of the partID and
+///triangleIndex that are returned in the ContactAddedCallback.  As with
+///TriangleIndexVertexArray, no duplicate is made of the material data, so it
+///is the users responsibility to maintain the array during the lifetime of the
+///TriangleIndexVertexMaterialArray.
+ATTRIBUTE_ALIGNED16(class) btTriangleIndexVertexMaterialArray : public btTriangleIndexVertexArray
+{
+protected:
+    MaterialArray       m_materials;
+		
+public:
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+    btTriangleIndexVertexMaterialArray()
+	{
+	}
+
+    btTriangleIndexVertexMaterialArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,
+        int numVertices,btScalar* vertexBase,int vertexStride,
+        int numMaterials, unsigned char* materialBase, int materialStride,
+        int* triangleMaterialsBase, int materialIndexStride);
+
+    virtual ~btTriangleIndexVertexMaterialArray() {}
+
+    void	addMaterialProperties(const btMaterialProperties& mat, PHY_ScalarType triangleType = PHY_INTEGER)
+    {
+        m_materials.push_back(mat);
+        m_materials[m_materials.size()-1].m_triangleType = triangleType;
+    }
+
+    virtual void getLockedMaterialBase(unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride,
+        unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType ,int subpart = 0);
+
+    virtual void getLockedReadOnlyMaterialBase(const unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride,
+        const unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart = 0);
+
+}
+;
+
+#endif //BT_MULTIMATERIAL_TRIANGLE_INDEX_VERTEX_ARRAY_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp	(revision 2122)
@@ -0,0 +1,133 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btTriangleMesh.h"
+
+
+
+btTriangleMesh::btTriangleMesh (bool use32bitIndices,bool use4componentVertices)
+:m_use32bitIndices(use32bitIndices),
+m_use4componentVertices(use4componentVertices),
+m_weldingThreshold(0.0)
+{
+	btIndexedMesh meshIndex;
+	meshIndex.m_numTriangles = 0;
+	meshIndex.m_numVertices = 0;
+	meshIndex.m_indexType = PHY_INTEGER;
+	meshIndex.m_triangleIndexBase = 0;
+	meshIndex.m_triangleIndexStride = 3*sizeof(int);
+	meshIndex.m_vertexBase = 0;
+	meshIndex.m_vertexStride = sizeof(btVector3);
+	m_indexedMeshes.push_back(meshIndex);
+
+	if (m_use32bitIndices)
+	{
+		m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
+		m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
+		m_indexedMeshes[0].m_indexType = PHY_INTEGER;
+		m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
+	} else
+	{
+		m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
+		m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
+		m_indexedMeshes[0].m_indexType = PHY_SHORT;
+		m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
+	}
+
+	if (m_use4componentVertices)
+	{
+		m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
+		m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
+		m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
+	} else
+	{
+		m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
+		m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
+		m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
+	}
+
+
+}
+
+void	btTriangleMesh::addIndex(int index)
+{
+	if (m_use32bitIndices)
+	{
+		m_32bitIndices.push_back(index);
+		m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
+	} else
+	{
+		m_16bitIndices.push_back(index);
+		m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
+	}
+}
+
+int	btTriangleMesh::findOrAddVertex(const btVector3& vertex)
+{
+	//return index of new/existing vertex
+	//todo: could use acceleration structure for this
+	if (m_use4componentVertices)
+	{
+		for (int i=0;i< m_4componentVertices.size();i++)
+		{
+			if ((m_4componentVertices[i]-vertex).length2() <= m_weldingThreshold)
+			{
+				return i;
+			}
+		}
+		m_indexedMeshes[0].m_numVertices++;
+		m_4componentVertices.push_back(vertex);
+		m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
+
+		return m_4componentVertices.size()-1;
+		
+	} else
+	{
+		
+		for (int i=0;i< m_3componentVertices.size();i+=3)
+		{
+			btVector3 vtx(m_3componentVertices[i],m_3componentVertices[i+1],m_3componentVertices[i+2]);
+			if ((vtx-vertex).length2() <= m_weldingThreshold)
+			{
+				return i/3;
+			}
+		}
+		m_3componentVertices.push_back(vertex.getX());
+		m_3componentVertices.push_back(vertex.getY());
+		m_3componentVertices.push_back(vertex.getZ());
+		m_indexedMeshes[0].m_numVertices++;
+		m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
+		return (m_3componentVertices.size()/3)-1;
+	}
+
+}
+		
+void	btTriangleMesh::addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2)
+{
+	m_indexedMeshes[0].m_numTriangles++;
+		
+	addIndex(findOrAddVertex(vertex0));
+	addIndex(findOrAddVertex(vertex1));
+	addIndex(findOrAddVertex(vertex2));
+}
+
+int btTriangleMesh::getNumTriangles() const
+{
+	if (m_use32bitIndices)
+	{
+		return m_32bitIndices.size() / 3;
+	}
+	return m_16bitIndices.size() / 3;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef TRIANGLE_MESH_H
+#define TRIANGLE_MESH_H
+
+#include "btTriangleIndexVertexArray.h"
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+///The btTriangleMesh class is a convenience class derived from btTriangleIndexVertexArray, that provides storage for a concave triangle mesh. It can be used as data for the btBvhTriangleMeshShape.
+///It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices.
+///If you want to share triangle/index data between graphics mesh and collision mesh (btBvhTriangleMeshShape), you can directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface.
+///Performance of btTriangleMesh and btTriangleIndexVertexArray used in a btBvhTriangleMeshShape is the same.
+///It has a brute-force option to weld together closeby vertices.
+class btTriangleMesh : public btTriangleIndexVertexArray
+{
+	btAlignedObjectArray<btVector3>	m_4componentVertices;
+	btAlignedObjectArray<float>		m_3componentVertices;
+
+	btAlignedObjectArray<unsigned int>		m_32bitIndices;
+	btAlignedObjectArray<unsigned short int>		m_16bitIndices;
+	bool	m_use32bitIndices;
+	bool	m_use4componentVertices;
+	
+
+	public:
+		btScalar	m_weldingThreshold;
+
+		btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true);
+
+		int		findOrAddVertex(const btVector3& vertex);
+		void	addIndex(int index);
+
+		bool	getUse32bitIndices() const
+		{
+			return m_use32bitIndices;
+		}
+
+		bool	getUse4componentVertices() const
+		{
+			return m_use4componentVertices;
+		}
+		
+		void	addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2);
+		
+		int getNumTriangles() const;
+
+		virtual void	preallocateVertices(int numverts){(void) numverts;}
+		virtual void	preallocateIndices(int numindices){(void) numindices;}
+
+		
+};
+
+#endif //TRIANGLE_MESH_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp	(revision 2122)
@@ -0,0 +1,209 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btTriangleMeshShape.h"
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btQuaternion.h"
+#include "btStridingMeshInterface.h"
+#include "LinearMath/btAabbUtil2.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+
+btTriangleMeshShape::btTriangleMeshShape(btStridingMeshInterface* meshInterface)
+: btConcaveShape (), m_meshInterface(meshInterface)
+{
+	m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;
+	if(meshInterface->hasPremadeAabb())
+	{
+		meshInterface->getPremadeAabb(&m_localAabbMin, &m_localAabbMax);
+	}
+	else
+	{
+		recalcLocalAabb();
+	}
+}
+
+
+btTriangleMeshShape::~btTriangleMeshShape()
+{
+		
+}
+
+
+
+
+void btTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
+{
+
+	btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
+	localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
+	btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
+	
+	btMatrix3x3 abs_b = trans.getBasis().absolute();  
+
+	btPoint3 center = trans(localCenter);
+
+	btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
+		   abs_b[1].dot(localHalfExtents),
+		  abs_b[2].dot(localHalfExtents));
+	aabbMin = center - extent;
+	aabbMax = center + extent;
+
+
+}
+
+void	btTriangleMeshShape::recalcLocalAabb()
+{
+	for (int i=0;i<3;i++)
+	{
+		btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
+		vec[i] = btScalar(1.);
+		btVector3 tmp = localGetSupportingVertex(vec);
+		m_localAabbMax[i] = tmp[i]+m_collisionMargin;
+		vec[i] = btScalar(-1.);
+		tmp = localGetSupportingVertex(vec);
+		m_localAabbMin[i] = tmp[i]-m_collisionMargin;
+	}
+}
+
+
+
+class SupportVertexCallback : public btTriangleCallback
+{
+
+	btVector3 m_supportVertexLocal;
+public:
+
+	btTransform	m_worldTrans;
+	btScalar m_maxDot;
+	btVector3 m_supportVecLocal;
+
+	SupportVertexCallback(const btVector3& supportVecWorld,const btTransform& trans)
+		: m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)), m_worldTrans(trans) ,m_maxDot(btScalar(-1e30))
+		
+	{
+		m_supportVecLocal = supportVecWorld * m_worldTrans.getBasis();
+	}
+
+	virtual void processTriangle( btVector3* triangle,int partId, int triangleIndex)
+	{
+		(void)partId;
+		(void)triangleIndex;
+		for (int i=0;i<3;i++)
+		{
+			btScalar dot = m_supportVecLocal.dot(triangle[i]);
+			if (dot > m_maxDot)
+			{
+				m_maxDot = dot;
+				m_supportVertexLocal = triangle[i];
+			}
+		}
+	}
+
+	btVector3 GetSupportVertexWorldSpace()
+	{
+		return m_worldTrans(m_supportVertexLocal);
+	}
+
+	btVector3	GetSupportVertexLocal()
+	{
+		return m_supportVertexLocal;
+	}
+
+};
+
+	
+void btTriangleMeshShape::setLocalScaling(const btVector3& scaling)
+{
+	m_meshInterface->setScaling(scaling);
+	recalcLocalAabb();
+}
+
+const btVector3& btTriangleMeshShape::getLocalScaling() const
+{
+	return m_meshInterface->getScaling();
+}
+
+
+
+
+
+
+//#define DEBUG_TRIANGLE_MESH
+
+
+
+void	btTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+		struct FilteredCallback : public btInternalTriangleIndexCallback
+	{
+		btTriangleCallback* m_callback;
+		btVector3 m_aabbMin;
+		btVector3 m_aabbMax;
+
+		FilteredCallback(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax)
+			:m_callback(callback),
+			m_aabbMin(aabbMin),
+			m_aabbMax(aabbMax)
+		{
+		}
+
+		virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
+		{
+			if (TestTriangleAgainstAabb2(&triangle[0],m_aabbMin,m_aabbMax))
+			{
+				//check aabb in triangle-space, before doing this
+				m_callback->processTriangle(triangle,partId,triangleIndex);
+			}
+			
+		}
+
+	};
+
+	FilteredCallback filterCallback(callback,aabbMin,aabbMax);
+
+	m_meshInterface->InternalProcessAllTriangles(&filterCallback,aabbMin,aabbMax);
+}
+
+
+
+
+
+void	btTriangleMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	(void)mass;
+	//moving concave objects not supported
+	btAssert(0);
+	inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+}
+
+
+btVector3 btTriangleMeshShape::localGetSupportingVertex(const btVector3& vec) const
+{
+	btVector3 supportVertex;
+
+	btTransform ident;
+	ident.setIdentity();
+
+	SupportVertexCallback supportCallback(vec,ident);
+
+	btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+	
+	processAllTriangles(&supportCallback,-aabbMax,aabbMax);
+		
+	supportVertex = supportCallback.GetSupportVertexLocal();
+
+	return supportVertex;
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h	(revision 2122)
@@ -0,0 +1,85 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef TRIANGLE_MESH_SHAPE_H
+#define TRIANGLE_MESH_SHAPE_H
+
+#include "btConcaveShape.h"
+#include "btStridingMeshInterface.h"
+
+
+///The btTriangleMeshShape is an internal concave triangle mesh interface. Don't use this class directly, use btBvhTriangleMeshShape instead.
+class btTriangleMeshShape : public btConcaveShape
+{
+protected:
+	btVector3	m_localAabbMin;
+	btVector3	m_localAabbMax;
+	btStridingMeshInterface* m_meshInterface;
+
+	///btTriangleMeshShape constructor has been disabled/protected, so that users will not mistakenly use this class.
+	///Don't use btTriangleMeshShape but use btBvhTriangleMeshShape instead!
+	btTriangleMeshShape(btStridingMeshInterface* meshInterface);
+
+public:
+
+	virtual ~btTriangleMeshShape();
+
+	virtual btVector3 localGetSupportingVertex(const btVector3& vec) const;
+
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+	{
+		assert(0);
+		return localGetSupportingVertex(vec);
+	}
+
+	void	recalcLocalAabb();
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual void	setLocalScaling(const btVector3& scaling);
+	virtual const btVector3& getLocalScaling() const;
+	
+	btStridingMeshInterface* getMeshInterface()
+	{
+		return m_meshInterface;
+	}
+
+	const btStridingMeshInterface* getMeshInterface() const
+	{
+		return m_meshInterface;
+	}
+
+	const btVector3& getLocalAabbMin() const
+	{
+		return m_localAabbMin;
+	}
+	const btVector3& getLocalAabbMax() const
+	{
+		return m_localAabbMax;
+	}
+
+
+
+	//debugging
+	virtual const char*	getName()const {return "TRIANGLEMESH";}
+
+
+};
+
+#endif //TRIANGLE_MESH_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btTriangleShape.h	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef OBB_TRIANGLE_MINKOWSKI_H
+#define OBB_TRIANGLE_MINKOWSKI_H
+
+#include "btConvexShape.h"
+#include "btBoxShape.h"
+
+class btTriangleShape : public btPolyhedralConvexShape
+{
+
+
+public:
+
+	btVector3	m_vertices1[3];
+
+	virtual int getNumVertices() const
+	{
+		return 3;
+	}
+
+	const btVector3& getVertexPtr(int index) const
+	{
+		return m_vertices1[index];
+	}
+	virtual void getVertex(int index,btVector3& vert) const
+	{
+		vert = m_vertices1[index];
+	}
+
+	virtual int getNumEdges() const
+	{
+		return 3;
+	}
+	
+	virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const
+	{
+		getVertex(i,pa);
+		getVertex((i+1)%3,pb);
+	}
+
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const 
+	{
+//		btAssert(0);
+		getAabbSlow(t,aabbMin,aabbMax);
+	}
+
+	btVector3 localGetSupportingVertexWithoutMargin(const btVector3& dir)const 
+	{
+		btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2]));
+	  	return m_vertices1[dots.maxAxis()];
+
+	}
+
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+	{
+		for (int i=0;i<numVectors;i++)
+		{
+			const btVector3& dir = vectors[i];
+			btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2]));
+  			supportVerticesOut[i] = m_vertices1[dots.maxAxis()];
+		}
+
+	}
+
+
+
+	btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2) : btPolyhedralConvexShape ()
+    {
+		m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
+        m_vertices1[0] = p0;
+        m_vertices1[1] = p1;
+        m_vertices1[2] = p2;
+    }
+
+
+	virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i) const
+	{
+		getPlaneEquation(i,planeNormal,planeSupport);
+	}
+
+	virtual int	getNumPlanes() const
+	{
+		return 1;
+	}
+
+	void calcNormal(btVector3& normal) const
+	{
+		normal = (m_vertices1[1]-m_vertices1[0]).cross(m_vertices1[2]-m_vertices1[0]);
+		normal.normalize();
+	}
+
+	virtual void getPlaneEquation(int i, btVector3& planeNormal,btPoint3& planeSupport) const
+	{
+		(void)i;
+		calcNormal(planeNormal);
+		planeSupport = m_vertices1[0];
+	}
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const
+	{
+		(void)mass;
+		btAssert(0);
+		inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+	}
+
+		virtual	bool isInside(const btPoint3& pt,btScalar tolerance) const
+	{
+		btVector3 normal;
+		calcNormal(normal);
+		//distance to plane
+		btScalar dist = pt.dot(normal);
+		btScalar planeconst = m_vertices1[0].dot(normal);
+		dist -= planeconst;
+		if (dist >= -tolerance && dist <= tolerance)
+		{
+			//inside check on edge-planes
+			int i;
+			for (i=0;i<3;i++)
+			{
+				btPoint3 pa,pb;
+				getEdge(i,pa,pb);
+				btVector3 edge = pb-pa;
+				btVector3 edgeNormal = edge.cross(normal);
+				edgeNormal.normalize();
+				btScalar dist = pt.dot( edgeNormal);
+				btScalar edgeConst = pa.dot(edgeNormal);
+				dist -= edgeConst;
+				if (dist < -tolerance)
+					return false;
+			}
+			
+			return true;
+		}
+
+		return false;
+	}
+		//debugging
+		virtual const char*	getName()const
+		{
+			return "Triangle";
+		}
+
+		virtual int		getNumPreferredPenetrationDirections() const
+		{
+			return 2;
+		}
+		
+		virtual void	getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+		{
+			calcNormal(penetrationVector);
+			if (index)
+				penetrationVector *= btScalar(-1.);
+		}
+
+
+};
+
+#endif //OBB_TRIANGLE_MINKOWSKI_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp	(revision 2122)
@@ -0,0 +1,115 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btUniformScalingShape.h"
+
+btUniformScalingShape::btUniformScalingShape(	btConvexShape* convexChildShape,btScalar uniformScalingFactor):
+btConvexShape (), m_childConvexShape(convexChildShape),
+m_uniformScalingFactor(uniformScalingFactor)
+{
+	m_shapeType = UNIFORM_SCALING_SHAPE_PROXYTYPE;
+}
+	
+btUniformScalingShape::~btUniformScalingShape()
+{
+}
+	
+
+btVector3	btUniformScalingShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+{
+	btVector3 tmpVertex;
+	tmpVertex = m_childConvexShape->localGetSupportingVertexWithoutMargin(vec);
+	return tmpVertex*m_uniformScalingFactor;
+}
+
+void	btUniformScalingShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+	m_childConvexShape->batchedUnitVectorGetSupportingVertexWithoutMargin(vectors,supportVerticesOut,numVectors);
+	int i;
+	for (i=0;i<numVectors;i++)
+	{
+		supportVerticesOut[i] = supportVerticesOut[i] * m_uniformScalingFactor;
+	}
+}
+
+
+btVector3	btUniformScalingShape::localGetSupportingVertex(const btVector3& vec)const
+{
+	btVector3 tmpVertex;
+	tmpVertex = m_childConvexShape->localGetSupportingVertex(vec);
+	return tmpVertex*m_uniformScalingFactor;
+}
+
+
+void	btUniformScalingShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+
+	///this linear upscaling is not realistic, but we don't deal with large mass ratios...
+	btVector3 tmpInertia;
+	m_childConvexShape->calculateLocalInertia(mass,tmpInertia);
+	inertia = tmpInertia * m_uniformScalingFactor;
+}
+
+
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+void btUniformScalingShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	m_childConvexShape->getAabb(t,aabbMin,aabbMax);
+	btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5);
+	btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor;
+
+	aabbMin = aabbCenter - scaledAabbHalfExtends;
+	aabbMax = aabbCenter + scaledAabbHalfExtends;
+
+}
+
+void btUniformScalingShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+{
+	m_childConvexShape->getAabbSlow(t,aabbMin,aabbMax);
+	btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5);
+	btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor;
+
+	aabbMin = aabbCenter - scaledAabbHalfExtends;
+	aabbMax = aabbCenter + scaledAabbHalfExtends;
+}
+
+void	btUniformScalingShape::setLocalScaling(const btVector3& scaling) 
+{
+	m_childConvexShape->setLocalScaling(scaling);
+}
+
+const btVector3& btUniformScalingShape::getLocalScaling() const
+{
+	return m_childConvexShape->getLocalScaling();
+}
+
+void	btUniformScalingShape::setMargin(btScalar margin)
+{
+	m_childConvexShape->setMargin(margin);
+}
+btScalar	btUniformScalingShape::getMargin() const
+{
+	return m_childConvexShape->getMargin() * m_uniformScalingFactor;
+}
+
+int		btUniformScalingShape::getNumPreferredPenetrationDirections() const
+{
+	return m_childConvexShape->getNumPreferredPenetrationDirections();
+}
+	
+void	btUniformScalingShape::getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+{
+	m_childConvexShape->getPreferredPenetrationDirection(index,penetrationVector);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.h	(revision 2122)
@@ -0,0 +1,87 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_UNIFORM_SCALING_SHAPE_H
+#define BT_UNIFORM_SCALING_SHAPE_H
+
+#include "btConvexShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+
+///The btUniformScalingShape allows to re-use uniform scaled instances of btConvexShape in a memory efficient way.
+///Istead of using btUniformScalingShape, it is better to use the non-uniform setLocalScaling method on convex shapes that implement it.
+class btUniformScalingShape : public btConvexShape
+{
+	btConvexShape*	m_childConvexShape;
+
+	btScalar	m_uniformScalingFactor;
+	
+	public:
+	
+	btUniformScalingShape(	btConvexShape* convexChildShape, btScalar uniformScalingFactor);
+	
+	virtual ~btUniformScalingShape();
+	
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec)const;
+
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	btScalar	getUniformScalingFactor() const
+	{
+		return m_uniformScalingFactor;
+	}
+
+	btConvexShape*	getChildShape() 
+	{
+		return m_childConvexShape;
+	}
+
+	const btConvexShape*	getChildShape() const
+	{
+		return m_childConvexShape;
+	}
+
+	virtual const char*	getName()const 
+	{
+		return "UniformScalingShape";
+	}
+	
+
+
+	///////////////////////////
+
+
+	///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+	void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	virtual void getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
+
+	virtual void	setLocalScaling(const btVector3& scaling) ;
+	virtual const btVector3& getLocalScaling() const ;
+
+	virtual void	setMargin(btScalar margin);
+	virtual btScalar	getMargin() const;
+
+	virtual int		getNumPreferredPenetrationDirections() const;
+	
+	virtual void	getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const;
+
+
+};
+
+#endif //BT_UNIFORM_SCALING_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btBoxCollision.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btBoxCollision.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btBoxCollision.h	(revision 2122)
@@ -0,0 +1,651 @@
+#ifndef BT_BOX_COLLISION_H_INCLUDED
+#define BT_BOX_COLLISION_H_INCLUDED
+
+/*! \file gim_box_collision.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "LinearMath/btTransform.h"
+
+/*! \defgroup BOUND_AABB_OPERATIONS
+*/
+//! @{
+
+///Swap numbers
+#define BT_SWAP_NUMBERS(a,b){ \
+    a = a+b; \
+    b = a-b; \
+    a = a-b; \
+}\
+
+
+#define BT_MAX(a,b) (a<b?b:a)
+#define BT_MIN(a,b) (a>b?b:a)
+
+#define BT_GREATER(x, y)	fabsf(x) > (y)
+
+#define BT_MAX3(a,b,c) BT_MAX(a,BT_MAX(b,c))
+#define BT_MIN3(a,b,c) BT_MIN(a,BT_MIN(b,c))
+
+
+
+
+
+
+enum eBT_PLANE_INTERSECTION_TYPE
+{
+	BT_CONST_BACK_PLANE = 0,
+	BT_CONST_COLLIDE_PLANE,
+	BT_CONST_FRONT_PLANE
+};
+
+//SIMD_FORCE_INLINE bool test_cross_edge_box(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, const btVector3 & extend,
+//	int dir_index0,
+//	int dir_index1
+//	int component_index0,
+//	int component_index1)
+//{
+//	// dir coords are -z and y
+//
+//	const btScalar dir0 = -edge[dir_index0];
+//	const btScalar dir1 = edge[dir_index1];
+//	btScalar pmin = pointa[component_index0]*dir0 + pointa[component_index1]*dir1;
+//	btScalar pmax = pointb[component_index0]*dir0 + pointb[component_index1]*dir1;
+//	//find minmax
+//	if(pmin>pmax)
+//	{
+//		BT_SWAP_NUMBERS(pmin,pmax);
+//	}
+//	//find extends
+//	const btScalar rad = extend[component_index0] * absolute_edge[dir_index0] +
+//					extend[component_index1] * absolute_edge[dir_index1];
+//
+//	if(pmin>rad || -rad>pmax) return false;
+//	return true;
+//}
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_X_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,2,1,1,2);
+//}
+//
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_Y_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,0,2,2,0);
+//}
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_Z_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,1,0,0,1);
+//}
+
+
+#define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\
+{\
+	const btScalar dir0 = -edge[i_dir_0];\
+	const btScalar dir1 = edge[i_dir_1];\
+	btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\
+	btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\
+	if(pmin>pmax)\
+	{\
+		BT_SWAP_NUMBERS(pmin,pmax); \
+	}\
+	const btScalar abs_dir0 = absolute_edge[i_dir_0];\
+	const btScalar abs_dir1 = absolute_edge[i_dir_1];\
+	const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\
+	if(pmin>rad || -rad>pmax) return false;\
+}\
+
+
+#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\
+}\
+
+#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\
+}\
+
+#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\
+}\
+
+
+//! Returns the dot product between a vec3f and the col of a matrix
+SIMD_FORCE_INLINE btScalar bt_mat3_dot_col(
+const btMatrix3x3 & mat, const btVector3 & vec3, int colindex)
+{
+	return vec3[0]*mat[0][colindex] + vec3[1]*mat[1][colindex] + vec3[2]*mat[2][colindex];
+}
+
+
+//!  Class for transforming a model1 to the space of model0
+ATTRIBUTE_ALIGNED16	(class) BT_BOX_BOX_TRANSFORM_CACHE
+{
+public:
+    btVector3  m_T1to0;//!< Transforms translation of model1 to model 0
+	btMatrix3x3 m_R1to0;//!< Transforms Rotation of model1 to model 0, equal  to R0' * R1
+	btMatrix3x3 m_AR;//!< Absolute value of m_R1to0
+
+	SIMD_FORCE_INLINE void calc_absolute_matrix()
+	{
+//		static const btVector3 vepsi(1e-6f,1e-6f,1e-6f);
+//		m_AR[0] = vepsi + m_R1to0[0].absolute();
+//		m_AR[1] = vepsi + m_R1to0[1].absolute();
+//		m_AR[2] = vepsi + m_R1to0[2].absolute();
+
+		int i,j;
+
+        for(i=0;i<3;i++)
+        {
+            for(j=0;j<3;j++ )
+            {
+            	m_AR[i][j] = 1e-6f + fabsf(m_R1to0[i][j]);
+            }
+        }
+
+	}
+
+	BT_BOX_BOX_TRANSFORM_CACHE()
+	{
+	}
+
+
+
+	//! Calc the transformation relative  1 to 0. Inverts matrics by transposing
+	SIMD_FORCE_INLINE void calc_from_homogenic(const btTransform & trans0,const btTransform & trans1)
+	{
+
+		btTransform temp_trans = trans0.inverse();
+		temp_trans = temp_trans * trans1;
+
+		m_T1to0 = temp_trans.getOrigin();
+		m_R1to0 = temp_trans.getBasis();
+
+
+		calc_absolute_matrix();
+	}
+
+	//! Calcs the full invertion of the matrices. Useful for scaling matrices
+	SIMD_FORCE_INLINE void calc_from_full_invert(const btTransform & trans0,const btTransform & trans1)
+	{
+		m_R1to0 = trans0.getBasis().inverse();
+		m_T1to0 = m_R1to0 * (-trans0.getOrigin());
+
+		m_T1to0 += m_R1to0*trans1.getOrigin();
+		m_R1to0 *= trans1.getBasis();
+
+		calc_absolute_matrix();
+	}
+
+	SIMD_FORCE_INLINE btVector3 transform(const btVector3 & point) const
+	{
+		return btVector3(m_R1to0[0].dot(point) + m_T1to0.x(),
+			m_R1to0[1].dot(point) + m_T1to0.y(),
+			m_R1to0[2].dot(point) + m_T1to0.z());
+	}
+};
+
+
+#define BOX_PLANE_EPSILON 0.000001f
+
+//! Axis aligned box
+ATTRIBUTE_ALIGNED16	(class) btAABB
+{
+public:
+	btVector3 m_min;
+	btVector3 m_max;
+
+	btAABB()
+	{}
+
+
+	btAABB(const btVector3 & V1,
+			 const btVector3 & V2,
+			 const btVector3 & V3)
+	{
+		m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]);
+	}
+
+	btAABB(const btVector3 & V1,
+			 const btVector3 & V2,
+			 const btVector3 & V3,
+			 btScalar margin)
+	{
+		m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]);
+
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	btAABB(const btAABB &other):
+		m_min(other.m_min),m_max(other.m_max)
+	{
+	}
+
+	btAABB(const btAABB &other,btScalar margin ):
+		m_min(other.m_min),m_max(other.m_max)
+	{
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	SIMD_FORCE_INLINE void invalidate()
+	{
+		m_min[0] = SIMD_INFINITY;
+		m_min[1] = SIMD_INFINITY;
+		m_min[2] = SIMD_INFINITY;
+		m_max[0] = -SIMD_INFINITY;
+		m_max[1] = -SIMD_INFINITY;
+		m_max[2] = -SIMD_INFINITY;
+	}
+
+	SIMD_FORCE_INLINE void increment_margin(btScalar margin)
+	{
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	SIMD_FORCE_INLINE void copy_with_margin(const btAABB &other, btScalar margin)
+	{
+		m_min[0] = other.m_min[0] - margin;
+		m_min[1] = other.m_min[1] - margin;
+		m_min[2] = other.m_min[2] - margin;
+
+		m_max[0] = other.m_max[0] + margin;
+		m_max[1] = other.m_max[1] + margin;
+		m_max[2] = other.m_max[2] + margin;
+	}
+
+	template<typename CLASS_POINT>
+	SIMD_FORCE_INLINE void calc_from_triangle(
+							const CLASS_POINT & V1,
+							const CLASS_POINT & V2,
+							const CLASS_POINT & V3)
+	{
+		m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]);
+	}
+
+	template<typename CLASS_POINT>
+	SIMD_FORCE_INLINE void calc_from_triangle_margin(
+							const CLASS_POINT & V1,
+							const CLASS_POINT & V2,
+							const CLASS_POINT & V3, btScalar margin)
+	{
+		m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]);
+
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	//! Apply a transform to an AABB
+	SIMD_FORCE_INLINE void appy_transform(const btTransform & trans)
+	{
+		btVector3 center = (m_max+m_min)*0.5f;
+		btVector3 extends = m_max - center;
+		// Compute new center
+		center = trans(center);
+
+		btVector3 textends(extends.dot(trans.getBasis().getRow(0).absolute()),
+ 				 extends.dot(trans.getBasis().getRow(1).absolute()),
+				 extends.dot(trans.getBasis().getRow(2).absolute()));
+
+		m_min = center - textends;
+		m_max = center + textends;
+	}
+
+
+	//! Apply a transform to an AABB
+	SIMD_FORCE_INLINE void appy_transform_trans_cache(const BT_BOX_BOX_TRANSFORM_CACHE & trans)
+	{
+		btVector3 center = (m_max+m_min)*0.5f;
+		btVector3 extends = m_max - center;
+		// Compute new center
+		center = trans.transform(center);
+
+		btVector3 textends(extends.dot(trans.m_R1to0.getRow(0).absolute()),
+ 				 extends.dot(trans.m_R1to0.getRow(1).absolute()),
+				 extends.dot(trans.m_R1to0.getRow(2).absolute()));
+
+		m_min = center - textends;
+		m_max = center + textends;
+	}
+
+	//! Merges a Box
+	SIMD_FORCE_INLINE void merge(const btAABB & box)
+	{
+		m_min[0] = BT_MIN(m_min[0],box.m_min[0]);
+		m_min[1] = BT_MIN(m_min[1],box.m_min[1]);
+		m_min[2] = BT_MIN(m_min[2],box.m_min[2]);
+
+		m_max[0] = BT_MAX(m_max[0],box.m_max[0]);
+		m_max[1] = BT_MAX(m_max[1],box.m_max[1]);
+		m_max[2] = BT_MAX(m_max[2],box.m_max[2]);
+	}
+
+	//! Merges a point
+	template<typename CLASS_POINT>
+	SIMD_FORCE_INLINE void merge_point(const CLASS_POINT & point)
+	{
+		m_min[0] = BT_MIN(m_min[0],point[0]);
+		m_min[1] = BT_MIN(m_min[1],point[1]);
+		m_min[2] = BT_MIN(m_min[2],point[2]);
+
+		m_max[0] = BT_MAX(m_max[0],point[0]);
+		m_max[1] = BT_MAX(m_max[1],point[1]);
+		m_max[2] = BT_MAX(m_max[2],point[2]);
+	}
+
+	//! Gets the extend and center
+	SIMD_FORCE_INLINE void get_center_extend(btVector3 & center,btVector3 & extend)  const
+	{
+		center = (m_max+m_min)*0.5f;
+		extend = m_max - center;
+	}
+
+	//! Finds the intersecting box between this box and the other.
+	SIMD_FORCE_INLINE void find_intersection(const btAABB & other, btAABB & intersection)  const
+	{
+		intersection.m_min[0] = BT_MAX(other.m_min[0],m_min[0]);
+		intersection.m_min[1] = BT_MAX(other.m_min[1],m_min[1]);
+		intersection.m_min[2] = BT_MAX(other.m_min[2],m_min[2]);
+
+		intersection.m_max[0] = BT_MIN(other.m_max[0],m_max[0]);
+		intersection.m_max[1] = BT_MIN(other.m_max[1],m_max[1]);
+		intersection.m_max[2] = BT_MIN(other.m_max[2],m_max[2]);
+	}
+
+
+	SIMD_FORCE_INLINE bool has_collision(const btAABB & other) const
+	{
+		if(m_min[0] > other.m_max[0] ||
+		   m_max[0] < other.m_min[0] ||
+		   m_min[1] > other.m_max[1] ||
+		   m_max[1] < other.m_min[1] ||
+		   m_min[2] > other.m_max[2] ||
+		   m_max[2] < other.m_min[2])
+		{
+			return false;
+		}
+		return true;
+	}
+
+	/*! \brief Finds the Ray intersection parameter.
+	\param aabb Aligned box
+	\param vorigin A vec3f with the origin of the ray
+	\param vdir A vec3f with the direction of the ray
+	*/
+	SIMD_FORCE_INLINE bool collide_ray(const btVector3 & vorigin,const btVector3 & vdir)  const
+	{
+		btVector3 extents,center;
+		this->get_center_extend(center,extents);;
+
+		btScalar Dx = vorigin[0] - center[0];
+		if(BT_GREATER(Dx, extents[0]) && Dx*vdir[0]>=0.0f)	return false;
+		btScalar Dy = vorigin[1] - center[1];
+		if(BT_GREATER(Dy, extents[1]) && Dy*vdir[1]>=0.0f)	return false;
+		btScalar Dz = vorigin[2] - center[2];
+		if(BT_GREATER(Dz, extents[2]) && Dz*vdir[2]>=0.0f)	return false;
+
+
+		btScalar f = vdir[1] * Dz - vdir[2] * Dy;
+		if(btFabs(f) > extents[1]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[1])) return false;
+		f = vdir[2] * Dx - vdir[0] * Dz;
+		if(btFabs(f) > extents[0]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[0]))return false;
+		f = vdir[0] * Dy - vdir[1] * Dx;
+		if(btFabs(f) > extents[0]*btFabs(vdir[1]) + extents[1]*btFabs(vdir[0]))return false;
+		return true;
+	}
+
+
+	SIMD_FORCE_INLINE void projection_interval(const btVector3 & direction, btScalar &vmin, btScalar &vmax) const
+	{
+		btVector3 center = (m_max+m_min)*0.5f;
+		btVector3 extend = m_max-center;
+
+		btScalar _fOrigin =  direction.dot(center);
+		btScalar _fMaximumExtent = extend.dot(direction.absolute());
+		vmin = _fOrigin - _fMaximumExtent;
+		vmax = _fOrigin + _fMaximumExtent;
+	}
+
+	SIMD_FORCE_INLINE eBT_PLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
+	{
+		btScalar _fmin,_fmax;
+		this->projection_interval(plane,_fmin,_fmax);
+
+		if(plane[3] > _fmax + BOX_PLANE_EPSILON)
+		{
+			return BT_CONST_BACK_PLANE; // 0
+		}
+
+		if(plane[3]+BOX_PLANE_EPSILON >=_fmin)
+		{
+			return BT_CONST_COLLIDE_PLANE; //1
+		}
+		return BT_CONST_FRONT_PLANE;//2
+	}
+
+	SIMD_FORCE_INLINE bool overlapping_trans_conservative(const btAABB & box, btTransform & trans1_to_0) const
+	{
+		btAABB tbox = box;
+		tbox.appy_transform(trans1_to_0);
+		return has_collision(tbox);
+	}
+
+	SIMD_FORCE_INLINE bool overlapping_trans_conservative2(const btAABB & box,
+		const BT_BOX_BOX_TRANSFORM_CACHE & trans1_to_0) const
+	{
+		btAABB tbox = box;
+		tbox.appy_transform_trans_cache(trans1_to_0);
+		return has_collision(tbox);
+	}
+
+	//! transcache is the transformation cache from box to this AABB
+	SIMD_FORCE_INLINE bool overlapping_trans_cache(
+		const btAABB & box,const BT_BOX_BOX_TRANSFORM_CACHE & transcache, bool fulltest) const
+	{
+
+		//Taken from OPCODE
+		btVector3 ea,eb;//extends
+		btVector3 ca,cb;//extends
+		get_center_extend(ca,ea);
+		box.get_center_extend(cb,eb);
+
+
+		btVector3 T;
+		btScalar t,t2;
+		int i;
+
+		// Class I : A's basis vectors
+		for(i=0;i<3;i++)
+		{
+			T[i] =  transcache.m_R1to0[i].dot(cb) + transcache.m_T1to0[i] - ca[i];
+			t = transcache.m_AR[i].dot(eb) + ea[i];
+			if(BT_GREATER(T[i], t))	return false;
+		}
+		// Class II : B's basis vectors
+		for(i=0;i<3;i++)
+		{
+			t = bt_mat3_dot_col(transcache.m_R1to0,T,i);
+			t2 = bt_mat3_dot_col(transcache.m_AR,ea,i) + eb[i];
+			if(BT_GREATER(t,t2))	return false;
+		}
+		// Class III : 9 cross products
+		if(fulltest)
+		{
+			int j,m,n,o,p,q,r;
+			for(i=0;i<3;i++)
+			{
+				m = (i+1)%3;
+				n = (i+2)%3;
+				o = i==0?1:0;
+				p = i==2?1:2;
+				for(j=0;j<3;j++)
+				{
+					q = j==2?1:2;
+					r = j==0?1:0;
+					t = T[n]*transcache.m_R1to0[m][j] - T[m]*transcache.m_R1to0[n][j];
+					t2 = ea[o]*transcache.m_AR[p][j] + ea[p]*transcache.m_AR[o][j] +
+						eb[r]*transcache.m_AR[i][q] + eb[q]*transcache.m_AR[i][r];
+					if(BT_GREATER(t,t2))	return false;
+				}
+			}
+		}
+		return true;
+	}
+
+	//! Simple test for planes.
+	SIMD_FORCE_INLINE bool collide_plane(
+		const btVector4 & plane) const
+	{
+		eBT_PLANE_INTERSECTION_TYPE classify = plane_classify(plane);
+		return (classify == BT_CONST_COLLIDE_PLANE);
+	}
+
+	//! test for a triangle, with edges
+	SIMD_FORCE_INLINE bool collide_triangle_exact(
+		const btVector3 & p1,
+		const btVector3 & p2,
+		const btVector3 & p3,
+		const btVector4 & triangle_plane) const
+	{
+		if(!collide_plane(triangle_plane)) return false;
+
+		btVector3 center,extends;
+		this->get_center_extend(center,extends);
+
+		const btVector3 v1(p1 - center);
+		const btVector3 v2(p2 - center);
+		const btVector3 v3(p3 - center);
+
+		//First axis
+		btVector3 diff(v2 - v1);
+		btVector3 abs_diff = diff.absolute();
+		//Test With X axis
+		TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v1,v3,extends);
+		//Test With Y axis
+		TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v1,v3,extends);
+		//Test With Z axis
+		TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v1,v3,extends);
+
+
+		diff = v3 - v2;
+		abs_diff = diff.absolute();
+		//Test With X axis
+		TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v2,v1,extends);
+		//Test With Y axis
+		TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v2,v1,extends);
+		//Test With Z axis
+		TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v2,v1,extends);
+
+		diff = v1 - v3;
+		abs_diff = diff.absolute();
+		//Test With X axis
+		TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v3,v2,extends);
+		//Test With Y axis
+		TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v3,v2,extends);
+		//Test With Z axis
+		TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v3,v2,extends);
+
+		return true;
+	}
+};
+
+
+//! Compairison of transformation objects
+SIMD_FORCE_INLINE bool btCompareTransformsEqual(const btTransform & t1,const btTransform & t2)
+{
+	if(!(t1.getOrigin() == t2.getOrigin()) ) return false;
+
+	if(!(t1.getBasis().getRow(0) == t2.getBasis().getRow(0)) ) return false;
+	if(!(t1.getBasis().getRow(1) == t2.getBasis().getRow(1)) ) return false;
+	if(!(t1.getBasis().getRow(2) == t2.getBasis().getRow(2)) ) return false;
+	return true;
+}
+
+
+//! @}
+
+#endif // GIM_BOX_COLLISION_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btClipPolygon.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btClipPolygon.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btClipPolygon.h	(revision 2122)
@@ -0,0 +1,186 @@
+#ifndef BT_CLIP_POLYGON_H_INCLUDED
+#define BT_CLIP_POLYGON_H_INCLUDED
+
+/*! \file btClipPolygon.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btGeometryUtil.h"
+
+/*! \addtogroup GEOMETRIC_OPERATIONS
+*/
+//! @{
+
+SIMD_FORCE_INLINE btScalar bt_distance_point_plane(const btVector4 & plane,const btVector3 &point)
+{
+	return point.dot(plane) - plane[3];
+}
+
+/*! Vector blending
+Takes two vectors a, b, blends them together*/
+SIMD_FORCE_INLINE void bt_vec_blend(btVector3 &vr, const btVector3 &va,const btVector3 &vb, btScalar blend_factor)
+{
+	vr = (1-blend_factor)*va + blend_factor*vb;
+}
+
+//! This function calcs the distance from a 3D plane
+SIMD_FORCE_INLINE void bt_plane_clip_polygon_collect(
+						const btVector3 & point0,
+						const btVector3 & point1,
+						btScalar dist0,
+						btScalar dist1,
+						btVector3 * clipped,
+						int & clipped_count)
+{
+	bool _prevclassif = (dist0>SIMD_EPSILON);
+	bool _classif = (dist1>SIMD_EPSILON);
+	if(_classif!=_prevclassif)
+	{
+		btScalar blendfactor = -dist0/(dist1-dist0);
+		bt_vec_blend(clipped[clipped_count],point0,point1,blendfactor);
+		clipped_count++;
+	}
+	if(!_classif)
+	{
+		clipped[clipped_count] = point1;
+		clipped_count++;
+	}
+}
+
+
+//! Clips a polygon by a plane
+/*!
+*\return The count of the clipped counts
+*/
+SIMD_FORCE_INLINE int bt_plane_clip_polygon(
+						const btVector4 & plane,
+						const btVector3 * polygon_points,
+						int polygon_point_count,
+						btVector3 * clipped)
+{
+    int clipped_count = 0;
+
+
+    //clip first point
+	btScalar firstdist = bt_distance_point_plane(plane,polygon_points[0]);;
+	if(!(firstdist>SIMD_EPSILON))
+	{
+		clipped[clipped_count] = polygon_points[0];
+		clipped_count++;
+	}
+
+	btScalar olddist = firstdist;
+	for(int i=1;i<polygon_point_count;i++)
+	{
+		btScalar dist = bt_distance_point_plane(plane,polygon_points[i]);
+
+		bt_plane_clip_polygon_collect(
+						polygon_points[i-1],polygon_points[i],
+						olddist,
+						dist,
+						clipped,
+						clipped_count);
+
+
+		olddist = dist;
+	}
+
+	//RETURN TO FIRST  point
+
+	bt_plane_clip_polygon_collect(
+					polygon_points[polygon_point_count-1],polygon_points[0],
+					olddist,
+					firstdist,
+					clipped,
+					clipped_count);
+
+	return clipped_count;
+}
+
+//! Clips a polygon by a plane
+/*!
+*\param clipped must be an array of 16 points.
+*\return The count of the clipped counts
+*/
+SIMD_FORCE_INLINE int bt_plane_clip_triangle(
+						const btVector4 & plane,
+						const btVector3 & point0,
+						const btVector3 & point1,
+						const btVector3& point2,
+						btVector3 * clipped // an allocated array of 16 points at least
+						)
+{
+    int clipped_count = 0;
+
+    //clip first point0
+	btScalar firstdist = bt_distance_point_plane(plane,point0);;
+	if(!(firstdist>SIMD_EPSILON))
+	{
+		clipped[clipped_count] = point0;
+		clipped_count++;
+	}
+
+	// point 1
+	btScalar olddist = firstdist;
+	btScalar dist = bt_distance_point_plane(plane,point1);
+
+	bt_plane_clip_polygon_collect(
+					point0,point1,
+					olddist,
+					dist,
+					clipped,
+					clipped_count);
+
+	olddist = dist;
+
+
+	// point 2
+	dist = bt_distance_point_plane(plane,point2);
+
+	bt_plane_clip_polygon_collect(
+					point1,point2,
+					olddist,
+					dist,
+					clipped,
+					clipped_count);
+	olddist = dist;
+
+
+
+	//RETURN TO FIRST  point0
+	bt_plane_clip_polygon_collect(
+					point2,point0,
+					olddist,
+					firstdist,
+					clipped,
+					clipped_count);
+
+	return clipped_count;
+}
+
+
+
+
+//! @}
+
+#endif // GIM_TRI_COLLISION_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btContactProcessing.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btContactProcessing.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btContactProcessing.cpp	(revision 2122)
@@ -0,0 +1,181 @@
+
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btContactProcessing.h"
+
+#define MAX_COINCIDENT 8
+
+struct CONTACT_KEY_TOKEN
+{
+	unsigned int m_key;
+	int m_value;
+	CONTACT_KEY_TOKEN()
+    {
+    }
+
+    CONTACT_KEY_TOKEN(unsigned int key,int token)
+    {
+    	m_key = key;
+    	m_value =  token;
+    }
+
+    CONTACT_KEY_TOKEN(const CONTACT_KEY_TOKEN& rtoken)
+    {
+    	m_key = rtoken.m_key;
+    	m_value = rtoken.m_value;
+    }
+
+    inline bool operator <(const CONTACT_KEY_TOKEN& other) const
+	{
+		return (m_key < other.m_key);
+	}
+
+	inline bool operator >(const CONTACT_KEY_TOKEN& other) const
+	{
+		return (m_key > other.m_key);
+	}
+
+};
+
+class CONTACT_KEY_TOKEN_COMP
+{
+	public:
+
+		bool operator() ( const CONTACT_KEY_TOKEN& a, const CONTACT_KEY_TOKEN& b )
+		{
+			return ( a < b );
+		}
+};
+
+
+void btContactArray::merge_contacts(
+	const btContactArray & contacts, bool normal_contact_average)
+{
+	clear();
+
+	int i;
+	if(contacts.size()==0) return;
+
+
+	if(contacts.size()==1)
+	{
+		push_back(contacts[0]);
+		return;
+	}
+
+	btAlignedObjectArray<CONTACT_KEY_TOKEN> keycontacts;
+
+	keycontacts.reserve(contacts.size());
+
+	//fill key contacts
+
+	for ( i = 0;i<contacts.size() ;i++ )
+	{
+		keycontacts.push_back(CONTACT_KEY_TOKEN(contacts[i].calc_key_contact(),i));
+	}
+
+	//sort keys
+	keycontacts.quickSort(CONTACT_KEY_TOKEN_COMP());
+
+	// Merge contacts
+	int coincident_count=0;
+	btVector3 coincident_normals[MAX_COINCIDENT];
+
+	unsigned int last_key = keycontacts[0].m_key;
+	unsigned int key = 0;
+
+	push_back(contacts[keycontacts[0].m_value]);
+
+	BT_CONTACT * pcontact = &(*this)[0];
+
+	for( i=1;i<keycontacts.size();i++)
+	{
+	    key = keycontacts[i].m_key;
+		const BT_CONTACT * scontact = &contacts[keycontacts[i].m_value];
+
+		if(last_key ==  key)//same points
+		{
+			//merge contact
+			if(pcontact->m_depth - CONTACT_DIFF_EPSILON > scontact->m_depth)//)
+			{
+				*pcontact = *scontact;
+                coincident_count = 0;
+			}
+			else if(normal_contact_average)
+			{
+				if(btFabs(pcontact->m_depth - scontact->m_depth)<CONTACT_DIFF_EPSILON)
+                {
+                    if(coincident_count<MAX_COINCIDENT)
+                    {
+                    	coincident_normals[coincident_count] = scontact->m_normal;
+                        coincident_count++;
+                    }
+                }
+			}
+		}
+		else
+		{//add new contact
+
+		    if(normal_contact_average && coincident_count>0)
+		    {
+		    	pcontact->interpolate_normals(coincident_normals,coincident_count);
+		        coincident_count = 0;
+		    }
+
+		    push_back(*scontact);
+		    pcontact = &(*this)[this->size()-1];
+        }
+		last_key = key;
+	}
+}
+
+void btContactArray::merge_contacts_unique(const btContactArray & contacts)
+{
+	clear();
+
+	if(contacts.size()==0) return;
+
+	if(contacts.size()==1)
+	{
+		push_back(contacts[0]);
+		return;
+	}
+
+	BT_CONTACT average_contact = contacts[0];
+
+	for (int i=1;i<contacts.size() ;i++ )
+	{
+		average_contact.m_point += contacts[i].m_point;
+		average_contact.m_normal += contacts[i].m_normal * contacts[i].m_depth;
+	}
+
+	//divide
+	btScalar divide_average = 1.0f/((btScalar)contacts.size());
+
+	average_contact.m_point *= divide_average;
+
+	average_contact.m_normal *= divide_average;
+
+	average_contact.m_depth = average_contact.m_normal.length();
+
+	average_contact.m_normal /= average_contact.m_depth;
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btContactProcessing.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btContactProcessing.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btContactProcessing.h	(revision 2122)
@@ -0,0 +1,149 @@
+#ifndef BT_CONTACT_H_INCLUDED
+#define BT_CONTACT_H_INCLUDED
+
+/*! \file gim_contact.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btAlignedObjectArray.h"
+#include "btTriangleShapeEx.h"
+
+
+/*! \defgroup CONTACTS
+\brief
+Functions for managing and sorting contacts resulting from a collision query.
+*/
+//! @{
+
+/**
+Configuration var for applying interpolation of  contact normals
+*/
+#define NORMAL_CONTACT_AVERAGE 1
+
+#define CONTACT_DIFF_EPSILON 0.00001f
+
+/// Structure for collision results
+class BT_CONTACT
+{
+public:
+    btVector3 m_point;
+    btVector3 m_normal;
+    btScalar m_depth;//Positive value indicates interpenetration
+    btScalar m_distance;//Padding not for use
+    int m_feature1;//Face number
+    int m_feature2;//Face number
+public:
+    BT_CONTACT()
+    {
+    }
+
+    BT_CONTACT(const BT_CONTACT & contact):
+				m_point(contact.m_point),
+				m_normal(contact.m_normal),
+				m_depth(contact.m_depth),
+				m_feature1(contact.m_feature1),
+				m_feature2(contact.m_feature2)
+    {
+    }
+
+    BT_CONTACT(const btVector3 &point,const btVector3 & normal,
+    	 			btScalar depth, int feature1, int feature2):
+				m_point(point),
+				m_normal(normal),
+				m_depth(depth),
+				m_feature1(feature1),
+				m_feature2(feature2)
+    {
+    }
+
+	//! Calcs key for coord classification
+    SIMD_FORCE_INLINE unsigned int calc_key_contact() const
+    {
+    	int _coords[] = {
+    		(int)(m_point[0]*1000.0f+1.0f),
+    		(int)(m_point[1]*1333.0f),
+    		(int)(m_point[2]*2133.0f+3.0f)};
+		unsigned int _hash=0;
+		unsigned int *_uitmp = (unsigned int *)(&_coords[0]);
+		_hash = *_uitmp;
+		_uitmp++;
+		_hash += (*_uitmp)<<4;
+		_uitmp++;
+		_hash += (*_uitmp)<<8;
+		return _hash;
+    }
+
+    SIMD_FORCE_INLINE void interpolate_normals( btVector3 * normals,int normal_count)
+    {
+    	btVector3 vec_sum(m_normal);
+		for(int i=0;i<normal_count;i++)
+		{
+			vec_sum += normals[i];
+		}
+
+		btScalar vec_sum_len = vec_sum.length2();
+		if(vec_sum_len <CONTACT_DIFF_EPSILON) return;
+
+		//GIM_INV_SQRT(vec_sum_len,vec_sum_len); // 1/sqrt(vec_sum_len)
+
+		m_normal = vec_sum/btSqrt(vec_sum_len);
+    }
+
+};
+
+
+class btContactArray:public btAlignedObjectArray<BT_CONTACT>
+{
+public:
+	btContactArray()
+	{
+		reserve(64);
+	}
+
+	SIMD_FORCE_INLINE void push_contact(
+		const btVector3 &point,const btVector3 & normal,
+		btScalar depth, int feature1, int feature2)
+	{
+		push_back( BT_CONTACT(point,normal,depth,feature1,feature2) );
+	}
+
+	SIMD_FORCE_INLINE void push_triangle_contacts(
+		const BT_TRIANGLE_CONTACT & tricontact,
+		int feature1,int feature2)
+	{
+		for(int i = 0;i<tricontact.m_point_count ;i++ )
+		{
+			push_contact(
+				tricontact.m_points[i],
+				tricontact.m_separating_normal,
+				tricontact.m_penetration_depth,feature1,feature2);
+		}
+	}
+
+	void merge_contacts(const btContactArray & contacts, bool normal_contact_average = true);
+
+	void merge_contacts_unique(const btContactArray & contacts);
+};
+
+//! @}
+#endif // GIM_CONTACT_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactBvh.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactBvh.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactBvh.cpp	(revision 2122)
@@ -0,0 +1,499 @@
+/*! \file gim_box_set.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btGImpactBvh.h"
+#include "LinearMath/btQuickprof.h"
+
+#ifdef TRI_COLLISION_PROFILING
+
+btClock g_tree_clock;
+
+float g_accum_tree_collision_time = 0;
+int g_count_traversing = 0;
+
+
+void bt_begin_gim02_tree_time()
+{
+	g_tree_clock.reset();
+}
+
+void bt_end_gim02_tree_time()
+{
+	g_accum_tree_collision_time += g_tree_clock.getTimeMicroseconds();
+	g_count_traversing++;
+}
+
+//! Gets the average time in miliseconds of tree collisions
+float btGImpactBvh::getAverageTreeCollisionTime()
+{
+	if(g_count_traversing == 0) return 0;
+
+	float avgtime = g_accum_tree_collision_time;
+	avgtime /= (float)g_count_traversing;
+
+	g_accum_tree_collision_time = 0;
+	g_count_traversing = 0;
+	return avgtime;
+
+//	float avgtime = g_count_traversing;
+//	g_count_traversing = 0;
+//	return avgtime;
+
+}
+
+#endif //TRI_COLLISION_PROFILING
+
+/////////////////////// btBvhTree /////////////////////////////////
+
+int btBvhTree::_calc_splitting_axis(
+	BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex)
+{
+
+	int i;
+
+	btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
+	btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
+	int numIndices = endIndex-startIndex;
+
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		means+=center;
+	}
+	means *= (btScalar(1.)/(btScalar)numIndices);
+
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		btVector3 diff2 = center-means;
+		diff2 = diff2 * diff2;
+		variance += diff2;
+	}
+	variance *= (btScalar(1.)/	((btScalar)numIndices-1)	);
+
+	return variance.maxAxis();
+}
+
+
+int btBvhTree::_sort_and_calc_splitting_index(
+	BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,
+	int endIndex, int splitAxis)
+{
+	int i;
+	int splitIndex =startIndex;
+	int numIndices = endIndex - startIndex;
+
+	// average of centers
+	btScalar splitValue = 0.0f;
+
+	btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		means+=center;
+	}
+	means *= (btScalar(1.)/(btScalar)numIndices);
+
+	splitValue = means[splitAxis];
+
+
+	//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		if (center[splitAxis] > splitValue)
+		{
+			//swap
+			primitive_boxes.swap(i,splitIndex);
+			//swapLeafNodes(i,splitIndex);
+			splitIndex++;
+		}
+	}
+
+	//if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex
+	//otherwise the tree-building might fail due to stack-overflows in certain cases.
+	//unbalanced1 is unsafe: it can cause stack overflows
+	//bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1)));
+
+	//unbalanced2 should work too: always use center (perfect balanced trees)
+	//bool unbalanced2 = true;
+
+	//this should be safe too:
+	int rangeBalancedIndices = numIndices/3;
+	bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices)));
+
+	if (unbalanced)
+	{
+		splitIndex = startIndex+ (numIndices>>1);
+	}
+
+	bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
+	btAssert(!unbal);
+
+	return splitIndex;
+
+}
+
+
+void btBvhTree::_build_sub_tree(BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex)
+{
+	int curIndex = m_num_nodes;
+	m_num_nodes++;
+
+	btAssert((endIndex-startIndex)>0);
+
+	if ((endIndex-startIndex)==1)
+	{
+	    //We have a leaf node
+	    setNodeBound(curIndex,primitive_boxes[startIndex].m_bound);
+		m_node_array[curIndex].setDataIndex(primitive_boxes[startIndex].m_data);
+
+		return;
+	}
+	//calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'.
+
+	//split axis
+	int splitIndex = _calc_splitting_axis(primitive_boxes,startIndex,endIndex);
+
+	splitIndex = _sort_and_calc_splitting_index(
+			primitive_boxes,startIndex,endIndex,
+			splitIndex//split axis
+			);
+
+
+	//calc this node bounding box
+
+	btAABB node_bound;
+	node_bound.invalidate();
+
+	for (int i=startIndex;i<endIndex;i++)
+	{
+		node_bound.merge(primitive_boxes[i].m_bound);
+	}
+
+	setNodeBound(curIndex,node_bound);
+
+
+	//build left branch
+	_build_sub_tree(primitive_boxes, startIndex, splitIndex );
+
+
+	//build right branch
+	 _build_sub_tree(primitive_boxes, splitIndex ,endIndex);
+
+	m_node_array[curIndex].setEscapeIndex(m_num_nodes - curIndex);
+
+
+}
+
+//! stackless build tree
+void btBvhTree::build_tree(
+	BT_BVH_DATA_ARRAY & primitive_boxes)
+{
+	// initialize node count to 0
+	m_num_nodes = 0;
+	// allocate nodes
+	m_node_array.resize(primitive_boxes.size()*2);
+
+	_build_sub_tree(primitive_boxes, 0, primitive_boxes.size());
+}
+
+////////////////////////////////////class btGImpactBvh
+
+void btGImpactBvh::refit()
+{
+	int nodecount = getNodeCount();
+	while(nodecount--)
+	{
+		if(isLeafNode(nodecount))
+		{
+			btAABB leafbox;
+			m_primitive_manager->get_primitive_box(getNodeData(nodecount),leafbox);
+			setNodeBound(nodecount,leafbox);
+		}
+		else
+		{
+			//const BT_BVH_TREE_NODE * nodepointer = get_node_pointer(nodecount);
+			//get left bound
+			btAABB bound;
+			bound.invalidate();
+
+			btAABB temp_box;
+
+			int child_node = getLeftNode(nodecount);
+			if(child_node)
+			{
+				getNodeBound(child_node,temp_box);
+				bound.merge(temp_box);
+			}
+
+			child_node = getRightNode(nodecount);
+			if(child_node)
+			{
+				getNodeBound(child_node,temp_box);
+				bound.merge(temp_box);
+			}
+
+			setNodeBound(nodecount,bound);
+		}
+	}
+}
+
+//! this rebuild the entire set
+void btGImpactBvh::buildSet()
+{
+	//obtain primitive boxes
+	BT_BVH_DATA_ARRAY primitive_boxes;
+	primitive_boxes.resize(m_primitive_manager->get_primitive_count());
+
+	for (int i = 0;i<primitive_boxes.size() ;i++ )
+	{
+		 m_primitive_manager->get_primitive_box(i,primitive_boxes[i].m_bound);
+		 primitive_boxes[i].m_data = i;
+	}
+
+	m_box_tree.build_tree(primitive_boxes);
+}
+
+//! returns the indices of the primitives in the m_primitive_manager
+bool btGImpactBvh::boxQuery(const btAABB & box, btAlignedObjectArray<int> & collided_results) const
+{
+	int curIndex = 0;
+	int numNodes = getNodeCount();
+
+	while (curIndex < numNodes)
+	{
+		btAABB bound;
+		getNodeBound(curIndex,bound);
+
+		//catch bugs in tree data
+
+		bool aabbOverlap = bound.has_collision(box);
+		bool isleafnode = isLeafNode(curIndex);
+
+		if (isleafnode && aabbOverlap)
+		{
+			collided_results.push_back(getNodeData(curIndex));
+		}
+
+		if (aabbOverlap || isleafnode)
+		{
+			//next subnode
+			curIndex++;
+		}
+		else
+		{
+			//skip node
+			curIndex+= getEscapeNodeIndex(curIndex);
+		}
+	}
+	if(collided_results.size()>0) return true;
+	return false;
+}
+
+
+
+//! returns the indices of the primitives in the m_primitive_manager
+bool btGImpactBvh::rayQuery(
+	const btVector3 & ray_dir,const btVector3 & ray_origin ,
+	btAlignedObjectArray<int> & collided_results) const
+{
+	int curIndex = 0;
+	int numNodes = getNodeCount();
+
+	while (curIndex < numNodes)
+	{
+		btAABB bound;
+		getNodeBound(curIndex,bound);
+
+		//catch bugs in tree data
+
+		bool aabbOverlap = bound.collide_ray(ray_origin,ray_dir);
+		bool isleafnode = isLeafNode(curIndex);
+
+		if (isleafnode && aabbOverlap)
+		{
+			collided_results.push_back(getNodeData( curIndex));
+		}
+
+		if (aabbOverlap || isleafnode)
+		{
+			//next subnode
+			curIndex++;
+		}
+		else
+		{
+			//skip node
+			curIndex+= getEscapeNodeIndex(curIndex);
+		}
+	}
+	if(collided_results.size()>0) return true;
+	return false;
+}
+
+
+SIMD_FORCE_INLINE bool _node_collision(
+	btGImpactBvh * boxset0, btGImpactBvh * boxset1,
+	const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0,
+	int node0 ,int node1, bool complete_primitive_tests)
+{
+	btAABB box0;
+	boxset0->getNodeBound(node0,box0);
+	btAABB box1;
+	boxset1->getNodeBound(node1,box1);
+
+	return box0.overlapping_trans_cache(box1,trans_cache_1to0,complete_primitive_tests );
+//	box1.appy_transform_trans_cache(trans_cache_1to0);
+//	return box0.has_collision(box1);
+
+}
+
+
+//stackless recursive collision routine
+static void _find_collision_pairs_recursive(
+	btGImpactBvh * boxset0, btGImpactBvh * boxset1,
+	btPairSet * collision_pairs,
+	const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0,
+	int node0, int node1, bool complete_primitive_tests)
+{
+
+
+
+	if( _node_collision(
+		boxset0,boxset1,trans_cache_1to0,
+		node0,node1,complete_primitive_tests) ==false) return;//avoid colliding internal nodes
+
+	if(boxset0->isLeafNode(node0))
+	{
+		if(boxset1->isLeafNode(node1))
+		{
+			// collision result
+			collision_pairs->push_pair(
+				boxset0->getNodeData(node0),boxset1->getNodeData(node1));
+			return;
+		}
+		else
+		{
+
+			//collide left recursive
+
+			_find_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								node0,boxset1->getLeftNode(node1),false);
+
+			//collide right recursive
+			_find_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								node0,boxset1->getRightNode(node1),false);
+
+
+		}
+	}
+	else
+	{
+		if(boxset1->isLeafNode(node1))
+		{
+
+			//collide left recursive
+			_find_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								boxset0->getLeftNode(node0),node1,false);
+
+
+			//collide right recursive
+
+			_find_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								boxset0->getRightNode(node0),node1,false);
+
+
+		}
+		else
+		{
+			//collide left0 left1
+
+
+
+			_find_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getLeftNode(node0),boxset1->getLeftNode(node1),false);
+
+			//collide left0 right1
+
+			_find_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getLeftNode(node0),boxset1->getRightNode(node1),false);
+
+
+			//collide right0 left1
+
+			_find_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getRightNode(node0),boxset1->getLeftNode(node1),false);
+
+			//collide right0 right1
+
+			_find_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getRightNode(node0),boxset1->getRightNode(node1),false);
+
+		}// else if node1 is not a leaf
+	}// else if node0 is not a leaf
+}
+
+
+void btGImpactBvh::find_collision(btGImpactBvh * boxset0, const btTransform & trans0,
+		btGImpactBvh * boxset1, const btTransform & trans1,
+		btPairSet & collision_pairs)
+{
+
+	if(boxset0->getNodeCount()==0 || boxset1->getNodeCount()==0 ) return;
+
+	BT_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0;
+
+	trans_cache_1to0.calc_from_homogenic(trans0,trans1);
+
+#ifdef TRI_COLLISION_PROFILING
+	bt_begin_gim02_tree_time();
+#endif //TRI_COLLISION_PROFILING
+
+	_find_collision_pairs_recursive(
+		boxset0,boxset1,
+		&collision_pairs,trans_cache_1to0,0,0,true);
+#ifdef TRI_COLLISION_PROFILING
+	bt_end_gim02_tree_time();
+#endif //TRI_COLLISION_PROFILING
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactBvh.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactBvh.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactBvh.h	(revision 2122)
@@ -0,0 +1,401 @@
+#ifndef GIM_BOX_SET_H_INCLUDED
+#define GIM_BOX_SET_H_INCLUDED
+
+/*! \file gim_box_set.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "LinearMath/btAlignedObjectArray.h"
+
+#include "btBoxCollision.h"
+#include "btTriangleShapeEx.h"
+
+
+
+/*! \defgroup BOX_TREES
+
+
+
+*/
+//! @{
+
+
+//! Overlapping pair
+struct BT_PAIR
+{
+    int m_index1;
+    int m_index2;
+    BT_PAIR()
+    {}
+
+    BT_PAIR(const BT_PAIR & p)
+    {
+    	m_index1 = p.m_index1;
+    	m_index2 = p.m_index2;
+	}
+
+	BT_PAIR(int index1, int index2)
+    {
+    	m_index1 = index1;
+    	m_index2 = index2;
+	}
+};
+
+//! A pairset array
+class btPairSet: public btAlignedObjectArray<BT_PAIR>
+{
+public:
+	btPairSet()
+	{
+		reserve(32);
+	}
+	inline void push_pair(int index1,int index2)
+	{
+		push_back(BT_PAIR(index1,index2));
+	}
+
+	inline void push_pair_inv(int index1,int index2)
+	{
+		push_back(BT_PAIR(index2,index1));
+	}
+};
+
+
+
+struct BT_BVH_DATA
+{
+	btAABB m_bound;
+	int m_data;
+};
+
+//! Node Structure for trees
+class BT_BVH_TREE_NODE
+{
+public:
+	btAABB m_bound;
+protected:
+	int	m_escapeIndexOrDataIndex;
+public:
+	BT_BVH_TREE_NODE()
+	{
+		m_escapeIndexOrDataIndex = 0;
+	}
+
+	SIMD_FORCE_INLINE bool isLeafNode() const
+	{
+		//skipindex is negative (internal node), triangleindex >=0 (leafnode)
+		return (m_escapeIndexOrDataIndex>=0);
+	}
+
+	SIMD_FORCE_INLINE int getEscapeIndex() const
+	{
+		//btAssert(m_escapeIndexOrDataIndex < 0);
+		return -m_escapeIndexOrDataIndex;
+	}
+
+	SIMD_FORCE_INLINE void setEscapeIndex(int index)
+	{
+		m_escapeIndexOrDataIndex = -index;
+	}
+
+	SIMD_FORCE_INLINE int getDataIndex() const
+	{
+		//btAssert(m_escapeIndexOrDataIndex >= 0);
+
+		return m_escapeIndexOrDataIndex;
+	}
+
+	SIMD_FORCE_INLINE void setDataIndex(int index)
+	{
+		m_escapeIndexOrDataIndex = index;
+	}
+
+};
+
+
+class BT_BVH_DATA_ARRAY:public btAlignedObjectArray<BT_BVH_DATA>
+{
+};
+
+
+class BT_BVH_TREE_NODE_ARRAY:public btAlignedObjectArray<BT_BVH_TREE_NODE>
+{
+};
+
+
+
+
+//! Basic Box tree structure
+class btBvhTree
+{
+protected:
+	int m_num_nodes;
+	BT_BVH_TREE_NODE_ARRAY m_node_array;
+protected:
+	int _sort_and_calc_splitting_index(
+		BT_BVH_DATA_ARRAY & primitive_boxes,
+		 int startIndex,  int endIndex, int splitAxis);
+
+	int _calc_splitting_axis(BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex);
+
+	void _build_sub_tree(BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex);
+public:
+	btBvhTree()
+	{
+		m_num_nodes = 0;
+	}
+
+	//! prototype functions for box tree management
+	//!@{
+	void build_tree(BT_BVH_DATA_ARRAY & primitive_boxes);
+
+	SIMD_FORCE_INLINE void clearNodes()
+	{
+		m_node_array.clear();
+		m_num_nodes = 0;
+	}
+
+	//! node count
+	SIMD_FORCE_INLINE int getNodeCount() const
+	{
+		return m_num_nodes;
+	}
+
+	//! tells if the node is a leaf
+	SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const
+	{
+		return m_node_array[nodeindex].isLeafNode();
+	}
+
+	SIMD_FORCE_INLINE int getNodeData(int nodeindex) const
+	{
+		return m_node_array[nodeindex].getDataIndex();
+	}
+
+	SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const
+	{
+		bound = m_node_array[nodeindex].m_bound;
+	}
+
+	SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound)
+	{
+		m_node_array[nodeindex].m_bound = bound;
+	}
+
+	SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const
+	{
+		return nodeindex+1;
+	}
+
+	SIMD_FORCE_INLINE int getRightNode(int nodeindex) const
+	{
+		if(m_node_array[nodeindex+1].isLeafNode()) return nodeindex+2;
+		return nodeindex+1 + m_node_array[nodeindex+1].getEscapeIndex();
+	}
+
+	SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const
+	{
+		return m_node_array[nodeindex].getEscapeIndex();
+	}
+
+	SIMD_FORCE_INLINE const BT_BVH_TREE_NODE * get_node_pointer(int index = 0) const
+	{
+		return &m_node_array[index];
+	}
+
+	//!@}
+};
+
+
+//! Prototype Base class for primitive classification
+/*!
+This class is a wrapper for primitive collections.
+This tells relevant info for the Bounding Box set classes, which take care of space classification.
+This class can manage Compound shapes and trimeshes, and if it is managing trimesh then the  Hierarchy Bounding Box classes will take advantage of primitive Vs Box overlapping tests for getting optimal results and less Per Box compairisons.
+*/
+class btPrimitiveManagerBase
+{
+public:
+
+	//! determines if this manager consist on only triangles, which special case will be optimized
+	virtual bool is_trimesh() const = 0;
+	virtual int get_primitive_count() const = 0;
+	virtual void get_primitive_box(int prim_index ,btAABB & primbox) const = 0;
+	//! retrieves only the points of the triangle, and the collision margin
+	virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const= 0;
+};
+
+
+//! Structure for containing Boxes
+/*!
+This class offers an structure for managing a box tree of primitives.
+Requires a Primitive prototype (like btPrimitiveManagerBase )
+*/
+class btGImpactBvh
+{
+protected:
+	btBvhTree m_box_tree;
+	btPrimitiveManagerBase * m_primitive_manager;
+
+protected:
+	//stackless refit
+	void refit();
+public:
+
+	//! this constructor doesn't build the tree. you must call	buildSet
+	btGImpactBvh()
+	{
+		m_primitive_manager = NULL;
+	}
+
+	//! this constructor doesn't build the tree. you must call	buildSet
+	btGImpactBvh(btPrimitiveManagerBase * primitive_manager)
+	{
+		m_primitive_manager = primitive_manager;
+	}
+
+	SIMD_FORCE_INLINE btAABB getGlobalBox()  const
+	{
+		btAABB totalbox;
+		getNodeBound(0, totalbox);
+		return totalbox;
+	}
+
+	SIMD_FORCE_INLINE void setPrimitiveManager(btPrimitiveManagerBase * primitive_manager)
+	{
+		m_primitive_manager = primitive_manager;
+	}
+
+	SIMD_FORCE_INLINE btPrimitiveManagerBase * getPrimitiveManager() const
+	{
+		return m_primitive_manager;
+	}
+
+
+//! node manager prototype functions
+///@{
+
+	//! this attemps to refit the box set.
+	SIMD_FORCE_INLINE void update()
+	{
+		refit();
+	}
+
+	//! this rebuild the entire set
+	void buildSet();
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	bool boxQuery(const btAABB & box, btAlignedObjectArray<int> & collided_results) const;
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	SIMD_FORCE_INLINE bool boxQueryTrans(const btAABB & box,
+		 const btTransform & transform, btAlignedObjectArray<int> & collided_results) const
+	{
+		btAABB transbox=box;
+		transbox.appy_transform(transform);
+		return boxQuery(transbox,collided_results);
+	}
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	bool rayQuery(
+		const btVector3 & ray_dir,const btVector3 & ray_origin ,
+		btAlignedObjectArray<int> & collided_results) const;
+
+	//! tells if this set has hierarcht
+	SIMD_FORCE_INLINE bool hasHierarchy() const
+	{
+		return true;
+	}
+
+	//! tells if this set is a trimesh
+	SIMD_FORCE_INLINE bool isTrimesh()  const
+	{
+		return m_primitive_manager->is_trimesh();
+	}
+
+	//! node count
+	SIMD_FORCE_INLINE int getNodeCount() const
+	{
+		return m_box_tree.getNodeCount();
+	}
+
+	//! tells if the node is a leaf
+	SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const
+	{
+		return m_box_tree.isLeafNode(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE int getNodeData(int nodeindex) const
+	{
+		return m_box_tree.getNodeData(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound)  const
+	{
+		m_box_tree.getNodeBound(nodeindex, bound);
+	}
+
+	SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound)
+	{
+		m_box_tree.setNodeBound(nodeindex, bound);
+	}
+
+
+	SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const
+	{
+		return m_box_tree.getLeftNode(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE int getRightNode(int nodeindex) const
+	{
+		return m_box_tree.getRightNode(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const
+	{
+		return m_box_tree.getEscapeNodeIndex(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE void getNodeTriangle(int nodeindex,btPrimitiveTriangle & triangle) const
+	{
+		m_primitive_manager->get_primitive_triangle(getNodeData(nodeindex),triangle);
+	}
+
+
+	SIMD_FORCE_INLINE const BT_BVH_TREE_NODE * get_node_pointer(int index = 0) const
+	{
+		return m_box_tree.get_node_pointer(index);
+	}
+
+//! @}
+
+	static float getAverageTreeCollisionTime();
+
+
+	static void find_collision(btGImpactBvh * boxset1, const btTransform & trans1,
+		btGImpactBvh * boxset2, const btTransform & trans2,
+		btPairSet & collision_pairs);
+};
+
+
+#endif // GIM_BOXPRUNING_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,896 @@
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+/*
+Author: Francisco Len Nßjera
+Concave-Concave Collision
+
+*/
+
+#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "btGImpactCollisionAlgorithm.h"
+#include "btContactProcessing.h"
+#include "LinearMath/btQuickprof.h"
+
+
+//! Class for accessing the plane equation
+class btPlaneShape : public btStaticPlaneShape
+{
+public:
+
+	btPlaneShape(const btVector3& v, float f)
+		:btStaticPlaneShape(v,f)
+	{
+	}
+
+	void get_plane_equation(btVector4 &equation)
+	{
+		equation[0] = m_planeNormal[0];
+		equation[1] = m_planeNormal[1];
+		equation[2] = m_planeNormal[2];
+		equation[3] = m_planeConstant;
+	}
+
+
+	void get_plane_equation_transformed(const btTransform & trans,btVector4 &equation)
+	{
+		equation[0] = trans.getBasis().getRow(0).dot(m_planeNormal);
+		equation[1] = trans.getBasis().getRow(1).dot(m_planeNormal);
+		equation[2] = trans.getBasis().getRow(2).dot(m_planeNormal);
+		equation[3] = trans.getOrigin().dot(m_planeNormal) + m_planeConstant;
+	}
+};
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef TRI_COLLISION_PROFILING
+
+btClock g_triangle_clock;
+
+float g_accum_triangle_collision_time = 0;
+int g_count_triangle_collision = 0;
+
+void bt_begin_gim02_tri_time()
+{
+	g_triangle_clock.reset();
+}
+
+void bt_end_gim02_tri_time()
+{
+	g_accum_triangle_collision_time += g_triangle_clock.getTimeMicroseconds();
+	g_count_triangle_collision++;
+}
+#endif //TRI_COLLISION_PROFILING
+//! Retrieving shapes shapes
+/*!
+Declared here due of insuficent space on Pool allocators
+*/
+//!@{
+class GIM_ShapeRetriever
+{
+public:
+	btGImpactShapeInterface * m_gim_shape;
+	btTriangleShapeEx m_trishape;
+	btTetrahedronShapeEx m_tetrashape;
+
+public:
+	class ChildShapeRetriever
+	{
+	public:
+		GIM_ShapeRetriever * m_parent;
+		virtual btCollisionShape * getChildShape(int index)
+		{
+			return m_parent->m_gim_shape->getChildShape(index);
+		}
+	};
+
+	class TriangleShapeRetriever:public ChildShapeRetriever
+	{
+	public:
+
+		virtual btCollisionShape * getChildShape(int index)
+		{
+			m_parent->m_gim_shape->getBulletTriangle(index,m_parent->m_trishape);
+			return &m_parent->m_trishape;
+		}
+	};
+
+	class TetraShapeRetriever:public ChildShapeRetriever
+	{
+	public:
+
+		virtual btCollisionShape * getChildShape(int index)
+		{
+			m_parent->m_gim_shape->getBulletTetrahedron(index,m_parent->m_tetrashape);
+			return &m_parent->m_tetrashape;
+		}
+	};
+public:
+	ChildShapeRetriever m_child_retriever;
+	TriangleShapeRetriever m_tri_retriever;
+	TetraShapeRetriever  m_tetra_retriever;
+	ChildShapeRetriever * m_current_retriever;
+
+	GIM_ShapeRetriever(btGImpactShapeInterface * gim_shape)
+	{
+		m_gim_shape = gim_shape;
+		//select retriever
+		if(m_gim_shape->needsRetrieveTriangles())
+		{
+			m_current_retriever = &m_tri_retriever;
+		}
+		else if(m_gim_shape->needsRetrieveTetrahedrons())
+		{
+			m_current_retriever = &m_tetra_retriever;
+		}
+		else
+		{
+			m_current_retriever = &m_child_retriever;
+		}
+
+		m_current_retriever->m_parent = this;
+	}
+
+	btCollisionShape * getChildShape(int index)
+	{
+		return m_current_retriever->getChildShape(index);
+	}
+
+
+};
+
+
+
+//!@}
+
+
+#ifdef TRI_COLLISION_PROFILING
+
+//! Gets the average time in miliseconds of tree collisions
+float btGImpactCollisionAlgorithm::getAverageTreeCollisionTime()
+{
+	return btGImpactBoxSet::getAverageTreeCollisionTime();
+
+}
+
+//! Gets the average time in miliseconds of triangle collisions
+float btGImpactCollisionAlgorithm::getAverageTriangleCollisionTime()
+{
+	if(g_count_triangle_collision == 0) return 0;
+
+	float avgtime = g_accum_triangle_collision_time;
+	avgtime /= (float)g_count_triangle_collision;
+
+	g_accum_triangle_collision_time = 0;
+	g_count_triangle_collision = 0;
+
+	return avgtime;
+}
+
+#endif //TRI_COLLISION_PROFILING
+
+
+
+btGImpactCollisionAlgorithm::btGImpactCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+: btCollisionAlgorithm(ci)
+{
+	m_manifoldPtr = NULL;
+	m_convex_algorithm = NULL;
+}
+
+btGImpactCollisionAlgorithm::~btGImpactCollisionAlgorithm()
+{
+	clearCache();
+}
+
+
+
+
+
+void btGImpactCollisionAlgorithm::addContactPoint(btCollisionObject * body0,
+				btCollisionObject * body1,
+				const btVector3 & point,
+				const btVector3 & normal,
+				btScalar distance)
+{
+	m_resultOut->setShapeIdentifiers(m_part0,m_triface0,m_part1,m_triface1);
+	checkManifold(body0,body1);
+	m_resultOut->addContactPoint(normal,point,distance);
+}
+
+
+void btGImpactCollisionAlgorithm::shape_vs_shape_collision(
+					  btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btCollisionShape * shape0,
+					  btCollisionShape * shape1)
+{
+
+	btCollisionShape* tmpShape0 = body0->getCollisionShape();
+	btCollisionShape* tmpShape1 = body1->getCollisionShape();
+	
+	body0->internalSetTemporaryCollisionShape(shape0);
+	body1->internalSetTemporaryCollisionShape(shape1);
+
+	{
+		btCollisionAlgorithm* algor = newAlgorithm(body0,body1);
+		// post :	checkManifold is called
+
+		m_resultOut->setShapeIdentifiers(m_part0,m_triface0,m_part1,m_triface1);
+
+		algor->processCollision(body0,body1,*m_dispatchInfo,m_resultOut);
+
+		algor->~btCollisionAlgorithm();
+		m_dispatcher->freeCollisionAlgorithm(algor);
+	}
+
+	body0->internalSetTemporaryCollisionShape(tmpShape0);
+	body1->internalSetTemporaryCollisionShape(tmpShape1);
+}
+
+void btGImpactCollisionAlgorithm::convex_vs_convex_collision(
+					  btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btCollisionShape * shape0,
+					  btCollisionShape * shape1)
+{
+
+	btCollisionShape* tmpShape0 = body0->getCollisionShape();
+	btCollisionShape* tmpShape1 = body1->getCollisionShape();
+	
+	body0->internalSetTemporaryCollisionShape(shape0);
+	body1->internalSetTemporaryCollisionShape(shape1);
+
+
+	m_resultOut->setShapeIdentifiers(m_part0,m_triface0,m_part1,m_triface1);
+
+	checkConvexAlgorithm(body0,body1);
+	m_convex_algorithm->processCollision(body0,body1,*m_dispatchInfo,m_resultOut);
+
+	body0->internalSetTemporaryCollisionShape(tmpShape0);
+	body1->internalSetTemporaryCollisionShape(tmpShape1);
+
+}
+
+
+
+
+void btGImpactCollisionAlgorithm::gimpact_vs_gimpact_find_pairs(
+					  const btTransform & trans0,
+					  const btTransform & trans1,
+					  btGImpactShapeInterface * shape0,
+					  btGImpactShapeInterface * shape1,btPairSet & pairset)
+{
+	if(shape0->hasBoxSet() && shape1->hasBoxSet())
+	{
+		btGImpactBoxSet::find_collision(shape0->getBoxSet(),trans0,shape1->getBoxSet(),trans1,pairset);
+	}
+	else
+	{
+		btAABB boxshape0;
+		btAABB boxshape1;
+		int i = shape0->getNumChildShapes();
+
+		while(i--)
+		{
+			shape0->getChildAabb(i,trans0,boxshape0.m_min,boxshape0.m_max);
+
+			int j = shape1->getNumChildShapes();
+			while(j--)
+			{
+				shape1->getChildAabb(i,trans1,boxshape1.m_min,boxshape1.m_max);
+
+				if(boxshape1.has_collision(boxshape0))
+				{
+					pairset.push_pair(i,j);
+				}
+			}
+		}
+	}
+
+
+}
+
+
+void btGImpactCollisionAlgorithm::gimpact_vs_shape_find_pairs(
+					  const btTransform & trans0,
+					  const btTransform & trans1,
+					  btGImpactShapeInterface * shape0,
+					  btCollisionShape * shape1,
+					  btAlignedObjectArray<int> & collided_primitives)
+{
+
+	btAABB boxshape;
+
+
+	if(shape0->hasBoxSet())
+	{
+		btTransform trans1to0 = trans0.inverse();
+		trans1to0 *= trans1;
+
+		shape1->getAabb(trans1to0,boxshape.m_min,boxshape.m_max);
+
+		shape0->getBoxSet()->boxQuery(boxshape, collided_primitives);
+	}
+	else
+	{
+		shape1->getAabb(trans1,boxshape.m_min,boxshape.m_max);
+
+		btAABB boxshape0;
+		int i = shape0->getNumChildShapes();
+
+		while(i--)
+		{
+			shape0->getChildAabb(i,trans0,boxshape0.m_min,boxshape0.m_max);
+
+			if(boxshape.has_collision(boxshape0))
+			{
+				collided_primitives.push_back(i);
+			}
+		}
+
+	}
+
+}
+
+
+void btGImpactCollisionAlgorithm::collide_gjk_triangles(btCollisionObject * body0,
+				  btCollisionObject * body1,
+				  btGImpactMeshShapePart * shape0,
+				  btGImpactMeshShapePart * shape1,
+				  const int * pairs, int pair_count)
+{
+	btTriangleShapeEx tri0;
+	btTriangleShapeEx tri1;
+
+	shape0->lockChildShapes();
+	shape1->lockChildShapes();
+
+	const int * pair_pointer = pairs;
+
+	while(pair_count--)
+	{
+
+		m_triface0 = *(pair_pointer);
+		m_triface1 = *(pair_pointer+1);
+		pair_pointer+=2;
+
+
+
+		shape0->getBulletTriangle(m_triface0,tri0);
+		shape1->getBulletTriangle(m_triface1,tri1);
+
+
+		//collide two convex shapes
+		if(tri0.overlap_test_conservative(tri1))
+		{
+			convex_vs_convex_collision(body0,body1,&tri0,&tri1);
+		}
+
+	}
+
+	shape0->unlockChildShapes();
+	shape1->unlockChildShapes();
+}
+
+void btGImpactCollisionAlgorithm::collide_sat_triangles(btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactMeshShapePart * shape0,
+					  btGImpactMeshShapePart * shape1,
+					  const int * pairs, int pair_count)
+{
+	btTransform orgtrans0 = body0->getWorldTransform();
+	btTransform orgtrans1 = body1->getWorldTransform();
+
+	btPrimitiveTriangle ptri0;
+	btPrimitiveTriangle ptri1;
+	BT_TRIANGLE_CONTACT contact_data;
+
+	shape0->lockChildShapes();
+	shape1->lockChildShapes();
+
+	const int * pair_pointer = pairs;
+
+	while(pair_count--)
+	{
+
+		m_triface0 = *(pair_pointer);
+		m_triface1 = *(pair_pointer+1);
+		pair_pointer+=2;
+
+
+		shape0->getPrimitiveTriangle(m_triface0,ptri0);
+		shape1->getPrimitiveTriangle(m_triface1,ptri1);
+
+		#ifdef TRI_COLLISION_PROFILING
+		bt_begin_gim02_tri_time();
+		#endif
+
+		ptri0.applyTransform(orgtrans0);
+		ptri1.applyTransform(orgtrans1);
+
+
+		//build planes
+		ptri0.buildTriPlane();
+		ptri1.buildTriPlane();
+		// test conservative
+
+
+
+		if(ptri0.overlap_test_conservative(ptri1))
+		{
+			if(ptri0.find_triangle_collision_clip_method(ptri1,contact_data))
+			{
+
+				int j = contact_data.m_point_count;
+				while(j--)
+				{
+
+					addContactPoint(body0, body1,
+								contact_data.m_points[j],
+								contact_data.m_separating_normal,
+								-contact_data.m_penetration_depth);
+				}
+			}
+		}
+
+		#ifdef TRI_COLLISION_PROFILING
+		bt_end_gim02_tri_time();
+		#endif
+
+	}
+
+	shape0->unlockChildShapes();
+	shape1->unlockChildShapes();
+
+}
+
+
+void btGImpactCollisionAlgorithm::gimpact_vs_gimpact(
+						btCollisionObject * body0,
+					   	btCollisionObject * body1,
+					  	btGImpactShapeInterface * shape0,
+					  	btGImpactShapeInterface * shape1)
+{
+
+	if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE)
+	{
+		btGImpactMeshShape * meshshape0 = static_cast<btGImpactMeshShape *>(shape0);
+		m_part0 = meshshape0->getMeshPartCount();
+
+		while(m_part0--)
+		{
+			gimpact_vs_gimpact(body0,body1,meshshape0->getMeshPart(m_part0),shape1);
+		}
+
+		return;
+	}
+
+	if(shape1->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE)
+	{
+		btGImpactMeshShape * meshshape1 = static_cast<btGImpactMeshShape *>(shape1);
+		m_part1 = meshshape1->getMeshPartCount();
+
+		while(m_part1--)
+		{
+
+			gimpact_vs_gimpact(body0,body1,shape0,meshshape1->getMeshPart(m_part1));
+
+		}
+
+		return;
+	}
+
+
+	btTransform orgtrans0 = body0->getWorldTransform();
+	btTransform orgtrans1 = body1->getWorldTransform();
+
+	btPairSet pairset;
+
+	gimpact_vs_gimpact_find_pairs(orgtrans0,orgtrans1,shape0,shape1,pairset);
+
+	if(pairset.size()== 0) return;
+
+	if(shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART &&
+		shape1->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART)
+	{
+		btGImpactMeshShapePart * shapepart0 = static_cast<btGImpactMeshShapePart * >(shape0);
+		btGImpactMeshShapePart * shapepart1 = static_cast<btGImpactMeshShapePart * >(shape1);
+		//specialized function
+		#ifdef BULLET_TRIANGLE_COLLISION
+		collide_gjk_triangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size());
+		#else
+		collide_sat_triangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size());
+		#endif
+
+		return;
+	}
+
+	//general function
+
+	shape0->lockChildShapes();
+	shape1->lockChildShapes();
+
+	GIM_ShapeRetriever retriever0(shape0);
+	GIM_ShapeRetriever retriever1(shape1);
+
+	bool child_has_transform0 = shape0->childrenHasTransform();
+	bool child_has_transform1 = shape1->childrenHasTransform();
+
+	int i = pairset.size();
+	while(i--)
+	{
+		BT_PAIR * pair = &pairset[i];
+		m_triface0 = pair->m_index1;
+		m_triface1 = pair->m_index2;
+		btCollisionShape * colshape0 = retriever0.getChildShape(m_triface0);
+		btCollisionShape * colshape1 = retriever1.getChildShape(m_triface1);
+
+		if(child_has_transform0)
+		{
+			body0->setWorldTransform(orgtrans0*shape0->getChildTransform(m_triface0));
+		}
+
+		if(child_has_transform1)
+		{
+			body1->setWorldTransform(orgtrans1*shape1->getChildTransform(m_triface1));
+		}
+
+		//collide two convex shapes
+		convex_vs_convex_collision(body0,body1,colshape0,colshape1);
+
+
+		if(child_has_transform0)
+		{
+			body0->setWorldTransform(orgtrans0);
+		}
+
+		if(child_has_transform1)
+		{
+			body1->setWorldTransform(orgtrans1);
+		}
+
+	}
+
+	shape0->unlockChildShapes();
+	shape1->unlockChildShapes();
+}
+
+void btGImpactCollisionAlgorithm::gimpact_vs_shape(btCollisionObject * body0,
+				  btCollisionObject * body1,
+				  btGImpactShapeInterface * shape0,
+				  btCollisionShape * shape1,bool swapped)
+{
+	if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE)
+	{
+		btGImpactMeshShape * meshshape0 = static_cast<btGImpactMeshShape *>(shape0);
+		m_part0 = meshshape0->getMeshPartCount();
+
+		while(m_part0--)
+		{
+
+			gimpact_vs_shape(body0,
+				  body1,
+				  meshshape0->getMeshPart(m_part0),
+				  shape1,swapped);
+
+		}
+
+		return;
+	}
+
+	#ifdef GIMPACT_VS_PLANE_COLLISION
+	if(shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART &&
+		shape1->getShapeType() == STATIC_PLANE_PROXYTYPE)
+	{
+		btGImpactMeshShapePart * shapepart = static_cast<btGImpactMeshShapePart *>(shape0);
+		btStaticPlaneShape * planeshape = static_cast<btStaticPlaneShape * >(shape1);
+		gimpacttrimeshpart_vs_plane_collision(body0,body1,shapepart,planeshape,swapped);
+		return;
+	}
+
+	#endif
+
+
+
+	if(shape1->isCompound())
+	{
+		btCompoundShape * compoundshape = static_cast<btCompoundShape *>(shape1);
+		gimpact_vs_compoundshape(body0,body1,shape0,compoundshape,swapped);
+		return;
+	}
+	else if(shape1->isConcave())
+	{
+		btConcaveShape * concaveshape = static_cast<btConcaveShape *>(shape1);
+		gimpact_vs_concave(body0,body1,shape0,concaveshape,swapped);
+		return;
+	}
+
+
+	btTransform orgtrans0 = body0->getWorldTransform();
+
+	btTransform orgtrans1 = body1->getWorldTransform();
+
+	btAlignedObjectArray<int> collided_results;
+
+	gimpact_vs_shape_find_pairs(orgtrans0,orgtrans1,shape0,shape1,collided_results);
+
+	if(collided_results.size() == 0) return;
+
+
+	shape0->lockChildShapes();
+
+	GIM_ShapeRetriever retriever0(shape0);
+
+
+	bool child_has_transform0 = shape0->childrenHasTransform();
+
+
+	int i = collided_results.size();
+
+	while(i--)
+	{
+		int child_index = collided_results[i];
+        if(swapped)
+    		m_triface1 = child_index;
+        else
+            m_triface0 = child_index;
+
+		btCollisionShape * colshape0 = retriever0.getChildShape(child_index);
+
+		if(child_has_transform0)
+		{
+			body0->setWorldTransform(orgtrans0*shape0->getChildTransform(child_index));
+		}
+
+		//collide two shapes
+		if(swapped)
+		{
+			shape_vs_shape_collision(body1,body0,shape1,colshape0);
+		}
+		else
+		{
+			shape_vs_shape_collision(body0,body1,colshape0,shape1);
+		}
+
+		//restore transforms
+		if(child_has_transform0)
+		{
+			body0->setWorldTransform(orgtrans0);
+		}
+
+	}
+
+	shape0->unlockChildShapes();
+
+}
+
+void btGImpactCollisionAlgorithm::gimpact_vs_compoundshape(btCollisionObject * body0,
+				  btCollisionObject * body1,
+				  btGImpactShapeInterface * shape0,
+				  btCompoundShape * shape1,bool swapped)
+{
+	btTransform orgtrans1 = body1->getWorldTransform();
+
+	int i = shape1->getNumChildShapes();
+	while(i--)
+	{
+
+		btCollisionShape * colshape1 = shape1->getChildShape(i);
+		btTransform childtrans1 = orgtrans1*shape1->getChildTransform(i);
+
+		body1->setWorldTransform(childtrans1);
+
+		//collide child shape
+		gimpact_vs_shape(body0, body1,
+					  shape0,colshape1,swapped);
+
+
+		//restore transforms
+		body1->setWorldTransform(orgtrans1);
+	}
+}
+
+void btGImpactCollisionAlgorithm::gimpacttrimeshpart_vs_plane_collision(
+					  btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactMeshShapePart * shape0,
+					  btStaticPlaneShape * shape1,bool swapped)
+{
+
+
+	btTransform orgtrans0 = body0->getWorldTransform();
+	btTransform orgtrans1 = body1->getWorldTransform();
+
+	btPlaneShape * planeshape = static_cast<btPlaneShape *>(shape1);
+	btVector4 plane;
+	planeshape->get_plane_equation_transformed(orgtrans1,plane);
+
+	//test box against plane
+
+	btAABB tribox;
+	shape0->getAabb(orgtrans0,tribox.m_min,tribox.m_max);
+	tribox.increment_margin(planeshape->getMargin());
+
+	if( tribox.plane_classify(plane)!= BT_CONST_COLLIDE_PLANE) return;
+
+	shape0->lockChildShapes();
+
+	btScalar margin = shape0->getMargin() + planeshape->getMargin();
+
+	btVector3 vertex;
+	int vi = shape0->getVertexCount();
+	while(vi--)
+	{
+		shape0->getVertex(vi,vertex);
+		vertex = orgtrans0(vertex);
+
+		btScalar distance = vertex.dot(plane) - plane[3] - margin;
+
+		if(distance<0.0)//add contact
+		{
+			if(swapped)
+			{
+				addContactPoint(body1, body0,
+					vertex,
+					-plane,
+					distance);
+			}
+			else
+			{
+				addContactPoint(body0, body1,
+					vertex,
+					plane,
+					distance);
+			}
+		}
+	}
+
+	shape0->unlockChildShapes();
+}
+
+
+
+
+class btGImpactTriangleCallback: public btTriangleCallback
+{
+public:
+	btGImpactCollisionAlgorithm * algorithm;
+	btCollisionObject * body0;
+	btCollisionObject * body1;
+	btGImpactShapeInterface * gimpactshape0;
+	bool swapped;
+	btScalar margin;
+
+	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
+	{
+		btTriangleShapeEx tri1(triangle[0],triangle[1],triangle[2]);
+		tri1.setMargin(margin);
+        if(swapped)
+        {
+            algorithm->setPart0(partId);
+            algorithm->setFace0(triangleIndex);
+        }
+        else
+        {
+            algorithm->setPart1(partId);
+            algorithm->setFace1(triangleIndex);
+        }
+		algorithm->gimpact_vs_shape(
+							body0,body1,gimpactshape0,&tri1,swapped);
+	}
+};
+
+
+
+
+void btGImpactCollisionAlgorithm::gimpact_vs_concave(
+				  btCollisionObject * body0,
+				  btCollisionObject * body1,
+				  btGImpactShapeInterface * shape0,
+				  btConcaveShape * shape1,bool swapped)
+{
+	//create the callback
+	btGImpactTriangleCallback tricallback;
+	tricallback.algorithm = this;
+	tricallback.body0 = body0;
+	tricallback.body1 = body1;
+	tricallback.gimpactshape0 = shape0;
+	tricallback.swapped = swapped;
+	tricallback.margin = shape1->getMargin();
+
+	//getting the trimesh AABB
+	btTransform gimpactInConcaveSpace;
+
+	gimpactInConcaveSpace = body1->getWorldTransform().inverse() * body0->getWorldTransform();
+
+	btVector3 minAABB,maxAABB;
+	shape0->getAabb(gimpactInConcaveSpace,minAABB,maxAABB);
+
+	shape1->processAllTriangles(&tricallback,minAABB,maxAABB);
+
+}
+
+
+
+void btGImpactCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+    clearCache();
+
+    m_resultOut = resultOut;
+	m_dispatchInfo = &dispatchInfo;
+    btGImpactShapeInterface * gimpactshape0;
+    btGImpactShapeInterface * gimpactshape1;
+
+	if (body0->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE)
+	{
+		gimpactshape0 = static_cast<btGImpactShapeInterface *>(body0->getCollisionShape());
+
+		if( body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE )
+		{
+			gimpactshape1 = static_cast<btGImpactShapeInterface *>(body1->getCollisionShape());
+
+			gimpact_vs_gimpact(body0,body1,gimpactshape0,gimpactshape1);
+		}
+		else
+		{
+			gimpact_vs_shape(body0,body1,gimpactshape0,body1->getCollisionShape(),false);
+		}
+
+	}
+	else if (body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE )
+	{
+		gimpactshape1 = static_cast<btGImpactShapeInterface *>(body1->getCollisionShape());
+
+		gimpact_vs_shape(body1,body0,gimpactshape1,body0->getCollisionShape(),true);
+	}
+}
+
+
+btScalar btGImpactCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	return 1.f;
+
+}
+
+///////////////////////////////////// REGISTERING ALGORITHM //////////////////////////////////////////////
+
+btGImpactCollisionAlgorithm::CreateFunc g_gimpact_cf;
+
+//! Use this function for register the algorithm externally
+void btGImpactCollisionAlgorithm::registerAlgorithm(btCollisionDispatcher * dispatcher)
+{
+
+	int i;
+
+	for ( i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ )
+	{
+		dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,i ,&g_gimpact_cf);
+	}
+
+	for ( i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ )
+	{
+		dispatcher->registerCollisionCreateFunc(i,GIMPACT_SHAPE_PROXYTYPE ,&g_gimpact_cf);
+	}
+
+}
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,306 @@
+/*! \file btGImpactShape.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BVH_CONCAVE_COLLISION_ALGORITHM_H
+#define BVH_CONCAVE_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+class btDispatcher;
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+
+#include "LinearMath/btAlignedObjectArray.h"
+
+#include "btGImpactShape.h"
+#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
+#include "BulletCollision/CollisionShapes/btCompoundShape.h"
+#include "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h"
+#include "LinearMath/btIDebugDraw.h"
+
+
+
+//! Collision Algorithm for GImpact Shapes
+/*!
+For register this algorithm in Bullet, proceed as following:
+ \code
+btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(m_dynamicsWorld ->getDispatcher());
+btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
+ \endcode
+*/
+class btGImpactCollisionAlgorithm : public btCollisionAlgorithm
+{
+protected:
+	btCollisionAlgorithm * m_convex_algorithm;
+    btPersistentManifold * m_manifoldPtr;
+	btManifoldResult* m_resultOut;
+	const btDispatcherInfo * m_dispatchInfo;
+	int m_triface0;
+	int m_part0;
+	int m_triface1;
+	int m_part1;
+
+
+	//! Creates a new contact point
+	SIMD_FORCE_INLINE btPersistentManifold* newContactManifold(btCollisionObject* body0,btCollisionObject* body1)
+	{
+		m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);		
+		return m_manifoldPtr;
+	}
+
+	SIMD_FORCE_INLINE void destroyConvexAlgorithm()
+	{
+		if(m_convex_algorithm)
+		{
+			m_convex_algorithm->~btCollisionAlgorithm();
+			m_dispatcher->freeCollisionAlgorithm( m_convex_algorithm);
+			m_convex_algorithm = NULL;
+		}
+	}
+
+	SIMD_FORCE_INLINE void destroyContactManifolds()
+	{
+		if(m_manifoldPtr == NULL) return;
+		m_dispatcher->releaseManifold(m_manifoldPtr);
+		m_manifoldPtr = NULL;
+	}
+
+	SIMD_FORCE_INLINE void clearCache()
+	{
+		destroyContactManifolds();
+		destroyConvexAlgorithm();
+
+		m_triface0 = -1;
+		m_part0 = -1;
+		m_triface1 = -1;
+		m_part1 = -1;
+	}
+
+	SIMD_FORCE_INLINE btPersistentManifold* getLastManifold()
+	{
+		return m_manifoldPtr;
+	}
+
+
+	// Call before process collision
+	SIMD_FORCE_INLINE void checkManifold(btCollisionObject* body0,btCollisionObject* body1)
+	{
+		if(getLastManifold() == 0)
+		{
+			newContactManifold(body0,body1);
+		}
+
+		m_resultOut->setPersistentManifold(getLastManifold());
+	}
+
+	// Call before process collision
+	SIMD_FORCE_INLINE btCollisionAlgorithm * newAlgorithm(btCollisionObject* body0,btCollisionObject* body1)
+	{
+		checkManifold(body0,body1);
+
+		btCollisionAlgorithm * convex_algorithm = m_dispatcher->findAlgorithm(
+				body0,body1,getLastManifold());
+		return convex_algorithm ;
+	}
+
+	// Call before process collision
+	SIMD_FORCE_INLINE void checkConvexAlgorithm(btCollisionObject* body0,btCollisionObject* body1)
+	{
+		if(m_convex_algorithm) return;
+		m_convex_algorithm = newAlgorithm(body0,body1);
+	}
+
+
+
+
+	void addContactPoint(btCollisionObject * body0,
+					btCollisionObject * body1,
+					const btVector3 & point,
+					const btVector3 & normal,
+					btScalar distance);
+
+//! Collision routines
+//!@{
+
+	void collide_gjk_triangles(btCollisionObject * body0,
+				  btCollisionObject * body1,
+				  btGImpactMeshShapePart * shape0,
+				  btGImpactMeshShapePart * shape1,
+				  const int * pairs, int pair_count);
+
+	void collide_sat_triangles(btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactMeshShapePart * shape0,
+					  btGImpactMeshShapePart * shape1,
+					  const int * pairs, int pair_count);
+
+
+
+
+	void shape_vs_shape_collision(
+					  btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btCollisionShape * shape0,
+					  btCollisionShape * shape1);
+
+	void convex_vs_convex_collision(btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btCollisionShape * shape0,
+					  btCollisionShape * shape1);
+
+
+
+	void gimpact_vs_gimpact_find_pairs(
+					  const btTransform & trans0,
+					  const btTransform & trans1,
+					  btGImpactShapeInterface * shape0,
+					  btGImpactShapeInterface * shape1,btPairSet & pairset);
+
+	void gimpact_vs_shape_find_pairs(
+					  const btTransform & trans0,
+					  const btTransform & trans1,
+					  btGImpactShapeInterface * shape0,
+					  btCollisionShape * shape1,
+					  btAlignedObjectArray<int> & collided_primitives);
+
+
+	void gimpacttrimeshpart_vs_plane_collision(
+					  btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactMeshShapePart * shape0,
+					  btStaticPlaneShape * shape1,bool swapped);
+
+
+public:
+
+	btGImpactCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+
+	virtual ~btGImpactCollisionAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	btScalar	calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		if (m_manifoldPtr)
+			manifoldArray.push_back(m_manifoldPtr);
+	}
+
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btGImpactCollisionAlgorithm));
+			return new(mem) btGImpactCollisionAlgorithm(ci,body0,body1);
+		}
+	};
+
+	//! Use this function for register the algorithm externally
+	static void registerAlgorithm(btCollisionDispatcher * dispatcher);
+
+	//! Gets the average time in miliseconds of tree collisions
+	static float getAverageTreeCollisionTime();
+
+	//! Gets the average time in miliseconds of triangle collisions
+	static float getAverageTriangleCollisionTime();
+
+
+	//! Collides two gimpact shapes
+	/*!
+	\pre shape0 and shape1 couldn't be btGImpactMeshShape objects
+	*/
+
+
+	void gimpact_vs_gimpact(btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactShapeInterface * shape0,
+					  btGImpactShapeInterface * shape1);
+
+	void gimpact_vs_shape(btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactShapeInterface * shape0,
+					  btCollisionShape * shape1,bool swapped);
+
+	void gimpact_vs_compoundshape(btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactShapeInterface * shape0,
+					  btCompoundShape * shape1,bool swapped);
+
+	void gimpact_vs_concave(
+					  btCollisionObject * body0,
+					  btCollisionObject * body1,
+					  btGImpactShapeInterface * shape0,
+					  btConcaveShape * shape1,bool swapped);
+
+
+
+
+		/// Accessor/Mutator pairs for Part and triangleID
+    void 	setFace0(int value) 
+    { 
+    	m_triface0 = value; 
+    }
+    int getFace0() 
+    { 
+    	return m_triface0; 
+    }
+    void setFace1(int value) 
+    { 
+    	m_triface1 = value; 
+    }
+    int getFace1() 
+    { 
+    	return m_triface1; 
+    }
+    void setPart0(int value) 
+    { 
+    	m_part0 = value; 
+    }
+    int getPart0() 
+    { 
+    	return m_part0; 
+    }
+    void setPart1(int value) 
+    { 
+    	m_part1 = value; 
+		}
+    int getPart1() 
+    { 
+    	return m_part1; 
+    }
+
+};
+
+
+//algorithm details
+//#define BULLET_TRIANGLE_COLLISION 1
+#define GIMPACT_VS_PLANE_COLLISION 1
+
+
+
+#endif //BVH_CONCAVE_COLLISION_ALGORITHM_H
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactMassUtil.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactMassUtil.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactMassUtil.h	(revision 2122)
@@ -0,0 +1,60 @@
+/*! \file btGImpactMassUtil.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef GIMPACT_MASS_UTIL_H
+#define GIMPACT_MASS_UTIL_H
+
+#include "LinearMath/btTransform.h"
+
+
+
+SIMD_FORCE_INLINE btVector3 gim_inertia_add_transformed(
+	const btVector3 & source_inertia, const btVector3 & added_inertia, const btTransform & transform)
+{
+	btMatrix3x3  rotatedTensor = transform.getBasis().scaled(added_inertia) * transform.getBasis().transpose();
+
+	btScalar x2 = transform.getOrigin()[0];
+	x2*= x2;
+	btScalar y2 = transform.getOrigin()[1];
+	y2*= y2;
+	btScalar z2 = transform.getOrigin()[2];
+	z2*= z2;
+
+	btScalar ix = rotatedTensor[0][0]*(y2+z2);
+	btScalar iy = rotatedTensor[1][1]*(x2+z2);
+	btScalar iz = rotatedTensor[2][2]*(x2+y2);
+
+	return btVector3(source_inertia[0]+ix,source_inertia[1]+iy,source_inertia[2] + iz);
+}
+
+SIMD_FORCE_INLINE btVector3 gim_get_point_inertia(const btVector3 & point, btScalar mass)
+{
+	btScalar x2 = point[0]*point[0];
+	btScalar y2 = point[1]*point[1];
+	btScalar z2 = point[2]*point[2];
+	return btVector3(mass*(y2+z2),mass*(x2+z2),mass*(x2+y2));
+}
+
+
+#endif //GIMPACT_MESH_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactQuantizedBvh.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactQuantizedBvh.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactQuantizedBvh.cpp	(revision 2122)
@@ -0,0 +1,529 @@
+/*! \file gim_box_set.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btGImpactQuantizedBvh.h"
+#include "LinearMath/btQuickprof.h"
+
+#ifdef TRI_COLLISION_PROFILING
+btClock g_q_tree_clock;
+
+
+float g_q_accum_tree_collision_time = 0;
+int g_q_count_traversing = 0;
+
+
+void bt_begin_gim02_q_tree_time()
+{
+	g_q_tree_clock.reset();
+}
+
+void bt_end_gim02_q_tree_time()
+{
+	g_q_accum_tree_collision_time += g_q_tree_clock.getTimeMicroseconds();
+	g_q_count_traversing++;
+}
+
+
+//! Gets the average time in miliseconds of tree collisions
+float btGImpactQuantizedBvh::getAverageTreeCollisionTime()
+{
+	if(g_q_count_traversing == 0) return 0;
+
+	float avgtime = g_q_accum_tree_collision_time;
+	avgtime /= (float)g_q_count_traversing;
+
+	g_q_accum_tree_collision_time = 0;
+	g_q_count_traversing = 0;
+	return avgtime;
+
+//	float avgtime = g_q_count_traversing;
+//	g_q_count_traversing = 0;
+//	return avgtime;
+
+}
+
+#endif //TRI_COLLISION_PROFILING
+
+/////////////////////// btQuantizedBvhTree /////////////////////////////////
+
+void btQuantizedBvhTree::calc_quantization(
+	BT_BVH_DATA_ARRAY & primitive_boxes, btScalar boundMargin)
+{
+	//calc globa box
+	btAABB global_bound;
+	global_bound.invalidate();
+
+	for (int i=0;i<primitive_boxes.size() ;i++ )
+	{
+		global_bound.merge(primitive_boxes[i].m_bound);
+	}
+
+	bt_calc_quantization_parameters(
+		m_global_bound.m_min,m_global_bound.m_max,m_bvhQuantization,global_bound.m_min,global_bound.m_max,boundMargin);
+
+}
+
+
+
+int btQuantizedBvhTree::_calc_splitting_axis(
+	BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex)
+{
+
+	int i;
+
+	btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
+	btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
+	int numIndices = endIndex-startIndex;
+
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		means+=center;
+	}
+	means *= (btScalar(1.)/(btScalar)numIndices);
+
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		btVector3 diff2 = center-means;
+		diff2 = diff2 * diff2;
+		variance += diff2;
+	}
+	variance *= (btScalar(1.)/	((btScalar)numIndices-1)	);
+
+	return variance.maxAxis();
+}
+
+
+int btQuantizedBvhTree::_sort_and_calc_splitting_index(
+	BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,
+	int endIndex, int splitAxis)
+{
+	int i;
+	int splitIndex =startIndex;
+	int numIndices = endIndex - startIndex;
+
+	// average of centers
+	btScalar splitValue = 0.0f;
+
+	btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		means+=center;
+	}
+	means *= (btScalar(1.)/(btScalar)numIndices);
+
+	splitValue = means[splitAxis];
+
+
+	//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		if (center[splitAxis] > splitValue)
+		{
+			//swap
+			primitive_boxes.swap(i,splitIndex);
+			//swapLeafNodes(i,splitIndex);
+			splitIndex++;
+		}
+	}
+
+	//if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex
+	//otherwise the tree-building might fail due to stack-overflows in certain cases.
+	//unbalanced1 is unsafe: it can cause stack overflows
+	//bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1)));
+
+	//unbalanced2 should work too: always use center (perfect balanced trees)
+	//bool unbalanced2 = true;
+
+	//this should be safe too:
+	int rangeBalancedIndices = numIndices/3;
+	bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices)));
+
+	if (unbalanced)
+	{
+		splitIndex = startIndex+ (numIndices>>1);
+	}
+
+	bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
+	btAssert(!unbal);
+
+	return splitIndex;
+
+}
+
+
+void btQuantizedBvhTree::_build_sub_tree(BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex)
+{
+	int curIndex = m_num_nodes;
+	m_num_nodes++;
+
+	btAssert((endIndex-startIndex)>0);
+
+	if ((endIndex-startIndex)==1)
+	{
+	    //We have a leaf node
+	    setNodeBound(curIndex,primitive_boxes[startIndex].m_bound);
+		m_node_array[curIndex].setDataIndex(primitive_boxes[startIndex].m_data);
+
+		return;
+	}
+	//calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'.
+
+	//split axis
+	int splitIndex = _calc_splitting_axis(primitive_boxes,startIndex,endIndex);
+
+	splitIndex = _sort_and_calc_splitting_index(
+			primitive_boxes,startIndex,endIndex,
+			splitIndex//split axis
+			);
+
+
+	//calc this node bounding box
+
+	btAABB node_bound;
+	node_bound.invalidate();
+
+	for (int i=startIndex;i<endIndex;i++)
+	{
+		node_bound.merge(primitive_boxes[i].m_bound);
+	}
+
+	setNodeBound(curIndex,node_bound);
+
+
+	//build left branch
+	_build_sub_tree(primitive_boxes, startIndex, splitIndex );
+
+
+	//build right branch
+	 _build_sub_tree(primitive_boxes, splitIndex ,endIndex);
+
+	m_node_array[curIndex].setEscapeIndex(m_num_nodes - curIndex);
+
+
+}
+
+//! stackless build tree
+void btQuantizedBvhTree::build_tree(
+	BT_BVH_DATA_ARRAY & primitive_boxes)
+{
+	calc_quantization(primitive_boxes);
+	// initialize node count to 0
+	m_num_nodes = 0;
+	// allocate nodes
+	m_node_array.resize(primitive_boxes.size()*2);
+
+	_build_sub_tree(primitive_boxes, 0, primitive_boxes.size());
+}
+
+////////////////////////////////////class btGImpactQuantizedBvh
+
+void btGImpactQuantizedBvh::refit()
+{
+	int nodecount = getNodeCount();
+	while(nodecount--)
+	{
+		if(isLeafNode(nodecount))
+		{
+			btAABB leafbox;
+			m_primitive_manager->get_primitive_box(getNodeData(nodecount),leafbox);
+			setNodeBound(nodecount,leafbox);
+		}
+		else
+		{
+			//const BT_BVH_TREE_NODE * nodepointer = get_node_pointer(nodecount);
+			//get left bound
+			btAABB bound;
+			bound.invalidate();
+
+			btAABB temp_box;
+
+			int child_node = getLeftNode(nodecount);
+			if(child_node)
+			{
+				getNodeBound(child_node,temp_box);
+				bound.merge(temp_box);
+			}
+
+			child_node = getRightNode(nodecount);
+			if(child_node)
+			{
+				getNodeBound(child_node,temp_box);
+				bound.merge(temp_box);
+			}
+
+			setNodeBound(nodecount,bound);
+		}
+	}
+}
+
+//! this rebuild the entire set
+void btGImpactQuantizedBvh::buildSet()
+{
+	//obtain primitive boxes
+	BT_BVH_DATA_ARRAY primitive_boxes;
+	primitive_boxes.resize(m_primitive_manager->get_primitive_count());
+
+	for (int i = 0;i<primitive_boxes.size() ;i++ )
+	{
+		 m_primitive_manager->get_primitive_box(i,primitive_boxes[i].m_bound);
+		 primitive_boxes[i].m_data = i;
+	}
+
+	m_box_tree.build_tree(primitive_boxes);
+}
+
+//! returns the indices of the primitives in the m_primitive_manager
+bool btGImpactQuantizedBvh::boxQuery(const btAABB & box, btAlignedObjectArray<int> & collided_results) const
+{
+	int curIndex = 0;
+	int numNodes = getNodeCount();
+
+	//quantize box
+
+	unsigned short quantizedMin[3];
+	unsigned short quantizedMax[3];
+
+	m_box_tree.quantizePoint(quantizedMin,box.m_min);
+	m_box_tree.quantizePoint(quantizedMax,box.m_max);
+
+
+	while (curIndex < numNodes)
+	{
+
+		//catch bugs in tree data
+
+		bool aabbOverlap = m_box_tree.testQuantizedBoxOverlapp(curIndex, quantizedMin,quantizedMax);
+		bool isleafnode = isLeafNode(curIndex);
+
+		if (isleafnode && aabbOverlap)
+		{
+			collided_results.push_back(getNodeData(curIndex));
+		}
+
+		if (aabbOverlap || isleafnode)
+		{
+			//next subnode
+			curIndex++;
+		}
+		else
+		{
+			//skip node
+			curIndex+= getEscapeNodeIndex(curIndex);
+		}
+	}
+	if(collided_results.size()>0) return true;
+	return false;
+}
+
+
+
+//! returns the indices of the primitives in the m_primitive_manager
+bool btGImpactQuantizedBvh::rayQuery(
+	const btVector3 & ray_dir,const btVector3 & ray_origin ,
+	btAlignedObjectArray<int> & collided_results) const
+{
+	int curIndex = 0;
+	int numNodes = getNodeCount();
+
+	while (curIndex < numNodes)
+	{
+		btAABB bound;
+		getNodeBound(curIndex,bound);
+
+		//catch bugs in tree data
+
+		bool aabbOverlap = bound.collide_ray(ray_origin,ray_dir);
+		bool isleafnode = isLeafNode(curIndex);
+
+		if (isleafnode && aabbOverlap)
+		{
+			collided_results.push_back(getNodeData( curIndex));
+		}
+
+		if (aabbOverlap || isleafnode)
+		{
+			//next subnode
+			curIndex++;
+		}
+		else
+		{
+			//skip node
+			curIndex+= getEscapeNodeIndex(curIndex);
+		}
+	}
+	if(collided_results.size()>0) return true;
+	return false;
+}
+
+
+SIMD_FORCE_INLINE bool _quantized_node_collision(
+	btGImpactQuantizedBvh * boxset0, btGImpactQuantizedBvh * boxset1,
+	const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0,
+	int node0 ,int node1, bool complete_primitive_tests)
+{
+	btAABB box0;
+	boxset0->getNodeBound(node0,box0);
+	btAABB box1;
+	boxset1->getNodeBound(node1,box1);
+
+	return box0.overlapping_trans_cache(box1,trans_cache_1to0,complete_primitive_tests );
+//	box1.appy_transform_trans_cache(trans_cache_1to0);
+//	return box0.has_collision(box1);
+
+}
+
+
+//stackless recursive collision routine
+static void _find_quantized_collision_pairs_recursive(
+	btGImpactQuantizedBvh * boxset0, btGImpactQuantizedBvh * boxset1,
+	btPairSet * collision_pairs,
+	const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0,
+	int node0, int node1, bool complete_primitive_tests)
+{
+
+
+
+	if( _quantized_node_collision(
+		boxset0,boxset1,trans_cache_1to0,
+		node0,node1,complete_primitive_tests) ==false) return;//avoid colliding internal nodes
+
+	if(boxset0->isLeafNode(node0))
+	{
+		if(boxset1->isLeafNode(node1))
+		{
+			// collision result
+			collision_pairs->push_pair(
+				boxset0->getNodeData(node0),boxset1->getNodeData(node1));
+			return;
+		}
+		else
+		{
+
+			//collide left recursive
+
+			_find_quantized_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								node0,boxset1->getLeftNode(node1),false);
+
+			//collide right recursive
+			_find_quantized_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								node0,boxset1->getRightNode(node1),false);
+
+
+		}
+	}
+	else
+	{
+		if(boxset1->isLeafNode(node1))
+		{
+
+			//collide left recursive
+			_find_quantized_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								boxset0->getLeftNode(node0),node1,false);
+
+
+			//collide right recursive
+
+			_find_quantized_collision_pairs_recursive(
+								boxset0,boxset1,
+								collision_pairs,trans_cache_1to0,
+								boxset0->getRightNode(node0),node1,false);
+
+
+		}
+		else
+		{
+			//collide left0 left1
+
+
+
+			_find_quantized_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getLeftNode(node0),boxset1->getLeftNode(node1),false);
+
+			//collide left0 right1
+
+			_find_quantized_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getLeftNode(node0),boxset1->getRightNode(node1),false);
+
+
+			//collide right0 left1
+
+			_find_quantized_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getRightNode(node0),boxset1->getLeftNode(node1),false);
+
+			//collide right0 right1
+
+			_find_quantized_collision_pairs_recursive(
+				boxset0,boxset1,
+				collision_pairs,trans_cache_1to0,
+				boxset0->getRightNode(node0),boxset1->getRightNode(node1),false);
+
+		}// else if node1 is not a leaf
+	}// else if node0 is not a leaf
+}
+
+
+void btGImpactQuantizedBvh::find_collision(btGImpactQuantizedBvh * boxset0, const btTransform & trans0,
+		btGImpactQuantizedBvh * boxset1, const btTransform & trans1,
+		btPairSet & collision_pairs)
+{
+
+	if(boxset0->getNodeCount()==0 || boxset1->getNodeCount()==0 ) return;
+
+	BT_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0;
+
+	trans_cache_1to0.calc_from_homogenic(trans0,trans1);
+
+#ifdef TRI_COLLISION_PROFILING
+	bt_begin_gim02_q_tree_time();
+#endif //TRI_COLLISION_PROFILING
+
+	_find_quantized_collision_pairs_recursive(
+		boxset0,boxset1,
+		&collision_pairs,trans_cache_1to0,0,0,true);
+#ifdef TRI_COLLISION_PROFILING
+	bt_end_gim02_q_tree_time();
+#endif //TRI_COLLISION_PROFILING
+
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactQuantizedBvh.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactQuantizedBvh.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactQuantizedBvh.h	(revision 2122)
@@ -0,0 +1,379 @@
+#ifndef GIM_QUANTIZED_SET_H_INCLUDED
+#define GIM_QUANTIZED_SET_H_INCLUDED
+
+/*! \file btGImpactQuantizedBvh.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btGImpactBvh.h"
+#include "btQuantization.h"
+
+
+
+/*! \defgroup BOX_TREES
+
+
+
+*/
+//! @{
+
+
+///btQuantizedBvhNode is a compressed aabb node, 16 bytes.
+///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
+ATTRIBUTE_ALIGNED16	(struct) BT_QUANTIZED_BVH_NODE
+{
+	//12 bytes
+	unsigned short int	m_quantizedAabbMin[3];
+	unsigned short int	m_quantizedAabbMax[3];
+	//4 bytes
+	int	m_escapeIndexOrDataIndex;
+
+	BT_QUANTIZED_BVH_NODE()
+	{
+		m_escapeIndexOrDataIndex = 0;
+	}
+
+	SIMD_FORCE_INLINE bool isLeafNode() const
+	{
+		//skipindex is negative (internal node), triangleindex >=0 (leafnode)
+		return (m_escapeIndexOrDataIndex>=0);
+	}
+
+	SIMD_FORCE_INLINE int getEscapeIndex() const
+	{
+		//btAssert(m_escapeIndexOrDataIndex < 0);
+		return -m_escapeIndexOrDataIndex;
+	}
+
+	SIMD_FORCE_INLINE void setEscapeIndex(int index)
+	{
+		m_escapeIndexOrDataIndex = -index;
+	}
+
+	SIMD_FORCE_INLINE int getDataIndex() const
+	{
+		//btAssert(m_escapeIndexOrDataIndex >= 0);
+
+		return m_escapeIndexOrDataIndex;
+	}
+
+	SIMD_FORCE_INLINE void setDataIndex(int index)
+	{
+		m_escapeIndexOrDataIndex = index;
+	}
+
+	SIMD_FORCE_INLINE bool testQuantizedBoxOverlapp(
+		unsigned short * quantizedMin,unsigned short * quantizedMax) const
+	{
+		if(m_quantizedAabbMin[0] > quantizedMax[0] ||
+		   m_quantizedAabbMax[0] < quantizedMin[0] ||
+		   m_quantizedAabbMin[1] > quantizedMax[1] ||
+		   m_quantizedAabbMax[1] < quantizedMin[1] ||
+		   m_quantizedAabbMin[2] > quantizedMax[2] ||
+		   m_quantizedAabbMax[2] < quantizedMin[2])
+		{
+			return false;
+		}
+		return true;
+	}
+
+};
+
+
+
+class BT_QUANTIZED_BVH_NODE_ARRAY:public btAlignedObjectArray<BT_QUANTIZED_BVH_NODE>
+{
+};
+
+
+
+
+//! Basic Box tree structure
+class btQuantizedBvhTree
+{
+protected:
+	int m_num_nodes;
+	BT_QUANTIZED_BVH_NODE_ARRAY m_node_array;
+	btAABB m_global_bound;
+	btVector3 m_bvhQuantization;
+protected:
+	void calc_quantization(BT_BVH_DATA_ARRAY & primitive_boxes, btScalar boundMargin = btScalar(1.0) );
+
+	int _sort_and_calc_splitting_index(
+		BT_BVH_DATA_ARRAY & primitive_boxes,
+		 int startIndex,  int endIndex, int splitAxis);
+
+	int _calc_splitting_axis(BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex);
+
+	void _build_sub_tree(BT_BVH_DATA_ARRAY & primitive_boxes, int startIndex,  int endIndex);
+public:
+	btQuantizedBvhTree()
+	{
+		m_num_nodes = 0;
+	}
+
+	//! prototype functions for box tree management
+	//!@{
+	void build_tree(BT_BVH_DATA_ARRAY & primitive_boxes);
+
+	SIMD_FORCE_INLINE void quantizePoint(
+		unsigned short * quantizedpoint, const btVector3 & point) const
+	{
+		bt_quantize_clamp(quantizedpoint,point,m_global_bound.m_min,m_global_bound.m_max,m_bvhQuantization);
+	}
+
+
+	SIMD_FORCE_INLINE bool testQuantizedBoxOverlapp(
+		int node_index,
+		unsigned short * quantizedMin,unsigned short * quantizedMax) const
+	{
+		return m_node_array[node_index].testQuantizedBoxOverlapp(quantizedMin,quantizedMax);
+	}
+
+	SIMD_FORCE_INLINE void clearNodes()
+	{
+		m_node_array.clear();
+		m_num_nodes = 0;
+	}
+
+	//! node count
+	SIMD_FORCE_INLINE int getNodeCount() const
+	{
+		return m_num_nodes;
+	}
+
+	//! tells if the node is a leaf
+	SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const
+	{
+		return m_node_array[nodeindex].isLeafNode();
+	}
+
+	SIMD_FORCE_INLINE int getNodeData(int nodeindex) const
+	{
+		return m_node_array[nodeindex].getDataIndex();
+	}
+
+	SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const
+	{
+		bound.m_min = bt_unquantize(
+			m_node_array[nodeindex].m_quantizedAabbMin,
+			m_global_bound.m_min,m_bvhQuantization);
+
+		bound.m_max = bt_unquantize(
+			m_node_array[nodeindex].m_quantizedAabbMax,
+			m_global_bound.m_min,m_bvhQuantization);
+	}
+
+	SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound)
+	{
+		bt_quantize_clamp(	m_node_array[nodeindex].m_quantizedAabbMin,
+							bound.m_min,
+							m_global_bound.m_min,
+							m_global_bound.m_max,
+							m_bvhQuantization);
+
+		bt_quantize_clamp(	m_node_array[nodeindex].m_quantizedAabbMax,
+							bound.m_max,
+							m_global_bound.m_min,
+							m_global_bound.m_max,
+							m_bvhQuantization);
+	}
+
+	SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const
+	{
+		return nodeindex+1;
+	}
+
+	SIMD_FORCE_INLINE int getRightNode(int nodeindex) const
+	{
+		if(m_node_array[nodeindex+1].isLeafNode()) return nodeindex+2;
+		return nodeindex+1 + m_node_array[nodeindex+1].getEscapeIndex();
+	}
+
+	SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const
+	{
+		return m_node_array[nodeindex].getEscapeIndex();
+	}
+
+	SIMD_FORCE_INLINE const BT_QUANTIZED_BVH_NODE * get_node_pointer(int index = 0) const
+	{
+		return &m_node_array[index];
+	}
+
+	//!@}
+};
+
+
+
+//! Structure for containing Boxes
+/*!
+This class offers an structure for managing a box tree of primitives.
+Requires a Primitive prototype (like btPrimitiveManagerBase )
+*/
+class btGImpactQuantizedBvh
+{
+protected:
+	btQuantizedBvhTree m_box_tree;
+	btPrimitiveManagerBase * m_primitive_manager;
+
+protected:
+	//stackless refit
+	void refit();
+public:
+
+	//! this constructor doesn't build the tree. you must call	buildSet
+	btGImpactQuantizedBvh()
+	{
+		m_primitive_manager = NULL;
+	}
+
+	//! this constructor doesn't build the tree. you must call	buildSet
+	btGImpactQuantizedBvh(btPrimitiveManagerBase * primitive_manager)
+	{
+		m_primitive_manager = primitive_manager;
+	}
+
+	SIMD_FORCE_INLINE btAABB getGlobalBox()  const
+	{
+		btAABB totalbox;
+		getNodeBound(0, totalbox);
+		return totalbox;
+	}
+
+	SIMD_FORCE_INLINE void setPrimitiveManager(btPrimitiveManagerBase * primitive_manager)
+	{
+		m_primitive_manager = primitive_manager;
+	}
+
+	SIMD_FORCE_INLINE btPrimitiveManagerBase * getPrimitiveManager() const
+	{
+		return m_primitive_manager;
+	}
+
+
+//! node manager prototype functions
+///@{
+
+	//! this attemps to refit the box set.
+	SIMD_FORCE_INLINE void update()
+	{
+		refit();
+	}
+
+	//! this rebuild the entire set
+	void buildSet();
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	bool boxQuery(const btAABB & box, btAlignedObjectArray<int> & collided_results) const;
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	SIMD_FORCE_INLINE bool boxQueryTrans(const btAABB & box,
+		 const btTransform & transform, btAlignedObjectArray<int> & collided_results) const
+	{
+		btAABB transbox=box;
+		transbox.appy_transform(transform);
+		return boxQuery(transbox,collided_results);
+	}
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	bool rayQuery(
+		const btVector3 & ray_dir,const btVector3 & ray_origin ,
+		btAlignedObjectArray<int> & collided_results) const;
+
+	//! tells if this set has hierarcht
+	SIMD_FORCE_INLINE bool hasHierarchy() const
+	{
+		return true;
+	}
+
+	//! tells if this set is a trimesh
+	SIMD_FORCE_INLINE bool isTrimesh()  const
+	{
+		return m_primitive_manager->is_trimesh();
+	}
+
+	//! node count
+	SIMD_FORCE_INLINE int getNodeCount() const
+	{
+		return m_box_tree.getNodeCount();
+	}
+
+	//! tells if the node is a leaf
+	SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const
+	{
+		return m_box_tree.isLeafNode(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE int getNodeData(int nodeindex) const
+	{
+		return m_box_tree.getNodeData(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound)  const
+	{
+		m_box_tree.getNodeBound(nodeindex, bound);
+	}
+
+	SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound)
+	{
+		m_box_tree.setNodeBound(nodeindex, bound);
+	}
+
+
+	SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const
+	{
+		return m_box_tree.getLeftNode(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE int getRightNode(int nodeindex) const
+	{
+		return m_box_tree.getRightNode(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const
+	{
+		return m_box_tree.getEscapeNodeIndex(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE void getNodeTriangle(int nodeindex,btPrimitiveTriangle & triangle) const
+	{
+		m_primitive_manager->get_primitive_triangle(getNodeData(nodeindex),triangle);
+	}
+
+
+	SIMD_FORCE_INLINE const BT_QUANTIZED_BVH_NODE * get_node_pointer(int index = 0) const
+	{
+		return m_box_tree.get_node_pointer(index);
+	}
+
+//! @}
+
+	static float getAverageTreeCollisionTime();
+
+
+	static void find_collision(btGImpactQuantizedBvh * boxset1, const btTransform & trans1,
+		btGImpactQuantizedBvh * boxset2, const btTransform & trans2,
+		btPairSet & collision_pairs);
+};
+
+
+#endif // GIM_BOXPRUNING_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactShape.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactShape.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactShape.cpp	(revision 2122)
@@ -0,0 +1,183 @@
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btGImpactShape.h"
+#include "btGImpactMassUtil.h"
+
+
+#define CALC_EXACT_INERTIA 1
+
+void btGImpactCompoundShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	lockChildShapes();
+#ifdef CALC_EXACT_INERTIA
+	inertia.setValue(0.f,0.f,0.f);
+
+	int i = this->getNumChildShapes();
+	btScalar shapemass = mass/btScalar(i);
+
+	while(i--)
+	{
+		btVector3 temp_inertia;
+		m_childShapes[i]->calculateLocalInertia(shapemass,temp_inertia);
+		if(childrenHasTransform())
+		{
+			inertia = gim_inertia_add_transformed( inertia,temp_inertia,m_childTransforms[i]);
+		}
+		else
+		{
+			inertia = gim_inertia_add_transformed( inertia,temp_inertia,btTransform::getIdentity());
+		}
+
+	}
+
+#else
+
+	// Calc box inertia
+
+	btScalar lx= m_localAABB.m_max[0] - m_localAABB.m_min[0];
+	btScalar ly= m_localAABB.m_max[1] - m_localAABB.m_min[1];
+	btScalar lz= m_localAABB.m_max[2] - m_localAABB.m_min[2];
+	const btScalar x2 = lx*lx;
+	const btScalar y2 = ly*ly;
+	const btScalar z2 = lz*lz;
+	const btScalar scaledmass = mass * btScalar(0.08333333);
+
+	inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
+
+#endif
+	unlockChildShapes();
+}
+
+
+
+void btGImpactMeshShapePart::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+	lockChildShapes();
+
+
+#ifdef CALC_EXACT_INERTIA
+	inertia.setValue(0.f,0.f,0.f);
+
+	int i = this->getVertexCount();
+	btScalar pointmass = mass/btScalar(i);
+
+	while(i--)
+	{
+		btVector3 pointintertia;
+		this->getVertex(i,pointintertia);
+		pointintertia = gim_get_point_inertia(pointintertia,pointmass);
+		inertia+=pointintertia;
+	}
+
+#else
+
+	// Calc box inertia
+
+	btScalar lx= m_localAABB.m_max[0] - m_localAABB.m_min[0];
+	btScalar ly= m_localAABB.m_max[1] - m_localAABB.m_min[1];
+	btScalar lz= m_localAABB.m_max[2] - m_localAABB.m_min[2];
+	const btScalar x2 = lx*lx;
+	const btScalar y2 = ly*ly;
+	const btScalar z2 = lz*lz;
+	const btScalar scaledmass = mass * btScalar(0.08333333);
+
+	inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
+
+#endif
+
+	unlockChildShapes();
+}
+
+void btGImpactMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+{
+
+#ifdef CALC_EXACT_INERTIA
+	inertia.setValue(0.f,0.f,0.f);
+
+	int i = this->getMeshPartCount();
+	btScalar partmass = mass/btScalar(i);
+
+	while(i--)
+	{
+		btVector3 partinertia;
+		getMeshPart(i)->calculateLocalInertia(partmass,partinertia);
+		inertia+=partinertia;
+	}
+
+#else
+
+	// Calc box inertia
+
+	btScalar lx= m_localAABB.m_max[0] - m_localAABB.m_min[0];
+	btScalar ly= m_localAABB.m_max[1] - m_localAABB.m_min[1];
+	btScalar lz= m_localAABB.m_max[2] - m_localAABB.m_min[2];
+	const btScalar x2 = lx*lx;
+	const btScalar y2 = ly*ly;
+	const btScalar z2 = lz*lz;
+	const btScalar scaledmass = mass * btScalar(0.08333333);
+
+	inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
+
+#endif
+}
+
+void btGImpactMeshShape::rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback) const
+{
+}
+
+
+void btGImpactMeshShapePart::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	lockChildShapes();
+	btAABB box;
+	box.m_min = aabbMin;
+	box.m_max = aabbMax;
+
+	btAlignedObjectArray<int> collided;
+	m_box_set.boxQuery(box,collided);
+
+	if(collided.size()==0)
+	{
+		unlockChildShapes();
+		return;
+	}
+
+	int part = (int)getPart();
+	btPrimitiveTriangle triangle;
+	int i = collided.size();
+	while(i--)
+	{
+		this->getPrimitiveTriangle(collided[i],triangle);
+		callback->processTriangle(triangle.m_vertices,part,collided[i]);
+	}
+	unlockChildShapes();
+
+}
+
+void btGImpactMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+{
+	int i = m_mesh_parts.size();
+	while(i--)
+	{
+		m_mesh_parts[i]->processAllTriangles(callback,aabbMin,aabbMax);
+	}
+}
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactShape.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactShape.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGImpactShape.h	(revision 2122)
@@ -0,0 +1,1110 @@
+/*! \file btGImpactShape.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef GIMPACT_SHAPE_H
+#define GIMPACT_SHAPE_H
+
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "BulletCollision/CollisionShapes/btStridingMeshInterface.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
+#include "BulletCollision/CollisionShapes/btConcaveShape.h"
+#include "BulletCollision/CollisionShapes/btTetrahedronShape.h"
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+#include "btGImpactQuantizedBvh.h" // box tree class
+
+
+//! declare Quantized trees, (you can change to float based trees)
+typedef btGImpactQuantizedBvh btGImpactBoxSet;
+
+enum eGIMPACT_SHAPE_TYPE
+{
+	CONST_GIMPACT_COMPOUND_SHAPE = 0,
+	CONST_GIMPACT_TRIMESH_SHAPE_PART,
+	CONST_GIMPACT_TRIMESH_SHAPE
+};
+
+
+//! Helper class for tetrahedrons
+class btTetrahedronShapeEx:public btBU_Simplex1to4
+{
+public:
+	btTetrahedronShapeEx()
+	{
+		m_numVertices = 4;
+	}
+
+
+	SIMD_FORCE_INLINE void setVertices(
+		const btVector3 & v0,const btVector3 & v1,
+		const btVector3 & v2,const btVector3 & v3)
+	{
+		m_vertices[0] = v0;
+		m_vertices[1] = v1;
+		m_vertices[2] = v2;
+		m_vertices[3] = v3;
+		recalcLocalAabb();
+	}
+};
+
+
+//! Base class for gimpact shapes
+class btGImpactShapeInterface : public btConcaveShape
+{
+protected:
+    btAABB m_localAABB;
+    bool m_needs_update;
+    btVector3  localScaling;
+    btGImpactBoxSet m_box_set;// optionally boxset
+
+	//! use this function for perfofm refit in bounding boxes
+    //! use this function for perfofm refit in bounding boxes
+    virtual void calcLocalAABB()
+    {
+		lockChildShapes();
+    	if(m_box_set.getNodeCount() == 0)
+    	{
+    		m_box_set.buildSet();
+    	}
+    	else
+    	{
+    		m_box_set.update();
+    	}
+    	unlockChildShapes();
+
+    	m_localAABB = m_box_set.getGlobalBox();
+    }
+
+
+public:
+	btGImpactShapeInterface()
+	{
+		m_shapeType=GIMPACT_SHAPE_PROXYTYPE;
+		m_localAABB.invalidate();
+		m_needs_update = true;
+		localScaling.setValue(1.f,1.f,1.f);
+	}
+
+
+	//! performs refit operation
+	/*!
+	Updates the entire Box set of this shape.
+	\pre postUpdate() must be called for attemps to calculating the box set, else this function
+		will does nothing.
+	\post if m_needs_update == true, then it calls calcLocalAABB();
+	*/
+    SIMD_FORCE_INLINE void updateBound()
+    {
+    	if(!m_needs_update) return;
+    	calcLocalAABB();
+    	m_needs_update  = false;
+    }
+
+    //! If the Bounding box is not updated, then this class attemps to calculate it.
+    /*!
+    \post Calls updateBound() for update the box set.
+    */
+    void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+    {
+        btAABB transformedbox = m_localAABB;
+        transformedbox.appy_transform(t);
+        aabbMin = transformedbox.m_min;
+        aabbMax = transformedbox.m_max;
+    }
+
+    //! Tells to this object that is needed to refit the box set
+    virtual void postUpdate()
+    {
+    	m_needs_update = true;
+    }
+
+	//! Obtains the local box, which is the global calculated box of the total of subshapes
+	SIMD_FORCE_INLINE const btAABB & getLocalBox()
+	{
+		return m_localAABB;
+	}
+
+
+    virtual int	getShapeType() const
+    {
+        return GIMPACT_SHAPE_PROXYTYPE;
+    }
+
+    /*!
+	\post You must call updateBound() for update the box set.
+	*/
+	virtual void	setLocalScaling(const btVector3& scaling)
+	{
+		localScaling = scaling;
+		postUpdate();
+	}
+
+	virtual const btVector3& getLocalScaling() const
+	{
+		return localScaling;
+	}
+
+
+	virtual void setMargin(btScalar margin)
+    {
+    	m_collisionMargin = margin;
+    	int i = getNumChildShapes();
+    	while(i--)
+    	{
+			btCollisionShape* child = getChildShape(i);
+			child->setMargin(margin);
+    	}
+
+		m_needs_update = true;
+    }
+
+
+	//! Subshape member functions
+	//!@{
+
+	//! Base method for determinig which kind of GIMPACT shape we get
+	virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() = 0;
+
+	//! gets boxset
+	SIMD_FORCE_INLINE btGImpactBoxSet * getBoxSet()
+	{
+		return &m_box_set;
+	}
+
+	//! Determines if this class has a hierarchy structure for sorting its primitives
+	SIMD_FORCE_INLINE bool hasBoxSet()  const
+	{
+		if(m_box_set.getNodeCount() == 0) return false;
+		return true;
+	}
+
+	//! Obtains the primitive manager
+	virtual const btPrimitiveManagerBase * getPrimitiveManager()  const = 0;
+
+
+	//! Gets the number of children
+	virtual int	getNumChildShapes() const  = 0;
+
+	//! if true, then its children must get transforms.
+	virtual bool childrenHasTransform() const = 0;
+
+	//! Determines if this shape has triangles
+	virtual bool needsRetrieveTriangles() const = 0;
+
+	//! Determines if this shape has tetrahedrons
+	virtual bool needsRetrieveTetrahedrons() const = 0;
+
+	virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const = 0;
+
+	virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const = 0;
+
+
+
+	//! call when reading child shapes
+	virtual void lockChildShapes() const
+	{
+	}
+
+	virtual void unlockChildShapes() const
+	{
+	}
+
+	//! if this trimesh
+	SIMD_FORCE_INLINE void getPrimitiveTriangle(int index,btPrimitiveTriangle & triangle) const
+	{
+		getPrimitiveManager()->get_primitive_triangle(index,triangle);
+	}
+
+
+	//! Retrieves the bound from a child
+    /*!
+    */
+    virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+    {
+        btAABB child_aabb;
+        getPrimitiveManager()->get_primitive_box(child_index,child_aabb);
+        child_aabb.appy_transform(t);
+        aabbMin = child_aabb.m_min;
+        aabbMax = child_aabb.m_max;
+    }
+
+	//! Gets the children
+	virtual btCollisionShape* getChildShape(int index) = 0;
+
+
+	//! Gets the child
+	virtual const btCollisionShape* getChildShape(int index) const = 0;
+
+	//! Gets the children transform
+	virtual btTransform	getChildTransform(int index) const = 0;
+
+	//! Sets the children transform
+	/*!
+	\post You must call updateBound() for update the box set.
+	*/
+	virtual void setChildTransform(int index, const btTransform & transform) = 0;
+
+	//!@}
+
+
+	//! virtual method for ray collision
+	virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback)  const
+	{
+	}
+
+	//! Function for retrieve triangles.
+	/*!
+	It gives the triangles in local space
+	*/
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
+	{
+	}
+
+	//!@}
+
+};
+
+
+//! btGImpactCompoundShape allows to handle multiple btCollisionShape objects at once
+/*!
+This class only can manage Convex subshapes
+*/
+class btGImpactCompoundShape	: public btGImpactShapeInterface
+{
+public:
+	//! compound primitive manager
+	class CompoundPrimitiveManager:public btPrimitiveManagerBase
+	{
+	public:
+		btGImpactCompoundShape * m_compoundShape;
+
+
+		CompoundPrimitiveManager(const CompoundPrimitiveManager& compound)
+		{
+			m_compoundShape = compound.m_compoundShape;
+		}
+
+		CompoundPrimitiveManager(btGImpactCompoundShape * compoundShape)
+		{
+			m_compoundShape = compoundShape;
+		}
+
+		CompoundPrimitiveManager()
+		{
+			m_compoundShape = NULL;
+		}
+
+		virtual bool is_trimesh() const
+		{
+			return false;
+		}
+
+		virtual int get_primitive_count() const
+		{
+			return (int )m_compoundShape->getNumChildShapes();
+		}
+
+		virtual void get_primitive_box(int prim_index ,btAABB & primbox) const
+		{
+			btTransform prim_trans;
+			if(m_compoundShape->childrenHasTransform())
+			{
+				prim_trans = m_compoundShape->getChildTransform(prim_index);
+			}
+			else
+			{
+				prim_trans.setIdentity();
+			}
+			const btCollisionShape* shape = m_compoundShape->getChildShape(prim_index);
+			shape->getAabb(prim_trans,primbox.m_min,primbox.m_max);
+		}
+
+		virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const
+		{
+			btAssert(0);
+		}
+
+	};
+
+
+
+protected:
+	CompoundPrimitiveManager m_primitive_manager;
+	btAlignedObjectArray<btTransform>		m_childTransforms;
+	btAlignedObjectArray<btCollisionShape*>	m_childShapes;
+
+
+public:
+
+	btGImpactCompoundShape(bool children_has_transform = true)
+	{
+		m_primitive_manager.m_compoundShape = this;
+		m_box_set.setPrimitiveManager(&m_primitive_manager);
+	}
+
+	virtual ~btGImpactCompoundShape()
+	{
+	}
+
+
+	//! if true, then its children must get transforms.
+	virtual bool childrenHasTransform() const
+	{
+		if(m_childTransforms.size()==0) return false;
+		return true;
+	}
+
+
+	//! Obtains the primitive manager
+	virtual const btPrimitiveManagerBase * getPrimitiveManager()  const
+	{
+		return &m_primitive_manager;
+	}
+
+	//! Obtains the compopund primitive manager
+	SIMD_FORCE_INLINE CompoundPrimitiveManager * getCompoundPrimitiveManager()
+	{
+		return &m_primitive_manager;
+	}
+
+	//! Gets the number of children
+	virtual int	getNumChildShapes() const
+	{
+		return m_childShapes.size();
+	}
+
+
+	//! Use this method for adding children. Only Convex shapes are allowed.
+	void addChildShape(const btTransform& localTransform,btCollisionShape* shape)
+	{
+		btAssert(shape->isConvex());
+		m_childTransforms.push_back(localTransform);
+		m_childShapes.push_back(shape);
+	}
+
+	//! Use this method for adding children. Only Convex shapes are allowed.
+	void addChildShape(btCollisionShape* shape)
+	{
+		btAssert(shape->isConvex());
+		m_childShapes.push_back(shape);
+	}
+
+	//! Gets the children
+	virtual btCollisionShape* getChildShape(int index)
+	{
+		return m_childShapes[index];
+	}
+
+	//! Gets the children
+	virtual const btCollisionShape* getChildShape(int index) const
+	{
+		return m_childShapes[index];
+	}
+
+	//! Retrieves the bound from a child
+    /*!
+    */
+    virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+    {
+
+    	if(childrenHasTransform())
+    	{
+    		m_childShapes[child_index]->getAabb(t*m_childTransforms[child_index],aabbMin,aabbMax);
+    	}
+    	else
+    	{
+    		m_childShapes[child_index]->getAabb(t,aabbMin,aabbMax);
+    	}
+    }
+
+
+	//! Gets the children transform
+	virtual btTransform	getChildTransform(int index) const
+	{
+		btAssert(m_childTransforms.size() == m_childShapes.size());
+		return m_childTransforms[index];
+	}
+
+	//! Sets the children transform
+	/*!
+	\post You must call updateBound() for update the box set.
+	*/
+	virtual void setChildTransform(int index, const btTransform & transform)
+	{
+		btAssert(m_childTransforms.size() == m_childShapes.size());
+		m_childTransforms[index] = transform;
+		postUpdate();
+	}
+
+	//! Determines if this shape has triangles
+	virtual bool needsRetrieveTriangles() const
+	{
+		return false;
+	}
+
+	//! Determines if this shape has tetrahedrons
+	virtual bool needsRetrieveTetrahedrons() const
+	{
+		return false;
+	}
+
+
+	virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const
+	{
+		btAssert(0);
+	}
+
+	virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const
+	{
+		btAssert(0);
+	}
+
+
+	//! Calculates the exact inertia tensor for this shape
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+	virtual const char*	getName()const
+	{
+		return "GImpactCompound";
+	}
+
+	virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType()
+	{
+		return CONST_GIMPACT_COMPOUND_SHAPE;
+	}
+
+};
+
+
+
+//! This class manages a sub part of a mesh supplied by the btStridingMeshInterface interface.
+/*!
+- Simply create this shape by passing the btStridingMeshInterface to the constructor btGImpactMeshShapePart, then you must call updateBound() after creating the mesh
+- When making operations with this shape, you must call <b>lock</b> before accessing to the trimesh primitives, and then call <b>unlock</b>
+- You can handle deformable meshes with this shape, by calling postUpdate() every time when changing the mesh vertices.
+
+*/
+class btGImpactMeshShapePart : public btGImpactShapeInterface
+{
+public:
+	//! Trimesh primitive manager
+	/*!
+	Manages the info from btStridingMeshInterface object and controls the Lock/Unlock mechanism
+	*/
+	class TrimeshPrimitiveManager:public btPrimitiveManagerBase
+	{
+	public:
+		btScalar m_margin;
+		btStridingMeshInterface * m_meshInterface;
+		btVector3 m_scale;
+		int m_part;
+		int m_lock_count;
+		const unsigned char *vertexbase;
+		int numverts;
+		PHY_ScalarType type;
+		int stride;
+		const unsigned char *indexbase;
+		int indexstride;
+		int  numfaces;
+		PHY_ScalarType indicestype;
+
+		TrimeshPrimitiveManager()
+		{
+			m_meshInterface = NULL;
+			m_part = 0;
+			m_margin = 0.01f;
+			m_scale = btVector3(1.f,1.f,1.f);
+			m_lock_count = 0;
+			vertexbase = 0;
+			numverts = 0;
+			stride = 0;
+			indexbase = 0;
+			indexstride = 0;
+			numfaces = 0;
+		}
+
+ 		TrimeshPrimitiveManager(const TrimeshPrimitiveManager & manager)
+		{
+			m_meshInterface = manager.m_meshInterface;
+			m_part = manager.m_part;
+			m_margin = manager.m_margin;
+			m_scale = manager.m_scale;
+			m_lock_count = 0;
+			vertexbase = 0;
+			numverts = 0;
+			stride = 0;
+			indexbase = 0;
+			indexstride = 0;
+			numfaces = 0;
+
+		}
+
+		TrimeshPrimitiveManager(
+			btStridingMeshInterface * meshInterface,	int part)
+		{
+			m_meshInterface = meshInterface;
+			m_part = part;
+			m_scale = m_meshInterface->getScaling();
+			m_margin = 0.1f;
+			m_lock_count = 0;
+			vertexbase = 0;
+			numverts = 0;
+			stride = 0;
+			indexbase = 0;
+			indexstride = 0;
+			numfaces = 0;
+
+		}
+
+
+		void lock()
+		{
+			if(m_lock_count>0)
+			{
+				m_lock_count++;
+				return;
+			}
+			m_meshInterface->getLockedReadOnlyVertexIndexBase(
+				&vertexbase,numverts,
+				type, stride,&indexbase, indexstride, numfaces,indicestype,m_part);
+
+			m_lock_count = 1;
+		}
+
+		void unlock()
+		{
+			if(m_lock_count == 0) return;
+			if(m_lock_count>1)
+			{
+				--m_lock_count;
+				return;
+			}
+			m_meshInterface->unLockReadOnlyVertexBase(m_part);
+			vertexbase = NULL;
+			m_lock_count = 0;
+		}
+
+		virtual bool is_trimesh() const
+		{
+			return true;
+		}
+
+		virtual int get_primitive_count() const
+		{
+			return (int )numfaces;
+		}
+
+		SIMD_FORCE_INLINE int get_vertex_count() const
+		{
+			return (int )numverts;
+		}
+
+		SIMD_FORCE_INLINE void get_indices(int face_index,int &i0,int &i1,int &i2) const
+		{
+			if(indicestype == PHY_SHORT)
+			{
+				short * s_indices = (short *)(indexbase + face_index*indexstride);
+				i0 = s_indices[0];
+				i1 = s_indices[1];
+				i2 = s_indices[2];
+			}
+			else
+			{
+				int * i_indices = (int *)(indexbase + face_index*indexstride);
+				i0 = i_indices[0];
+				i1 = i_indices[1];
+				i2 = i_indices[2];
+			}
+		}
+
+		SIMD_FORCE_INLINE void get_vertex(int vertex_index, btVector3 & vertex) const
+		{
+			if(type == PHY_DOUBLE)
+			{
+				double * dvertices = (double *)(vertexbase + vertex_index*stride);
+				vertex[0] = btScalar(dvertices[0]*m_scale[0]);
+				vertex[1] = btScalar(dvertices[1]*m_scale[1]);
+				vertex[2] = btScalar(dvertices[2]*m_scale[2]);
+			}
+			else
+			{
+				float * svertices = (float *)(vertexbase + vertex_index*stride);
+				vertex[0] = svertices[0]*m_scale[0];
+				vertex[1] = svertices[1]*m_scale[1];
+				vertex[2] = svertices[2]*m_scale[2];
+			}
+		}
+
+		virtual void get_primitive_box(int prim_index ,btAABB & primbox) const
+		{
+			btPrimitiveTriangle  triangle;
+			get_primitive_triangle(prim_index,triangle);
+			primbox.calc_from_triangle_margin(
+				triangle.m_vertices[0],
+				triangle.m_vertices[1],triangle.m_vertices[2],triangle.m_margin);
+		}
+
+		virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const
+		{
+			int indices[3];
+			get_indices(prim_index,indices[0],indices[1],indices[2]);
+			get_vertex(indices[0],triangle.m_vertices[0]);
+			get_vertex(indices[1],triangle.m_vertices[1]);
+			get_vertex(indices[2],triangle.m_vertices[2]);
+			triangle.m_margin = m_margin;
+		}
+
+		SIMD_FORCE_INLINE void get_bullet_triangle(int prim_index,btTriangleShapeEx & triangle) const
+		{
+			int indices[3];
+			get_indices(prim_index,indices[0],indices[1],indices[2]);
+			get_vertex(indices[0],triangle.m_vertices1[0]);
+			get_vertex(indices[1],triangle.m_vertices1[1]);
+			get_vertex(indices[2],triangle.m_vertices1[2]);
+			triangle.setMargin(m_margin);
+		}
+
+	};
+
+
+protected:
+	TrimeshPrimitiveManager m_primitive_manager;
+public:
+
+	btGImpactMeshShapePart()
+	{
+		m_box_set.setPrimitiveManager(&m_primitive_manager);
+	}
+
+
+	btGImpactMeshShapePart(btStridingMeshInterface * meshInterface,	int part)
+	{
+		m_primitive_manager.m_meshInterface = meshInterface;
+		m_primitive_manager.m_part = part;
+		m_box_set.setPrimitiveManager(&m_primitive_manager);
+	}
+
+	virtual ~btGImpactMeshShapePart()
+	{
+	}
+
+	//! if true, then its children must get transforms.
+	virtual bool childrenHasTransform() const
+	{
+		return false;
+	}
+
+
+	//! call when reading child shapes
+	virtual void lockChildShapes() const
+	{
+		void * dummy = (void*)(m_box_set.getPrimitiveManager());
+		TrimeshPrimitiveManager * dummymanager = static_cast<TrimeshPrimitiveManager *>(dummy);
+		dummymanager->lock();
+	}
+
+	virtual void unlockChildShapes()  const
+	{
+		void * dummy = (void*)(m_box_set.getPrimitiveManager());
+		TrimeshPrimitiveManager * dummymanager = static_cast<TrimeshPrimitiveManager *>(dummy);
+		dummymanager->unlock();
+	}
+
+	//! Gets the number of children
+	virtual int	getNumChildShapes() const
+	{
+		return m_primitive_manager.get_primitive_count();
+	}
+
+
+	//! Gets the children
+	virtual btCollisionShape* getChildShape(int index)
+	{
+		btAssert(0);
+		return NULL;
+	}
+
+
+
+	//! Gets the child
+	virtual const btCollisionShape* getChildShape(int index) const
+	{
+		btAssert(0);
+		return NULL;
+	}
+
+	//! Gets the children transform
+	virtual btTransform	getChildTransform(int index) const
+	{
+		btAssert(0);
+		return btTransform();
+	}
+
+	//! Sets the children transform
+	/*!
+	\post You must call updateBound() for update the box set.
+	*/
+	virtual void setChildTransform(int index, const btTransform & transform)
+	{
+		btAssert(0);
+	}
+
+
+	//! Obtains the primitive manager
+	virtual const btPrimitiveManagerBase * getPrimitiveManager()  const
+	{
+		return &m_primitive_manager;
+	}
+
+	SIMD_FORCE_INLINE TrimeshPrimitiveManager * getTrimeshPrimitiveManager()
+	{
+		return &m_primitive_manager;
+	}
+
+
+
+
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+
+
+
+	virtual const char*	getName()const
+	{
+		return "GImpactMeshShapePart";
+	}
+
+	virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType()
+	{
+		return CONST_GIMPACT_TRIMESH_SHAPE_PART;
+	}
+
+	//! Determines if this shape has triangles
+	virtual bool needsRetrieveTriangles() const
+	{
+		return true;
+	}
+
+	//! Determines if this shape has tetrahedrons
+	virtual bool needsRetrieveTetrahedrons() const
+	{
+		return false;
+	}
+
+	virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const
+	{
+		m_primitive_manager.get_bullet_triangle(prim_index,triangle);
+	}
+
+	virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const
+	{
+		btAssert(0);
+	}
+
+
+
+	SIMD_FORCE_INLINE int getVertexCount() const
+	{
+		return m_primitive_manager.get_vertex_count();
+	}
+
+	SIMD_FORCE_INLINE void getVertex(int vertex_index, btVector3 & vertex) const
+	{
+		m_primitive_manager.get_vertex(vertex_index,vertex);
+	}
+
+	SIMD_FORCE_INLINE void setMargin(btScalar margin)
+    {
+    	m_primitive_manager.m_margin = margin;
+    	postUpdate();
+    }
+
+    SIMD_FORCE_INLINE btScalar getMargin() const
+    {
+    	return m_primitive_manager.m_margin;
+    }
+
+    virtual void	setLocalScaling(const btVector3& scaling)
+    {
+    	m_primitive_manager.m_scale = scaling;
+    	postUpdate();
+    }
+
+    virtual const btVector3& getLocalScaling() const
+    {
+    	return m_primitive_manager.m_scale;
+    }
+
+    SIMD_FORCE_INLINE int getPart() const
+    {
+    	return (int)m_primitive_manager.m_part;
+    }
+
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+};
+
+
+//! This class manages a mesh supplied by the btStridingMeshInterface interface.
+/*!
+Set of btGImpactMeshShapePart parts
+- Simply create this shape by passing the btStridingMeshInterface to the constructor btGImpactMeshShape, then you must call updateBound() after creating the mesh
+
+- You can handle deformable meshes with this shape, by calling postUpdate() every time when changing the mesh vertices.
+
+*/
+class btGImpactMeshShape : public btGImpactShapeInterface
+{
+protected:
+	btAlignedObjectArray<btGImpactMeshShapePart*> m_mesh_parts;
+	void buildMeshParts(btStridingMeshInterface * meshInterface)
+	{
+		for (int i=0;i<meshInterface->getNumSubParts() ;++i )
+		{
+			btGImpactMeshShapePart * newpart = new btGImpactMeshShapePart(meshInterface,i);
+			m_mesh_parts.push_back(newpart);
+		}
+	}
+
+	//! use this function for perfofm refit in bounding boxes
+    virtual void calcLocalAABB()
+    {
+    	m_localAABB.invalidate();
+    	int i = m_mesh_parts.size();
+    	while(i--)
+    	{
+    		m_mesh_parts[i]->updateBound();
+    		m_localAABB.merge(m_mesh_parts[i]->getLocalBox());
+    	}
+    }
+
+public:
+	btGImpactMeshShape(btStridingMeshInterface * meshInterface)
+	{
+		buildMeshParts(meshInterface);
+	}
+
+	virtual ~btGImpactMeshShape()
+	{
+		int i = m_mesh_parts.size();
+    	while(i--)
+    	{
+			btGImpactMeshShapePart * part = m_mesh_parts[i];
+			delete part;
+    	}
+		m_mesh_parts.clear();
+	}
+
+
+
+	int getMeshPartCount() const
+	{
+		return m_mesh_parts.size();
+	}
+
+	btGImpactMeshShapePart * getMeshPart(int index)
+	{
+		return m_mesh_parts[index];
+	}
+
+
+
+	const btGImpactMeshShapePart * getMeshPart(int index) const
+	{
+		return m_mesh_parts[index];
+	}
+
+
+	virtual void	setLocalScaling(const btVector3& scaling)
+	{
+		localScaling = scaling;
+
+		int i = m_mesh_parts.size();
+    	while(i--)
+    	{
+			btGImpactMeshShapePart * part = m_mesh_parts[i];
+			part->setLocalScaling(scaling);
+    	}
+
+		m_needs_update = true;
+	}
+
+	virtual void setMargin(btScalar margin)
+    {
+    	m_collisionMargin = margin;
+
+		int i = m_mesh_parts.size();
+    	while(i--)
+    	{
+			btGImpactMeshShapePart * part = m_mesh_parts[i];
+			part->setMargin(margin);
+    	}
+
+		m_needs_update = true;
+    }
+
+	//! Tells to this object that is needed to refit all the meshes
+    virtual void postUpdate()
+    {
+		int i = m_mesh_parts.size();
+    	while(i--)
+    	{
+			btGImpactMeshShapePart * part = m_mesh_parts[i];
+			part->postUpdate();
+    	}
+
+    	m_needs_update = true;
+    }
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+
+
+	//! Obtains the primitive manager
+	virtual const btPrimitiveManagerBase * getPrimitiveManager()  const
+	{
+		btAssert(0);
+		return NULL;
+	}
+
+
+	//! Gets the number of children
+	virtual int	getNumChildShapes() const
+	{
+		btAssert(0);
+		return 0;
+	}
+
+
+	//! if true, then its children must get transforms.
+	virtual bool childrenHasTransform() const
+	{
+		btAssert(0);
+		return false;
+	}
+
+	//! Determines if this shape has triangles
+	virtual bool needsRetrieveTriangles() const
+	{
+		btAssert(0);
+		return false;
+	}
+
+	//! Determines if this shape has tetrahedrons
+	virtual bool needsRetrieveTetrahedrons() const
+	{
+		btAssert(0);
+		return false;
+	}
+
+	virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const
+	{
+		btAssert(0);
+	}
+
+	virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const
+	{
+		btAssert(0);
+	}
+
+	//! call when reading child shapes
+	virtual void lockChildShapes()
+	{
+		btAssert(0);
+	}
+
+	virtual void unlockChildShapes()
+	{
+		btAssert(0);
+	}
+
+
+
+
+	//! Retrieves the bound from a child
+    /*!
+    */
+    virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+    {
+        btAssert(0);
+    }
+
+	//! Gets the children
+	virtual btCollisionShape* getChildShape(int index)
+	{
+		btAssert(0);
+		return NULL;
+	}
+
+
+	//! Gets the child
+	virtual const btCollisionShape* getChildShape(int index) const
+	{
+		btAssert(0);
+		return NULL;
+	}
+
+	//! Gets the children transform
+	virtual btTransform	getChildTransform(int index) const
+	{
+		btAssert(0);
+		return btTransform();
+	}
+
+	//! Sets the children transform
+	/*!
+	\post You must call updateBound() for update the box set.
+	*/
+	virtual void setChildTransform(int index, const btTransform & transform)
+	{
+		btAssert(0);
+	}
+
+
+	virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType()
+	{
+		return CONST_GIMPACT_TRIMESH_SHAPE;
+	}
+
+
+	virtual const char*	getName()const
+	{
+		return "GImpactMesh";
+	}
+
+	virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback)  const;
+
+	//! Function for retrieve triangles.
+	/*!
+	It gives the triangles in local space
+	*/
+	virtual void	processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+};
+
+
+#endif //GIMPACT_MESH_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGenericPoolAllocator.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGenericPoolAllocator.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGenericPoolAllocator.cpp	(revision 2122)
@@ -0,0 +1,283 @@
+/*! \file btGenericPoolAllocator.cpp
+\author Francisco Len Nßjera. email projectileman@yahoo.com
+
+General purpose allocator class
+*/
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btGenericPoolAllocator.h"
+
+
+
+/// *************** btGenericMemoryPool ******************///////////
+
+size_t btGenericMemoryPool::allocate_from_free_nodes(size_t num_elements)
+{
+	size_t ptr = BT_UINT_MAX;
+
+	if(m_free_nodes_count == 0) return BT_UINT_MAX;
+	// find an avaliable free node with the correct size
+	size_t revindex = m_free_nodes_count;
+
+	while(revindex-- && ptr == BT_UINT_MAX)
+	{
+		if(m_allocated_sizes[m_free_nodes[revindex]]>=num_elements)
+		{
+			ptr = revindex;
+		}
+	}
+	if(ptr == BT_UINT_MAX) return BT_UINT_MAX; // not found
+
+
+	revindex = ptr;
+	ptr = m_free_nodes[revindex];
+	// post: ptr contains the node index, and revindex the index in m_free_nodes
+
+	size_t  finalsize = m_allocated_sizes[ptr];
+	finalsize -= num_elements;
+
+	m_allocated_sizes[ptr] = num_elements;
+
+	// post: finalsize>=0, m_allocated_sizes[ptr] has the requested size
+
+	if(finalsize>0) // preserve free node, there are some free memory
+	{
+		m_free_nodes[revindex] = ptr + num_elements;
+		m_allocated_sizes[ptr + num_elements] = finalsize;
+	}
+	else // delete free node
+	{
+		// swap with end
+		m_free_nodes[revindex] = m_free_nodes[m_free_nodes_count-1];
+		m_free_nodes_count--;
+	}
+
+	return ptr;
+}
+
+size_t btGenericMemoryPool::allocate_from_pool(size_t num_elements)
+{
+	if(m_allocated_count+num_elements>m_max_element_count) return BT_UINT_MAX;
+
+	size_t ptr = m_allocated_count;
+
+	m_allocated_sizes[m_allocated_count] = num_elements;
+	m_allocated_count+=num_elements;
+
+	return ptr;
+}
+
+
+void btGenericMemoryPool::init_pool(size_t element_size, size_t element_count)
+{
+	m_allocated_count = 0;
+	m_free_nodes_count = 0;
+
+	m_element_size = element_size;
+	m_max_element_count = element_count;
+
+
+
+
+	m_pool = (unsigned char *) btAlignedAlloc(m_element_size*m_max_element_count,16);
+	m_free_nodes = (size_t *) btAlignedAlloc(sizeof(size_t)*m_max_element_count,16);
+	m_allocated_sizes = (size_t *) btAlignedAlloc(sizeof(size_t)*m_max_element_count,16);
+
+	for (size_t i = 0;i< m_max_element_count;i++ )
+	{
+		m_allocated_sizes[i] = 0;
+	}
+}
+
+void btGenericMemoryPool::end_pool()
+{
+	btAlignedFree(m_pool);
+	btAlignedFree(m_free_nodes);
+	btAlignedFree(m_allocated_sizes);
+	m_allocated_count = 0;
+	m_free_nodes_count = 0;
+}
+
+
+//! Allocates memory in pool
+/*!
+\param size_bytes size in bytes of the buffer
+*/
+void * btGenericMemoryPool::allocate(size_t size_bytes)
+{
+
+	size_t module = size_bytes%m_element_size;
+	size_t element_count = size_bytes/m_element_size;
+	if(module>0) element_count++;
+
+	size_t alloc_pos = allocate_from_free_nodes(element_count);
+	// a free node is found
+	if(alloc_pos != BT_UINT_MAX)
+	{
+		return get_element_data(alloc_pos);
+	}
+	// allocate directly on pool
+	alloc_pos = allocate_from_pool(element_count);
+
+	if(alloc_pos == BT_UINT_MAX) return NULL; // not space
+	return get_element_data(alloc_pos);
+}
+
+bool btGenericMemoryPool::freeMemory(void * pointer)
+{
+	unsigned char * pointer_pos = (unsigned char *)pointer;
+	unsigned char * pool_pos = (unsigned char *)m_pool;
+	// calc offset
+	if(pointer_pos<pool_pos) return false;//other pool
+	size_t offset = size_t(pointer_pos - pool_pos);
+	if(offset>=get_pool_capacity()) return false;// far away
+
+	// find free position
+	m_free_nodes[m_free_nodes_count] = offset/m_element_size;
+	m_free_nodes_count++;
+	return true;
+}
+
+
+/// *******************! btGenericPoolAllocator *******************!///
+
+
+btGenericPoolAllocator::~btGenericPoolAllocator()
+{
+	// destroy pools
+	size_t i;
+	for (i=0;i<m_pool_count;i++)
+	{
+		m_pools[i]->end_pool();
+		btAlignedFree(m_pools[i]);
+	}
+}
+
+
+// creates a pool
+btGenericMemoryPool * btGenericPoolAllocator::push_new_pool()
+{
+	if(m_pool_count >= BT_DEFAULT_MAX_POOLS) return NULL;
+
+	btGenericMemoryPool * newptr = (btGenericMemoryPool *)btAlignedAlloc(sizeof(btGenericMemoryPool),16);
+
+	m_pools[m_pool_count] = newptr;
+
+	m_pools[m_pool_count]->init_pool(m_pool_element_size,m_pool_element_count);
+
+	m_pool_count++;
+	return newptr;
+}
+
+void * btGenericPoolAllocator::failback_alloc(size_t size_bytes)
+{
+
+	btGenericMemoryPool * pool = NULL;
+
+
+	if(size_bytes<=get_pool_capacity())
+	{
+		pool = 	push_new_pool();
+	}
+
+	if(pool==NULL) // failback
+	{
+		return btAlignedAlloc(size_bytes,16);
+	}
+
+	return pool->allocate(size_bytes);
+}
+
+bool btGenericPoolAllocator::failback_free(void * pointer)
+{
+	btAlignedFree(pointer);
+	return true;
+}
+
+
+//! Allocates memory in pool
+/*!
+\param size_bytes size in bytes of the buffer
+*/
+void * btGenericPoolAllocator::allocate(size_t size_bytes)
+{
+	void * ptr = NULL;
+
+	size_t i = 0;
+	while(i<m_pool_count && ptr == NULL)
+	{
+		ptr = m_pools[i]->allocate(size_bytes);
+		++i;
+	}
+
+	if(ptr) return ptr;
+
+	return failback_alloc(size_bytes);
+}
+
+bool btGenericPoolAllocator::freeMemory(void * pointer)
+{
+	bool result = false;
+
+	size_t i = 0;
+	while(i<m_pool_count && result == false)
+	{
+		result = m_pools[i]->freeMemory(pointer);
+		++i;
+	}
+
+	if(result) return true;
+
+	return failback_free(pointer);
+}
+
+/// ************** STANDARD ALLOCATOR ***************************///
+
+
+#define BT_DEFAULT_POOL_SIZE 32768
+#define BT_DEFAULT_POOL_ELEMENT_SIZE 8
+
+// main allocator
+class BT_STANDARD_ALLOCATOR: public btGenericPoolAllocator
+{
+public:
+	BT_STANDARD_ALLOCATOR():btGenericPoolAllocator(BT_DEFAULT_POOL_ELEMENT_SIZE,BT_DEFAULT_POOL_SIZE)
+	{
+	}
+};
+
+// global allocator
+BT_STANDARD_ALLOCATOR g_main_allocator;
+
+
+void * btPoolAlloc(size_t size)
+{
+	return g_main_allocator.allocate(size);
+}
+
+void * btPoolRealloc(void *ptr, size_t oldsize, size_t newsize)
+{
+	void * newptr = btPoolAlloc(newsize);
+    size_t copysize = oldsize<newsize?oldsize:newsize;
+    memcpy(newptr,ptr,copysize);
+    btPoolFree(ptr);
+    return newptr;
+}
+
+void btPoolFree(void *ptr)
+{
+	g_main_allocator.freeMemory(ptr);
+}
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGenericPoolAllocator.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGenericPoolAllocator.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGenericPoolAllocator.h	(revision 2122)
@@ -0,0 +1,168 @@
+/*! \file btGenericPoolAllocator.h
+\author Francisco Len Nßjera. email projectileman@yahoo.com
+
+General purpose allocator class
+*/
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_GENERIC_POOL_ALLOCATOR_H
+#define BT_GENERIC_POOL_ALLOCATOR_H
+
+#include <limits.h>
+#include <stdio.h>
+#include <memory.h>
+#include "LinearMath/btAlignedAllocator.h"
+
+#define BT_UINT_MAX UINT_MAX
+#define BT_DEFAULT_MAX_POOLS 16
+
+
+//! Generic Pool class
+class btGenericMemoryPool
+{
+public:
+	unsigned char * m_pool; //[m_element_size*m_max_element_count];
+	size_t * m_free_nodes; //[m_max_element_count];//! free nodes
+	size_t * m_allocated_sizes;//[m_max_element_count];//! Number of elements allocated per node
+	size_t m_allocated_count;
+	size_t m_free_nodes_count;
+protected:
+	size_t m_element_size;
+	size_t m_max_element_count;
+
+	size_t allocate_from_free_nodes(size_t num_elements);
+	size_t allocate_from_pool(size_t num_elements);
+
+public:
+
+	void init_pool(size_t element_size, size_t element_count);
+
+	void end_pool();
+
+
+	btGenericMemoryPool(size_t element_size, size_t element_count)
+	{
+		init_pool(element_size, element_count);
+	}
+
+	~btGenericMemoryPool()
+	{
+		end_pool();
+	}
+
+
+	inline size_t get_pool_capacity()
+	{
+		return m_element_size*m_max_element_count;
+	}
+
+	inline size_t gem_element_size()
+	{
+		return m_element_size;
+	}
+
+	inline size_t get_max_element_count()
+	{
+		return m_max_element_count;
+	}
+
+	inline size_t get_allocated_count()
+	{
+		return m_allocated_count;
+	}
+
+	inline size_t get_free_positions_count()
+	{
+		return m_free_nodes_count;
+	}
+
+	inline void * get_element_data(size_t element_index)
+	{
+		return &m_pool[element_index*m_element_size];
+	}
+
+	//! Allocates memory in pool
+	/*!
+	\param size_bytes size in bytes of the buffer
+	*/
+	void * allocate(size_t size_bytes);
+
+	bool freeMemory(void * pointer);
+};
+
+
+
+
+//! Generic Allocator with pools
+/*!
+General purpose Allocator which can create Memory Pools dynamiacally as needed.
+*/
+class btGenericPoolAllocator
+{
+protected:
+	size_t m_pool_element_size;
+	size_t m_pool_element_count;
+public:
+	btGenericMemoryPool * m_pools[BT_DEFAULT_MAX_POOLS];
+	size_t m_pool_count;
+
+
+	inline size_t get_pool_capacity()
+	{
+		return m_pool_element_size*m_pool_element_count;
+	}
+
+
+protected:
+	// creates a pool
+	btGenericMemoryPool * push_new_pool();
+
+	void * failback_alloc(size_t size_bytes);
+
+	bool failback_free(void * pointer);
+public:
+
+	btGenericPoolAllocator(size_t pool_element_size, size_t pool_element_count)
+	{
+		m_pool_count = 0;
+		m_pool_element_size = pool_element_size;
+		m_pool_element_count = pool_element_count;
+	}
+
+	virtual ~btGenericPoolAllocator();
+
+	//! Allocates memory in pool
+	/*!
+	\param size_bytes size in bytes of the buffer
+	*/
+	void * allocate(size_t size_bytes);
+
+	bool freeMemory(void * pointer);
+};
+
+
+
+/*! \defgroup POOL_MEMORY_FUNCTIONS
+standar managed Memory functions. Memory pools are used.
+*/
+//! @{
+void * btPoolAlloc(size_t size);
+void * btPoolRealloc(void *ptr, size_t oldsize, size_t newsize);
+void btPoolFree(void *ptr);
+//! @}
+
+
+#endif
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGeometryOperations.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGeometryOperations.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btGeometryOperations.h	(revision 2122)
@@ -0,0 +1,216 @@
+#ifndef BT_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED
+#define BT_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED
+
+/*! \file btGeometryOperations.h
+*\author Francisco Len Nßjera
+
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btBoxCollision.h"
+
+
+
+/*! \defgroup GEOMETRIC_OPERATIONS
+*/
+//! @{
+
+
+#define PLANEDIREPSILON 0.0000001f
+#define PARALELENORMALS 0.000001f
+
+
+#define BT_CLAMP(number,minval,maxval) (number<minval?minval:(number>maxval?maxval:number))
+
+/// Calc a plane from a triangle edge an a normal. plane is a vec4f
+SIMD_FORCE_INLINE void bt_edge_plane(const btVector3 & e1,const btVector3 &  e2, const btVector3 & normal,btVector4 & plane)
+{
+	btVector3 planenormal = (e2-e1).cross(normal);
+	planenormal.normalize();
+	plane.setValue(planenormal[0],planenormal[1],planenormal[2],e2.dot(planenormal));
+}
+
+
+
+//***************** SEGMENT and LINE FUNCTIONS **********************************///
+
+/*! Finds the closest point(cp) to (v) on a segment (e1,e2)
+ */
+SIMD_FORCE_INLINE void bt_closest_point_on_segment(
+	btVector3 & cp, const btVector3 & v,
+	const btVector3  &e1,const btVector3 &e2)
+{
+    btVector3 n = e2-e1;
+    cp = v - e1;
+	btScalar _scalar = cp.dot(n)/n.dot(n);
+	if(_scalar <0.0f)
+	{
+	    cp = e1;
+	}
+	else if(_scalar >1.0f)
+	{
+	    cp = e2;
+	}
+	else
+	{
+		cp = _scalar*n + e1;
+	}
+}
+
+
+//! line plane collision
+/*!
+*\return
+	-0  if the ray never intersects
+	-1 if the ray collides in front
+	-2 if the ray collides in back
+*/
+
+SIMD_FORCE_INLINE int bt_line_plane_collision(
+	const btVector4 & plane,
+	const btVector3 & vDir,
+	const btVector3 & vPoint,
+	btVector3 & pout,
+	btScalar &tparam,
+	btScalar tmin, btScalar tmax)
+{
+
+	btScalar _dotdir = vDir.dot(plane);
+
+	if(btFabs(_dotdir)<PLANEDIREPSILON)
+	{
+		tparam = tmax;
+	    return 0;
+	}
+
+	btScalar _dis = bt_distance_point_plane(plane,vPoint);
+	char returnvalue = _dis<0.0f? 2:1;
+	tparam = -_dis/_dotdir;
+
+	if(tparam<tmin)
+	{
+		returnvalue = 0;
+		tparam = tmin;
+	}
+	else if(tparam>tmax)
+	{
+		returnvalue = 0;
+		tparam = tmax;
+	}
+	pout = tparam*vDir + vPoint;
+	return returnvalue;
+}
+
+
+//! Find closest points on segments
+SIMD_FORCE_INLINE void bt_segment_collision(
+	const btVector3 & vA1,
+	const btVector3 & vA2,
+	const btVector3 & vB1,
+	const btVector3 & vB2,
+	btVector3 & vPointA,
+	btVector3 & vPointB)
+{
+    btVector3 AD = vA2 - vA1;
+    btVector3 BD = vB2 - vB1;
+    btVector3 N = AD.cross(BD);
+    btScalar tp = N.length2();
+
+    btVector4 _M;//plane
+
+    if(tp<SIMD_EPSILON)//ARE PARALELE
+    {
+    	//project B over A
+    	bool invert_b_order = false;
+    	_M[0] = vB1.dot(AD);
+    	_M[1] = vB2.dot(AD);
+
+    	if(_M[0]>_M[1])
+    	{
+    		invert_b_order  = true;
+    		BT_SWAP_NUMBERS(_M[0],_M[1]);
+    	}
+    	_M[2] = vA1.dot(AD);
+    	_M[3] = vA2.dot(AD);
+    	//mid points
+    	N[0] = (_M[0]+_M[1])*0.5f;
+    	N[1] = (_M[2]+_M[3])*0.5f;
+
+    	if(N[0]<N[1])
+    	{
+    		if(_M[1]<_M[2])
+    		{
+    			vPointB = invert_b_order?vB1:vB2;
+    			vPointA = vA1;
+    		}
+    		else if(_M[1]<_M[3])
+    		{
+    			vPointB = invert_b_order?vB1:vB2;
+    			bt_closest_point_on_segment(vPointA,vPointB,vA1,vA2);
+    		}
+    		else
+    		{
+    			vPointA = vA2;
+    			bt_closest_point_on_segment(vPointB,vPointA,vB1,vB2);
+    		}
+    	}
+    	else
+    	{
+    		if(_M[3]<_M[0])
+    		{
+    			vPointB = invert_b_order?vB2:vB1;
+    			vPointA = vA2;
+    		}
+    		else if(_M[3]<_M[1])
+    		{
+    			vPointA = vA2;
+    			bt_closest_point_on_segment(vPointB,vPointA,vB1,vB2);
+    		}
+    		else
+    		{
+    			vPointB = invert_b_order?vB1:vB2;
+    			bt_closest_point_on_segment(vPointA,vPointB,vA1,vA2);
+    		}
+    	}
+    	return;
+    }
+
+    N = N.cross(BD);
+    _M.setValue(N[0],N[1],N[2],vB1.dot(N));
+
+	// get point A as the plane collision point
+    bt_line_plane_collision(_M,AD,vA1,vPointA,tp,btScalar(0), btScalar(1));
+
+    /*Closest point on segment*/
+    vPointB = vPointA - vB1;
+	tp = vPointB.dot(BD);
+	tp/= BD.dot(BD);
+	tp = BT_CLAMP(tp,0.0f,1.0f);
+
+	vPointB = tp*BD + vB1;
+}
+
+
+
+//! @}
+
+
+#endif // GIM_VECTOR_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btQuantization.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btQuantization.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btQuantization.h	(revision 2122)
@@ -0,0 +1,92 @@
+#ifndef BT_QUANTIZATION_H_INCLUDED
+#define BT_QUANTIZATION_H_INCLUDED
+
+/*! \file btQuantization.h
+*\author Francisco Len Nßjera
+
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "LinearMath/btTransform.h"
+
+
+
+/*! \defgroup GEOMETRIC_OPERATIONS
+*/
+//! @{
+
+
+
+SIMD_FORCE_INLINE void bt_calc_quantization_parameters(
+	btVector3 & outMinBound,
+	btVector3 & outMaxBound,
+	btVector3 & bvhQuantization,
+	const btVector3& srcMinBound,const btVector3& srcMaxBound,
+	btScalar quantizationMargin)
+{
+	//enlarge the AABB to avoid division by zero when initializing the quantization values
+	btVector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin);
+	outMinBound = srcMinBound - clampValue;
+	outMaxBound = srcMaxBound + clampValue;
+	btVector3 aabbSize = outMaxBound - outMinBound;
+	bvhQuantization = btVector3(btScalar(65535.0),
+								btScalar(65535.0),
+								btScalar(65535.0)) / aabbSize;
+}
+
+
+SIMD_FORCE_INLINE void bt_quantize_clamp(
+	unsigned short* out,
+	const btVector3& point,
+	const btVector3 & min_bound,
+	const btVector3 & max_bound,
+	const btVector3 & bvhQuantization)
+{
+
+	btVector3 clampedPoint(point);
+	clampedPoint.setMax(min_bound);
+	clampedPoint.setMin(max_bound);
+
+	btVector3 v = (clampedPoint - min_bound) * bvhQuantization;
+	out[0] = (unsigned short)(v.getX()+0.5f);
+	out[1] = (unsigned short)(v.getY()+0.5f);
+	out[2] = (unsigned short)(v.getZ()+0.5f);
+}
+
+
+SIMD_FORCE_INLINE btVector3 bt_unquantize(
+	const unsigned short* vecIn,
+	const btVector3 & offset,
+	const btVector3 & bvhQuantization)
+{
+	btVector3	vecOut;
+	vecOut.setValue(
+		(btScalar)(vecIn[0]) / (bvhQuantization.getX()),
+		(btScalar)(vecIn[1]) / (bvhQuantization.getY()),
+		(btScalar)(vecIn[2]) / (bvhQuantization.getZ()));
+	vecOut += offset;
+	return vecOut;
+}
+
+//! @}
+
+
+#endif // GIM_VECTOR_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btTriangleShapeEx.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btTriangleShapeEx.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btTriangleShapeEx.cpp	(revision 2122)
@@ -0,0 +1,218 @@
+/*! \file btGImpactTriangleShape.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btTriangleShapeEx.h"
+
+
+
+void BT_TRIANGLE_CONTACT::merge_points(const btVector4 & plane,
+                                       btScalar margin, const btVector3 * points, int point_count)
+{
+    m_point_count = 0;
+    m_penetration_depth= -1000.0f;
+
+    int point_indices[MAX_TRI_CLIPPING];
+
+	int _k;
+
+    for ( _k=0;_k<point_count;_k++)
+    {
+        btScalar _dist = - bt_distance_point_plane(plane,points[_k]) + margin;
+
+        if (_dist>=0.0f)
+        {
+            if (_dist>m_penetration_depth)
+            {
+                m_penetration_depth = _dist;
+                point_indices[0] = _k;
+                m_point_count=1;
+            }
+            else if ((_dist+SIMD_EPSILON)>=m_penetration_depth)
+            {
+                point_indices[m_point_count] = _k;
+                m_point_count++;
+            }
+        }
+    }
+
+    for ( _k=0;_k<m_point_count;_k++)
+    {
+        m_points[_k] = points[point_indices[_k]];
+    }
+}
+
+///class btPrimitiveTriangle
+bool btPrimitiveTriangle::overlap_test_conservative(const btPrimitiveTriangle& other)
+{
+    btScalar total_margin = m_margin + other.m_margin;
+    // classify points on other triangle
+    btScalar dis0 = bt_distance_point_plane(m_plane,other.m_vertices[0]) - total_margin;
+
+    btScalar dis1 = bt_distance_point_plane(m_plane,other.m_vertices[1]) - total_margin;
+
+    btScalar dis2 = bt_distance_point_plane(m_plane,other.m_vertices[2]) - total_margin;
+
+    if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false;
+
+    // classify points on this triangle
+    dis0 = bt_distance_point_plane(other.m_plane,m_vertices[0]) - total_margin;
+
+    dis1 = bt_distance_point_plane(other.m_plane,m_vertices[1]) - total_margin;
+
+    dis2 = bt_distance_point_plane(other.m_plane,m_vertices[2]) - total_margin;
+
+    if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false;
+
+    return true;
+}
+
+int btPrimitiveTriangle::clip_triangle(btPrimitiveTriangle & other, btVector3 * clipped_points )
+{
+    // edge 0
+
+    btVector3 temp_points[MAX_TRI_CLIPPING];
+
+
+    btVector4 edgeplane;
+
+    get_edge_plane(0,edgeplane);
+
+
+    int clipped_count = bt_plane_clip_triangle(
+                            edgeplane,other.m_vertices[0],other.m_vertices[1],other.m_vertices[2],temp_points);
+
+    if (clipped_count == 0) return 0;
+
+    btVector3 temp_points1[MAX_TRI_CLIPPING];
+
+
+    // edge 1
+    get_edge_plane(1,edgeplane);
+
+
+    clipped_count = bt_plane_clip_polygon(edgeplane,temp_points,clipped_count,temp_points1);
+
+    if (clipped_count == 0) return 0;
+
+    // edge 2
+    get_edge_plane(2,edgeplane);
+
+    clipped_count = bt_plane_clip_polygon(
+                        edgeplane,temp_points1,clipped_count,clipped_points);
+
+    return clipped_count;
+}
+
+bool btPrimitiveTriangle::find_triangle_collision_clip_method(btPrimitiveTriangle & other, BT_TRIANGLE_CONTACT & contacts)
+{
+    btScalar margin = m_margin + other.m_margin;
+
+    btVector3 clipped_points[MAX_TRI_CLIPPING];
+    int clipped_count;
+    //create planes
+    // plane v vs U points
+
+    BT_TRIANGLE_CONTACT contacts1;
+
+    contacts1.m_separating_normal = m_plane;
+
+
+    clipped_count = clip_triangle(other,clipped_points);
+
+    if (clipped_count == 0 )
+    {
+        return false;//Reject
+    }
+
+    //find most deep interval face1
+    contacts1.merge_points(contacts1.m_separating_normal,margin,clipped_points,clipped_count);
+    if (contacts1.m_point_count == 0) return false; // too far
+    //Normal pointing to this triangle
+    contacts1.m_separating_normal *= -1.f;
+
+
+    //Clip tri1 by tri2 edges
+    BT_TRIANGLE_CONTACT contacts2;
+    contacts2.m_separating_normal = other.m_plane;
+
+    clipped_count = other.clip_triangle(*this,clipped_points);
+
+    if (clipped_count == 0 )
+    {
+        return false;//Reject
+    }
+
+    //find most deep interval face1
+    contacts2.merge_points(contacts2.m_separating_normal,margin,clipped_points,clipped_count);
+    if (contacts2.m_point_count == 0) return false; // too far
+
+
+
+
+    ////check most dir for contacts
+    if (contacts2.m_penetration_depth<contacts1.m_penetration_depth)
+    {
+        contacts.copy_from(contacts2);
+    }
+    else
+    {
+        contacts.copy_from(contacts1);
+    }
+    return true;
+}
+
+
+
+///class btTriangleShapeEx: public btTriangleShape
+
+bool btTriangleShapeEx::overlap_test_conservative(const btTriangleShapeEx& other)
+{
+    btScalar total_margin = getMargin() + other.getMargin();
+
+    btVector4 plane0;
+    buildTriPlane(plane0);
+    btVector4 plane1;
+    other.buildTriPlane(plane1);
+
+    // classify points on other triangle
+    btScalar dis0 = bt_distance_point_plane(plane0,other.m_vertices1[0]) - total_margin;
+
+    btScalar dis1 = bt_distance_point_plane(plane0,other.m_vertices1[1]) - total_margin;
+
+    btScalar dis2 = bt_distance_point_plane(plane0,other.m_vertices1[2]) - total_margin;
+
+    if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false;
+
+    // classify points on this triangle
+    dis0 = bt_distance_point_plane(plane1,m_vertices1[0]) - total_margin;
+
+    dis1 = bt_distance_point_plane(plane1,m_vertices1[1]) - total_margin;
+
+    dis2 = bt_distance_point_plane(plane1,m_vertices1[2]) - total_margin;
+
+    if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false;
+
+    return true;
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btTriangleShapeEx.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btTriangleShapeEx.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/btTriangleShapeEx.h	(revision 2122)
@@ -0,0 +1,180 @@
+/*! \file btGImpactShape.h
+\author Francisco Len Nßjera
+*/
+/*
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef TRIANGLE_SHAPE_EX_H
+#define TRIANGLE_SHAPE_EX_H
+
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "btBoxCollision.h"
+#include "btClipPolygon.h"
+#include "btGeometryOperations.h"
+
+
+#define MAX_TRI_CLIPPING 16
+
+//! Structure for collision
+struct BT_TRIANGLE_CONTACT
+{
+    btScalar m_penetration_depth;
+    int m_point_count;
+    btVector4 m_separating_normal;
+    btVector3 m_points[MAX_TRI_CLIPPING];
+
+	SIMD_FORCE_INLINE void copy_from(const BT_TRIANGLE_CONTACT& other)
+	{
+		m_penetration_depth = other.m_penetration_depth;
+		m_separating_normal = other.m_separating_normal;
+		m_point_count = other.m_point_count;
+		int i = m_point_count;
+		while(i--)
+		{
+			m_points[i] = other.m_points[i];
+		}
+	}
+
+	BT_TRIANGLE_CONTACT()
+	{
+	}
+
+	BT_TRIANGLE_CONTACT(const BT_TRIANGLE_CONTACT& other)
+	{
+		copy_from(other);
+	}
+
+    //! classify points that are closer
+    void merge_points(const btVector4 & plane,
+    				btScalar margin, const btVector3 * points, int point_count);
+
+};
+
+
+
+class btPrimitiveTriangle
+{
+public:
+	btVector3 m_vertices[3];
+	btVector4 m_plane;
+	btScalar m_margin;
+	btScalar m_dummy;
+	btPrimitiveTriangle():m_margin(0.01f)
+	{
+
+	}
+
+
+	SIMD_FORCE_INLINE void buildTriPlane()
+	{
+		btVector3 normal = (m_vertices[1]-m_vertices[0]).cross(m_vertices[2]-m_vertices[0]);
+		normal.normalize();
+		m_plane.setValue(normal[0],normal[1],normal[2],m_vertices[0].dot(normal));
+	}
+
+	//! Test if triangles could collide
+	bool overlap_test_conservative(const btPrimitiveTriangle& other);
+
+	//! Calcs the plane which is paralele to the edge and perpendicular to the triangle plane
+	/*!
+	\pre this triangle must have its plane calculated.
+	*/
+	SIMD_FORCE_INLINE void get_edge_plane(int edge_index, btVector4 &plane)  const
+    {
+		const btVector3 & e0 = m_vertices[edge_index];
+		const btVector3 & e1 = m_vertices[(edge_index+1)%3];
+		bt_edge_plane(e0,e1,m_plane,plane);
+    }
+
+    void applyTransform(const btTransform& t)
+	{
+		m_vertices[0] = t(m_vertices[0]);
+		m_vertices[1] = t(m_vertices[1]);
+		m_vertices[2] = t(m_vertices[2]);
+	}
+
+	//! Clips the triangle against this
+	/*!
+	\pre clipped_points must have MAX_TRI_CLIPPING size, and this triangle must have its plane calculated.
+	\return the number of clipped points
+	*/
+    int clip_triangle(btPrimitiveTriangle & other, btVector3 * clipped_points );
+
+	//! Find collision using the clipping method
+	/*!
+	\pre this triangle and other must have their triangles calculated
+	*/
+    bool find_triangle_collision_clip_method(btPrimitiveTriangle & other, BT_TRIANGLE_CONTACT & contacts);
+};
+
+
+
+//! Helper class for colliding Bullet Triangle Shapes
+/*!
+This class implements a better getAabb method than the previous btTriangleShape class
+*/
+class btTriangleShapeEx: public btTriangleShape
+{
+public:
+
+	btTriangleShapeEx():btTriangleShape(btVector3(0,0,0),btVector3(0,0,0),btVector3(0,0,0))
+	{
+	}
+
+	btTriangleShapeEx(const btVector3& p0,const btVector3& p1,const btVector3& p2):	btTriangleShape(p0,p1,p2)
+	{
+	}
+
+	btTriangleShapeEx(const btTriangleShapeEx & other):	btTriangleShape(other.m_vertices1[0],other.m_vertices1[1],other.m_vertices1[2])
+	{
+	}
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const
+	{
+		btVector3 tv0 = t(m_vertices1[0]);
+		btVector3 tv1 = t(m_vertices1[1]);
+		btVector3 tv2 = t(m_vertices1[2]);
+
+		btAABB trianglebox(tv0,tv1,tv2,m_collisionMargin);
+		aabbMin = trianglebox.m_min;
+		aabbMax = trianglebox.m_max;
+	}
+
+	void applyTransform(const btTransform& t)
+	{
+		m_vertices1[0] = t(m_vertices1[0]);
+		m_vertices1[1] = t(m_vertices1[1]);
+		m_vertices1[2] = t(m_vertices1[2]);
+	}
+
+	SIMD_FORCE_INLINE void buildTriPlane(btVector4 & plane) const
+	{
+		btVector3 normal = (m_vertices1[1]-m_vertices1[0]).cross(m_vertices1[2]-m_vertices1[0]);
+		normal.normalize();
+		plane.setValue(normal[0],normal[1],normal[2],m_vertices1[0].dot(normal));
+	}
+
+	bool overlap_test_conservative(const btTriangleShapeEx& other);
+};
+
+
+#endif //TRIANGLE_MESH_SHAPE_H
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_array.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_array.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_array.h	(revision 2122)
@@ -0,0 +1,332 @@
+#ifndef GIM_ARRAY_H_INCLUDED
+#define GIM_ARRAY_H_INCLUDED
+/*! \file gim_array.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "gim_memory.h"
+
+/*! \addtogroup CONTAINERS
+\brief
+Abstract class for template containers
+*/
+//! @{
+
+#define GIM_ARRAY_GROW_INCREMENT 2
+#define GIM_ARRAY_GROW_FACTOR 2
+
+//!	Very simple array container with fast access and simd memory
+template<typename T>
+class gim_array
+{
+public:
+//! properties
+//!@{
+    T *m_data;
+    GUINT m_size;
+    GUINT m_allocated_size;
+//!@}
+//! protected operations
+//!@{
+
+    inline void destroyData()
+	{
+	    m_allocated_size = 0;
+		if(m_data==NULL) return;
+		gim_free(m_data);
+		m_data = NULL;
+	}
+
+	inline bool resizeData(GUINT newsize)
+	{
+		if(newsize==0)
+		{
+			destroyData();
+			return true;
+		}
+
+		if(m_size>0)
+		{
+            m_data = (T*)gim_realloc(m_data,m_size*sizeof(T),newsize*sizeof(T));
+		}
+		else
+		{
+		    m_data = (T*)gim_alloc(newsize*sizeof(T));
+		}
+		m_allocated_size = newsize;
+		return true;
+	}
+
+	inline bool growingCheck()
+	{
+		if(m_allocated_size<=m_size)
+		{
+		    GUINT requestsize = m_size;
+		    m_size = m_allocated_size;
+			if(resizeData((requestsize+GIM_ARRAY_GROW_INCREMENT)*GIM_ARRAY_GROW_FACTOR)==false) return false;
+		}
+		return true;
+	}
+
+//!@}
+//! public operations
+//!@{
+    inline  bool reserve(GUINT size)
+    {
+        if(m_allocated_size>=size) return false;
+        return resizeData(size);
+    }
+
+    inline void clear_range(GUINT start_range)
+    {
+        while(m_size>start_range)
+        {
+            m_data[--m_size].~T();
+        }
+    }
+
+    inline void clear()
+    {
+        if(m_size==0)return;
+        clear_range(0);
+    }
+
+    inline void clear_memory()
+    {
+        clear();
+        destroyData();
+    }
+
+    gim_array()
+    {
+        m_data = 0;
+        m_size = 0;
+        m_allocated_size = 0;
+    }
+
+    gim_array(GUINT reservesize)
+    {
+        m_data = 0;
+        m_size = 0;
+
+        m_allocated_size = 0;
+        reserve(reservesize);
+    }
+
+    ~gim_array()
+    {
+        clear_memory();
+    }
+
+    inline GUINT size() const
+    {
+        return m_size;
+    }
+
+    inline GUINT max_size() const
+    {
+        return m_allocated_size;
+    }
+
+    inline T & operator[](size_t i)
+	{
+		return m_data[i];
+	}
+	inline  const T & operator[](size_t i) const
+	{
+		return m_data[i];
+	}
+
+    inline T * pointer(){ return m_data;}
+    inline const T * pointer() const
+    { return m_data;}
+
+
+    inline T * get_pointer_at(GUINT i)
+	{
+		return m_data + i;
+	}
+
+	inline const T * get_pointer_at(GUINT i) const
+	{
+		return m_data + i;
+	}
+
+	inline T & at(GUINT i)
+	{
+		return m_data[i];
+	}
+
+	inline const T & at(GUINT i) const
+	{
+		return m_data[i];
+	}
+
+	inline T & front()
+	{
+		return *m_data;
+	}
+
+	inline const T & front() const
+	{
+		return *m_data;
+	}
+
+	inline T & back()
+	{
+		return m_data[m_size-1];
+	}
+
+	inline const T & back() const
+	{
+		return m_data[m_size-1];
+	}
+
+
+	inline void swap(GUINT i, GUINT j)
+	{
+	    gim_swap_elements(m_data,i,j);
+	}
+
+	inline void push_back(const T & obj)
+	{
+	    this->growingCheck();
+	    m_data[m_size] = obj;
+	    m_size++;
+	}
+
+	//!Simply increase the m_size, doesn't call the new element constructor
+	inline void push_back_mem()
+	{
+	    this->growingCheck();
+	    m_size++;
+	}
+
+	inline void push_back_memcpy(const T & obj)
+	{
+	    this->growingCheck();
+	    irr_simd_memcpy(&m_data[m_size],&obj,sizeof(T));
+	    m_size++;
+	}
+
+	inline void pop_back()
+	{
+	    m_size--;
+        m_data[m_size].~T();
+	}
+
+	//!Simply decrease the m_size, doesn't call the deleted element destructor
+	inline void pop_back_mem()
+	{
+	    m_size--;
+	}
+
+    //! fast erase
+	inline void erase(GUINT index)
+	{
+	    if(index<m_size-1)
+	    {
+	        swap(index,m_size-1);
+	    }
+	    pop_back();
+	}
+
+	inline void erase_sorted_mem(GUINT index)
+	{
+	    m_size--;
+	    for(GUINT i = index;i<m_size;i++)
+	    {
+	        gim_simd_memcpy(m_data+i,m_data+i+1,sizeof(T));
+	    }
+	}
+
+	inline void erase_sorted(GUINT index)
+	{
+	    m_data[index].~T();
+	    erase_sorted_mem(index);
+	}
+
+	inline void insert_mem(GUINT index)
+	{
+	    this->growingCheck();
+	    for(GUINT i = m_size;i>index;i--)
+	    {
+	        gim_simd_memcpy(m_data+i,m_data+i-1,sizeof(T));
+	    }
+	    m_size++;
+	}
+
+	inline void insert(const T & obj,GUINT index)
+	{
+	    insert_mem(index);
+	    m_data[index] = obj;
+	}
+
+	inline void resize(GUINT size, bool call_constructor = true)
+	{
+
+	    if(size>m_size)
+	    {
+            reserve(size);
+            if(call_constructor)
+            {
+            	T obj;
+                while(m_size<size)
+                {
+                    m_data[m_size] = obj;
+                    m_size++;
+                }
+            }
+            else
+            {
+            	m_size = size;
+            }
+	    }
+	    else if(size<m_size)
+	    {
+	        if(call_constructor) clear_range(size);
+	        m_size = size;
+	    }
+	}
+
+	inline void refit()
+	{
+	    resizeData(m_size);
+	}
+//!@}
+};
+
+
+//! @}
+
+
+
+#endif // GIM_CONTAINERS_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_basic_geometry_operations.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_basic_geometry_operations.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_basic_geometry_operations.h	(revision 2122)
@@ -0,0 +1,547 @@
+#ifndef GIM_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED
+#define GIM_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED
+
+/*! \file gim_basic_geometry_operations.h
+*\author Francisco Len Nßjera
+type independant geometry routines
+
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "gim_linear_math.h"
+
+
+
+/*! \defgroup GEOMETRIC_OPERATIONS
+*/
+//! @{
+
+
+#define PLANEDIREPSILON 0.0000001f
+#define PARALELENORMALS 0.000001f
+
+
+#define TRIANGLE_NORMAL(v1,v2,v3,n)\
+{\
+	vec3f _dif1,_dif2;\
+    VEC_DIFF(_dif1,v2,v1);\
+    VEC_DIFF(_dif2,v3,v1);\
+    VEC_CROSS(n,_dif1,_dif2);\
+    VEC_NORMALIZE(n);\
+}\
+
+#define TRIANGLE_NORMAL_FAST(v1,v2,v3,n){\
+    vec3f _dif1,_dif2; \
+    VEC_DIFF(_dif1,v2,v1); \
+    VEC_DIFF(_dif2,v3,v1); \
+    VEC_CROSS(n,_dif1,_dif2); \
+}\
+
+/// plane is a vec4f
+#define TRIANGLE_PLANE(v1,v2,v3,plane) {\
+    TRIANGLE_NORMAL(v1,v2,v3,plane);\
+    plane[3] = VEC_DOT(v1,plane);\
+}\
+
+/// plane is a vec4f
+#define TRIANGLE_PLANE_FAST(v1,v2,v3,plane) {\
+    TRIANGLE_NORMAL_FAST(v1,v2,v3,plane);\
+    plane[3] = VEC_DOT(v1,plane);\
+}\
+
+/// Calc a plane from an edge an a normal. plane is a vec4f
+#define EDGE_PLANE(e1,e2,n,plane) {\
+    vec3f _dif; \
+    VEC_DIFF(_dif,e2,e1); \
+    VEC_CROSS(plane,_dif,n); \
+    VEC_NORMALIZE(plane); \
+    plane[3] = VEC_DOT(e1,plane);\
+}\
+
+#define DISTANCE_PLANE_POINT(plane,point) (VEC_DOT(plane,point) - plane[3])
+
+#define PROJECT_POINT_PLANE(point,plane,projected) {\
+	GREAL _dis;\
+	_dis = DISTANCE_PLANE_POINT(plane,point);\
+	VEC_SCALE(projected,-_dis,plane);\
+	VEC_SUM(projected,projected,point);	\
+}\
+
+//! Verifies if a point is in the plane hull
+template<typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE bool POINT_IN_HULL(
+	const CLASS_POINT& point,const CLASS_PLANE * planes,GUINT plane_count)
+{
+	GREAL _dis;
+	for (GUINT _i = 0;_i< plane_count;++_i)
+	{
+		_dis = DISTANCE_PLANE_POINT(planes[_i],point);
+	    if(_dis>0.0f) return false;
+	}
+	return true;
+}
+
+template<typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE void PLANE_CLIP_SEGMENT(
+	const CLASS_POINT& s1,
+	const CLASS_POINT &s2,const CLASS_PLANE &plane,CLASS_POINT &clipped)
+{
+	GREAL _dis1,_dis2;
+	_dis1 = DISTANCE_PLANE_POINT(plane,s1);
+	VEC_DIFF(clipped,s2,s1);
+	_dis2 = VEC_DOT(clipped,plane);
+	VEC_SCALE(clipped,-_dis1/_dis2,clipped);
+	VEC_SUM(clipped,clipped,s1);
+}
+
+enum ePLANE_INTERSECTION_TYPE
+{
+	G_BACK_PLANE = 0,
+	G_COLLIDE_PLANE,
+	G_FRONT_PLANE
+};
+
+enum eLINE_PLANE_INTERSECTION_TYPE
+{
+	G_FRONT_PLANE_S1 = 0,
+	G_FRONT_PLANE_S2,
+	G_BACK_PLANE_S1,
+	G_BACK_PLANE_S2,
+	G_COLLIDE_PLANE_S1,
+	G_COLLIDE_PLANE_S2
+};
+
+//! Confirms if the plane intersect the edge or nor
+/*!
+intersection type must have the following values
+<ul>
+<li> 0 : Segment in front of plane, s1 closest
+<li> 1 : Segment in front of plane, s2 closest
+<li> 2 : Segment in back of plane, s1 closest
+<li> 3 : Segment in back of plane, s2 closest
+<li> 4 : Segment collides plane, s1 in back
+<li> 5 : Segment collides plane, s2 in back
+</ul>
+*/
+
+template<typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE PLANE_CLIP_SEGMENT2(
+	const CLASS_POINT& s1,
+	const CLASS_POINT &s2,
+	const CLASS_PLANE &plane,CLASS_POINT &clipped)
+{
+	GREAL _dis1 = DISTANCE_PLANE_POINT(plane,s1);
+	GREAL _dis2 = DISTANCE_PLANE_POINT(plane,s2);
+	if(_dis1 >-G_EPSILON && _dis2 >-G_EPSILON)
+	{
+	    if(_dis1<_dis2) return G_FRONT_PLANE_S1;
+	    return G_FRONT_PLANE_S2;
+	}
+	else if(_dis1 <G_EPSILON && _dis2 <G_EPSILON)
+	{
+	    if(_dis1>_dis2) return G_BACK_PLANE_S1;
+	    return G_BACK_PLANE_S2;
+	}
+
+	VEC_DIFF(clipped,s2,s1);
+	_dis2 = VEC_DOT(clipped,plane);
+	VEC_SCALE(clipped,-_dis1/_dis2,clipped);
+	VEC_SUM(clipped,clipped,s1);
+	if(_dis1<_dis2) return G_COLLIDE_PLANE_S1;
+	return G_COLLIDE_PLANE_S2;
+}
+
+//! Confirms if the plane intersect the edge or not
+/*!
+clipped1 and clipped2 are the vertices behind the plane.
+clipped1 is the closest
+
+intersection_type must have the following values
+<ul>
+<li> 0 : Segment in front of plane, s1 closest
+<li> 1 : Segment in front of plane, s2 closest
+<li> 2 : Segment in back of plane, s1 closest
+<li> 3 : Segment in back of plane, s2 closest
+<li> 4 : Segment collides plane, s1 in back
+<li> 5 : Segment collides plane, s2 in back
+</ul>
+*/
+template<typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE PLANE_CLIP_SEGMENT_CLOSEST(
+	const CLASS_POINT& s1,
+	const CLASS_POINT &s2,
+	const CLASS_PLANE &plane,
+	CLASS_POINT &clipped1,CLASS_POINT &clipped2)
+{
+	eLINE_PLANE_INTERSECTION_TYPE intersection_type = PLANE_CLIP_SEGMENT2(s1,s2,plane,clipped1);
+	switch(intersection_type)
+	{
+	case G_FRONT_PLANE_S1:
+		VEC_COPY(clipped1,s1);
+	    VEC_COPY(clipped2,s2);
+		break;
+	case G_FRONT_PLANE_S2:
+		VEC_COPY(clipped1,s2);
+	    VEC_COPY(clipped2,s1);
+		break;
+	case G_BACK_PLANE_S1:
+		VEC_COPY(clipped1,s1);
+	    VEC_COPY(clipped2,s2);
+		break;
+	case G_BACK_PLANE_S2:
+		VEC_COPY(clipped1,s2);
+	    VEC_COPY(clipped2,s1);
+		break;
+	case G_COLLIDE_PLANE_S1:
+		VEC_COPY(clipped2,s1);
+		break;
+	case G_COLLIDE_PLANE_S2:
+		VEC_COPY(clipped2,s2);
+		break;
+	}
+	return intersection_type;
+}
+
+
+//! Finds the 2 smallest cartesian coordinates of a plane normal
+#define PLANE_MINOR_AXES(plane, i0, i1) VEC_MINOR_AXES(plane, i0, i1)
+
+//! Ray plane collision in one way
+/*!
+Intersects plane in one way only. The ray must face the plane (normals must be in opossite directions).<br/>
+It uses the PLANEDIREPSILON constant.
+*/
+template<typename T,typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE bool RAY_PLANE_COLLISION(
+	const CLASS_PLANE & plane,
+	const CLASS_POINT & vDir,
+	const CLASS_POINT & vPoint,
+	CLASS_POINT & pout,T &tparam)
+{
+	GREAL _dis,_dotdir;
+	_dotdir = VEC_DOT(plane,vDir);
+	if(_dotdir<PLANEDIREPSILON)
+	{
+	    return false;
+	}
+	_dis = DISTANCE_PLANE_POINT(plane,vPoint);
+	tparam = -_dis/_dotdir;
+	VEC_SCALE(pout,tparam,vDir);
+	VEC_SUM(pout,vPoint,pout);
+	return true;
+}
+
+//! line collision
+/*!
+*\return
+	-0  if the ray never intersects
+	-1 if the ray collides in front
+	-2 if the ray collides in back
+*/
+template<typename T,typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE GUINT LINE_PLANE_COLLISION(
+	const CLASS_PLANE & plane,
+	const CLASS_POINT & vDir,
+	const CLASS_POINT & vPoint,
+	CLASS_POINT & pout,
+	T &tparam,
+	T tmin, T tmax)
+{
+	GREAL _dis,_dotdir;
+	_dotdir = VEC_DOT(plane,vDir);
+	if(btFabs(_dotdir)<PLANEDIREPSILON)
+	{
+		tparam = tmax;
+	    return 0;
+	}
+	_dis = DISTANCE_PLANE_POINT(plane,vPoint);
+	char returnvalue = _dis<0.0f?2:1;
+	tparam = -_dis/_dotdir;
+
+	if(tparam<tmin)
+	{
+		returnvalue = 0;
+		tparam = tmin;
+	}
+	else if(tparam>tmax)
+	{
+		returnvalue = 0;
+		tparam = tmax;
+	}
+
+	VEC_SCALE(pout,tparam,vDir);
+	VEC_SUM(pout,vPoint,pout);
+	return returnvalue;
+}
+
+/*! \brief Returns the Ray on which 2 planes intersect if they do.
+    Written by Rodrigo Hernandez on ODE convex collision
+
+  \param p1 Plane 1
+  \param p2 Plane 2
+  \param p Contains the origin of the ray upon returning if planes intersect
+  \param d Contains the direction of the ray upon returning if planes intersect
+  \return true if the planes intersect, 0 if paralell.
+
+*/
+template<typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE bool INTERSECT_PLANES(
+		const CLASS_PLANE &p1,
+		const CLASS_PLANE &p2,
+		CLASS_POINT &p,
+		CLASS_POINT &d)
+{
+	VEC_CROSS(d,p1,p2);
+  	GREAL denom = VEC_DOT(d, d);
+  	if(GIM_IS_ZERO(denom)) return false;
+	vec3f _n;
+	_n[0]=p1[3]*p2[0] - p2[3]*p1[0];
+	_n[1]=p1[3]*p2[1] - p2[3]*p1[1];
+	_n[2]=p1[3]*p2[2] - p2[3]*p1[2];
+	VEC_CROSS(p,_n,d);
+	p[0]/=denom;
+	p[1]/=denom;
+	p[2]/=denom;
+	return true;
+}
+
+//***************** SEGMENT and LINE FUNCTIONS **********************************///
+
+/*! Finds the closest point(cp) to (v) on a segment (e1,e2)
+ */
+template<typename CLASS_POINT>
+SIMD_FORCE_INLINE void CLOSEST_POINT_ON_SEGMENT(
+	CLASS_POINT & cp, const CLASS_POINT & v,
+	const CLASS_POINT &e1,const CLASS_POINT &e2)
+{
+    vec3f _n;
+    VEC_DIFF(_n,e2,e1);
+    VEC_DIFF(cp,v,e1);
+	GREAL _scalar = VEC_DOT(cp, _n);
+	_scalar/= VEC_DOT(_n, _n);
+	if(_scalar <0.0f)
+	{
+	    VEC_COPY(cp,e1);
+	}
+	else if(_scalar >1.0f)
+	{
+	    VEC_COPY(cp,e2);
+	}
+	else
+	{
+        VEC_SCALE(cp,_scalar,_n);
+        VEC_SUM(cp,cp,e1);
+	}
+}
+
+
+/*! \brief Finds the line params where these lines intersect.
+
+\param dir1 Direction of line 1
+\param point1 Point of line 1
+\param dir2 Direction of line 2
+\param point2 Point of line 2
+\param t1 Result Parameter for line 1
+\param t2 Result Parameter for line 2
+\param dointersect  0  if the lines won't intersect, else 1
+
+*/
+template<typename T,typename CLASS_POINT>
+SIMD_FORCE_INLINE bool LINE_INTERSECTION_PARAMS(
+	const CLASS_POINT & dir1,
+	CLASS_POINT & point1,
+	const CLASS_POINT & dir2,
+	CLASS_POINT &  point2,
+	T& t1,T& t2)
+{
+    GREAL det;
+	GREAL e1e1 = VEC_DOT(dir1,dir1);
+	GREAL e1e2 = VEC_DOT(dir1,dir2);
+	GREAL e2e2 = VEC_DOT(dir2,dir2);
+	vec3f p1p2;
+    VEC_DIFF(p1p2,point1,point2);
+    GREAL p1p2e1 = VEC_DOT(p1p2,dir1);
+	GREAL p1p2e2 = VEC_DOT(p1p2,dir2);
+	det = e1e2*e1e2 - e1e1*e2e2;
+	if(GIM_IS_ZERO(det)) return false;
+	t1 = (e1e2*p1p2e2 - e2e2*p1p2e1)/det;
+	t2 = (e1e1*p1p2e2 - e1e2*p1p2e1)/det;
+	return true;
+}
+
+//! Find closest points on segments
+template<typename CLASS_POINT>
+SIMD_FORCE_INLINE void SEGMENT_COLLISION(
+	const CLASS_POINT & vA1,
+	const CLASS_POINT & vA2,
+	const CLASS_POINT & vB1,
+	const CLASS_POINT & vB2,
+	CLASS_POINT & vPointA,
+	CLASS_POINT & vPointB)
+{
+    CLASS_POINT _AD,_BD,_N;
+    vec4f _M;//plane
+    VEC_DIFF(_AD,vA2,vA1);
+    VEC_DIFF(_BD,vB2,vB1);
+    VEC_CROSS(_N,_AD,_BD);
+    GREAL _tp = VEC_DOT(_N,_N);
+    if(_tp<G_EPSILON)//ARE PARALELE
+    {
+    	//project B over A
+    	bool invert_b_order = false;
+    	_M[0] = VEC_DOT(vB1,_AD);
+    	_M[1] = VEC_DOT(vB2,_AD);
+    	if(_M[0]>_M[1])
+    	{
+    		invert_b_order  = true;
+    		GIM_SWAP_NUMBERS(_M[0],_M[1]);
+    	}
+    	_M[2] = VEC_DOT(vA1,_AD);
+    	_M[3] = VEC_DOT(vA2,_AD);
+    	//mid points
+    	_N[0] = (_M[0]+_M[1])*0.5f;
+    	_N[1] = (_M[2]+_M[3])*0.5f;
+
+    	if(_N[0]<_N[1])
+    	{
+    		if(_M[1]<_M[2])
+    		{
+    			vPointB = invert_b_order?vB1:vB2;
+    			vPointA = vA1;
+    		}
+    		else if(_M[1]<_M[3])
+    		{
+    			vPointB = invert_b_order?vB1:vB2;
+    			CLOSEST_POINT_ON_SEGMENT(vPointA,vPointB,vA1,vA2);
+    		}
+    		else
+    		{
+    			vPointA = vA2;
+    			CLOSEST_POINT_ON_SEGMENT(vPointB,vPointA,vB1,vB2);
+    		}
+    	}
+    	else
+    	{
+    		if(_M[3]<_M[0])
+    		{
+    			vPointB = invert_b_order?vB2:vB1;
+    			vPointA = vA2;
+    		}
+    		else if(_M[3]<_M[1])
+    		{
+    			vPointA = vA2;
+    			CLOSEST_POINT_ON_SEGMENT(vPointB,vPointA,vB1,vB2);
+    		}
+    		else
+    		{
+    			vPointB = invert_b_order?vB1:vB2;
+    			CLOSEST_POINT_ON_SEGMENT(vPointA,vPointB,vA1,vA2);
+    		}
+    	}
+    	return;
+    }
+
+
+    VEC_CROSS(_M,_N,_BD);
+    _M[3] = VEC_DOT(_M,vB1);
+
+    LINE_PLANE_COLLISION(_M,_AD,vA1,vPointA,_tp,btScalar(0), btScalar(1));
+    /*Closest point on segment*/
+    VEC_DIFF(vPointB,vPointA,vB1);
+	_tp = VEC_DOT(vPointB, _BD);
+	_tp/= VEC_DOT(_BD, _BD);
+	_tp = GIM_CLAMP(_tp,0.0f,1.0f);
+    VEC_SCALE(vPointB,_tp,_BD);
+    VEC_SUM(vPointB,vPointB,vB1);
+}
+
+
+
+
+//! Line box intersection in one dimension
+/*!
+
+*\param pos Position of the ray
+*\param dir Projection of the Direction of the ray
+*\param bmin Minimum bound of the box
+*\param bmax Maximum bound of the box
+*\param tfirst the minimum projection. Assign to 0 at first.
+*\param tlast the maximum projection. Assign to INFINITY at first.
+*\return true if there is an intersection.
+*/
+template<typename T>
+SIMD_FORCE_INLINE bool BOX_AXIS_INTERSECT(T pos, T dir,T bmin, T bmax, T & tfirst, T & tlast)
+{
+	if(GIM_IS_ZERO(dir))
+	{
+        return !(pos < bmin || pos > bmax);
+	}
+	GREAL a0 = (bmin - pos) / dir;
+	GREAL a1 = (bmax - pos) / dir;
+	if(a0 > a1)   GIM_SWAP_NUMBERS(a0, a1);
+	tfirst = GIM_MAX(a0, tfirst);
+	tlast = GIM_MIN(a1, tlast);
+	if (tlast < tfirst) return false;
+	return true;
+}
+
+
+//! Sorts 3 componets
+template<typename T>
+SIMD_FORCE_INLINE void SORT_3_INDICES(
+		const T * values,
+		GUINT * order_indices)
+{
+	//get minimum
+	order_indices[0] = values[0] < values[1] ? (values[0] < values[2] ? 0 : 2) : (values[1] < values[2] ? 1 : 2);
+
+	//get second and third
+	GUINT i0 = (order_indices[0] + 1)%3;
+	GUINT i1 = (i0 + 1)%3;
+
+	if(values[i0] < values[i1])
+	{
+		order_indices[1] = i0;
+		order_indices[2] = i1;
+	}
+	else
+	{
+		order_indices[1] = i1;
+		order_indices[2] = i0;
+	}
+}
+
+
+
+//! @}
+
+
+#endif // GIM_VECTOR_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_bitset.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_bitset.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_bitset.h	(revision 2122)
@@ -0,0 +1,129 @@
+#ifndef GIM_BITSET_H_INCLUDED
+#define GIM_BITSET_H_INCLUDED
+/*! \file gim_bitset.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "gim_array.h"
+
+/*! \addtogroup CONTAINERS
+\brief
+Abstract class for template containers
+*/
+//! @{
+
+#define GUINT_BIT_COUNT 32
+#define GUINT_EXPONENT 5
+
+class gim_bitset
+{
+public:
+    gim_array<GUINT> m_container;
+
+    gim_bitset()
+    {
+
+    }
+
+    gim_bitset(GUINT bits_count)
+    {
+        resize(bits_count);
+    }
+
+    ~gim_bitset()
+    {
+    }
+
+	inline bool resize(GUINT newsize)
+	{
+		GUINT oldsize = m_container.size();
+		m_container.resize(newsize/GUINT_BIT_COUNT + 1,false);
+		while(oldsize<m_container.size())
+		{
+			m_container[oldsize] = 0;
+		}
+		return true;
+	}
+
+	inline GUINT size()
+	{
+		return m_container.size()*GUINT_BIT_COUNT;
+	}
+
+	inline void set_all()
+	{
+		for(GUINT i = 0;i<m_container.size();++i)
+		{
+			m_container[i] = 0xffffffff;
+		}
+	}
+
+	inline void clear_all()
+	{
+	    for(GUINT i = 0;i<m_container.size();++i)
+		{
+			m_container[i] = 0;
+		}
+	}
+
+	inline void set(GUINT bit_index)
+	{
+		if(bit_index>=size())
+		{
+			resize(bit_index);
+		}
+		m_container[bit_index >> GUINT_EXPONENT] |= (1 << (bit_index & (GUINT_BIT_COUNT-1)));
+	}
+
+	///Return 0 or 1
+	inline char get(GUINT bit_index)
+	{
+		if(bit_index>=size())
+		{
+			return 0;
+		}
+		char value = m_container[bit_index >> GUINT_EXPONENT] &
+					 (1 << (bit_index & (GUINT_BIT_COUNT-1)));
+		return value;
+	}
+
+	inline void clear(GUINT bit_index)
+	{
+	    m_container[bit_index >> GUINT_EXPONENT] &= ~(1 << (bit_index & (GUINT_BIT_COUNT-1)));
+	}
+};
+
+
+//! @}
+
+
+
+#endif // GIM_CONTAINERS_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_collision.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_collision.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_collision.h	(revision 2122)
@@ -0,0 +1,594 @@
+#ifndef GIM_BOX_COLLISION_H_INCLUDED
+#define GIM_BOX_COLLISION_H_INCLUDED
+
+/*! \file gim_box_collision.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+#include "gim_basic_geometry_operations.h"
+#include "LinearMath/btTransform.h"
+
+/*! \defgroup BOUND_AABB_OPERATIONS
+*/
+//! @{
+
+
+//SIMD_FORCE_INLINE bool test_cross_edge_box(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, const btVector3 & extend,
+//	int dir_index0,
+//	int dir_index1
+//	int component_index0,
+//	int component_index1)
+//{
+//	// dir coords are -z and y
+//
+//	const btScalar dir0 = -edge[dir_index0];
+//	const btScalar dir1 = edge[dir_index1];
+//	btScalar pmin = pointa[component_index0]*dir0 + pointa[component_index1]*dir1;
+//	btScalar pmax = pointb[component_index0]*dir0 + pointb[component_index1]*dir1;
+//	//find minmax
+//	if(pmin>pmax)
+//	{
+//		GIM_SWAP_NUMBERS(pmin,pmax);
+//	}
+//	//find extends
+//	const btScalar rad = extend[component_index0] * absolute_edge[dir_index0] +
+//					extend[component_index1] * absolute_edge[dir_index1];
+//
+//	if(pmin>rad || -rad>pmax) return false;
+//	return true;
+//}
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_X_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,2,1,1,2);
+//}
+//
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_Y_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,0,2,2,0);
+//}
+//
+//SIMD_FORCE_INLINE bool test_cross_edge_box_Z_axis(
+//	const btVector3 & edge,
+//	const btVector3 & absolute_edge,
+//	const btVector3 & pointa,
+//	const btVector3 & pointb, btVector3 & extend)
+//{
+//
+//	return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,1,0,0,1);
+//}
+
+#define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\
+{\
+	const btScalar dir0 = -edge[i_dir_0];\
+	const btScalar dir1 = edge[i_dir_1];\
+	btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\
+	btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\
+	if(pmin>pmax)\
+	{\
+		GIM_SWAP_NUMBERS(pmin,pmax); \
+	}\
+	const btScalar abs_dir0 = absolute_edge[i_dir_0];\
+	const btScalar abs_dir1 = absolute_edge[i_dir_1];\
+	const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\
+	if(pmin>rad || -rad>pmax) return false;\
+}\
+
+
+#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\
+}\
+
+#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\
+}\
+
+#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
+{\
+	TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\
+}\
+
+
+
+//!  Class for transforming a model1 to the space of model0
+class GIM_BOX_BOX_TRANSFORM_CACHE
+{
+public:
+    btVector3  m_T1to0;//!< Transforms translation of model1 to model 0
+	btMatrix3x3 m_R1to0;//!< Transforms Rotation of model1 to model 0, equal  to R0' * R1
+	btMatrix3x3 m_AR;//!< Absolute value of m_R1to0
+
+	SIMD_FORCE_INLINE void calc_absolute_matrix()
+	{
+		static const btVector3 vepsi(1e-6f,1e-6f,1e-6f);
+		m_AR[0] = vepsi + m_R1to0[0].absolute();
+		m_AR[1] = vepsi + m_R1to0[1].absolute();
+		m_AR[2] = vepsi + m_R1to0[2].absolute();
+	}
+
+	GIM_BOX_BOX_TRANSFORM_CACHE()
+	{
+	}
+
+
+	GIM_BOX_BOX_TRANSFORM_CACHE(mat4f  trans1_to_0)
+	{
+		COPY_MATRIX_3X3(m_R1to0,trans1_to_0)
+        MAT_GET_TRANSLATION(trans1_to_0,m_T1to0)
+		calc_absolute_matrix();
+	}
+
+	//! Calc the transformation relative  1 to 0. Inverts matrics by transposing
+	SIMD_FORCE_INLINE void calc_from_homogenic(const btTransform & trans0,const btTransform & trans1)
+	{
+
+		m_R1to0 = trans0.getBasis().transpose();
+		m_T1to0 = m_R1to0 * (-trans0.getOrigin());
+
+		m_T1to0 += m_R1to0*trans1.getOrigin();
+		m_R1to0 *= trans1.getBasis();
+
+		calc_absolute_matrix();
+	}
+
+	//! Calcs the full invertion of the matrices. Useful for scaling matrices
+	SIMD_FORCE_INLINE void calc_from_full_invert(const btTransform & trans0,const btTransform & trans1)
+	{
+		m_R1to0 = trans0.getBasis().inverse();
+		m_T1to0 = m_R1to0 * (-trans0.getOrigin());
+
+		m_T1to0 += m_R1to0*trans1.getOrigin();
+		m_R1to0 *= trans1.getBasis();
+
+		calc_absolute_matrix();
+	}
+
+	SIMD_FORCE_INLINE btVector3 transform(const btVector3 & point)
+	{
+		return btVector3(m_R1to0[0].dot(point) + m_T1to0.x(),
+			m_R1to0[1].dot(point) + m_T1to0.y(),
+			m_R1to0[2].dot(point) + m_T1to0.z());
+	}
+};
+
+
+#define BOX_PLANE_EPSILON 0.000001f
+
+//! Axis aligned box
+class GIM_AABB
+{
+public:
+	btVector3 m_min;
+	btVector3 m_max;
+
+	GIM_AABB()
+	{}
+
+
+	GIM_AABB(const btVector3 & V1,
+			 const btVector3 & V2,
+			 const btVector3 & V3)
+	{
+		m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
+	}
+
+	GIM_AABB(const btVector3 & V1,
+			 const btVector3 & V2,
+			 const btVector3 & V3,
+			 GREAL margin)
+	{
+		m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
+
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	GIM_AABB(const GIM_AABB &other):
+		m_min(other.m_min),m_max(other.m_max)
+	{
+	}
+
+	GIM_AABB(const GIM_AABB &other,btScalar margin ):
+		m_min(other.m_min),m_max(other.m_max)
+	{
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	SIMD_FORCE_INLINE void invalidate()
+	{
+		m_min[0] = G_REAL_INFINITY;
+		m_min[1] = G_REAL_INFINITY;
+		m_min[2] = G_REAL_INFINITY;
+		m_max[0] = -G_REAL_INFINITY;
+		m_max[1] = -G_REAL_INFINITY;
+		m_max[2] = -G_REAL_INFINITY;
+	}
+
+	SIMD_FORCE_INLINE void increment_margin(btScalar margin)
+	{
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	SIMD_FORCE_INLINE void copy_with_margin(const GIM_AABB &other, btScalar margin)
+	{
+		m_min[0] = other.m_min[0] - margin;
+		m_min[1] = other.m_min[1] - margin;
+		m_min[2] = other.m_min[2] - margin;
+
+		m_max[0] = other.m_max[0] + margin;
+		m_max[1] = other.m_max[1] + margin;
+		m_max[2] = other.m_max[2] + margin;
+	}
+
+	template<typename CLASS_POINT>
+	SIMD_FORCE_INLINE void calc_from_triangle(
+							const CLASS_POINT & V1,
+							const CLASS_POINT & V2,
+							const CLASS_POINT & V3)
+	{
+		m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
+	}
+
+	template<typename CLASS_POINT>
+	SIMD_FORCE_INLINE void calc_from_triangle_margin(
+							const CLASS_POINT & V1,
+							const CLASS_POINT & V2,
+							const CLASS_POINT & V3, btScalar margin)
+	{
+		m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
+		m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
+		m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
+
+		m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
+		m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
+		m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
+
+		m_min[0] -= margin;
+		m_min[1] -= margin;
+		m_min[2] -= margin;
+		m_max[0] += margin;
+		m_max[1] += margin;
+		m_max[2] += margin;
+	}
+
+	//! Apply a transform to an AABB
+	SIMD_FORCE_INLINE void appy_transform(const btTransform & trans)
+	{
+		btVector3 center = (m_max+m_min)*0.5f;
+		btVector3 extends = m_max - center;
+		// Compute new center
+		center = trans(center);
+
+		btVector3 textends(extends.dot(trans.getBasis().getRow(0).absolute()),
+ 				 extends.dot(trans.getBasis().getRow(1).absolute()),
+				 extends.dot(trans.getBasis().getRow(2).absolute()));
+
+		m_min = center - textends;
+		m_max = center + textends;
+	}
+
+	//! Merges a Box
+	SIMD_FORCE_INLINE void merge(const GIM_AABB & box)
+	{
+		m_min[0] = GIM_MIN(m_min[0],box.m_min[0]);
+		m_min[1] = GIM_MIN(m_min[1],box.m_min[1]);
+		m_min[2] = GIM_MIN(m_min[2],box.m_min[2]);
+
+		m_max[0] = GIM_MAX(m_max[0],box.m_max[0]);
+		m_max[1] = GIM_MAX(m_max[1],box.m_max[1]);
+		m_max[2] = GIM_MAX(m_max[2],box.m_max[2]);
+	}
+
+	//! Merges a point
+	template<typename CLASS_POINT>
+	SIMD_FORCE_INLINE void merge_point(const CLASS_POINT & point)
+	{
+		m_min[0] = GIM_MIN(m_min[0],point[0]);
+		m_min[1] = GIM_MIN(m_min[1],point[1]);
+		m_min[2] = GIM_MIN(m_min[2],point[2]);
+
+		m_max[0] = GIM_MAX(m_max[0],point[0]);
+		m_max[1] = GIM_MAX(m_max[1],point[1]);
+		m_max[2] = GIM_MAX(m_max[2],point[2]);
+	}
+
+	//! Gets the extend and center
+	SIMD_FORCE_INLINE void get_center_extend(btVector3 & center,btVector3 & extend)  const
+	{
+		center = (m_max+m_min)*0.5f;
+		extend = m_max - center;
+	}
+
+	//! Finds the intersecting box between this box and the other.
+	SIMD_FORCE_INLINE void find_intersection(const GIM_AABB & other, GIM_AABB & intersection)  const
+	{
+		intersection.m_min[0] = GIM_MAX(other.m_min[0],m_min[0]);
+		intersection.m_min[1] = GIM_MAX(other.m_min[1],m_min[1]);
+		intersection.m_min[2] = GIM_MAX(other.m_min[2],m_min[2]);
+
+		intersection.m_max[0] = GIM_MIN(other.m_max[0],m_max[0]);
+		intersection.m_max[1] = GIM_MIN(other.m_max[1],m_max[1]);
+		intersection.m_max[2] = GIM_MIN(other.m_max[2],m_max[2]);
+	}
+
+
+	SIMD_FORCE_INLINE bool has_collision(const GIM_AABB & other) const
+	{
+		if(m_min[0] > other.m_max[0] ||
+		   m_max[0] < other.m_min[0] ||
+		   m_min[1] > other.m_max[1] ||
+		   m_max[1] < other.m_min[1] ||
+		   m_min[2] > other.m_max[2] ||
+		   m_max[2] < other.m_min[2])
+		{
+			return false;
+		}
+		return true;
+	}
+
+	/*! \brief Finds the Ray intersection parameter.
+	\param aabb Aligned box
+	\param vorigin A vec3f with the origin of the ray
+	\param vdir A vec3f with the direction of the ray
+	*/
+	SIMD_FORCE_INLINE bool collide_ray(const btVector3 & vorigin,const btVector3 & vdir)
+	{
+		btVector3 extents,center;
+		this->get_center_extend(center,extents);;
+
+		btScalar Dx = vorigin[0] - center[0];
+		if(GIM_GREATER(Dx, extents[0]) && Dx*vdir[0]>=0.0f)	return false;
+		btScalar Dy = vorigin[1] - center[1];
+		if(GIM_GREATER(Dy, extents[1]) && Dy*vdir[1]>=0.0f)	return false;
+		btScalar Dz = vorigin[2] - center[2];
+		if(GIM_GREATER(Dz, extents[2]) && Dz*vdir[2]>=0.0f)	return false;
+
+
+		btScalar f = vdir[1] * Dz - vdir[2] * Dy;
+		if(btFabs(f) > extents[1]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[1])) return false;
+		f = vdir[2] * Dx - vdir[0] * Dz;
+		if(btFabs(f) > extents[0]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[0]))return false;
+		f = vdir[0] * Dy - vdir[1] * Dx;
+		if(btFabs(f) > extents[0]*btFabs(vdir[1]) + extents[1]*btFabs(vdir[0]))return false;
+		return true;
+	}
+
+
+	SIMD_FORCE_INLINE void projection_interval(const btVector3 & direction, btScalar &vmin, btScalar &vmax) const
+	{
+		btVector3 center = (m_max+m_min)*0.5f;
+		btVector3 extend = m_max-center;
+
+		btScalar _fOrigin =  direction.dot(center);
+		btScalar _fMaximumExtent = extend.dot(direction.absolute());
+		vmin = _fOrigin - _fMaximumExtent;
+		vmax = _fOrigin + _fMaximumExtent;
+	}
+
+	SIMD_FORCE_INLINE ePLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
+	{
+		btScalar _fmin,_fmax;
+		this->projection_interval(plane,_fmin,_fmax);
+
+		if(plane[3] > _fmax + BOX_PLANE_EPSILON)
+		{
+			return G_BACK_PLANE; // 0
+		}
+
+		if(plane[3]+BOX_PLANE_EPSILON >=_fmin)
+		{
+			return G_COLLIDE_PLANE; //1
+		}
+		return G_FRONT_PLANE;//2
+	}
+
+	SIMD_FORCE_INLINE bool overlapping_trans_conservative(const GIM_AABB & box, btTransform & trans1_to_0)
+	{
+		GIM_AABB tbox = box;
+		tbox.appy_transform(trans1_to_0);
+		return has_collision(tbox);
+	}
+
+	//! transcache is the transformation cache from box to this AABB
+	SIMD_FORCE_INLINE bool overlapping_trans_cache(
+		const GIM_AABB & box,const GIM_BOX_BOX_TRANSFORM_CACHE & transcache, bool fulltest)
+	{
+
+		//Taken from OPCODE
+		btVector3 ea,eb;//extends
+		btVector3 ca,cb;//extends
+		get_center_extend(ca,ea);
+		box.get_center_extend(cb,eb);
+
+
+		btVector3 T;
+		btScalar t,t2;
+		int i;
+
+		// Class I : A's basis vectors
+		for(i=0;i<3;i++)
+		{
+			T[i] =  transcache.m_R1to0[i].dot(cb) + transcache.m_T1to0[i] - ca[i];
+			t = transcache.m_AR[i].dot(eb) + ea[i];
+			if(GIM_GREATER(T[i], t))	return false;
+		}
+		// Class II : B's basis vectors
+		for(i=0;i<3;i++)
+		{
+			t = MAT_DOT_COL(transcache.m_R1to0,T,i);
+			t2 = MAT_DOT_COL(transcache.m_AR,ea,i) + eb[i];
+			if(GIM_GREATER(t,t2))	return false;
+		}
+		// Class III : 9 cross products
+		if(fulltest)
+		{
+			int j,m,n,o,p,q,r;
+			for(i=0;i<3;i++)
+			{
+				m = (i+1)%3;
+				n = (i+2)%3;
+				o = i==0?1:0;
+				p = i==2?1:2;
+				for(j=0;j<3;j++)
+				{
+					q = j==2?1:2;
+					r = j==0?1:0;
+					t = T[n]*transcache.m_R1to0[m][j] - T[m]*transcache.m_R1to0[n][j];
+					t2 = ea[o]*transcache.m_AR[p][j] + ea[p]*transcache.m_AR[o][j] +
+						eb[r]*transcache.m_AR[i][q] + eb[q]*transcache.m_AR[i][r];
+					if(GIM_GREATER(t,t2))	return false;
+				}
+			}
+		}
+		return true;
+	}
+
+	//! Simple test for planes.
+	SIMD_FORCE_INLINE bool collide_plane(
+		const btVector4 & plane)
+	{
+		ePLANE_INTERSECTION_TYPE classify = plane_classify(plane);
+		return (classify == G_COLLIDE_PLANE);
+	}
+
+	//! test for a triangle, with edges
+	SIMD_FORCE_INLINE bool collide_triangle_exact(
+		const btVector3 & p1,
+		const btVector3 & p2,
+		const btVector3 & p3,
+		const btVector4 & triangle_plane)
+	{
+		if(!collide_plane(triangle_plane)) return false;
+
+		btVector3 center,extends;
+		this->get_center_extend(center,extends);
+
+		const btVector3 v1(p1 - center);
+		const btVector3 v2(p2 - center);
+		const btVector3 v3(p3 - center);
+
+		//First axis
+		btVector3 diff(v2 - v1);
+		btVector3 abs_diff = diff.absolute();
+		//Test With X axis
+		TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v1,v3,extends);
+		//Test With Y axis
+		TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v1,v3,extends);
+		//Test With Z axis
+		TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v1,v3,extends);
+
+
+		diff = v3 - v2;
+		abs_diff = diff.absolute();
+		//Test With X axis
+		TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v2,v1,extends);
+		//Test With Y axis
+		TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v2,v1,extends);
+		//Test With Z axis
+		TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v2,v1,extends);
+
+		diff = v1 - v3;
+		abs_diff = diff.absolute();
+		//Test With X axis
+		TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v3,v2,extends);
+		//Test With Y axis
+		TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v3,v2,extends);
+		//Test With Z axis
+		TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v3,v2,extends);
+
+		return true;
+	}
+};
+
+
+//! Compairison of transformation objects
+SIMD_FORCE_INLINE bool btCompareTransformsEqual(const btTransform & t1,const btTransform & t2)
+{
+	if(!(t1.getOrigin() == t2.getOrigin()) ) return false;
+
+	if(!(t1.getBasis().getRow(0) == t2.getBasis().getRow(0)) ) return false;
+	if(!(t1.getBasis().getRow(1) == t2.getBasis().getRow(1)) ) return false;
+	if(!(t1.getBasis().getRow(2) == t2.getBasis().getRow(2)) ) return false;
+	return true;
+}
+
+
+//! @}
+
+#endif // GIM_BOX_COLLISION_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_set.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_set.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_set.cpp	(revision 2122)
@@ -0,0 +1,182 @@
+
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "gim_box_set.h"
+
+
+GUINT GIM_BOX_TREE::_calc_splitting_axis(
+	gim_array<GIM_AABB_DATA> & primitive_boxes, GUINT startIndex,  GUINT endIndex)
+{
+	GUINT i;
+
+	btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
+	btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
+	GUINT numIndices = endIndex-startIndex;
+
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		means+=center;
+	}
+	means *= (btScalar(1.)/(btScalar)numIndices);
+
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btVector3 center = btScalar(0.5)*(primitive_boxes[i].m_bound.m_max +
+					 primitive_boxes[i].m_bound.m_min);
+		btVector3 diff2 = center-means;
+		diff2 = diff2 * diff2;
+		variance += diff2;
+	}
+	variance *= (btScalar(1.)/	((btScalar)numIndices-1)	);
+
+	return variance.maxAxis();
+}
+
+
+GUINT GIM_BOX_TREE::_sort_and_calc_splitting_index(
+	gim_array<GIM_AABB_DATA> & primitive_boxes, GUINT startIndex,
+	GUINT endIndex, GUINT splitAxis)
+{
+	GUINT i;
+	GUINT splitIndex =startIndex;
+	GUINT numIndices = endIndex - startIndex;
+
+	// average of centers
+	btScalar splitValue = 0.0f;
+	for (i=startIndex;i<endIndex;i++)
+	{
+		splitValue+= 0.5f*(primitive_boxes[i].m_bound.m_max[splitAxis] +
+					 primitive_boxes[i].m_bound.m_min[splitAxis]);
+	}
+	splitValue /= (btScalar)numIndices;
+
+	//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
+	for (i=startIndex;i<endIndex;i++)
+	{
+		btScalar center = 0.5f*(primitive_boxes[i].m_bound.m_max[splitAxis] +
+					 primitive_boxes[i].m_bound.m_min[splitAxis]);
+		if (center > splitValue)
+		{
+			//swap
+			primitive_boxes.swap(i,splitIndex);
+			splitIndex++;
+		}
+	}
+
+	//if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex
+	//otherwise the tree-building might fail due to stack-overflows in certain cases.
+	//unbalanced1 is unsafe: it can cause stack overflows
+	//bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1)));
+
+	//unbalanced2 should work too: always use center (perfect balanced trees)
+	//bool unbalanced2 = true;
+
+	//this should be safe too:
+	GUINT rangeBalancedIndices = numIndices/3;
+	bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices)));
+
+	if (unbalanced)
+	{
+		splitIndex = startIndex+ (numIndices>>1);
+	}
+
+	bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
+	btAssert(!unbal);
+
+	return splitIndex;
+}
+
+
+void GIM_BOX_TREE::_build_sub_tree(gim_array<GIM_AABB_DATA> & primitive_boxes, GUINT startIndex,  GUINT endIndex)
+{
+	GUINT current_index = m_num_nodes++;
+
+	btAssert((endIndex-startIndex)>0);
+
+	if((endIndex-startIndex) == 1) //we got a leaf
+	{		
+		m_node_array[current_index].m_left = 0;
+		m_node_array[current_index].m_right = 0;
+		m_node_array[current_index].m_escapeIndex = 0;
+
+		m_node_array[current_index].m_bound = primitive_boxes[startIndex].m_bound;
+		m_node_array[current_index].m_data = primitive_boxes[startIndex].m_data;
+		return;
+	}
+
+	//configure inner node
+
+	GUINT splitIndex;
+
+	//calc this node bounding box
+	m_node_array[current_index].m_bound.invalidate();	
+	for (splitIndex=startIndex;splitIndex<endIndex;splitIndex++)
+	{
+		m_node_array[current_index].m_bound.merge(primitive_boxes[splitIndex].m_bound);
+	}
+
+	//calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'.
+
+	//split axis
+	splitIndex = _calc_splitting_axis(primitive_boxes,startIndex,endIndex);
+
+	splitIndex = _sort_and_calc_splitting_index(
+			primitive_boxes,startIndex,endIndex,splitIndex);
+
+	//configure this inner node : the left node index
+	m_node_array[current_index].m_left = m_num_nodes;
+	//build left child tree
+	_build_sub_tree(primitive_boxes, startIndex, splitIndex );
+
+	//configure this inner node : the right node index
+	m_node_array[current_index].m_right = m_num_nodes;
+
+	//build right child tree
+	_build_sub_tree(primitive_boxes, splitIndex ,endIndex);
+
+	//configure this inner node : the escape index
+	m_node_array[current_index].m_escapeIndex  = m_num_nodes - current_index;
+}
+
+//! stackless build tree
+void GIM_BOX_TREE::build_tree(
+	gim_array<GIM_AABB_DATA> & primitive_boxes)
+{
+	// initialize node count to 0
+	m_num_nodes = 0;
+	// allocate nodes
+	m_node_array.resize(primitive_boxes.size()*2);
+	
+	_build_sub_tree(primitive_boxes, 0, primitive_boxes.size());
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_set.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_set.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_box_set.h	(revision 2122)
@@ -0,0 +1,678 @@
+#ifndef GIM_BOX_SET_H_INCLUDED
+#define GIM_BOX_SET_H_INCLUDED
+
+/*! \file gim_box_set.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "gim_array.h"
+#include "gim_radixsort.h"
+#include "gim_box_collision.h"
+#include "gim_tri_collision.h"
+
+
+/*! \defgroup BOX_PRUNNING
+
+
+
+*/
+//! @{
+
+//! Overlapping pair
+struct GIM_PAIR
+{
+    GUINT m_index1;
+    GUINT m_index2;
+    GIM_PAIR()
+    {}
+
+    GIM_PAIR(const GIM_PAIR & p)
+    {
+    	m_index1 = p.m_index1;
+    	m_index2 = p.m_index2;
+	}
+
+	GIM_PAIR(GUINT index1, GUINT index2)
+    {
+    	m_index1 = index1;
+    	m_index2 = index2;
+	}
+};
+
+//! A pairset array
+class gim_pair_set: public gim_array<GIM_PAIR>
+{
+public:
+	gim_pair_set():gim_array<GIM_PAIR>(32)
+	{
+	}
+	inline void push_pair(GUINT index1,GUINT index2)
+	{
+		push_back(GIM_PAIR(index1,index2));
+	}
+
+	inline void push_pair_inv(GUINT index1,GUINT index2)
+	{
+		push_back(GIM_PAIR(index2,index1));
+	}
+};
+
+
+//! Prototype Base class for primitive classification
+/*!
+This class is a wrapper for primitive collections.
+This tells relevant info for the Bounding Box set classes, which take care of space classification.
+This class can manage Compound shapes and trimeshes, and if it is managing trimesh then the  Hierarchy Bounding Box classes will take advantage of primitive Vs Box overlapping tests for getting optimal results and less Per Box compairisons.
+*/
+class GIM_PRIMITIVE_MANAGER_PROTOTYPE
+{
+public:
+
+	//! determines if this manager consist on only triangles, which special case will be optimized
+	virtual bool is_trimesh() = 0;
+	virtual GUINT get_primitive_count() = 0;
+	virtual void get_primitive_box(GUINT prim_index ,GIM_AABB & primbox) = 0;
+	virtual void get_primitive_triangle(GUINT prim_index,GIM_TRIANGLE & triangle) = 0;
+};
+
+
+struct GIM_AABB_DATA
+{
+	GIM_AABB m_bound;
+	GUINT m_data;
+};
+
+//! Node Structure for trees
+struct GIM_BOX_TREE_NODE
+{
+	GIM_AABB m_bound;
+	GUINT m_left;//!< Left subtree
+	GUINT m_right;//!< Right subtree
+	GUINT m_escapeIndex;//!< Scape index for traversing
+	GUINT m_data;//!< primitive index if apply
+
+	GIM_BOX_TREE_NODE()
+	{
+	    m_left = 0;
+	    m_right = 0;
+	    m_escapeIndex = 0;
+	    m_data = 0;
+	}
+
+	SIMD_FORCE_INLINE bool is_leaf_node() const
+	{
+	    return  (!m_left && !m_right);
+	}
+};
+
+//! Basic Box tree structure
+class GIM_BOX_TREE
+{
+protected:
+	GUINT m_num_nodes;
+	gim_array<GIM_BOX_TREE_NODE> m_node_array;
+protected:
+	GUINT _sort_and_calc_splitting_index(
+		gim_array<GIM_AABB_DATA> & primitive_boxes,
+		 GUINT startIndex,  GUINT endIndex, GUINT splitAxis);
+
+	GUINT _calc_splitting_axis(gim_array<GIM_AABB_DATA> & primitive_boxes, GUINT startIndex,  GUINT endIndex);
+
+	void _build_sub_tree(gim_array<GIM_AABB_DATA> & primitive_boxes, GUINT startIndex,  GUINT endIndex);
+public:
+	GIM_BOX_TREE()
+	{
+		m_num_nodes = 0;
+	}
+
+	//! prototype functions for box tree management
+	//!@{
+	void build_tree(gim_array<GIM_AABB_DATA> & primitive_boxes);
+
+	SIMD_FORCE_INLINE void clearNodes()
+	{
+		m_node_array.clear();
+		m_num_nodes = 0;
+	}
+
+	//! node count
+	SIMD_FORCE_INLINE GUINT getNodeCount() const
+	{
+		return m_num_nodes;
+	}
+
+	//! tells if the node is a leaf
+	SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
+	{
+		return m_node_array[nodeindex].is_leaf_node();
+	}
+
+	SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const
+	{
+		return m_node_array[nodeindex].m_data;
+	}
+
+	SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB & bound) const
+	{
+		bound = m_node_array[nodeindex].m_bound;
+	}
+
+	SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB & bound)
+	{
+		m_node_array[nodeindex].m_bound = bound;
+	}
+
+	SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex)  const
+	{
+		return m_node_array[nodeindex].m_left;
+	}
+
+	SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex)  const
+	{
+		return m_node_array[nodeindex].m_right;
+	}
+
+	SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const
+	{
+		return m_node_array[nodeindex].m_escapeIndex;
+	}
+
+	//!@}
+};
+
+
+//! Generic Box Tree Template
+/*!
+This class offers an structure for managing a box tree of primitives.
+Requires a Primitive prototype (like GIM_PRIMITIVE_MANAGER_PROTOTYPE ) and
+a Box tree structure ( like GIM_BOX_TREE).
+*/
+template<typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE, typename _GIM_BOX_TREE_PROTOTYPE>
+class GIM_BOX_TREE_TEMPLATE_SET
+{
+protected:
+	_GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager;
+	_GIM_BOX_TREE_PROTOTYPE m_box_tree;
+protected:
+	//stackless refit
+	SIMD_FORCE_INLINE void refit()
+	{
+		GUINT nodecount = getNodeCount();
+		while(nodecount--)
+		{
+			if(isLeafNode(nodecount))
+			{
+				GIM_AABB leafbox;
+				m_primitive_manager.get_primitive_box(getNodeData(nodecount),leafbox);
+				setNodeBound(nodecount,leafbox);
+			}
+			else
+			{
+				//get left bound
+				GUINT childindex = getLeftNodeIndex(nodecount);
+				GIM_AABB bound;
+				getNodeBound(childindex,bound);
+				//get right bound
+				childindex = getRightNodeIndex(nodecount);
+				GIM_AABB bound2;
+				getNodeBound(childindex,bound2);
+				bound.merge(bound2);
+
+				setNodeBound(nodecount,bound);
+			}
+		}
+	}
+public:
+
+	GIM_BOX_TREE_TEMPLATE_SET()
+	{
+	}
+
+	SIMD_FORCE_INLINE GIM_AABB getGlobalBox()  const
+	{
+		GIM_AABB totalbox;
+		getNodeBound(0, totalbox);
+		return totalbox;
+	}
+
+	SIMD_FORCE_INLINE void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & primitive_manager)
+	{
+		m_primitive_manager = primitive_manager;
+	}
+
+	const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() const
+	{
+		return m_primitive_manager;
+	}
+
+	_GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager()
+	{
+		return m_primitive_manager;
+	}
+
+//! node manager prototype functions
+///@{
+
+	//! this attemps to refit the box set.
+	SIMD_FORCE_INLINE void update()
+	{
+		refit();
+	}
+
+	//! this rebuild the entire set
+	SIMD_FORCE_INLINE void buildSet()
+	{
+		//obtain primitive boxes
+		gim_array<GIM_AABB_DATA> primitive_boxes;
+		primitive_boxes.resize(m_primitive_manager.get_primitive_count(),false);
+
+		for (GUINT i = 0;i<primitive_boxes.size() ;i++ )
+		{
+			 m_primitive_manager.get_primitive_box(i,primitive_boxes[i].m_bound);
+			 primitive_boxes[i].m_data = i;
+		}
+
+		m_box_tree.build_tree(primitive_boxes);
+	}
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	SIMD_FORCE_INLINE bool boxQuery(const GIM_AABB & box, gim_array<GUINT> & collided_results) const
+	{
+		GUINT curIndex = 0;
+		GUINT numNodes = getNodeCount();
+
+		while (curIndex < numNodes)
+		{
+			GIM_AABB bound;
+			getNodeBound(curIndex,bound);
+
+			//catch bugs in tree data
+
+			bool aabbOverlap = bound.has_collision(box);
+			bool isleafnode = isLeafNode(curIndex);
+
+			if (isleafnode && aabbOverlap)
+			{
+				collided_results.push_back(getNodeData(curIndex));
+			}
+
+			if (aabbOverlap || isleafnode)
+			{
+				//next subnode
+				curIndex++;
+			}
+			else
+			{
+				//skip node
+				curIndex+= getScapeNodeIndex(curIndex);
+			}
+		}
+		if(collided_results.size()>0) return true;
+		return false;
+	}
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	SIMD_FORCE_INLINE bool boxQueryTrans(const GIM_AABB & box,
+		 const btTransform & transform, gim_array<GUINT> & collided_results) const
+	{
+		GIM_AABB transbox=box;
+		transbox.appy_transform(transform);
+		return boxQuery(transbox,collided_results);
+	}
+
+	//! returns the indices of the primitives in the m_primitive_manager
+	SIMD_FORCE_INLINE bool rayQuery(
+		const btVector3 & ray_dir,const btVector3 & ray_origin ,
+		gim_array<GUINT> & collided_results) const
+	{
+		GUINT curIndex = 0;
+		GUINT numNodes = getNodeCount();
+
+		while (curIndex < numNodes)
+		{
+			GIM_AABB bound;
+			getNodeBound(curIndex,bound);
+
+			//catch bugs in tree data
+
+			bool aabbOverlap = bound.collide_ray(ray_origin,ray_dir);
+			bool isleafnode = isLeafNode(curIndex);
+
+			if (isleafnode && aabbOverlap)
+			{
+				collided_results.push_back(getNodeData( curIndex));
+			}
+
+			if (aabbOverlap || isleafnode)
+			{
+				//next subnode
+				curIndex++;
+			}
+			else
+			{
+				//skip node
+				curIndex+= getScapeNodeIndex(curIndex);
+			}
+		}
+		if(collided_results.size()>0) return true;
+		return false;
+	}
+
+	//! tells if this set has hierarcht
+	SIMD_FORCE_INLINE bool hasHierarchy() const
+	{
+		return true;
+	}
+
+	//! tells if this set is a trimesh
+	SIMD_FORCE_INLINE bool isTrimesh()  const
+	{
+		return m_primitive_manager.is_trimesh();
+	}
+
+	//! node count
+	SIMD_FORCE_INLINE GUINT getNodeCount() const
+	{
+		return m_box_tree.getNodeCount();
+	}
+
+	//! tells if the node is a leaf
+	SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
+	{
+		return m_box_tree.isLeafNode(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const
+	{
+		return m_box_tree.getNodeData(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB & bound)  const
+	{
+		m_box_tree.getNodeBound(nodeindex, bound);
+	}
+
+	SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB & bound)
+	{
+		m_box_tree.setNodeBound(nodeindex, bound);
+	}
+
+	SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex) const
+	{
+		return m_box_tree.getLeftNodeIndex(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex) const
+	{
+		return m_box_tree.getRightNodeIndex(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const
+	{
+		return m_box_tree.getScapeNodeIndex(nodeindex);
+	}
+
+	SIMD_FORCE_INLINE void getNodeTriangle(GUINT nodeindex,GIM_TRIANGLE & triangle) const
+	{
+		m_primitive_manager.get_primitive_triangle(getNodeData(nodeindex),triangle);
+	}
+
+//! @}
+};
+
+//! Class for Box Tree Sets
+/*!
+this has the GIM_BOX_TREE implementation for bounding boxes.
+*/
+template<typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE>
+class GIM_BOX_TREE_SET: public GIM_BOX_TREE_TEMPLATE_SET< _GIM_PRIMITIVE_MANAGER_PROTOTYPE, GIM_BOX_TREE>
+{
+public:
+
+};
+
+
+
+
+
+/// GIM_BOX_SET collision methods
+template<typename BOX_SET_CLASS0,typename BOX_SET_CLASS1>
+class GIM_TREE_TREE_COLLIDER
+{
+public:
+	gim_pair_set * m_collision_pairs;
+	BOX_SET_CLASS0 * m_boxset0;
+	BOX_SET_CLASS1 * m_boxset1;
+	GUINT current_node0;
+	GUINT current_node1;
+	bool node0_is_leaf;
+	bool node1_is_leaf;
+	bool t0_is_trimesh;
+	bool t1_is_trimesh;
+	bool node0_has_triangle;
+	bool node1_has_triangle;
+	GIM_AABB m_box0;
+	GIM_AABB m_box1;
+	GIM_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0;
+	btTransform trans_cache_0to1;
+	GIM_TRIANGLE m_tri0;
+	btVector4 m_tri0_plane;
+	GIM_TRIANGLE m_tri1;
+	btVector4 m_tri1_plane;
+
+
+public:
+	GIM_TREE_TREE_COLLIDER()
+	{
+		current_node0 = G_UINT_INFINITY;
+		current_node1 = G_UINT_INFINITY;
+	}
+protected:
+	SIMD_FORCE_INLINE void retrieve_node0_triangle(GUINT node0)
+	{
+		if(node0_has_triangle) return;
+		m_boxset0->getNodeTriangle(node0,m_tri0);
+		//transform triangle
+		m_tri0.m_vertices[0] = trans_cache_0to1(m_tri0.m_vertices[0]);
+		m_tri0.m_vertices[1] = trans_cache_0to1(m_tri0.m_vertices[1]);
+		m_tri0.m_vertices[2] = trans_cache_0to1(m_tri0.m_vertices[2]);
+		m_tri0.get_plane(m_tri0_plane);
+
+		node0_has_triangle = true;
+	}
+
+	SIMD_FORCE_INLINE void retrieve_node1_triangle(GUINT node1)
+	{
+		if(node1_has_triangle) return;
+		m_boxset1->getNodeTriangle(node1,m_tri1);
+		//transform triangle
+		m_tri1.m_vertices[0] = trans_cache_1to0.transform(m_tri1.m_vertices[0]);
+		m_tri1.m_vertices[1] = trans_cache_1to0.transform(m_tri1.m_vertices[1]);
+		m_tri1.m_vertices[2] = trans_cache_1to0.transform(m_tri1.m_vertices[2]);
+		m_tri1.get_plane(m_tri1_plane);
+
+		node1_has_triangle = true;
+	}
+
+	SIMD_FORCE_INLINE void retrieve_node0_info(GUINT node0)
+	{
+		if(node0 == current_node0) return;
+		m_boxset0->getNodeBound(node0,m_box0);
+		node0_is_leaf = m_boxset0->isLeafNode(node0);
+		node0_has_triangle = false;
+		current_node0 = node0;
+	}
+
+	SIMD_FORCE_INLINE void retrieve_node1_info(GUINT node1)
+	{
+		if(node1 == current_node1) return;
+		m_boxset1->getNodeBound(node1,m_box1);
+		node1_is_leaf = m_boxset1->isLeafNode(node1);
+		node1_has_triangle = false;
+		current_node1 = node1;
+	}
+
+	SIMD_FORCE_INLINE bool node_collision(GUINT node0 ,GUINT node1)
+	{
+		retrieve_node0_info(node0);
+		retrieve_node1_info(node1);
+		bool result = m_box0.overlapping_trans_cache(m_box1,trans_cache_1to0,true);
+		if(!result) return false;
+
+		if(t0_is_trimesh && node0_is_leaf)
+		{
+			//perform primitive vs box collision
+			retrieve_node0_triangle(node0);
+			//do triangle vs box collision
+			m_box1.increment_margin(m_tri0.m_margin);
+
+			result = m_box1.collide_triangle_exact(
+				m_tri0.m_vertices[0],m_tri0.m_vertices[1],m_tri0.m_vertices[2],m_tri0_plane);
+
+			m_box1.increment_margin(-m_tri0.m_margin);
+
+			if(!result) return false;
+			return true;
+		}
+		else if(t1_is_trimesh && node1_is_leaf)
+		{
+			//perform primitive vs box collision
+			retrieve_node1_triangle(node1);
+			//do triangle vs box collision
+			m_box0.increment_margin(m_tri1.m_margin);
+
+			result = m_box0.collide_triangle_exact(
+				m_tri1.m_vertices[0],m_tri1.m_vertices[1],m_tri1.m_vertices[2],m_tri1_plane);
+
+			m_box0.increment_margin(-m_tri1.m_margin);
+
+			if(!result) return false;
+			return true;
+		}
+		return true;
+	}
+
+	//stackless collision routine
+	void find_collision_pairs()
+	{
+		gim_pair_set stack_collisions;
+		stack_collisions.reserve(32);
+
+		//add the first pair
+		stack_collisions.push_pair(0,0);
+
+
+		while(stack_collisions.size())
+		{
+			//retrieve the last pair and pop
+			GUINT node0 = stack_collisions.back().m_index1;
+			GUINT node1 = stack_collisions.back().m_index2;
+			stack_collisions.pop_back();
+			if(node_collision(node0,node1)) // a collision is found
+			{
+				if(node0_is_leaf)
+				{
+					if(node1_is_leaf)
+					{
+						m_collision_pairs->push_pair(m_boxset0->getNodeData(node0),m_boxset1->getNodeData(node1));
+					}
+					else
+					{
+						//collide left
+						stack_collisions.push_pair(node0,m_boxset1->getLeftNodeIndex(node1));
+
+						//collide right
+						stack_collisions.push_pair(node0,m_boxset1->getRightNodeIndex(node1));
+					}
+				}
+				else
+				{
+					if(node1_is_leaf)
+					{
+						//collide left
+						stack_collisions.push_pair(m_boxset0->getLeftNodeIndex(node0),node1);
+						//collide right
+						stack_collisions.push_pair(m_boxset0->getRightNodeIndex(node0),node1);
+					}
+					else
+					{
+						GUINT left0 = m_boxset0->getLeftNodeIndex(node0);
+						GUINT right0 = m_boxset0->getRightNodeIndex(node0);
+						GUINT left1 = m_boxset1->getLeftNodeIndex(node1);
+						GUINT right1 = m_boxset1->getRightNodeIndex(node1);
+						//collide left
+						stack_collisions.push_pair(left0,left1);
+						//collide right
+						stack_collisions.push_pair(left0,right1);
+						//collide left
+						stack_collisions.push_pair(right0,left1);
+						//collide right
+						stack_collisions.push_pair(right0,right1);
+
+					}// else if node1 is not a leaf
+				}// else if node0 is not a leaf
+
+			}// if(node_collision(node0,node1))
+		}//while(stack_collisions.size())
+	}
+public:
+	void find_collision(BOX_SET_CLASS0 * boxset1, const btTransform & trans1,
+		BOX_SET_CLASS1 * boxset2, const btTransform & trans2,
+		gim_pair_set & collision_pairs, bool complete_primitive_tests = true)
+	{
+		m_collision_pairs = &collision_pairs;
+		m_boxset0 = boxset1;
+		m_boxset1 = boxset2;
+
+		trans_cache_1to0.calc_from_homogenic(trans1,trans2);
+
+		trans_cache_0to1 =  trans2.inverse();
+		trans_cache_0to1 *= trans1;
+
+
+		if(complete_primitive_tests)
+		{
+			t0_is_trimesh = boxset1->getPrimitiveManager().is_trimesh();
+			t1_is_trimesh = boxset2->getPrimitiveManager().is_trimesh();
+		}
+		else
+		{
+			t0_is_trimesh = false;
+			t1_is_trimesh = false;
+		}
+
+		find_collision_pairs();
+	}
+};
+
+
+#endif // GIM_BOXPRUNING_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_clip_polygon.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_clip_polygon.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_clip_polygon.h	(revision 2122)
@@ -0,0 +1,214 @@
+#ifndef GIM_CLIP_POLYGON_H_INCLUDED
+#define GIM_CLIP_POLYGON_H_INCLUDED
+
+/*! \file gim_tri_collision.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+/*! \addtogroup GEOMETRIC_OPERATIONS
+*/
+//! @{
+
+//! This function calcs the distance from a 3D plane
+class DISTANCE_PLANE_3D_FUNC
+{
+public:
+	template<typename CLASS_POINT,typename CLASS_PLANE>
+	inline GREAL operator()(const CLASS_PLANE & plane, const CLASS_POINT & point)
+	{
+		return DISTANCE_PLANE_POINT(plane, point);
+	}
+};
+
+
+
+template<typename CLASS_POINT>
+SIMD_FORCE_INLINE void PLANE_CLIP_POLYGON_COLLECT(
+						const CLASS_POINT & point0,
+						const CLASS_POINT & point1,
+						GREAL dist0,
+						GREAL dist1,
+						CLASS_POINT * clipped,
+						GUINT & clipped_count)
+{
+	GUINT _prevclassif = (dist0>G_EPSILON);
+	GUINT _classif = (dist1>G_EPSILON);
+	if(_classif!=_prevclassif)
+	{
+		GREAL blendfactor = -dist0/(dist1-dist0);
+		VEC_BLEND(clipped[clipped_count],point0,point1,blendfactor);
+		clipped_count++;
+	}
+	if(!_classif)
+	{
+		VEC_COPY(clipped[clipped_count],point1);
+		clipped_count++;
+	}
+}
+
+
+//! Clips a polygon by a plane
+/*!
+*\return The count of the clipped counts
+*/
+template<typename CLASS_POINT,typename CLASS_PLANE, typename DISTANCE_PLANE_FUNC>
+SIMD_FORCE_INLINE GUINT PLANE_CLIP_POLYGON_GENERIC(
+						const CLASS_PLANE & plane,
+						const CLASS_POINT * polygon_points,
+						GUINT polygon_point_count,
+						CLASS_POINT * clipped,DISTANCE_PLANE_FUNC distance_func)
+{
+    GUINT clipped_count = 0;
+
+
+    //clip first point
+	GREAL firstdist = distance_func(plane,polygon_points[0]);;
+	if(!(firstdist>G_EPSILON))
+	{
+		VEC_COPY(clipped[clipped_count],polygon_points[0]);
+		clipped_count++;
+	}
+
+	GREAL olddist = firstdist;
+	for(GUINT _i=1;_i<polygon_point_count;_i++)
+	{		
+		GREAL dist = distance_func(plane,polygon_points[_i]);
+
+		PLANE_CLIP_POLYGON_COLLECT(
+						polygon_points[_i-1],polygon_points[_i],
+						olddist,
+						dist,
+						clipped,
+						clipped_count);
+
+
+		olddist = dist;		
+	}
+
+	//RETURN TO FIRST  point	
+
+	PLANE_CLIP_POLYGON_COLLECT(
+					polygon_points[polygon_point_count-1],polygon_points[0],
+					olddist,
+					firstdist,
+					clipped,
+					clipped_count);
+
+	return clipped_count;
+}
+
+//! Clips a polygon by a plane
+/*!
+*\return The count of the clipped counts
+*/
+template<typename CLASS_POINT,typename CLASS_PLANE, typename DISTANCE_PLANE_FUNC>
+SIMD_FORCE_INLINE GUINT PLANE_CLIP_TRIANGLE_GENERIC(
+						const CLASS_PLANE & plane,
+						const CLASS_POINT & point0,
+						const CLASS_POINT & point1,
+						const CLASS_POINT & point2,
+						CLASS_POINT * clipped,DISTANCE_PLANE_FUNC distance_func)
+{
+    GUINT clipped_count = 0;
+
+    //clip first point
+	GREAL firstdist = distance_func(plane,point0);;
+	if(!(firstdist>G_EPSILON))
+	{
+		VEC_COPY(clipped[clipped_count],point0);
+		clipped_count++;
+	}
+
+	// point 1
+	GREAL olddist = firstdist;
+	GREAL dist = distance_func(plane,point1);
+
+	PLANE_CLIP_POLYGON_COLLECT(
+					point0,point1,
+					olddist,
+					dist,
+					clipped,
+					clipped_count);
+
+	olddist = dist;
+
+
+	// point 2
+	dist = distance_func(plane,point2);
+
+	PLANE_CLIP_POLYGON_COLLECT(
+					point1,point2,
+					olddist,
+					dist,
+					clipped,
+					clipped_count);
+	olddist = dist;
+
+
+
+	//RETURN TO FIRST  point
+	PLANE_CLIP_POLYGON_COLLECT(
+					point2,point0,
+					olddist,
+					firstdist,
+					clipped,
+					clipped_count);
+
+	return clipped_count;
+}
+
+
+template<typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE GUINT PLANE_CLIP_POLYGON3D(
+						const CLASS_PLANE & plane,
+						const CLASS_POINT * polygon_points,
+						GUINT polygon_point_count,
+						CLASS_POINT * clipped)
+{
+	return PLANE_CLIP_POLYGON_GENERIC<CLASS_POINT,CLASS_PLANE>(plane,polygon_points,polygon_point_count,clipped,DISTANCE_PLANE_3D_FUNC());
+}
+
+
+template<typename CLASS_POINT,typename CLASS_PLANE>
+SIMD_FORCE_INLINE GUINT PLANE_CLIP_TRIANGLE3D(
+						const CLASS_PLANE & plane,
+						const CLASS_POINT & point0,
+						const CLASS_POINT & point1,
+						const CLASS_POINT & point2,
+						CLASS_POINT * clipped)
+{
+	return PLANE_CLIP_TRIANGLE_GENERIC<CLASS_POINT,CLASS_PLANE>(plane,point0,point1,point2,clipped,DISTANCE_PLANE_3D_FUNC());
+}
+
+
+//! @}
+
+#endif // GIM_TRI_COLLISION_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_contact.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_contact.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_contact.cpp	(revision 2122)
@@ -0,0 +1,146 @@
+
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "gim_contact.h"
+
+#define MAX_COINCIDENT 8
+
+void gim_contact_array::merge_contacts(
+	const gim_contact_array & contacts, bool normal_contact_average)
+{
+	clear();
+
+	if(contacts.size()==1)
+	{
+		push_back(contacts.back());
+		return;
+	}
+
+	gim_array<GIM_RSORT_TOKEN> keycontacts(contacts.size());
+	keycontacts.resize(contacts.size(),false);
+
+	//fill key contacts
+
+	GUINT i;
+
+	for (i = 0;i<contacts.size() ;i++ )
+	{
+		keycontacts[i].m_key = contacts[i].calc_key_contact();
+		keycontacts[i].m_value = i;
+	}
+
+	//sort keys
+	gim_heap_sort(keycontacts.pointer(),keycontacts.size(),GIM_RSORT_TOKEN_COMPARATOR());
+
+	// Merge contacts
+
+	GUINT coincident_count=0;
+	btVector3 coincident_normals[MAX_COINCIDENT];
+
+	GUINT last_key = keycontacts[0].m_key;
+	GUINT key = 0;
+
+	push_back(contacts[keycontacts[0].m_value]);
+	GIM_CONTACT * pcontact = &back();
+
+
+
+	for( i=1;i<keycontacts.size();i++)
+	{
+	    key = keycontacts[i].m_key;
+		const GIM_CONTACT * scontact = &contacts[keycontacts[i].m_value];
+
+		if(last_key ==  key)//same points
+		{
+			//merge contact
+			if(pcontact->m_depth - CONTACT_DIFF_EPSILON > scontact->m_depth)//)
+			{
+				*pcontact = *scontact;
+                coincident_count = 0;
+			}
+			else if(normal_contact_average)
+			{
+				if(btFabs(pcontact->m_depth - scontact->m_depth)<CONTACT_DIFF_EPSILON)
+                {
+                    if(coincident_count<MAX_COINCIDENT)
+                    {
+                    	coincident_normals[coincident_count] = scontact->m_normal;
+                        coincident_count++;
+                    }
+                }
+			}
+		}
+		else
+		{//add new contact
+
+		    if(normal_contact_average && coincident_count>0)
+		    {
+		    	pcontact->interpolate_normals(coincident_normals,coincident_count);
+		        coincident_count = 0;
+		    }
+
+		    push_back(*scontact);
+		    pcontact = &back();
+        }
+		last_key = key;
+	}
+}
+
+void gim_contact_array::merge_contacts_unique(const gim_contact_array & contacts)
+{
+	clear();
+
+	if(contacts.size()==1)
+	{
+		push_back(contacts.back());
+		return;
+	}
+
+	GIM_CONTACT average_contact = contacts.back();
+
+	for (GUINT i=1;i<contacts.size() ;i++ )
+	{
+		average_contact.m_point += contacts[i].m_point;
+		average_contact.m_normal += contacts[i].m_normal * contacts[i].m_depth;
+	}
+
+	//divide
+	GREAL divide_average = 1.0f/((GREAL)contacts.size());
+
+	average_contact.m_point *= divide_average;
+
+	average_contact.m_normal *= divide_average;
+
+	average_contact.m_depth = average_contact.m_normal.length();
+
+	average_contact.m_normal /= average_contact.m_depth;
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_contact.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_contact.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_contact.h	(revision 2122)
@@ -0,0 +1,172 @@
+#ifndef GIM_CONTACT_H_INCLUDED
+#define GIM_CONTACT_H_INCLUDED
+
+/*! \file gim_contact.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+#include "gim_geometry.h"
+#include "gim_radixsort.h"
+#include "gim_array.h"
+
+/*! \defgroup CONTACTS
+\brief
+Functions for managing and sorting contacts resulting from a collision query.
+<ul>
+<li> Contact lists must be create by calling \ref GIM_CREATE_CONTACT_LIST
+<li> After querys, contact lists must be destroy by calling \ref GIM_DYNARRAY_DESTROY
+<li> Contacts can be merge for avoid duplicate results by calling \ref gim_merge_contacts
+</ul>
+
+*/
+//! @{
+
+/**
+Configuration var for applying interpolation of  contact normals
+*/
+#define NORMAL_CONTACT_AVERAGE 1
+#define CONTACT_DIFF_EPSILON 0.00001f
+
+/// Structure for collision results
+class GIM_CONTACT
+{
+public:
+    btVector3 m_point;
+    btVector3 m_normal;
+    GREAL m_depth;//Positive value indicates interpenetration
+    GREAL m_distance;//Padding not for use
+    GUINT m_feature1;//Face number
+    GUINT m_feature2;//Face number
+public:
+    GIM_CONTACT()
+    {
+    }
+
+    GIM_CONTACT(const GIM_CONTACT & contact):
+				m_point(contact.m_point),
+				m_normal(contact.m_normal),
+				m_depth(contact.m_depth),
+				m_feature1(contact.m_feature1),
+				m_feature2(contact.m_feature2)
+    {
+    	m_point = contact.m_point;
+    	m_normal = contact.m_normal;
+    	m_depth = contact.m_depth;
+    	m_feature1 = contact.m_feature1;
+    	m_feature2 = contact.m_feature2;
+    }
+
+    GIM_CONTACT(const btVector3 &point,const btVector3 & normal,
+    	 			GREAL depth, GUINT feature1, GUINT feature2):
+				m_point(point),
+				m_normal(normal),
+				m_depth(depth),
+				m_feature1(feature1),
+				m_feature2(feature2)
+    {
+    }
+
+	//! Calcs key for coord classification
+    SIMD_FORCE_INLINE GUINT calc_key_contact() const
+    {
+    	GINT _coords[] = {
+    		(GINT)(m_point[0]*1000.0f+1.0f),
+    		(GINT)(m_point[1]*1333.0f),
+    		(GINT)(m_point[2]*2133.0f+3.0f)};
+		GUINT _hash=0;
+		GUINT *_uitmp = (GUINT *)(&_coords[0]);
+		_hash = *_uitmp;
+		_uitmp++;
+		_hash += (*_uitmp)<<4;
+		_uitmp++;
+		_hash += (*_uitmp)<<8;
+		return _hash;
+    }
+
+    SIMD_FORCE_INLINE void interpolate_normals( btVector3 * normals,GUINT normal_count)
+    {
+    	btVector3 vec_sum(m_normal);
+		for(GUINT i=0;i<normal_count;i++)
+		{
+			vec_sum += normals[i];
+		}
+
+		GREAL vec_sum_len = vec_sum.length2();
+		if(vec_sum_len <CONTACT_DIFF_EPSILON) return;
+
+		GIM_INV_SQRT(vec_sum_len,vec_sum_len); // 1/sqrt(vec_sum_len)
+
+		m_normal = vec_sum*vec_sum_len;
+    }
+
+};
+
+
+class gim_contact_array:public gim_array<GIM_CONTACT>
+{
+public:
+	gim_contact_array():gim_array<GIM_CONTACT>(64)
+	{
+	}
+
+	SIMD_FORCE_INLINE void push_contact(const btVector3 &point,const btVector3 & normal,
+    	 			GREAL depth, GUINT feature1, GUINT feature2)
+	{
+		push_back_mem();
+		GIM_CONTACT & newele = back();
+		newele.m_point = point;
+		newele.m_normal = normal;
+		newele.m_depth = depth;
+		newele.m_feature1 = feature1;
+		newele.m_feature2 = feature2;
+	}
+
+	SIMD_FORCE_INLINE void push_triangle_contacts(
+		const GIM_TRIANGLE_CONTACT_DATA & tricontact,
+		GUINT feature1,GUINT feature2)
+	{
+		for(GUINT i = 0;i<tricontact.m_point_count ;i++ )
+		{
+			push_back_mem();
+			GIM_CONTACT & newele = back();
+			newele.m_point = tricontact.m_points[i];
+			newele.m_normal = tricontact.m_separating_normal;
+			newele.m_depth = tricontact.m_penetration_depth;
+			newele.m_feature1 = feature1;
+			newele.m_feature2 = feature2;
+		}
+	}
+
+	void merge_contacts(const gim_contact_array & contacts, bool normal_contact_average = true);
+	void merge_contacts_unique(const gim_contact_array & contacts);
+};
+
+//! @}
+#endif // GIM_CONTACT_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_geom_types.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_geom_types.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_geom_types.h	(revision 2122)
@@ -0,0 +1,102 @@
+#ifndef GIM_GEOM_TYPES_H_INCLUDED
+#define GIM_GEOM_TYPES_H_INCLUDED
+
+/*! \file gim_geom_types.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "gim_math.h"
+
+/*! \defgroup GEOMETRIC_TYPES
+\brief
+Basic types and constants for geometry
+*/
+//! @{
+
+//! Short Integer vector 2D
+typedef GSHORT vec2s[2];
+//! Integer vector 3D
+typedef GSHORT vec3s[3];
+//! Integer vector 4D
+typedef GSHORT vec4s[4];
+
+//! Short Integer vector 2D
+typedef GUSHORT vec2us[2];
+//! Integer vector 3D
+typedef GUSHORT vec3us[3];
+//! Integer vector 4D
+typedef GUSHORT vec4us[4];
+
+//! Integer vector 2D
+typedef GINT vec2i[2];
+//! Integer vector 3D
+typedef GINT vec3i[3];
+//! Integer vector 4D
+typedef GINT vec4i[4];
+
+//! Unsigned Integer vector 2D
+typedef GUINT vec2ui[2];
+//! Unsigned Integer vector 3D
+typedef GUINT vec3ui[3];
+//! Unsigned Integer vector 4D
+typedef GUINT vec4ui[4];
+
+//! Float vector 2D
+typedef GREAL vec2f[2];
+//! Float vector 3D
+typedef GREAL vec3f[3];
+//! Float vector 4D
+typedef GREAL vec4f[4];
+
+//! Double vector 2D
+typedef GREAL2 vec2d[2];
+//! Float vector 3D
+typedef GREAL2 vec3d[3];
+//! Float vector 4D
+typedef GREAL2 vec4d[4];
+
+//! Matrix 2D, row ordered
+typedef GREAL mat2f[2][2];
+//! Matrix 3D, row ordered
+typedef GREAL mat3f[3][3];
+//! Matrix 4D, row ordered
+typedef GREAL mat4f[4][4];
+
+//! Quaternion
+typedef GREAL quatf[4];
+
+//typedef struct _aabb3f aabb3f;
+//! @}
+
+
+
+#endif // GIM_GEOM_TYPES_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_geometry.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_geometry.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_geometry.h	(revision 2122)
@@ -0,0 +1,42 @@
+#ifndef GIM_GEOMETRY_H_INCLUDED
+#define GIM_GEOMETRY_H_INCLUDED
+
+/*! \file gim_geometry.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+///Additional Headers for Collision
+#include "gim_basic_geometry_operations.h"
+#include "gim_clip_polygon.h"
+#include "gim_box_collision.h"
+#include "gim_tri_collision.h"
+
+#endif // GIM_VECTOR_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_hash_table.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_hash_table.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_hash_table.h	(revision 2122)
@@ -0,0 +1,920 @@
+#ifndef GIM_HASH_TABLE_H_INCLUDED
+#define GIM_HASH_TABLE_H_INCLUDED
+/*! \file gim_trimesh_data.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "gim_radixsort.h"
+
+/*! \addtogroup CONTAINERS
+\brief
+Abstract class for collision objects
+*/
+//! @{
+
+#define GIM_INVALID_HASH 0xffffffff //!< A very very high value
+#define GIM_DEFAULT_HASH_TABLE_SIZE 380
+#define GIM_DEFAULT_HASH_TABLE_NODE_SIZE 4
+#define GIM_HASH_TABLE_GROW_FACTOR 2
+
+#define GIM_MIN_RADIX_SORT_SIZE 860 //!< calibrated on a PIII
+
+template<typename T>
+struct GIM_HASH_TABLE_NODE
+{
+    GUINT m_key;
+    T m_data;
+    GIM_HASH_TABLE_NODE()
+    {
+    }
+
+    GIM_HASH_TABLE_NODE(const GIM_HASH_TABLE_NODE & value)
+    {
+        m_key = value.m_key;
+        m_data = value.m_data;
+    }
+
+    GIM_HASH_TABLE_NODE(GUINT key, const T & data)
+    {
+        m_key = key;
+        m_data = data;
+    }
+
+    bool operator <(const GIM_HASH_TABLE_NODE<T> & other) const
+	{
+		///inverse order, further objects are first
+		if(m_key <  other.m_key) return true;
+		return false;
+	}
+
+	bool operator >(const GIM_HASH_TABLE_NODE<T> & other) const
+	{
+		///inverse order, further objects are first
+		if(m_key >  other.m_key) return true;
+		return false;
+	}
+
+	bool operator ==(const GIM_HASH_TABLE_NODE<T> & other) const
+	{
+		///inverse order, further objects are first
+		if(m_key ==  other.m_key) return true;
+		return false;
+	}
+};
+
+///Macro for getting the key
+class GIM_HASH_NODE_GET_KEY
+{
+public:
+	template<class T>
+	inline GUINT operator()( const T& a)
+	{
+		return a.m_key;
+	}
+};
+
+
+
+///Macro for comparing the key and the element
+class GIM_HASH_NODE_CMP_KEY_MACRO
+{
+public:
+	template<class T>
+	inline int operator() ( const T& a, GUINT key)
+	{
+		return ((int)(a.m_key - key));
+	}
+};
+
+///Macro for comparing Hash nodes
+class GIM_HASH_NODE_CMP_MACRO
+{
+public:
+	template<class T>
+	inline int operator() ( const T& a, const T& b )
+	{
+		return ((int)(a.m_key - b.m_key));
+	}
+};
+
+
+
+
+
+//! Sorting for hash table
+/*!
+switch automatically between quicksort and radixsort
+*/
+template<typename T>
+void gim_sort_hash_node_array(T * array, GUINT array_count)
+{
+    if(array_count<GIM_MIN_RADIX_SORT_SIZE)
+    {
+    	gim_heap_sort(array,array_count,GIM_HASH_NODE_CMP_MACRO());
+    }
+    else
+    {
+    	memcopy_elements_func cmpfunc;
+    	gim_radix_sort(array,array_count,GIM_HASH_NODE_GET_KEY(),cmpfunc);
+    }
+}
+
+
+
+
+
+
+// Note: assumes long is at least 32 bits.
+#define GIM_NUM_PRIME 28
+
+static const GUINT gim_prime_list[GIM_NUM_PRIME] =
+{
+  53ul,         97ul,         193ul,       389ul,       769ul,
+  1543ul,       3079ul,       6151ul,      12289ul,     24593ul,
+  49157ul,      98317ul,      196613ul,    393241ul,    786433ul,
+  1572869ul,    3145739ul,    6291469ul,   12582917ul,  25165843ul,
+  50331653ul,   100663319ul,  201326611ul, 402653189ul, 805306457ul,
+  1610612741ul, 3221225473ul, 4294967291ul
+};
+
+inline GUINT gim_next_prime(GUINT number)
+{
+    //Find nearest upper prime
+    GUINT result_ind = 0;
+    gim_binary_search(gim_prime_list,0,(GIM_NUM_PRIME-2),number,result_ind);
+
+    // inv: result_ind < 28
+    return gim_prime_list[result_ind];
+}
+
+
+
+//! A compact hash table implementation
+/*!
+A memory aligned compact hash table that coud be treated as an array.
+It could be a simple sorted array without the overhead of the hash key bucked, or could
+be a formely hash table with an array of keys.
+You can use switch_to_hashtable() and switch_to_sorted_array for saving space or increase speed.
+</br>
+
+<ul>
+<li> if node_size = 0, then this container becomes a simple sorted array allocator. reserve_size is used for reserve memory in m_nodes.
+When the array size reaches the size equivalent to 'min_hash_table_size', then it becomes a hash table by calling check_for_switching_to_hashtable.
+<li> If node_size != 0, then this container becomes a hash table for ever
+</ul>
+
+*/
+template<class T>
+class gim_hash_table
+{
+protected:
+    typedef GIM_HASH_TABLE_NODE<T> _node_type;
+
+    //!The nodes
+    //array< _node_type, SuperAllocator<_node_type> > m_nodes;
+    gim_array< _node_type > m_nodes;
+    //SuperBufferedArray< _node_type > m_nodes;
+    bool m_sorted;
+
+    /*! \defgroup HASH_TABLE_STRUCTURES
+    \brief
+    Hash table data management. The hash table has the indices to the corresponding m_nodes array
+    */
+    //! @{
+
+    GUINT * m_hash_table;//!<
+    GUINT m_table_size;//!<
+    GUINT m_node_size;//!<
+    GUINT m_min_hash_table_size;
+
+
+
+    //! Returns the cell index
+    inline GUINT _find_cell(GUINT hashkey)
+    {
+        _node_type * nodesptr = m_nodes.pointer();
+        GUINT start_index = (hashkey%m_table_size)*m_node_size;
+        GUINT end_index = start_index + m_node_size;
+
+        while(start_index<end_index)
+        {
+            GUINT value = m_hash_table[start_index];
+            if(value != GIM_INVALID_HASH)
+            {
+                if(nodesptr[value].m_key == hashkey) return start_index;
+            }
+            start_index++;
+        }
+        return GIM_INVALID_HASH;
+    }
+
+    //! Find the avaliable cell for the hashkey, and return an existing cell if it has the same hash key
+    inline GUINT _find_avaliable_cell(GUINT hashkey)
+    {
+        _node_type * nodesptr = m_nodes.pointer();
+        GUINT avaliable_index = GIM_INVALID_HASH;
+        GUINT start_index = (hashkey%m_table_size)*m_node_size;
+        GUINT end_index = start_index + m_node_size;
+
+        while(start_index<end_index)
+        {
+            GUINT value = m_hash_table[start_index];
+            if(value == GIM_INVALID_HASH)
+            {
+                if(avaliable_index==GIM_INVALID_HASH)
+                {
+                    avaliable_index = start_index;
+                }
+            }
+            else if(nodesptr[value].m_key == hashkey)
+            {
+                return start_index;
+            }
+            start_index++;
+        }
+        return avaliable_index;
+    }
+
+
+
+    //! reserves the memory for the hash table.
+    /*!
+    \pre hash table must be empty
+    \post reserves the memory for the hash table, an initializes all elements to GIM_INVALID_HASH.
+    */
+    inline void _reserve_table_memory(GUINT newtablesize)
+    {
+        if(newtablesize==0) return;
+        if(m_node_size==0) return;
+
+        //Get a Prime size
+
+        m_table_size = gim_next_prime(newtablesize);
+
+        GUINT datasize = m_table_size*m_node_size;
+        //Alloc the data buffer
+        m_hash_table =  (GUINT *)gim_alloc(datasize*sizeof(GUINT));
+    }
+
+    inline void _invalidate_keys()
+    {
+        GUINT datasize = m_table_size*m_node_size;
+        for(GUINT i=0;i<datasize;i++)
+        {
+            m_hash_table[i] = GIM_INVALID_HASH;// invalidate keys
+        }
+    }
+
+    //! Clear all memory for the hash table
+    inline void _clear_table_memory()
+    {
+        if(m_hash_table==NULL) return;
+        gim_free(m_hash_table);
+        m_hash_table = NULL;
+        m_table_size = 0;
+    }
+
+    //! Invalidates the keys (Assigning GIM_INVALID_HASH to all) Reorders the hash keys
+    inline void _rehash()
+    {
+        _invalidate_keys();
+
+        _node_type * nodesptr = m_nodes.pointer();
+        for(GUINT i=0;i<(GUINT)m_nodes.size();i++)
+        {
+            GUINT nodekey = nodesptr[i].m_key;
+            if(nodekey != GIM_INVALID_HASH)
+            {
+                //Search for the avaliable cell in buffer
+                GUINT index = _find_avaliable_cell(nodekey);
+
+
+				if(m_hash_table[index]!=GIM_INVALID_HASH)
+				{//The new index is alreade used... discard this new incomming object, repeated key
+				    btAssert(m_hash_table[index]==nodekey);
+					nodesptr[i].m_key = GIM_INVALID_HASH;
+				}
+				else
+				{
+					//;
+					//Assign the value for alloc
+					m_hash_table[index] = i;
+				}
+            }
+        }
+    }
+
+    //! Resize hash table indices
+    inline void _resize_table(GUINT newsize)
+    {
+        //Clear memory
+        _clear_table_memory();
+        //Alloc the data
+        _reserve_table_memory(newsize);
+        //Invalidate keys and rehash
+        _rehash();
+    }
+
+    //! Destroy hash table memory
+    inline void _destroy()
+    {
+        if(m_hash_table==NULL) return;
+        _clear_table_memory();
+    }
+
+    //! Finds an avaliable hash table cell, and resizes the table if there isn't space
+    inline GUINT _assign_hash_table_cell(GUINT hashkey)
+    {
+        GUINT cell_index = _find_avaliable_cell(hashkey);
+
+        if(cell_index==GIM_INVALID_HASH)
+        {
+            //rehashing
+            _resize_table(m_table_size+1);
+            GUINT cell_index = _find_avaliable_cell(hashkey);
+            btAssert(cell_index!=GIM_INVALID_HASH);
+        }
+        return cell_index;
+    }
+
+    //! erase by index in hash table
+    inline bool _erase_by_index_hash_table(GUINT index)
+    {
+        if(index >= m_nodes.size()) return false;
+        if(m_nodes[index].m_key != GIM_INVALID_HASH)
+        {
+            //Search for the avaliable cell in buffer
+            GUINT cell_index = _find_cell(m_nodes[index].m_key);
+
+            btAssert(cell_index!=GIM_INVALID_HASH);
+            btAssert(m_hash_table[cell_index]==index);
+
+            m_hash_table[cell_index] = GIM_INVALID_HASH;
+        }
+
+        return this->_erase_unsorted(index);
+    }
+
+    //! erase by key in hash table
+    inline bool _erase_hash_table(GUINT hashkey)
+    {
+        if(hashkey == GIM_INVALID_HASH) return false;
+
+        //Search for the avaliable cell in buffer
+        GUINT cell_index = _find_cell(hashkey);
+        if(cell_index ==GIM_INVALID_HASH) return false;
+
+        GUINT index = m_hash_table[cell_index];
+        m_hash_table[cell_index] = GIM_INVALID_HASH;
+
+        return this->_erase_unsorted(index);
+    }
+
+
+
+    //! insert an element in hash table
+    /*!
+    If the element exists, this won't insert the element
+    \return the index in the array of the existing element,or GIM_INVALID_HASH if the element has been inserted
+    If so, the element has been inserted at the last position of the array.
+    */
+    inline GUINT _insert_hash_table(GUINT hashkey, const T & value)
+    {
+        if(hashkey==GIM_INVALID_HASH)
+        {
+            //Insert anyway
+            _insert_unsorted(hashkey,value);
+            return GIM_INVALID_HASH;
+        }
+
+        GUINT cell_index = _assign_hash_table_cell(hashkey);
+
+        GUINT value_key = m_hash_table[cell_index];
+
+        if(value_key!= GIM_INVALID_HASH) return value_key;// Not overrited
+
+        m_hash_table[cell_index] = m_nodes.size();
+
+        _insert_unsorted(hashkey,value);
+        return GIM_INVALID_HASH;
+    }
+
+    //! insert an element in hash table.
+    /*!
+    If the element exists, this replaces the element.
+    \return the index in the array of the existing element,or GIM_INVALID_HASH if the element has been inserted
+    If so, the element has been inserted at the last position of the array.
+    */
+    inline GUINT _insert_hash_table_replace(GUINT hashkey, const T & value)
+    {
+        if(hashkey==GIM_INVALID_HASH)
+        {
+            //Insert anyway
+            _insert_unsorted(hashkey,value);
+            return GIM_INVALID_HASH;
+        }
+
+        GUINT cell_index = _assign_hash_table_cell(hashkey);
+
+        GUINT value_key = m_hash_table[cell_index];
+
+        if(value_key!= GIM_INVALID_HASH)
+        {//replaces the existing
+            m_nodes[value_key] = _node_type(hashkey,value);
+            return value_key;// index of the replaced element
+        }
+
+        m_hash_table[cell_index] = m_nodes.size();
+
+        _insert_unsorted(hashkey,value);
+        return GIM_INVALID_HASH;
+
+    }
+
+    //! @}
+
+    /*! \defgroup SORTED_ARRAY_STRUCTURES
+    \brief
+    Sorted array data management. The hash table has the indices to the corresponding m_nodes array
+    */
+    //! @{
+    inline bool _erase_sorted(GUINT index)
+    {
+        if(index>=(GUINT)m_nodes.size()) return false;
+        m_nodes.erase_sorted(index);
+		if(m_nodes.size()<2) m_sorted = false;
+        return true;
+    }
+
+    //! faster, but unsorted
+    inline bool _erase_unsorted(GUINT index)
+    {
+        if(index>=m_nodes.size()) return false;
+
+        GUINT lastindex = m_nodes.size()-1;
+        if(index<lastindex && m_hash_table!=0)
+        {
+			GUINT hashkey =  m_nodes[lastindex].m_key;
+			if(hashkey!=GIM_INVALID_HASH)
+			{
+				//update the new position of the last element
+				GUINT cell_index = _find_cell(hashkey);
+				btAssert(cell_index!=GIM_INVALID_HASH);
+				//new position of the last element which will be swaped
+				m_hash_table[cell_index] = index;
+			}
+        }
+        m_nodes.erase(index);
+        m_sorted = false;
+        return true;
+    }
+
+    //! Insert in position ordered
+    /*!
+    Also checks if it is needed to transform this container to a hash table, by calling check_for_switching_to_hashtable
+    */
+    inline void _insert_in_pos(GUINT hashkey, const T & value, GUINT pos)
+    {
+        m_nodes.insert(_node_type(hashkey,value),pos);
+        this->check_for_switching_to_hashtable();
+    }
+
+    //! Insert an element in an ordered array
+    inline GUINT _insert_sorted(GUINT hashkey, const T & value)
+    {
+        if(hashkey==GIM_INVALID_HASH || size()==0)
+        {
+            m_nodes.push_back(_node_type(hashkey,value));
+            return GIM_INVALID_HASH;
+        }
+        //Insert at last position
+        //Sort element
+
+
+        GUINT result_ind=0;
+        GUINT last_index = m_nodes.size()-1;
+        _node_type * ptr = m_nodes.pointer();
+
+        bool found = gim_binary_search_ex(
+        	ptr,0,last_index,result_ind,hashkey,GIM_HASH_NODE_CMP_KEY_MACRO());
+
+
+        //Insert before found index
+        if(found)
+        {
+            return result_ind;
+        }
+        else
+        {
+            _insert_in_pos(hashkey, value, result_ind);
+        }
+        return GIM_INVALID_HASH;
+    }
+
+    inline GUINT _insert_sorted_replace(GUINT hashkey, const T & value)
+    {
+        if(hashkey==GIM_INVALID_HASH || size()==0)
+        {
+            m_nodes.push_back(_node_type(hashkey,value));
+            return GIM_INVALID_HASH;
+        }
+        //Insert at last position
+        //Sort element
+        GUINT result_ind;
+        GUINT last_index = m_nodes.size()-1;
+        _node_type * ptr = m_nodes.pointer();
+
+        bool found = gim_binary_search_ex(
+        	ptr,0,last_index,result_ind,hashkey,GIM_HASH_NODE_CMP_KEY_MACRO());
+
+        //Insert before found index
+        if(found)
+        {
+            m_nodes[result_ind] = _node_type(hashkey,value);
+        }
+        else
+        {
+            _insert_in_pos(hashkey, value, result_ind);
+        }
+        return result_ind;
+    }
+
+    //! Fast insertion in m_nodes array
+    inline GUINT  _insert_unsorted(GUINT hashkey, const T & value)
+    {
+        m_nodes.push_back(_node_type(hashkey,value));
+        m_sorted = false;
+        return GIM_INVALID_HASH;
+    }
+
+    //! @}
+
+
+public:
+
+    /*!
+        <li> if node_size = 0, then this container becomes a simple sorted array allocator. reserve_size is used for reserve memory in m_nodes.
+        When the array size reaches the size equivalent to 'min_hash_table_size', then it becomes a hash table by calling check_for_switching_to_hashtable.
+        <li> If node_size != 0, then this container becomes a hash table for ever
+        </ul>
+    */
+    gim_hash_table(GUINT reserve_size = GIM_DEFAULT_HASH_TABLE_SIZE,
+                     GUINT node_size = GIM_DEFAULT_HASH_TABLE_NODE_SIZE,
+                     GUINT min_hash_table_size = GIM_INVALID_HASH)
+    {
+        m_hash_table = NULL;
+        m_table_size = 0;
+        m_sorted = false;
+        m_node_size = node_size;
+        m_min_hash_table_size = min_hash_table_size;
+
+        if(m_node_size!=0)
+        {
+            if(reserve_size!=0)
+            {
+                m_nodes.reserve(reserve_size);
+                _reserve_table_memory(reserve_size);
+                _invalidate_keys();
+            }
+            else
+            {
+                m_nodes.reserve(GIM_DEFAULT_HASH_TABLE_SIZE);
+                _reserve_table_memory(GIM_DEFAULT_HASH_TABLE_SIZE);
+                _invalidate_keys();
+            }
+        }
+        else if(reserve_size!=0)
+        {
+            m_nodes.reserve(reserve_size);
+        }
+
+    }
+
+    ~gim_hash_table()
+    {
+        _destroy();
+    }
+
+    inline bool is_hash_table()
+    {
+        if(m_hash_table) return true;
+        return false;
+    }
+
+    inline bool is_sorted()
+    {
+        if(size()<2) return true;
+        return m_sorted;
+    }
+
+    bool sort()
+    {
+        if(is_sorted()) return true;
+        if(m_nodes.size()<2) return false;
+
+
+        _node_type * ptr = m_nodes.pointer();
+        GUINT siz = m_nodes.size();
+        gim_sort_hash_node_array(ptr,siz);
+        m_sorted=true;
+
+
+
+        if(m_hash_table)
+        {
+            _rehash();
+        }
+        return true;
+    }
+
+    bool switch_to_hashtable()
+    {
+        if(m_hash_table) return false;
+        if(m_node_size==0) m_node_size = GIM_DEFAULT_HASH_TABLE_NODE_SIZE;
+        if(m_nodes.size()<GIM_DEFAULT_HASH_TABLE_SIZE)
+        {
+            _resize_table(GIM_DEFAULT_HASH_TABLE_SIZE);
+        }
+        else
+        {
+            _resize_table(m_nodes.size()+1);
+        }
+
+        return true;
+    }
+
+    bool switch_to_sorted_array()
+    {
+        if(m_hash_table==NULL) return true;
+        _clear_table_memory();
+        return sort();
+    }
+
+    //!If the container reaches the
+    bool check_for_switching_to_hashtable()
+    {
+        if(this->m_hash_table) return true;
+
+        if(!(m_nodes.size()< m_min_hash_table_size))
+        {
+            if(m_node_size == 0)
+            {
+                m_node_size = GIM_DEFAULT_HASH_TABLE_NODE_SIZE;
+            }
+
+            _resize_table(m_nodes.size()+1);
+            return true;
+        }
+        return false;
+    }
+
+    inline void set_sorted(bool value)
+    {
+    	m_sorted = value;
+    }
+
+    //! Retrieves the amount of keys.
+    inline GUINT size() const
+    {
+        return m_nodes.size();
+    }
+
+    //! Retrieves the hash key.
+    inline GUINT get_key(GUINT index) const
+    {
+        return m_nodes[index].m_key;
+    }
+
+    //! Retrieves the value by index
+    /*!
+    */
+    inline T * get_value_by_index(GUINT index)
+    {
+        return &m_nodes[index].m_data;
+    }
+
+    inline const T& operator[](GUINT index) const
+    {
+        return m_nodes[index].m_data;
+    }
+
+    inline T& operator[](GUINT index)
+    {
+        return m_nodes[index].m_data;
+    }
+
+    //! Finds the index of the element with the key
+    /*!
+    \return the index in the array of the existing element,or GIM_INVALID_HASH if the element has been inserted
+    If so, the element has been inserted at the last position of the array.
+    */
+    inline GUINT find(GUINT hashkey)
+    {
+        if(m_hash_table)
+        {
+            GUINT cell_index = _find_cell(hashkey);
+            if(cell_index==GIM_INVALID_HASH) return GIM_INVALID_HASH;
+            return m_hash_table[cell_index];
+        }
+		GUINT last_index = m_nodes.size();
+        if(last_index<2)
+        {
+			if(last_index==0) return GIM_INVALID_HASH;
+            if(m_nodes[0].m_key == hashkey) return 0;
+            return GIM_INVALID_HASH;
+        }
+        else if(m_sorted)
+        {
+            //Binary search
+            GUINT result_ind = 0;
+			last_index--;
+            _node_type *  ptr =  m_nodes.pointer();
+
+            bool found = gim_binary_search_ex(ptr,0,last_index,result_ind,hashkey,GIM_HASH_NODE_CMP_KEY_MACRO());
+
+
+            if(found) return result_ind;
+        }
+        return GIM_INVALID_HASH;
+    }
+
+    //! Retrieves the value associated with the index
+    /*!
+    \return the found element, or null
+    */
+    inline T * get_value(GUINT hashkey)
+    {
+        GUINT index = find(hashkey);
+        if(index == GIM_INVALID_HASH) return NULL;
+        return &m_nodes[index].m_data;
+    }
+
+
+    /*!
+    */
+    inline bool erase_by_index(GUINT index)
+    {
+        if(index > m_nodes.size()) return false;
+
+        if(m_hash_table == NULL)
+        {
+            if(is_sorted())
+            {
+                return this->_erase_sorted(index);
+            }
+            else
+            {
+                return this->_erase_unsorted(index);
+            }
+        }
+        else
+        {
+            return this->_erase_by_index_hash_table(index);
+        }
+        return false;
+    }
+
+
+
+    inline bool erase_by_index_unsorted(GUINT index)
+    {
+        if(index > m_nodes.size()) return false;
+
+        if(m_hash_table == NULL)
+        {
+            return this->_erase_unsorted(index);
+        }
+        else
+        {
+            return this->_erase_by_index_hash_table(index);
+        }
+        return false;
+    }
+
+
+
+    /*!
+
+    */
+    inline bool erase_by_key(GUINT hashkey)
+    {
+        if(size()==0) return false;
+
+        if(m_hash_table)
+        {
+            return this->_erase_hash_table(hashkey);
+        }
+        //Binary search
+
+        if(is_sorted()==false) return false;
+
+        GUINT result_ind = find(hashkey);
+        if(result_ind!= GIM_INVALID_HASH)
+        {
+            return this->_erase_sorted(result_ind);
+        }
+        return false;
+    }
+
+    void clear()
+    {
+        m_nodes.clear();
+
+        if(m_hash_table==NULL) return;
+        GUINT datasize = m_table_size*m_node_size;
+        //Initialize the hashkeys.
+        GUINT i;
+        for(i=0;i<datasize;i++)
+        {
+            m_hash_table[i] = GIM_INVALID_HASH;// invalidate keys
+        }
+		m_sorted = false;
+    }
+
+    //! Insert an element into the hash
+    /*!
+    \return If GIM_INVALID_HASH, the object has been inserted succesfully. Else it returns the position
+    of the existing element.
+    */
+    inline GUINT insert(GUINT hashkey, const T & element)
+    {
+        if(m_hash_table)
+        {
+            return this->_insert_hash_table(hashkey,element);
+        }
+        if(this->is_sorted())
+        {
+            return this->_insert_sorted(hashkey,element);
+        }
+        return this->_insert_unsorted(hashkey,element);
+    }
+
+    //! Insert an element into the hash, and could overrite an existing object with the same hash.
+    /*!
+    \return If GIM_INVALID_HASH, the object has been inserted succesfully. Else it returns the position
+    of the replaced element.
+    */
+    inline GUINT insert_override(GUINT hashkey, const T & element)
+    {
+        if(m_hash_table)
+        {
+            return this->_insert_hash_table_replace(hashkey,element);
+        }
+        if(this->is_sorted())
+        {
+            return this->_insert_sorted_replace(hashkey,element);
+        }
+        this->_insert_unsorted(hashkey,element);
+        return m_nodes.size();
+    }
+
+
+
+    //! Insert an element into the hash,But if this container is a sorted array, this inserts it unsorted
+    /*!
+    */
+    inline GUINT insert_unsorted(GUINT hashkey,const T & element)
+    {
+        if(m_hash_table)
+        {
+            return this->_insert_hash_table(hashkey,element);
+        }
+        return this->_insert_unsorted(hashkey,element);
+    }
+
+
+};
+
+//! @}
+
+
+
+#endif // GIM_CONTAINERS_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_linear_math.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_linear_math.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_linear_math.h	(revision 2122)
@@ -0,0 +1,1584 @@
+#ifndef GIM_LINEAR_H_INCLUDED
+#define GIM_LINEAR_H_INCLUDED
+
+/*! \file gim_linear_math.h
+*\author Francisco Len Nßjera
+Type Independant Vector and matrix operations.
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "gim_math.h"
+#include "gim_geom_types.h"
+
+
+
+/*! \defgroup VECTOR_OPERATIONS
+T
+Operations for vectors : vec2f,vec3f and vec4f
+*/
+//! @{
+
+//! Zero out a 2D vector
+#define VEC_ZERO_2(a)				\
+{						\
+   (a)[0] = (a)[1] = 0.0f;			\
+}\
+
+
+//! Zero out a 3D vector
+#define VEC_ZERO(a)				\
+{						\
+   (a)[0] = (a)[1] = (a)[2] = 0.0f;		\
+}\
+
+
+/// Zero out a 4D vector
+#define VEC_ZERO_4(a)				\
+{						\
+   (a)[0] = (a)[1] = (a)[2] = (a)[3] = 0.0f;	\
+}\
+
+
+/// Vector copy
+#define VEC_COPY_2(b,a)				\
+{						\
+   (b)[0] = (a)[0];				\
+   (b)[1] = (a)[1];				\
+}\
+
+
+/// Copy 3D vector
+#define VEC_COPY(b,a)				\
+{						\
+   (b)[0] = (a)[0];				\
+   (b)[1] = (a)[1];				\
+   (b)[2] = (a)[2];				\
+}\
+
+
+/// Copy 4D vector
+#define VEC_COPY_4(b,a)				\
+{						\
+   (b)[0] = (a)[0];				\
+   (b)[1] = (a)[1];				\
+   (b)[2] = (a)[2];				\
+   (b)[3] = (a)[3];				\
+}\
+
+/// VECTOR SWAP
+#define VEC_SWAP(b,a)				\
+{  \
+    GIM_SWAP_NUMBERS((b)[0],(a)[0]);\
+    GIM_SWAP_NUMBERS((b)[1],(a)[1]);\
+    GIM_SWAP_NUMBERS((b)[2],(a)[2]);\
+}\
+
+/// Vector difference
+#define VEC_DIFF_2(v21,v2,v1)			\
+{						\
+   (v21)[0] = (v2)[0] - (v1)[0];		\
+   (v21)[1] = (v2)[1] - (v1)[1];		\
+}\
+
+
+/// Vector difference
+#define VEC_DIFF(v21,v2,v1)			\
+{						\
+   (v21)[0] = (v2)[0] - (v1)[0];		\
+   (v21)[1] = (v2)[1] - (v1)[1];		\
+   (v21)[2] = (v2)[2] - (v1)[2];		\
+}\
+
+
+/// Vector difference
+#define VEC_DIFF_4(v21,v2,v1)			\
+{						\
+   (v21)[0] = (v2)[0] - (v1)[0];		\
+   (v21)[1] = (v2)[1] - (v1)[1];		\
+   (v21)[2] = (v2)[2] - (v1)[2];		\
+   (v21)[3] = (v2)[3] - (v1)[3];		\
+}\
+
+
+/// Vector sum
+#define VEC_SUM_2(v21,v2,v1)			\
+{						\
+   (v21)[0] = (v2)[0] + (v1)[0];		\
+   (v21)[1] = (v2)[1] + (v1)[1];		\
+}\
+
+
+/// Vector sum
+#define VEC_SUM(v21,v2,v1)			\
+{						\
+   (v21)[0] = (v2)[0] + (v1)[0];		\
+   (v21)[1] = (v2)[1] + (v1)[1];		\
+   (v21)[2] = (v2)[2] + (v1)[2];		\
+}\
+
+
+/// Vector sum
+#define VEC_SUM_4(v21,v2,v1)			\
+{						\
+   (v21)[0] = (v2)[0] + (v1)[0];		\
+   (v21)[1] = (v2)[1] + (v1)[1];		\
+   (v21)[2] = (v2)[2] + (v1)[2];		\
+   (v21)[3] = (v2)[3] + (v1)[3];		\
+}\
+
+
+/// scalar times vector
+#define VEC_SCALE_2(c,a,b)			\
+{						\
+   (c)[0] = (a)*(b)[0];				\
+   (c)[1] = (a)*(b)[1];				\
+}\
+
+
+/// scalar times vector
+#define VEC_SCALE(c,a,b)			\
+{						\
+   (c)[0] = (a)*(b)[0];				\
+   (c)[1] = (a)*(b)[1];				\
+   (c)[2] = (a)*(b)[2];				\
+}\
+
+
+/// scalar times vector
+#define VEC_SCALE_4(c,a,b)			\
+{						\
+   (c)[0] = (a)*(b)[0];				\
+   (c)[1] = (a)*(b)[1];				\
+   (c)[2] = (a)*(b)[2];				\
+   (c)[3] = (a)*(b)[3];				\
+}\
+
+
+/// accumulate scaled vector
+#define VEC_ACCUM_2(c,a,b)			\
+{						\
+   (c)[0] += (a)*(b)[0];			\
+   (c)[1] += (a)*(b)[1];			\
+}\
+
+
+/// accumulate scaled vector
+#define VEC_ACCUM(c,a,b)			\
+{						\
+   (c)[0] += (a)*(b)[0];			\
+   (c)[1] += (a)*(b)[1];			\
+   (c)[2] += (a)*(b)[2];			\
+}\
+
+
+/// accumulate scaled vector
+#define VEC_ACCUM_4(c,a,b)			\
+{						\
+   (c)[0] += (a)*(b)[0];			\
+   (c)[1] += (a)*(b)[1];			\
+   (c)[2] += (a)*(b)[2];			\
+   (c)[3] += (a)*(b)[3];			\
+}\
+
+
+/// Vector dot product
+#define VEC_DOT_2(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1])
+
+
+/// Vector dot product
+#define VEC_DOT(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2])
+
+/// Vector dot product
+#define VEC_DOT_4(a,b)	((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3])
+
+/// vector impact parameter (squared)
+#define VEC_IMPACT_SQ(bsq,direction,position) {\
+   GREAL _llel_ = VEC_DOT(direction, position);\
+   bsq = VEC_DOT(position, position) - _llel_*_llel_;\
+}\
+
+
+/// vector impact parameter
+#define VEC_IMPACT(bsq,direction,position)	{\
+   VEC_IMPACT_SQ(bsq,direction,position);		\
+   GIM_SQRT(bsq,bsq);					\
+}\
+
+/// Vector length
+#define VEC_LENGTH_2(a,l)\
+{\
+    GREAL _pp = VEC_DOT_2(a,a);\
+    GIM_SQRT(_pp,l);\
+}\
+
+
+/// Vector length
+#define VEC_LENGTH(a,l)\
+{\
+    GREAL _pp = VEC_DOT(a,a);\
+    GIM_SQRT(_pp,l);\
+}\
+
+
+/// Vector length
+#define VEC_LENGTH_4(a,l)\
+{\
+    GREAL _pp = VEC_DOT_4(a,a);\
+    GIM_SQRT(_pp,l);\
+}\
+
+/// Vector inv length
+#define VEC_INV_LENGTH_2(a,l)\
+{\
+    GREAL _pp = VEC_DOT_2(a,a);\
+    GIM_INV_SQRT(_pp,l);\
+}\
+
+
+/// Vector inv length
+#define VEC_INV_LENGTH(a,l)\
+{\
+    GREAL _pp = VEC_DOT(a,a);\
+    GIM_INV_SQRT(_pp,l);\
+}\
+
+
+/// Vector inv length
+#define VEC_INV_LENGTH_4(a,l)\
+{\
+    GREAL _pp = VEC_DOT_4(a,a);\
+    GIM_INV_SQRT(_pp,l);\
+}\
+
+
+
+/// distance between two points
+#define VEC_DISTANCE(_len,_va,_vb) {\
+    vec3f _tmp_;				\
+    VEC_DIFF(_tmp_, _vb, _va);			\
+    VEC_LENGTH(_tmp_,_len);			\
+}\
+
+
+/// Vector length
+#define VEC_CONJUGATE_LENGTH(a,l)\
+{\
+    GREAL _pp = 1.0 - a[0]*a[0] - a[1]*a[1] - a[2]*a[2];\
+    GIM_SQRT(_pp,l);\
+}\
+
+
+/// Vector length
+#define VEC_NORMALIZE(a) {	\
+    GREAL len;\
+    VEC_INV_LENGTH(a,len); \
+    if(len<G_REAL_INFINITY)\
+    {\
+        a[0] *= len;				\
+        a[1] *= len;				\
+        a[2] *= len;				\
+    }						\
+}\
+
+/// Set Vector size
+#define VEC_RENORMALIZE(a,newlen) {	\
+    GREAL len;\
+    VEC_INV_LENGTH(a,len); \
+    if(len<G_REAL_INFINITY)\
+    {\
+        len *= newlen;\
+        a[0] *= len;				\
+        a[1] *= len;				\
+        a[2] *= len;				\
+    }						\
+}\
+
+/// Vector cross
+#define VEC_CROSS(c,a,b)		\
+{						\
+   c[0] = (a)[1] * (b)[2] - (a)[2] * (b)[1];	\
+   c[1] = (a)[2] * (b)[0] - (a)[0] * (b)[2];	\
+   c[2] = (a)[0] * (b)[1] - (a)[1] * (b)[0];	\
+}\
+
+
+/*! Vector perp -- assumes that n is of unit length
+ * accepts vector v, subtracts out any component parallel to n */
+#define VEC_PERPENDICULAR(vp,v,n)			\
+{						\
+   GREAL dot = VEC_DOT(v, n);			\
+   vp[0] = (v)[0] - dot*(n)[0];		\
+   vp[1] = (v)[1] - dot*(n)[1];		\
+   vp[2] = (v)[2] - dot*(n)[2];		\
+}\
+
+
+/*! Vector parallel -- assumes that n is of unit length */
+#define VEC_PARALLEL(vp,v,n)			\
+{						\
+   GREAL dot = VEC_DOT(v, n);			\
+   vp[0] = (dot) * (n)[0];			\
+   vp[1] = (dot) * (n)[1];			\
+   vp[2] = (dot) * (n)[2];			\
+}\
+
+/*! Same as Vector parallel --  n can have any length
+ * accepts vector v, subtracts out any component perpendicular to n */
+#define VEC_PROJECT(vp,v,n)			\
+{ \
+	GREAL scalar = VEC_DOT(v, n);			\
+	scalar/= VEC_DOT(n, n); \
+	vp[0] = (scalar) * (n)[0];			\
+    vp[1] = (scalar) * (n)[1];			\
+    vp[2] = (scalar) * (n)[2];			\
+}\
+
+
+/*! accepts vector v*/
+#define VEC_UNPROJECT(vp,v,n)			\
+{ \
+	GREAL scalar = VEC_DOT(v, n);			\
+	scalar = VEC_DOT(n, n)/scalar; \
+	vp[0] = (scalar) * (n)[0];			\
+    vp[1] = (scalar) * (n)[1];			\
+    vp[2] = (scalar) * (n)[2];			\
+}\
+
+
+/*! Vector reflection -- assumes n is of unit length
+ Takes vector v, reflects it against reflector n, and returns vr */
+#define VEC_REFLECT(vr,v,n)			\
+{						\
+   GREAL dot = VEC_DOT(v, n);			\
+   vr[0] = (v)[0] - 2.0 * (dot) * (n)[0];	\
+   vr[1] = (v)[1] - 2.0 * (dot) * (n)[1];	\
+   vr[2] = (v)[2] - 2.0 * (dot) * (n)[2];	\
+}\
+
+
+/*! Vector blending
+Takes two vectors a, b, blends them together with two scalars */
+#define VEC_BLEND_AB(vr,sa,a,sb,b)			\
+{						\
+   vr[0] = (sa) * (a)[0] + (sb) * (b)[0];	\
+   vr[1] = (sa) * (a)[1] + (sb) * (b)[1];	\
+   vr[2] = (sa) * (a)[2] + (sb) * (b)[2];	\
+}\
+
+/*! Vector blending
+Takes two vectors a, b, blends them together with s <=1 */
+#define VEC_BLEND(vr,a,b,s) VEC_BLEND_AB(vr,(1-s),a,s,b)
+
+#define VEC_SET3(a,b,op,c) a[0]=b[0] op c[0]; a[1]=b[1] op c[1]; a[2]=b[2] op c[2];
+
+//! Finds the bigger cartesian coordinate from a vector
+#define VEC_MAYOR_COORD(vec, maxc)\
+{\
+	GREAL A[] = {fabs(vec[0]),fabs(vec[1]),fabs(vec[2])};\
+    maxc =  A[0]>A[1]?(A[0]>A[2]?0:2):(A[1]>A[2]?1:2);\
+}\
+
+//! Finds the 2 smallest cartesian coordinates from a vector
+#define VEC_MINOR_AXES(vec, i0, i1)\
+{\
+	VEC_MAYOR_COORD(vec,i0);\
+	i0 = (i0+1)%3;\
+	i1 = (i0+1)%3;\
+}\
+
+
+
+
+#define VEC_EQUAL(v1,v2) (v1[0]==v2[0]&&v1[1]==v2[1]&&v1[2]==v2[2])
+
+#define VEC_NEAR_EQUAL(v1,v2) (GIM_NEAR_EQUAL(v1[0],v2[0])&&GIM_NEAR_EQUAL(v1[1],v2[1])&&GIM_NEAR_EQUAL(v1[2],v2[2]))
+
+
+/// Vector cross
+#define X_AXIS_CROSS_VEC(dst,src)\
+{					   \
+	dst[0] = 0.0f;     \
+	dst[1] = -src[2];  \
+	dst[2] = src[1];  \
+}\
+
+#define Y_AXIS_CROSS_VEC(dst,src)\
+{					   \
+	dst[0] = src[2];     \
+	dst[1] = 0.0f;  \
+	dst[2] = -src[0];  \
+}\
+
+#define Z_AXIS_CROSS_VEC(dst,src)\
+{					   \
+	dst[0] = -src[1];     \
+	dst[1] = src[0];  \
+	dst[2] = 0.0f;  \
+}\
+
+
+
+//! @}
+
+
+/*! \defgroup MATRIX_OPERATIONS
+Operations for matrices : mat2f, mat3f and mat4f
+*/
+//! @{
+
+/// initialize matrix
+#define IDENTIFY_MATRIX_3X3(m)			\
+{						\
+   m[0][0] = 1.0;				\
+   m[0][1] = 0.0;				\
+   m[0][2] = 0.0;				\
+						\
+   m[1][0] = 0.0;				\
+   m[1][1] = 1.0;				\
+   m[1][2] = 0.0;				\
+						\
+   m[2][0] = 0.0;				\
+   m[2][1] = 0.0;				\
+   m[2][2] = 1.0;				\
+}\
+
+/*! initialize matrix */
+#define IDENTIFY_MATRIX_4X4(m)			\
+{						\
+   m[0][0] = 1.0;				\
+   m[0][1] = 0.0;				\
+   m[0][2] = 0.0;				\
+   m[0][3] = 0.0;				\
+						\
+   m[1][0] = 0.0;				\
+   m[1][1] = 1.0;				\
+   m[1][2] = 0.0;				\
+   m[1][3] = 0.0;				\
+						\
+   m[2][0] = 0.0;				\
+   m[2][1] = 0.0;				\
+   m[2][2] = 1.0;				\
+   m[2][3] = 0.0;				\
+						\
+   m[3][0] = 0.0;				\
+   m[3][1] = 0.0;				\
+   m[3][2] = 0.0;				\
+   m[3][3] = 1.0;				\
+}\
+
+/*! initialize matrix */
+#define ZERO_MATRIX_4X4(m)			\
+{						\
+   m[0][0] = 0.0;				\
+   m[0][1] = 0.0;				\
+   m[0][2] = 0.0;				\
+   m[0][3] = 0.0;				\
+						\
+   m[1][0] = 0.0;				\
+   m[1][1] = 0.0;				\
+   m[1][2] = 0.0;				\
+   m[1][3] = 0.0;				\
+						\
+   m[2][0] = 0.0;				\
+   m[2][1] = 0.0;				\
+   m[2][2] = 0.0;				\
+   m[2][3] = 0.0;				\
+						\
+   m[3][0] = 0.0;				\
+   m[3][1] = 0.0;				\
+   m[3][2] = 0.0;				\
+   m[3][3] = 0.0;				\
+}\
+
+/*! matrix rotation  X */
+#define ROTX_CS(m,cosine,sine)		\
+{					\
+   /* rotation about the x-axis */	\
+					\
+   m[0][0] = 1.0;			\
+   m[0][1] = 0.0;			\
+   m[0][2] = 0.0;			\
+   m[0][3] = 0.0;			\
+					\
+   m[1][0] = 0.0;			\
+   m[1][1] = (cosine);			\
+   m[1][2] = (sine);			\
+   m[1][3] = 0.0;			\
+					\
+   m[2][0] = 0.0;			\
+   m[2][1] = -(sine);			\
+   m[2][2] = (cosine);			\
+   m[2][3] = 0.0;			\
+					\
+   m[3][0] = 0.0;			\
+   m[3][1] = 0.0;			\
+   m[3][2] = 0.0;			\
+   m[3][3] = 1.0;			\
+}\
+
+/*! matrix rotation  Y */
+#define ROTY_CS(m,cosine,sine)		\
+{					\
+   /* rotation about the y-axis */	\
+					\
+   m[0][0] = (cosine);			\
+   m[0][1] = 0.0;			\
+   m[0][2] = -(sine);			\
+   m[0][3] = 0.0;			\
+					\
+   m[1][0] = 0.0;			\
+   m[1][1] = 1.0;			\
+   m[1][2] = 0.0;			\
+   m[1][3] = 0.0;			\
+					\
+   m[2][0] = (sine);			\
+   m[2][1] = 0.0;			\
+   m[2][2] = (cosine);			\
+   m[2][3] = 0.0;			\
+					\
+   m[3][0] = 0.0;			\
+   m[3][1] = 0.0;			\
+   m[3][2] = 0.0;			\
+   m[3][3] = 1.0;			\
+}\
+
+/*! matrix rotation  Z */
+#define ROTZ_CS(m,cosine,sine)		\
+{					\
+   /* rotation about the z-axis */	\
+					\
+   m[0][0] = (cosine);			\
+   m[0][1] = (sine);			\
+   m[0][2] = 0.0;			\
+   m[0][3] = 0.0;			\
+					\
+   m[1][0] = -(sine);			\
+   m[1][1] = (cosine);			\
+   m[1][2] = 0.0;			\
+   m[1][3] = 0.0;			\
+					\
+   m[2][0] = 0.0;			\
+   m[2][1] = 0.0;			\
+   m[2][2] = 1.0;			\
+   m[2][3] = 0.0;			\
+					\
+   m[3][0] = 0.0;			\
+   m[3][1] = 0.0;			\
+   m[3][2] = 0.0;			\
+   m[3][3] = 1.0;			\
+}\
+
+/*! matrix copy */
+#define COPY_MATRIX_2X2(b,a)	\
+{				\
+   b[0][0] = a[0][0];		\
+   b[0][1] = a[0][1];		\
+				\
+   b[1][0] = a[1][0];		\
+   b[1][1] = a[1][1];		\
+				\
+}\
+
+
+/*! matrix copy */
+#define COPY_MATRIX_2X3(b,a)	\
+{				\
+   b[0][0] = a[0][0];		\
+   b[0][1] = a[0][1];		\
+   b[0][2] = a[0][2];		\
+				\
+   b[1][0] = a[1][0];		\
+   b[1][1] = a[1][1];		\
+   b[1][2] = a[1][2];		\
+}\
+
+
+/*! matrix copy */
+#define COPY_MATRIX_3X3(b,a)	\
+{				\
+   b[0][0] = a[0][0];		\
+   b[0][1] = a[0][1];		\
+   b[0][2] = a[0][2];		\
+				\
+   b[1][0] = a[1][0];		\
+   b[1][1] = a[1][1];		\
+   b[1][2] = a[1][2];		\
+				\
+   b[2][0] = a[2][0];		\
+   b[2][1] = a[2][1];		\
+   b[2][2] = a[2][2];		\
+}\
+
+
+/*! matrix copy */
+#define COPY_MATRIX_4X4(b,a)	\
+{				\
+   b[0][0] = a[0][0];		\
+   b[0][1] = a[0][1];		\
+   b[0][2] = a[0][2];		\
+   b[0][3] = a[0][3];		\
+				\
+   b[1][0] = a[1][0];		\
+   b[1][1] = a[1][1];		\
+   b[1][2] = a[1][2];		\
+   b[1][3] = a[1][3];		\
+				\
+   b[2][0] = a[2][0];		\
+   b[2][1] = a[2][1];		\
+   b[2][2] = a[2][2];		\
+   b[2][3] = a[2][3];		\
+				\
+   b[3][0] = a[3][0];		\
+   b[3][1] = a[3][1];		\
+   b[3][2] = a[3][2];		\
+   b[3][3] = a[3][3];		\
+}\
+
+
+/*! matrix transpose */
+#define TRANSPOSE_MATRIX_2X2(b,a)	\
+{				\
+   b[0][0] = a[0][0];		\
+   b[0][1] = a[1][0];		\
+				\
+   b[1][0] = a[0][1];		\
+   b[1][1] = a[1][1];		\
+}\
+
+
+/*! matrix transpose */
+#define TRANSPOSE_MATRIX_3X3(b,a)	\
+{				\
+   b[0][0] = a[0][0];		\
+   b[0][1] = a[1][0];		\
+   b[0][2] = a[2][0];		\
+				\
+   b[1][0] = a[0][1];		\
+   b[1][1] = a[1][1];		\
+   b[1][2] = a[2][1];		\
+				\
+   b[2][0] = a[0][2];		\
+   b[2][1] = a[1][2];		\
+   b[2][2] = a[2][2];		\
+}\
+
+
+/*! matrix transpose */
+#define TRANSPOSE_MATRIX_4X4(b,a)	\
+{				\
+   b[0][0] = a[0][0];		\
+   b[0][1] = a[1][0];		\
+   b[0][2] = a[2][0];		\
+   b[0][3] = a[3][0];		\
+				\
+   b[1][0] = a[0][1];		\
+   b[1][1] = a[1][1];		\
+   b[1][2] = a[2][1];		\
+   b[1][3] = a[3][1];		\
+				\
+   b[2][0] = a[0][2];		\
+   b[2][1] = a[1][2];		\
+   b[2][2] = a[2][2];		\
+   b[2][3] = a[3][2];		\
+				\
+   b[3][0] = a[0][3];		\
+   b[3][1] = a[1][3];		\
+   b[3][2] = a[2][3];		\
+   b[3][3] = a[3][3];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define SCALE_MATRIX_2X2(b,s,a)		\
+{					\
+   b[0][0] = (s) * a[0][0];		\
+   b[0][1] = (s) * a[0][1];		\
+					\
+   b[1][0] = (s) * a[1][0];		\
+   b[1][1] = (s) * a[1][1];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define SCALE_MATRIX_3X3(b,s,a)		\
+{					\
+   b[0][0] = (s) * a[0][0];		\
+   b[0][1] = (s) * a[0][1];		\
+   b[0][2] = (s) * a[0][2];		\
+					\
+   b[1][0] = (s) * a[1][0];		\
+   b[1][1] = (s) * a[1][1];		\
+   b[1][2] = (s) * a[1][2];		\
+					\
+   b[2][0] = (s) * a[2][0];		\
+   b[2][1] = (s) * a[2][1];		\
+   b[2][2] = (s) * a[2][2];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define SCALE_MATRIX_4X4(b,s,a)		\
+{					\
+   b[0][0] = (s) * a[0][0];		\
+   b[0][1] = (s) * a[0][1];		\
+   b[0][2] = (s) * a[0][2];		\
+   b[0][3] = (s) * a[0][3];		\
+					\
+   b[1][0] = (s) * a[1][0];		\
+   b[1][1] = (s) * a[1][1];		\
+   b[1][2] = (s) * a[1][2];		\
+   b[1][3] = (s) * a[1][3];		\
+					\
+   b[2][0] = (s) * a[2][0];		\
+   b[2][1] = (s) * a[2][1];		\
+   b[2][2] = (s) * a[2][2];		\
+   b[2][3] = (s) * a[2][3];		\
+					\
+   b[3][0] = s * a[3][0];		\
+   b[3][1] = s * a[3][1];		\
+   b[3][2] = s * a[3][2];		\
+   b[3][3] = s * a[3][3];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define SCALE_VEC_MATRIX_2X2(b,svec,a)		\
+{					\
+   b[0][0] = svec[0] * a[0][0];		\
+   b[1][0] = svec[0] * a[1][0];		\
+					\
+   b[0][1] = svec[1] * a[0][1];		\
+   b[1][1] = svec[1] * a[1][1];		\
+}\
+
+
+/*! multiply matrix by scalar. Each columns is scaled by each scalar vector component */
+#define SCALE_VEC_MATRIX_3X3(b,svec,a)		\
+{					\
+   b[0][0] = svec[0] * a[0][0];		\
+   b[1][0] = svec[0] * a[1][0];		\
+   b[2][0] = svec[0] * a[2][0];		\
+					\
+   b[0][1] = svec[1] * a[0][1];		\
+   b[1][1] = svec[1] * a[1][1];		\
+   b[2][1] = svec[1] * a[2][1];		\
+					\
+   b[0][2] = svec[2] * a[0][2];		\
+   b[1][2] = svec[2] * a[1][2];		\
+   b[2][2] = svec[2] * a[2][2];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define SCALE_VEC_MATRIX_4X4(b,svec,a)		\
+{					\
+   b[0][0] = svec[0] * a[0][0];		\
+   b[1][0] = svec[0] * a[1][0];		\
+   b[2][0] = svec[0] * a[2][0];		\
+   b[3][0] = svec[0] * a[3][0];		\
+					\
+   b[0][1] = svec[1] * a[0][1];		\
+   b[1][1] = svec[1] * a[1][1];		\
+   b[2][1] = svec[1] * a[2][1];		\
+   b[3][1] = svec[1] * a[3][1];		\
+					\
+   b[0][2] = svec[2] * a[0][2];		\
+   b[1][2] = svec[2] * a[1][2];		\
+   b[2][2] = svec[2] * a[2][2];		\
+   b[3][2] = svec[2] * a[3][2];		\
+   \
+   b[0][3] = svec[3] * a[0][3];		\
+   b[1][3] = svec[3] * a[1][3];		\
+   b[2][3] = svec[3] * a[2][3];		\
+   b[3][3] = svec[3] * a[3][3];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define ACCUM_SCALE_MATRIX_2X2(b,s,a)		\
+{					\
+   b[0][0] += (s) * a[0][0];		\
+   b[0][1] += (s) * a[0][1];		\
+					\
+   b[1][0] += (s) * a[1][0];		\
+   b[1][1] += (s) * a[1][1];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define ACCUM_SCALE_MATRIX_3X3(b,s,a)		\
+{					\
+   b[0][0] += (s) * a[0][0];		\
+   b[0][1] += (s) * a[0][1];		\
+   b[0][2] += (s) * a[0][2];		\
+					\
+   b[1][0] += (s) * a[1][0];		\
+   b[1][1] += (s) * a[1][1];		\
+   b[1][2] += (s) * a[1][2];		\
+					\
+   b[2][0] += (s) * a[2][0];		\
+   b[2][1] += (s) * a[2][1];		\
+   b[2][2] += (s) * a[2][2];		\
+}\
+
+
+/*! multiply matrix by scalar */
+#define ACCUM_SCALE_MATRIX_4X4(b,s,a)		\
+{					\
+   b[0][0] += (s) * a[0][0];		\
+   b[0][1] += (s) * a[0][1];		\
+   b[0][2] += (s) * a[0][2];		\
+   b[0][3] += (s) * a[0][3];		\
+					\
+   b[1][0] += (s) * a[1][0];		\
+   b[1][1] += (s) * a[1][1];		\
+   b[1][2] += (s) * a[1][2];		\
+   b[1][3] += (s) * a[1][3];		\
+					\
+   b[2][0] += (s) * a[2][0];		\
+   b[2][1] += (s) * a[2][1];		\
+   b[2][2] += (s) * a[2][2];		\
+   b[2][3] += (s) * a[2][3];		\
+					\
+   b[3][0] += (s) * a[3][0];		\
+   b[3][1] += (s) * a[3][1];		\
+   b[3][2] += (s) * a[3][2];		\
+   b[3][3] += (s) * a[3][3];		\
+}\
+
+/*! matrix product */
+/*! c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];*/
+#define MATRIX_PRODUCT_2X2(c,a,b)		\
+{						\
+   c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0];	\
+   c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1];	\
+						\
+   c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0];	\
+   c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1];	\
+						\
+}\
+
+/*! matrix product */
+/*! c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];*/
+#define MATRIX_PRODUCT_3X3(c,a,b)				\
+{								\
+   c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+a[0][2]*b[2][0];	\
+   c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+a[0][2]*b[2][1];	\
+   c[0][2] = a[0][0]*b[0][2]+a[0][1]*b[1][2]+a[0][2]*b[2][2];	\
+								\
+   c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]+a[1][2]*b[2][0];	\
+   c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]+a[1][2]*b[2][1];	\
+   c[1][2] = a[1][0]*b[0][2]+a[1][1]*b[1][2]+a[1][2]*b[2][2];	\
+								\
+   c[2][0] = a[2][0]*b[0][0]+a[2][1]*b[1][0]+a[2][2]*b[2][0];	\
+   c[2][1] = a[2][0]*b[0][1]+a[2][1]*b[1][1]+a[2][2]*b[2][1];	\
+   c[2][2] = a[2][0]*b[0][2]+a[2][1]*b[1][2]+a[2][2]*b[2][2];	\
+}\
+
+
+/*! matrix product */
+/*! c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];*/
+#define MATRIX_PRODUCT_4X4(c,a,b)		\
+{						\
+   c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+a[0][2]*b[2][0]+a[0][3]*b[3][0];\
+   c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+a[0][2]*b[2][1]+a[0][3]*b[3][1];\
+   c[0][2] = a[0][0]*b[0][2]+a[0][1]*b[1][2]+a[0][2]*b[2][2]+a[0][3]*b[3][2];\
+   c[0][3] = a[0][0]*b[0][3]+a[0][1]*b[1][3]+a[0][2]*b[2][3]+a[0][3]*b[3][3];\
+						\
+   c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]+a[1][2]*b[2][0]+a[1][3]*b[3][0];\
+   c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]+a[1][2]*b[2][1]+a[1][3]*b[3][1];\
+   c[1][2] = a[1][0]*b[0][2]+a[1][1]*b[1][2]+a[1][2]*b[2][2]+a[1][3]*b[3][2];\
+   c[1][3] = a[1][0]*b[0][3]+a[1][1]*b[1][3]+a[1][2]*b[2][3]+a[1][3]*b[3][3];\
+						\
+   c[2][0] = a[2][0]*b[0][0]+a[2][1]*b[1][0]+a[2][2]*b[2][0]+a[2][3]*b[3][0];\
+   c[2][1] = a[2][0]*b[0][1]+a[2][1]*b[1][1]+a[2][2]*b[2][1]+a[2][3]*b[3][1];\
+   c[2][2] = a[2][0]*b[0][2]+a[2][1]*b[1][2]+a[2][2]*b[2][2]+a[2][3]*b[3][2];\
+   c[2][3] = a[2][0]*b[0][3]+a[2][1]*b[1][3]+a[2][2]*b[2][3]+a[2][3]*b[3][3];\
+						\
+   c[3][0] = a[3][0]*b[0][0]+a[3][1]*b[1][0]+a[3][2]*b[2][0]+a[3][3]*b[3][0];\
+   c[3][1] = a[3][0]*b[0][1]+a[3][1]*b[1][1]+a[3][2]*b[2][1]+a[3][3]*b[3][1];\
+   c[3][2] = a[3][0]*b[0][2]+a[3][1]*b[1][2]+a[3][2]*b[2][2]+a[3][3]*b[3][2];\
+   c[3][3] = a[3][0]*b[0][3]+a[3][1]*b[1][3]+a[3][2]*b[2][3]+a[3][3]*b[3][3];\
+}\
+
+
+/*! matrix times vector */
+#define MAT_DOT_VEC_2X2(p,m,v)					\
+{								\
+   p[0] = m[0][0]*v[0] + m[0][1]*v[1];				\
+   p[1] = m[1][0]*v[0] + m[1][1]*v[1];				\
+}\
+
+
+/*! matrix times vector */
+#define MAT_DOT_VEC_3X3(p,m,v)					\
+{								\
+   p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2];		\
+   p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2];		\
+   p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2];		\
+}\
+
+
+/*! matrix times vector
+v is a vec4f
+*/
+#define MAT_DOT_VEC_4X4(p,m,v)					\
+{								\
+   p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2] + m[0][3]*v[3];	\
+   p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2] + m[1][3]*v[3];	\
+   p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2] + m[2][3]*v[3];	\
+   p[3] = m[3][0]*v[0] + m[3][1]*v[1] + m[3][2]*v[2] + m[3][3]*v[3];	\
+}\
+
+/*! matrix times vector
+v is a vec3f
+and m is a mat4f<br>
+Last column is added as the position
+*/
+#define MAT_DOT_VEC_3X4(p,m,v)					\
+{								\
+   p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2] + m[0][3];	\
+   p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2] + m[1][3];	\
+   p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2] + m[2][3];	\
+}\
+
+
+/*! vector transpose times matrix */
+/*! p[j] = v[0]*m[0][j] + v[1]*m[1][j] + v[2]*m[2][j]; */
+#define VEC_DOT_MAT_3X3(p,v,m)					\
+{								\
+   p[0] = v[0]*m[0][0] + v[1]*m[1][0] + v[2]*m[2][0];		\
+   p[1] = v[0]*m[0][1] + v[1]*m[1][1] + v[2]*m[2][1];		\
+   p[2] = v[0]*m[0][2] + v[1]*m[1][2] + v[2]*m[2][2];		\
+}\
+
+
+/*! affine matrix times vector */
+/** The matrix is assumed to be an affine matrix, with last two
+ * entries representing a translation */
+#define MAT_DOT_VEC_2X3(p,m,v)					\
+{								\
+   p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2];		\
+   p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2];		\
+}\
+
+//! Transform a plane
+#define MAT_TRANSFORM_PLANE_4X4(pout,m,plane)\
+{								\
+   pout[0] = m[0][0]*plane[0] + m[0][1]*plane[1]  + m[0][2]*plane[2];\
+   pout[1] = m[1][0]*plane[0] + m[1][1]*plane[1]  + m[1][2]*plane[2];\
+   pout[2] = m[2][0]*plane[0] + m[2][1]*plane[1]  + m[2][2]*plane[2];\
+   pout[3] = m[0][3]*pout[0] + m[1][3]*pout[1]  + m[2][3]*pout[2] + plane[3];\
+}\
+
+
+
+/** inverse transpose of matrix times vector
+ *
+ * This macro computes inverse transpose of matrix m,
+ * and multiplies vector v into it, to yeild vector p
+ *
+ * DANGER !!! Do Not use this on normal vectors!!!
+ * It will leave normals the wrong length !!!
+ * See macro below for use on normals.
+ */
+#define INV_TRANSP_MAT_DOT_VEC_2X2(p,m,v)			\
+{								\
+   GREAL det;						\
+								\
+   det = m[0][0]*m[1][1] - m[0][1]*m[1][0];			\
+   p[0] = m[1][1]*v[0] - m[1][0]*v[1];				\
+   p[1] = - m[0][1]*v[0] + m[0][0]*v[1];			\
+								\
+   /* if matrix not singular, and not orthonormal, then renormalize */ \
+   if ((det!=1.0f) && (det != 0.0f)) {				\
+      det = 1.0f / det;						\
+      p[0] *= det;						\
+      p[1] *= det;						\
+   }								\
+}\
+
+
+/** transform normal vector by inverse transpose of matrix
+ * and then renormalize the vector
+ *
+ * This macro computes inverse transpose of matrix m,
+ * and multiplies vector v into it, to yeild vector p
+ * Vector p is then normalized.
+ */
+#define NORM_XFORM_2X2(p,m,v)					\
+{								\
+   GREAL len;							\
+								\
+   /* do nothing if off-diagonals are zero and diagonals are 	\
+    * equal */							\
+   if ((m[0][1] != 0.0) || (m[1][0] != 0.0) || (m[0][0] != m[1][1])) { \
+      p[0] = m[1][1]*v[0] - m[1][0]*v[1];			\
+      p[1] = - m[0][1]*v[0] + m[0][0]*v[1];			\
+								\
+      len = p[0]*p[0] + p[1]*p[1];				\
+      GIM_INV_SQRT(len,len);					\
+      p[0] *= len;						\
+      p[1] *= len;						\
+   } else {							\
+      VEC_COPY_2 (p, v);					\
+   }								\
+}\
+
+
+/** outer product of vector times vector transpose
+ *
+ * The outer product of vector v and vector transpose t yeilds
+ * dyadic matrix m.
+ */
+#define OUTER_PRODUCT_2X2(m,v,t)				\
+{								\
+   m[0][0] = v[0] * t[0];					\
+   m[0][1] = v[0] * t[1];					\
+								\
+   m[1][0] = v[1] * t[0];					\
+   m[1][1] = v[1] * t[1];					\
+}\
+
+
+/** outer product of vector times vector transpose
+ *
+ * The outer product of vector v and vector transpose t yeilds
+ * dyadic matrix m.
+ */
+#define OUTER_PRODUCT_3X3(m,v,t)				\
+{								\
+   m[0][0] = v[0] * t[0];					\
+   m[0][1] = v[0] * t[1];					\
+   m[0][2] = v[0] * t[2];					\
+								\
+   m[1][0] = v[1] * t[0];					\
+   m[1][1] = v[1] * t[1];					\
+   m[1][2] = v[1] * t[2];					\
+								\
+   m[2][0] = v[2] * t[0];					\
+   m[2][1] = v[2] * t[1];					\
+   m[2][2] = v[2] * t[2];					\
+}\
+
+
+/** outer product of vector times vector transpose
+ *
+ * The outer product of vector v and vector transpose t yeilds
+ * dyadic matrix m.
+ */
+#define OUTER_PRODUCT_4X4(m,v,t)				\
+{								\
+   m[0][0] = v[0] * t[0];					\
+   m[0][1] = v[0] * t[1];					\
+   m[0][2] = v[0] * t[2];					\
+   m[0][3] = v[0] * t[3];					\
+								\
+   m[1][0] = v[1] * t[0];					\
+   m[1][1] = v[1] * t[1];					\
+   m[1][2] = v[1] * t[2];					\
+   m[1][3] = v[1] * t[3];					\
+								\
+   m[2][0] = v[2] * t[0];					\
+   m[2][1] = v[2] * t[1];					\
+   m[2][2] = v[2] * t[2];					\
+   m[2][3] = v[2] * t[3];					\
+								\
+   m[3][0] = v[3] * t[0];					\
+   m[3][1] = v[3] * t[1];					\
+   m[3][2] = v[3] * t[2];					\
+   m[3][3] = v[3] * t[3];					\
+}\
+
+
+/** outer product of vector times vector transpose
+ *
+ * The outer product of vector v and vector transpose t yeilds
+ * dyadic matrix m.
+ */
+#define ACCUM_OUTER_PRODUCT_2X2(m,v,t)				\
+{								\
+   m[0][0] += v[0] * t[0];					\
+   m[0][1] += v[0] * t[1];					\
+								\
+   m[1][0] += v[1] * t[0];					\
+   m[1][1] += v[1] * t[1];					\
+}\
+
+
+/** outer product of vector times vector transpose
+ *
+ * The outer product of vector v and vector transpose t yeilds
+ * dyadic matrix m.
+ */
+#define ACCUM_OUTER_PRODUCT_3X3(m,v,t)				\
+{								\
+   m[0][0] += v[0] * t[0];					\
+   m[0][1] += v[0] * t[1];					\
+   m[0][2] += v[0] * t[2];					\
+								\
+   m[1][0] += v[1] * t[0];					\
+   m[1][1] += v[1] * t[1];					\
+   m[1][2] += v[1] * t[2];					\
+								\
+   m[2][0] += v[2] * t[0];					\
+   m[2][1] += v[2] * t[1];					\
+   m[2][2] += v[2] * t[2];					\
+}\
+
+
+/** outer product of vector times vector transpose
+ *
+ * The outer product of vector v and vector transpose t yeilds
+ * dyadic matrix m.
+ */
+#define ACCUM_OUTER_PRODUCT_4X4(m,v,t)				\
+{								\
+   m[0][0] += v[0] * t[0];					\
+   m[0][1] += v[0] * t[1];					\
+   m[0][2] += v[0] * t[2];					\
+   m[0][3] += v[0] * t[3];					\
+								\
+   m[1][0] += v[1] * t[0];					\
+   m[1][1] += v[1] * t[1];					\
+   m[1][2] += v[1] * t[2];					\
+   m[1][3] += v[1] * t[3];					\
+								\
+   m[2][0] += v[2] * t[0];					\
+   m[2][1] += v[2] * t[1];					\
+   m[2][2] += v[2] * t[2];					\
+   m[2][3] += v[2] * t[3];					\
+								\
+   m[3][0] += v[3] * t[0];					\
+   m[3][1] += v[3] * t[1];					\
+   m[3][2] += v[3] * t[2];					\
+   m[3][3] += v[3] * t[3];					\
+}\
+
+
+/** determinant of matrix
+ *
+ * Computes determinant of matrix m, returning d
+ */
+#define DETERMINANT_2X2(d,m)					\
+{								\
+   d = m[0][0] * m[1][1] - m[0][1] * m[1][0];			\
+}\
+
+
+/** determinant of matrix
+ *
+ * Computes determinant of matrix m, returning d
+ */
+#define DETERMINANT_3X3(d,m)					\
+{								\
+   d = m[0][0] * (m[1][1]*m[2][2] - m[1][2] * m[2][1]);		\
+   d -= m[0][1] * (m[1][0]*m[2][2] - m[1][2] * m[2][0]);	\
+   d += m[0][2] * (m[1][0]*m[2][1] - m[1][1] * m[2][0]);	\
+}\
+
+
+/** i,j,th cofactor of a 4x4 matrix
+ *
+ */
+#define COFACTOR_4X4_IJ(fac,m,i,j) 				\
+{								\
+   GUINT __ii[4], __jj[4], __k;						\
+								\
+   for (__k=0; __k<i; __k++) __ii[__k] = __k;				\
+   for (__k=i; __k<3; __k++) __ii[__k] = __k+1;				\
+   for (__k=0; __k<j; __k++) __jj[__k] = __k;				\
+   for (__k=j; __k<3; __k++) __jj[__k] = __k+1;				\
+								\
+   (fac) = m[__ii[0]][__jj[0]] * (m[__ii[1]][__jj[1]]*m[__ii[2]][__jj[2]] 	\
+                            - m[__ii[1]][__jj[2]]*m[__ii[2]][__jj[1]]); \
+   (fac) -= m[__ii[0]][__jj[1]] * (m[__ii[1]][__jj[0]]*m[__ii[2]][__jj[2]]	\
+                             - m[__ii[1]][__jj[2]]*m[__ii[2]][__jj[0]]);\
+   (fac) += m[__ii[0]][__jj[2]] * (m[__ii[1]][__jj[0]]*m[__ii[2]][__jj[1]]	\
+                             - m[__ii[1]][__jj[1]]*m[__ii[2]][__jj[0]]);\
+								\
+   __k = i+j;							\
+   if ( __k != (__k/2)*2) {						\
+      (fac) = -(fac);						\
+   }								\
+}\
+
+
+/** determinant of matrix
+ *
+ * Computes determinant of matrix m, returning d
+ */
+#define DETERMINANT_4X4(d,m)					\
+{								\
+   GREAL cofac;						\
+   COFACTOR_4X4_IJ (cofac, m, 0, 0);				\
+   d = m[0][0] * cofac;						\
+   COFACTOR_4X4_IJ (cofac, m, 0, 1);				\
+   d += m[0][1] * cofac;					\
+   COFACTOR_4X4_IJ (cofac, m, 0, 2);				\
+   d += m[0][2] * cofac;					\
+   COFACTOR_4X4_IJ (cofac, m, 0, 3);				\
+   d += m[0][3] * cofac;					\
+}\
+
+
+/** cofactor of matrix
+ *
+ * Computes cofactor of matrix m, returning a
+ */
+#define COFACTOR_2X2(a,m)					\
+{								\
+   a[0][0] = (m)[1][1];						\
+   a[0][1] = - (m)[1][0];						\
+   a[1][0] = - (m)[0][1];						\
+   a[1][1] = (m)[0][0];						\
+}\
+
+
+/** cofactor of matrix
+ *
+ * Computes cofactor of matrix m, returning a
+ */
+#define COFACTOR_3X3(a,m)					\
+{								\
+   a[0][0] = m[1][1]*m[2][2] - m[1][2]*m[2][1];			\
+   a[0][1] = - (m[1][0]*m[2][2] - m[2][0]*m[1][2]);		\
+   a[0][2] = m[1][0]*m[2][1] - m[1][1]*m[2][0];			\
+   a[1][0] = - (m[0][1]*m[2][2] - m[0][2]*m[2][1]);		\
+   a[1][1] = m[0][0]*m[2][2] - m[0][2]*m[2][0];			\
+   a[1][2] = - (m[0][0]*m[2][1] - m[0][1]*m[2][0]);		\
+   a[2][0] = m[0][1]*m[1][2] - m[0][2]*m[1][1];			\
+   a[2][1] = - (m[0][0]*m[1][2] - m[0][2]*m[1][0]);		\
+   a[2][2] = m[0][0]*m[1][1] - m[0][1]*m[1][0]);		\
+}\
+
+
+/** cofactor of matrix
+ *
+ * Computes cofactor of matrix m, returning a
+ */
+#define COFACTOR_4X4(a,m)					\
+{								\
+   int i,j;							\
+								\
+   for (i=0; i<4; i++) {					\
+      for (j=0; j<4; j++) {					\
+         COFACTOR_4X4_IJ (a[i][j], m, i, j);			\
+      }								\
+   }								\
+}\
+
+
+/** adjoint of matrix
+ *
+ * Computes adjoint of matrix m, returning a
+ * (Note that adjoint is just the transpose of the cofactor matrix)
+ */
+#define ADJOINT_2X2(a,m)					\
+{								\
+   a[0][0] = (m)[1][1];						\
+   a[1][0] = - (m)[1][0];						\
+   a[0][1] = - (m)[0][1];						\
+   a[1][1] = (m)[0][0];						\
+}\
+
+
+/** adjoint of matrix
+ *
+ * Computes adjoint of matrix m, returning a
+ * (Note that adjoint is just the transpose of the cofactor matrix)
+ */
+#define ADJOINT_3X3(a,m)					\
+{								\
+   a[0][0] = m[1][1]*m[2][2] - m[1][2]*m[2][1];			\
+   a[1][0] = - (m[1][0]*m[2][2] - m[2][0]*m[1][2]);		\
+   a[2][0] = m[1][0]*m[2][1] - m[1][1]*m[2][0];			\
+   a[0][1] = - (m[0][1]*m[2][2] - m[0][2]*m[2][1]);		\
+   a[1][1] = m[0][0]*m[2][2] - m[0][2]*m[2][0];			\
+   a[2][1] = - (m[0][0]*m[2][1] - m[0][1]*m[2][0]);		\
+   a[0][2] = m[0][1]*m[1][2] - m[0][2]*m[1][1];			\
+   a[1][2] = - (m[0][0]*m[1][2] - m[0][2]*m[1][0]);		\
+   a[2][2] = m[0][0]*m[1][1] - m[0][1]*m[1][0]);		\
+}\
+
+
+/** adjoint of matrix
+ *
+ * Computes adjoint of matrix m, returning a
+ * (Note that adjoint is just the transpose of the cofactor matrix)
+ */
+#define ADJOINT_4X4(a,m)					\
+{								\
+   char _i_,_j_;							\
+								\
+   for (_i_=0; _i_<4; _i_++) {					\
+      for (_j_=0; _j_<4; _j_++) {					\
+         COFACTOR_4X4_IJ (a[_j_][_i_], m, _i_, _j_);			\
+      }								\
+   }								\
+}\
+
+
+/** compute adjoint of matrix and scale
+ *
+ * Computes adjoint of matrix m, scales it by s, returning a
+ */
+#define SCALE_ADJOINT_2X2(a,s,m)				\
+{								\
+   a[0][0] = (s) * m[1][1];					\
+   a[1][0] = - (s) * m[1][0];					\
+   a[0][1] = - (s) * m[0][1];					\
+   a[1][1] = (s) * m[0][0];					\
+}\
+
+
+/** compute adjoint of matrix and scale
+ *
+ * Computes adjoint of matrix m, scales it by s, returning a
+ */
+#define SCALE_ADJOINT_3X3(a,s,m)				\
+{								\
+   a[0][0] = (s) * (m[1][1] * m[2][2] - m[1][2] * m[2][1]);	\
+   a[1][0] = (s) * (m[1][2] * m[2][0] - m[1][0] * m[2][2]);	\
+   a[2][0] = (s) * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);	\
+								\
+   a[0][1] = (s) * (m[0][2] * m[2][1] - m[0][1] * m[2][2]);	\
+   a[1][1] = (s) * (m[0][0] * m[2][2] - m[0][2] * m[2][0]);	\
+   a[2][1] = (s) * (m[0][1] * m[2][0] - m[0][0] * m[2][1]);	\
+								\
+   a[0][2] = (s) * (m[0][1] * m[1][2] - m[0][2] * m[1][1]);	\
+   a[1][2] = (s) * (m[0][2] * m[1][0] - m[0][0] * m[1][2]);	\
+   a[2][2] = (s) * (m[0][0] * m[1][1] - m[0][1] * m[1][0]);	\
+}\
+
+
+/** compute adjoint of matrix and scale
+ *
+ * Computes adjoint of matrix m, scales it by s, returning a
+ */
+#define SCALE_ADJOINT_4X4(a,s,m)				\
+{								\
+   char _i_,_j_; \
+   for (_i_=0; _i_<4; _i_++) {					\
+      for (_j_=0; _j_<4; _j_++) {					\
+         COFACTOR_4X4_IJ (a[_j_][_i_], m, _i_, _j_);			\
+         a[_j_][_i_] *= s;						\
+      }								\
+   }								\
+}\
+
+/** inverse of matrix
+ *
+ * Compute inverse of matrix a, returning determinant m and
+ * inverse b
+ */
+#define INVERT_2X2(b,det,a)			\
+{						\
+   GREAL _tmp_;					\
+   DETERMINANT_2X2 (det, a);			\
+   _tmp_ = 1.0 / (det);				\
+   SCALE_ADJOINT_2X2 (b, _tmp_, a);		\
+}\
+
+
+/** inverse of matrix
+ *
+ * Compute inverse of matrix a, returning determinant m and
+ * inverse b
+ */
+#define INVERT_3X3(b,det,a)			\
+{						\
+   GREAL _tmp_;					\
+   DETERMINANT_3X3 (det, a);			\
+   _tmp_ = 1.0 / (det);				\
+   SCALE_ADJOINT_3X3 (b, _tmp_, a);		\
+}\
+
+
+/** inverse of matrix
+ *
+ * Compute inverse of matrix a, returning determinant m and
+ * inverse b
+ */
+#define INVERT_4X4(b,det,a)			\
+{						\
+   GREAL _tmp_;					\
+   DETERMINANT_4X4 (det, a);			\
+   _tmp_ = 1.0 / (det);				\
+   SCALE_ADJOINT_4X4 (b, _tmp_, a);		\
+}\
+
+//! Get the triple(3) row of a transform matrix
+#define MAT_GET_ROW(mat,vec3,rowindex)\
+{\
+    vec3[0] = mat[rowindex][0];\
+    vec3[1] = mat[rowindex][1];\
+    vec3[2] = mat[rowindex][2]; \
+}\
+
+//! Get the tuple(2) row of a transform matrix
+#define MAT_GET_ROW2(mat,vec2,rowindex)\
+{\
+    vec2[0] = mat[rowindex][0];\
+    vec2[1] = mat[rowindex][1];\
+}\
+
+
+//! Get the quad (4) row of a transform matrix
+#define MAT_GET_ROW4(mat,vec4,rowindex)\
+{\
+    vec4[0] = mat[rowindex][0];\
+    vec4[1] = mat[rowindex][1];\
+    vec4[2] = mat[rowindex][2];\
+    vec4[3] = mat[rowindex][3];\
+}\
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_GET_COL(mat,vec3,colindex)\
+{\
+    vec3[0] = mat[0][colindex];\
+    vec3[1] = mat[1][colindex];\
+    vec3[2] = mat[2][colindex]; \
+}\
+
+//! Get the tuple(2) col of a transform matrix
+#define MAT_GET_COL2(mat,vec2,colindex)\
+{\
+    vec2[0] = mat[0][colindex];\
+    vec2[1] = mat[1][colindex];\
+}\
+
+
+//! Get the quad (4) col of a transform matrix
+#define MAT_GET_COL4(mat,vec4,colindex)\
+{\
+    vec4[0] = mat[0][colindex];\
+    vec4[1] = mat[1][colindex];\
+    vec4[2] = mat[2][colindex];\
+    vec4[3] = mat[3][colindex];\
+}\
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_GET_X(mat,vec3)\
+{\
+    MAT_GET_COL(mat,vec3,0);\
+}\
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_GET_Y(mat,vec3)\
+{\
+    MAT_GET_COL(mat,vec3,1);\
+}\
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_GET_Z(mat,vec3)\
+{\
+    MAT_GET_COL(mat,vec3,2);\
+}\
+
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_SET_X(mat,vec3)\
+{\
+    mat[0][0] = vec3[0];\
+    mat[1][0] = vec3[1];\
+    mat[2][0] = vec3[2];\
+}\
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_SET_Y(mat,vec3)\
+{\
+    mat[0][1] = vec3[0];\
+    mat[1][1] = vec3[1];\
+    mat[2][1] = vec3[2];\
+}\
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_SET_Z(mat,vec3)\
+{\
+    mat[0][2] = vec3[0];\
+    mat[1][2] = vec3[1];\
+    mat[2][2] = vec3[2];\
+}\
+
+
+//! Get the triple(3) col of a transform matrix
+#define MAT_GET_TRANSLATION(mat,vec3)\
+{\
+    vec3[0] = mat[0][3];\
+    vec3[1] = mat[1][3];\
+    vec3[2] = mat[2][3]; \
+}\
+
+//! Set the triple(3) col of a transform matrix
+#define MAT_SET_TRANSLATION(mat,vec3)\
+{\
+    mat[0][3] = vec3[0];\
+    mat[1][3] = vec3[1];\
+    mat[2][3] = vec3[2]; \
+}\
+
+
+
+//! Returns the dot product between a vec3f and the row of a matrix
+#define MAT_DOT_ROW(mat,vec3,rowindex) (vec3[0]*mat[rowindex][0] + vec3[1]*mat[rowindex][1] + vec3[2]*mat[rowindex][2])
+
+//! Returns the dot product between a vec2f and the row of a matrix
+#define MAT_DOT_ROW2(mat,vec2,rowindex) (vec2[0]*mat[rowindex][0] + vec2[1]*mat[rowindex][1])
+
+//! Returns the dot product between a vec4f and the row of a matrix
+#define MAT_DOT_ROW4(mat,vec4,rowindex) (vec4[0]*mat[rowindex][0] + vec4[1]*mat[rowindex][1] + vec4[2]*mat[rowindex][2] + vec4[3]*mat[rowindex][3])
+
+
+//! Returns the dot product between a vec3f and the col of a matrix
+#define MAT_DOT_COL(mat,vec3,colindex) (vec3[0]*mat[0][colindex] + vec3[1]*mat[1][colindex] + vec3[2]*mat[2][colindex])
+
+//! Returns the dot product between a vec2f and the col of a matrix
+#define MAT_DOT_COL2(mat,vec2,colindex) (vec2[0]*mat[0][colindex] + vec2[1]*mat[1][colindex])
+
+//! Returns the dot product between a vec4f and the col of a matrix
+#define MAT_DOT_COL4(mat,vec4,colindex) (vec4[0]*mat[0][colindex] + vec4[1]*mat[1][colindex] + vec4[2]*mat[2][colindex] + vec4[3]*mat[3][colindex])
+
+/*!Transpose matrix times vector
+v is a vec3f
+and m is a mat4f<br>
+*/
+#define INV_MAT_DOT_VEC_3X3(p,m,v)					\
+{								\
+   p[0] = MAT_DOT_COL(m,v,0); \
+   p[1] = MAT_DOT_COL(m,v,1);	\
+   p[2] = MAT_DOT_COL(m,v,2);	\
+}\
+
+
+//! @}
+
+#endif // GIM_VECTOR_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_math.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_math.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_math.h	(revision 2122)
@@ -0,0 +1,181 @@
+#ifndef GIM_MATH_H_INCLUDED
+#define GIM_MATH_H_INCLUDED
+/*! \file gim_math.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "LinearMath/btScalar.h"
+
+
+/*! \defgroup BASIC_TYPES
+Basic types and constants
+Conventions:
+Types starting with G
+Constants starting with G_
+*/
+//! @{
+
+#define GREAL btScalar
+#define GREAL2 double
+#define GINT int
+#define GUINT unsigned int
+#define GSHORT short
+#define GUSHORT unsigned short
+#define GINT64 long long
+#define GUINT64 unsigned long long
+
+//! @}
+
+/*! \defgroup BASIC_CONSTANTS
+Basic constants
+Conventions:
+Types starting with G
+Constants starting with G_
+*/
+//! @{
+
+#define G_PI 3.14159265358979f
+#define G_HALF_PI 1.5707963f
+//267948966
+#define G_TWO_PI 6.28318530f
+//71795864
+#define G_ROOT3 1.73205f
+#define G_ROOT2 1.41421f
+#define G_UINT_INFINITY 0xffffffff //!< A very very high value
+#define G_REAL_INFINITY FLT_MAX
+#define	G_SIGN_BITMASK			0x80000000
+#define G_EPSILON SIMD_EPSILON
+//! @}
+
+
+/*! \defgroup SCALAR_TYPES
+\brief
+Precision type constants
+*/
+//! @{
+enum GIM_SCALAR_TYPES
+{
+	G_STYPE_REAL =0,
+	G_STYPE_REAL2,
+	G_STYPE_SHORT,
+	G_STYPE_USHORT,
+	G_STYPE_INT,
+	G_STYPE_UINT,
+	G_STYPE_INT64,
+	G_STYPE_UINT64
+};
+//! @}
+
+/*! \defgroup MATH_FUNCTIONS
+mathematical functions
+*/
+//! @{
+
+#define G_DEGTORAD(X) ((X)*3.1415926f/180.0f)
+#define G_RADTODEG(X) ((X)*180.0f/3.1415926f)
+
+//! Integer representation of a floating-point value.
+#define GIM_IR(x)					((GUINT&)(x))
+
+//! Signed integer representation of a floating-point value.
+#define GIM_SIR(x)					((GINT&)(x))
+
+//! Absolute integer representation of a floating-point value
+#define GIM_AIR(x)					(GIM_IR(x)&0x7fffffff)
+
+//! Floating-point representation of an integer value.
+#define GIM_FR(x)					((GREAL&)(x))
+
+#define GIM_MAX(a,b) (a<b?b:a)
+#define GIM_MIN(a,b) (a>b?b:a)
+
+#define GIM_MAX3(a,b,c) GIM_MAX(a,GIM_MAX(b,c))
+#define GIM_MIN3(a,b,c) GIM_MIN(a,GIM_MIN(b,c))
+
+#define GIM_IS_ZERO(value) (value < G_EPSILON &&  value > -G_EPSILON)
+
+#define GIM_IS_NEGATIVE(value) (value <= -G_EPSILON)
+
+#define GIM_IS_POSISITVE(value) (value >= G_EPSILON)
+
+#define GIM_NEAR_EQUAL(v1,v2) GIM_IS_ZERO((v1-v2))
+
+///returns a clamped number
+#define GIM_CLAMP(number,minval,maxval) (number<minval?minval:(number>maxval?maxval:number))
+
+#define GIM_GREATER(x, y)	fabsf(x) > (y)
+
+///Swap numbers
+#define GIM_SWAP_NUMBERS(a,b){ \
+    a = a+b; \
+    b = a-b; \
+    a = a-b; \
+}\
+
+#define GIM_INV_SQRT(va,isva)\
+{\
+    if(va<=0.0000001f)\
+    {\
+        isva = G_REAL_INFINITY;\
+    }\
+    else\
+    {\
+        GREAL _x = va * 0.5f;\
+        GUINT _y = 0x5f3759df - ( GIM_IR(va) >> 1);\
+        isva = GIM_FR(_y);\
+        isva  = isva * ( 1.5f - ( _x * isva * isva ) );\
+    }\
+}\
+
+#define GIM_SQRT(va,sva)\
+{\
+    GIM_INV_SQRT(va,sva);\
+    sva = 1.0f/sva;\
+}\
+
+//! Computes 1.0f / sqrtf(x). Comes from Quake3. See http://www.magic-software.com/3DGEDInvSqrt.html
+inline GREAL gim_inv_sqrt(GREAL f)
+{
+    GREAL r;
+    GIM_INV_SQRT(f,r);
+    return r;
+}
+
+inline GREAL gim_sqrt(GREAL f)
+{
+    GREAL r;
+    GIM_SQRT(f,r);
+    return r;
+}
+
+//! @}
+
+#endif // GIM_MATH_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_memory.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_memory.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_memory.cpp	(revision 2122)
@@ -0,0 +1,135 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "gim_memory.h"
+#include "stdlib.h"
+
+#ifdef GIM_SIMD_MEMORY
+#include "LinearMath/btAlignedAllocator.h"
+#endif
+
+static gim_alloc_function *g_allocfn = 0;
+static gim_alloca_function *g_allocafn = 0;
+static gim_realloc_function *g_reallocfn = 0;
+static gim_free_function *g_freefn = 0;
+
+void gim_set_alloc_handler (gim_alloc_function *fn)
+{
+  g_allocfn = fn;
+}
+
+void gim_set_alloca_handler (gim_alloca_function *fn)
+{
+  g_allocafn = fn;
+}
+
+void gim_set_realloc_handler (gim_realloc_function *fn)
+{
+  g_reallocfn = fn;
+}
+
+void gim_set_free_handler (gim_free_function *fn)
+{
+  g_freefn = fn;
+}
+
+gim_alloc_function *gim_get_alloc_handler()
+{
+  return g_allocfn;
+}
+
+gim_alloca_function *gim_get_alloca_handler()
+{
+  return g_allocafn;
+}
+
+
+gim_realloc_function *gim_get_realloc_handler ()
+{
+  return g_reallocfn;
+}
+
+
+gim_free_function  *gim_get_free_handler ()
+{
+  return g_freefn;
+}
+
+
+void * gim_alloc(size_t size)
+{
+	void * ptr;
+	if (g_allocfn)
+	{
+		ptr = g_allocfn(size);
+	}
+	else
+	{
+#ifdef GIM_SIMD_MEMORY
+		ptr = btAlignedAlloc(size,16);
+#else
+		ptr = malloc(size);
+#endif
+	}
+  	return ptr;
+}
+
+void * gim_alloca(size_t size)
+{
+  if (g_allocafn) return g_allocafn(size); else return gim_alloc(size);
+}
+
+
+void * gim_realloc(void *ptr, size_t oldsize, size_t newsize)
+{
+ 	void * newptr = gim_alloc(newsize);
+    size_t copysize = oldsize<newsize?oldsize:newsize;
+    gim_simd_memcpy(newptr,ptr,copysize);
+    gim_free(ptr);
+    return newptr;
+}
+
+void gim_free(void *ptr)
+{
+	if (!ptr) return;
+	if (g_freefn)
+	{
+	   g_freefn(ptr);
+	}
+	else
+	{
+	#ifdef GIM_SIMD_MEMORY
+		btAlignedFree(ptr);
+	#else
+		free(ptr);
+	#endif
+	}
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_memory.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_memory.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_memory.h	(revision 2122)
@@ -0,0 +1,211 @@
+#ifndef GIM_MEMORY_H_INCLUDED
+#define GIM_MEMORY_H_INCLUDED
+/*! \file gim_memory.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "gim_math.h"
+#include <memory.h>
+
+//#define PREFETCH 1
+//! \defgroup PREFETCH
+//! @{
+#ifdef PREFETCH
+#include <xmmintrin.h>	// for prefetch
+#define pfval	64
+#define pfval2	128
+//! Prefetch 64
+#define pf(_x,_i)	_mm_prefetch((void *)(_x + _i + pfval), 0)
+//! Prefetch 128
+#define pf2(_x,_i)	_mm_prefetch((void *)(_x + _i + pfval2), 0)
+#else
+//! Prefetch 64
+#define pf(_x,_i)
+//! Prefetch 128
+#define pf2(_x,_i)
+#endif
+//! @}
+
+/*! \defgroup ARRAY_UTILITIES
+\brief
+Functions for manip packed arrays of numbers
+*/
+//! @{
+#define GIM_COPY_ARRAYS(dest_array,source_array,element_count)\
+{\
+    for (GUINT _i_=0;_i_<element_count ;++_i_)\
+    {\
+    	dest_array[_i_] = source_array[_i_];\
+    }\
+}\
+
+#define GIM_COPY_ARRAYS_1(dest_array,source_array,element_count,copy_macro)\
+{\
+    for (GUINT _i_=0;_i_<element_count ;++_i_)\
+    {\
+    	copy_macro(dest_array[_i_],source_array[_i_]);\
+    }\
+}\
+
+
+#define GIM_ZERO_ARRAY(array,element_count)\
+{\
+    for (GUINT _i_=0;_i_<element_count ;++_i_)\
+    {\
+    	array[_i_] = 0;\
+    }\
+}\
+
+#define GIM_CONSTANT_ARRAY(array,element_count,constant)\
+{\
+    for (GUINT _i_=0;_i_<element_count ;++_i_)\
+    {\
+    	array[_i_] = constant;\
+    }\
+}\
+//! @}
+
+/*! \defgroup MEMORY_FUNCTION_PROTOTYPES
+Function prototypes to allocate and free memory.
+*/
+//! @{
+typedef void * gim_alloc_function (size_t size);
+typedef void * gim_alloca_function (size_t size);//Allocs on the heap
+typedef void * gim_realloc_function (void *ptr, size_t oldsize, size_t newsize);
+typedef void gim_free_function (void *ptr);
+//! @}
+
+/*! \defgroup MEMORY_FUNCTION_HANDLERS
+\brief
+Memory Function Handlers
+ set new memory management functions. if fn is 0, the default handlers are
+  used. */
+//! @{
+void gim_set_alloc_handler (gim_alloc_function *fn);
+void gim_set_alloca_handler (gim_alloca_function *fn);
+void gim_set_realloc_handler (gim_realloc_function *fn);
+void gim_set_free_handler (gim_free_function *fn);
+//! @}
+
+/*! \defgroup MEMORY_FUNCTION_GET_HANDLERS
+\brief
+get current memory management functions.
+*/
+//! @{
+gim_alloc_function *gim_get_alloc_handler (void);
+gim_alloca_function *gim_get_alloca_handler(void);
+gim_realloc_function *gim_get_realloc_handler (void);
+gim_free_function  *gim_get_free_handler (void);
+//! @}
+
+/*! \defgroup MEMORY_FUNCTIONS
+Standar Memory functions
+*/
+//! @{
+void * gim_alloc(size_t size);
+void * gim_alloca(size_t size);
+void * gim_realloc(void *ptr, size_t oldsize, size_t newsize);
+void gim_free(void *ptr);
+//! @}
+
+
+#if defined (WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+    #define GIM_SIMD_MEMORY 1
+#endif
+
+//! SIMD POINTER INTEGER
+#define SIMD_T GUINT64
+//! SIMD INTEGER SIZE
+#define SIMD_T_SIZE sizeof(SIMD_T)
+
+
+inline void gim_simd_memcpy(void * dst, const void * src, size_t copysize)
+{
+#ifdef GIM_SIMD_MEMORY
+/*
+//'long long int' is incompatible with visual studio 6...
+    //copy words
+    SIMD_T * ui_src_ptr = (SIMD_T *)src;
+    SIMD_T * ui_dst_ptr = (SIMD_T *)dst;
+    while(copysize>=SIMD_T_SIZE)
+    {
+        *(ui_dst_ptr++) = *(ui_src_ptr++);
+        copysize-=SIMD_T_SIZE;
+    }
+    if(copysize==0) return;
+*/
+
+    char * c_src_ptr = (char *)src;
+    char * c_dst_ptr = (char *)dst;
+    while(copysize>0)
+    {
+        *(c_dst_ptr++) = *(c_src_ptr++);
+        copysize--;
+    }
+    return;
+#else
+    memcpy(dst,src,copysize);
+#endif
+}
+
+
+
+template<class T>
+inline void gim_swap_elements(T* _array,size_t _i,size_t _j)
+{
+	T _e_tmp_ = _array[_i];
+	_array[_i] = _array[_j];
+	_array[_j] = _e_tmp_;
+}
+
+
+template<class T>
+inline void gim_swap_elements_memcpy(T* _array,size_t _i,size_t _j)
+{
+	char _e_tmp_[sizeof(T)];
+	gim_simd_memcpy(_e_tmp_,&_array[_i],sizeof(T));
+	gim_simd_memcpy(&_array[_i],&_array[_j],sizeof(T));
+	gim_simd_memcpy(&_array[_j],_e_tmp_,sizeof(T));
+}
+
+template <int SIZE>
+inline void gim_swap_elements_ptr(char * _array,size_t _i,size_t _j)
+{
+	char _e_tmp_[SIZE];
+	_i*=SIZE;
+	_j*=SIZE;
+	gim_simd_memcpy(_e_tmp_,_array+_i,SIZE);
+	gim_simd_memcpy(_array+_i,_array+_j,SIZE);
+	gim_simd_memcpy(_array+_j,_e_tmp_,SIZE);
+}
+
+#endif // GIM_MEMORY_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_radixsort.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_radixsort.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_radixsort.h	(revision 2122)
@@ -0,0 +1,410 @@
+#ifndef GIM_RADIXSORT_H_INCLUDED
+#define GIM_RADIXSORT_H_INCLUDED
+/*! \file gim_radixsort.h
+\author Francisco Len Nßjera.
+Based on the work of Michael Herf : "fast floating-point radix sort"
+Avaliable on http://www.stereopsis.com/radix.html
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "gim_memory.h"
+
+/*! \defgroup SORTING
+\brief
+Macros for sorting.
+*/
+
+//! Prototype for comparators
+class less_comparator
+{
+	public:
+
+	template<class T,class Z>
+	inline int operator() ( const T& a, const Z& b )
+	{
+		return ( a<b?-1:(a>b?1:0));
+	}
+};
+
+//! Prototype for comparators
+class integer_comparator
+{
+	public:
+
+	template<class T>
+	inline int operator() ( const T& a, const T& b )
+	{
+		return (int)(a-b);
+	}
+};
+
+//!Prototype for getting the integer representation of an object
+class uint_key_func
+{
+public:
+	template<class T>
+	inline GUINT operator()( const T& a)
+	{
+		return (GUINT)a;
+	}
+};
+
+
+//!Prototype for copying elements
+class copy_elements_func
+{
+public:
+	template<class T>
+	inline void operator()(T& a,T& b)
+	{
+		a = b;
+	}
+};
+
+//!Prototype for copying elements
+class memcopy_elements_func
+{
+public:
+	template<class T>
+	inline void operator()(T& a,T& b)
+	{
+		gim_simd_memcpy(&a,&b,sizeof(T));
+	}
+};
+
+
+//! @{
+struct GIM_RSORT_TOKEN
+{
+    GUINT m_key;
+    GUINT m_value;
+    GIM_RSORT_TOKEN()
+    {
+    }
+    GIM_RSORT_TOKEN(const GIM_RSORT_TOKEN& rtoken)
+    {
+    	m_key = rtoken.m_key;
+    	m_value = rtoken.m_value;
+    }
+
+    inline bool operator <(const GIM_RSORT_TOKEN& other) const
+	{
+		return (m_key < other.m_key);
+	}
+
+	inline bool operator >(const GIM_RSORT_TOKEN& other) const
+	{
+		return (m_key > other.m_key);
+	}
+};
+
+//! Prototype for comparators
+class GIM_RSORT_TOKEN_COMPARATOR
+{
+	public:
+
+	inline int operator()( const GIM_RSORT_TOKEN& a, const GIM_RSORT_TOKEN& b )
+	{
+		return (int)((a.m_key) - (b.m_key));
+	}
+};
+
+
+
+#define kHist 2048
+// ---- utils for accessing 11-bit quantities
+#define D11_0(x)	(x & 0x7FF)
+#define D11_1(x)	(x >> 11 & 0x7FF)
+#define D11_2(x)	(x >> 22 )
+
+
+
+///Radix sort for unsigned integer keys
+inline void gim_radix_sort_rtokens(
+				GIM_RSORT_TOKEN * array,
+				GIM_RSORT_TOKEN * sorted, GUINT element_count)
+{
+	GUINT i;
+	GUINT b0[kHist * 3];
+	GUINT *b1 = b0 + kHist;
+	GUINT *b2 = b1 + kHist;
+	for (i = 0; i < kHist * 3; ++i)
+	{
+		b0[i] = 0;
+	}
+	GUINT fi;
+	GUINT pos;
+	for (i = 0; i < element_count; ++i)
+	{
+	    fi = array[i].m_key;
+		b0[D11_0(fi)] ++;
+		b1[D11_1(fi)] ++;
+		b2[D11_2(fi)] ++;
+	}
+	{
+		GUINT sum0 = 0, sum1 = 0, sum2 = 0;
+		GUINT tsum;
+		for (i = 0; i < kHist; ++i)
+		{
+			tsum = b0[i] + sum0;
+			b0[i] = sum0 - 1;
+			sum0 = tsum;
+			tsum = b1[i] + sum1;
+			b1[i] = sum1 - 1;
+			sum1 = tsum;
+			tsum = b2[i] + sum2;
+			b2[i] = sum2 - 1;
+			sum2 = tsum;
+		}
+	}
+	for (i = 0; i < element_count; ++i)
+	{
+        fi = array[i].m_key;
+		pos = D11_0(fi);
+		pos = ++b0[pos];
+		sorted[pos].m_key = array[i].m_key;
+		sorted[pos].m_value = array[i].m_value;
+	}
+	for (i = 0; i < element_count; ++i)
+	{
+        fi = sorted[i].m_key;
+		pos = D11_1(fi);
+		pos = ++b1[pos];
+		array[pos].m_key = sorted[i].m_key;
+		array[pos].m_value = sorted[i].m_value;
+	}
+	for (i = 0; i < element_count; ++i)
+	{
+        fi = array[i].m_key;
+		pos = D11_2(fi);
+		pos = ++b2[pos];
+		sorted[pos].m_key = array[i].m_key;
+		sorted[pos].m_value = array[i].m_value;
+	}
+}
+
+
+
+
+/// Get the sorted tokens from an array. For generic use. Tokens are IRR_RSORT_TOKEN
+/*!
+*\param array Array of elements to sort
+*\param sorted_tokens Tokens of sorted elements
+*\param element_count element count
+*\param uintkey_macro Functor which retrieves the integer representation of an array element
+*/
+template<typename T, class GETKEY_CLASS>
+void gim_radix_sort_array_tokens(
+			T* array ,
+			GIM_RSORT_TOKEN * sorted_tokens,
+			GUINT element_count,GETKEY_CLASS uintkey_macro)
+{
+	GIM_RSORT_TOKEN * _unsorted = (GIM_RSORT_TOKEN *) gim_alloc(sizeof(GIM_RSORT_TOKEN)*element_count);
+    for (GUINT _i=0;_i<element_count;++_i)
+    {
+        _unsorted[_i].m_key = uintkey_macro(array[_i]);
+        _unsorted[_i].m_value = _i;
+    }
+    gim_radix_sort_rtokens(_unsorted,sorted_tokens,element_count);
+    gim_free(_unsorted);
+    gim_free(_unsorted);
+}
+
+/// Sorts array in place. For generic use
+/*!
+\param type Type of the array
+\param array
+\param element_count
+\param get_uintkey_macro Macro for extract the Integer value of the element. Similar to SIMPLE_GET_UINTKEY
+\param copy_elements_macro Macro for copy elements, similar to SIMPLE_COPY_ELEMENTS
+*/
+template<typename T, class GETKEY_CLASS, class COPY_CLASS>
+void gim_radix_sort(
+	T * array, GUINT element_count,
+	GETKEY_CLASS get_uintkey_macro, COPY_CLASS copy_elements_macro)
+{
+	GIM_RSORT_TOKEN * _sorted = (GIM_RSORT_TOKEN  *) gim_alloc(sizeof(GIM_RSORT_TOKEN)*element_count);
+    gim_radix_sort_array_tokens(array,_sorted,element_count,get_uintkey_macro);
+    T * _original_array = (T *) gim_alloc(sizeof(T)*element_count);
+    gim_simd_memcpy(_original_array,array,sizeof(T)*element_count);
+    for (GUINT _i=0;_i<element_count;++_i)
+    {
+        copy_elements_macro(array[_i],_original_array[_sorted[_i].m_value]);
+    }
+    gim_free(_original_array);
+    gim_free(_sorted);
+}
+
+//! Failsafe Iterative binary search,
+/*!
+If the element is not found, it returns the nearest upper element position, may be the further position after the last element.
+\param _array
+\param _start_i the beginning of the array
+\param _end_i the ending  index of the array
+\param _search_key Value to find
+\param _comp_macro macro for comparing elements
+\param _found If true the value has found. Boolean
+\param _result_index the index of the found element, or if not found then it will get the index of the  closest bigger value
+*/
+template<class T, typename KEYCLASS, typename COMP_CLASS>
+bool  gim_binary_search_ex(
+		const T* _array, GUINT _start_i,
+		GUINT _end_i,GUINT & _result_index,
+		const KEYCLASS & _search_key,
+		COMP_CLASS _comp_macro)
+{
+	GUINT _k;
+	int _comp_result;
+	GUINT _i = _start_i;
+	GUINT _j = _end_i+1;
+	while (_i < _j)
+	{
+		_k = (_j+_i-1)/2;
+		_comp_result = _comp_macro(_array[_k], _search_key);
+		if (_comp_result == 0)
+		{
+			_result_index = _k;
+			return true;
+		}
+		else if (_comp_result < 0)
+		{
+			_i = _k+1;
+		}
+		else
+		{
+			_j = _k;
+		}
+	}
+	_result_index = _i;
+	return false;
+}
+
+
+
+//! Failsafe Iterative binary search,Template version
+/*!
+If the element is not found, it returns the nearest upper element position, may be the further position after the last element.
+\param _array
+\param _start_i the beginning of the array
+\param _end_i the ending  index of the array
+\param _search_key Value to find
+\param _result_index the index of the found element, or if not found then it will get the index of the  closest bigger value
+\return true if found, else false
+*/
+template<class T>
+bool gim_binary_search(
+	const T*_array,GUINT _start_i,
+	GUINT _end_i,const T & _search_key,
+	GUINT & _result_index)
+{
+	GUINT _i = _start_i;
+	GUINT _j = _end_i+1;
+	GUINT _k;
+	while(_i < _j)
+	{
+		_k = (_j+_i-1)/2;
+		if(_array[_k]==_search_key)
+		{
+			_result_index = _k;
+			return true;
+		}
+		else if (_array[_k]<_search_key)
+		{
+			_i = _k+1;
+		}
+		else
+		{
+			_j = _k;
+		}
+	}
+	_result_index = _i;
+	return false;
+}
+
+
+
+///heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/
+template <typename T, typename COMP_CLASS>
+void gim_down_heap(T *pArr, GUINT k, GUINT n,COMP_CLASS CompareFunc)
+{
+	/*  PRE: a[k+1..N] is a heap */
+	/* POST:  a[k..N]  is a heap */
+
+	T temp = pArr[k - 1];
+	/* k has child(s) */
+	while (k <= n/2)
+	{
+		int child = 2*k;
+
+		if ((child < (int)n) && CompareFunc(pArr[child - 1] , pArr[child])<0)
+		{
+			child++;
+		}
+		/* pick larger child */
+		if (CompareFunc(temp , pArr[child - 1])<0)
+		{
+			/* move child up */
+			pArr[k - 1] = pArr[child - 1];
+			k = child;
+		}
+		else
+		{
+			break;
+		}
+	}
+	pArr[k - 1] = temp;
+} /*downHeap*/
+
+
+template <typename T, typename COMP_CLASS>
+void gim_heap_sort(T *pArr, GUINT element_count, COMP_CLASS CompareFunc)
+{
+	/* sort a[0..N-1],  N.B. 0 to N-1 */
+	GUINT k;
+	GUINT n = element_count;
+	for (k = n/2; k > 0; k--)
+	{
+		gim_down_heap(pArr, k, n, CompareFunc);
+	}
+
+	/* a[1..N] is now a heap */
+	while ( n>=2 )
+	{
+		gim_swap_elements(pArr,0,n-1); /* largest of a[0..n-1] */
+		--n;
+		/* restore a[1..i-1] heap */
+		gim_down_heap(pArr, 1, n, CompareFunc);
+	}
+}
+
+
+
+//! @}
+#endif // GIM_RADIXSORT_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_tri_collision.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_tri_collision.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_tri_collision.cpp	(revision 2122)
@@ -0,0 +1,640 @@
+
+/*! \file gim_tri_collision.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "gim_tri_collision.h"
+
+
+#define TRI_LOCAL_EPSILON 0.000001f
+#define MIN_EDGE_EDGE_DIS 0.00001f
+
+
+class _GIM_TRIANGLE_CALCULATION_CACHE
+{
+public:
+	GREAL margin;	
+	btVector3 tu_vertices[3];
+	btVector3 tv_vertices[3];
+	btVector4 tu_plane;
+	btVector4 tv_plane;
+	btVector3 closest_point_u;
+	btVector3 closest_point_v;
+	btVector3 edge_edge_dir;
+	btVector3 distances;
+	GREAL du[4];
+	GREAL du0du1;
+	GREAL du0du2;
+	GREAL dv[4];
+	GREAL dv0dv1;
+	GREAL dv0dv2;	
+	btVector3 temp_points[MAX_TRI_CLIPPING];
+	btVector3 temp_points1[MAX_TRI_CLIPPING];
+	btVector3 contact_points[MAX_TRI_CLIPPING];
+	
+
+
+	//! if returns false, the faces are paralele
+	SIMD_FORCE_INLINE bool compute_intervals(
+					const GREAL &D0,
+					const GREAL &D1,
+					const GREAL &D2,
+					const GREAL &D0D1,
+					const GREAL &D0D2,
+					GREAL & scale_edge0,
+					GREAL & scale_edge1,
+					GUINT &edge_index0,
+					GUINT &edge_index1)
+	{
+		if(D0D1>0.0f)
+		{
+			/* here we know that D0D2<=0.0 */
+			/* that is D0, D1 are on the same side, D2 on the other or on the plane */
+			scale_edge0 = -D2/(D0-D2);
+			scale_edge1 = -D1/(D2-D1);
+			edge_index0 = 2;edge_index1 = 1;
+		}
+		else if(D0D2>0.0f)
+		{
+			/* here we know that d0d1<=0.0 */
+			scale_edge0 = -D0/(D1-D0);
+			scale_edge1 = -D1/(D2-D1);
+			edge_index0 = 0;edge_index1 = 1;
+		}
+		else if(D1*D2>0.0f || D0!=0.0f)
+		{
+			/* here we know that d0d1<=0.0 or that D0!=0.0 */
+			scale_edge0 = -D0/(D1-D0);
+			scale_edge1 = -D2/(D0-D2);
+			edge_index0 = 0 ;edge_index1 = 2;
+		}
+		else
+		{
+			return false;
+		}
+		return true;
+	}
+
+
+	//! clip triangle
+	/*!
+	*/
+	SIMD_FORCE_INLINE GUINT clip_triangle(
+		const btVector4 & tri_plane,
+		const btVector3 * tripoints,
+		const btVector3 * srcpoints,
+		btVector3 * clip_points)
+	{
+		// edge 0
+
+		btVector4 edgeplane;
+
+		EDGE_PLANE(tripoints[0],tripoints[1],tri_plane,edgeplane);
+
+		GUINT clipped_count = PLANE_CLIP_TRIANGLE3D(
+			edgeplane,srcpoints[0],srcpoints[1],srcpoints[2],temp_points);
+
+		if(clipped_count == 0) return 0;
+
+		// edge 1
+
+		EDGE_PLANE(tripoints[1],tripoints[2],tri_plane,edgeplane);
+
+		clipped_count = PLANE_CLIP_POLYGON3D(
+			edgeplane,temp_points,clipped_count,temp_points1);
+
+		if(clipped_count == 0) return 0;
+
+		// edge 2
+
+		EDGE_PLANE(tripoints[2],tripoints[0],tri_plane,edgeplane);
+
+		clipped_count = PLANE_CLIP_POLYGON3D(
+			edgeplane,temp_points1,clipped_count,clip_points);
+
+		return clipped_count;
+
+
+		/*GUINT i0 = (tri_plane.closestAxis()+1)%3;
+		GUINT i1 = (i0+1)%3;
+		// edge 0
+		btVector3 temp_points[MAX_TRI_CLIPPING];
+		btVector3 temp_points1[MAX_TRI_CLIPPING];
+
+		GUINT clipped_count= PLANE_CLIP_TRIANGLE_GENERIC(
+			0,srcpoints[0],srcpoints[1],srcpoints[2],temp_points,
+			DISTANCE_EDGE(tripoints[0],tripoints[1],i0,i1));
+		
+		
+		if(clipped_count == 0) return 0;
+
+		// edge 1
+		clipped_count = PLANE_CLIP_POLYGON_GENERIC(
+			0,temp_points,clipped_count,temp_points1,
+			DISTANCE_EDGE(tripoints[1],tripoints[2],i0,i1));
+
+		if(clipped_count == 0) return 0;
+
+		// edge 2
+		clipped_count = PLANE_CLIP_POLYGON_GENERIC(
+			0,temp_points1,clipped_count,clipped_points,
+			DISTANCE_EDGE(tripoints[2],tripoints[0],i0,i1));
+
+		return clipped_count;*/
+	}
+
+	SIMD_FORCE_INLINE void sort_isect(
+		GREAL & isect0,GREAL & isect1,GUINT &e0,GUINT &e1,btVector3 & vec0,btVector3 & vec1)
+	{
+		if(isect1<isect0)
+		{
+			//swap
+			GIM_SWAP_NUMBERS(isect0,isect1);
+			GIM_SWAP_NUMBERS(e0,e1);
+			btVector3 tmp = vec0;
+			vec0 = vec1;
+			vec1 = tmp;
+		}
+	}
+
+	//! Test verifying interval intersection with the direction between planes
+	/*!
+	\pre tv_plane and tu_plane must be set
+	\post
+	distances[2] is set with the distance
+	closest_point_u, closest_point_v, edge_edge_dir are set too
+	\return
+	- 0: faces are paralele
+	- 1: face U casts face V
+	- 2: face V casts face U
+	- 3: nearest edges
+	*/
+	SIMD_FORCE_INLINE GUINT cross_line_intersection_test()
+	{
+		// Compute direction of intersection line
+		edge_edge_dir = tu_plane.cross(tv_plane);
+		GREAL Dlen;
+		VEC_LENGTH(edge_edge_dir,Dlen);
+
+		if(Dlen<0.0001)
+		{
+			return 0; //faces near paralele
+		}
+
+		edge_edge_dir*= 1/Dlen;//normalize
+
+
+		// Compute interval for triangle 1
+		GUINT tu_e0,tu_e1;//edge indices
+		GREAL tu_scale_e0,tu_scale_e1;//edge scale
+		if(!compute_intervals(du[0],du[1],du[2],
+			du0du1,du0du2,tu_scale_e0,tu_scale_e1,tu_e0,tu_e1)) return 0;
+
+		// Compute interval for triangle 2
+		GUINT tv_e0,tv_e1;//edge indices
+		GREAL tv_scale_e0,tv_scale_e1;//edge scale
+
+		if(!compute_intervals(dv[0],dv[1],dv[2],
+			dv0dv1,dv0dv2,tv_scale_e0,tv_scale_e1,tv_e0,tv_e1)) return 0;
+
+		//proyected vertices
+		btVector3 up_e0 = tu_vertices[tu_e0].lerp(tu_vertices[(tu_e0+1)%3],tu_scale_e0);
+		btVector3 up_e1 = tu_vertices[tu_e1].lerp(tu_vertices[(tu_e1+1)%3],tu_scale_e1);
+
+		btVector3 vp_e0 = tv_vertices[tv_e0].lerp(tv_vertices[(tv_e0+1)%3],tv_scale_e0);
+		btVector3 vp_e1 = tv_vertices[tv_e1].lerp(tv_vertices[(tv_e1+1)%3],tv_scale_e1);
+
+		//proyected intervals
+		GREAL isect_u[] = {up_e0.dot(edge_edge_dir),up_e1.dot(edge_edge_dir)};
+		GREAL isect_v[] = {vp_e0.dot(edge_edge_dir),vp_e1.dot(edge_edge_dir)};
+
+		sort_isect(isect_u[0],isect_u[1],tu_e0,tu_e1,up_e0,up_e1);
+		sort_isect(isect_v[0],isect_v[1],tv_e0,tv_e1,vp_e0,vp_e1);
+
+		const GREAL midpoint_u = 0.5f*(isect_u[0]+isect_u[1]); // midpoint
+		const GREAL midpoint_v = 0.5f*(isect_v[0]+isect_v[1]); // midpoint
+
+		if(midpoint_u<midpoint_v)
+		{
+			if(isect_u[1]>=isect_v[1]) // face U casts face V
+			{
+				return 1;
+			}
+			else if(isect_v[0]<=isect_u[0]) // face V casts face U
+			{
+				return 2;
+			}
+			// closest points
+			closest_point_u = up_e1;
+			closest_point_v = vp_e0;
+			// calc edges and separation
+
+			if(isect_u[1]+ MIN_EDGE_EDGE_DIS<isect_v[0]) //calc distance between two lines instead
+			{
+				SEGMENT_COLLISION(
+					tu_vertices[tu_e1],tu_vertices[(tu_e1+1)%3],
+					tv_vertices[tv_e0],tv_vertices[(tv_e0+1)%3],
+					closest_point_u,
+					closest_point_v);
+
+				edge_edge_dir = closest_point_u-closest_point_v;
+				VEC_LENGTH(edge_edge_dir,distances[2]);
+				edge_edge_dir *= 1.0f/distances[2];// normalize
+			}
+			else
+			{
+				distances[2] = isect_v[0]-isect_u[1];//distance negative
+				//edge_edge_dir *= -1.0f; //normal pointing from V to U
+			}
+
+		}
+		else
+		{
+			if(isect_v[1]>=isect_u[1]) // face V casts face U
+			{
+				return 2;
+			}
+			else if(isect_u[0]<=isect_v[0]) // face U casts face V
+			{
+				return 1;
+			}
+			// closest points
+			closest_point_u = up_e0;
+			closest_point_v = vp_e1;
+			// calc edges and separation
+
+			if(isect_v[1]+MIN_EDGE_EDGE_DIS<isect_u[0]) //calc distance between two lines instead
+			{
+				SEGMENT_COLLISION(
+					tu_vertices[tu_e0],tu_vertices[(tu_e0+1)%3],
+					tv_vertices[tv_e1],tv_vertices[(tv_e1+1)%3],
+					closest_point_u,
+					closest_point_v);
+
+				edge_edge_dir = closest_point_u-closest_point_v;
+				VEC_LENGTH(edge_edge_dir,distances[2]);
+				edge_edge_dir *= 1.0f/distances[2];// normalize
+			}
+			else
+			{
+				distances[2] = isect_u[0]-isect_v[1];//distance negative
+				//edge_edge_dir *= -1.0f; //normal pointing from V to U
+			}
+		}
+		return 3;
+	}
+
+
+	//! collides by two sides
+	SIMD_FORCE_INLINE bool triangle_collision(
+					const btVector3 & u0,
+					const btVector3 & u1,
+					const btVector3 & u2,
+					GREAL margin_u,
+					const btVector3 & v0,
+					const btVector3 & v1,
+					const btVector3 & v2,
+					GREAL margin_v,
+					GIM_TRIANGLE_CONTACT_DATA & contacts)
+	{
+
+		margin = margin_u + margin_v;
+
+		tu_vertices[0] = u0;
+		tu_vertices[1] = u1;
+		tu_vertices[2] = u2;
+
+		tv_vertices[0] = v0;
+		tv_vertices[1] = v1;
+		tv_vertices[2] = v2;
+
+		//create planes
+		// plane v vs U points
+
+		TRIANGLE_PLANE(tv_vertices[0],tv_vertices[1],tv_vertices[2],tv_plane);
+
+		du[0] = DISTANCE_PLANE_POINT(tv_plane,tu_vertices[0]);
+		du[1] = DISTANCE_PLANE_POINT(tv_plane,tu_vertices[1]);
+		du[2] = DISTANCE_PLANE_POINT(tv_plane,tu_vertices[2]);
+
+
+		du0du1 = du[0] * du[1];
+		du0du2 = du[0] * du[2];
+
+
+		if(du0du1>0.0f && du0du2>0.0f)	// same sign on all of them + not equal 0 ?
+		{
+			if(du[0]<0) //we need test behind the triangle plane
+			{
+				distances[0] = GIM_MAX3(du[0],du[1],du[2]);
+				distances[0] = -distances[0];
+				if(distances[0]>margin) return false; //never intersect
+
+				//reorder triangle v
+				VEC_SWAP(tv_vertices[0],tv_vertices[1]);
+				VEC_SCALE_4(tv_plane,-1.0f,tv_plane);
+			}
+			else
+			{
+				distances[0] = GIM_MIN3(du[0],du[1],du[2]);
+				if(distances[0]>margin) return false; //never intersect
+			}
+		}
+		else
+		{
+			//Look if we need to invert the triangle
+			distances[0] = (du[0]+du[1]+du[2])/3.0f; //centroid
+
+			if(distances[0]<0.0f)
+			{
+				//reorder triangle v
+				VEC_SWAP(tv_vertices[0],tv_vertices[1]);
+				VEC_SCALE_4(tv_plane,-1.0f,tv_plane);
+
+				distances[0] = GIM_MAX3(du[0],du[1],du[2]);
+				distances[0] = -distances[0];
+			}
+			else
+			{
+				distances[0] = GIM_MIN3(du[0],du[1],du[2]);
+			}
+		}
+
+
+		// plane U vs V points
+
+		TRIANGLE_PLANE(tu_vertices[0],tu_vertices[1],tu_vertices[2],tu_plane);
+
+		dv[0] = DISTANCE_PLANE_POINT(tu_plane,tv_vertices[0]);
+		dv[1] = DISTANCE_PLANE_POINT(tu_plane,tv_vertices[1]);
+		dv[2] = DISTANCE_PLANE_POINT(tu_plane,tv_vertices[2]);
+
+		dv0dv1 = dv[0] * dv[1];
+		dv0dv2 = dv[0] * dv[2];
+
+
+		if(dv0dv1>0.0f && dv0dv2>0.0f)	// same sign on all of them + not equal 0 ?
+		{
+			if(dv[0]<0) //we need test behind the triangle plane
+			{
+				distances[1] = GIM_MAX3(dv[0],dv[1],dv[2]);
+				distances[1] = -distances[1];
+				if(distances[1]>margin) return false; //never intersect
+
+				//reorder triangle u
+				VEC_SWAP(tu_vertices[0],tu_vertices[1]);
+				VEC_SCALE_4(tu_plane,-1.0f,tu_plane);
+			}
+			else
+			{
+				distances[1] = GIM_MIN3(dv[0],dv[1],dv[2]);
+				if(distances[1]>margin) return false; //never intersect
+			}
+		}
+		else
+		{
+			//Look if we need to invert the triangle
+			distances[1] = (dv[0]+dv[1]+dv[2])/3.0f; //centroid
+
+			if(distances[1]<0.0f)
+			{
+				//reorder triangle v
+				VEC_SWAP(tu_vertices[0],tu_vertices[1]);
+				VEC_SCALE_4(tu_plane,-1.0f,tu_plane);
+
+				distances[1] = GIM_MAX3(dv[0],dv[1],dv[2]);
+				distances[1] = -distances[1];
+			}
+			else
+			{
+				distances[1] = GIM_MIN3(dv[0],dv[1],dv[2]);
+			}
+		}
+
+		GUINT bl;
+		/* bl = cross_line_intersection_test();
+		if(bl==3)
+		{
+			//take edge direction too
+			bl = distances.maxAxis();
+		}
+		else
+		{*/
+			bl = 0;
+			if(distances[0]<distances[1]) bl = 1;
+		//}
+
+		if(bl==2) //edge edge separation
+		{
+			if(distances[2]>margin) return false;
+
+			contacts.m_penetration_depth = -distances[2] + margin;
+			contacts.m_points[0] = closest_point_v;
+			contacts.m_point_count = 1;
+			VEC_COPY(contacts.m_separating_normal,edge_edge_dir);
+
+			return true;
+		}
+
+		//clip face against other
+
+		
+		GUINT point_count;
+		//TODO
+		if(bl == 0) //clip U points against V
+		{
+			point_count = clip_triangle(tv_plane,tv_vertices,tu_vertices,contact_points);
+			if(point_count == 0) return false;						
+			contacts.merge_points(tv_plane,margin,contact_points,point_count);			
+		}
+		else //clip V points against U
+		{
+			point_count = clip_triangle(tu_plane,tu_vertices,tv_vertices,contact_points);
+			if(point_count == 0) return false;			
+			contacts.merge_points(tu_plane,margin,contact_points,point_count);
+			contacts.m_separating_normal *= -1.f;
+		}
+		if(contacts.m_point_count == 0) return false;
+		return true;
+	}
+
+};
+
+
+/*class _GIM_TRIANGLE_CALCULATION_CACHE
+{
+public:
+	GREAL margin;
+	GUINT clipped_count;
+	btVector3 tu_vertices[3];
+	btVector3 tv_vertices[3];
+	btVector3 temp_points[MAX_TRI_CLIPPING];
+	btVector3 temp_points1[MAX_TRI_CLIPPING];
+	btVector3 clipped_points[MAX_TRI_CLIPPING];
+	GIM_TRIANGLE_CONTACT_DATA contacts1;
+	GIM_TRIANGLE_CONTACT_DATA contacts2;
+
+
+	//! clip triangle
+	GUINT clip_triangle(
+		const btVector4 & tri_plane,
+		const btVector3 * tripoints,
+		const btVector3 * srcpoints,
+		btVector3 * clipped_points)
+	{
+		// edge 0
+
+		btVector4 edgeplane;
+
+		EDGE_PLANE(tripoints[0],tripoints[1],tri_plane,edgeplane);
+
+		GUINT clipped_count = PLANE_CLIP_TRIANGLE3D(
+			edgeplane,srcpoints[0],srcpoints[1],srcpoints[2],temp_points);
+
+		if(clipped_count == 0) return 0;
+
+		// edge 1
+
+		EDGE_PLANE(tripoints[1],tripoints[2],tri_plane,edgeplane);
+
+		clipped_count = PLANE_CLIP_POLYGON3D(
+			edgeplane,temp_points,clipped_count,temp_points1);
+
+		if(clipped_count == 0) return 0;
+
+		// edge 2
+
+		EDGE_PLANE(tripoints[2],tripoints[0],tri_plane,edgeplane);
+
+		clipped_count = PLANE_CLIP_POLYGON3D(
+			edgeplane,temp_points1,clipped_count,clipped_points);
+
+		return clipped_count;
+	}
+
+
+
+
+	//! collides only on one side
+	bool triangle_collision(
+					const btVector3 & u0,
+					const btVector3 & u1,
+					const btVector3 & u2,
+					GREAL margin_u,
+					const btVector3 & v0,
+					const btVector3 & v1,
+					const btVector3 & v2,
+					GREAL margin_v,
+					GIM_TRIANGLE_CONTACT_DATA & contacts)
+	{
+
+		margin = margin_u + margin_v;
+
+		
+		tu_vertices[0] = u0;
+		tu_vertices[1] = u1;
+		tu_vertices[2] = u2;
+
+		tv_vertices[0] = v0;
+		tv_vertices[1] = v1;
+		tv_vertices[2] = v2;
+
+		//create planes
+		// plane v vs U points
+
+
+		TRIANGLE_PLANE(tv_vertices[0],tv_vertices[1],tv_vertices[2],contacts1.m_separating_normal);
+
+		clipped_count = clip_triangle(
+			contacts1.m_separating_normal,tv_vertices,tu_vertices,clipped_points);
+
+		if(clipped_count == 0 )
+		{
+			 return false;//Reject
+		}
+
+		//find most deep interval face1
+		contacts1.merge_points(contacts1.m_separating_normal,margin,clipped_points,clipped_count);
+		if(contacts1.m_point_count == 0) return false; // too far
+
+		//Normal pointing to triangle1
+		//contacts1.m_separating_normal *= -1.f;
+
+		//Clip tri1 by tri2 edges
+
+		TRIANGLE_PLANE(tu_vertices[0],tu_vertices[1],tu_vertices[2],contacts2.m_separating_normal);
+
+		clipped_count = clip_triangle(
+			contacts2.m_separating_normal,tu_vertices,tv_vertices,clipped_points);
+
+		if(clipped_count == 0 )
+		{
+			 return false;//Reject
+		}
+
+		//find most deep interval face1
+		contacts2.merge_points(contacts2.m_separating_normal,margin,clipped_points,clipped_count);
+		if(contacts2.m_point_count == 0) return false; // too far
+
+		contacts2.m_separating_normal *= -1.f;
+
+		////check most dir for contacts
+		if(contacts2.m_penetration_depth<contacts1.m_penetration_depth)
+		{
+			contacts.copy_from(contacts2);
+		}
+		else
+		{
+			contacts.copy_from(contacts1);
+		}
+		return true;
+	}
+
+
+};*/
+
+
+
+bool GIM_TRIANGLE::collide_triangle_hard_test(
+		const GIM_TRIANGLE & other,
+		GIM_TRIANGLE_CONTACT_DATA & contact_data) const
+{
+	_GIM_TRIANGLE_CALCULATION_CACHE calc_cache;	
+	return calc_cache.triangle_collision(
+					m_vertices[0],m_vertices[1],m_vertices[2],m_margin,
+					other.m_vertices[0],other.m_vertices[1],other.m_vertices[2],other.m_margin,
+					contact_data);
+
+}
+
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_tri_collision.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_tri_collision.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/GIMPACT/gim_tri_collision.h	(revision 2122)
@@ -0,0 +1,383 @@
+#ifndef GIM_TRI_COLLISION_H_INCLUDED
+#define GIM_TRI_COLLISION_H_INCLUDED
+
+/*! \file gim_tri_collision.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+   (1) The GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 2.1 of the License, or (at
+       your option) any later version. The text of the GNU Lesser
+       General Public License is included with this library in the
+       file GIMPACT-LICENSE-LGPL.TXT.
+   (2) The BSD-style license that is included with this library in
+       the file GIMPACT-LICENSE-BSD.TXT.
+   (3) The zlib/libpng license that is included with this library in
+       the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+
+#include "gim_box_collision.h"
+#include "gim_clip_polygon.h"
+
+/*! \addtogroup GEOMETRIC_OPERATIONS
+*/
+//! @{
+
+
+
+#define MAX_TRI_CLIPPING 16
+
+//! Structure for collision
+struct GIM_TRIANGLE_CONTACT_DATA
+{
+    GREAL m_penetration_depth;
+    GUINT m_point_count;
+    btVector4 m_separating_normal;
+    btVector3 m_points[MAX_TRI_CLIPPING];
+
+	SIMD_FORCE_INLINE void copy_from(const GIM_TRIANGLE_CONTACT_DATA& other)
+	{
+		m_penetration_depth = other.m_penetration_depth;
+		m_separating_normal = other.m_separating_normal;
+		m_point_count = other.m_point_count;
+		GUINT i = m_point_count;
+		while(i--)
+		{
+			m_points[i] = other.m_points[i];
+		}
+	}
+
+	GIM_TRIANGLE_CONTACT_DATA()
+	{
+	}
+
+	GIM_TRIANGLE_CONTACT_DATA(const GIM_TRIANGLE_CONTACT_DATA& other)
+	{
+		copy_from(other);
+	}
+
+	
+	
+
+    //! classify points that are closer
+    template<typename DISTANCE_FUNC,typename CLASS_PLANE>
+    SIMD_FORCE_INLINE void mergepoints_generic(const CLASS_PLANE & plane,
+    				GREAL margin, const btVector3 * points, GUINT point_count, DISTANCE_FUNC distance_func)
+    {	
+    	m_point_count = 0;
+    	m_penetration_depth= -1000.0f;
+
+		GUINT point_indices[MAX_TRI_CLIPPING];
+
+		GUINT _k;
+
+		for(_k=0;_k<point_count;_k++)
+		{
+			GREAL _dist = -distance_func(plane,points[_k]) + margin;
+
+			if(_dist>=0.0f)
+			{
+				if(_dist>m_penetration_depth)
+				{
+					m_penetration_depth = _dist;
+					point_indices[0] = _k;
+					m_point_count=1;
+				}
+				else if((_dist+G_EPSILON)>=m_penetration_depth)
+				{
+					point_indices[m_point_count] = _k;
+					m_point_count++;
+				}
+			}
+		}
+
+		for( _k=0;_k<m_point_count;_k++)
+		{
+			m_points[_k] = points[point_indices[_k]];
+		}
+	}
+
+	//! classify points that are closer
+	SIMD_FORCE_INLINE void merge_points(const btVector4 & plane, GREAL margin,
+										 const btVector3 * points, GUINT point_count)
+	{
+		m_separating_normal = plane;
+		mergepoints_generic(plane, margin, points, point_count, DISTANCE_PLANE_3D_FUNC());
+	}
+};
+
+
+//! Class for colliding triangles
+class GIM_TRIANGLE
+{
+public:
+	btScalar m_margin;
+    btVector3 m_vertices[3];
+
+    GIM_TRIANGLE():m_margin(0.1f)
+    {
+    }
+
+    SIMD_FORCE_INLINE GIM_AABB get_box()  const
+    {
+    	return GIM_AABB(m_vertices[0],m_vertices[1],m_vertices[2],m_margin);
+    }
+
+    SIMD_FORCE_INLINE void get_normal(btVector3 &normal)  const
+    {
+    	TRIANGLE_NORMAL(m_vertices[0],m_vertices[1],m_vertices[2],normal);
+    }
+
+    SIMD_FORCE_INLINE void get_plane(btVector4 &plane)  const
+    {
+    	TRIANGLE_PLANE(m_vertices[0],m_vertices[1],m_vertices[2],plane);;
+    }
+
+    SIMD_FORCE_INLINE void apply_transform(const btTransform & trans)
+    {
+    	m_vertices[0] = trans(m_vertices[0]);
+    	m_vertices[1] = trans(m_vertices[1]);
+    	m_vertices[2] = trans(m_vertices[2]);
+    }
+
+    SIMD_FORCE_INLINE void get_edge_plane(GUINT edge_index,const btVector3 &triangle_normal,btVector4 &plane)  const
+    {
+		const btVector3 & e0 = m_vertices[edge_index];
+		const btVector3 & e1 = m_vertices[(edge_index+1)%3];
+		EDGE_PLANE(e0,e1,triangle_normal,plane);
+    }
+
+    //! Gets the relative transformation of this triangle
+    /*!
+    The transformation is oriented to the triangle normal , and aligned to the 1st edge of this triangle. The position corresponds to vertice 0:
+    - triangle normal corresponds to Z axis.
+    - 1st normalized edge corresponds to X axis,
+
+    */
+    SIMD_FORCE_INLINE void get_triangle_transform(btTransform & triangle_transform)  const
+    {
+    	btMatrix3x3 & matrix = triangle_transform.getBasis();
+
+    	btVector3 zaxis;
+    	get_normal(zaxis);
+    	MAT_SET_Z(matrix,zaxis);
+
+    	btVector3 xaxis = m_vertices[1] - m_vertices[0];
+    	VEC_NORMALIZE(xaxis);
+    	MAT_SET_X(matrix,xaxis);
+
+    	//y axis
+    	xaxis = zaxis.cross(xaxis);
+    	MAT_SET_Y(matrix,xaxis);
+
+    	triangle_transform.setOrigin(m_vertices[0]);
+    }
+
+
+	//! Test triangles by finding separating axis
+	/*!
+	\param other Triangle for collide
+	\param contact_data Structure for holding contact points, normal and penetration depth; The normal is pointing toward this triangle from the other triangle
+	*/
+	bool collide_triangle_hard_test(
+		const GIM_TRIANGLE & other,
+		GIM_TRIANGLE_CONTACT_DATA & contact_data) const;
+
+	//! Test boxes before doing hard test
+	/*!
+	\param other Triangle for collide
+	\param contact_data Structure for holding contact points, normal and penetration depth; The normal is pointing toward this triangle from the other triangle
+	\
+	*/
+	SIMD_FORCE_INLINE bool collide_triangle(
+		const GIM_TRIANGLE & other,
+		GIM_TRIANGLE_CONTACT_DATA & contact_data) const
+	{
+		//test box collisioin
+		GIM_AABB boxu(m_vertices[0],m_vertices[1],m_vertices[2],m_margin);
+		GIM_AABB boxv(other.m_vertices[0],other.m_vertices[1],other.m_vertices[2],other.m_margin);
+		if(!boxu.has_collision(boxv)) return false;
+
+		//do hard test
+		return collide_triangle_hard_test(other,contact_data);
+	}
+
+	/*!
+
+	Solve the System for u,v parameters:
+
+	u*axe1[i1] + v*axe2[i1] = vecproj[i1]
+	u*axe1[i2] + v*axe2[i2] = vecproj[i2]
+
+	sustitute:
+	v = (vecproj[i2] - u*axe1[i2])/axe2[i2]
+
+	then the first equation in terms of 'u':
+
+	--> u*axe1[i1] + ((vecproj[i2] - u*axe1[i2])/axe2[i2])*axe2[i1] = vecproj[i1]
+
+	--> u*axe1[i1] + vecproj[i2]*axe2[i1]/axe2[i2] - u*axe1[i2]*axe2[i1]/axe2[i2] = vecproj[i1]
+
+	--> u*(axe1[i1]  - axe1[i2]*axe2[i1]/axe2[i2]) = vecproj[i1] - vecproj[i2]*axe2[i1]/axe2[i2]
+
+	--> u*((axe1[i1]*axe2[i2]  - axe1[i2]*axe2[i1])/axe2[i2]) = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1])/axe2[i2]
+
+	--> u*(axe1[i1]*axe2[i2]  - axe1[i2]*axe2[i1]) = vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]
+
+	--> u = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]) /(axe1[i1]*axe2[i2]  - axe1[i2]*axe2[i1])
+
+if 0.0<= u+v <=1.0 then they are inside of triangle
+
+	\return false if the point is outside of triangle.This function  doesn't take the margin
+	*/
+	SIMD_FORCE_INLINE bool get_uv_parameters(
+			const btVector3 & point,
+			const btVector3 & tri_plane,
+			GREAL & u, GREAL & v) const
+	{
+		btVector3 _axe1 = m_vertices[1]-m_vertices[0];
+		btVector3 _axe2 = m_vertices[2]-m_vertices[0];
+		btVector3 _vecproj = point - m_vertices[0];
+		GUINT _i1 = (tri_plane.closestAxis()+1)%3;
+		GUINT _i2 = (_i1+1)%3;
+		if(btFabs(_axe2[_i2])<G_EPSILON)
+		{
+			u = (_vecproj[_i2]*_axe2[_i1] - _vecproj[_i1]*_axe2[_i2]) /(_axe1[_i2]*_axe2[_i1]  - _axe1[_i1]*_axe2[_i2]);
+			v = (_vecproj[_i1] - u*_axe1[_i1])/_axe2[_i1];
+		}
+		else
+		{
+			u = (_vecproj[_i1]*_axe2[_i2] - _vecproj[_i2]*_axe2[_i1]) /(_axe1[_i1]*_axe2[_i2]  - _axe1[_i2]*_axe2[_i1]);
+			v = (_vecproj[_i2] - u*_axe1[_i2])/_axe2[_i2];
+		}
+
+		if(u<-G_EPSILON)
+		{
+			return false;
+		}
+		else if(v<-G_EPSILON)
+		{
+			return false;
+		}
+		else
+		{
+			float sumuv;
+			sumuv = u+v;
+			if(sumuv<-G_EPSILON)
+			{
+				return false;
+			}
+			else if(sumuv-1.0f>G_EPSILON)
+			{
+				return false;
+			}
+		}
+		return true;
+	}
+
+	//! is point in triangle beam?
+	/*!
+	Test if point is in triangle, with m_margin tolerance
+	*/
+	SIMD_FORCE_INLINE bool is_point_inside(const btVector3 & point, const btVector3 & tri_normal) const
+	{
+		//Test with edge 0
+		btVector4 edge_plane;
+		this->get_edge_plane(0,tri_normal,edge_plane);
+		GREAL dist = DISTANCE_PLANE_POINT(edge_plane,point);
+		if(dist-m_margin>0.0f) return false; // outside plane
+
+		this->get_edge_plane(1,tri_normal,edge_plane);
+		dist = DISTANCE_PLANE_POINT(edge_plane,point);
+		if(dist-m_margin>0.0f) return false; // outside plane
+
+		this->get_edge_plane(2,tri_normal,edge_plane);
+		dist = DISTANCE_PLANE_POINT(edge_plane,point);
+		if(dist-m_margin>0.0f) return false; // outside plane
+		return true;
+	}
+
+
+	//! Bidireccional ray collision
+	SIMD_FORCE_INLINE bool ray_collision(
+		const btVector3 & vPoint,
+		const btVector3 & vDir, btVector3 & pout, btVector3 & triangle_normal,
+		GREAL & tparam, GREAL tmax = G_REAL_INFINITY)
+	{
+		btVector4 faceplane;
+		{
+			btVector3 dif1 = m_vertices[1] - m_vertices[0];
+			btVector3 dif2 = m_vertices[2] - m_vertices[0];
+    		VEC_CROSS(faceplane,dif1,dif2);
+    		faceplane[3] = m_vertices[0].dot(faceplane);
+		}
+
+		GUINT res = LINE_PLANE_COLLISION(faceplane,vDir,vPoint,pout,tparam, btScalar(0), tmax);
+		if(res == 0) return false;
+		if(! is_point_inside(pout,faceplane)) return false;
+
+		if(res==2) //invert normal
+		{
+			triangle_normal.setValue(-faceplane[0],-faceplane[1],-faceplane[2]);
+		}
+		else
+		{
+			triangle_normal.setValue(faceplane[0],faceplane[1],faceplane[2]);
+		}
+
+		VEC_NORMALIZE(triangle_normal);
+
+		return true;
+	}
+
+
+	//! one direccion ray collision
+	SIMD_FORCE_INLINE bool ray_collision_front_side(
+		const btVector3 & vPoint,
+		const btVector3 & vDir, btVector3 & pout, btVector3 & triangle_normal,
+		GREAL & tparam, GREAL tmax = G_REAL_INFINITY)
+	{
+		btVector4 faceplane;
+		{
+			btVector3 dif1 = m_vertices[1] - m_vertices[0];
+			btVector3 dif2 = m_vertices[2] - m_vertices[0];
+    		VEC_CROSS(faceplane,dif1,dif2);
+    		faceplane[3] = m_vertices[0].dot(faceplane);
+		}
+
+		GUINT res = LINE_PLANE_COLLISION(faceplane,vDir,vPoint,pout,tparam, btScalar(0), tmax);
+		if(res != 1) return false;
+
+		if(!is_point_inside(pout,faceplane)) return false;
+
+		triangle_normal.setValue(faceplane[0],faceplane[1],faceplane[2]);
+
+		VEC_NORMALIZE(triangle_normal);
+
+		return true;
+	}
+
+};
+
+
+
+//! @}
+
+#endif // GIM_TRI_COLLISION_H_INCLUDED
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp	(revision 2122)
@@ -0,0 +1,225 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btContinuousConvexCollision.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
+#include "LinearMath/btTransformUtil.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+
+#include "btGjkPairDetector.h"
+#include "btPointCollector.h"
+
+
+
+btContinuousConvexCollision::btContinuousConvexCollision ( const btConvexShape*	convexA,const btConvexShape*	convexB,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* penetrationDepthSolver)
+:m_simplexSolver(simplexSolver),
+m_penetrationDepthSolver(penetrationDepthSolver),
+m_convexA(convexA),m_convexB(convexB)
+{
+}
+
+/// This maximum should not be necessary. It allows for untested/degenerate cases in production code.
+/// You don't want your game ever to lock-up.
+#define MAX_ITERATIONS 64
+
+bool	btContinuousConvexCollision::calcTimeOfImpact(
+				const btTransform& fromA,
+				const btTransform& toA,
+				const btTransform& fromB,
+				const btTransform& toB,
+				CastResult& result)
+{
+
+	m_simplexSolver->reset();
+
+	/// compute linear and angular velocity for this interval, to interpolate
+	btVector3 linVelA,angVelA,linVelB,angVelB;
+	btTransformUtil::calculateVelocity(fromA,toA,btScalar(1.),linVelA,angVelA);
+	btTransformUtil::calculateVelocity(fromB,toB,btScalar(1.),linVelB,angVelB);
+
+
+	btScalar boundingRadiusA = m_convexA->getAngularMotionDisc();
+	btScalar boundingRadiusB = m_convexB->getAngularMotionDisc();
+
+	btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB;
+	btVector3 relLinVel = (linVelB-linVelA);
+
+	btScalar relLinVelocLength = (linVelB-linVelA).length();
+	
+	if ((relLinVelocLength+maxAngularProjectedVelocity) == 0.f)
+		return false;
+
+
+	btScalar radius = btScalar(0.001);
+
+	btScalar lambda = btScalar(0.);
+	btVector3 v(1,0,0);
+
+	int maxIter = MAX_ITERATIONS;
+
+	btVector3 n;
+	n.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+	bool hasResult = false;
+	btVector3 c;
+
+	btScalar lastLambda = lambda;
+	//btScalar epsilon = btScalar(0.001);
+
+	int numIter = 0;
+	//first solution, using GJK
+
+
+	btTransform identityTrans;
+	identityTrans.setIdentity();
+
+	btSphereShape	raySphere(btScalar(0.0));
+	raySphere.setMargin(btScalar(0.));
+
+
+//	result.drawCoordSystem(sphereTr);
+
+	btPointCollector	pointCollector1;
+
+	{
+		
+		btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver);		
+		btGjkPairDetector::ClosestPointInput input;
+	
+		//we don't use margins during CCD
+	//	gjk.setIgnoreMargin(true);
+
+		input.m_transformA = fromA;
+		input.m_transformB = fromB;
+		gjk.getClosestPoints(input,pointCollector1,0);
+
+		hasResult = pointCollector1.m_hasResult;
+		c = pointCollector1.m_pointInWorld;
+	}
+
+	if (hasResult)
+	{
+		btScalar dist;
+		dist = pointCollector1.m_distance;
+		n = pointCollector1.m_normalOnBInWorld;
+
+		btScalar projectedLinearVelocity = relLinVel.dot(n);
+		
+		//not close enough
+		while (dist > radius)
+		{
+			numIter++;
+			if (numIter > maxIter)
+			{
+				return false; //todo: report a failure
+			}
+			btScalar dLambda = btScalar(0.);
+
+			projectedLinearVelocity = relLinVel.dot(n);
+
+			//calculate safe moving fraction from distance / (linear+rotational velocity)
+			
+			//btScalar clippedDist  = GEN_min(angularConservativeRadius,dist);
+			//btScalar clippedDist  = dist;
+			
+			
+			dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
+
+			
+			
+			lambda = lambda + dLambda;
+
+			if (lambda > btScalar(1.))
+				return false;
+
+			if (lambda < btScalar(0.))
+				return false;
+
+
+			//todo: next check with relative epsilon
+			if (lambda <= lastLambda)
+			{
+				return false;
+				//n.setValue(0,0,0);
+				break;
+			}
+			lastLambda = lambda;
+
+			
+
+			//interpolate to next lambda
+			btTransform interpolatedTransA,interpolatedTransB,relativeTrans;
+
+			btTransformUtil::integrateTransform(fromA,linVelA,angVelA,lambda,interpolatedTransA);
+			btTransformUtil::integrateTransform(fromB,linVelB,angVelB,lambda,interpolatedTransB);
+			relativeTrans = interpolatedTransB.inverseTimes(interpolatedTransA);
+
+			result.DebugDraw( lambda );
+
+			btPointCollector	pointCollector;
+			btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver);
+			btGjkPairDetector::ClosestPointInput input;
+			input.m_transformA = interpolatedTransA;
+			input.m_transformB = interpolatedTransB;
+			gjk.getClosestPoints(input,pointCollector,0);
+			if (pointCollector.m_hasResult)
+			{
+				if (pointCollector.m_distance < btScalar(0.))
+				{
+					//degenerate ?!
+					result.m_fraction = lastLambda;
+					n = pointCollector.m_normalOnBInWorld;
+					result.m_normal=n;//.setValue(1,1,1);// = n;
+					result.m_hitPoint = pointCollector.m_pointInWorld;
+					return true;
+				}
+				c = pointCollector.m_pointInWorld;		
+				n = pointCollector.m_normalOnBInWorld;
+				dist = pointCollector.m_distance;
+			} else
+			{
+				//??
+				return false;
+			}
+
+		}
+
+		//don't report time of impact for motion away from the contact normal (or causes minor penetration)
+		if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=result.m_allowedPenetration)//SIMD_EPSILON)
+			return false;
+
+		result.m_fraction = lambda;
+		result.m_normal = n;
+		result.m_hitPoint = c;
+		return true;
+	}
+
+	return false;
+
+/*
+//todo:
+	//if movement away from normal, discard result
+	btVector3 move = transBLocalTo.getOrigin() - transBLocalFrom.getOrigin();
+	if (result.m_fraction < btScalar(1.))
+	{
+		if (move.dot(result.m_normal) <= btScalar(0.))
+		{
+		}
+	}
+*/
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h	(revision 2122)
@@ -0,0 +1,52 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef CONTINUOUS_COLLISION_CONVEX_CAST_H
+#define CONTINUOUS_COLLISION_CONVEX_CAST_H
+
+#include "btConvexCast.h"
+#include "btSimplexSolverInterface.h"
+class btConvexPenetrationDepthSolver;
+class btConvexShape;
+
+/// btContinuousConvexCollision implements angular and linear time of impact for convex objects.
+/// Based on Brian Mirtich's Conservative Advancement idea (PhD thesis).
+/// Algorithm operates in worldspace, in order to keep inbetween motion globally consistent.
+/// It uses GJK at the moment. Future improvement would use minkowski sum / supporting vertex, merging innerloops
+class btContinuousConvexCollision : public btConvexCast
+{
+	btSimplexSolverInterface* m_simplexSolver;
+	btConvexPenetrationDepthSolver*	m_penetrationDepthSolver;
+	const btConvexShape*	m_convexA;
+	const btConvexShape*	m_convexB;
+
+
+public:
+
+	btContinuousConvexCollision (const btConvexShape*	shapeA,const btConvexShape*	shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
+
+	virtual bool	calcTimeOfImpact(
+				const btTransform& fromA,
+				const btTransform& toA,
+				const btTransform& fromB,
+				const btTransform& toB,
+				CastResult& result);
+
+
+};
+
+#endif //CONTINUOUS_COLLISION_CONVEX_CAST_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp	(revision 2122)
@@ -0,0 +1,20 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btConvexCast.h"
+
+btConvexCast::~btConvexCast()
+{
+}
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef CONVEX_CAST_H
+#define CONVEX_CAST_H
+
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btScalar.h"
+class btMinkowskiSumShape;
+#include "LinearMath/btIDebugDraw.h"
+
+/// btConvexCast is an interface for Casting
+class btConvexCast
+{
+public:
+
+
+	virtual ~btConvexCast();
+
+	///RayResult stores the closest result
+	/// alternatively, add a callback method to decide about closest/all results
+	struct	CastResult
+	{
+		//virtual bool	addRayResult(const btVector3& normal,btScalar	fraction) = 0;
+				
+		virtual void	DebugDraw(btScalar	fraction) {(void)fraction;}
+		virtual void	drawCoordSystem(const btTransform& trans) {(void)trans;}
+
+		CastResult()
+			:m_fraction(btScalar(1e30)),
+			m_debugDrawer(0),
+			m_allowedPenetration(btScalar(0))
+		{
+		}
+
+
+		virtual ~CastResult() {};
+
+		btTransform	m_hitTransformA;
+		btTransform	m_hitTransformB;
+		btVector3	m_normal;
+		btVector3   m_hitPoint;
+		btScalar	m_fraction; //input and output
+		btIDebugDraw* m_debugDrawer;
+		btScalar	m_allowedPenetration;
+
+	};
+
+
+	/// cast a convex against another convex object
+	virtual bool	calcTimeOfImpact(
+					const btTransform& fromA,
+					const btTransform& toA,
+					const btTransform& fromB,
+					const btTransform& toB,
+					CastResult& result) = 0;
+};
+
+#endif //CONVEX_CAST_H
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h	(revision 2122)
@@ -0,0 +1,43 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef CONVEX_PENETRATION_DEPTH_H
+#define CONVEX_PENETRATION_DEPTH_H
+
+class btStackAlloc;
+class btVector3;
+#include "btSimplexSolverInterface.h"
+class btConvexShape;
+#include "LinearMath/btPoint3.h"
+class btTransform;
+
+///ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
+class btConvexPenetrationDepthSolver
+{
+public:	
+	
+	virtual ~btConvexPenetrationDepthSolver() {};
+	virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
+		const btConvexShape* convexA,const btConvexShape* convexB,
+					const btTransform& transA,const btTransform& transB,
+				btVector3& v, btPoint3& pa, btPoint3& pb,
+				class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+				) = 0;
+
+
+};
+#endif //CONVEX_PENETRATION_DEPTH_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h	(revision 2122)
@@ -0,0 +1,88 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
+#define DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btVector3.h"
+class btStackAlloc;
+
+/// This interface is made to be used by an iterative approach to do TimeOfImpact calculations
+/// This interface allows to query for closest points and penetration depth between two (convex) objects
+/// the closest point is on the second object (B), and the normal points from the surface on B towards A.
+/// distance is between closest points on B and closest point on A. So you can calculate closest point on A
+/// by taking closestPointInA = closestPointInB + m_distance * m_normalOnSurfaceB
+struct btDiscreteCollisionDetectorInterface
+{
+	
+	struct Result
+	{
+	
+		virtual ~Result(){}	
+
+		///setShapeIdentifiers provides experimental support for per-triangle material / custom material combiner
+		virtual void setShapeIdentifiers(int partId0,int index0,	int partId1,int index1)=0;
+		virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)=0;
+	};
+
+	struct ClosestPointInput
+	{
+		ClosestPointInput()
+			:m_maximumDistanceSquared(btScalar(1e30)),
+			m_stackAlloc(0)
+		{
+		}
+
+		btTransform m_transformA;
+		btTransform m_transformB;
+		btScalar	m_maximumDistanceSquared;
+		btStackAlloc* m_stackAlloc;
+	};
+
+	virtual ~btDiscreteCollisionDetectorInterface() {};
+
+	//
+	// give either closest points (distance > 0) or penetration (distance)
+	// the normal always points from B towards A
+	//
+	virtual void	getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false) = 0;
+
+};
+
+struct btStorageResult : public btDiscreteCollisionDetectorInterface::Result
+{
+		btVector3	m_normalOnSurfaceB;
+		btVector3	m_closestPointInB;
+		btScalar	m_distance; //negative means penetration !
+
+		btStorageResult() : m_distance(btScalar(1e30))
+		{
+
+		}
+		virtual ~btStorageResult() {};
+
+		virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
+		{
+			if (depth < m_distance)
+			{
+				m_normalOnSurfaceB = normalOnBInWorld;
+				m_closestPointInB = pointInWorld;
+				m_distance = depth;
+			}
+		}
+};
+
+#endif //DISCRETE_COLLISION_DETECTOR_INTERFACE1_H
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp	(revision 2122)
@@ -0,0 +1,176 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#include "btGjkConvexCast.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "btGjkPairDetector.h"
+#include "btPointCollector.h"
+#include "LinearMath/btTransformUtil.h"
+
+#ifdef BT_USE_DOUBLE_PRECISION
+#define MAX_ITERATIONS 64
+#else
+#define MAX_ITERATIONS 32
+#endif
+
+btGjkConvexCast::btGjkConvexCast(const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver)
+:m_simplexSolver(simplexSolver),
+m_convexA(convexA),
+m_convexB(convexB)
+{
+}
+
+bool	btGjkConvexCast::calcTimeOfImpact(
+					const btTransform& fromA,
+					const btTransform& toA,
+					const btTransform& fromB,
+					const btTransform& toB,
+					CastResult& result)
+{
+
+
+	m_simplexSolver->reset();
+
+	/// compute linear velocity for this interval, to interpolate
+	//assume no rotation/angular velocity, assert here?
+	btVector3 linVelA,linVelB;
+	linVelA = toA.getOrigin()-fromA.getOrigin();
+	linVelB = toB.getOrigin()-fromB.getOrigin();
+
+	btScalar radius = btScalar(0.001);
+	btScalar lambda = btScalar(0.);
+	btVector3 v(1,0,0);
+
+	int maxIter = MAX_ITERATIONS;
+
+	btVector3 n;
+	n.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+	bool hasResult = false;
+	btVector3 c;
+	btVector3 r = (linVelA-linVelB);
+
+	btScalar lastLambda = lambda;
+	//btScalar epsilon = btScalar(0.001);
+
+	int numIter = 0;
+	//first solution, using GJK
+
+
+	btTransform identityTrans;
+	identityTrans.setIdentity();
+
+
+//	result.drawCoordSystem(sphereTr);
+
+	btPointCollector	pointCollector;
+
+		
+	btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,0);//m_penetrationDepthSolver);		
+	btGjkPairDetector::ClosestPointInput input;
+
+	//we don't use margins during CCD
+	//	gjk.setIgnoreMargin(true);
+
+	input.m_transformA = fromA;
+	input.m_transformB = fromB;
+	gjk.getClosestPoints(input,pointCollector,0);
+
+	hasResult = pointCollector.m_hasResult;
+	c = pointCollector.m_pointInWorld;
+
+	if (hasResult)
+	{
+		btScalar dist;
+		dist = pointCollector.m_distance;
+		n = pointCollector.m_normalOnBInWorld;
+
+	
+
+		//not close enough
+		while (dist > radius)
+		{
+			numIter++;
+			if (numIter > maxIter)
+			{
+				return false; //todo: report a failure
+			}
+			btScalar dLambda = btScalar(0.);
+
+			btScalar projectedLinearVelocity = r.dot(n);
+			
+			dLambda = dist / (projectedLinearVelocity);
+
+			lambda = lambda - dLambda;
+
+			if (lambda > btScalar(1.))
+				return false;
+
+			if (lambda < btScalar(0.))
+				return false;
+
+			//todo: next check with relative epsilon
+			if (lambda <= lastLambda)
+			{
+				return false;
+				//n.setValue(0,0,0);
+				break;
+			}
+			lastLambda = lambda;
+
+			//interpolate to next lambda
+			result.DebugDraw( lambda );
+			input.m_transformA.getOrigin().setInterpolate3(fromA.getOrigin(),toA.getOrigin(),lambda);
+			input.m_transformB.getOrigin().setInterpolate3(fromB.getOrigin(),toB.getOrigin(),lambda);
+			
+			gjk.getClosestPoints(input,pointCollector,0);
+			if (pointCollector.m_hasResult)
+			{
+				if (pointCollector.m_distance < btScalar(0.))
+				{
+					result.m_fraction = lastLambda;
+					n = pointCollector.m_normalOnBInWorld;
+					result.m_normal=n;
+					result.m_hitPoint = pointCollector.m_pointInWorld;
+					return true;
+				}
+				c = pointCollector.m_pointInWorld;		
+				n = pointCollector.m_normalOnBInWorld;
+				dist = pointCollector.m_distance;
+			} else
+			{
+				//??
+				return false;
+			}
+
+		}
+
+		//is n normalized?
+		//don't report time of impact for motion away from the contact normal (or causes minor penetration)
+		if (n.dot(r)>=-result.m_allowedPenetration)
+			return false;
+
+		result.m_fraction = lambda;
+		result.m_normal = n;
+		result.m_hitPoint = c;
+		return true;
+	}
+
+	return false;
+
+
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h	(revision 2122)
@@ -0,0 +1,50 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef GJK_CONVEX_CAST_H
+#define GJK_CONVEX_CAST_H
+
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+#include "LinearMath/btVector3.h"
+#include "btConvexCast.h"
+class btConvexShape;
+class btMinkowskiSumShape;
+#include "btSimplexSolverInterface.h"
+
+///GjkConvexCast performs a raycast on a convex object using support mapping.
+class btGjkConvexCast : public btConvexCast
+{
+	btSimplexSolverInterface*	m_simplexSolver;
+	const btConvexShape*	m_convexA;
+	const btConvexShape*	m_convexB;
+
+public:
+
+	btGjkConvexCast(const btConvexShape*	convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver);
+
+	/// cast a convex against another convex object
+	virtual bool	calcTimeOfImpact(
+					const btTransform& fromA,
+					const btTransform& toA,
+					const btTransform& fromB,
+					const btTransform& toB,
+					CastResult& result);
+
+};
+
+#endif //GJK_CONVEX_CAST_H
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp	(revision 2122)
@@ -0,0 +1,628 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the
+use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software in a
+product, an acknowledgment in the product documentation would be appreciated
+but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+GJK-EPA collision solver by Nathanael Presson
+Nov.2006
+*/
+
+#include "btGjkEpa.h"
+#include <string.h> //for memset
+#include "LinearMath/btStackAlloc.h"
+
+#if defined(DEBUG) || defined (_DEBUG)
+#include <stdio.h> //for debug printf
+#ifdef __SPU__
+#include <spu_printf.h>
+#define printf spu_printf
+#endif //__SPU__
+#endif
+
+namespace gjkepa_impl
+{
+
+//
+// Port. typedefs
+//
+
+typedef	btScalar		F;
+typedef bool			Z;
+typedef int				I;
+typedef unsigned int	U;
+typedef unsigned char	U1;
+typedef unsigned short	U2;
+
+typedef btVector3		Vector3;
+typedef btMatrix3x3		Rotation;
+
+//
+// Config
+//
+
+#if 0
+#define BTLOCALSUPPORT	localGetSupportingVertexWithoutMargin
+#else
+#define BTLOCALSUPPORT	localGetSupportingVertex
+#endif
+
+//
+// Const
+//
+
+
+#define cstInf				SIMD_INFINITY
+#define cstPi				SIMD_PI
+#define	cst2Pi				SIMD_2_PI
+#define GJK_maxiterations	(128)
+#define GJK_hashsize		(1<<6)
+#define GJK_hashmask		(GJK_hashsize-1)
+#define GJK_insimplex_eps	F(0.0001)
+#define GJK_sqinsimplex_eps	(GJK_insimplex_eps*GJK_insimplex_eps)
+#define EPA_maxiterations	256
+#define	EPA_inface_eps		F(0.01)
+#define EPA_accuracy		F(0.001)
+
+//
+// Utils
+//
+
+static inline F								Abs(F v)					{ return(v<0?-v:v); }
+static inline F								Sign(F v)					{ return(F(v<0?-1:1)); }
+template <typename T> static inline void	Swap(T& a,T& b)				{ T 
+t(a);a=b;b=t; }
+template <typename T> static inline T		Min(const T& a,const T& b)	{ 
+return(a<b?a:b); }
+template <typename T> static inline T		Max(const T& a,const T& b)	{ 
+return(a>b?a:b); }
+static inline void							ClearMemory(void* p,U sz)	{ memset(p,0,(size_t)sz); 
+}
+#if 0
+template <typename T> static inline void	Raise(const T& object)		{
+throw(object); }
+#else
+template <typename T> static inline void	Raise(const T&)				{}
+#endif
+
+
+
+//
+// GJK
+//
+struct	GJK
+	{
+	struct Mkv
+		{
+		Vector3	w;		/* Minkowski vertice	*/
+		Vector3	r;		/* Ray					*/
+		};
+	struct He
+		{
+		Vector3	v;
+		He*		n;
+		};
+	btStackAlloc*				sa;
+	btBlock*		sablock;
+	He*						table[GJK_hashsize];
+	Rotation				wrotations[2];
+	Vector3					positions[2];
+	const btConvexShape*	shapes[2];
+	Mkv						simplex[5];
+	Vector3					ray;
+	U						order;
+	U						iterations;
+	F						margin;
+	Z						failed;
+	//
+					GJK(btStackAlloc* psa,
+						const Rotation& wrot0,const Vector3& pos0,const btConvexShape* shape0,
+						const Rotation& wrot1,const Vector3& pos1,const btConvexShape* shape1,
+						F pmargin=0)
+		{
+		wrotations[0]=wrot0;positions[0]=pos0;shapes[0]=shape0;
+		wrotations[1]=wrot1;positions[1]=pos1;shapes[1]=shape1;
+		sa		=psa;
+		sablock	=sa->beginBlock();
+		margin	=pmargin;
+		failed	=false;
+		}
+	//
+					~GJK()
+		{
+		sa->endBlock(sablock);
+		}
+	// vdh : very dumm hash
+	static inline U	Hash(const Vector3& v)
+		{
+		//this doesn't compile under GCC 3.3.5, so add the ()...
+		//const U	h(U(v[0]*15461)^U(v[1]*83003)^U(v[2]*15473));
+		//return(((*((const U*)&h))*169639)&GJK_hashmask);
+	    const U h((U)(v[0]*15461)^(U)(v[1]*83003)^(U)(v[2]*15473));
+	    return(((*((const U*)&h))*169639)&GJK_hashmask);
+		}
+	//
+	inline Vector3	LocalSupport(const Vector3& d,U i) const
+		{
+		return(wrotations[i]*shapes[i]->BTLOCALSUPPORT(d*wrotations[i])+positions[i]);
+		}
+	//
+	inline void		Support(const Vector3& d,Mkv& v) const
+		{
+		v.r	=	d;
+		v.w	=	LocalSupport(d,0)-LocalSupport(-d,1)+d*margin;
+		}
+	#define SPX(_i_)	simplex[_i_]
+	#define SPXW(_i_)	simplex[_i_].w
+	//
+	inline Z		FetchSupport()
+		{
+		const U			h(Hash(ray));
+		He*				e = (He*)(table[h]);
+		while(e) { if(e->v==ray) { --order;return(false); } else e=e->n; }
+		e=(He*)sa->allocate(sizeof(He));e->v=ray;e->n=table[h];table[h]=e;
+		Support(ray,simplex[++order]);
+		return(ray.dot(SPXW(order))>0);
+		}
+	//
+	inline Z		SolveSimplex2(const Vector3& ao,const Vector3& ab)
+		{
+		if(ab.dot(ao)>=0)
+			{
+			const Vector3	cabo(cross(ab,ao));
+			if(cabo.length2()>GJK_sqinsimplex_eps)
+				{ ray=cross(cabo,ab); }
+				else
+				{ return(true); }
+			}
+			else
+			{ order=0;SPX(0)=SPX(1);ray=ao;	}
+		return(false);
+		}
+	//
+	inline Z		SolveSimplex3(const Vector3& ao,const Vector3& ab,const Vector3& 
+ac)
+		{
+		return(SolveSimplex3a(ao,ab,ac,cross(ab,ac)));
+		}
+	//
+	inline Z		SolveSimplex3a(const Vector3& ao,const Vector3& ab,const Vector3& 
+ac,const Vector3& cabc)
+		{
+				if((cross(cabc,ab)).dot(ao)<-GJK_insimplex_eps)
+			{ order=1;SPX(0)=SPX(1);SPX(1)=SPX(2);return(SolveSimplex2(ao,ab));	}
+		else	if((cross(cabc,ac)).dot(ao)>+GJK_insimplex_eps)
+			{ order=1;SPX(1)=SPX(2);return(SolveSimplex2(ao,ac)); }
+		else
+			{
+			const F			d(cabc.dot(ao));
+			if(Abs(d)>GJK_insimplex_eps)
+				{
+				if(d>0)
+					{ ray=cabc; }
+					else
+					{ ray=-cabc;Swap(SPX(0),SPX(1)); }
+				return(false);
+				} else return(true);
+			}
+		}
+	//
+	inline Z		SolveSimplex4(const Vector3& ao,const Vector3& ab,const Vector3& 
+ac,const Vector3& ad)
+		{
+		Vector3			crs;
+				if((crs=cross(ab,ac)).dot(ao)>GJK_insimplex_eps)
+			{ 
+order=2;SPX(0)=SPX(1);SPX(1)=SPX(2);SPX(2)=SPX(3);return(SolveSimplex3a(ao,ab,ac,crs)); 
+}
+		else	if((crs=cross(ac,ad)).dot(ao)>GJK_insimplex_eps)
+			{ order=2;SPX(2)=SPX(3);return(SolveSimplex3a(ao,ac,ad,crs)); }
+		else	if((crs=cross(ad,ab)).dot(ao)>GJK_insimplex_eps)
+			{ 
+order=2;SPX(1)=SPX(0);SPX(0)=SPX(2);SPX(2)=SPX(3);return(SolveSimplex3a(ao,ad,ab,crs)); 
+}
+		else	return(true);
+		}
+	//
+	inline Z		SearchOrigin(const Vector3& initray=Vector3(1,0,0))
+		{
+		iterations	=	0;
+		order		=	(U)-1;
+		failed		=	false;
+		ray			=	initray.normalized();
+		ClearMemory(table,sizeof(void*)*GJK_hashsize);
+		FetchSupport();
+		ray			=	-SPXW(0);
+		for(;iterations<GJK_maxiterations;++iterations)
+			{
+			const F		rl(ray.length());
+			ray/=rl>0?rl:1;
+			if(FetchSupport())
+				{
+				Z	found(false);
+				switch(order)
+					{
+					case	1:	found=SolveSimplex2(-SPXW(1),SPXW(0)-SPXW(1));break;
+					case	2:	found=SolveSimplex3(-SPXW(2),SPXW(1)-SPXW(2),SPXW(0)-SPXW(2));break;
+					case	3:	found=SolveSimplex4(-SPXW(3),SPXW(2)-SPXW(3),SPXW(1)-SPXW(3),SPXW(0)-SPXW(3));break;
+					}
+				if(found) return(true);
+				} else return(false);
+			}
+		failed=true;
+		return(false);
+		}
+	//
+	inline Z		EncloseOrigin()
+		{
+		switch(order)
+			{
+			/* Point		*/
+			case	0:	break;
+			/* Line			*/
+			case	1:
+				{
+				const Vector3	ab(SPXW(1)-SPXW(0));
+				const Vector3	b[]={	cross(ab,Vector3(1,0,0)),
+										cross(ab,Vector3(0,1,0)),
+										cross(ab,Vector3(0,0,1))};
+				const F			m[]={b[0].length2(),b[1].length2(),b[2].length2()};
+				const Rotation	r(btQuaternion(ab.normalized(),cst2Pi/3));
+				Vector3			w(b[m[0]>m[1]?m[0]>m[2]?0:2:m[1]>m[2]?1:2]);
+				Support(w.normalized(),simplex[4]);w=r*w;
+				Support(w.normalized(),simplex[2]);w=r*w;
+				Support(w.normalized(),simplex[3]);w=r*w;
+				order=4;
+				return(true);
+				}
+			break;
+			/* Triangle		*/
+			case	2:
+				{
+				const 
+Vector3	n(cross((SPXW(1)-SPXW(0)),(SPXW(2)-SPXW(0))).normalized());
+				Support( n,simplex[3]);
+				Support(-n,simplex[4]);
+				order=4;
+				return(true);
+				}
+			break;
+			/* Tetrahedron	*/
+			case	3:	return(true);
+			/* Hexahedron	*/
+			case	4:	return(true);
+			}
+		return(false);
+		}
+	#undef SPX
+	#undef SPXW
+	};
+
+//
+// EPA
+//
+struct	EPA
+	{
+	//
+	struct Face
+		{
+		const GJK::Mkv*	v[3];
+		Face*			f[3];
+		U				e[3];
+		Vector3			n;
+		F				d;
+		U				mark;
+		Face*			prev;
+		Face*			next;
+		Face()			{}
+		};
+	//
+	GJK*			gjk;
+	btStackAlloc*		sa;
+	Face*			root;
+	U				nfaces;
+	U				iterations;
+	Vector3			features[2][3];
+	Vector3			nearest[2];
+	Vector3			normal;
+	F				depth;
+	Z				failed;
+	//
+					EPA(GJK* pgjk)
+		{
+		gjk		=	pgjk;
+		sa		=	pgjk->sa;
+		}
+	//
+					~EPA()
+		{
+		}
+	//
+	inline Vector3	GetCoordinates(const Face* face) const
+		{
+		const Vector3	o(face->n*-face->d);
+		const F			a[]={	cross(face->v[0]->w-o,face->v[1]->w-o).length(),
+								cross(face->v[1]->w-o,face->v[2]->w-o).length(),
+								cross(face->v[2]->w-o,face->v[0]->w-o).length()};
+		const F			sm(a[0]+a[1]+a[2]);
+		return(Vector3(a[1],a[2],a[0])/(sm>0?sm:1));
+		}
+	//
+	inline Face*	FindBest() const
+		{
+		Face*	bf = 0;
+		if(root)
+			{
+			Face*	cf = root;
+			F		bd(cstInf);
+			do	{
+				if(cf->d<bd) { bd=cf->d;bf=cf; }
+				} while(0!=(cf=cf->next));
+			}
+		return(bf);
+		}
+	//
+	inline Z		Set(Face* f,const GJK::Mkv* a,const GJK::Mkv* b,const GJK::Mkv*
+c) const
+		{
+		const Vector3	nrm(cross(b->w-a->w,c->w-a->w));
+		const F			len(nrm.length());
+		const Z			valid(	(cross(a->w,b->w).dot(nrm)>=-EPA_inface_eps)&&
+								(cross(b->w,c->w).dot(nrm)>=-EPA_inface_eps)&&
+								(cross(c->w,a->w).dot(nrm)>=-EPA_inface_eps));
+		f->v[0]	=	a;
+		f->v[1]	=	b;
+		f->v[2]	=	c;
+		f->mark	=	0;
+		f->n	=	nrm/(len>0?len:cstInf);
+		f->d	=	Max<F>(0,-f->n.dot(a->w));
+		return(valid);
+		}
+	//
+	inline Face*	NewFace(const GJK::Mkv* a,const GJK::Mkv* b,const GJK::Mkv* c)
+		{
+		Face*	pf = (Face*)sa->allocate(sizeof(Face));
+		if(Set(pf,a,b,c))
+			{
+			if(root) root->prev=pf;
+			pf->prev=0;
+			pf->next=root;
+			root	=pf;
+			++nfaces;
+			}
+			else
+			{
+			pf->prev=pf->next=0;
+			}
+		return(pf);
+		}
+	//
+	inline void		Detach(Face* face)
+		{
+		if(face->prev||face->next)
+			{
+			--nfaces;
+			if(face==root)
+				{ root=face->next;root->prev=0; }
+				else
+				{
+				if(face->next==0)
+					{ face->prev->next=0; }
+					else
+					{ face->prev->next=face->next;face->next->prev=face->prev; }
+				}
+			face->prev=face->next=0;
+			}
+		}
+	//
+	inline void		Link(Face* f0,U e0,Face* f1,U e1) const
+		{
+		f0->f[e0]=f1;f1->e[e1]=e0;
+		f1->f[e1]=f0;f0->e[e0]=e1;
+		}
+	//
+	GJK::Mkv*		Support(const Vector3& w) const
+		{
+		GJK::Mkv*		v =(GJK::Mkv*)sa->allocate(sizeof(GJK::Mkv));
+		gjk->Support(w,*v);
+		return(v);
+		}
+	//
+	U				BuildHorizon(U markid,const GJK::Mkv* w,Face& f,U e,Face*& cf,Face*& 
+ff)
+		{
+		static const U	mod3[]={0,1,2,0,1};
+		U				ne(0);
+		if(f.mark!=markid)
+			{
+			const U	e1(mod3[e+1]);
+			if((f.n.dot(w->w)+f.d)>0)
+				{
+				Face*	nf = NewFace(f.v[e1],f.v[e],w);
+				Link(nf,0,&f,e);
+				if(cf) Link(cf,1,nf,2); else ff=nf;
+				cf=nf;ne=1;
+				}
+				else
+				{
+				const U	e2(mod3[e+2]);
+				Detach(&f);
+				f.mark	=	markid;
+				ne		+=	BuildHorizon(markid,w,*f.f[e1],f.e[e1],cf,ff);
+				ne		+=	BuildHorizon(markid,w,*f.f[e2],f.e[e2],cf,ff);
+				}
+			}
+		return(ne);
+		}
+	//
+	inline F		EvaluatePD(F accuracy=EPA_accuracy)
+		{
+		btBlock*	sablock = sa->beginBlock();
+		Face*				bestface = 0;
+		U					markid(1);
+		depth		=	-cstInf;
+		normal		=	Vector3(0,0,0);
+		root		=	0;
+		nfaces		=	0;
+		iterations	=	0;
+		failed		=	false;
+		/* Prepare hull		*/
+		if(gjk->EncloseOrigin())
+			{
+			const U*		pfidx = 0;
+			U				nfidx= 0;
+			const U*		peidx = 0;
+			U				neidx = 0;
+			GJK::Mkv*		basemkv[5];
+			Face*			basefaces[6];
+			switch(gjk->order)
+				{
+				/* Tetrahedron		*/
+				case	3:	{
+							static const U	fidx[4][3]={{2,1,0},{3,0,1},{3,1,2},{3,2,0}};
+							static const 
+U	eidx[6][4]={{0,0,2,1},{0,1,1,1},{0,2,3,1},{1,0,3,2},{2,0,1,2},{3,0,2,2}};
+							pfidx=(const U*)fidx;nfidx=4;peidx=(const U*)eidx;neidx=6;
+							}	break;
+				/* Hexahedron		*/
+				case	4:	{
+							static const 
+U	fidx[6][3]={{2,0,4},{4,1,2},{1,4,0},{0,3,1},{0,2,3},{1,3,2}};
+							static const 
+U	eidx[9][4]={{0,0,4,0},{0,1,2,1},{0,2,1,2},{1,1,5,2},{1,0,2,0},{2,2,3,2},{3,1,5,0},{3,0,4,2},{5,1,4,1}};
+							pfidx=(const U*)fidx;nfidx=6;peidx=(const U*)eidx;neidx=9;
+							}	break;
+				}
+			U i;
+
+			for( i=0;i<=gjk->order;++i)		{ 
+basemkv[i]=(GJK::Mkv*)sa->allocate(sizeof(GJK::Mkv));*basemkv[i]=gjk->simplex[i]; 
+}
+			for( i=0;i<nfidx;++i,pfidx+=3)		{ 
+basefaces[i]=NewFace(basemkv[pfidx[0]],basemkv[pfidx[1]],basemkv[pfidx[2]]); 
+}
+			for( i=0;i<neidx;++i,peidx+=4)		{ 
+Link(basefaces[peidx[0]],peidx[1],basefaces[peidx[2]],peidx[3]); }
+			}
+		if(0==nfaces)
+			{
+			sa->endBlock(sablock);
+			return(depth);
+			}
+		/* Expand hull		*/
+		for(;iterations<EPA_maxiterations;++iterations)
+			{
+			Face*		bf = FindBest();
+			if(bf)
+				{
+				GJK::Mkv*	w = Support(-bf->n);
+				const F		d(bf->n.dot(w->w)+bf->d);
+				bestface	=	bf;
+				if(d<-accuracy)
+					{
+					Face*	cf =0;
+					Face*	ff =0;
+					U		nf = 0;
+					Detach(bf);
+					bf->mark=++markid;
+					for(U i=0;i<3;++i)	{ 
+nf+=BuildHorizon(markid,w,*bf->f[i],bf->e[i],cf,ff); }
+					if(nf<=2)			{ break; }
+					Link(cf,1,ff,2);
+					} else break;
+				} else break;
+			}
+		/* Extract contact	*/
+		if(bestface)
+			{
+			const Vector3	b(GetCoordinates(bestface));
+			normal			=	bestface->n;
+			depth			=	Max<F>(0,bestface->d);
+			for(U i=0;i<2;++i)
+				{
+				const F	s(F(i?-1:1));
+				for(U j=0;j<3;++j)
+					{
+					features[i][j]=gjk->LocalSupport(s*bestface->v[j]->r,i);
+					}
+				}
+			nearest[0]		=	features[0][0]*b.x()+features[0][1]*b.y()+features[0][2]*b.z();
+			nearest[1]		=	features[1][0]*b.x()+features[1][1]*b.y()+features[1][2]*b.z();
+			} else failed=true;
+		sa->endBlock(sablock);
+		return(depth);
+		}
+	};
+}
+
+//
+// Api
+//
+
+using namespace	gjkepa_impl;
+
+
+
+//
+bool	btGjkEpaSolver::Collide(const btConvexShape *shape0,const btTransform &wtrs0,
+								const btConvexShape *shape1,const btTransform &wtrs1,
+								btScalar	radialmargin,
+								btStackAlloc* stackAlloc,
+								sResults&	results)
+{
+	
+
+/* Initialize					*/
+results.witnesses[0]	=
+results.witnesses[1]	=
+results.normal			=	Vector3(0,0,0);
+results.depth			=	0;
+results.status			=	sResults::Separated;
+results.epa_iterations	=	0;
+results.gjk_iterations	=	0;
+/* Use GJK to locate origin		*/
+GJK			gjk(stackAlloc,
+				wtrs0.getBasis(),wtrs0.getOrigin(),shape0,
+				wtrs1.getBasis(),wtrs1.getOrigin(),shape1,
+				radialmargin+EPA_accuracy);
+const Z		collide(gjk.SearchOrigin());
+results.gjk_iterations	=	static_cast<int>(gjk.iterations+1);
+if(collide)
+	{
+	/* Then EPA for penetration depth	*/
+	EPA			epa(&gjk);
+	const F		pd(epa.EvaluatePD());
+	results.epa_iterations	=	static_cast<int>(epa.iterations+1);
+	if(pd>0)
+		{
+		results.status			=	sResults::Penetrating;
+		results.normal			=	epa.normal;
+		results.depth			=	pd;
+		results.witnesses[0]	=	epa.nearest[0];
+		results.witnesses[1]	=	epa.nearest[1];
+		return(true);
+		} else { if(epa.failed) results.status=sResults::EPA_Failed; }
+	} else { if(gjk.failed) results.status=sResults::GJK_Failed; }
+return(false);
+}
+
+
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa.h	(revision 2122)
@@ -0,0 +1,53 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+GJK-EPA collision solver by Nathanael Presson
+Nov.2006
+*/
+
+
+#ifndef _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
+#define _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+
+class btStackAlloc;
+
+///btGjkEpaSolver contributed under zlib by Nathanael Presson
+struct	btGjkEpaSolver
+{
+struct	sResults
+	{
+	enum eStatus
+		{
+		Separated,		/* Shapes doesnt penetrate												*/ 
+		Penetrating,	/* Shapes are penetrating												*/ 
+		GJK_Failed,		/* GJK phase fail, no big issue, shapes are probably just 'touching'	*/ 
+		EPA_Failed		/* EPA phase fail, bigger problem, need to save parameters, and debug	*/ 
+		}		status;
+	btVector3	witnesses[2];
+	btVector3	normal;
+	btScalar	depth;
+	int	epa_iterations;
+	int	gjk_iterations;
+	};
+static bool	Collide(const btConvexShape* shape0,const btTransform& wtrs0,
+					const btConvexShape* shape1,const btTransform& wtrs1,
+					btScalar	radialmargin,
+					btStackAlloc* stackAlloc,
+					sResults&	results);
+};
+
+#endif
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp	(revision 2122)
@@ -0,0 +1,943 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the
+use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software in a
+product, an acknowledgment in the product documentation would be appreciated
+but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+GJK-EPA collision solver by Nathanael Presson, 2008
+*/
+#include "BulletCollision/CollisionShapes/btConvexInternalShape.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "btGjkEpa2.h"
+
+#if defined(DEBUG) || defined (_DEBUG)
+#include <stdio.h> //for debug printf
+#ifdef __SPU__
+#include <spu_printf.h>
+#define printf spu_printf
+#endif //__SPU__
+#endif
+
+namespace gjkepa2_impl
+{
+
+// Config
+
+	/* GJK	*/ 
+#define GJK_MAX_ITERATIONS	128
+#define GJK_ACCURARY		((btScalar)0.0001)
+#define GJK_MIN_DISTANCE	((btScalar)0.0001)
+#define GJK_DUPLICATED_EPS	((btScalar)0.0001)
+#define GJK_SIMPLEX2_EPS	((btScalar)0.0)
+#define GJK_SIMPLEX3_EPS	((btScalar)0.0)
+#define GJK_SIMPLEX4_EPS	((btScalar)0.0)
+
+	/* EPA	*/ 
+#define EPA_MAX_VERTICES	64
+#define EPA_MAX_FACES		(EPA_MAX_VERTICES*2)
+#define EPA_MAX_ITERATIONS	255
+#define EPA_ACCURACY		((btScalar)0.0001)
+#define EPA_FALLBACK		(10*EPA_ACCURACY)
+#define EPA_PLANE_EPS		((btScalar)0.00001)
+#define EPA_INSIDE_EPS		((btScalar)0.01)
+
+
+// Shorthands
+typedef unsigned int	U;
+typedef unsigned char	U1;
+
+// MinkowskiDiff
+struct	MinkowskiDiff
+	{
+	const btConvexShape*	m_shapes[2];
+	btMatrix3x3				m_toshape1;
+	btTransform				m_toshape0;
+	btVector3				(btConvexShape::*Ls)(const btVector3&) const;
+	void					EnableMargin(bool enable)
+		{
+		if(enable)
+			Ls=&btConvexShape::localGetSupportVertexNonVirtual;
+			else
+			Ls=&btConvexShape::localGetSupportVertexWithoutMarginNonVirtual;
+		}	
+	inline btVector3		Support0(const btVector3& d) const
+		{
+		return(((m_shapes[0])->*(Ls))(d));
+		}
+	inline btVector3		Support1(const btVector3& d) const
+		{
+		return(m_toshape0*((m_shapes[1])->*(Ls))(m_toshape1*d));
+		}
+	inline btVector3		Support(const btVector3& d) const
+		{
+		return(Support0(d)-Support1(-d));
+		}
+	btVector3				Support(const btVector3& d,U index) const
+		{
+		if(index)
+			return(Support1(d));
+			else
+			return(Support0(d));
+		}
+	};
+
+typedef	MinkowskiDiff	tShape;
+
+
+// GJK
+struct	GJK
+{
+/* Types		*/ 
+struct	sSV
+	{
+	btVector3	d,w;
+	};
+struct	sSimplex
+	{
+	sSV*		c[4];
+	btScalar	p[4];
+	U			rank;
+	};
+struct	eStatus	{ enum _ {
+	Valid,
+	Inside,
+	Failed		};};
+/* Fields		*/ 
+tShape			m_shape;
+btVector3		m_ray;
+btScalar		m_distance;
+sSimplex		m_simplices[2];
+sSV				m_store[4];
+sSV*			m_free[4];
+U				m_nfree;
+U				m_current;
+sSimplex*		m_simplex;
+eStatus::_		m_status;
+/* Methods		*/ 
+					GJK()
+	{
+	Initialize();
+	}
+void				Initialize()
+	{
+	m_ray		=	btVector3(0,0,0);
+	m_nfree		=	0;
+	m_status	=	eStatus::Failed;
+	m_current	=	0;
+	m_distance	=	0;
+	}
+eStatus::_			Evaluate(const tShape& shapearg,const btVector3& guess)
+	{
+	U			iterations=0;
+	btScalar	sqdist=0;
+	btScalar	alpha=0;
+	btVector3	lastw[4];
+	U			clastw=0;
+	/* Initialize solver		*/ 
+	m_free[0]			=	&m_store[0];
+	m_free[1]			=	&m_store[1];
+	m_free[2]			=	&m_store[2];
+	m_free[3]			=	&m_store[3];
+	m_nfree				=	4;
+	m_current			=	0;
+	m_status			=	eStatus::Valid;
+	m_shape				=	shapearg;
+	m_distance			=	0;
+	/* Initialize simplex		*/ 
+	m_simplices[0].rank	=	0;
+	m_ray				=	guess;
+	const btScalar	sqrl=	m_ray.length2();
+	appendvertice(m_simplices[0],sqrl>0?-m_ray:btVector3(1,0,0));
+	m_simplices[0].p[0]	=	1;
+	m_ray				=	m_simplices[0].c[0]->w;	
+	sqdist				=	sqrl;
+	lastw[0]			=
+	lastw[1]			=
+	lastw[2]			=
+	lastw[3]			=	m_ray;
+	/* Loop						*/ 
+	do	{
+		const U		next=1-m_current;
+		sSimplex&	cs=m_simplices[m_current];
+		sSimplex&	ns=m_simplices[next];
+		/* Check zero							*/ 
+		const btScalar	rl=m_ray.length();
+		if(rl<GJK_MIN_DISTANCE)
+			{/* Touching or inside				*/ 
+			m_status=eStatus::Inside;
+			break;
+			}
+		/* Append new vertice in -'v' direction	*/ 
+		appendvertice(cs,-m_ray);
+		const btVector3&	w=cs.c[cs.rank-1]->w;
+		bool				found=false;
+		for(U i=0;i<4;++i)
+			{
+			if((w-lastw[i]).length2()<GJK_DUPLICATED_EPS)
+				{ found=true;break; }
+			}
+		if(found)
+			{/* Return old simplex				*/ 
+			removevertice(m_simplices[m_current]);
+			break;
+			}
+			else
+			{/* Update lastw					*/ 
+			lastw[clastw=(clastw+1)&3]=w;
+			}
+		/* Check for termination				*/ 
+		const btScalar	omega=dot(m_ray,w)/rl;
+		alpha=btMax(omega,alpha);
+		if(((rl-alpha)-(GJK_ACCURARY*rl))<=0)
+			{/* Return old simplex				*/ 
+			removevertice(m_simplices[m_current]);
+			break;
+			}		
+		/* Reduce simplex						*/ 
+		btScalar	weights[4];
+		U			mask=0;
+		switch(cs.rank)
+			{
+			case	2:	sqdist=projectorigin(	cs.c[0]->w,
+												cs.c[1]->w,
+												weights,mask);break;
+			case	3:	sqdist=projectorigin(	cs.c[0]->w,
+												cs.c[1]->w,
+												cs.c[2]->w,
+												weights,mask);break;
+			case	4:	sqdist=projectorigin(	cs.c[0]->w,
+												cs.c[1]->w,
+												cs.c[2]->w,
+												cs.c[3]->w,
+												weights,mask);break;
+			}
+		if(sqdist>=0)
+			{/* Valid	*/ 
+			ns.rank		=	0;
+			m_ray		=	btVector3(0,0,0);
+			m_current	=	next;
+			for(U i=0,ni=cs.rank;i<ni;++i)
+				{
+				if(mask&(1<<i))
+					{
+					ns.c[ns.rank]		=	cs.c[i];
+					ns.p[ns.rank++]		=	weights[i];
+					m_ray				+=	cs.c[i]->w*weights[i];
+					}
+					else
+					{
+					m_free[m_nfree++]	=	cs.c[i];
+					}
+				}
+			if(mask==15) m_status=eStatus::Inside;
+			}
+			else
+			{/* Return old simplex				*/ 
+			removevertice(m_simplices[m_current]);
+			break;
+			}
+		m_status=((++iterations)<GJK_MAX_ITERATIONS)?m_status:eStatus::Failed;
+		} while(m_status==eStatus::Valid);
+	m_simplex=&m_simplices[m_current];
+	switch(m_status)
+		{
+		case	eStatus::Valid:		m_distance=m_ray.length();break;
+		case	eStatus::Inside:	m_distance=0;break;
+		}	
+	return(m_status);
+	}
+bool					EncloseOrigin()
+	{
+	switch(m_simplex->rank)
+		{
+		case	1:
+			{
+			for(U i=0;i<3;++i)
+				{
+				btVector3		axis=btVector3(0,0,0);
+				axis[i]=1;
+				appendvertice(*m_simplex, axis);
+				if(EncloseOrigin())	return(true);
+				removevertice(*m_simplex);
+				appendvertice(*m_simplex,-axis);
+				if(EncloseOrigin())	return(true);
+				removevertice(*m_simplex);
+				}
+			}
+		break;
+		case	2:
+			{
+			const btVector3	d=m_simplex->c[1]->w-m_simplex->c[0]->w;
+			for(U i=0;i<3;++i)
+				{
+				btVector3		axis=btVector3(0,0,0);
+				axis[i]=1;
+				const btVector3	p=cross(d,axis);
+				if(p.length2()>0)
+					{
+					appendvertice(*m_simplex, p);
+					if(EncloseOrigin())	return(true);
+					removevertice(*m_simplex);
+					appendvertice(*m_simplex,-p);
+					if(EncloseOrigin())	return(true);
+					removevertice(*m_simplex);
+					}
+				}
+			}
+		break;
+		case	3:
+			{
+			const btVector3	n=cross(m_simplex->c[1]->w-m_simplex->c[0]->w,
+									m_simplex->c[2]->w-m_simplex->c[0]->w);
+			if(n.length2()>0)
+				{
+				appendvertice(*m_simplex,n);
+				if(EncloseOrigin())	return(true);
+				removevertice(*m_simplex);
+				appendvertice(*m_simplex,-n);
+				if(EncloseOrigin())	return(true);
+				removevertice(*m_simplex);
+				}
+			}
+		break;
+		case	4:
+			{
+			if(btFabs(det(	m_simplex->c[0]->w-m_simplex->c[3]->w,
+							m_simplex->c[1]->w-m_simplex->c[3]->w,
+							m_simplex->c[2]->w-m_simplex->c[3]->w))>0)
+				return(true);
+			}
+		break;
+		}
+	return(false);
+	}
+/* Internals	*/ 
+void				getsupport(const btVector3& d,sSV& sv) const
+	{
+	sv.d	=	d/d.length();
+	sv.w	=	m_shape.Support(sv.d);
+	}
+void				removevertice(sSimplex& simplex)
+	{
+	m_free[m_nfree++]=simplex.c[--simplex.rank];
+	}
+void				appendvertice(sSimplex& simplex,const btVector3& v)
+	{
+	simplex.p[simplex.rank]=0;
+	simplex.c[simplex.rank]=m_free[--m_nfree];
+	getsupport(v,*simplex.c[simplex.rank++]);
+	}
+static btScalar		det(const btVector3& a,const btVector3& b,const btVector3& c)
+	{
+	return(	a.y()*b.z()*c.x()+a.z()*b.x()*c.y()-
+			a.x()*b.z()*c.y()-a.y()*b.x()*c.z()+
+			a.x()*b.y()*c.z()-a.z()*b.y()*c.x());
+	}
+static btScalar		projectorigin(	const btVector3& a,
+									const btVector3& b,
+									btScalar* w,U& m)
+	{
+	const btVector3	d=b-a;
+	const btScalar	l=d.length2();
+	if(l>GJK_SIMPLEX2_EPS)
+		{
+		const btScalar	t(l>0?-dot(a,d)/l:0);
+		if(t>=1)		{ w[0]=0;w[1]=1;m=2;return(b.length2()); }
+		else if(t<=0)	{ w[0]=1;w[1]=0;m=1;return(a.length2()); }
+		else			{ w[0]=1-(w[1]=t);m=3;return((a+d*t).length2()); }
+		}
+	return(-1);
+	}
+static btScalar		projectorigin(	const btVector3& a,
+									const btVector3& b,
+									const btVector3& c,
+									btScalar* w,U& m)
+	{
+	static const U		imd3[]={1,2,0};
+	const btVector3*	vt[]={&a,&b,&c};
+	const btVector3		dl[]={a-b,b-c,c-a};
+	const btVector3		n=cross(dl[0],dl[1]);
+	const btScalar		l=n.length2();
+	if(l>GJK_SIMPLEX3_EPS)
+		{
+		btScalar	mindist=-1;
+		btScalar	subw[2];
+		U			subm;
+		for(U i=0;i<3;++i)
+			{
+			if(dot(*vt[i],cross(dl[i],n))>0)
+				{
+				const U			j=imd3[i];
+				const btScalar	subd(projectorigin(*vt[i],*vt[j],subw,subm));
+				if((mindist<0)||(subd<mindist))
+					{
+					mindist		=	subd;
+					m			=	static_cast<U>(((subm&1)?1<<i:0)+((subm&2)?1<<j:0));
+					w[i]		=	subw[0];
+					w[j]		=	subw[1];
+					w[imd3[j]]	=	0;				
+					}
+				}
+			}
+		if(mindist<0)
+			{
+			const btScalar	d=dot(a,n);	
+			const btScalar	s=btSqrt(l);
+			const btVector3	p=n*(d/l);
+			mindist	=	p.length2();
+			m		=	7;
+			w[0]	=	(cross(dl[1],b-p)).length()/s;
+			w[1]	=	(cross(dl[2],c-p)).length()/s;
+			w[2]	=	1-(w[0]+w[1]);
+			}
+		return(mindist);
+		}
+	return(-1);
+	}
+static btScalar		projectorigin(	const btVector3& a,
+									const btVector3& b,
+									const btVector3& c,
+									const btVector3& d,
+									btScalar* w,U& m)
+	{
+	static const U		imd3[]={1,2,0};
+	const btVector3*	vt[]={&a,&b,&c,&d};
+	const btVector3		dl[]={a-d,b-d,c-d};
+	const btScalar		vl=det(dl[0],dl[1],dl[2]);
+	const bool			ng=(vl*dot(a,cross(b-c,a-b)))<=0;
+	if(ng&&(btFabs(vl)>GJK_SIMPLEX4_EPS))
+		{
+		btScalar	mindist=-1;
+		btScalar	subw[3];
+		U			subm;
+		for(U i=0;i<3;++i)
+			{
+			const U			j=imd3[i];
+			const btScalar	s=vl*dot(d,cross(dl[i],dl[j]));
+			if(s>0)
+				{
+				const btScalar	subd=projectorigin(*vt[i],*vt[j],d,subw,subm);
+				if((mindist<0)||(subd<mindist))
+					{
+					mindist		=	subd;
+					m			=	static_cast<U>((subm&1?1<<i:0)+
+									(subm&2?1<<j:0)+
+									(subm&4?8:0));
+					w[i]		=	subw[0];
+					w[j]		=	subw[1];
+					w[imd3[j]]	=	0;
+					w[3]		=	subw[2];
+					}
+				}
+			}
+		if(mindist<0)
+			{
+			mindist	=	0;
+			m		=	15;
+			w[0]	=	det(c,b,d)/vl;
+			w[1]	=	det(a,c,d)/vl;
+			w[2]	=	det(b,a,d)/vl;
+			w[3]	=	1-(w[0]+w[1]+w[2]);
+			}
+		return(mindist);
+		}
+	return(-1);
+	}
+};
+
+// EPA
+struct	EPA
+{
+/* Types		*/ 
+typedef	GJK::sSV	sSV;
+struct	sFace
+	{
+	btVector3	n;
+	btScalar	d;
+	btScalar	p;
+	sSV*		c[3];
+	sFace*		f[3];
+	sFace*		l[2];
+	U1			e[3];
+	U1			pass;
+	};
+struct	sList
+	{
+	sFace*		root;
+	U			count;
+				sList() : root(0),count(0)	{}
+	};
+struct	sHorizon
+	{
+	sFace*		cf;
+	sFace*		ff;
+	U			nf;
+				sHorizon() : cf(0),ff(0),nf(0)	{}
+	};
+struct	eStatus { enum _ {
+	Valid,
+	Touching,
+	Degenerated,
+	NonConvex,
+	InvalidHull,		
+	OutOfFaces,
+	OutOfVertices,
+	AccuraryReached,
+	FallBack,
+	Failed		};};
+/* Fields		*/ 
+eStatus::_		m_status;
+GJK::sSimplex	m_result;
+btVector3		m_normal;
+btScalar		m_depth;
+sSV				m_sv_store[EPA_MAX_VERTICES];
+sFace			m_fc_store[EPA_MAX_FACES];
+U				m_nextsv;
+sList			m_hull;
+sList			m_stock;
+/* Methods		*/ 
+					EPA()
+	{
+	Initialize();	
+	}
+
+
+					static inline void		bind(sFace* fa,U ea,sFace* fb,U eb)
+	{
+	fa->e[ea]=(U1)eb;fa->f[ea]=fb;
+	fb->e[eb]=(U1)ea;fb->f[eb]=fa;
+	}
+static inline void		append(sList& list,sFace* face)
+	{
+	face->l[0]	=	0;
+	face->l[1]	=	list.root;
+	if(list.root) list.root->l[0]=face;
+	list.root	=	face;
+	++list.count;
+	}
+static inline void		remove(sList& list,sFace* face)
+	{
+	if(face->l[1]) face->l[1]->l[0]=face->l[0];
+	if(face->l[0]) face->l[0]->l[1]=face->l[1];
+	if(face==list.root) list.root=face->l[1];
+	--list.count;
+	}
+
+
+void				Initialize()
+	{
+	m_status	=	eStatus::Failed;
+	m_normal	=	btVector3(0,0,0);
+	m_depth		=	0;
+	m_nextsv	=	0;
+	for(U i=0;i<EPA_MAX_FACES;++i)
+		{
+		append(m_stock,&m_fc_store[EPA_MAX_FACES-i-1]);
+		}
+	}
+eStatus::_			Evaluate(GJK& gjk,const btVector3& guess)
+	{
+	GJK::sSimplex&	simplex=*gjk.m_simplex;
+	if((simplex.rank>1)&&gjk.EncloseOrigin())
+		{
+
+		/* Clean up				*/ 
+		while(m_hull.root)
+			{
+			sFace*	f = m_hull.root;
+			remove(m_hull,f);
+			append(m_stock,f);
+			}
+		m_status	=	eStatus::Valid;
+		m_nextsv	=	0;
+		/* Orient simplex		*/ 
+		if(gjk.det(	simplex.c[0]->w-simplex.c[3]->w,
+					simplex.c[1]->w-simplex.c[3]->w,
+					simplex.c[2]->w-simplex.c[3]->w)<0)
+			{
+			btSwap(simplex.c[0],simplex.c[1]);
+			btSwap(simplex.p[0],simplex.p[1]);
+			}
+		/* Build initial hull	*/ 
+		sFace*	tetra[]={newface(simplex.c[0],simplex.c[1],simplex.c[2],true),
+						newface(simplex.c[1],simplex.c[0],simplex.c[3],true),
+						newface(simplex.c[2],simplex.c[1],simplex.c[3],true),
+						newface(simplex.c[0],simplex.c[2],simplex.c[3],true)};
+		if(m_hull.count==4)
+			{
+			sFace*		best=findbest();
+			sFace		outer=*best;
+			U			pass=0;
+			U			iterations=0;
+			bind(tetra[0],0,tetra[1],0);
+			bind(tetra[0],1,tetra[2],0);
+			bind(tetra[0],2,tetra[3],0);
+			bind(tetra[1],1,tetra[3],2);
+			bind(tetra[1],2,tetra[2],1);
+			bind(tetra[2],2,tetra[3],1);
+			m_status=eStatus::Valid;
+			for(;iterations<EPA_MAX_ITERATIONS;++iterations)
+				{
+				if(m_nextsv<EPA_MAX_VERTICES)
+					{	
+					sHorizon		horizon;
+					sSV*			w=&m_sv_store[m_nextsv++];
+					bool			valid=true;					
+					best->pass	=	(U1)(++pass);
+					gjk.getsupport(best->n,*w);
+					const btScalar	wdist=dot(best->n,w->w)-best->d;
+					if(wdist>EPA_ACCURACY)
+						{
+						for(U j=0;(j<3)&&valid;++j)
+							{
+							valid&=expand(	pass,w,
+											best->f[j],best->e[j],
+											horizon);
+							}
+						if(valid&&(horizon.nf>=3))
+							{
+							bind(horizon.cf,1,horizon.ff,2);
+							remove(m_hull,best);
+							append(m_stock,best);
+							best=findbest();
+							if(best->p>=outer.p) outer=*best;
+							} else { m_status=eStatus::InvalidHull;break; }
+						} else { m_status=eStatus::AccuraryReached;break; }
+					} else { m_status=eStatus::OutOfVertices;break; }
+				}
+			const btVector3	projection=outer.n*outer.d;
+			m_normal	=	outer.n;
+			m_depth		=	outer.d;
+			m_result.rank	=	3;
+			m_result.c[0]	=	outer.c[0];
+			m_result.c[1]	=	outer.c[1];
+			m_result.c[2]	=	outer.c[2];
+			m_result.p[0]	=	cross(	outer.c[1]->w-projection,
+										outer.c[2]->w-projection).length();
+			m_result.p[1]	=	cross(	outer.c[2]->w-projection,
+										outer.c[0]->w-projection).length();
+			m_result.p[2]	=	cross(	outer.c[0]->w-projection,
+										outer.c[1]->w-projection).length();
+			const btScalar	sum=m_result.p[0]+m_result.p[1]+m_result.p[2];
+			m_result.p[0]	/=	sum;
+			m_result.p[1]	/=	sum;
+			m_result.p[2]	/=	sum;
+			return(m_status);
+			}
+		}
+	/* Fallback		*/ 
+	m_status	=	eStatus::FallBack;
+	m_normal	=	-guess;
+	const btScalar	nl=m_normal.length();
+	if(nl>0)
+		m_normal	=	m_normal/nl;
+		else
+		m_normal	=	btVector3(1,0,0);
+	m_depth	=	0;
+	m_result.rank=1;
+	m_result.c[0]=simplex.c[0];
+	m_result.p[0]=1;	
+	return(m_status);
+	}
+sFace*				newface(sSV* a,sSV* b,sSV* c,bool forced)
+	{
+	if(m_stock.root)
+		{
+		sFace*	face=m_stock.root;
+		remove(m_stock,face);
+		append(m_hull,face);
+		face->pass	=	0;
+		face->c[0]	=	a;
+		face->c[1]	=	b;
+		face->c[2]	=	c;
+		face->n		=	cross(b->w-a->w,c->w-a->w);
+		const btScalar	l=face->n.length();
+		const bool		v=l>EPA_ACCURACY;
+		face->p		=	btMin(btMin(
+							dot(a->w,cross(face->n,a->w-b->w)),
+							dot(b->w,cross(face->n,b->w-c->w))),
+							dot(c->w,cross(face->n,c->w-a->w)))	/
+							(v?l:1);
+		face->p		=	face->p>=-EPA_INSIDE_EPS?0:face->p;
+		if(v)
+			{
+			face->d		=	dot(a->w,face->n)/l;
+			face->n		/=	l;
+			if(forced||(face->d>=-EPA_PLANE_EPS))
+				{
+				return(face);
+				} else m_status=eStatus::NonConvex;
+			} else m_status=eStatus::Degenerated;
+		remove(m_hull,face);
+		append(m_stock,face);
+		return(0);
+		}
+	m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces;
+	return(0);
+	}
+sFace*				findbest()
+	{
+	sFace*		minf=m_hull.root;
+	btScalar	mind=minf->d*minf->d;
+	btScalar	maxp=minf->p;
+	for(sFace* f=minf->l[1];f;f=f->l[1])
+		{
+		const btScalar	sqd=f->d*f->d;
+		if((f->p>=maxp)&&(sqd<mind))
+			{
+			minf=f;
+			mind=sqd;
+			maxp=f->p;
+			}
+		}
+	return(minf);
+	}
+bool				expand(U pass,sSV* w,sFace* f,U e,sHorizon& horizon)
+	{
+	static const U	i1m3[]={1,2,0};
+	static const U	i2m3[]={2,0,1};
+	if(f->pass!=pass)
+		{
+		const U	e1=i1m3[e];
+		if((dot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)
+			{
+			sFace*	nf=newface(f->c[e1],f->c[e],w,false);
+			if(nf)
+				{
+				bind(nf,0,f,e);
+				if(horizon.cf) bind(horizon.cf,1,nf,2); else horizon.ff=nf;
+				horizon.cf=nf;
+				++horizon.nf;
+				return(true);
+				}
+			}
+			else
+			{
+			const U	e2=i2m3[e];
+			f->pass		=	(U1)pass;
+			if(	expand(pass,w,f->f[e1],f->e[e1],horizon)&&
+				expand(pass,w,f->f[e2],f->e[e2],horizon))
+				{
+				remove(m_hull,f);
+				append(m_stock,f);
+				return(true);
+				}
+			}
+		}
+	return(false);
+	}
+
+};
+
+//
+static void	Initialize(	const btConvexShape* shape0,const btTransform& wtrs0,
+						const btConvexShape* shape1,const btTransform& wtrs1,
+						btGjkEpaSolver2::sResults& results,
+						tShape& shape,
+						bool withmargins)
+{
+/* Results		*/ 
+results.witnesses[0]	=
+results.witnesses[1]	=	btVector3(0,0,0);
+results.status			=	btGjkEpaSolver2::sResults::Separated;
+/* Shape		*/ 
+shape.m_shapes[0]		=	shape0;
+shape.m_shapes[1]		=	shape1;
+shape.m_toshape1		=	wtrs1.getBasis().transposeTimes(wtrs0.getBasis());
+shape.m_toshape0		=	wtrs0.inverseTimes(wtrs1);
+shape.EnableMargin(withmargins);
+}
+
+}
+
+//
+// Api
+//
+
+using namespace	gjkepa2_impl;
+
+//
+int			btGjkEpaSolver2::StackSizeRequirement()
+{
+return(sizeof(GJK)+sizeof(EPA));
+}
+
+//
+bool		btGjkEpaSolver2::Distance(	const btConvexShape*	shape0,
+										const btTransform&		wtrs0,
+										const btConvexShape*	shape1,
+										const btTransform&		wtrs1,
+										const btVector3&		guess,
+										sResults&				results)
+{
+tShape			shape;
+Initialize(shape0,wtrs0,shape1,wtrs1,results,shape,false);
+GJK				gjk;
+GJK::eStatus::_	gjk_status=gjk.Evaluate(shape,guess);
+if(gjk_status==GJK::eStatus::Valid)
+	{
+	btVector3	w0=btVector3(0,0,0);
+	btVector3	w1=btVector3(0,0,0);
+	for(U i=0;i<gjk.m_simplex->rank;++i)
+		{
+		const btScalar	p=gjk.m_simplex->p[i];
+		w0+=shape.Support( gjk.m_simplex->c[i]->d,0)*p;
+		w1+=shape.Support(-gjk.m_simplex->c[i]->d,1)*p;
+		}
+	results.witnesses[0]	=	wtrs0*w0;
+	results.witnesses[1]	=	wtrs0*w1;
+	results.normal			=	w0-w1;
+	results.distance		=	results.normal.length();
+	results.normal			/=	results.distance>GJK_MIN_DISTANCE?results.distance:1;
+	return(true);
+	}
+	else
+	{
+	results.status	=	gjk_status==GJK::eStatus::Inside?
+							sResults::Penetrating	:
+							sResults::GJK_Failed	;
+	return(false);
+	}
+}
+
+//
+bool	btGjkEpaSolver2::Penetration(	const btConvexShape*	shape0,
+										const btTransform&		wtrs0,
+										const btConvexShape*	shape1,
+										const btTransform&		wtrs1,
+										const btVector3&		guess,
+										sResults&				results,
+										bool					usemargins)
+{
+tShape			shape;
+Initialize(shape0,wtrs0,shape1,wtrs1,results,shape,usemargins);
+GJK				gjk;	
+GJK::eStatus::_	gjk_status=gjk.Evaluate(shape,-guess);
+switch(gjk_status)
+	{
+	case	GJK::eStatus::Inside:
+		{
+		EPA				epa;
+		EPA::eStatus::_	epa_status=epa.Evaluate(gjk,-guess);
+		if(epa_status!=EPA::eStatus::Failed)
+			{
+			btVector3	w0=btVector3(0,0,0);
+			for(U i=0;i<epa.m_result.rank;++i)
+				{
+				w0+=shape.Support(epa.m_result.c[i]->d,0)*epa.m_result.p[i];
+				}
+			results.status			=	sResults::Penetrating;
+			results.witnesses[0]	=	wtrs0*w0;
+			results.witnesses[1]	=	wtrs0*(w0-epa.m_normal*epa.m_depth);
+			results.normal			=	-epa.m_normal;
+			results.distance		=	-epa.m_depth;
+			return(true);
+			} else results.status=sResults::EPA_Failed;
+		}
+	break;
+	case	GJK::eStatus::Failed:
+	results.status=sResults::GJK_Failed;
+	break;
+	}
+return(false);
+}
+
+//
+btScalar	btGjkEpaSolver2::SignedDistance(const btVector3& position,
+											btScalar margin,
+											const btConvexShape* shape0,
+											const btTransform& wtrs0,
+											sResults& results)
+{
+tShape			shape;
+btSphereShape	shape1(margin);
+btTransform		wtrs1(btQuaternion(0,0,0,1),position);
+Initialize(shape0,wtrs0,&shape1,wtrs1,results,shape,false);
+GJK				gjk;	
+GJK::eStatus::_	gjk_status=gjk.Evaluate(shape,btVector3(1,1,1));
+if(gjk_status==GJK::eStatus::Valid)
+	{
+	btVector3	w0=btVector3(0,0,0);
+	btVector3	w1=btVector3(0,0,0);
+	for(U i=0;i<gjk.m_simplex->rank;++i)
+		{
+		const btScalar	p=gjk.m_simplex->p[i];
+		w0+=shape.Support( gjk.m_simplex->c[i]->d,0)*p;
+		w1+=shape.Support(-gjk.m_simplex->c[i]->d,1)*p;
+		}
+	results.witnesses[0]	=	wtrs0*w0;
+	results.witnesses[1]	=	wtrs0*w1;
+	const btVector3	delta=	results.witnesses[1]-
+							results.witnesses[0];
+	const btScalar	margin=	shape0->getMargin()+
+							shape1.getMargin();
+	const btScalar	length=	delta.length();	
+	results.normal			=	delta/length;
+	results.witnesses[0]	+=	results.normal*margin;
+	return(length-margin);
+	}
+	else
+	{
+	if(gjk_status==GJK::eStatus::Inside)
+		{
+		if(Penetration(shape0,wtrs0,&shape1,wtrs1,gjk.m_ray,results))
+			{
+			const btVector3	delta=	results.witnesses[0]-
+									results.witnesses[1];
+			const btScalar	length=	delta.length();
+			if (length >= SIMD_EPSILON)
+				results.normal	=	delta/length;			
+			return(-length);
+			}
+		}	
+	}
+return(SIMD_INFINITY);
+}
+
+//
+bool	btGjkEpaSolver2::SignedDistance(const btConvexShape*	shape0,
+										const btTransform&		wtrs0,
+										const btConvexShape*	shape1,
+										const btTransform&		wtrs1,
+										const btVector3&		guess,
+										sResults&				results)
+{
+if(!Distance(shape0,wtrs0,shape1,wtrs1,guess,results))
+	return(Penetration(shape0,wtrs0,shape1,wtrs1,guess,results,false));
+	else
+	return(true);
+}
+
+/* Symbols cleanup		*/ 
+
+#undef GJK_MAX_ITERATIONS
+#undef GJK_ACCURARY
+#undef GJK_MIN_DISTANCE
+#undef GJK_DUPLICATED_EPS
+#undef GJK_SIMPLEX2_EPS
+#undef GJK_SIMPLEX3_EPS
+#undef GJK_SIMPLEX4_EPS
+
+#undef EPA_MAX_VERTICES
+#undef EPA_MAX_FACES
+#undef EPA_MAX_ITERATIONS
+#undef EPA_ACCURACY
+#undef EPA_FALLBACK
+#undef EPA_PLANE_EPS
+#undef EPA_INSIDE_EPS
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h	(revision 2122)
@@ -0,0 +1,71 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the
+use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software in a
+product, an acknowledgment in the product documentation would be appreciated
+but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+GJK-EPA collision solver by Nathanael Presson, 2008
+*/
+#ifndef _68DA1F85_90B7_4bb0_A705_83B4040A75C6_
+#define _68DA1F85_90B7_4bb0_A705_83B4040A75C6_
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+
+///btGjkEpaSolver contributed under zlib by Nathanael Presson
+struct	btGjkEpaSolver2
+{
+struct	sResults
+	{
+	enum eStatus
+		{
+		Separated,		/* Shapes doesnt penetrate												*/ 
+		Penetrating,	/* Shapes are penetrating												*/ 
+		GJK_Failed,		/* GJK phase fail, no big issue, shapes are probably just 'touching'	*/ 
+		EPA_Failed		/* EPA phase fail, bigger problem, need to save parameters, and debug	*/ 
+		}		status;
+	btVector3	witnesses[2];
+	btVector3	normal;
+	btScalar	distance;
+	};
+
+static int		StackSizeRequirement();
+
+static bool		Distance(	const btConvexShape* shape0,const btTransform& wtrs0,
+							const btConvexShape* shape1,const btTransform& wtrs1,
+							const btVector3& guess,
+							sResults& results);
+
+static bool		Penetration(const btConvexShape* shape0,const btTransform& wtrs0,
+							const btConvexShape* shape1,const btTransform& wtrs1,
+							const btVector3& guess,
+							sResults& results,
+							bool usemargins=true);
+
+static btScalar	SignedDistance(	const btVector3& position,
+								btScalar margin,
+								const btConvexShape* shape,
+								const btTransform& wtrs,
+								sResults& results);
+							
+static bool		SignedDistance(	const btConvexShape* shape0,const btTransform& wtrs0,
+								const btConvexShape* shape1,const btTransform& wtrs1,
+								const btVector3& guess,
+								sResults& results);
+};
+
+#endif
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+EPA Copyright (c) Ricardo Padrela 2006
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "btGjkEpaPenetrationDepthSolver.h"
+
+#ifndef __SPU__
+//#define USE_ORIGINAL_GJK 1
+#endif
+
+#ifdef USE_ORIGINAL_GJK
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
+#endif
+
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
+
+bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver,
+											  const btConvexShape* pConvexA, const btConvexShape* pConvexB,
+											  const btTransform& transformA, const btTransform& transformB,
+											  btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
+											  class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc )
+{
+
+	(void)debugDraw;
+	(void)v;
+	(void)simplexSolver;
+
+	const btScalar				radialmargin(btScalar(0.));
+	
+//#define USE_ORIGINAL_GJK 1
+#ifdef USE_ORIGINAL_GJK
+	btGjkEpaSolver::sResults	results;
+	if(btGjkEpaSolver::Collide(	pConvexA,transformA,
+								pConvexB,transformB,
+								radialmargin,stackAlloc,results))
+#else
+	btVector3	guessVector(transformA.getOrigin()-transformB.getOrigin());
+	btGjkEpaSolver2::sResults	results;
+	if(btGjkEpaSolver2::Penetration(pConvexA,transformA,
+								pConvexB,transformB,
+								guessVector,results))
+	
+#endif
+		{
+	//	debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
+		//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
+		wWitnessOnA = results.witnesses[0];
+		wWitnessOnB = results.witnesses[1];
+		return true;		
+		}
+
+	return false;
+}
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h	(revision 2122)
@@ -0,0 +1,39 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+EPA Copyright (c) Ricardo Padrela 2006 
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef BT_GJP_EPA_PENETRATION_DEPTH_H
+#define BT_GJP_EPA_PENETRATION_DEPTH_H
+
+#include "btConvexPenetrationDepthSolver.h"
+
+///EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to
+///calculate the penetration depth between two convex shapes.
+class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
+{
+	public :
+
+		bool			calcPenDepth( btSimplexSolverInterface& simplexSolver,
+									  const btConvexShape* pConvexA, const btConvexShape* pConvexB,
+									  const btTransform& transformA, const btTransform& transformB,
+									  btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
+									  class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
+
+	private :
+
+};
+
+#endif	// BT_GJP_EPA_PENETRATION_DEPTH_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp	(revision 2122)
@@ -0,0 +1,351 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btGjkPairDetector.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
+#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
+
+
+
+#if defined(DEBUG) || defined (_DEBUG)
+#define TEST_NON_VIRTUAL 1
+#include <stdio.h> //for debug printf
+#ifdef __SPU__
+#include <spu_printf.h>
+#define printf spu_printf
+//#define DEBUG_SPU_COLLISION_DETECTION 1
+#endif //__SPU__
+#endif
+
+//must be above the machine epsilon
+#define REL_ERROR2 btScalar(1.0e-6)
+
+//temp globals, to improve GJK/EPA/penetration calculations
+int gNumDeepPenetrationChecks = 0;
+int gNumGjkChecks = 0;
+
+
+
+btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver*	penetrationDepthSolver)
+:m_cachedSeparatingAxis(btScalar(0.),btScalar(0.),btScalar(1.)),
+m_penetrationDepthSolver(penetrationDepthSolver),
+m_simplexSolver(simplexSolver),
+m_minkowskiA(objectA),
+m_minkowskiB(objectB),
+m_ignoreMargin(false),
+m_lastUsedMethod(-1),
+m_catchDegeneracies(1)
+{
+}
+
+void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults)
+{
+	btScalar distance=btScalar(0.);
+	btVector3	normalInB(btScalar(0.),btScalar(0.),btScalar(0.));
+	btVector3 pointOnA,pointOnB;
+	btTransform	localTransA = input.m_transformA;
+	btTransform localTransB = input.m_transformB;
+	btVector3 positionOffset = (localTransA.getOrigin() + localTransB.getOrigin()) * btScalar(0.5);
+	localTransA.getOrigin() -= positionOffset;
+	localTransB.getOrigin() -= positionOffset;
+
+
+	btScalar marginA = m_minkowskiA->getMarginNonVirtual();
+	btScalar marginB = m_minkowskiB->getMarginNonVirtual();
+
+#ifdef TEST_NON_VIRTUAL
+	btScalar marginAv = m_minkowskiA->getMargin();
+	btScalar marginBv = m_minkowskiB->getMargin();
+
+	btAssert(marginA == marginAv);
+	btAssert(marginB == marginBv);
+#endif //TEST_NON_VIRTUAL
+
+	gNumGjkChecks++;
+
+#ifdef DEBUG_SPU_COLLISION_DETECTION
+	spu_printf("inside gjk\n");
+#endif
+	//for CCD we don't use margins
+	if (m_ignoreMargin)
+	{
+		marginA = btScalar(0.);
+		marginB = btScalar(0.);
+#ifdef DEBUG_SPU_COLLISION_DETECTION
+		spu_printf("ignoring margin\n");
+#endif
+	}
+
+	m_curIter = 0;
+	int gGjkMaxIter = 1000;//this is to catch invalid input, perhaps check for #NaN?
+	m_cachedSeparatingAxis.setValue(0,1,0);
+
+	bool isValid = false;
+	bool checkSimplex = false;
+	bool checkPenetration = true;
+	m_degenerateSimplex = 0;
+
+	m_lastUsedMethod = -1;
+
+	{
+		btScalar squaredDistance = SIMD_INFINITY;
+		btScalar delta = btScalar(0.);
+		
+		btScalar margin = marginA + marginB;
+		
+		
+
+		m_simplexSolver->reset();
+		
+		for ( ; ; )
+		//while (true)
+		{
+
+			btVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis();
+			btVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis();
+
+#ifdef TEST_NON_VIRTUAL
+			btVector3 pInAv = m_minkowskiA->localGetSupportingVertexWithoutMargin(seperatingAxisInA);
+			btVector3 qInBv = m_minkowskiB->localGetSupportingVertexWithoutMargin(seperatingAxisInB);
+#endif 
+			btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA);
+			btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB);
+#ifdef TEST_NON_VIRTUAL
+			btAssert((pInAv-pInA).length() < 0.0001);
+			btAssert((qInBv-qInB).length() < 0.0001);
+#endif //
+
+			btPoint3  pWorld = localTransA(pInA);	
+			btPoint3  qWorld = localTransB(qInB);
+
+#ifdef DEBUG_SPU_COLLISION_DETECTION
+		spu_printf("got local supporting vertices\n");
+#endif
+
+			btVector3 w	= pWorld - qWorld;
+			delta = m_cachedSeparatingAxis.dot(w);
+
+			// potential exit, they don't overlap
+			if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) 
+			{
+				checkPenetration = false;
+				break;
+			}
+
+			//exit 0: the new point is already in the simplex, or we didn't come any closer
+			if (m_simplexSolver->inSimplex(w))
+			{
+				m_degenerateSimplex = 1;
+				checkSimplex = true;
+				break;
+			}
+			// are we getting any closer ?
+			btScalar f0 = squaredDistance - delta;
+			btScalar f1 = squaredDistance * REL_ERROR2;
+
+			if (f0 <= f1)
+			{
+				if (f0 <= btScalar(0.))
+				{
+					m_degenerateSimplex = 2;
+				}
+				checkSimplex = true;
+				break;
+			}
+
+#ifdef DEBUG_SPU_COLLISION_DETECTION
+		spu_printf("addVertex 1\n");
+#endif
+			//add current vertex to simplex
+			m_simplexSolver->addVertex(w, pWorld, qWorld);
+#ifdef DEBUG_SPU_COLLISION_DETECTION
+		spu_printf("addVertex 2\n");
+#endif
+			//calculate the closest point to the origin (update vector v)
+			if (!m_simplexSolver->closest(m_cachedSeparatingAxis))
+			{
+				m_degenerateSimplex = 3;
+				checkSimplex = true;
+				break;
+			}
+
+			if(m_cachedSeparatingAxis.length2()<REL_ERROR2)
+            {
+                m_degenerateSimplex = 6;
+                checkSimplex = true;
+                break;
+            }
+
+			btScalar previousSquaredDistance = squaredDistance;
+			squaredDistance = m_cachedSeparatingAxis.length2();
+			
+			//redundant m_simplexSolver->compute_points(pointOnA, pointOnB);
+
+			//are we getting any closer ?
+			if (previousSquaredDistance - squaredDistance <= SIMD_EPSILON * previousSquaredDistance) 
+			{ 
+				m_simplexSolver->backup_closest(m_cachedSeparatingAxis);
+				checkSimplex = true;
+				break;
+			}
+
+			  //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject   
+              if (m_curIter++ > gGjkMaxIter)   
+              {   
+                      #if defined(DEBUG) || defined (_DEBUG) || defined (DEBUG_SPU_COLLISION_DETECTION)
+
+                              printf("btGjkPairDetector maxIter exceeded:%i\n",m_curIter);   
+                              printf("sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n",   
+                              m_cachedSeparatingAxis.getX(),   
+                              m_cachedSeparatingAxis.getY(),   
+                              m_cachedSeparatingAxis.getZ(),   
+                              squaredDistance,   
+                              m_minkowskiA->getShapeType(),   
+                              m_minkowskiB->getShapeType());   
+
+                      #endif   
+                      break;   
+
+              } 
+
+
+			bool check = (!m_simplexSolver->fullSimplex());
+			//bool check = (!m_simplexSolver->fullSimplex() && squaredDistance > SIMD_EPSILON * m_simplexSolver->maxVertex());
+
+			if (!check)
+			{
+				//do we need this backup_closest here ?
+				m_simplexSolver->backup_closest(m_cachedSeparatingAxis);
+				break;
+			}
+		}
+
+		if (checkSimplex)
+		{
+			m_simplexSolver->compute_points(pointOnA, pointOnB);
+			normalInB = pointOnA-pointOnB;
+			btScalar lenSqr = m_cachedSeparatingAxis.length2();
+			//valid normal
+			if (lenSqr < 0.0001)
+			{
+				m_degenerateSimplex = 5;
+			} 
+			if (lenSqr > SIMD_EPSILON*SIMD_EPSILON)
+			{
+				btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+				normalInB *= rlen; //normalize
+				btScalar s = btSqrt(squaredDistance);
+			
+				btAssert(s > btScalar(0.0));
+				pointOnA -= m_cachedSeparatingAxis * (marginA / s);
+				pointOnB += m_cachedSeparatingAxis * (marginB / s);
+				distance = ((btScalar(1.)/rlen) - margin);
+				isValid = true;
+				
+				m_lastUsedMethod = 1;
+			} else
+			{
+				m_lastUsedMethod = 2;
+			}
+		}
+
+		bool catchDegeneratePenetrationCase = 
+			(m_catchDegeneracies && m_penetrationDepthSolver && m_degenerateSimplex && ((distance+margin) < 0.01));
+
+		//if (checkPenetration && !isValid)
+		if (checkPenetration && (!isValid || catchDegeneratePenetrationCase ))
+		{
+			//penetration case
+		
+			//if there is no way to handle penetrations, bail out
+			if (m_penetrationDepthSolver)
+			{
+				// Penetration depth case.
+				btVector3 tmpPointOnA,tmpPointOnB;
+				
+				gNumDeepPenetrationChecks++;
+
+				bool isValid2 = m_penetrationDepthSolver->calcPenDepth( 
+					*m_simplexSolver, 
+					m_minkowskiA,m_minkowskiB,
+					localTransA,localTransB,
+					m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB,
+					debugDraw,input.m_stackAlloc
+					);
+
+				if (isValid2)
+				{
+					btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA;
+					btScalar lenSqr = tmpNormalInB.length2();
+					if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON))
+					{
+						tmpNormalInB /= btSqrt(lenSqr);
+						btScalar distance2 = -(tmpPointOnA-tmpPointOnB).length();
+						//only replace valid penetrations when the result is deeper (check)
+						if (!isValid || (distance2 < distance))
+						{
+							distance = distance2;
+							pointOnA = tmpPointOnA;
+							pointOnB = tmpPointOnB;
+							normalInB = tmpNormalInB;
+							isValid = true;
+							m_lastUsedMethod = 3;
+						} else
+						{
+							
+						}
+					} else
+					{
+						//isValid = false;
+						m_lastUsedMethod = 4;
+					}
+				} else
+				{
+					m_lastUsedMethod = 5;
+				}
+				
+			}
+		}
+	}
+
+	if (isValid)
+	{
+#ifdef __SPU__
+		//spu_printf("distance\n");
+#endif //__CELLOS_LV2__
+
+
+#ifdef DEBUG_SPU_COLLISION_DETECTION
+		spu_printf("output 1\n");
+#endif
+		output.addContactPoint(
+			normalInB,
+			pointOnB+positionOffset,
+			distance);
+
+#ifdef DEBUG_SPU_COLLISION_DETECTION
+		spu_printf("output 2\n");
+#endif
+		//printf("gjk add:%f",distance);
+	}
+
+
+}
+
+
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h	(revision 2122)
@@ -0,0 +1,85 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+
+#ifndef GJK_PAIR_DETECTOR_H
+#define GJK_PAIR_DETECTOR_H
+
+#include "btDiscreteCollisionDetectorInterface.h"
+#include "LinearMath/btPoint3.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+class btConvexShape;
+#include "btSimplexSolverInterface.h"
+class btConvexPenetrationDepthSolver;
+
+/// btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface
+class btGjkPairDetector : public btDiscreteCollisionDetectorInterface
+{
+	
+
+	btVector3	m_cachedSeparatingAxis;
+	btConvexPenetrationDepthSolver*	m_penetrationDepthSolver;
+	btSimplexSolverInterface* m_simplexSolver;
+	const btConvexShape* m_minkowskiA;
+	const btConvexShape* m_minkowskiB;
+	bool		m_ignoreMargin;
+	
+
+public:
+
+	//some debugging to fix degeneracy problems
+	int			m_lastUsedMethod;
+	int			m_curIter;
+	int			m_degenerateSimplex;
+	int			m_catchDegeneracies;
+
+
+	btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver*	penetrationDepthSolver);
+	virtual ~btGjkPairDetector() {};
+
+	virtual void	getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
+
+	void setMinkowskiA(btConvexShape* minkA)
+	{
+		m_minkowskiA = minkA;
+	}
+
+	void setMinkowskiB(btConvexShape* minkB)
+	{
+		m_minkowskiB = minkB;
+	}
+	void setCachedSeperatingAxis(const btVector3& seperatingAxis)
+	{
+		m_cachedSeparatingAxis = seperatingAxis;
+	}
+
+	void	setPenetrationDepthSolver(btConvexPenetrationDepthSolver*	penetrationDepthSolver)
+	{
+		m_penetrationDepthSolver = penetrationDepthSolver;
+	}
+
+	///don't use setIgnoreMargin, it's for Bullet's internal use
+	void	setIgnoreMargin(bool ignoreMargin)
+	{
+		m_ignoreMargin = ignoreMargin;
+	}
+
+
+};
+
+#endif //GJK_PAIR_DETECTOR_H
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h	(revision 2122)
@@ -0,0 +1,117 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef MANIFOLD_CONTACT_POINT_H
+#define MANIFOLD_CONTACT_POINT_H
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransformUtil.h"
+
+
+
+
+
+/// ManifoldContactPoint collects and maintains persistent contactpoints.
+/// used to improve stability and performance of rigidbody dynamics response.
+class btManifoldPoint
+	{
+		public:
+			btManifoldPoint()
+				:m_userPersistentData(0),
+				m_appliedImpulse(0.f),
+				m_lateralFrictionInitialized(false),
+				m_lifeTime(0)
+			{
+			}
+
+			btManifoldPoint( const btVector3 &pointA, const btVector3 &pointB, 
+					const btVector3 &normal, 
+					btScalar distance ) :
+					m_localPointA( pointA ), 
+					m_localPointB( pointB ), 
+					m_normalWorldOnB( normal ), 
+					m_distance1( distance ),
+					m_combinedFriction(btScalar(0.)),
+					m_combinedRestitution(btScalar(0.)),
+					m_userPersistentData(0),
+					m_appliedImpulse(0.f),
+					m_lateralFrictionInitialized(false),
+					m_appliedImpulseLateral1(0.f),
+					m_appliedImpulseLateral2(0.f),
+					m_lifeTime(0)
+			{
+				
+					
+			}
+
+			
+
+			btVector3 m_localPointA;			
+			btVector3 m_localPointB;			
+			btVector3	m_positionWorldOnB;
+			///m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity
+			btVector3	m_positionWorldOnA;
+			btVector3 m_normalWorldOnB;
+		
+			btScalar	m_distance1;
+			btScalar	m_combinedFriction;
+			btScalar	m_combinedRestitution;
+
+         //BP mod, store contact triangles.
+         int	   m_partId0;
+         int      m_partId1;
+         int      m_index0;
+         int      m_index1;
+				
+			mutable void*	m_userPersistentData;
+			btScalar		m_appliedImpulse;
+
+			bool			m_lateralFrictionInitialized;
+			btScalar		m_appliedImpulseLateral1;
+			btScalar		m_appliedImpulseLateral2;
+			int				m_lifeTime;//lifetime of the contactpoint in frames
+			
+			btVector3		m_lateralFrictionDir1;
+			btVector3		m_lateralFrictionDir2;
+
+			btScalar getDistance() const
+			{
+				return m_distance1;
+			}
+			int	getLifeTime() const
+			{
+				return m_lifeTime;
+			}
+
+			const btVector3& getPositionWorldOnA() const {
+				return m_positionWorldOnA;
+//				return m_positionWorldOnB + m_normalWorldOnB * m_distance1;
+			}
+
+			const btVector3& getPositionWorldOnB() const
+			{
+				return m_positionWorldOnB;
+			}
+
+			void	setDistance(btScalar dist)
+			{
+				m_distance1 = dist;
+			}
+			
+			
+
+	};
+
+#endif //MANIFOLD_CONTACT_POINT_H
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp	(revision 2122)
@@ -0,0 +1,334 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btMinkowskiPenetrationDepthSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+
+#define NUM_UNITSPHERE_POINTS 42
+static btVector3	sPenetrationDirections[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] = 
+{
+btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)),
+btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)),
+btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)),
+btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)),
+btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)),
+btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)),
+btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)),
+btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)),
+btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)),
+btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)),
+btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)),
+btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)),
+btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)),
+btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)),
+btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)),
+btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)),
+btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)),
+btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)),
+btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)),
+btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)),
+btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)),
+btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)),
+btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)),
+btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)),
+btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)),
+btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)),
+btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)),
+btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)),
+btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)),
+btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)),
+btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)),
+btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)),
+btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)),
+btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)),
+btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)),
+btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)),
+btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)),
+btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)),
+btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)),
+btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)),
+btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)),
+btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))
+};
+
+
+bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& simplexSolver,
+												   const btConvexShape* convexA,const btConvexShape* convexB,
+												   const btTransform& transA,const btTransform& transB,
+												   btVector3& v, btPoint3& pa, btPoint3& pb,
+												   class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+												   )
+{
+
+	(void)stackAlloc;
+	(void)v;
+	
+
+	struct btIntermediateResult : public btDiscreteCollisionDetectorInterface::Result
+	{
+
+		btIntermediateResult():m_hasResult(false)
+		{
+		}
+		
+		btVector3 m_normalOnBInWorld;
+		btVector3 m_pointInWorld;
+		btScalar m_depth;
+		bool	m_hasResult;
+
+		virtual void setShapeIdentifiers(int partId0,int index0,	int partId1,int index1)
+		{
+			(void)partId0;
+			(void)index0;
+			(void)partId1;
+			(void)index1;
+		}
+		void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
+		{
+			m_normalOnBInWorld = normalOnBInWorld;
+			m_pointInWorld = pointInWorld;
+			m_depth = depth;
+			m_hasResult = true;
+		}
+	};
+
+	//just take fixed number of orientation, and sample the penetration depth in that direction
+	btScalar minProj = btScalar(1e30);
+	btVector3 minNorm(btScalar(0.), btScalar(0.), btScalar(0.));
+	btVector3 minA,minB;
+	btVector3 seperatingAxisInA,seperatingAxisInB;
+	btVector3 pInA,qInB,pWorld,qWorld,w;
+
+#ifndef __SPU__
+#define USE_BATCHED_SUPPORT 1
+#endif
+#ifdef USE_BATCHED_SUPPORT
+
+	btVector3	supportVerticesABatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2];
+	btVector3	supportVerticesBBatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2];
+	btVector3	seperatingAxisInABatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2];
+	btVector3	seperatingAxisInBBatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2];
+	int i;
+
+	int numSampleDirections = NUM_UNITSPHERE_POINTS;
+
+	for (i=0;i<numSampleDirections;i++)
+	{
+		const btVector3& norm = sPenetrationDirections[i];
+		seperatingAxisInABatch[i] =  (-norm) * transA.getBasis() ;
+		seperatingAxisInBBatch[i] =  norm   * transB.getBasis() ;
+	}
+
+	{
+		int numPDA = convexA->getNumPreferredPenetrationDirections();
+		if (numPDA)
+		{
+			for (int i=0;i<numPDA;i++)
+			{
+				btVector3 norm;
+				convexA->getPreferredPenetrationDirection(i,norm);
+				norm  = transA.getBasis() * norm;
+				sPenetrationDirections[numSampleDirections] = norm;
+				seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis();
+				seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis();
+				numSampleDirections++;
+			}
+		}
+	}
+
+	{
+		int numPDB = convexB->getNumPreferredPenetrationDirections();
+		if (numPDB)
+		{
+			for (int i=0;i<numPDB;i++)
+			{
+				btVector3 norm;
+				convexB->getPreferredPenetrationDirection(i,norm);
+				norm  = transB.getBasis() * norm;
+				sPenetrationDirections[numSampleDirections] = norm;
+				seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis();
+				seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis();
+				numSampleDirections++;
+			}
+		}
+	}
+
+
+
+	convexA->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInABatch,supportVerticesABatch,numSampleDirections);
+	convexB->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInBBatch,supportVerticesBBatch,numSampleDirections);
+
+	for (i=0;i<numSampleDirections;i++)
+	{
+		const btVector3& norm = sPenetrationDirections[i];
+		seperatingAxisInA = seperatingAxisInABatch[i];
+		seperatingAxisInB = seperatingAxisInBBatch[i];
+
+		pInA = supportVerticesABatch[i];
+		qInB = supportVerticesBBatch[i];
+
+		pWorld = transA(pInA);	
+		qWorld = transB(qInB);
+		w	= qWorld - pWorld;
+		btScalar delta = norm.dot(w);
+		//find smallest delta
+		if (delta < minProj)
+		{
+			minProj = delta;
+			minNorm = norm;
+			minA = pWorld;
+			minB = qWorld;
+		}
+	}	
+#else
+
+	int numSampleDirections = NUM_UNITSPHERE_POINTS;
+
+#ifndef __SPU__
+	{
+		int numPDA = convexA->getNumPreferredPenetrationDirections();
+		if (numPDA)
+		{
+			for (int i=0;i<numPDA;i++)
+			{
+				btVector3 norm;
+				convexA->getPreferredPenetrationDirection(i,norm);
+				norm  = transA.getBasis() * norm;
+				sPenetrationDirections[numSampleDirections] = norm;
+				numSampleDirections++;
+			}
+		}
+	}
+
+	{
+		int numPDB = convexB->getNumPreferredPenetrationDirections();
+		if (numPDB)
+		{
+			for (int i=0;i<numPDB;i++)
+			{
+				btVector3 norm;
+				convexB->getPreferredPenetrationDirection(i,norm);
+				norm  = transB.getBasis() * norm;
+				sPenetrationDirections[numSampleDirections] = norm;
+				numSampleDirections++;
+			}
+		}
+	}
+#endif // __SPU__
+
+	for (int i=0;i<numSampleDirections;i++)
+	{
+		const btVector3& norm = sPenetrationDirections[i];
+		seperatingAxisInA = (-norm)* transA.getBasis();
+		seperatingAxisInB = norm* transB.getBasis();
+		pInA = convexA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA);
+		qInB = convexB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB);
+		pWorld = transA(pInA);	
+		qWorld = transB(qInB);
+		w	= qWorld - pWorld;
+		btScalar delta = norm.dot(w);
+		//find smallest delta
+		if (delta < minProj)
+		{
+			minProj = delta;
+			minNorm = norm;
+			minA = pWorld;
+			minB = qWorld;
+		}
+	}
+#endif //USE_BATCHED_SUPPORT
+
+	//add the margins
+
+	minA += minNorm*convexA->getMarginNonVirtual();
+	minB -= minNorm*convexB->getMarginNonVirtual();
+	//no penetration
+	if (minProj < btScalar(0.))
+		return false;
+
+	minProj += (convexA->getMarginNonVirtual() + convexB->getMarginNonVirtual());
+
+
+
+
+
+//#define DEBUG_DRAW 1
+#ifdef DEBUG_DRAW
+	if (debugDraw)
+	{
+		btVector3 color(0,1,0);
+		debugDraw->drawLine(minA,minB,color);
+		color = btVector3 (1,1,1);
+		btVector3 vec = minB-minA;
+		btScalar prj2 = minNorm.dot(vec);
+		debugDraw->drawLine(minA,minA+(minNorm*minProj),color);
+
+	}
+#endif //DEBUG_DRAW
+
+	
+
+	btGjkPairDetector gjkdet(convexA,convexB,&simplexSolver,0);
+
+	btScalar offsetDist = minProj;
+	btVector3 offset = minNorm * offsetDist;
+	
+
+
+	btGjkPairDetector::ClosestPointInput input;
+		
+	btVector3 newOrg = transA.getOrigin() + offset;
+
+	btTransform displacedTrans = transA;
+	displacedTrans.setOrigin(newOrg);
+
+	input.m_transformA = displacedTrans;
+	input.m_transformB = transB;
+	input.m_maximumDistanceSquared = btScalar(1e30);//minProj;
+	
+	btIntermediateResult res;
+	gjkdet.getClosestPoints(input,res,debugDraw);
+
+	btScalar correctedMinNorm = minProj - res.m_depth;
+
+
+	//the penetration depth is over-estimated, relax it
+	btScalar penetration_relaxation= btScalar(1.);
+	minNorm*=penetration_relaxation;
+
+	if (res.m_hasResult)
+	{
+
+		pa = res.m_pointInWorld - minNorm * correctedMinNorm;
+		pb = res.m_pointInWorld;
+		
+#ifdef DEBUG_DRAW
+		if (debugDraw)
+		{
+			btVector3 color(1,0,0);
+			debugDraw->drawLine(pa,pb,color);
+		}
+#endif//DEBUG_DRAW
+
+
+	}
+	return res.m_hasResult;
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h	(revision 2122)
@@ -0,0 +1,36 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef MINKOWSKI_PENETRATION_DEPTH_SOLVER_H
+#define MINKOWSKI_PENETRATION_DEPTH_SOLVER_H
+
+#include "btConvexPenetrationDepthSolver.h"
+
+///MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation.
+///Implementation is based on sampling the depth using support mapping, and using GJK step to get the witness points.
+class btMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver
+{
+public:
+
+	virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
+	const btConvexShape* convexA,const btConvexShape* convexB,
+				const btTransform& transA,const btTransform& transB,
+			btVector3& v, btPoint3& pa, btPoint3& pb,
+			class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+			);
+};
+
+#endif //MINKOWSKI_PENETRATION_DEPTH_SOLVER_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp	(revision 2122)
@@ -0,0 +1,256 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btPersistentManifold.h"
+#include "LinearMath/btTransform.h"
+#include <assert.h>
+
+btScalar					gContactBreakingThreshold = btScalar(0.02);
+ContactDestroyedCallback	gContactDestroyedCallback = 0;
+ContactProcessedCallback	gContactProcessedCallback = 0;
+
+
+
+btPersistentManifold::btPersistentManifold()
+:m_body0(0),
+m_body1(0),
+m_cachedPoints (0),
+m_index1a(0)
+{
+}
+
+
+
+
+#ifdef DEBUG_PERSISTENCY
+#include <stdio.h>
+void	btPersistentManifold::DebugPersistency()
+{
+	int i;
+	printf("DebugPersistency : numPoints %d\n",m_cachedPoints);
+	for (i=0;i<m_cachedPoints;i++)
+	{
+		printf("m_pointCache[%d].m_userPersistentData = %x\n",i,m_pointCache[i].m_userPersistentData);
+	}
+}
+#endif //DEBUG_PERSISTENCY
+
+void btPersistentManifold::clearUserCache(btManifoldPoint& pt)
+{
+
+	void* oldPtr = pt.m_userPersistentData;
+	if (oldPtr)
+	{
+#ifdef DEBUG_PERSISTENCY
+		int i;
+		int occurance = 0;
+		for (i=0;i<m_cachedPoints;i++)
+		{
+			if (m_pointCache[i].m_userPersistentData == oldPtr)
+			{
+				occurance++;
+				if (occurance>1)
+					printf("error in clearUserCache\n");
+			}
+		}
+		assert(occurance<=0);
+#endif //DEBUG_PERSISTENCY
+
+		if (pt.m_userPersistentData && gContactDestroyedCallback)
+		{
+			(*gContactDestroyedCallback)(pt.m_userPersistentData);
+			pt.m_userPersistentData = 0;
+		}
+		
+#ifdef DEBUG_PERSISTENCY
+		DebugPersistency();
+#endif
+	}
+
+	
+}
+
+
+int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt) 
+{
+
+		//calculate 4 possible cases areas, and take biggest area
+		//also need to keep 'deepest'
+		
+		int maxPenetrationIndex = -1;
+#define KEEP_DEEPEST_POINT 1
+#ifdef KEEP_DEEPEST_POINT
+		btScalar maxPenetration = pt.getDistance();
+		for (int i=0;i<4;i++)
+		{
+			if (m_pointCache[i].getDistance() < maxPenetration)
+			{
+				maxPenetrationIndex = i;
+				maxPenetration = m_pointCache[i].getDistance();
+			}
+		}
+#endif //KEEP_DEEPEST_POINT
+		
+		btScalar res0(btScalar(0.)),res1(btScalar(0.)),res2(btScalar(0.)),res3(btScalar(0.));
+		if (maxPenetrationIndex != 0)
+		{
+			btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA;
+			btVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;
+			btVector3 cross = a0.cross(b0);
+			res0 = cross.length2();
+		}
+		if (maxPenetrationIndex != 1)
+		{
+			btVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA;
+			btVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;
+			btVector3 cross = a1.cross(b1);
+			res1 = cross.length2();
+		}
+
+		if (maxPenetrationIndex != 2)
+		{
+			btVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA;
+			btVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA;
+			btVector3 cross = a2.cross(b2);
+			res2 = cross.length2();
+		}
+
+		if (maxPenetrationIndex != 3)
+		{
+			btVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA;
+			btVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA;
+			btVector3 cross = a3.cross(b3);
+			res3 = cross.length2();
+		}
+
+		btVector4 maxvec(res0,res1,res2,res3);
+		int biggestarea = maxvec.closestAxis4();
+		return biggestarea;
+}
+
+
+int btPersistentManifold::getCacheEntry(const btManifoldPoint& newPoint) const
+{
+	btScalar shortestDist =  getContactBreakingThreshold() * getContactBreakingThreshold();
+	int size = getNumContacts();
+	int nearestPoint = -1;
+	for( int i = 0; i < size; i++ )
+	{
+		const btManifoldPoint &mp = m_pointCache[i];
+
+		btVector3 diffA =  mp.m_localPointA- newPoint.m_localPointA;
+		const btScalar distToManiPoint = diffA.dot(diffA);
+		if( distToManiPoint < shortestDist )
+		{
+			shortestDist = distToManiPoint;
+			nearestPoint = i;
+		}
+	}
+	return nearestPoint;
+}
+
+int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint)
+{
+	assert(validContactDistance(newPoint));
+
+	int insertIndex = getNumContacts();
+	if (insertIndex == MANIFOLD_CACHE_SIZE)
+	{
+#if MANIFOLD_CACHE_SIZE >= 4
+		//sort cache so best points come first, based on area
+		insertIndex = sortCachedPoints(newPoint);
+#else
+		insertIndex = 0;
+#endif
+		clearUserCache(m_pointCache[insertIndex]);
+		
+	} else
+	{
+		m_cachedPoints++;
+
+		
+	}
+	btAssert(m_pointCache[insertIndex].m_userPersistentData==0);
+	m_pointCache[insertIndex] = newPoint;
+	return insertIndex;
+}
+
+btScalar	btPersistentManifold::getContactBreakingThreshold() const
+{
+	return gContactBreakingThreshold;
+}
+
+
+
+void btPersistentManifold::refreshContactPoints(const btTransform& trA,const btTransform& trB)
+{
+	int i;
+#ifdef DEBUG_PERSISTENCY
+	printf("refreshContactPoints posA = (%f,%f,%f) posB = (%f,%f,%f)\n",
+		trA.getOrigin().getX(),
+		trA.getOrigin().getY(),
+		trA.getOrigin().getZ(),
+		trB.getOrigin().getX(),
+		trB.getOrigin().getY(),
+		trB.getOrigin().getZ());
+#endif //DEBUG_PERSISTENCY
+	/// first refresh worldspace positions and distance
+	for (i=getNumContacts()-1;i>=0;i--)
+	{
+		btManifoldPoint &manifoldPoint = m_pointCache[i];
+		manifoldPoint.m_positionWorldOnA = trA( manifoldPoint.m_localPointA );
+		manifoldPoint.m_positionWorldOnB = trB( manifoldPoint.m_localPointB );
+		manifoldPoint.m_distance1 = (manifoldPoint.m_positionWorldOnA -  manifoldPoint.m_positionWorldOnB).dot(manifoldPoint.m_normalWorldOnB);
+		manifoldPoint.m_lifeTime++;
+	}
+
+	/// then 
+	btScalar distance2d;
+	btVector3 projectedDifference,projectedPoint;
+	for (i=getNumContacts()-1;i>=0;i--)
+	{
+		
+		btManifoldPoint &manifoldPoint = m_pointCache[i];
+		//contact becomes invalid when signed distance exceeds margin (projected on contactnormal direction)
+		if (!validContactDistance(manifoldPoint))
+		{
+			removeContactPoint(i);
+		} else
+		{
+			//contact also becomes invalid when relative movement orthogonal to normal exceeds margin
+			projectedPoint = manifoldPoint.m_positionWorldOnA - manifoldPoint.m_normalWorldOnB * manifoldPoint.m_distance1;
+			projectedDifference = manifoldPoint.m_positionWorldOnB - projectedPoint;
+			distance2d = projectedDifference.dot(projectedDifference);
+			if (distance2d  > getContactBreakingThreshold()*getContactBreakingThreshold() )
+			{
+				removeContactPoint(i);
+			} else
+			{
+				//contact point processed callback
+				if (gContactProcessedCallback)
+					(*gContactProcessedCallback)(manifoldPoint,m_body0,m_body1);
+			}
+		}
+	}
+#ifdef DEBUG_PERSISTENCY
+	DebugPersistency();
+#endif //
+}
+
+
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h	(revision 2122)
@@ -0,0 +1,193 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef PERSISTENT_MANIFOLD_H
+#define PERSISTENT_MANIFOLD_H
+
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+#include "btManifoldPoint.h"
+#include "LinearMath/btAlignedAllocator.h"
+
+struct btCollisionResult;
+
+///contact breaking and merging threshold
+extern btScalar gContactBreakingThreshold;
+
+typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
+typedef bool (*ContactProcessedCallback)(btManifoldPoint& cp,void* body0,void* body1);
+extern ContactDestroyedCallback	gContactDestroyedCallback;
+
+
+
+
+#define MANIFOLD_CACHE_SIZE 4
+
+///btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping in the broadphase.
+///Those contact points are created by the collision narrow phase.
+///The cache can be empty, or hold 1,2,3 or 4 points. Some collision algorithms (GJK) might only add one point at a time.
+///updates/refreshes old contact points, and throw them away if necessary (distance becomes too large)
+///reduces the cache to 4 points, when more then 4 points are added, using following rules:
+///the contact point with deepest penetration is always kept, and it tries to maximuze the area covered by the points
+///note that some pairs of objects might have more then one contact manifold.
+ATTRIBUTE_ALIGNED16( class) btPersistentManifold 
+{
+
+	btManifoldPoint m_pointCache[MANIFOLD_CACHE_SIZE];
+
+	/// this two body pointers can point to the physics rigidbody class.
+	/// void* will allow any rigidbody class
+	void* m_body0;
+	void* m_body1;
+	int	m_cachedPoints;
+
+	
+	/// sort cached points so most isolated points come first
+	int	sortCachedPoints(const btManifoldPoint& pt);
+
+	int		findContactPoint(const btManifoldPoint* unUsed, int numUnused,const btManifoldPoint& pt);
+
+public:
+
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	int m_index1a;
+
+	btPersistentManifold();
+
+	btPersistentManifold(void* body0,void* body1,int bla)
+		: m_body0(body0),m_body1(body1),m_cachedPoints(0)
+	{
+		(void)bla;
+	}
+
+	SIMD_FORCE_INLINE void* getBody0() { return m_body0;}
+	SIMD_FORCE_INLINE void* getBody1() { return m_body1;}
+
+	SIMD_FORCE_INLINE const void* getBody0() const { return m_body0;}
+	SIMD_FORCE_INLINE const void* getBody1() const { return m_body1;}
+
+	void	setBodies(void* body0,void* body1)
+	{
+		m_body0 = body0;
+		m_body1 = body1;
+	}
+
+	void clearUserCache(btManifoldPoint& pt);
+
+#ifdef DEBUG_PERSISTENCY
+	void	DebugPersistency();
+#endif //
+	
+	SIMD_FORCE_INLINE int	getNumContacts() const { return m_cachedPoints;}
+
+	SIMD_FORCE_INLINE const btManifoldPoint& getContactPoint(int index) const
+	{
+		btAssert(index < m_cachedPoints);
+		return m_pointCache[index];
+	}
+
+	SIMD_FORCE_INLINE btManifoldPoint& getContactPoint(int index)
+	{
+		btAssert(index < m_cachedPoints);
+		return m_pointCache[index];
+	}
+
+	/// todo: get this margin from the current physics / collision environment
+	btScalar	getContactBreakingThreshold() const;
+	
+	int getCacheEntry(const btManifoldPoint& newPoint) const;
+
+	int addManifoldPoint( const btManifoldPoint& newPoint);
+
+	void removeContactPoint (int index)
+	{
+		clearUserCache(m_pointCache[index]);
+
+		int lastUsedIndex = getNumContacts() - 1;
+//		m_pointCache[index] = m_pointCache[lastUsedIndex];
+		if(index != lastUsedIndex) 
+		{
+			m_pointCache[index] = m_pointCache[lastUsedIndex]; 
+			//get rid of duplicated userPersistentData pointer
+			m_pointCache[lastUsedIndex].m_userPersistentData = 0;
+			m_pointCache[lastUsedIndex].m_appliedImpulse = 0.f;
+			m_pointCache[lastUsedIndex].m_lateralFrictionInitialized = false;
+			m_pointCache[lastUsedIndex].m_appliedImpulseLateral1 = 0.f;
+			m_pointCache[lastUsedIndex].m_appliedImpulseLateral2 = 0.f;
+			m_pointCache[lastUsedIndex].m_lifeTime = 0;
+		}
+
+		btAssert(m_pointCache[lastUsedIndex].m_userPersistentData==0);
+		m_cachedPoints--;
+	}
+	void replaceContactPoint(const btManifoldPoint& newPoint,int insertIndex)
+	{
+		btAssert(validContactDistance(newPoint));
+
+#define MAINTAIN_PERSISTENCY 1
+#ifdef MAINTAIN_PERSISTENCY
+		int	lifeTime = m_pointCache[insertIndex].getLifeTime();
+		btScalar	appliedImpulse = m_pointCache[insertIndex].m_appliedImpulse;
+		btScalar	appliedLateralImpulse1 = m_pointCache[insertIndex].m_appliedImpulseLateral1;
+		btScalar	appliedLateralImpulse2 = m_pointCache[insertIndex].m_appliedImpulseLateral2;
+				
+		btAssert(lifeTime>=0);
+		void* cache = m_pointCache[insertIndex].m_userPersistentData;
+		
+		m_pointCache[insertIndex] = newPoint;
+
+		m_pointCache[insertIndex].m_userPersistentData = cache;
+		m_pointCache[insertIndex].m_appliedImpulse = appliedImpulse;
+		m_pointCache[insertIndex].m_appliedImpulseLateral1 = appliedLateralImpulse1;
+		m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2;
+		
+		m_pointCache[insertIndex].m_lifeTime = lifeTime;
+#else
+		clearUserCache(m_pointCache[insertIndex]);
+		m_pointCache[insertIndex] = newPoint;
+	
+#endif
+	}
+
+	bool validContactDistance(const btManifoldPoint& pt) const
+	{
+		return pt.m_distance1 <= getContactBreakingThreshold();
+	}
+	/// calculated new worldspace coordinates and depth, and reject points that exceed the collision margin
+	void	refreshContactPoints(  const btTransform& trA,const btTransform& trB);
+
+	
+	SIMD_FORCE_INLINE	void	clearManifold()
+	{
+		int i;
+		for (i=0;i<m_cachedPoints;i++)
+		{
+			clearUserCache(m_pointCache[i]);
+		}
+		m_cachedPoints = 0;
+	}
+
+
+
+}
+;
+
+
+
+
+
+#endif //PERSISTENT_MANIFOLD_H
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPointCollector.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPointCollector.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btPointCollector.h	(revision 2122)
@@ -0,0 +1,61 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef POINT_COLLECTOR_H
+#define POINT_COLLECTOR_H
+
+#include "btDiscreteCollisionDetectorInterface.h"
+
+
+
+struct btPointCollector : public btDiscreteCollisionDetectorInterface::Result
+{
+	
+	
+	btVector3 m_normalOnBInWorld;
+	btVector3 m_pointInWorld;
+	btScalar	m_distance;//negative means penetration
+
+	bool	m_hasResult;
+
+	btPointCollector () 
+		: m_distance(btScalar(1e30)),m_hasResult(false)
+	{
+	}
+
+	virtual void setShapeIdentifiers(int partId0,int index0,	int partId1,int index1)
+	{
+		(void)partId0;
+		(void)index0;
+		(void)partId1;
+		(void)index1;
+		//??
+	}
+
+	virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
+	{
+		if (depth< m_distance)
+		{
+			m_hasResult = true;
+			m_normalOnBInWorld = normalOnBInWorld;
+			m_pointInWorld = pointInWorld;
+			//negative means penetration
+			m_distance = depth;
+		}
+	}
+};
+
+#endif //POINT_COLLECTOR_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp	(revision 2122)
@@ -0,0 +1,163 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+//#include <stdio.h>
+
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
+#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
+#include "btRaycastCallback.h"
+
+btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to)
+	:
+	m_from(from),
+	m_to(to),
+	m_hitFraction(btScalar(1.))
+{
+
+}
+
+
+
+void btTriangleRaycastCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
+{
+	const btVector3 &vert0=triangle[0];
+	const btVector3 &vert1=triangle[1];
+	const btVector3 &vert2=triangle[2];
+
+	btVector3 v10; v10 = vert1 - vert0 ;
+	btVector3 v20; v20 = vert2 - vert0 ;
+
+	btVector3 triangleNormal; triangleNormal = v10.cross( v20 );
+	
+	const btScalar dist = vert0.dot(triangleNormal);
+	btScalar dist_a = triangleNormal.dot(m_from) ;
+	dist_a-= dist;
+	btScalar dist_b = triangleNormal.dot(m_to);
+	dist_b -= dist;
+
+	if ( dist_a * dist_b >= btScalar(0.0) )
+	{
+		return ; // same sign
+	}
+	
+	const btScalar proj_length=dist_a-dist_b;
+	const btScalar distance = (dist_a)/(proj_length);
+	// Now we have the intersection point on the plane, we'll see if it's inside the triangle
+	// Add an epsilon as a tolerance for the raycast,
+	// in case the ray hits exacly on the edge of the triangle.
+	// It must be scaled for the triangle size.
+	
+	if(distance < m_hitFraction)
+	{
+		
+
+		btScalar edge_tolerance =triangleNormal.length2();		
+		edge_tolerance *= btScalar(-0.0001);
+		btVector3 point; point.setInterpolate3( m_from, m_to, distance);
+		{
+			btVector3 v0p; v0p = vert0 - point;
+			btVector3 v1p; v1p = vert1 - point;
+			btVector3 cp0; cp0 = v0p.cross( v1p );
+
+			if ( (btScalar)(cp0.dot(triangleNormal)) >=edge_tolerance) 
+			{
+						
+
+				btVector3 v2p; v2p = vert2 -  point;
+				btVector3 cp1;
+				cp1 = v1p.cross( v2p);
+				if ( (btScalar)(cp1.dot(triangleNormal)) >=edge_tolerance) 
+				{
+					btVector3 cp2;
+					cp2 = v2p.cross(v0p);
+					
+					if ( (btScalar)(cp2.dot(triangleNormal)) >=edge_tolerance) 
+					{
+
+						if ( dist_a > 0 )
+						{
+							m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex);
+						}
+						else
+						{
+							m_hitFraction = reportHit(-triangleNormal,distance,partId,triangleIndex);
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+
+btTriangleConvexcastCallback::btTriangleConvexcastCallback (const btConvexShape* convexShape, const btTransform& convexShapeFrom, const btTransform& convexShapeTo, const btTransform& triangleToWorld, const btScalar triangleCollisionMargin)
+{
+	m_convexShape = convexShape;
+	m_convexShapeFrom = convexShapeFrom;
+	m_convexShapeTo = convexShapeTo;
+	m_triangleToWorld = triangleToWorld;
+	m_hitFraction = 1.0;
+    m_triangleCollisionMargin = triangleCollisionMargin;
+}
+
+void
+btTriangleConvexcastCallback::processTriangle (btVector3* triangle, int partId, int triangleIndex)
+{
+	btTriangleShape triangleShape (triangle[0], triangle[1], triangle[2]);
+    triangleShape.setMargin(m_triangleCollisionMargin);
+
+	btVoronoiSimplexSolver	simplexSolver;
+	btGjkEpaPenetrationDepthSolver	gjkEpaPenetrationSolver;
+
+//#define  USE_SUBSIMPLEX_CONVEX_CAST 1
+//if you reenable USE_SUBSIMPLEX_CONVEX_CAST see commented out code below
+#ifdef USE_SUBSIMPLEX_CONVEX_CAST
+	btSubsimplexConvexCast convexCaster(m_convexShape, &triangleShape, &simplexSolver);
+#else
+	//btGjkConvexCast	convexCaster(m_convexShape,&triangleShape,&simplexSolver);
+	btContinuousConvexCollision convexCaster(m_convexShape,&triangleShape,&simplexSolver,&gjkEpaPenetrationSolver);
+#endif //#USE_SUBSIMPLEX_CONVEX_CAST
+	
+	btConvexCast::CastResult castResult;
+	castResult.m_fraction = btScalar(1.);
+	if (convexCaster.calcTimeOfImpact(m_convexShapeFrom,m_convexShapeTo,m_triangleToWorld, m_triangleToWorld, castResult))
+	{
+		//add hit
+		if (castResult.m_normal.length2() > btScalar(0.0001))
+		{					
+			if (castResult.m_fraction < m_hitFraction)
+			{
+/* btContinuousConvexCast's normal is already in world space */
+/*
+#ifdef USE_SUBSIMPLEX_CONVEX_CAST
+				//rotate normal into worldspace
+				castResult.m_normal = m_convexShapeFrom.getBasis() * castResult.m_normal;
+#endif //USE_SUBSIMPLEX_CONVEX_CAST
+*/
+				castResult.m_normal.normalize();
+
+				reportHit (castResult.m_normal,
+							castResult.m_hitPoint,
+							castResult.m_fraction,
+							partId,
+							triangleIndex);
+			}
+		}
+	}
+}
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h	(revision 2122)
@@ -0,0 +1,60 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef RAYCAST_TRI_CALLBACK_H
+#define RAYCAST_TRI_CALLBACK_H
+
+#include "BulletCollision/CollisionShapes/btTriangleCallback.h"
+#include "LinearMath/btTransform.h"
+struct btBroadphaseProxy;
+class btConvexShape;
+
+class  btTriangleRaycastCallback: public btTriangleCallback
+{
+public:
+
+	//input
+	btVector3 m_from;
+	btVector3 m_to;
+
+	btScalar	m_hitFraction;
+
+	btTriangleRaycastCallback(const btVector3& from,const btVector3& to);
+	
+	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
+
+	virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex ) = 0;
+	
+};
+
+class btTriangleConvexcastCallback : public btTriangleCallback
+{
+public:
+	const btConvexShape* m_convexShape;
+	btTransform m_convexShapeFrom;
+	btTransform m_convexShapeTo;
+	btTransform m_triangleToWorld;
+	btScalar m_hitFraction;
+    btScalar m_triangleCollisionMargin;
+
+	btTriangleConvexcastCallback (const btConvexShape* convexShape, const btTransform& convexShapeFrom, const btTransform& convexShapeTo, const btTransform& triangleToWorld, const btScalar triangleCollisionMargin);
+
+	virtual void processTriangle (btVector3* triangle, int partId, int triangleIndex);
+
+	virtual btScalar reportHit (const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex) = 0;
+};
+
+#endif //RAYCAST_TRI_CALLBACK_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef SIMPLEX_SOLVER_INTERFACE_H
+#define SIMPLEX_SOLVER_INTERFACE_H
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btPoint3.h"
+
+#define NO_VIRTUAL_INTERFACE 1
+#ifdef NO_VIRTUAL_INTERFACE
+#include "btVoronoiSimplexSolver.h"
+#define btSimplexSolverInterface btVoronoiSimplexSolver
+#else
+
+/// btSimplexSolverInterface can incrementally calculate distance between origin and up to 4 vertices
+/// Used by GJK or Linear Casting. Can be implemented by the Johnson-algorithm or alternative approaches based on
+/// voronoi regions or barycentric coordinates
+class btSimplexSolverInterface
+{
+	public:
+		virtual ~btSimplexSolverInterface() {};
+
+	virtual void reset() = 0;
+
+	virtual void addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q) = 0;
+	
+	virtual bool closest(btVector3& v) = 0;
+
+	virtual btScalar maxVertex() = 0;
+
+	virtual bool fullSimplex() const = 0;
+
+	virtual int getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const = 0;
+
+	virtual bool inSimplex(const btVector3& w) = 0;
+	
+	virtual void backup_closest(btVector3& v) = 0;
+
+	virtual bool emptySimplex() const = 0;
+
+	virtual void compute_points(btPoint3& p1, btPoint3& p2) = 0;
+
+	virtual int numVertices() const =0;
+
+
+};
+#endif
+#endif //SIMPLEX_SOLVER_INTERFACE_H
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp	(revision 2122)
@@ -0,0 +1,157 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btSubSimplexConvexCast.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+
+#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
+#include "btPointCollector.h"
+#include "LinearMath/btTransformUtil.h"
+
+btSubsimplexConvexCast::btSubsimplexConvexCast (const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver)
+:m_simplexSolver(simplexSolver),
+m_convexA(convexA),m_convexB(convexB)
+{
+}
+
+///Typically the conservative advancement reaches solution in a few iterations, clip it to 32 for degenerate cases.
+///See discussion about this here http://continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=565
+#ifdef BT_USE_DOUBLE_PRECISION
+#define MAX_ITERATIONS 64
+#else
+#define MAX_ITERATIONS 32
+#endif
+bool	btSubsimplexConvexCast::calcTimeOfImpact(
+		const btTransform& fromA,
+		const btTransform& toA,
+		const btTransform& fromB,
+		const btTransform& toB,
+		CastResult& result)
+{
+
+	m_simplexSolver->reset();
+
+	btVector3 linVelA,linVelB;
+	linVelA = toA.getOrigin()-fromA.getOrigin();
+	linVelB = toB.getOrigin()-fromB.getOrigin();
+
+	btScalar lambda = btScalar(0.);
+
+	btTransform interpolatedTransA = fromA;
+	btTransform interpolatedTransB = fromB;
+
+	///take relative motion
+	btVector3 r = (linVelA-linVelB);
+	btVector3 v;
+	
+	btVector3 supVertexA = fromA(m_convexA->localGetSupportingVertex(-r*fromA.getBasis()));
+	btVector3 supVertexB = fromB(m_convexB->localGetSupportingVertex(r*fromB.getBasis()));
+	v = supVertexA-supVertexB;
+	int maxIter = MAX_ITERATIONS;
+
+	btVector3 n;
+	n.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+	bool hasResult = false;
+	btVector3 c;
+
+	btScalar lastLambda = lambda;
+
+
+	btScalar dist2 = v.length2();
+#ifdef BT_USE_DOUBLE_PRECISION
+	btScalar epsilon = btScalar(0.0001);
+#else
+	btScalar epsilon = btScalar(0.0001);
+#endif //BT_USE_DOUBLE_PRECISION
+	btVector3	w,p;
+	btScalar VdotR;
+	
+	while ( (dist2 > epsilon) && maxIter--)
+	{
+		supVertexA = interpolatedTransA(m_convexA->localGetSupportingVertex(-v*interpolatedTransA.getBasis()));
+		supVertexB = interpolatedTransB(m_convexB->localGetSupportingVertex(v*interpolatedTransB.getBasis()));
+		w = supVertexA-supVertexB;
+
+		btScalar VdotW = v.dot(w);
+
+		if (lambda > btScalar(1.0))
+		{
+			return false;
+		}
+
+		if ( VdotW > btScalar(0.))
+		{
+			VdotR = v.dot(r);
+
+			if (VdotR >= -(SIMD_EPSILON*SIMD_EPSILON))
+				return false;
+			else
+			{
+				lambda = lambda - VdotW / VdotR;
+				//interpolate to next lambda
+				//	x = s + lambda * r;
+				interpolatedTransA.getOrigin().setInterpolate3(fromA.getOrigin(),toA.getOrigin(),lambda);
+				interpolatedTransB.getOrigin().setInterpolate3(fromB.getOrigin(),toB.getOrigin(),lambda);
+				//m_simplexSolver->reset();
+				//check next line
+				 w = supVertexA-supVertexB;
+				lastLambda = lambda;
+				n = v;
+				hasResult = true;
+			}
+		} 
+		m_simplexSolver->addVertex( w, supVertexA , supVertexB);
+		if (m_simplexSolver->closest(v))
+		{
+			dist2 = v.length2();
+			hasResult = true;
+			//todo: check this normal for validity
+			//n=v;
+			//printf("V=%f , %f, %f\n",v[0],v[1],v[2]);
+			//printf("DIST2=%f\n",dist2);
+			//printf("numverts = %i\n",m_simplexSolver->numVertices());
+		} else
+		{
+			dist2 = btScalar(0.);
+		} 
+	}
+
+	//int numiter = MAX_ITERATIONS - maxIter;
+//	printf("number of iterations: %d", numiter);
+	
+	//don't report a time of impact when moving 'away' from the hitnormal
+	
+
+	result.m_fraction = lambda;
+	if (n.length2() >= (SIMD_EPSILON*SIMD_EPSILON))
+		result.m_normal = n.normalized();
+	else
+		result.m_normal = btVector3(btScalar(0.0), btScalar(0.0), btScalar(0.0));
+
+	//don't report time of impact for motion away from the contact normal (or causes minor penetration)
+	if (result.m_normal.dot(r)>=-result.m_allowedPenetration)
+		return false;
+
+	btVector3 hitA,hitB;
+	m_simplexSolver->compute_points(hitA,hitB);
+	result.m_hitPoint=hitB;
+	return true;
+}
+
+
+
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h	(revision 2122)
@@ -0,0 +1,50 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef SUBSIMPLEX_CONVEX_CAST_H
+#define SUBSIMPLEX_CONVEX_CAST_H
+
+#include "btConvexCast.h"
+#include "btSimplexSolverInterface.h"
+class btConvexShape;
+
+/// btSubsimplexConvexCast implements Gino van den Bergens' paper
+///"Ray Casting against bteral Convex Objects with Application to Continuous Collision Detection"
+/// GJK based Ray Cast, optimized version
+/// Objects should not start in overlap, otherwise results are not defined.
+class btSubsimplexConvexCast : public btConvexCast
+{
+	btSimplexSolverInterface* m_simplexSolver;
+	const btConvexShape*	m_convexA;
+	const btConvexShape*	m_convexB;
+
+public:
+
+	btSubsimplexConvexCast (const btConvexShape*	shapeA,const btConvexShape*	shapeB,btSimplexSolverInterface* simplexSolver);
+
+	//virtual ~btSubsimplexConvexCast();
+	///SimsimplexConvexCast calculateTimeOfImpact calculates the time of impact+normal for the linear cast (sweep) between two moving objects.
+	///Precondition is that objects should not penetration/overlap at the start from the interval. Overlap can be tested using btGjkPairDetector.
+	virtual bool	calcTimeOfImpact(
+			const btTransform& fromA,
+			const btTransform& toA,
+			const btTransform& fromB,
+			const btTransform& toB,
+			CastResult& result);
+
+};
+
+#endif //SUBSIMPLEX_CONVEX_CAST_H
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp	(revision 2122)
@@ -0,0 +1,607 @@
+
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+	
+	Elsevier CDROM license agreements grants nonexclusive license to use the software
+	for any purpose, commercial or non-commercial as long as the following credit is included
+	identifying the original source of the software:
+
+	Parts of the source are "from the book Real-Time Collision Detection by
+	Christer Ericson, published by Morgan Kaufmann Publishers,
+	(c) 2005 Elsevier Inc."
+		
+*/
+
+
+#include "btVoronoiSimplexSolver.h"
+#include <assert.h>
+//#include <stdio.h>
+
+#define VERTA  0
+#define VERTB  1
+#define VERTC  2
+#define VERTD  3
+
+#define CATCH_DEGENERATE_TETRAHEDRON 1
+void	btVoronoiSimplexSolver::removeVertex(int index)
+{
+	
+	assert(m_numVertices>0);
+	m_numVertices--;
+	m_simplexVectorW[index] = m_simplexVectorW[m_numVertices];
+	m_simplexPointsP[index] = m_simplexPointsP[m_numVertices];
+	m_simplexPointsQ[index] = m_simplexPointsQ[m_numVertices];
+}
+
+void	btVoronoiSimplexSolver::reduceVertices (const btUsageBitfield& usedVerts)
+{
+	if ((numVertices() >= 4) && (!usedVerts.usedVertexD))
+		removeVertex(3);
+
+	if ((numVertices() >= 3) && (!usedVerts.usedVertexC))
+		removeVertex(2);
+
+	if ((numVertices() >= 2) && (!usedVerts.usedVertexB))
+		removeVertex(1);
+	
+	if ((numVertices() >= 1) && (!usedVerts.usedVertexA))
+		removeVertex(0);
+
+}
+
+
+
+
+
+//clear the simplex, remove all the vertices
+void btVoronoiSimplexSolver::reset()
+{
+	m_cachedValidClosest = false;
+	m_numVertices = 0;
+	m_needsUpdate = true;
+	m_lastW = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+	m_cachedBC.reset();
+}
+
+
+
+	//add a vertex
+void btVoronoiSimplexSolver::addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q)
+{
+	m_lastW = w;
+	m_needsUpdate = true;
+
+	m_simplexVectorW[m_numVertices] = w;
+	m_simplexPointsP[m_numVertices] = p;
+	m_simplexPointsQ[m_numVertices] = q;
+
+	m_numVertices++;
+}
+
+bool	btVoronoiSimplexSolver::updateClosestVectorAndPoints()
+{
+	
+	if (m_needsUpdate)
+	{
+		m_cachedBC.reset();
+
+		m_needsUpdate = false;
+
+		switch (numVertices())
+		{
+		case 0:
+				m_cachedValidClosest = false;
+				break;
+		case 1:
+			{
+				m_cachedP1 = m_simplexPointsP[0];
+				m_cachedP2 = m_simplexPointsQ[0];
+				m_cachedV = m_cachedP1-m_cachedP2; //== m_simplexVectorW[0]
+				m_cachedBC.reset();
+				m_cachedBC.setBarycentricCoordinates(btScalar(1.),btScalar(0.),btScalar(0.),btScalar(0.));
+				m_cachedValidClosest = m_cachedBC.isValid();
+				break;
+			};
+		case 2:
+			{
+			//closest point origin from line segment
+					const btVector3& from = m_simplexVectorW[0];
+					const btVector3& to = m_simplexVectorW[1];
+					btVector3 nearest;
+
+					btVector3 p (btScalar(0.),btScalar(0.),btScalar(0.));
+					btVector3 diff = p - from;
+					btVector3 v = to - from;
+					btScalar t = v.dot(diff);
+					
+					if (t > 0) {
+						btScalar dotVV = v.dot(v);
+						if (t < dotVV) {
+							t /= dotVV;
+							diff -= t*v;
+							m_cachedBC.m_usedVertices.usedVertexA = true;
+							m_cachedBC.m_usedVertices.usedVertexB = true;
+						} else {
+							t = 1;
+							diff -= v;
+							//reduce to 1 point
+							m_cachedBC.m_usedVertices.usedVertexB = true;
+						}
+					} else
+					{
+						t = 0;
+						//reduce to 1 point
+						m_cachedBC.m_usedVertices.usedVertexA = true;
+					}
+					m_cachedBC.setBarycentricCoordinates(1-t,t);
+					nearest = from + t*v;
+
+					m_cachedP1 = m_simplexPointsP[0] + t * (m_simplexPointsP[1] - m_simplexPointsP[0]);
+					m_cachedP2 = m_simplexPointsQ[0] + t * (m_simplexPointsQ[1] - m_simplexPointsQ[0]);
+					m_cachedV = m_cachedP1 - m_cachedP2;
+					
+					reduceVertices(m_cachedBC.m_usedVertices);
+
+					m_cachedValidClosest = m_cachedBC.isValid();
+					break;
+			}
+		case 3: 
+			{ 
+				//closest point origin from triangle 
+				btVector3 p (btScalar(0.),btScalar(0.),btScalar(0.)); 
+
+				const btVector3& a = m_simplexVectorW[0]; 
+				const btVector3& b = m_simplexVectorW[1]; 
+				const btVector3& c = m_simplexVectorW[2]; 
+
+				closestPtPointTriangle(p,a,b,c,m_cachedBC); 
+				m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] + 
+				m_simplexPointsP[1] * m_cachedBC.m_barycentricCoords[1] + 
+				m_simplexPointsP[2] * m_cachedBC.m_barycentricCoords[2]; 
+
+				m_cachedP2 = m_simplexPointsQ[0] * m_cachedBC.m_barycentricCoords[0] + 
+				m_simplexPointsQ[1] * m_cachedBC.m_barycentricCoords[1] + 
+				m_simplexPointsQ[2] * m_cachedBC.m_barycentricCoords[2]; 
+
+				m_cachedV = m_cachedP1-m_cachedP2; 
+
+				reduceVertices (m_cachedBC.m_usedVertices); 
+				m_cachedValidClosest = m_cachedBC.isValid(); 
+
+				break; 
+			}
+		case 4:
+			{
+
+				
+				btVector3 p (btScalar(0.),btScalar(0.),btScalar(0.));
+				
+				const btVector3& a = m_simplexVectorW[0];
+				const btVector3& b = m_simplexVectorW[1];
+				const btVector3& c = m_simplexVectorW[2];
+				const btVector3& d = m_simplexVectorW[3];
+
+				bool hasSeperation = closestPtPointTetrahedron(p,a,b,c,d,m_cachedBC);
+
+				if (hasSeperation)
+				{
+
+					m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] +
+						m_simplexPointsP[1] * m_cachedBC.m_barycentricCoords[1] +
+						m_simplexPointsP[2] * m_cachedBC.m_barycentricCoords[2] +
+						m_simplexPointsP[3] * m_cachedBC.m_barycentricCoords[3];
+
+					m_cachedP2 = m_simplexPointsQ[0] * m_cachedBC.m_barycentricCoords[0] +
+						m_simplexPointsQ[1] * m_cachedBC.m_barycentricCoords[1] +
+						m_simplexPointsQ[2] * m_cachedBC.m_barycentricCoords[2] +
+						m_simplexPointsQ[3] * m_cachedBC.m_barycentricCoords[3];
+
+					m_cachedV = m_cachedP1-m_cachedP2;
+					reduceVertices (m_cachedBC.m_usedVertices);
+				} else
+				{
+//					printf("sub distance got penetration\n");
+
+					if (m_cachedBC.m_degenerate)
+					{
+						m_cachedValidClosest = false;
+					} else
+					{
+						m_cachedValidClosest = true;
+						//degenerate case == false, penetration = true + zero
+						m_cachedV.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+					}
+					break;
+				}
+
+				m_cachedValidClosest = m_cachedBC.isValid();
+
+				//closest point origin from tetrahedron
+				break;
+			}
+		default:
+			{
+				m_cachedValidClosest = false;
+			}
+		};
+	}
+
+	return m_cachedValidClosest;
+
+}
+
+//return/calculate the closest vertex
+bool btVoronoiSimplexSolver::closest(btVector3& v)
+{
+	bool succes = updateClosestVectorAndPoints();
+	v = m_cachedV;
+	return succes;
+}
+
+
+
+btScalar btVoronoiSimplexSolver::maxVertex()
+{
+	int i, numverts = numVertices();
+	btScalar maxV = btScalar(0.);
+	for (i=0;i<numverts;i++)
+	{
+		btScalar curLen2 = m_simplexVectorW[i].length2();
+		if (maxV < curLen2)
+			maxV = curLen2;
+	}
+	return maxV;
+}
+
+
+
+	//return the current simplex
+int btVoronoiSimplexSolver::getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const
+{
+	int i;
+	for (i=0;i<numVertices();i++)
+	{
+		yBuf[i] = m_simplexVectorW[i];
+		pBuf[i] = m_simplexPointsP[i];
+		qBuf[i] = m_simplexPointsQ[i];
+	}
+	return numVertices();
+}
+
+
+
+
+bool btVoronoiSimplexSolver::inSimplex(const btVector3& w)
+{
+	bool found = false;
+	int i, numverts = numVertices();
+	//btScalar maxV = btScalar(0.);
+	
+	//w is in the current (reduced) simplex
+	for (i=0;i<numverts;i++)
+	{
+		if (m_simplexVectorW[i] == w)
+			found = true;
+	}
+
+	//check in case lastW is already removed
+	if (w == m_lastW)
+		return true;
+    	
+	return found;
+}
+
+void btVoronoiSimplexSolver::backup_closest(btVector3& v) 
+{
+	v = m_cachedV;
+}
+
+
+bool btVoronoiSimplexSolver::emptySimplex() const 
+{
+	return (numVertices() == 0);
+
+}
+
+void btVoronoiSimplexSolver::compute_points(btPoint3& p1, btPoint3& p2) 
+{
+	updateClosestVectorAndPoints();
+	p1 = m_cachedP1;
+	p2 = m_cachedP2;
+
+}
+
+
+
+
+bool	btVoronoiSimplexSolver::closestPtPointTriangle(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c,btSubSimplexClosestResult& result)
+{
+	result.m_usedVertices.reset();
+
+    // Check if P in vertex region outside A
+    btVector3 ab = b - a;
+    btVector3 ac = c - a;
+    btVector3 ap = p - a;
+    btScalar d1 = ab.dot(ap);
+    btScalar d2 = ac.dot(ap);
+    if (d1 <= btScalar(0.0) && d2 <= btScalar(0.0)) 
+	{
+		result.m_closestPointOnSimplex = a;
+		result.m_usedVertices.usedVertexA = true;
+		result.setBarycentricCoordinates(1,0,0);
+		return true;// a; // barycentric coordinates (1,0,0)
+	}
+
+    // Check if P in vertex region outside B
+    btVector3 bp = p - b;
+    btScalar d3 = ab.dot(bp);
+    btScalar d4 = ac.dot(bp);
+    if (d3 >= btScalar(0.0) && d4 <= d3) 
+	{
+		result.m_closestPointOnSimplex = b;
+		result.m_usedVertices.usedVertexB = true;
+		result.setBarycentricCoordinates(0,1,0);
+
+		return true; // b; // barycentric coordinates (0,1,0)
+	}
+    // Check if P in edge region of AB, if so return projection of P onto AB
+    btScalar vc = d1*d4 - d3*d2;
+    if (vc <= btScalar(0.0) && d1 >= btScalar(0.0) && d3 <= btScalar(0.0)) {
+        btScalar v = d1 / (d1 - d3);
+		result.m_closestPointOnSimplex = a + v * ab;
+		result.m_usedVertices.usedVertexA = true;
+		result.m_usedVertices.usedVertexB = true;
+		result.setBarycentricCoordinates(1-v,v,0);
+		return true;
+        //return a + v * ab; // barycentric coordinates (1-v,v,0)
+    }
+
+    // Check if P in vertex region outside C
+    btVector3 cp = p - c;
+    btScalar d5 = ab.dot(cp);
+    btScalar d6 = ac.dot(cp);
+    if (d6 >= btScalar(0.0) && d5 <= d6) 
+	{
+		result.m_closestPointOnSimplex = c;
+		result.m_usedVertices.usedVertexC = true;
+		result.setBarycentricCoordinates(0,0,1);
+		return true;//c; // barycentric coordinates (0,0,1)
+	}
+
+    // Check if P in edge region of AC, if so return projection of P onto AC
+    btScalar vb = d5*d2 - d1*d6;
+    if (vb <= btScalar(0.0) && d2 >= btScalar(0.0) && d6 <= btScalar(0.0)) {
+        btScalar w = d2 / (d2 - d6);
+		result.m_closestPointOnSimplex = a + w * ac;
+		result.m_usedVertices.usedVertexA = true;
+		result.m_usedVertices.usedVertexC = true;
+		result.setBarycentricCoordinates(1-w,0,w);
+		return true;
+        //return a + w * ac; // barycentric coordinates (1-w,0,w)
+    }
+
+    // Check if P in edge region of BC, if so return projection of P onto BC
+    btScalar va = d3*d6 - d5*d4;
+    if (va <= btScalar(0.0) && (d4 - d3) >= btScalar(0.0) && (d5 - d6) >= btScalar(0.0)) {
+        btScalar w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
+		
+		result.m_closestPointOnSimplex = b + w * (c - b);
+		result.m_usedVertices.usedVertexB = true;
+		result.m_usedVertices.usedVertexC = true;
+		result.setBarycentricCoordinates(0,1-w,w);
+		return true;		
+       // return b + w * (c - b); // barycentric coordinates (0,1-w,w)
+    }
+
+    // P inside face region. Compute Q through its barycentric coordinates (u,v,w)
+    btScalar denom = btScalar(1.0) / (va + vb + vc);
+    btScalar v = vb * denom;
+    btScalar w = vc * denom;
+    
+	result.m_closestPointOnSimplex = a + ab * v + ac * w;
+	result.m_usedVertices.usedVertexA = true;
+	result.m_usedVertices.usedVertexB = true;
+	result.m_usedVertices.usedVertexC = true;
+	result.setBarycentricCoordinates(1-v-w,v,w);
+	
+	return true;
+//	return a + ab * v + ac * w; // = u*a + v*b + w*c, u = va * denom = btScalar(1.0) - v - w
+
+}
+
+
+
+
+
+/// Test if point p and d lie on opposite sides of plane through abc
+int btVoronoiSimplexSolver::pointOutsideOfPlane(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d)
+{
+	btVector3 normal = (b-a).cross(c-a);
+
+    btScalar signp = (p - a).dot(normal); // [AP AB AC]
+    btScalar signd = (d - a).dot( normal); // [AD AB AC]
+
+#ifdef CATCH_DEGENERATE_TETRAHEDRON
+#ifdef BT_USE_DOUBLE_PRECISION
+if (signd * signd < (btScalar(1e-8) * btScalar(1e-8)))
+	{
+		return -1;
+	}
+#else
+	if (signd * signd < (btScalar(1e-4) * btScalar(1e-4)))
+	{
+//		printf("affine dependent/degenerate\n");//
+		return -1;
+	}
+#endif
+
+#endif
+	// Points on opposite sides if expression signs are opposite
+    return signp * signd < btScalar(0.);
+}
+
+
+bool	btVoronoiSimplexSolver::closestPtPointTetrahedron(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d, btSubSimplexClosestResult& finalResult)
+{
+	btSubSimplexClosestResult tempResult;
+
+    // Start out assuming point inside all halfspaces, so closest to itself
+	finalResult.m_closestPointOnSimplex = p;
+	finalResult.m_usedVertices.reset();
+    finalResult.m_usedVertices.usedVertexA = true;
+	finalResult.m_usedVertices.usedVertexB = true;
+	finalResult.m_usedVertices.usedVertexC = true;
+	finalResult.m_usedVertices.usedVertexD = true;
+
+    int pointOutsideABC = pointOutsideOfPlane(p, a, b, c, d);
+	int pointOutsideACD = pointOutsideOfPlane(p, a, c, d, b);
+  	int	pointOutsideADB = pointOutsideOfPlane(p, a, d, b, c);
+	int	pointOutsideBDC = pointOutsideOfPlane(p, b, d, c, a);
+
+   if (pointOutsideABC < 0 || pointOutsideACD < 0 || pointOutsideADB < 0 || pointOutsideBDC < 0)
+   {
+	   finalResult.m_degenerate = true;
+	   return false;
+   }
+
+   if (!pointOutsideABC  && !pointOutsideACD && !pointOutsideADB && !pointOutsideBDC)
+	 {
+		 return false;
+	 }
+
+
+    btScalar bestSqDist = FLT_MAX;
+    // If point outside face abc then compute closest point on abc
+	if (pointOutsideABC) 
+	{
+        closestPtPointTriangle(p, a, b, c,tempResult);
+		btPoint3 q = tempResult.m_closestPointOnSimplex;
+		
+        btScalar sqDist = (q - p).dot( q - p);
+        // Update best closest point if (squared) distance is less than current best
+        if (sqDist < bestSqDist) {
+			bestSqDist = sqDist;
+			finalResult.m_closestPointOnSimplex = q;
+			//convert result bitmask!
+			finalResult.m_usedVertices.reset();
+			finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA;
+			finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexB;
+			finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexC;
+			finalResult.setBarycentricCoordinates(
+					tempResult.m_barycentricCoords[VERTA],
+					tempResult.m_barycentricCoords[VERTB],
+					tempResult.m_barycentricCoords[VERTC],
+					0
+			);
+
+		}
+    }
+  
+
+	// Repeat test for face acd
+	if (pointOutsideACD) 
+	{
+        closestPtPointTriangle(p, a, c, d,tempResult);
+		btPoint3 q = tempResult.m_closestPointOnSimplex;
+		//convert result bitmask!
+
+        btScalar sqDist = (q - p).dot( q - p);
+        if (sqDist < bestSqDist) 
+		{
+			bestSqDist = sqDist;
+			finalResult.m_closestPointOnSimplex = q;
+			finalResult.m_usedVertices.reset();
+			finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA;
+
+			finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexB;
+			finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexC;
+			finalResult.setBarycentricCoordinates(
+					tempResult.m_barycentricCoords[VERTA],
+					0,
+					tempResult.m_barycentricCoords[VERTB],
+					tempResult.m_barycentricCoords[VERTC]
+			);
+
+		}
+    }
+    // Repeat test for face adb
+
+	
+	if (pointOutsideADB)
+	{
+		closestPtPointTriangle(p, a, d, b,tempResult);
+		btPoint3 q = tempResult.m_closestPointOnSimplex;
+		//convert result bitmask!
+
+        btScalar sqDist = (q - p).dot( q - p);
+        if (sqDist < bestSqDist) 
+		{
+			bestSqDist = sqDist;
+			finalResult.m_closestPointOnSimplex = q;
+			finalResult.m_usedVertices.reset();
+			finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA;
+			finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexC;
+			
+			finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexB;
+			finalResult.setBarycentricCoordinates(
+					tempResult.m_barycentricCoords[VERTA],
+					tempResult.m_barycentricCoords[VERTC],
+					0,
+					tempResult.m_barycentricCoords[VERTB]
+			);
+
+		}
+    }
+    // Repeat test for face bdc
+    
+
+	if (pointOutsideBDC)
+	{
+        closestPtPointTriangle(p, b, d, c,tempResult);
+		btPoint3 q = tempResult.m_closestPointOnSimplex;
+		//convert result bitmask!
+        btScalar sqDist = (q - p).dot( q - p);
+        if (sqDist < bestSqDist) 
+		{
+			bestSqDist = sqDist;
+			finalResult.m_closestPointOnSimplex = q;
+			finalResult.m_usedVertices.reset();
+			//
+			finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexA;
+			finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexC;
+			finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexB;
+
+			finalResult.setBarycentricCoordinates(
+					0,
+					tempResult.m_barycentricCoords[VERTA],
+					tempResult.m_barycentricCoords[VERTC],
+					tempResult.m_barycentricCoords[VERTB]
+			);
+
+		}
+    }
+
+	//help! we ended up full !
+	
+	if (finalResult.m_usedVertices.usedVertexA &&
+		finalResult.m_usedVertices.usedVertexB &&
+		finalResult.m_usedVertices.usedVertexC &&
+		finalResult.m_usedVertices.usedVertexD) 
+	{
+		return true;
+	}
+
+    return true;
+}
+
Index: /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h
===================================================================
--- /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h	(revision 2122)
@@ -0,0 +1,157 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef btVoronoiSimplexSolver_H
+#define btVoronoiSimplexSolver_H
+
+#include "btSimplexSolverInterface.h"
+
+
+
+#define VORONOI_SIMPLEX_MAX_VERTS 5
+
+struct btUsageBitfield{
+	btUsageBitfield()
+	{
+		reset();
+	}
+
+	void reset()
+	{
+		usedVertexA = false;
+		usedVertexB = false;
+		usedVertexC = false;
+		usedVertexD = false;
+	}
+	unsigned short usedVertexA	: 1;
+	unsigned short usedVertexB	: 1;
+	unsigned short usedVertexC	: 1;
+	unsigned short usedVertexD	: 1;
+	unsigned short unused1		: 1;
+	unsigned short unused2		: 1;
+	unsigned short unused3		: 1;
+	unsigned short unused4		: 1;
+};
+
+
+struct	btSubSimplexClosestResult
+{
+	btPoint3	m_closestPointOnSimplex;
+	//MASK for m_usedVertices
+	//stores the simplex vertex-usage, using the MASK, 
+	// if m_usedVertices & MASK then the related vertex is used
+	btUsageBitfield	m_usedVertices;
+	btScalar	m_barycentricCoords[4];
+	bool m_degenerate;
+
+	void	reset()
+	{
+		m_degenerate = false;
+		setBarycentricCoordinates();
+		m_usedVertices.reset();
+	}
+	bool	isValid()
+	{
+		bool valid = (m_barycentricCoords[0] >= btScalar(0.)) &&
+			(m_barycentricCoords[1] >= btScalar(0.)) &&
+			(m_barycentricCoords[2] >= btScalar(0.)) &&
+			(m_barycentricCoords[3] >= btScalar(0.));
+
+
+		return valid;
+	}
+	void	setBarycentricCoordinates(btScalar a=btScalar(0.),btScalar b=btScalar(0.),btScalar c=btScalar(0.),btScalar d=btScalar(0.))
+	{
+		m_barycentricCoords[0] = a;
+		m_barycentricCoords[1] = b;
+		m_barycentricCoords[2] = c;
+		m_barycentricCoords[3] = d;
+	}
+
+};
+
+/// btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points simplex to the origin.
+/// Can be used with GJK, as an alternative to Johnson distance algorithm.
+#ifdef NO_VIRTUAL_INTERFACE
+class btVoronoiSimplexSolver
+#else
+class btVoronoiSimplexSolver : public btSimplexSolverInterface
+#endif
+{
+public:
+
+	int	m_numVertices;
+
+	btVector3	m_simplexVectorW[VORONOI_SIMPLEX_MAX_VERTS];
+	btPoint3	m_simplexPointsP[VORONOI_SIMPLEX_MAX_VERTS];
+	btPoint3	m_simplexPointsQ[VORONOI_SIMPLEX_MAX_VERTS];
+
+	
+
+	btPoint3	m_cachedP1;
+	btPoint3	m_cachedP2;
+	btVector3	m_cachedV;
+	btVector3	m_lastW;
+	bool		m_cachedValidClosest;
+
+	btSubSimplexClosestResult m_cachedBC;
+
+	bool	m_needsUpdate;
+	
+	void	removeVertex(int index);
+	void	reduceVertices (const btUsageBitfield& usedVerts);
+	bool	updateClosestVectorAndPoints();
+
+	bool	closestPtPointTetrahedron(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d, btSubSimplexClosestResult& finalResult);
+	int		pointOutsideOfPlane(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c, const btPoint3& d);
+	bool	closestPtPointTriangle(const btPoint3& p, const btPoint3& a, const btPoint3& b, const btPoint3& c,btSubSimplexClosestResult& result);
+
+public:
+
+	 void reset();
+
+	 void addVertex(const btVector3& w, const btPoint3& p, const btPoint3& q);
+
+
+	 bool closest(btVector3& v);
+
+	 btScalar maxVertex();
+
+	 bool fullSimplex() const
+	 {
+		 return (m_numVertices == 4);
+	 }
+
+	 int getSimplex(btPoint3 *pBuf, btPoint3 *qBuf, btVector3 *yBuf) const;
+
+	 bool inSimplex(const btVector3& w);
+	
+	 void backup_closest(btVector3& v) ;
+
+	 bool emptySimplex() const ;
+
+	 void compute_points(btPoint3& p1, btPoint3& p2) ;
+
+	 int numVertices() const 
+	 {
+		 return m_numVertices;
+	 }
+
+
+};
+
+#endif //VoronoiSimplexSolver
Index: /code/branches/physics/src/bullet/BulletDynamics/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,32 @@
+ADD_LIBRARY(LibBulletDynamics SHARED
+
+	ConstraintSolver/btContactConstraint.cpp
+	ConstraintSolver/btContactConstraint.h
+	ConstraintSolver/btConeTwistConstraint.cpp
+	ConstraintSolver/btConeTwistConstraint.h
+	ConstraintSolver/btGeneric6DofConstraint.cpp
+	ConstraintSolver/btGeneric6DofConstraint.h
+	ConstraintSolver/btHingeConstraint.cpp
+	ConstraintSolver/btHingeConstraint.h
+	ConstraintSolver/btPoint2PointConstraint.cpp
+	ConstraintSolver/btPoint2PointConstraint.h
+	ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
+	ConstraintSolver/btSequentialImpulseConstraintSolver.h
+	ConstraintSolver/btSliderConstraint.cpp
+	ConstraintSolver/btSliderConstraint.h
+	ConstraintSolver/btSolve2LinearConstraint.cpp
+	ConstraintSolver/btSolve2LinearConstraint.h
+	ConstraintSolver/btTypedConstraint.cpp
+	ConstraintSolver/btTypedConstraint.h
+	Dynamics/Bullet-C-API.cpp
+	Dynamics/btDiscreteDynamicsWorld.cpp
+	Dynamics/btDiscreteDynamicsWorld.h
+	Dynamics/btSimpleDynamicsWorld.cpp
+	Dynamics/btSimpleDynamicsWorld.h
+	Dynamics/btRigidBody.cpp
+	Dynamics/btRigidBody.h
+	Vehicle/btRaycastVehicle.cpp
+	Vehicle/btRaycastVehicle.h
+	Vehicle/btWheelInfo.cpp
+	Vehicle/btWheelInfo.h
+)
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp	(revision 2122)
@@ -0,0 +1,289 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+btConeTwistConstraint is Copyright (c) 2007 Starbreeze Studios
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+Written by: Marcus Hennix
+*/
+
+
+#include "btConeTwistConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btTransformUtil.h"
+#include "LinearMath/btMinMax.h"
+#include <new>
+
+btConeTwistConstraint::btConeTwistConstraint()
+:btTypedConstraint(CONETWIST_CONSTRAINT_TYPE)
+{
+}
+
+
+btConeTwistConstraint::btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB, 
+											 const btTransform& rbAFrame,const btTransform& rbBFrame)
+											 :btTypedConstraint(CONETWIST_CONSTRAINT_TYPE, rbA,rbB),m_rbAFrame(rbAFrame),m_rbBFrame(rbBFrame),
+											 m_angularOnly(false)
+{
+	m_swingSpan1 = btScalar(1e30);
+	m_swingSpan2 = btScalar(1e30);
+	m_twistSpan  = btScalar(1e30);
+	m_biasFactor = 0.3f;
+	m_relaxationFactor = 1.0f;
+
+	m_solveTwistLimit = false;
+	m_solveSwingLimit = false;
+
+}
+
+btConeTwistConstraint::btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame)
+											:btTypedConstraint(CONETWIST_CONSTRAINT_TYPE,rbA),m_rbAFrame(rbAFrame),
+											 m_angularOnly(false)
+{
+	m_rbBFrame = m_rbAFrame;
+	
+	m_swingSpan1 = btScalar(1e30);
+	m_swingSpan2 = btScalar(1e30);
+	m_twistSpan  = btScalar(1e30);
+	m_biasFactor = 0.3f;
+	m_relaxationFactor = 1.0f;
+
+	m_solveTwistLimit = false;
+	m_solveSwingLimit = false;
+	
+}			
+
+void	btConeTwistConstraint::buildJacobian()
+{
+	m_appliedImpulse = btScalar(0.);
+
+	//set bias, sign, clear accumulator
+	m_swingCorrection = btScalar(0.);
+	m_twistLimitSign = btScalar(0.);
+	m_solveTwistLimit = false;
+	m_solveSwingLimit = false;
+	m_accTwistLimitImpulse = btScalar(0.);
+	m_accSwingLimitImpulse = btScalar(0.);
+
+	if (!m_angularOnly)
+	{
+		btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin();
+		btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin();
+		btVector3 relPos = pivotBInW - pivotAInW;
+
+		btVector3 normal[3];
+		if (relPos.length2() > SIMD_EPSILON)
+		{
+			normal[0] = relPos.normalized();
+		}
+		else
+		{
+			normal[0].setValue(btScalar(1.0),0,0);
+		}
+
+		btPlaneSpace1(normal[0], normal[1], normal[2]);
+
+		for (int i=0;i<3;i++)
+		{
+			new (&m_jac[i]) btJacobianEntry(
+				m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+				m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+				pivotAInW - m_rbA.getCenterOfMassPosition(),
+				pivotBInW - m_rbB.getCenterOfMassPosition(),
+				normal[i],
+				m_rbA.getInvInertiaDiagLocal(),
+				m_rbA.getInvMass(),
+				m_rbB.getInvInertiaDiagLocal(),
+				m_rbB.getInvMass());
+		}
+	}
+
+	btVector3 b1Axis1,b1Axis2,b1Axis3;
+	btVector3 b2Axis1,b2Axis2;
+
+	b1Axis1 = getRigidBodyA().getCenterOfMassTransform().getBasis() * this->m_rbAFrame.getBasis().getColumn(0);
+	b2Axis1 = getRigidBodyB().getCenterOfMassTransform().getBasis() * this->m_rbBFrame.getBasis().getColumn(0);
+
+	btScalar swing1=btScalar(0.),swing2 = btScalar(0.);
+
+	btScalar swx=btScalar(0.),swy = btScalar(0.);
+	btScalar thresh = btScalar(10.);
+	btScalar fact;
+
+	// Get Frame into world space
+	if (m_swingSpan1 >= btScalar(0.05f))
+	{
+		b1Axis2 = getRigidBodyA().getCenterOfMassTransform().getBasis() * this->m_rbAFrame.getBasis().getColumn(1);
+//		swing1  = btAtan2Fast( b2Axis1.dot(b1Axis2),b2Axis1.dot(b1Axis1) );
+		swx = b2Axis1.dot(b1Axis1);
+		swy = b2Axis1.dot(b1Axis2);
+		swing1  = btAtan2Fast(swy, swx);
+		fact = (swy*swy + swx*swx) * thresh * thresh;
+		fact = fact / (fact + btScalar(1.0));
+		swing1 *= fact; 
+
+	}
+
+	if (m_swingSpan2 >= btScalar(0.05f))
+	{
+		b1Axis3 = getRigidBodyA().getCenterOfMassTransform().getBasis() * this->m_rbAFrame.getBasis().getColumn(2);			
+//		swing2 = btAtan2Fast( b2Axis1.dot(b1Axis3),b2Axis1.dot(b1Axis1) );
+		swx = b2Axis1.dot(b1Axis1);
+		swy = b2Axis1.dot(b1Axis3);
+		swing2  = btAtan2Fast(swy, swx);
+		fact = (swy*swy + swx*swx) * thresh * thresh;
+		fact = fact / (fact + btScalar(1.0));
+		swing2 *= fact; 
+	}
+
+	btScalar RMaxAngle1Sq = 1.0f / (m_swingSpan1*m_swingSpan1);		
+	btScalar RMaxAngle2Sq = 1.0f / (m_swingSpan2*m_swingSpan2);	
+	btScalar EllipseAngle = btFabs(swing1*swing1)* RMaxAngle1Sq + btFabs(swing2*swing2) * RMaxAngle2Sq;
+
+	if (EllipseAngle > 1.0f)
+	{
+		m_swingCorrection = EllipseAngle-1.0f;
+		m_solveSwingLimit = true;
+		
+		// Calculate necessary axis & factors
+		m_swingAxis = b2Axis1.cross(b1Axis2* b2Axis1.dot(b1Axis2) + b1Axis3* b2Axis1.dot(b1Axis3));
+		m_swingAxis.normalize();
+
+		btScalar swingAxisSign = (b2Axis1.dot(b1Axis1) >= 0.0f) ? 1.0f : -1.0f;
+		m_swingAxis *= swingAxisSign;
+
+		m_kSwing =  btScalar(1.) / (getRigidBodyA().computeAngularImpulseDenominator(m_swingAxis) +
+			getRigidBodyB().computeAngularImpulseDenominator(m_swingAxis));
+
+	}
+
+	// Twist limits
+	if (m_twistSpan >= btScalar(0.))
+	{
+		btVector3 b2Axis2 = getRigidBodyB().getCenterOfMassTransform().getBasis() * this->m_rbBFrame.getBasis().getColumn(1);
+		btQuaternion rotationArc = shortestArcQuat(b2Axis1,b1Axis1);
+		btVector3 TwistRef = quatRotate(rotationArc,b2Axis2); 
+		btScalar twist = btAtan2Fast( TwistRef.dot(b1Axis3), TwistRef.dot(b1Axis2) );
+
+		btScalar lockedFreeFactor = (m_twistSpan > btScalar(0.05f)) ? m_limitSoftness : btScalar(0.);
+		if (twist <= -m_twistSpan*lockedFreeFactor)
+		{
+			m_twistCorrection = -(twist + m_twistSpan);
+			m_solveTwistLimit = true;
+
+			m_twistAxis = (b2Axis1 + b1Axis1) * 0.5f;
+			m_twistAxis.normalize();
+			m_twistAxis *= -1.0f;
+
+			m_kTwist = btScalar(1.) / (getRigidBodyA().computeAngularImpulseDenominator(m_twistAxis) +
+				getRigidBodyB().computeAngularImpulseDenominator(m_twistAxis));
+
+		}	else
+			if (twist >  m_twistSpan*lockedFreeFactor)
+			{
+				m_twistCorrection = (twist - m_twistSpan);
+				m_solveTwistLimit = true;
+
+				m_twistAxis = (b2Axis1 + b1Axis1) * 0.5f;
+				m_twistAxis.normalize();
+
+				m_kTwist = btScalar(1.) / (getRigidBodyA().computeAngularImpulseDenominator(m_twistAxis) +
+					getRigidBodyB().computeAngularImpulseDenominator(m_twistAxis));
+
+			}
+	}
+}
+
+void	btConeTwistConstraint::solveConstraint(btScalar	timeStep)
+{
+
+	btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin();
+	btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin();
+
+	btScalar tau = btScalar(0.3);
+
+	//linear part
+	if (!m_angularOnly)
+	{
+		btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); 
+		btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition();
+
+		btVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1);
+		btVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2);
+		btVector3 vel = vel1 - vel2;
+
+		for (int i=0;i<3;i++)
+		{		
+			const btVector3& normal = m_jac[i].m_linearJointAxis;
+			btScalar jacDiagABInv = btScalar(1.) / m_jac[i].getDiagonal();
+
+			btScalar rel_vel;
+			rel_vel = normal.dot(vel);
+			//positional error (zeroth order error)
+			btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal
+			btScalar impulse = depth*tau/timeStep  * jacDiagABInv -  rel_vel * jacDiagABInv;
+			m_appliedImpulse += impulse;
+			btVector3 impulse_vector = normal * impulse;
+			m_rbA.applyImpulse(impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition());
+			m_rbB.applyImpulse(-impulse_vector, pivotBInW - m_rbB.getCenterOfMassPosition());
+		}
+	}
+	
+	{
+		///solve angular part
+		const btVector3& angVelA = getRigidBodyA().getAngularVelocity();
+		const btVector3& angVelB = getRigidBodyB().getAngularVelocity();
+
+		// solve swing limit
+		if (m_solveSwingLimit)
+		{
+			btScalar amplitude = ((angVelB - angVelA).dot( m_swingAxis )*m_relaxationFactor*m_relaxationFactor + m_swingCorrection*(btScalar(1.)/timeStep)*m_biasFactor);
+			btScalar impulseMag = amplitude * m_kSwing;
+
+			// Clamp the accumulated impulse
+			btScalar temp = m_accSwingLimitImpulse;
+			m_accSwingLimitImpulse = btMax(m_accSwingLimitImpulse + impulseMag, btScalar(0.0) );
+			impulseMag = m_accSwingLimitImpulse - temp;
+
+			btVector3 impulse = m_swingAxis * impulseMag;
+
+			m_rbA.applyTorqueImpulse(impulse);
+			m_rbB.applyTorqueImpulse(-impulse);
+
+		}
+
+		// solve twist limit
+		if (m_solveTwistLimit)
+		{
+			btScalar amplitude = ((angVelB - angVelA).dot( m_twistAxis )*m_relaxationFactor*m_relaxationFactor + m_twistCorrection*(btScalar(1.)/timeStep)*m_biasFactor );
+			btScalar impulseMag = amplitude * m_kTwist;
+
+			// Clamp the accumulated impulse
+			btScalar temp = m_accTwistLimitImpulse;
+			m_accTwistLimitImpulse = btMax(m_accTwistLimitImpulse + impulseMag, btScalar(0.0) );
+			impulseMag = m_accTwistLimitImpulse - temp;
+
+			btVector3 impulse = m_twistAxis * impulseMag;
+
+			m_rbA.applyTorqueImpulse(impulse);
+			m_rbB.applyTorqueImpulse(-impulse);
+
+		}
+	
+	}
+
+}
+
+void	btConeTwistConstraint::updateRHS(btScalar	timeStep)
+{
+	(void)timeStep;
+
+}
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h	(revision 2122)
@@ -0,0 +1,126 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+btConeTwistConstraint is Copyright (c) 2007 Starbreeze Studios
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+Written by: Marcus Hennix
+*/
+
+
+
+#ifndef CONETWISTCONSTRAINT_H
+#define CONETWISTCONSTRAINT_H
+
+#include "../../LinearMath/btVector3.h"
+#include "btJacobianEntry.h"
+#include "btTypedConstraint.h"
+
+class btRigidBody;
+
+
+///btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc)
+class btConeTwistConstraint : public btTypedConstraint
+{
+#ifdef IN_PARALLELL_SOLVER
+public:
+#endif
+	btJacobianEntry	m_jac[3]; //3 orthogonal linear constraints
+
+	btTransform m_rbAFrame; 
+	btTransform m_rbBFrame;
+
+	btScalar	m_limitSoftness;
+	btScalar	m_biasFactor;
+	btScalar	m_relaxationFactor;
+
+	btScalar	m_swingSpan1;
+	btScalar	m_swingSpan2;
+	btScalar	m_twistSpan;
+
+	btVector3   m_swingAxis;
+	btVector3	m_twistAxis;
+
+	btScalar	m_kSwing;
+	btScalar	m_kTwist;
+
+	btScalar	m_twistLimitSign;
+	btScalar	m_swingCorrection;
+	btScalar	m_twistCorrection;
+
+	btScalar	m_accSwingLimitImpulse;
+	btScalar	m_accTwistLimitImpulse;
+
+	bool		m_angularOnly;
+	bool		m_solveTwistLimit;
+	bool		m_solveSwingLimit;
+
+	
+public:
+
+	btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB,const btTransform& rbAFrame, const btTransform& rbBFrame);
+	
+	btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame);
+
+	btConeTwistConstraint();
+
+	virtual void	buildJacobian();
+
+	virtual	void	solveConstraint(btScalar	timeStep);
+
+	void	updateRHS(btScalar	timeStep);
+
+	const btRigidBody& getRigidBodyA() const
+	{
+		return m_rbA;
+	}
+	const btRigidBody& getRigidBodyB() const
+	{
+		return m_rbB;
+	}
+
+	void	setAngularOnly(bool angularOnly)
+	{
+		m_angularOnly = angularOnly;
+	}
+
+	void	setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar _twistSpan,  btScalar _softness = 0.8f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
+	{
+		m_swingSpan1 = _swingSpan1;
+		m_swingSpan2 = _swingSpan2;
+		m_twistSpan  = _twistSpan;
+
+		m_limitSoftness =  _softness;
+		m_biasFactor = _biasFactor;
+		m_relaxationFactor = _relaxationFactor;
+	}
+
+	const btTransform& getAFrame() { return m_rbAFrame; };	
+	const btTransform& getBFrame() { return m_rbBFrame; };
+
+	inline int getSolveTwistLimit()
+	{
+		return m_solveTwistLimit;
+	}
+
+	inline int getSolveSwingLimit()
+	{
+		return m_solveTwistLimit;
+	}
+
+	inline btScalar getTwistLimitSign()
+	{
+		return m_twistLimitSign;
+	}
+
+};
+
+#endif //CONETWISTCONSTRAINT_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConstraintSolver.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConstraintSolver.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btConstraintSolver.h	(revision 2122)
@@ -0,0 +1,52 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONSTRAINT_SOLVER_H
+#define CONSTRAINT_SOLVER_H
+
+#include "LinearMath/btScalar.h"
+
+class btPersistentManifold;
+class btRigidBody;
+class btCollisionObject;
+class btTypedConstraint;
+struct btContactSolverInfo;
+struct btBroadphaseProxy;
+class btIDebugDraw;
+class btStackAlloc;
+class	btDispatcher;
+/// btConstraintSolver provides solver interface
+class btConstraintSolver
+{
+
+public:
+
+	virtual ~btConstraintSolver() {}
+	
+	virtual void prepareSolve (int /* numBodies */, int /* numManifolds */) {;}
+
+	///solve a group of constraints
+	virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints, const btContactSolverInfo& info,class btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher) = 0;
+
+	virtual void allSolved (const btContactSolverInfo& /* info */,class btIDebugDraw* /* debugDrawer */, btStackAlloc* /* stackAlloc */) {;}
+
+	///clear internal cached data and reset random seed
+	virtual	void	reset() = 0;
+};
+
+
+
+
+#endif //CONSTRAINT_SOLVER_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactConstraint.cpp	(revision 2122)
@@ -0,0 +1,429 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btContactConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btVector3.h"
+#include "btJacobianEntry.h"
+#include "btContactSolverInfo.h"
+#include "LinearMath/btMinMax.h"
+#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
+
+#define ASSERT2 assert
+
+#define USE_INTERNAL_APPLY_IMPULSE 1
+
+
+//bilateral constraint between two dynamic objects
+void resolveSingleBilateral(btRigidBody& body1, const btVector3& pos1,
+                      btRigidBody& body2, const btVector3& pos2,
+                      btScalar distance, const btVector3& normal,btScalar& impulse ,btScalar timeStep)
+{
+	(void)timeStep;
+	(void)distance;
+
+
+	btScalar normalLenSqr = normal.length2();
+	ASSERT2(btFabs(normalLenSqr) < btScalar(1.1));
+	if (normalLenSqr > btScalar(1.1))
+	{
+		impulse = btScalar(0.);
+		return;
+	}
+	btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); 
+	btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition();
+	//this jacobian entry could be re-used for all iterations
+	
+	btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+	btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+	btVector3 vel = vel1 - vel2;
+	
+
+	  btJacobianEntry jac(body1.getCenterOfMassTransform().getBasis().transpose(),
+		body2.getCenterOfMassTransform().getBasis().transpose(),
+		rel_pos1,rel_pos2,normal,body1.getInvInertiaDiagLocal(),body1.getInvMass(),
+		body2.getInvInertiaDiagLocal(),body2.getInvMass());
+
+	btScalar jacDiagAB = jac.getDiagonal();
+	btScalar jacDiagABInv = btScalar(1.) / jacDiagAB;
+	
+	  btScalar rel_vel = jac.getRelativeVelocity(
+		body1.getLinearVelocity(),
+		body1.getCenterOfMassTransform().getBasis().transpose() * body1.getAngularVelocity(),
+		body2.getLinearVelocity(),
+		body2.getCenterOfMassTransform().getBasis().transpose() * body2.getAngularVelocity()); 
+	btScalar a;
+	a=jacDiagABInv;
+
+
+	rel_vel = normal.dot(vel);
+	
+	//todo: move this into proper structure
+	btScalar contactDamping = btScalar(0.2);
+
+#ifdef ONLY_USE_LINEAR_MASS
+	btScalar massTerm = btScalar(1.) / (body1.getInvMass() + body2.getInvMass());
+	impulse = - contactDamping * rel_vel * massTerm;
+#else	
+	btScalar velocityImpulse = -contactDamping * rel_vel * jacDiagABInv;
+	impulse = velocityImpulse;
+#endif
+}
+
+
+
+//response  between two dynamic objects with friction
+btScalar resolveSingleCollision(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo)
+{
+
+	const btVector3& pos1_ = contactPoint.getPositionWorldOnA();
+	const btVector3& pos2_ = contactPoint.getPositionWorldOnB();
+   	const btVector3& normal = contactPoint.m_normalWorldOnB;
+
+	//constant over all iterations
+	btVector3 rel_pos1 = pos1_ - body1.getCenterOfMassPosition(); 
+	btVector3 rel_pos2 = pos2_ - body2.getCenterOfMassPosition();
+	
+	btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+	btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+	btVector3 vel = vel1 - vel2;
+	btScalar rel_vel;
+	rel_vel = normal.dot(vel);
+	
+	btScalar Kfps = btScalar(1.) / solverInfo.m_timeStep ;
+
+	// btScalar damping = solverInfo.m_damping ;
+	btScalar Kerp = solverInfo.m_erp;
+	btScalar Kcor = Kerp *Kfps;
+
+	btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
+	assert(cpd);
+	btScalar distance = cpd->m_penetration;
+	btScalar positionalError = Kcor *-distance;
+	btScalar velocityError = cpd->m_restitution - rel_vel;// * damping;
+
+	btScalar penetrationImpulse = positionalError * cpd->m_jacDiagABInv;
+
+	btScalar	velocityImpulse = velocityError * cpd->m_jacDiagABInv;
+
+	btScalar normalImpulse = penetrationImpulse+velocityImpulse;
+	
+	// See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse
+	btScalar oldNormalImpulse = cpd->m_appliedImpulse;
+	btScalar sum = oldNormalImpulse + normalImpulse;
+	cpd->m_appliedImpulse = btScalar(0.) > sum ? btScalar(0.): sum;
+
+	normalImpulse = cpd->m_appliedImpulse - oldNormalImpulse;
+
+#ifdef USE_INTERNAL_APPLY_IMPULSE
+	if (body1.getInvMass())
+	{
+		body1.internalApplyImpulse(contactPoint.m_normalWorldOnB*body1.getInvMass(),cpd->m_angularComponentA,normalImpulse);
+	}
+	if (body2.getInvMass())
+	{
+		body2.internalApplyImpulse(contactPoint.m_normalWorldOnB*body2.getInvMass(),cpd->m_angularComponentB,-normalImpulse);
+	}
+#else //USE_INTERNAL_APPLY_IMPULSE
+	body1.applyImpulse(normal*(normalImpulse), rel_pos1);
+	body2.applyImpulse(-normal*(normalImpulse), rel_pos2);
+#endif //USE_INTERNAL_APPLY_IMPULSE
+
+	return normalImpulse;
+}
+
+
+btScalar resolveSingleFriction(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo)
+{
+
+	(void)solverInfo;
+
+	const btVector3& pos1 = contactPoint.getPositionWorldOnA();
+	const btVector3& pos2 = contactPoint.getPositionWorldOnB();
+
+	btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); 
+	btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition();
+	
+	btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
+	assert(cpd);
+
+	btScalar combinedFriction = cpd->m_friction;
+	
+	btScalar limit = cpd->m_appliedImpulse * combinedFriction;
+	
+	if (cpd->m_appliedImpulse>btScalar(0.))
+	//friction
+	{
+		//apply friction in the 2 tangential directions
+		
+		// 1st tangent
+		btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+		btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+		btVector3 vel = vel1 - vel2;
+	
+		btScalar j1,j2;
+
+		{
+				
+			btScalar vrel = cpd->m_frictionWorldTangential0.dot(vel);
+
+			// calculate j that moves us to zero relative velocity
+			j1 = -vrel * cpd->m_jacDiagABInvTangent0;
+			btScalar oldTangentImpulse = cpd->m_accumulatedTangentImpulse0;
+			cpd->m_accumulatedTangentImpulse0 = oldTangentImpulse + j1;
+			btSetMin(cpd->m_accumulatedTangentImpulse0, limit);
+			btSetMax(cpd->m_accumulatedTangentImpulse0, -limit);
+			j1 = cpd->m_accumulatedTangentImpulse0 - oldTangentImpulse;
+
+		}
+		{
+			// 2nd tangent
+
+			btScalar vrel = cpd->m_frictionWorldTangential1.dot(vel);
+			
+			// calculate j that moves us to zero relative velocity
+			j2 = -vrel * cpd->m_jacDiagABInvTangent1;
+			btScalar oldTangentImpulse = cpd->m_accumulatedTangentImpulse1;
+			cpd->m_accumulatedTangentImpulse1 = oldTangentImpulse + j2;
+			btSetMin(cpd->m_accumulatedTangentImpulse1, limit);
+			btSetMax(cpd->m_accumulatedTangentImpulse1, -limit);
+			j2 = cpd->m_accumulatedTangentImpulse1 - oldTangentImpulse;
+		}
+
+#ifdef USE_INTERNAL_APPLY_IMPULSE
+	if (body1.getInvMass())
+	{
+		body1.internalApplyImpulse(cpd->m_frictionWorldTangential0*body1.getInvMass(),cpd->m_frictionAngularComponent0A,j1);
+		body1.internalApplyImpulse(cpd->m_frictionWorldTangential1*body1.getInvMass(),cpd->m_frictionAngularComponent1A,j2);
+	}
+	if (body2.getInvMass())
+	{
+		body2.internalApplyImpulse(cpd->m_frictionWorldTangential0*body2.getInvMass(),cpd->m_frictionAngularComponent0B,-j1);
+		body2.internalApplyImpulse(cpd->m_frictionWorldTangential1*body2.getInvMass(),cpd->m_frictionAngularComponent1B,-j2);	
+	}
+#else //USE_INTERNAL_APPLY_IMPULSE
+	body1.applyImpulse((j1 * cpd->m_frictionWorldTangential0)+(j2 * cpd->m_frictionWorldTangential1), rel_pos1);
+	body2.applyImpulse((j1 * -cpd->m_frictionWorldTangential0)+(j2 * -cpd->m_frictionWorldTangential1), rel_pos2);
+#endif //USE_INTERNAL_APPLY_IMPULSE
+
+
+	} 
+	return cpd->m_appliedImpulse;
+}
+
+
+btScalar resolveSingleFrictionOriginal(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo);
+
+btScalar resolveSingleFrictionOriginal(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo)
+{
+
+	(void)solverInfo;
+
+	const btVector3& pos1 = contactPoint.getPositionWorldOnA();
+	const btVector3& pos2 = contactPoint.getPositionWorldOnB();
+
+	btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); 
+	btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition();
+	
+	btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
+	assert(cpd);
+
+	btScalar combinedFriction = cpd->m_friction;
+	
+	btScalar limit = cpd->m_appliedImpulse * combinedFriction;
+	//if (contactPoint.m_appliedImpulse>btScalar(0.))
+	//friction
+	{
+		//apply friction in the 2 tangential directions
+		
+		{
+			// 1st tangent
+			btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+			btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+			btVector3 vel = vel1 - vel2;
+			
+			btScalar vrel = cpd->m_frictionWorldTangential0.dot(vel);
+
+			// calculate j that moves us to zero relative velocity
+			btScalar j = -vrel * cpd->m_jacDiagABInvTangent0;
+			btScalar total = cpd->m_accumulatedTangentImpulse0 + j;
+			btSetMin(total, limit);
+			btSetMax(total, -limit);
+			j = total - cpd->m_accumulatedTangentImpulse0;
+			cpd->m_accumulatedTangentImpulse0 = total;
+			body1.applyImpulse(j * cpd->m_frictionWorldTangential0, rel_pos1);
+			body2.applyImpulse(j * -cpd->m_frictionWorldTangential0, rel_pos2);
+		}
+
+				
+		{
+			// 2nd tangent
+			btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+			btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+			btVector3 vel = vel1 - vel2;
+
+			btScalar vrel = cpd->m_frictionWorldTangential1.dot(vel);
+			
+			// calculate j that moves us to zero relative velocity
+			btScalar j = -vrel * cpd->m_jacDiagABInvTangent1;
+			btScalar total = cpd->m_accumulatedTangentImpulse1 + j;
+			btSetMin(total, limit);
+			btSetMax(total, -limit);
+			j = total - cpd->m_accumulatedTangentImpulse1;
+			cpd->m_accumulatedTangentImpulse1 = total;
+			body1.applyImpulse(j * cpd->m_frictionWorldTangential1, rel_pos1);
+			body2.applyImpulse(j * -cpd->m_frictionWorldTangential1, rel_pos2);
+		}
+	} 
+	return cpd->m_appliedImpulse;
+}
+
+
+//velocity + friction
+//response  between two dynamic objects with friction
+btScalar resolveSingleCollisionCombined(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo)
+{
+
+	const btVector3& pos1 = contactPoint.getPositionWorldOnA();
+	const btVector3& pos2 = contactPoint.getPositionWorldOnB();
+   	const btVector3& normal = contactPoint.m_normalWorldOnB;
+
+	btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); 
+	btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition();
+	
+	btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+	btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+	btVector3 vel = vel1 - vel2;
+	btScalar rel_vel;
+	rel_vel = normal.dot(vel);
+	
+	btScalar Kfps = btScalar(1.) / solverInfo.m_timeStep ;
+
+	//btScalar damping = solverInfo.m_damping ;
+	btScalar Kerp = solverInfo.m_erp;
+	btScalar Kcor = Kerp *Kfps;
+
+	btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
+	assert(cpd);
+	btScalar distance = cpd->m_penetration;
+	btScalar positionalError = Kcor *-distance;
+	btScalar velocityError = cpd->m_restitution - rel_vel;// * damping;
+
+	btScalar penetrationImpulse = positionalError * cpd->m_jacDiagABInv;
+
+	btScalar	velocityImpulse = velocityError * cpd->m_jacDiagABInv;
+
+	btScalar normalImpulse = penetrationImpulse+velocityImpulse;
+	
+	// See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse
+	btScalar oldNormalImpulse = cpd->m_appliedImpulse;
+	btScalar sum = oldNormalImpulse + normalImpulse;
+	cpd->m_appliedImpulse = btScalar(0.) > sum ? btScalar(0.): sum;
+
+	normalImpulse = cpd->m_appliedImpulse - oldNormalImpulse;
+
+
+#ifdef USE_INTERNAL_APPLY_IMPULSE
+	if (body1.getInvMass())
+	{
+		body1.internalApplyImpulse(contactPoint.m_normalWorldOnB*body1.getInvMass(),cpd->m_angularComponentA,normalImpulse);
+	}
+	if (body2.getInvMass())
+	{
+		body2.internalApplyImpulse(contactPoint.m_normalWorldOnB*body2.getInvMass(),cpd->m_angularComponentB,-normalImpulse);
+	}
+#else //USE_INTERNAL_APPLY_IMPULSE
+	body1.applyImpulse(normal*(normalImpulse), rel_pos1);
+	body2.applyImpulse(-normal*(normalImpulse), rel_pos2);
+#endif //USE_INTERNAL_APPLY_IMPULSE
+
+	{
+		//friction
+		btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+		btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+		btVector3 vel = vel1 - vel2;
+	  
+		rel_vel = normal.dot(vel);
+
+
+		btVector3 lat_vel = vel - normal * rel_vel;
+		btScalar lat_rel_vel = lat_vel.length();
+
+		btScalar combinedFriction = cpd->m_friction;
+
+		if (cpd->m_appliedImpulse > 0)
+		if (lat_rel_vel > SIMD_EPSILON)
+		{
+			lat_vel /= lat_rel_vel;
+			btVector3 temp1 = body1.getInvInertiaTensorWorld() * rel_pos1.cross(lat_vel);
+			btVector3 temp2 = body2.getInvInertiaTensorWorld() * rel_pos2.cross(lat_vel);
+			btScalar friction_impulse = lat_rel_vel /
+				(body1.getInvMass() + body2.getInvMass() + lat_vel.dot(temp1.cross(rel_pos1) + temp2.cross(rel_pos2)));
+			btScalar normal_impulse = cpd->m_appliedImpulse * combinedFriction;
+
+			btSetMin(friction_impulse, normal_impulse);
+			btSetMax(friction_impulse, -normal_impulse);
+			body1.applyImpulse(lat_vel * -friction_impulse, rel_pos1);
+			body2.applyImpulse(lat_vel * friction_impulse, rel_pos2);
+		}
+	}
+
+
+
+	return normalImpulse;
+}
+
+btScalar resolveSingleFrictionEmpty(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo);
+
+btScalar resolveSingleFrictionEmpty(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo)
+{
+	(void)contactPoint;
+	(void)body1;
+	(void)body2;
+	(void)solverInfo;
+
+
+	return btScalar(0.);
+};
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactConstraint.h	(revision 2122)
@@ -0,0 +1,122 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONTACT_CONSTRAINT_H
+#define CONTACT_CONSTRAINT_H
+
+//todo: make into a proper class working with the iterative constraint solver
+
+class btRigidBody;
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btScalar.h"
+struct btContactSolverInfo;
+class btManifoldPoint;
+
+enum {
+	DEFAULT_CONTACT_SOLVER_TYPE=0,
+	CONTACT_SOLVER_TYPE1,
+	CONTACT_SOLVER_TYPE2,
+	USER_CONTACT_SOLVER_TYPE1,
+	MAX_CONTACT_SOLVER_TYPES
+};
+
+
+typedef btScalar (*ContactSolverFunc)(btRigidBody& body1,
+									 btRigidBody& body2,
+									 class btManifoldPoint& contactPoint,
+									 const btContactSolverInfo& info);
+
+///stores some extra information to each contact point. It is not in the contact point, because that want to keep the collision detection independent from the constraint solver.
+struct btConstraintPersistentData
+{
+	inline btConstraintPersistentData()
+	:m_appliedImpulse(btScalar(0.)),
+	m_prevAppliedImpulse(btScalar(0.)),
+	m_accumulatedTangentImpulse0(btScalar(0.)),
+	m_accumulatedTangentImpulse1(btScalar(0.)),
+	m_jacDiagABInv(btScalar(0.)),
+	m_persistentLifeTime(0),
+	m_restitution(btScalar(0.)),
+	m_friction(btScalar(0.)),
+	m_penetration(btScalar(0.)),
+	m_contactSolverFunc(0),
+	m_frictionSolverFunc(0)
+	{
+	}
+	
+					
+				/// total applied impulse during most recent frame
+			btScalar	m_appliedImpulse;
+			btScalar	m_prevAppliedImpulse;
+			btScalar	m_accumulatedTangentImpulse0;
+			btScalar	m_accumulatedTangentImpulse1;
+			
+			btScalar	m_jacDiagABInv;
+			btScalar	m_jacDiagABInvTangent0;
+			btScalar	m_jacDiagABInvTangent1;
+			int		m_persistentLifeTime;
+			btScalar	m_restitution;
+			btScalar	m_friction;
+			btScalar	m_penetration;
+			btVector3	m_frictionWorldTangential0;
+			btVector3	m_frictionWorldTangential1;
+
+			btVector3	m_frictionAngularComponent0A;
+			btVector3	m_frictionAngularComponent0B;
+			btVector3	m_frictionAngularComponent1A;
+			btVector3	m_frictionAngularComponent1B;
+
+			//some data doesn't need to be persistent over frames: todo: clean/reuse this
+			btVector3	m_angularComponentA;
+			btVector3	m_angularComponentB;
+		
+			ContactSolverFunc	m_contactSolverFunc;
+			ContactSolverFunc	m_frictionSolverFunc;
+
+};
+
+///bilateral constraint between two dynamic objects
+///positive distance = separation, negative distance = penetration
+void resolveSingleBilateral(btRigidBody& body1, const btVector3& pos1,
+                      btRigidBody& body2, const btVector3& pos2,
+                      btScalar distance, const btVector3& normal,btScalar& impulse ,btScalar timeStep);
+
+
+///contact constraint resolution:
+///calculate and apply impulse to satisfy non-penetration and non-negative relative velocity constraint
+///positive distance = separation, negative distance = penetration
+btScalar resolveSingleCollision(
+	btRigidBody& body1,
+	btRigidBody& body2,
+		btManifoldPoint& contactPoint,
+		 const btContactSolverInfo& info);
+
+btScalar resolveSingleFriction(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo
+		);
+
+
+
+btScalar resolveSingleCollisionCombined(
+	btRigidBody& body1,
+	btRigidBody& body2,
+	btManifoldPoint& contactPoint,
+	const btContactSolverInfo& solverInfo
+		);
+
+#endif //CONTACT_CONSTRAINT_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactSolverInfo.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactSolverInfo.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btContactSolverInfo.h	(revision 2122)
@@ -0,0 +1,75 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef CONTACT_SOLVER_INFO
+#define CONTACT_SOLVER_INFO
+
+enum	btSolverMode
+{
+	SOLVER_RANDMIZE_ORDER = 1,
+	SOLVER_FRICTION_SEPARATE = 2,
+	SOLVER_USE_WARMSTARTING = 4,
+	SOLVER_CACHE_FRIENDLY = 8
+};
+
+struct btContactSolverInfoData
+{
+	
+
+	btScalar	m_tau;
+	btScalar	m_damping;
+	btScalar	m_friction;
+	btScalar	m_timeStep;
+	btScalar	m_restitution;
+	int		m_numIterations;
+	btScalar	m_maxErrorReduction;
+	btScalar	m_sor;
+	btScalar	m_erp;//used as Baumgarte factor
+	btScalar	m_erp2;//used in Split Impulse
+	int			m_splitImpulse;
+	btScalar	m_splitImpulsePenetrationThreshold;
+	btScalar	m_linearSlop;
+	btScalar	m_warmstartingFactor;
+
+	int			m_solverMode;
+
+
+};
+
+struct btContactSolverInfo : public btContactSolverInfoData
+{
+
+	
+
+	inline btContactSolverInfo()
+	{
+		m_tau = btScalar(0.6);
+		m_damping = btScalar(1.0);
+		m_friction = btScalar(0.3);
+		m_restitution = btScalar(0.);
+		m_maxErrorReduction = btScalar(20.);
+		m_numIterations = 10;
+		m_erp = btScalar(0.2);
+		m_erp2 = btScalar(0.1);
+		m_sor = btScalar(1.3);
+		m_splitImpulse = false;
+		m_splitImpulsePenetrationThreshold = -0.02f;
+		m_linearSlop = btScalar(0.0);
+		m_warmstartingFactor=btScalar(0.85);
+		m_solverMode = SOLVER_RANDMIZE_ORDER | SOLVER_CACHE_FRIENDLY | SOLVER_USE_WARMSTARTING;
+	}
+};
+
+#endif //CONTACT_SOLVER_INFO
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp	(revision 2122)
@@ -0,0 +1,528 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+/*
+2007-09-09
+Refactored by Francisco Le?n
+email: projectileman@yahoo.com
+http://gimpact.sf.net
+*/
+
+
+#include "btGeneric6DofConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btTransformUtil.h"
+#include <new>
+
+
+static const btScalar kSign[] = { btScalar(1.0), btScalar(-1.0), btScalar(1.0) };
+static const int kAxisA[] = { 1, 0, 0 };
+static const int kAxisB[] = { 2, 2, 1 };
+#define GENERIC_D6_DISABLE_WARMSTARTING 1
+
+btScalar btGetMatrixElem(const btMatrix3x3& mat, int index);
+btScalar btGetMatrixElem(const btMatrix3x3& mat, int index)
+{
+	int i = index%3;
+	int j = index/3;
+	return mat[i][j];
+}
+
+///MatrixToEulerXYZ from http://www.geometrictools.com/LibFoundation/Mathematics/Wm4Matrix3.inl.html
+bool	matrixToEulerXYZ(const btMatrix3x3& mat,btVector3& xyz);
+bool	matrixToEulerXYZ(const btMatrix3x3& mat,btVector3& xyz)
+{
+//	// rot =  cy*cz          -cy*sz           sy
+//	//        cz*sx*sy+cx*sz  cx*cz-sx*sy*sz -cy*sx
+//	//       -cx*cz*sy+sx*sz  cz*sx+cx*sy*sz  cx*cy
+//
+
+		if (btGetMatrixElem(mat,2) < btScalar(1.0))
+		{
+			if (btGetMatrixElem(mat,2) > btScalar(-1.0))
+			{
+				xyz[0] = btAtan2(-btGetMatrixElem(mat,5),btGetMatrixElem(mat,8));
+				xyz[1] = btAsin(btGetMatrixElem(mat,2));
+				xyz[2] = btAtan2(-btGetMatrixElem(mat,1),btGetMatrixElem(mat,0));
+				return true;
+			}
+			else
+			{
+				// WARNING.  Not unique.  XA - ZA = -atan2(r10,r11)
+				xyz[0] = -btAtan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4));
+				xyz[1] = -SIMD_HALF_PI;
+				xyz[2] = btScalar(0.0);
+				return false;
+			}
+		}
+		else
+		{
+			// WARNING.  Not unique.  XAngle + ZAngle = atan2(r10,r11)
+			xyz[0] = btAtan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4));
+			xyz[1] = SIMD_HALF_PI;
+			xyz[2] = 0.0;
+
+		}
+
+
+	return false;
+}
+
+
+
+//////////////////////////// btRotationalLimitMotor ////////////////////////////////////
+
+
+int btRotationalLimitMotor::testLimitValue(btScalar test_value)
+{
+	if(m_loLimit>m_hiLimit)
+	{
+		m_currentLimit = 0;//Free from violation
+		return 0;
+	}
+
+	if (test_value < m_loLimit)
+	{
+		m_currentLimit = 1;//low limit violation
+		m_currentLimitError =  test_value - m_loLimit;
+		return 1;
+	}
+	else if (test_value> m_hiLimit)
+	{
+		m_currentLimit = 2;//High limit violation
+		m_currentLimitError = test_value - m_hiLimit;
+		return 2;
+	};
+
+	m_currentLimit = 0;//Free from violation
+	return 0;
+	
+}
+
+
+btScalar btRotationalLimitMotor::solveAngularLimits(
+		btScalar timeStep,btVector3& axis,btScalar jacDiagABInv,
+	 	btRigidBody * body0, btRigidBody * body1)
+{
+    if (needApplyTorques()==false) return 0.0f;
+
+    btScalar target_velocity = m_targetVelocity;
+    btScalar maxMotorForce = m_maxMotorForce;
+
+	//current error correction
+    if (m_currentLimit!=0)
+    {
+        target_velocity = -m_ERP*m_currentLimitError/(timeStep);
+        maxMotorForce = m_maxLimitForce;
+    }
+
+    maxMotorForce *= timeStep;
+
+    // current velocity difference
+    btVector3 vel_diff = body0->getAngularVelocity();
+    if (body1)
+    {
+        vel_diff -= body1->getAngularVelocity();
+    }
+
+
+
+    btScalar rel_vel = axis.dot(vel_diff);
+
+	// correction velocity
+    btScalar motor_relvel = m_limitSoftness*(target_velocity  - m_damping*rel_vel);
+
+
+    if ( motor_relvel < SIMD_EPSILON && motor_relvel > -SIMD_EPSILON  )
+    {
+        return 0.0f;//no need for applying force
+    }
+
+
+	// correction impulse
+    btScalar unclippedMotorImpulse = (1+m_bounce)*motor_relvel*jacDiagABInv;
+
+	// clip correction impulse
+    btScalar clippedMotorImpulse;
+
+    //todo: should clip against accumulated impulse
+    if (unclippedMotorImpulse>0.0f)
+    {
+        clippedMotorImpulse =  unclippedMotorImpulse > maxMotorForce? maxMotorForce: unclippedMotorImpulse;
+    }
+    else
+    {
+        clippedMotorImpulse =  unclippedMotorImpulse < -maxMotorForce ? -maxMotorForce: unclippedMotorImpulse;
+    }
+
+
+	// sort with accumulated impulses
+    btScalar	lo = btScalar(-1e30);
+    btScalar	hi = btScalar(1e30);
+
+    btScalar oldaccumImpulse = m_accumulatedImpulse;
+    btScalar sum = oldaccumImpulse + clippedMotorImpulse;
+    m_accumulatedImpulse = sum > hi ? btScalar(0.) : sum < lo ? btScalar(0.) : sum;
+
+    clippedMotorImpulse = m_accumulatedImpulse - oldaccumImpulse;
+
+
+
+    btVector3 motorImp = clippedMotorImpulse * axis;
+
+
+    body0->applyTorqueImpulse(motorImp);
+    if (body1) body1->applyTorqueImpulse(-motorImp);
+
+    return clippedMotorImpulse;
+
+
+}
+
+//////////////////////////// End btRotationalLimitMotor ////////////////////////////////////
+
+//////////////////////////// btTranslationalLimitMotor ////////////////////////////////////
+btScalar btTranslationalLimitMotor::solveLinearAxis(
+		btScalar timeStep,
+        btScalar jacDiagABInv,
+        btRigidBody& body1,const btVector3 &pointInA,
+        btRigidBody& body2,const btVector3 &pointInB,
+        int limit_index,
+        const btVector3 & axis_normal_on_a,
+		const btVector3 & anchorPos)
+{
+
+///find relative velocity
+//    btVector3 rel_pos1 = pointInA - body1.getCenterOfMassPosition();
+//    btVector3 rel_pos2 = pointInB - body2.getCenterOfMassPosition();
+    btVector3 rel_pos1 = anchorPos - body1.getCenterOfMassPosition();
+    btVector3 rel_pos2 = anchorPos - body2.getCenterOfMassPosition();
+
+    btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1);
+    btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2);
+    btVector3 vel = vel1 - vel2;
+
+    btScalar rel_vel = axis_normal_on_a.dot(vel);
+
+
+
+/// apply displacement correction
+
+//positional error (zeroth order error)
+    btScalar depth = -(pointInA - pointInB).dot(axis_normal_on_a);
+    btScalar	lo = btScalar(-1e30);
+    btScalar	hi = btScalar(1e30);
+
+    btScalar minLimit = m_lowerLimit[limit_index];
+    btScalar maxLimit = m_upperLimit[limit_index];
+
+    //handle the limits
+    if (minLimit < maxLimit)
+    {
+        {
+            if (depth > maxLimit)
+            {
+                depth -= maxLimit;
+                lo = btScalar(0.);
+
+            }
+            else
+            {
+                if (depth < minLimit)
+                {
+                    depth -= minLimit;
+                    hi = btScalar(0.);
+                }
+                else
+                {
+                    return 0.0f;
+                }
+            }
+        }
+    }
+
+    btScalar normalImpulse= m_limitSoftness*(m_restitution*depth/timeStep - m_damping*rel_vel) * jacDiagABInv;
+
+
+
+
+    btScalar oldNormalImpulse = m_accumulatedImpulse[limit_index];
+    btScalar sum = oldNormalImpulse + normalImpulse;
+    m_accumulatedImpulse[limit_index] = sum > hi ? btScalar(0.) : sum < lo ? btScalar(0.) : sum;
+    normalImpulse = m_accumulatedImpulse[limit_index] - oldNormalImpulse;
+
+    btVector3 impulse_vector = axis_normal_on_a * normalImpulse;
+    body1.applyImpulse( impulse_vector, rel_pos1);
+    body2.applyImpulse(-impulse_vector, rel_pos2);
+    return normalImpulse;
+}
+
+//////////////////////////// btTranslationalLimitMotor ////////////////////////////////////
+
+
+btGeneric6DofConstraint::btGeneric6DofConstraint()
+        :btTypedConstraint(D6_CONSTRAINT_TYPE),
+		m_useLinearReferenceFrameA(true)
+{
+}
+
+btGeneric6DofConstraint::btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA)
+        : btTypedConstraint(D6_CONSTRAINT_TYPE, rbA, rbB)
+        , m_frameInA(frameInA)
+        , m_frameInB(frameInB),
+		m_useLinearReferenceFrameA(useLinearReferenceFrameA)
+{
+
+}
+
+
+
+
+
+void btGeneric6DofConstraint::calculateAngleInfo()
+{
+	btMatrix3x3 relative_frame = m_calculatedTransformA.getBasis().inverse()*m_calculatedTransformB.getBasis();
+
+	matrixToEulerXYZ(relative_frame,m_calculatedAxisAngleDiff);
+
+
+
+	// in euler angle mode we do not actually constrain the angular velocity
+  // along the axes axis[0] and axis[2] (although we do use axis[1]) :
+  //
+  //    to get			constrain w2-w1 along		...not
+  //    ------			---------------------		------
+  //    d(angle[0])/dt = 0	ax[1] x ax[2]			ax[0]
+  //    d(angle[1])/dt = 0	ax[1]
+  //    d(angle[2])/dt = 0	ax[0] x ax[1]			ax[2]
+  //
+  // constraining w2-w1 along an axis 'a' means that a'*(w2-w1)=0.
+  // to prove the result for angle[0], write the expression for angle[0] from
+  // GetInfo1 then take the derivative. to prove this for angle[2] it is
+  // easier to take the euler rate expression for d(angle[2])/dt with respect
+  // to the components of w and set that to 0.
+
+	btVector3 axis0 = m_calculatedTransformB.getBasis().getColumn(0);
+	btVector3 axis2 = m_calculatedTransformA.getBasis().getColumn(2);
+
+	m_calculatedAxis[1] = axis2.cross(axis0);
+	m_calculatedAxis[0] = m_calculatedAxis[1].cross(axis2);
+	m_calculatedAxis[2] = axis0.cross(m_calculatedAxis[1]);
+
+
+//    if(m_debugDrawer)
+//    {
+//
+//    	char buff[300];
+//		sprintf(buff,"\n X: %.2f ; Y: %.2f ; Z: %.2f ",
+//		m_calculatedAxisAngleDiff[0],
+//		m_calculatedAxisAngleDiff[1],
+//		m_calculatedAxisAngleDiff[2]);
+//    	m_debugDrawer->reportErrorWarning(buff);
+//    }
+
+}
+
+void btGeneric6DofConstraint::calculateTransforms()
+{
+    m_calculatedTransformA = m_rbA.getCenterOfMassTransform() * m_frameInA;
+    m_calculatedTransformB = m_rbB.getCenterOfMassTransform() * m_frameInB;
+
+    calculateAngleInfo();
+}
+
+
+void btGeneric6DofConstraint::buildLinearJacobian(
+    btJacobianEntry & jacLinear,const btVector3 & normalWorld,
+    const btVector3 & pivotAInW,const btVector3 & pivotBInW)
+{
+    new (&jacLinear) btJacobianEntry(
+        m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+        m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+        pivotAInW - m_rbA.getCenterOfMassPosition(),
+        pivotBInW - m_rbB.getCenterOfMassPosition(),
+        normalWorld,
+        m_rbA.getInvInertiaDiagLocal(),
+        m_rbA.getInvMass(),
+        m_rbB.getInvInertiaDiagLocal(),
+        m_rbB.getInvMass());
+
+}
+
+void btGeneric6DofConstraint::buildAngularJacobian(
+    btJacobianEntry & jacAngular,const btVector3 & jointAxisW)
+{
+    new (&jacAngular)	btJacobianEntry(jointAxisW,
+                                      m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+                                      m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+                                      m_rbA.getInvInertiaDiagLocal(),
+                                      m_rbB.getInvInertiaDiagLocal());
+
+}
+
+bool btGeneric6DofConstraint::testAngularLimitMotor(int axis_index)
+{
+    btScalar angle = m_calculatedAxisAngleDiff[axis_index];
+
+    //test limits
+    m_angularLimits[axis_index].testLimitValue(angle);
+    return m_angularLimits[axis_index].needApplyTorques();
+}
+
+void btGeneric6DofConstraint::buildJacobian()
+{
+
+	// Clear accumulated impulses for the next simulation step
+    m_linearLimits.m_accumulatedImpulse.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
+    int i;
+    for(i = 0; i < 3; i++)
+    {
+        m_angularLimits[i].m_accumulatedImpulse = btScalar(0.);
+    }
+    //calculates transform
+    calculateTransforms();
+
+//  const btVector3& pivotAInW = m_calculatedTransformA.getOrigin();
+//  const btVector3& pivotBInW = m_calculatedTransformB.getOrigin();
+	calcAnchorPos();
+	btVector3 pivotAInW = m_AnchorPos;
+	btVector3 pivotBInW = m_AnchorPos;
+
+// not used here
+//    btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition();
+//    btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition();
+
+    btVector3 normalWorld;
+    //linear part
+    for (i=0;i<3;i++)
+    {
+        if (m_linearLimits.isLimited(i))
+        {
+			if (m_useLinearReferenceFrameA)
+	            normalWorld = m_calculatedTransformA.getBasis().getColumn(i);
+			else
+	            normalWorld = m_calculatedTransformB.getBasis().getColumn(i);
+
+            buildLinearJacobian(
+                m_jacLinear[i],normalWorld ,
+                pivotAInW,pivotBInW);
+
+        }
+    }
+
+    // angular part
+    for (i=0;i<3;i++)
+    {
+        //calculates error angle
+        if (testAngularLimitMotor(i))
+        {
+            normalWorld = this->getAxis(i);
+            // Create angular atom
+            buildAngularJacobian(m_jacAng[i],normalWorld);
+        }
+    }
+
+
+}
+
+
+void btGeneric6DofConstraint::solveConstraint(btScalar	timeStep)
+{
+    m_timeStep = timeStep;
+
+    //calculateTransforms();
+
+    int i;
+
+    // linear
+
+    btVector3 pointInA = m_calculatedTransformA.getOrigin();
+	btVector3 pointInB = m_calculatedTransformB.getOrigin();
+
+	btScalar jacDiagABInv;
+	btVector3 linear_axis;
+    for (i=0;i<3;i++)
+    {
+        if (m_linearLimits.isLimited(i))
+        {
+            jacDiagABInv = btScalar(1.) / m_jacLinear[i].getDiagonal();
+
+			if (m_useLinearReferenceFrameA)
+	            linear_axis = m_calculatedTransformA.getBasis().getColumn(i);
+			else
+	            linear_axis = m_calculatedTransformB.getBasis().getColumn(i);
+
+            m_linearLimits.solveLinearAxis(
+            	m_timeStep,
+            	jacDiagABInv,
+            	m_rbA,pointInA,
+                m_rbB,pointInB,
+                i,linear_axis, m_AnchorPos);
+
+        }
+    }
+
+    // angular
+    btVector3 angular_axis;
+    btScalar angularJacDiagABInv;
+    for (i=0;i<3;i++)
+    {
+        if (m_angularLimits[i].needApplyTorques())
+        {
+
+			// get axis
+			angular_axis = getAxis(i);
+
+			angularJacDiagABInv = btScalar(1.) / m_jacAng[i].getDiagonal();
+
+			m_angularLimits[i].solveAngularLimits(m_timeStep,angular_axis,angularJacDiagABInv, &m_rbA,&m_rbB);
+        }
+    }
+}
+
+void	btGeneric6DofConstraint::updateRHS(btScalar	timeStep)
+{
+    (void)timeStep;
+
+}
+
+btVector3 btGeneric6DofConstraint::getAxis(int axis_index) const
+{
+    return m_calculatedAxis[axis_index];
+}
+
+btScalar btGeneric6DofConstraint::getAngle(int axis_index) const
+{
+    return m_calculatedAxisAngleDiff[axis_index];
+}
+
+void btGeneric6DofConstraint::calcAnchorPos(void)
+{
+	btScalar imA = m_rbA.getInvMass();
+	btScalar imB = m_rbB.getInvMass();
+	btScalar weight;
+	if(imB == btScalar(0.0))
+	{
+		weight = btScalar(1.0);
+	}
+	else
+	{
+		weight = imA / (imA + imB);
+	}
+	const btVector3& pA = m_calculatedTransformA.getOrigin();
+	const btVector3& pB = m_calculatedTransformB.getOrigin();
+	m_AnchorPos = pA * weight + pB * (btScalar(1.0) - weight);
+	return;
+} // btGeneric6DofConstraint::calcAnchorPos()
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h	(revision 2122)
@@ -0,0 +1,437 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+/*
+2007-09-09
+btGeneric6DofConstraint Refactored by Francisco Le?n
+email: projectileman@yahoo.com
+http://gimpact.sf.net
+*/
+
+
+#ifndef GENERIC_6DOF_CONSTRAINT_H
+#define GENERIC_6DOF_CONSTRAINT_H
+
+#include "LinearMath/btVector3.h"
+#include "btJacobianEntry.h"
+#include "btTypedConstraint.h"
+
+class btRigidBody;
+
+
+//! Rotation Limit structure for generic joints
+class btRotationalLimitMotor
+{
+public:
+    //! limit_parameters
+    //!@{
+    btScalar m_loLimit;//!< joint limit
+    btScalar m_hiLimit;//!< joint limit
+    btScalar m_targetVelocity;//!< target motor velocity
+    btScalar m_maxMotorForce;//!< max force on motor
+    btScalar m_maxLimitForce;//!< max force on limit
+    btScalar m_damping;//!< Damping.
+    btScalar m_limitSoftness;//! Relaxation factor
+    btScalar m_ERP;//!< Error tolerance factor when joint is at limit
+    btScalar m_bounce;//!< restitution factor
+    bool m_enableMotor;
+
+    //!@}
+
+    //! temp_variables
+    //!@{
+    btScalar m_currentLimitError;//!  How much is violated this limit
+    int m_currentLimit;//!< 0=free, 1=at lo limit, 2=at hi limit
+    btScalar m_accumulatedImpulse;
+    //!@}
+
+    btRotationalLimitMotor()
+    {
+    	m_accumulatedImpulse = 0.f;
+        m_targetVelocity = 0;
+        m_maxMotorForce = 0.1f;
+        m_maxLimitForce = 300.0f;
+        m_loLimit = -SIMD_INFINITY;
+        m_hiLimit = SIMD_INFINITY;
+        m_ERP = 0.5f;
+        m_bounce = 0.0f;
+        m_damping = 1.0f;
+        m_limitSoftness = 0.5f;
+        m_currentLimit = 0;
+        m_currentLimitError = 0;
+        m_enableMotor = false;
+    }
+
+    btRotationalLimitMotor(const btRotationalLimitMotor & limot)
+    {
+        m_targetVelocity = limot.m_targetVelocity;
+        m_maxMotorForce = limot.m_maxMotorForce;
+        m_limitSoftness = limot.m_limitSoftness;
+        m_loLimit = limot.m_loLimit;
+        m_hiLimit = limot.m_hiLimit;
+        m_ERP = limot.m_ERP;
+        m_bounce = limot.m_bounce;
+        m_currentLimit = limot.m_currentLimit;
+        m_currentLimitError = limot.m_currentLimitError;
+        m_enableMotor = limot.m_enableMotor;
+    }
+
+
+
+	//! Is limited
+    bool isLimited()
+    {
+    	if(m_loLimit>=m_hiLimit) return false;
+    	return true;
+    }
+
+	//! Need apply correction
+    bool needApplyTorques()
+    {
+    	if(m_currentLimit == 0 && m_enableMotor == false) return false;
+    	return true;
+    }
+
+	//! calculates  error
+	/*!
+	calculates m_currentLimit and m_currentLimitError.
+	*/
+	int testLimitValue(btScalar test_value);
+
+	//! apply the correction impulses for two bodies
+    btScalar solveAngularLimits(btScalar timeStep,btVector3& axis, btScalar jacDiagABInv,btRigidBody * body0, btRigidBody * body1);
+
+
+};
+
+
+
+class btTranslationalLimitMotor
+{
+public:
+	btVector3 m_lowerLimit;//!< the constraint lower limits
+    btVector3 m_upperLimit;//!< the constraint upper limits
+    btVector3 m_accumulatedImpulse;
+    //! Linear_Limit_parameters
+    //!@{
+    btScalar	m_limitSoftness;//!< Softness for linear limit
+    btScalar	m_damping;//!< Damping for linear limit
+    btScalar	m_restitution;//! Bounce parameter for linear limit
+    //!@}
+
+    btTranslationalLimitMotor()
+    {
+    	m_lowerLimit.setValue(0.f,0.f,0.f);
+    	m_upperLimit.setValue(0.f,0.f,0.f);
+    	m_accumulatedImpulse.setValue(0.f,0.f,0.f);
+
+    	m_limitSoftness = 0.7f;
+    	m_damping = btScalar(1.0f);
+    	m_restitution = btScalar(0.5f);
+    }
+
+    btTranslationalLimitMotor(const btTranslationalLimitMotor & other )
+    {
+    	m_lowerLimit = other.m_lowerLimit;
+    	m_upperLimit = other.m_upperLimit;
+    	m_accumulatedImpulse = other.m_accumulatedImpulse;
+
+    	m_limitSoftness = other.m_limitSoftness ;
+    	m_damping = other.m_damping;
+    	m_restitution = other.m_restitution;
+    }
+
+    //! Test limit
+	/*!
+    - free means upper < lower,
+    - locked means upper == lower
+    - limited means upper > lower
+    - limitIndex: first 3 are linear, next 3 are angular
+    */
+    inline bool	isLimited(int limitIndex)
+    {
+       return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
+    }
+
+
+    btScalar solveLinearAxis(
+    	btScalar timeStep,
+        btScalar jacDiagABInv,
+        btRigidBody& body1,const btVector3 &pointInA,
+        btRigidBody& body2,const btVector3 &pointInB,
+        int limit_index,
+        const btVector3 & axis_normal_on_a,
+		const btVector3 & anchorPos);
+
+
+};
+
+/// btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space
+/*!
+btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or 'locked'.
+currently this limit supports rotational motors<br>
+<ul>
+<li> For Linear limits, use btGeneric6DofConstraint.setLinearUpperLimit, btGeneric6DofConstraint.setLinearLowerLimit. You can set the parameters with the btTranslationalLimitMotor structure accsesible through the btGeneric6DofConstraint.getTranslationalLimitMotor method.
+At this moment translational motors are not supported. May be in the future. </li>
+
+<li> For Angular limits, use the btRotationalLimitMotor structure for configuring the limit.
+This is accessible through btGeneric6DofConstraint.getLimitMotor method,
+This brings support for limit parameters and motors. </li>
+
+<li> Angulars limits have these possible ranges:
+<table border=1 >
+<tr
+
+	<td><b>AXIS</b></td>
+	<td><b>MIN ANGLE</b></td>
+	<td><b>MAX ANGLE</b></td>
+	<td>X</td>
+		<td>-PI</td>
+		<td>PI</td>
+	<td>Y</td>
+		<td>-PI/2</td>
+		<td>PI/2</td>
+	<td>Z</td>
+		<td>-PI/2</td>
+		<td>PI/2</td>
+</tr>
+</table>
+</li>
+</ul>
+
+*/
+class btGeneric6DofConstraint : public btTypedConstraint
+{
+protected:
+
+	//! relative_frames
+    //!@{
+	btTransform	m_frameInA;//!< the constraint space w.r.t body A
+    btTransform	m_frameInB;//!< the constraint space w.r.t body B
+    //!@}
+
+    //! Jacobians
+    //!@{
+    btJacobianEntry	m_jacLinear[3];//!< 3 orthogonal linear constraints
+    btJacobianEntry	m_jacAng[3];//!< 3 orthogonal angular constraints
+    //!@}
+
+	//! Linear_Limit_parameters
+    //!@{
+    btTranslationalLimitMotor m_linearLimits;
+    //!@}
+
+
+    //! hinge_parameters
+    //!@{
+    btRotationalLimitMotor m_angularLimits[3];
+	//!@}
+
+
+protected:
+    //! temporal variables
+    //!@{
+    btScalar m_timeStep;
+    btTransform m_calculatedTransformA;
+    btTransform m_calculatedTransformB;
+    btVector3 m_calculatedAxisAngleDiff;
+    btVector3 m_calculatedAxis[3];
+    
+	btVector3 m_AnchorPos; // point betwen pivots of bodies A and B to solve linear axes
+
+    bool	m_useLinearReferenceFrameA;
+    
+    //!@}
+
+    btGeneric6DofConstraint&	operator=(btGeneric6DofConstraint&	other)
+    {
+        btAssert(0);
+        (void) other;
+        return *this;
+    }
+
+
+
+    void buildLinearJacobian(
+        btJacobianEntry & jacLinear,const btVector3 & normalWorld,
+        const btVector3 & pivotAInW,const btVector3 & pivotBInW);
+
+    void buildAngularJacobian(btJacobianEntry & jacAngular,const btVector3 & jointAxisW);
+
+
+	//! calcs the euler angles between the two bodies.
+    void calculateAngleInfo();
+
+
+
+public:
+    btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
+
+    btGeneric6DofConstraint();
+
+	//! Calcs global transform of the offsets
+	/*!
+	Calcs the global transform for the joint offset for body A an B, and also calcs the agle differences between the bodies.
+	\sa btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofConstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleInfo
+	*/
+    void calculateTransforms();
+
+	//! Gets the global transform of the offset for body A
+    /*!
+    \sa btGeneric6DofConstraint.getFrameOffsetA, btGeneric6DofConstraint.getFrameOffsetB, btGeneric6DofConstraint.calculateAngleInfo.
+    */
+    const btTransform & getCalculatedTransformA() const
+    {
+    	return m_calculatedTransformA;
+    }
+
+    //! Gets the global transform of the offset for body B
+    /*!
+    \sa btGeneric6DofConstraint.getFrameOffsetA, btGeneric6DofConstraint.getFrameOffsetB, btGeneric6DofConstraint.calculateAngleInfo.
+    */
+    const btTransform & getCalculatedTransformB() const
+    {
+    	return m_calculatedTransformB;
+    }
+
+    const btTransform & getFrameOffsetA() const
+    {
+    	return m_frameInA;
+    }
+
+    const btTransform & getFrameOffsetB() const
+    {
+    	return m_frameInB;
+    }
+
+
+    btTransform & getFrameOffsetA()
+    {
+    	return m_frameInA;
+    }
+
+    btTransform & getFrameOffsetB()
+    {
+    	return m_frameInB;
+    }
+
+
+	//! performs Jacobian calculation, and also calculates angle differences and axis
+    virtual void	buildJacobian();
+
+    virtual	void	solveConstraint(btScalar	timeStep);
+
+    void	updateRHS(btScalar	timeStep);
+
+	//! Get the rotation axis in global coordinates
+	/*!
+	\pre btGeneric6DofConstraint.buildJacobian must be called previously.
+	*/
+    btVector3 getAxis(int axis_index) const;
+
+    //! Get the relative Euler angle
+    /*!
+	\pre btGeneric6DofConstraint.buildJacobian must be called previously.
+	*/
+    btScalar getAngle(int axis_index) const;
+
+	//! Test angular limit.
+	/*!
+	Calculates angular correction and returns true if limit needs to be corrected.
+	\pre btGeneric6DofConstraint.buildJacobian must be called previously.
+	*/
+    bool testAngularLimitMotor(int axis_index);
+
+    void	setLinearLowerLimit(const btVector3& linearLower)
+    {
+    	m_linearLimits.m_lowerLimit = linearLower;
+    }
+
+    void	setLinearUpperLimit(const btVector3& linearUpper)
+    {
+    	m_linearLimits.m_upperLimit = linearUpper;
+    }
+
+    void	setAngularLowerLimit(const btVector3& angularLower)
+    {
+        m_angularLimits[0].m_loLimit = angularLower.getX();
+        m_angularLimits[1].m_loLimit = angularLower.getY();
+        m_angularLimits[2].m_loLimit = angularLower.getZ();
+    }
+
+    void	setAngularUpperLimit(const btVector3& angularUpper)
+    {
+        m_angularLimits[0].m_hiLimit = angularUpper.getX();
+        m_angularLimits[1].m_hiLimit = angularUpper.getY();
+        m_angularLimits[2].m_hiLimit = angularUpper.getZ();
+    }
+
+	//! Retrieves the angular limit informacion
+    btRotationalLimitMotor * getRotationalLimitMotor(int index)
+    {
+    	return &m_angularLimits[index];
+    }
+
+    //! Retrieves the  limit informacion
+    btTranslationalLimitMotor * getTranslationalLimitMotor()
+    {
+    	return &m_linearLimits;
+    }
+
+    //first 3 are linear, next 3 are angular
+    void setLimit(int axis, btScalar lo, btScalar hi)
+    {
+    	if(axis<3)
+    	{
+    		m_linearLimits.m_lowerLimit[axis] = lo;
+    		m_linearLimits.m_upperLimit[axis] = hi;
+    	}
+    	else
+    	{
+    		m_angularLimits[axis-3].m_loLimit = lo;
+    		m_angularLimits[axis-3].m_hiLimit = hi;
+    	}
+    }
+
+	//! Test limit
+	/*!
+    - free means upper < lower,
+    - locked means upper == lower
+    - limited means upper > lower
+    - limitIndex: first 3 are linear, next 3 are angular
+    */
+    bool	isLimited(int limitIndex)
+    {
+    	if(limitIndex<3)
+    	{
+			return m_linearLimits.isLimited(limitIndex);
+
+    	}
+        return m_angularLimits[limitIndex-3].isLimited();
+    }
+
+    const btRigidBody& getRigidBodyA() const
+    {
+        return m_rbA;
+    }
+    const btRigidBody& getRigidBodyB() const
+    {
+        return m_rbB;
+    }
+
+	virtual void calcAnchorPos(void); // overridable
+
+};
+
+#endif //GENERIC_6DOF_CONSTRAINT_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp	(revision 2122)
@@ -0,0 +1,403 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btHingeConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btTransformUtil.h"
+#include "LinearMath/btMinMax.h"
+#include <new>
+
+
+btHingeConstraint::btHingeConstraint()
+: btTypedConstraint (HINGE_CONSTRAINT_TYPE),
+m_enableAngularMotor(false)
+{
+}
+
+btHingeConstraint::btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB,
+									 btVector3& axisInA,btVector3& axisInB)
+									 :btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA,rbB),
+									 m_angularOnly(false),
+									 m_enableAngularMotor(false)
+{
+	m_rbAFrame.getOrigin() = pivotInA;
+	
+	// since no frame is given, assume this to be zero angle and just pick rb transform axis
+	btVector3 rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(0);
+
+	btVector3 rbAxisA2;
+	btScalar projection = axisInA.dot(rbAxisA1);
+	if (projection >= 1.0f - SIMD_EPSILON) {
+		rbAxisA1 = -rbA.getCenterOfMassTransform().getBasis().getColumn(2);
+		rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1);
+	} else if (projection <= -1.0f + SIMD_EPSILON) {
+		rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(2);
+		rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1);      
+	} else {
+		rbAxisA2 = axisInA.cross(rbAxisA1);
+		rbAxisA1 = rbAxisA2.cross(axisInA);
+	}
+
+	m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(),
+									rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(),
+									rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() );
+
+	btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB);
+	btVector3 rbAxisB1 =  quatRotate(rotationArc,rbAxisA1);
+	btVector3 rbAxisB2 =  axisInB.cross(rbAxisB1);	
+	
+	m_rbBFrame.getOrigin() = pivotInB;
+	m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),-axisInB.getX(),
+									rbAxisB1.getY(),rbAxisB2.getY(),-axisInB.getY(),
+									rbAxisB1.getZ(),rbAxisB2.getZ(),-axisInB.getZ() );
+	
+	//start with free
+	m_lowerLimit = btScalar(1e30);
+	m_upperLimit = btScalar(-1e30);
+	m_biasFactor = 0.3f;
+	m_relaxationFactor = 1.0f;
+	m_limitSoftness = 0.9f;
+	m_solveLimit = false;
+
+}
+
+
+
+btHingeConstraint::btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA)
+:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA), m_angularOnly(false), m_enableAngularMotor(false)
+{
+
+	// since no frame is given, assume this to be zero angle and just pick rb transform axis
+	// fixed axis in worldspace
+	btVector3 rbAxisA1, rbAxisA2;
+	btPlaneSpace1(axisInA, rbAxisA1, rbAxisA2);
+
+	m_rbAFrame.getOrigin() = pivotInA;
+	m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(),
+									rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(),
+									rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() );
+
+	btVector3 axisInB = rbA.getCenterOfMassTransform().getBasis() * -axisInA;
+
+	btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB);
+	btVector3 rbAxisB1 =  quatRotate(rotationArc,rbAxisA1);
+	btVector3 rbAxisB2 = axisInB.cross(rbAxisB1);
+
+
+	m_rbBFrame.getOrigin() = rbA.getCenterOfMassTransform()(pivotInA);
+	m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),axisInB.getX(),
+									rbAxisB1.getY(),rbAxisB2.getY(),axisInB.getY(),
+									rbAxisB1.getZ(),rbAxisB2.getZ(),axisInB.getZ() );
+	
+	//start with free
+	m_lowerLimit = btScalar(1e30);
+	m_upperLimit = btScalar(-1e30);
+	m_biasFactor = 0.3f;
+	m_relaxationFactor = 1.0f;
+	m_limitSoftness = 0.9f;
+	m_solveLimit = false;
+}
+
+btHingeConstraint::btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, 
+								     const btTransform& rbAFrame, const btTransform& rbBFrame)
+:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA,rbB),m_rbAFrame(rbAFrame),m_rbBFrame(rbBFrame),
+m_angularOnly(false),
+m_enableAngularMotor(false)
+{
+	// flip axis
+	m_rbBFrame.getBasis()[0][2] *= btScalar(-1.);
+	m_rbBFrame.getBasis()[1][2] *= btScalar(-1.);
+	m_rbBFrame.getBasis()[2][2] *= btScalar(-1.);
+
+	//start with free
+	m_lowerLimit = btScalar(1e30);
+	m_upperLimit = btScalar(-1e30);
+	m_biasFactor = 0.3f;
+	m_relaxationFactor = 1.0f;
+	m_limitSoftness = 0.9f;
+	m_solveLimit = false;
+}			
+
+
+
+btHingeConstraint::btHingeConstraint(btRigidBody& rbA, const btTransform& rbAFrame)
+:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA),m_rbAFrame(rbAFrame),m_rbBFrame(rbAFrame),
+m_angularOnly(false),
+m_enableAngularMotor(false)
+{
+	///not providing rigidbody B means implicitly using worldspace for body B
+
+	// flip axis
+	m_rbBFrame.getBasis()[0][2] *= btScalar(-1.);
+	m_rbBFrame.getBasis()[1][2] *= btScalar(-1.);
+	m_rbBFrame.getBasis()[2][2] *= btScalar(-1.);
+
+	m_rbBFrame.getOrigin() = m_rbA.getCenterOfMassTransform()(m_rbAFrame.getOrigin());
+
+	//start with free
+	m_lowerLimit = btScalar(1e30);
+	m_upperLimit = btScalar(-1e30);	
+	m_biasFactor = 0.3f;
+	m_relaxationFactor = 1.0f;
+	m_limitSoftness = 0.9f;
+	m_solveLimit = false;
+}
+
+void	btHingeConstraint::buildJacobian()
+{
+	m_appliedImpulse = btScalar(0.);
+
+	if (!m_angularOnly)
+	{
+		btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin();
+		btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin();
+		btVector3 relPos = pivotBInW - pivotAInW;
+
+		btVector3 normal[3];
+		if (relPos.length2() > SIMD_EPSILON)
+		{
+			normal[0] = relPos.normalized();
+		}
+		else
+		{
+			normal[0].setValue(btScalar(1.0),0,0);
+		}
+
+		btPlaneSpace1(normal[0], normal[1], normal[2]);
+
+		for (int i=0;i<3;i++)
+		{
+			new (&m_jac[i]) btJacobianEntry(
+				m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+				m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+				pivotAInW - m_rbA.getCenterOfMassPosition(),
+				pivotBInW - m_rbB.getCenterOfMassPosition(),
+				normal[i],
+				m_rbA.getInvInertiaDiagLocal(),
+				m_rbA.getInvMass(),
+				m_rbB.getInvInertiaDiagLocal(),
+				m_rbB.getInvMass());
+		}
+	}
+
+	//calculate two perpendicular jointAxis, orthogonal to hingeAxis
+	//these two jointAxis require equal angular velocities for both bodies
+
+	//this is unused for now, it's a todo
+	btVector3 jointAxis0local;
+	btVector3 jointAxis1local;
+	
+	btPlaneSpace1(m_rbAFrame.getBasis().getColumn(2),jointAxis0local,jointAxis1local);
+
+	getRigidBodyA().getCenterOfMassTransform().getBasis() * m_rbAFrame.getBasis().getColumn(2);
+	btVector3 jointAxis0 = getRigidBodyA().getCenterOfMassTransform().getBasis() * jointAxis0local;
+	btVector3 jointAxis1 = getRigidBodyA().getCenterOfMassTransform().getBasis() * jointAxis1local;
+	btVector3 hingeAxisWorld = getRigidBodyA().getCenterOfMassTransform().getBasis() * m_rbAFrame.getBasis().getColumn(2);
+		
+	new (&m_jacAng[0])	btJacobianEntry(jointAxis0,
+		m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+		m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+		m_rbA.getInvInertiaDiagLocal(),
+		m_rbB.getInvInertiaDiagLocal());
+
+	new (&m_jacAng[1])	btJacobianEntry(jointAxis1,
+		m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+		m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+		m_rbA.getInvInertiaDiagLocal(),
+		m_rbB.getInvInertiaDiagLocal());
+
+	new (&m_jacAng[2])	btJacobianEntry(hingeAxisWorld,
+		m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+		m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+		m_rbA.getInvInertiaDiagLocal(),
+		m_rbB.getInvInertiaDiagLocal());
+
+
+	// Compute limit information
+	btScalar hingeAngle = getHingeAngle();  
+
+	//set bias, sign, clear accumulator
+	m_correction = btScalar(0.);
+	m_limitSign = btScalar(0.);
+	m_solveLimit = false;
+	m_accLimitImpulse = btScalar(0.);
+
+//	if (m_lowerLimit < m_upperLimit)
+	if (m_lowerLimit <= m_upperLimit)
+	{
+//		if (hingeAngle <= m_lowerLimit*m_limitSoftness)
+		if (hingeAngle <= m_lowerLimit)
+		{
+			m_correction = (m_lowerLimit - hingeAngle);
+			m_limitSign = 1.0f;
+			m_solveLimit = true;
+		} 
+//		else if (hingeAngle >= m_upperLimit*m_limitSoftness)
+		else if (hingeAngle >= m_upperLimit)
+		{
+			m_correction = m_upperLimit - hingeAngle;
+			m_limitSign = -1.0f;
+			m_solveLimit = true;
+		}
+	}
+
+	//Compute K = J*W*J' for hinge axis
+	btVector3 axisA =  getRigidBodyA().getCenterOfMassTransform().getBasis() *  m_rbAFrame.getBasis().getColumn(2);
+	m_kHinge =   1.0f / (getRigidBodyA().computeAngularImpulseDenominator(axisA) +
+			             getRigidBodyB().computeAngularImpulseDenominator(axisA));
+
+}
+
+void	btHingeConstraint::solveConstraint(btScalar	timeStep)
+{
+
+	btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin();
+	btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin();
+
+	btScalar tau = btScalar(0.3);
+
+	//linear part
+	if (!m_angularOnly)
+	{
+		btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); 
+		btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition();
+
+		btVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1);
+		btVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2);
+		btVector3 vel = vel1 - vel2;
+
+		for (int i=0;i<3;i++)
+		{		
+			const btVector3& normal = m_jac[i].m_linearJointAxis;
+			btScalar jacDiagABInv = btScalar(1.) / m_jac[i].getDiagonal();
+
+			btScalar rel_vel;
+			rel_vel = normal.dot(vel);
+			//positional error (zeroth order error)
+			btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal
+			btScalar impulse = depth*tau/timeStep  * jacDiagABInv -  rel_vel * jacDiagABInv;
+			m_appliedImpulse += impulse;
+			btVector3 impulse_vector = normal * impulse;
+			m_rbA.applyImpulse(impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition());
+			m_rbB.applyImpulse(-impulse_vector, pivotBInW - m_rbB.getCenterOfMassPosition());
+		}
+	}
+
+	
+	{
+		///solve angular part
+
+		// get axes in world space
+		btVector3 axisA =  getRigidBodyA().getCenterOfMassTransform().getBasis() *  m_rbAFrame.getBasis().getColumn(2);
+		btVector3 axisB =  getRigidBodyB().getCenterOfMassTransform().getBasis() *  m_rbBFrame.getBasis().getColumn(2);
+
+		const btVector3& angVelA = getRigidBodyA().getAngularVelocity();
+		const btVector3& angVelB = getRigidBodyB().getAngularVelocity();
+
+		btVector3 angVelAroundHingeAxisA = axisA * axisA.dot(angVelA);
+		btVector3 angVelAroundHingeAxisB = axisB * axisB.dot(angVelB);
+
+		btVector3 angAorthog = angVelA - angVelAroundHingeAxisA;
+		btVector3 angBorthog = angVelB - angVelAroundHingeAxisB;
+		btVector3 velrelOrthog = angAorthog-angBorthog;
+		{
+			//solve orthogonal angular velocity correction
+			btScalar relaxation = btScalar(1.);
+			btScalar len = velrelOrthog.length();
+			if (len > btScalar(0.00001))
+			{
+				btVector3 normal = velrelOrthog.normalized();
+				btScalar denom = getRigidBodyA().computeAngularImpulseDenominator(normal) +
+					getRigidBodyB().computeAngularImpulseDenominator(normal);
+				// scale for mass and relaxation
+				//todo:  expose this 0.9 factor to developer
+				velrelOrthog *= (btScalar(1.)/denom) * m_relaxationFactor;
+			}
+
+			//solve angular positional correction
+			btVector3 angularError = -axisA.cross(axisB) *(btScalar(1.)/timeStep);
+			btScalar len2 = angularError.length();
+			if (len2>btScalar(0.00001))
+			{
+				btVector3 normal2 = angularError.normalized();
+				btScalar denom2 = getRigidBodyA().computeAngularImpulseDenominator(normal2) +
+						getRigidBodyB().computeAngularImpulseDenominator(normal2);
+				angularError *= (btScalar(1.)/denom2) * relaxation;
+			}
+
+			m_rbA.applyTorqueImpulse(-velrelOrthog+angularError);
+			m_rbB.applyTorqueImpulse(velrelOrthog-angularError);
+
+			// solve limit
+			if (m_solveLimit)
+			{
+				btScalar amplitude = ( (angVelB - angVelA).dot( axisA )*m_relaxationFactor + m_correction* (btScalar(1.)/timeStep)*m_biasFactor  ) * m_limitSign;
+
+				btScalar impulseMag = amplitude * m_kHinge;
+
+				// Clamp the accumulated impulse
+				btScalar temp = m_accLimitImpulse;
+				m_accLimitImpulse = btMax(m_accLimitImpulse + impulseMag, btScalar(0) );
+				impulseMag = m_accLimitImpulse - temp;
+
+
+				btVector3 impulse = axisA * impulseMag * m_limitSign;
+				m_rbA.applyTorqueImpulse(impulse);
+				m_rbB.applyTorqueImpulse(-impulse);
+			}
+		}
+
+		//apply motor
+		if (m_enableAngularMotor) 
+		{
+			//todo: add limits too
+			btVector3 angularLimit(0,0,0);
+
+			btVector3 velrel = angVelAroundHingeAxisA - angVelAroundHingeAxisB;
+			btScalar projRelVel = velrel.dot(axisA);
+
+			btScalar desiredMotorVel = m_motorTargetVelocity;
+			btScalar motor_relvel = desiredMotorVel - projRelVel;
+
+			btScalar unclippedMotorImpulse = m_kHinge * motor_relvel;;
+			//todo: should clip against accumulated impulse
+			btScalar clippedMotorImpulse = unclippedMotorImpulse > m_maxMotorImpulse ? m_maxMotorImpulse : unclippedMotorImpulse;
+			clippedMotorImpulse = clippedMotorImpulse < -m_maxMotorImpulse ? -m_maxMotorImpulse : clippedMotorImpulse;
+			btVector3 motorImp = clippedMotorImpulse * axisA;
+
+			m_rbA.applyTorqueImpulse(motorImp+angularLimit);
+			m_rbB.applyTorqueImpulse(-motorImp-angularLimit);
+			
+		}
+	}
+
+}
+
+void	btHingeConstraint::updateRHS(btScalar	timeStep)
+{
+	(void)timeStep;
+
+}
+
+btScalar btHingeConstraint::getHingeAngle()
+{
+	const btVector3 refAxis0  = getRigidBodyA().getCenterOfMassTransform().getBasis() * m_rbAFrame.getBasis().getColumn(0);
+	const btVector3 refAxis1  = getRigidBodyA().getCenterOfMassTransform().getBasis() * m_rbAFrame.getBasis().getColumn(1);
+	const btVector3 swingAxis = getRigidBodyB().getCenterOfMassTransform().getBasis() * m_rbBFrame.getBasis().getColumn(1);
+
+	return btAtan2Fast( swingAxis.dot(refAxis0), swingAxis.dot(refAxis1)  );
+}
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.h	(revision 2122)
@@ -0,0 +1,158 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/* Hinge Constraint by Dirk Gregorius. Limits added by Marcus Hennix at Starbreeze Studios */
+
+#ifndef HINGECONSTRAINT_H
+#define HINGECONSTRAINT_H
+
+#include "LinearMath/btVector3.h"
+#include "btJacobianEntry.h"
+#include "btTypedConstraint.h"
+
+class btRigidBody;
+
+/// hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space
+/// axis defines the orientation of the hinge axis
+class btHingeConstraint : public btTypedConstraint
+{
+#ifdef IN_PARALLELL_SOLVER
+public:
+#endif
+	btJacobianEntry	m_jac[3]; //3 orthogonal linear constraints
+	btJacobianEntry	m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor
+
+	btTransform m_rbAFrame; // constraint axii. Assumes z is hinge axis.
+	btTransform m_rbBFrame;
+
+	btScalar	m_motorTargetVelocity;
+	btScalar	m_maxMotorImpulse;
+
+	btScalar	m_limitSoftness; 
+	btScalar	m_biasFactor; 
+	btScalar    m_relaxationFactor; 
+
+	btScalar    m_lowerLimit;	
+	btScalar    m_upperLimit;	
+	
+	btScalar	m_kHinge;
+
+	btScalar	m_limitSign;
+	btScalar	m_correction;
+
+	btScalar	m_accLimitImpulse;
+
+	bool		m_angularOnly;
+	bool		m_enableAngularMotor;
+	bool		m_solveLimit;
+
+	
+public:
+
+	btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB, btVector3& axisInA,btVector3& axisInB);
+
+	btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA);
+	
+	btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame);
+
+	btHingeConstraint(btRigidBody& rbA,const btTransform& rbAFrame);
+
+	btHingeConstraint();
+
+	virtual void	buildJacobian();
+
+	virtual	void	solveConstraint(btScalar	timeStep);
+
+	void	updateRHS(btScalar	timeStep);
+
+	const btRigidBody& getRigidBodyA() const
+	{
+		return m_rbA;
+	}
+	const btRigidBody& getRigidBodyB() const
+	{
+		return m_rbB;
+	}
+
+	void	setAngularOnly(bool angularOnly)
+	{
+		m_angularOnly = angularOnly;
+	}
+
+	void	enableAngularMotor(bool enableMotor,btScalar targetVelocity,btScalar maxMotorImpulse)
+	{
+		m_enableAngularMotor  = enableMotor;
+		m_motorTargetVelocity = targetVelocity;
+		m_maxMotorImpulse = maxMotorImpulse;
+	}
+
+	void	setLimit(btScalar low,btScalar high,btScalar _softness = 0.9f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
+	{
+		m_lowerLimit = low;
+		m_upperLimit = high;
+
+		m_limitSoftness =  _softness;
+		m_biasFactor = _biasFactor;
+		m_relaxationFactor = _relaxationFactor;
+
+	}
+
+	btScalar	getLowerLimit() const
+	{
+		return m_lowerLimit;
+	}
+
+	btScalar	getUpperLimit() const
+	{
+		return m_upperLimit;
+	}
+
+
+	btScalar getHingeAngle();
+
+
+	const btTransform& getAFrame() { return m_rbAFrame; };	
+	const btTransform& getBFrame() { return m_rbBFrame; };
+
+	inline int getSolveLimit()
+	{
+		return m_solveLimit;
+	}
+
+	inline btScalar getLimitSign()
+	{
+		return m_limitSign;
+	}
+
+	inline bool getAngularOnly() 
+	{ 
+		return m_angularOnly; 
+	}
+	inline bool getEnableAngularMotor() 
+	{ 
+		return m_enableAngularMotor; 
+	}
+	inline btScalar getMotorTargetVelosity() 
+	{ 
+		return m_motorTargetVelocity; 
+	}
+	inline btScalar getMaxMotorImpulse() 
+	{ 
+		return m_maxMotorImpulse; 
+	}
+
+};
+
+#endif //HINGECONSTRAINT_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btJacobianEntry.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btJacobianEntry.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btJacobianEntry.h	(revision 2122)
@@ -0,0 +1,156 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef JACOBIAN_ENTRY_H
+#define JACOBIAN_ENTRY_H
+
+#include "LinearMath/btVector3.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+
+//notes:
+// Another memory optimization would be to store m_1MinvJt in the remaining 3 w components
+// which makes the btJacobianEntry memory layout 16 bytes
+// if you only are interested in angular part, just feed massInvA and massInvB zero
+
+/// Jacobian entry is an abstraction that allows to describe constraints
+/// it can be used in combination with a constraint solver
+/// Can be used to relate the effect of an impulse to the constraint error
+class btJacobianEntry
+{
+public:
+	btJacobianEntry() {};
+	//constraint between two different rigidbodies
+	btJacobianEntry(
+		const btMatrix3x3& world2A,
+		const btMatrix3x3& world2B,
+		const btVector3& rel_pos1,const btVector3& rel_pos2,
+		const btVector3& jointAxis,
+		const btVector3& inertiaInvA, 
+		const btScalar massInvA,
+		const btVector3& inertiaInvB,
+		const btScalar massInvB)
+		:m_linearJointAxis(jointAxis)
+	{
+		m_aJ = world2A*(rel_pos1.cross(m_linearJointAxis));
+		m_bJ = world2B*(rel_pos2.cross(-m_linearJointAxis));
+		m_0MinvJt	= inertiaInvA * m_aJ;
+		m_1MinvJt = inertiaInvB * m_bJ;
+		m_Adiag = massInvA + m_0MinvJt.dot(m_aJ) + massInvB + m_1MinvJt.dot(m_bJ);
+
+		btAssert(m_Adiag > btScalar(0.0));
+	}
+
+	//angular constraint between two different rigidbodies
+	btJacobianEntry(const btVector3& jointAxis,
+		const btMatrix3x3& world2A,
+		const btMatrix3x3& world2B,
+		const btVector3& inertiaInvA,
+		const btVector3& inertiaInvB)
+		:m_linearJointAxis(btVector3(btScalar(0.),btScalar(0.),btScalar(0.)))
+	{
+		m_aJ= world2A*jointAxis;
+		m_bJ = world2B*-jointAxis;
+		m_0MinvJt	= inertiaInvA * m_aJ;
+		m_1MinvJt = inertiaInvB * m_bJ;
+		m_Adiag =  m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
+
+		btAssert(m_Adiag > btScalar(0.0));
+	}
+
+	//angular constraint between two different rigidbodies
+	btJacobianEntry(const btVector3& axisInA,
+		const btVector3& axisInB,
+		const btVector3& inertiaInvA,
+		const btVector3& inertiaInvB)
+		: m_linearJointAxis(btVector3(btScalar(0.),btScalar(0.),btScalar(0.)))
+		, m_aJ(axisInA)
+		, m_bJ(-axisInB)
+	{
+		m_0MinvJt	= inertiaInvA * m_aJ;
+		m_1MinvJt = inertiaInvB * m_bJ;
+		m_Adiag =  m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
+
+		btAssert(m_Adiag > btScalar(0.0));
+	}
+
+	//constraint on one rigidbody
+	btJacobianEntry(
+		const btMatrix3x3& world2A,
+		const btVector3& rel_pos1,const btVector3& rel_pos2,
+		const btVector3& jointAxis,
+		const btVector3& inertiaInvA, 
+		const btScalar massInvA)
+		:m_linearJointAxis(jointAxis)
+	{
+		m_aJ= world2A*(rel_pos1.cross(jointAxis));
+		m_bJ = world2A*(rel_pos2.cross(-jointAxis));
+		m_0MinvJt	= inertiaInvA * m_aJ;
+		m_1MinvJt = btVector3(btScalar(0.),btScalar(0.),btScalar(0.));
+		m_Adiag = massInvA + m_0MinvJt.dot(m_aJ);
+
+		btAssert(m_Adiag > btScalar(0.0));
+	}
+
+	btScalar	getDiagonal() const { return m_Adiag; }
+
+	// for two constraints on the same rigidbody (for example vehicle friction)
+	btScalar	getNonDiagonal(const btJacobianEntry& jacB, const btScalar massInvA) const
+	{
+		const btJacobianEntry& jacA = *this;
+		btScalar lin = massInvA * jacA.m_linearJointAxis.dot(jacB.m_linearJointAxis);
+		btScalar ang = jacA.m_0MinvJt.dot(jacB.m_aJ);
+		return lin + ang;
+	}
+
+	
+
+	// for two constraints on sharing two same rigidbodies (for example two contact points between two rigidbodies)
+	btScalar	getNonDiagonal(const btJacobianEntry& jacB,const btScalar massInvA,const btScalar massInvB) const
+	{
+		const btJacobianEntry& jacA = *this;
+		btVector3 lin = jacA.m_linearJointAxis * jacB.m_linearJointAxis;
+		btVector3 ang0 = jacA.m_0MinvJt * jacB.m_aJ;
+		btVector3 ang1 = jacA.m_1MinvJt * jacB.m_bJ;
+		btVector3 lin0 = massInvA * lin ;
+		btVector3 lin1 = massInvB * lin;
+		btVector3 sum = ang0+ang1+lin0+lin1;
+		return sum[0]+sum[1]+sum[2];
+	}
+
+	btScalar getRelativeVelocity(const btVector3& linvelA,const btVector3& angvelA,const btVector3& linvelB,const btVector3& angvelB)
+	{
+		btVector3 linrel = linvelA - linvelB;
+		btVector3 angvela  = angvelA * m_aJ;
+		btVector3 angvelb  = angvelB * m_bJ;
+		linrel *= m_linearJointAxis;
+		angvela += angvelb;
+		angvela += linrel;
+		btScalar rel_vel2 = angvela[0]+angvela[1]+angvela[2];
+		return rel_vel2 + SIMD_EPSILON;
+	}
+//private:
+
+	btVector3	m_linearJointAxis;
+	btVector3	m_aJ;
+	btVector3	m_bJ;
+	btVector3	m_0MinvJt;
+	btVector3	m_1MinvJt;
+	//Optimization: can be stored in the w/last component of one of the vectors
+	btScalar	m_Adiag;
+
+};
+
+#endif //JACOBIAN_ENTRY_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp	(revision 2122)
@@ -0,0 +1,127 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btPoint2PointConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include <new>
+
+
+
+btPoint2PointConstraint::btPoint2PointConstraint()
+:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE)
+{
+}
+
+btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB)
+:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB)
+{
+
+}
+
+
+btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA)
+:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA))
+{
+	
+}
+
+void	btPoint2PointConstraint::buildJacobian()
+{
+	m_appliedImpulse = btScalar(0.);
+
+	btVector3	normal(0,0,0);
+
+	for (int i=0;i<3;i++)
+	{
+		normal[i] = 1;
+		new (&m_jac[i]) btJacobianEntry(
+			m_rbA.getCenterOfMassTransform().getBasis().transpose(),
+			m_rbB.getCenterOfMassTransform().getBasis().transpose(),
+			m_rbA.getCenterOfMassTransform()*m_pivotInA - m_rbA.getCenterOfMassPosition(),
+			m_rbB.getCenterOfMassTransform()*m_pivotInB - m_rbB.getCenterOfMassPosition(),
+			normal,
+			m_rbA.getInvInertiaDiagLocal(),
+			m_rbA.getInvMass(),
+			m_rbB.getInvInertiaDiagLocal(),
+			m_rbB.getInvMass());
+		normal[i] = 0;
+	}
+
+}
+
+void	btPoint2PointConstraint::solveConstraint(btScalar	timeStep)
+{
+	btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA;
+	btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB;
+
+
+	btVector3 normal(0,0,0);
+	
+
+//	btVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity();
+//	btVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity();
+
+	for (int i=0;i<3;i++)
+	{		
+		normal[i] = 1;
+		btScalar jacDiagABInv = btScalar(1.) / m_jac[i].getDiagonal();
+
+		btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); 
+		btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition();
+		//this jacobian entry could be re-used for all iterations
+		
+		btVector3 vel1 = m_rbA.getVelocityInLocalPoint(rel_pos1);
+		btVector3 vel2 = m_rbB.getVelocityInLocalPoint(rel_pos2);
+		btVector3 vel = vel1 - vel2;
+		
+		btScalar rel_vel;
+		rel_vel = normal.dot(vel);
+
+	/*
+		//velocity error (first order error)
+		btScalar rel_vel = m_jac[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA,
+														m_rbB.getLinearVelocity(),angvelB);
+	*/
+	
+		//positional error (zeroth order error)
+		btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal
+		
+		btScalar impulse = depth*m_setting.m_tau/timeStep  * jacDiagABInv -  m_setting.m_damping * rel_vel * jacDiagABInv;
+
+		btScalar impulseClamp = m_setting.m_impulseClamp;
+		if (impulseClamp > 0)
+		{
+			if (impulse < -impulseClamp) 
+				impulse = -impulseClamp;
+			if (impulse > impulseClamp) 
+				impulse = impulseClamp;
+		}
+
+		m_appliedImpulse+=impulse;
+		btVector3 impulse_vector = normal * impulse;
+		m_rbA.applyImpulse(impulse_vector, pivotAInW - m_rbA.getCenterOfMassPosition());
+		m_rbB.applyImpulse(-impulse_vector, pivotBInW - m_rbB.getCenterOfMassPosition());
+		
+		normal[i] = 0;
+	}
+}
+
+void	btPoint2PointConstraint::updateRHS(btScalar	timeStep)
+{
+	(void)timeStep;
+
+}
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h	(revision 2122)
@@ -0,0 +1,91 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef POINT2POINTCONSTRAINT_H
+#define POINT2POINTCONSTRAINT_H
+
+#include "LinearMath/btVector3.h"
+#include "btJacobianEntry.h"
+#include "btTypedConstraint.h"
+
+class btRigidBody;
+
+struct	btConstraintSetting
+{
+	btConstraintSetting()	:
+		m_tau(btScalar(0.3)),
+		m_damping(btScalar(1.)),
+		m_impulseClamp(btScalar(0.))
+	{
+	}
+	btScalar		m_tau;
+	btScalar		m_damping;
+	btScalar		m_impulseClamp;
+};
+
+/// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space
+class btPoint2PointConstraint : public btTypedConstraint
+{
+#ifdef IN_PARALLELL_SOLVER
+public:
+#endif
+	btJacobianEntry	m_jac[3]; //3 orthogonal linear constraints
+	
+	btVector3	m_pivotInA;
+	btVector3	m_pivotInB;
+	
+	
+	
+public:
+
+	btConstraintSetting	m_setting;
+
+	btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB);
+
+	btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA);
+
+	btPoint2PointConstraint();
+
+	virtual void	buildJacobian();
+
+
+	virtual	void	solveConstraint(btScalar	timeStep);
+
+	void	updateRHS(btScalar	timeStep);
+
+	void	setPivotA(const btVector3& pivotA)
+	{
+		m_pivotInA = pivotA;
+	}
+
+	void	setPivotB(const btVector3& pivotB)
+	{
+		m_pivotInB = pivotB;
+	}
+
+	const btVector3& getPivotInA() const
+	{
+		return m_pivotInA;
+	}
+
+	const btVector3& getPivotInB() const
+	{
+		return m_pivotInB;
+	}
+
+
+};
+
+#endif //POINT2POINTCONSTRAINT_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp	(revision 2122)
@@ -0,0 +1,1422 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+//#define COMPUTE_IMPULSE_DENOM 1
+//It is not necessary (redundant) to refresh contact manifolds, this refresh has been moved to the collision algorithms.
+//#define FORCE_REFESH_CONTACT_MANIFOLDS 1
+
+#include "btSequentialImpulseConstraintSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "btContactConstraint.h"
+#include "btSolve2LinearConstraint.h"
+#include "btContactSolverInfo.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "btJacobianEntry.h"
+#include "LinearMath/btMinMax.h"
+#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
+#include <new>
+#include "LinearMath/btStackAlloc.h"
+#include "LinearMath/btQuickprof.h"
+#include "btSolverBody.h"
+#include "btSolverConstraint.h"
+
+
+#include "LinearMath/btAlignedObjectArray.h"
+
+
+int totalCpd = 0;
+
+int	gTotalContactPoints = 0;
+
+struct	btOrderIndex
+{
+	int	m_manifoldIndex;
+	int	m_pointIndex;
+};
+
+
+
+#define SEQUENTIAL_IMPULSE_MAX_SOLVER_POINTS 16384
+static btOrderIndex	gOrder[SEQUENTIAL_IMPULSE_MAX_SOLVER_POINTS];
+
+
+unsigned long btSequentialImpulseConstraintSolver::btRand2()
+{
+  m_btSeed2 = (1664525L*m_btSeed2 + 1013904223L) & 0xffffffff;
+  return m_btSeed2;
+}
+
+
+
+//See ODE: adam's all-int straightforward(?) dRandInt (0..n-1)
+int btSequentialImpulseConstraintSolver::btRandInt2 (int n)
+{
+  // seems good; xor-fold and modulus
+  const unsigned long un = static_cast<unsigned long>(n);
+  unsigned long r = btRand2();
+
+  // note: probably more aggressive than it needs to be -- might be
+  //       able to get away without one or two of the innermost branches.
+  if (un <= 0x00010000UL) {
+    r ^= (r >> 16);
+    if (un <= 0x00000100UL) {
+      r ^= (r >> 8);
+      if (un <= 0x00000010UL) {
+        r ^= (r >> 4);
+        if (un <= 0x00000004UL) {
+          r ^= (r >> 2);
+          if (un <= 0x00000002UL) {
+            r ^= (r >> 1);
+          }
+        }
+     }
+    }
+   }
+
+  return (int) (r % un);
+}
+
+
+
+
+bool  MyContactDestroyedCallback(void* userPersistentData);
+bool  MyContactDestroyedCallback(void* userPersistentData)
+{
+	assert (userPersistentData);
+	btConstraintPersistentData* cpd = (btConstraintPersistentData*)userPersistentData;
+	btAlignedFree(cpd);
+	totalCpd--;
+	//printf("totalCpd = %i. DELETED Ptr %x\n",totalCpd,userPersistentData);
+	return true;
+}
+
+
+
+btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver()
+:m_btSeed2(0)
+{
+	gContactDestroyedCallback = &MyContactDestroyedCallback;
+
+	//initialize default friction/contact funcs
+	int i,j;
+	for (i=0;i<MAX_CONTACT_SOLVER_TYPES;i++)
+		for (j=0;j<MAX_CONTACT_SOLVER_TYPES;j++)
+		{
+
+			m_contactDispatch[i][j] = resolveSingleCollision;
+			m_frictionDispatch[i][j] = resolveSingleFriction;
+		}
+}
+
+btSequentialImpulseConstraintSolver::~btSequentialImpulseConstraintSolver()
+{
+
+}
+
+void	initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject);
+void	initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject)
+{
+	btRigidBody* rb = btRigidBody::upcast(collisionObject);
+	if (rb)
+	{
+		solverBody->m_angularVelocity = rb->getAngularVelocity() ;
+		solverBody->m_centerOfMassPosition = collisionObject->getWorldTransform().getOrigin();
+		solverBody->m_friction = collisionObject->getFriction();
+		solverBody->m_invMass = rb->getInvMass();
+		solverBody->m_linearVelocity = rb->getLinearVelocity();
+		solverBody->m_originalBody = rb;
+		solverBody->m_angularFactor = rb->getAngularFactor();
+	} else
+	{
+		solverBody->m_angularVelocity.setValue(0,0,0);
+		solverBody->m_centerOfMassPosition = collisionObject->getWorldTransform().getOrigin();
+		solverBody->m_friction = collisionObject->getFriction();
+		solverBody->m_invMass = 0.f;
+		solverBody->m_linearVelocity.setValue(0,0,0);
+		solverBody->m_originalBody = 0;
+		solverBody->m_angularFactor = 1.f;
+	}
+	solverBody->m_pushVelocity.setValue(0.f,0.f,0.f);
+	solverBody->m_turnVelocity.setValue(0.f,0.f,0.f);
+}
+
+
+int		gNumSplitImpulseRecoveries = 0;
+
+btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
+btScalar restitutionCurve(btScalar rel_vel, btScalar restitution)
+{
+	btScalar rest = restitution * -rel_vel;
+	return rest;
+}
+
+
+void	resolveSplitPenetrationImpulseCacheFriendly(
+        btSolverBody& body1,
+        btSolverBody& body2,
+        const btSolverConstraint& contactConstraint,
+        const btContactSolverInfo& solverInfo);
+
+//SIMD_FORCE_INLINE
+void	resolveSplitPenetrationImpulseCacheFriendly(
+        btSolverBody& body1,
+        btSolverBody& body2,
+        const btSolverConstraint& contactConstraint,
+        const btContactSolverInfo& solverInfo)
+{
+        (void)solverInfo;
+
+		if (contactConstraint.m_penetration < solverInfo.m_splitImpulsePenetrationThreshold)
+        {
+
+				gNumSplitImpulseRecoveries++;
+                btScalar normalImpulse;
+
+                //  Optimized version of projected relative velocity, use precomputed cross products with normal
+                //      body1.getVelocityInLocalPoint(contactConstraint.m_rel_posA,vel1);
+                //      body2.getVelocityInLocalPoint(contactConstraint.m_rel_posB,vel2);
+                //      btVector3 vel = vel1 - vel2;
+                //      btScalar  rel_vel = contactConstraint.m_contactNormal.dot(vel);
+
+                btScalar rel_vel;
+                btScalar vel1Dotn = contactConstraint.m_contactNormal.dot(body1.m_pushVelocity)
+                + contactConstraint.m_relpos1CrossNormal.dot(body1.m_turnVelocity);
+                btScalar vel2Dotn = contactConstraint.m_contactNormal.dot(body2.m_pushVelocity)
+                + contactConstraint.m_relpos2CrossNormal.dot(body2.m_turnVelocity);
+
+                rel_vel = vel1Dotn-vel2Dotn;
+
+
+				btScalar positionalError = -contactConstraint.m_penetration * solverInfo.m_erp2/solverInfo.m_timeStep;
+                //      btScalar positionalError = contactConstraint.m_penetration;
+
+                btScalar velocityError = contactConstraint.m_restitution - rel_vel;// * damping;
+
+                btScalar penetrationImpulse = positionalError * contactConstraint.m_jacDiagABInv;
+                btScalar        velocityImpulse = velocityError * contactConstraint.m_jacDiagABInv;
+                normalImpulse = penetrationImpulse+velocityImpulse;
+
+                // See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse
+                btScalar oldNormalImpulse = contactConstraint.m_appliedPushImpulse;
+                btScalar sum = oldNormalImpulse + normalImpulse;
+                contactConstraint.m_appliedPushImpulse = btScalar(0.) > sum ? btScalar(0.): sum;
+
+                normalImpulse = contactConstraint.m_appliedPushImpulse - oldNormalImpulse;
+
+				body1.internalApplyPushImpulse(contactConstraint.m_contactNormal*body1.m_invMass, contactConstraint.m_angularComponentA,normalImpulse);
+               
+				body2.internalApplyPushImpulse(contactConstraint.m_contactNormal*body2.m_invMass, contactConstraint.m_angularComponentB,-normalImpulse);
+               
+        }
+
+}
+
+
+//velocity + friction
+//response  between two dynamic objects with friction
+
+btScalar resolveSingleCollisionCombinedCacheFriendly(
+	btSolverBody& body1,
+	btSolverBody& body2,
+	const btSolverConstraint& contactConstraint,
+	const btContactSolverInfo& solverInfo);
+
+//SIMD_FORCE_INLINE 
+btScalar resolveSingleCollisionCombinedCacheFriendly(
+	btSolverBody& body1,
+	btSolverBody& body2,
+	const btSolverConstraint& contactConstraint,
+	const btContactSolverInfo& solverInfo)
+{
+	(void)solverInfo;
+
+	btScalar normalImpulse;
+
+	{
+
+		
+		//  Optimized version of projected relative velocity, use precomputed cross products with normal
+		//	body1.getVelocityInLocalPoint(contactConstraint.m_rel_posA,vel1);
+		//	body2.getVelocityInLocalPoint(contactConstraint.m_rel_posB,vel2);
+		//	btVector3 vel = vel1 - vel2;
+		//	btScalar  rel_vel = contactConstraint.m_contactNormal.dot(vel);
+
+		btScalar rel_vel;
+		btScalar vel1Dotn = contactConstraint.m_contactNormal.dot(body1.m_linearVelocity) 
+					+ contactConstraint.m_relpos1CrossNormal.dot(body1.m_angularVelocity);
+		btScalar vel2Dotn = contactConstraint.m_contactNormal.dot(body2.m_linearVelocity) 
+					+ contactConstraint.m_relpos2CrossNormal.dot(body2.m_angularVelocity);
+
+		rel_vel = vel1Dotn-vel2Dotn;
+
+		btScalar positionalError = 0.f;
+		if (!solverInfo.m_splitImpulse || (contactConstraint.m_penetration > solverInfo.m_splitImpulsePenetrationThreshold))
+		{
+ 			positionalError = -contactConstraint.m_penetration * solverInfo.m_erp/solverInfo.m_timeStep;
+		}
+
+		btScalar velocityError = contactConstraint.m_restitution - rel_vel;// * damping;
+
+		btScalar penetrationImpulse = positionalError * contactConstraint.m_jacDiagABInv;
+		btScalar	velocityImpulse = velocityError * contactConstraint.m_jacDiagABInv;
+		normalImpulse = penetrationImpulse+velocityImpulse;
+		
+		
+		// See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse
+		btScalar oldNormalImpulse = contactConstraint.m_appliedImpulse;
+		btScalar sum = oldNormalImpulse + normalImpulse;
+		contactConstraint.m_appliedImpulse = btScalar(0.) > sum ? btScalar(0.): sum;
+
+		normalImpulse = contactConstraint.m_appliedImpulse - oldNormalImpulse;
+
+		body1.internalApplyImpulse(contactConstraint.m_contactNormal*body1.m_invMass,
+				contactConstraint.m_angularComponentA,normalImpulse);
+		
+		body2.internalApplyImpulse(contactConstraint.m_contactNormal*body2.m_invMass,
+				contactConstraint.m_angularComponentB,-normalImpulse);
+	}
+
+	return normalImpulse;
+}
+
+
+#ifndef NO_FRICTION_TANGENTIALS
+
+btScalar resolveSingleFrictionCacheFriendly(
+	btSolverBody& body1,
+	btSolverBody& body2,
+	const btSolverConstraint& contactConstraint,
+	const btContactSolverInfo& solverInfo,
+	btScalar appliedNormalImpulse);
+
+//SIMD_FORCE_INLINE 
+btScalar resolveSingleFrictionCacheFriendly(
+	btSolverBody& body1,
+	btSolverBody& body2,
+	const btSolverConstraint& contactConstraint,
+	const btContactSolverInfo& solverInfo,
+	btScalar appliedNormalImpulse)
+{
+	(void)solverInfo;
+
+	
+	const btScalar combinedFriction = contactConstraint.m_friction;
+	
+	const btScalar limit = appliedNormalImpulse * combinedFriction;
+	
+	if (appliedNormalImpulse>btScalar(0.))
+	//friction
+	{
+		
+		btScalar j1;
+		{
+
+			btScalar rel_vel;
+			const btScalar vel1Dotn = contactConstraint.m_contactNormal.dot(body1.m_linearVelocity) 
+						+ contactConstraint.m_relpos1CrossNormal.dot(body1.m_angularVelocity);
+			const btScalar vel2Dotn = contactConstraint.m_contactNormal.dot(body2.m_linearVelocity) 
+				+ contactConstraint.m_relpos2CrossNormal.dot(body2.m_angularVelocity);
+			rel_vel = vel1Dotn-vel2Dotn;
+
+			// calculate j that moves us to zero relative velocity
+			j1 = -rel_vel * contactConstraint.m_jacDiagABInv;
+#define CLAMP_ACCUMULATED_FRICTION_IMPULSE 1
+#ifdef CLAMP_ACCUMULATED_FRICTION_IMPULSE
+			btScalar oldTangentImpulse = contactConstraint.m_appliedImpulse;
+			contactConstraint.m_appliedImpulse = oldTangentImpulse + j1;
+			
+			if (limit < contactConstraint.m_appliedImpulse)
+			{
+				contactConstraint.m_appliedImpulse = limit;
+			} else
+			{
+				if (contactConstraint.m_appliedImpulse < -limit)
+					contactConstraint.m_appliedImpulse = -limit;
+			}
+			j1 = contactConstraint.m_appliedImpulse - oldTangentImpulse;
+#else
+			if (limit < j1)
+			{
+				j1 = limit;
+			} else
+			{
+				if (j1 < -limit)
+					j1 = -limit;
+			}
+
+#endif //CLAMP_ACCUMULATED_FRICTION_IMPULSE
+
+			//GEN_set_min(contactConstraint.m_appliedImpulse, limit);
+			//GEN_set_max(contactConstraint.m_appliedImpulse, -limit);
+
+			
+
+		}
+	
+		body1.internalApplyImpulse(contactConstraint.m_contactNormal*body1.m_invMass,contactConstraint.m_angularComponentA,j1);
+		
+		body2.internalApplyImpulse(contactConstraint.m_contactNormal*body2.m_invMass,contactConstraint.m_angularComponentB,-j1);
+
+	} 
+	return 0.f;
+}
+
+
+#else
+
+//velocity + friction
+//response  between two dynamic objects with friction
+btScalar resolveSingleFrictionCacheFriendly(
+	btSolverBody& body1,
+	btSolverBody& body2,
+	btSolverConstraint& contactConstraint,
+	const btContactSolverInfo& solverInfo)
+{
+
+	btVector3 vel1;
+	btVector3 vel2;
+	btScalar normalImpulse(0.f);
+
+	{
+		const btVector3& normal = contactConstraint.m_contactNormal;
+		if (contactConstraint.m_penetration < 0.f)
+			return 0.f;
+
+
+		body1.getVelocityInLocalPoint(contactConstraint.m_rel_posA,vel1);
+		body2.getVelocityInLocalPoint(contactConstraint.m_rel_posB,vel2);
+		btVector3 vel = vel1 - vel2;
+		btScalar rel_vel;
+		rel_vel = normal.dot(vel);
+
+		btVector3 lat_vel = vel - normal * rel_vel;
+		btScalar lat_rel_vel = lat_vel.length2();
+
+		btScalar combinedFriction = contactConstraint.m_friction;
+		const btVector3& rel_pos1 = contactConstraint.m_rel_posA;
+		const btVector3& rel_pos2 = contactConstraint.m_rel_posB;
+
+
+		if (lat_rel_vel > SIMD_EPSILON*SIMD_EPSILON)
+		{
+			lat_rel_vel = btSqrt(lat_rel_vel);
+
+			lat_vel /= lat_rel_vel;
+			btVector3 temp1 = body1.m_invInertiaWorld * rel_pos1.cross(lat_vel);
+			btVector3 temp2 = body2.m_invInertiaWorld * rel_pos2.cross(lat_vel);
+			btScalar friction_impulse = lat_rel_vel /
+				(body1.m_invMass + body2.m_invMass + lat_vel.dot(temp1.cross(rel_pos1) + temp2.cross(rel_pos2)));
+			btScalar normal_impulse = contactConstraint.m_appliedImpulse * combinedFriction;
+
+			GEN_set_min(friction_impulse, normal_impulse);
+			GEN_set_max(friction_impulse, -normal_impulse);
+			body1.applyImpulse(lat_vel * -friction_impulse, rel_pos1);
+			body2.applyImpulse(lat_vel * friction_impulse, rel_pos2);
+		}
+	}
+
+	return normalImpulse;
+}
+
+#endif //NO_FRICTION_TANGENTIALS
+
+
+
+
+
+void	btSequentialImpulseConstraintSolver::addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation)
+{
+
+	btRigidBody* body0=btRigidBody::upcast(colObj0);
+	btRigidBody* body1=btRigidBody::upcast(colObj1);
+
+	btSolverConstraint& solverConstraint = m_tmpSolverFrictionConstraintPool.expand();
+	solverConstraint.m_contactNormal = normalAxis;
+
+	solverConstraint.m_solverBodyIdA = solverBodyIdA;
+	solverConstraint.m_solverBodyIdB = solverBodyIdB;
+	solverConstraint.m_constraintType = btSolverConstraint::BT_SOLVER_FRICTION_1D;
+	solverConstraint.m_frictionIndex = frictionIndex;
+
+	solverConstraint.m_friction = cp.m_combinedFriction;
+	solverConstraint.m_originalContactPoint = 0;
+
+	solverConstraint.m_appliedImpulse = btScalar(0.);
+	solverConstraint.m_appliedPushImpulse = 0.f;
+	solverConstraint.m_penetration = 0.f;
+	{
+		btVector3 ftorqueAxis1 = rel_pos1.cross(solverConstraint.m_contactNormal);
+		solverConstraint.m_relpos1CrossNormal = ftorqueAxis1;
+		solverConstraint.m_angularComponentA = body0 ? body0->getInvInertiaTensorWorld()*ftorqueAxis1 : btVector3(0,0,0);
+	}
+	{
+		btVector3 ftorqueAxis1 = rel_pos2.cross(solverConstraint.m_contactNormal);
+		solverConstraint.m_relpos2CrossNormal = ftorqueAxis1;
+		solverConstraint.m_angularComponentB = body1 ? body1->getInvInertiaTensorWorld()*ftorqueAxis1 : btVector3(0,0,0);
+	}
+
+#ifdef COMPUTE_IMPULSE_DENOM
+	btScalar denom0 = rb0->computeImpulseDenominator(pos1,solverConstraint.m_contactNormal);
+	btScalar denom1 = rb1->computeImpulseDenominator(pos2,solverConstraint.m_contactNormal);
+#else
+	btVector3 vec;
+	btScalar denom0 = 0.f;
+	btScalar denom1 = 0.f;
+	if (body0)
+	{
+		vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1);
+		denom0 = body0->getInvMass() + normalAxis.dot(vec);
+	}
+	if (body1)
+	{
+		vec = ( solverConstraint.m_angularComponentB).cross(rel_pos2);
+		denom1 = body1->getInvMass() + normalAxis.dot(vec);
+	}
+
+
+#endif //COMPUTE_IMPULSE_DENOM
+	btScalar denom = relaxation/(denom0+denom1);
+	solverConstraint.m_jacDiagABInv = denom;
+
+
+}
+
+
+
+btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** /*bodies */,int /*numBodies */,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc)
+{
+	BT_PROFILE("solveGroupCacheFriendlySetup");
+	(void)stackAlloc;
+	(void)debugDrawer;
+
+
+	if (!(numConstraints + numManifolds))
+	{
+//		printf("empty\n");
+		return 0.f;
+	}
+	btPersistentManifold* manifold = 0;
+	btCollisionObject* colObj0=0,*colObj1=0;
+
+	//btRigidBody* rb0=0,*rb1=0;
+
+
+#ifdef FORCE_REFESH_CONTACT_MANIFOLDS
+
+	BEGIN_PROFILE("refreshManifolds");
+
+	int i;
+	
+	
+
+	for (i=0;i<numManifolds;i++)
+	{
+		manifold = manifoldPtr[i];
+		rb1 = (btRigidBody*)manifold->getBody1();
+		rb0 = (btRigidBody*)manifold->getBody0();
+		
+		manifold->refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform());
+
+	}
+
+	END_PROFILE("refreshManifolds");
+#endif //FORCE_REFESH_CONTACT_MANIFOLDS
+
+	
+
+
+
+	//int sizeofSB = sizeof(btSolverBody);
+	//int sizeofSC = sizeof(btSolverConstraint);
+
+
+	//if (1)
+	{
+		//if m_stackAlloc, try to pack bodies/constraints to speed up solving
+//		btBlock*					sablock;
+//		sablock = stackAlloc->beginBlock();
+
+	//	int memsize = 16;
+//		unsigned char* stackMemory = stackAlloc->allocate(memsize);
+
+		
+		//todo: use stack allocator for this temp memory
+//		int minReservation = numManifolds*2;
+
+		//m_tmpSolverBodyPool.reserve(minReservation);
+
+		//don't convert all bodies, only the one we need so solver the constraints
+/*
+		{
+			for (int i=0;i<numBodies;i++)
+			{
+				btRigidBody* rb = btRigidBody::upcast(bodies[i]);
+				if (rb && 	(rb->getIslandTag() >= 0))
+				{
+					btAssert(rb->getCompanionId() < 0);
+					int solverBodyId = m_tmpSolverBodyPool.size();
+					btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
+					initSolverBody(&solverBody,rb);
+					rb->setCompanionId(solverBodyId);
+				} 
+			}
+		}
+*/
+		
+		//m_tmpSolverConstraintPool.reserve(minReservation);
+		//m_tmpSolverFrictionConstraintPool.reserve(minReservation);
+
+		{
+			int i;
+
+			for (i=0;i<numManifolds;i++)
+			{
+				manifold = manifoldPtr[i];
+				colObj0 = (btCollisionObject*)manifold->getBody0();
+				colObj1 = (btCollisionObject*)manifold->getBody1();
+			
+				int solverBodyIdA=-1;
+				int solverBodyIdB=-1;
+
+				if (manifold->getNumContacts())
+				{
+
+					
+
+					if (colObj0->getIslandTag() >= 0)
+					{
+						if (colObj0->getCompanionId() >= 0)
+						{
+							//body has already been converted
+							solverBodyIdA = colObj0->getCompanionId();
+						} else
+						{
+							solverBodyIdA = m_tmpSolverBodyPool.size();
+							btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
+							initSolverBody(&solverBody,colObj0);
+							colObj0->setCompanionId(solverBodyIdA);
+						}
+					} else
+					{
+						//create a static body
+						solverBodyIdA = m_tmpSolverBodyPool.size();
+						btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
+						initSolverBody(&solverBody,colObj0);
+					}
+
+					if (colObj1->getIslandTag() >= 0)
+					{
+						if (colObj1->getCompanionId() >= 0)
+						{
+							solverBodyIdB = colObj1->getCompanionId();
+						} else
+						{
+							solverBodyIdB = m_tmpSolverBodyPool.size();
+							btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
+							initSolverBody(&solverBody,colObj1);
+							colObj1->setCompanionId(solverBodyIdB);
+						}
+					} else
+					{
+						//create a static body
+						solverBodyIdB = m_tmpSolverBodyPool.size();
+						btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
+						initSolverBody(&solverBody,colObj1);
+					}
+				}
+
+				btVector3 rel_pos1;
+				btVector3 rel_pos2;
+				btScalar relaxation;
+
+				for (int j=0;j<manifold->getNumContacts();j++)
+				{
+					
+					btManifoldPoint& cp = manifold->getContactPoint(j);
+					
+					if (cp.getDistance() <= btScalar(0.))
+					{
+						
+						const btVector3& pos1 = cp.getPositionWorldOnA();
+						const btVector3& pos2 = cp.getPositionWorldOnB();
+
+						 rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); 
+						 rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin();
+
+						
+						relaxation = 1.f;
+						btScalar rel_vel;
+						btVector3 vel;
+
+						int frictionIndex = m_tmpSolverConstraintPool.size();
+
+						{
+							btSolverConstraint& solverConstraint = m_tmpSolverConstraintPool.expand();
+							btRigidBody* rb0 = btRigidBody::upcast(colObj0);
+							btRigidBody* rb1 = btRigidBody::upcast(colObj1);
+
+							solverConstraint.m_solverBodyIdA = solverBodyIdA;
+							solverConstraint.m_solverBodyIdB = solverBodyIdB;
+							solverConstraint.m_constraintType = btSolverConstraint::BT_SOLVER_CONTACT_1D;
+
+							solverConstraint.m_originalContactPoint = &cp;
+
+							btVector3 torqueAxis0 = rel_pos1.cross(cp.m_normalWorldOnB);
+							solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0 : btVector3(0,0,0);
+							btVector3 torqueAxis1 = rel_pos2.cross(cp.m_normalWorldOnB);		
+							solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*torqueAxis1 : btVector3(0,0,0);
+							{
+#ifdef COMPUTE_IMPULSE_DENOM
+								btScalar denom0 = rb0->computeImpulseDenominator(pos1,cp.m_normalWorldOnB);
+								btScalar denom1 = rb1->computeImpulseDenominator(pos2,cp.m_normalWorldOnB);
+#else							
+								btVector3 vec;
+								btScalar denom0 = 0.f;
+								btScalar denom1 = 0.f;
+								if (rb0)
+								{
+									vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1);
+									denom0 = rb0->getInvMass() + cp.m_normalWorldOnB.dot(vec);
+								}
+								if (rb1)
+								{
+									vec = ( solverConstraint.m_angularComponentB).cross(rel_pos2);
+									denom1 = rb1->getInvMass() + cp.m_normalWorldOnB.dot(vec);
+								}
+#endif //COMPUTE_IMPULSE_DENOM		
+								
+								btScalar denom = relaxation/(denom0+denom1);
+								solverConstraint.m_jacDiagABInv = denom;
+							}
+
+							solverConstraint.m_contactNormal = cp.m_normalWorldOnB;
+							solverConstraint.m_relpos1CrossNormal = rel_pos1.cross(cp.m_normalWorldOnB);
+							solverConstraint.m_relpos2CrossNormal = rel_pos2.cross(cp.m_normalWorldOnB);
+
+
+							btVector3 vel1 = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0);
+							btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0);
+				
+							vel  = vel1 - vel2;
+							
+							rel_vel = cp.m_normalWorldOnB.dot(vel);
+							
+							solverConstraint.m_penetration = btMin(cp.getDistance()+infoGlobal.m_linearSlop,btScalar(0.));
+							//solverConstraint.m_penetration = cp.getDistance();
+
+							solverConstraint.m_friction = cp.m_combinedFriction;
+							solverConstraint.m_restitution =  restitutionCurve(rel_vel, cp.m_combinedRestitution);
+							if (solverConstraint.m_restitution <= btScalar(0.))
+							{
+								solverConstraint.m_restitution = 0.f;
+							};
+
+							
+							btScalar penVel = -solverConstraint.m_penetration/infoGlobal.m_timeStep;
+
+							
+
+							if (solverConstraint.m_restitution > penVel)
+							{
+								solverConstraint.m_penetration = btScalar(0.);
+							}
+							 
+							
+							
+							///warm starting (or zero if disabled)
+							if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
+							{
+								solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor;
+								if (rb0)
+									m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].internalApplyImpulse(solverConstraint.m_contactNormal*rb0->getInvMass(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse);
+								if (rb1)
+									m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].internalApplyImpulse(solverConstraint.m_contactNormal*rb1->getInvMass(),solverConstraint.m_angularComponentB,-solverConstraint.m_appliedImpulse);
+							} else
+							{
+								solverConstraint.m_appliedImpulse = 0.f;
+							}
+
+							solverConstraint.m_appliedPushImpulse = 0.f;
+							
+							solverConstraint.m_frictionIndex = m_tmpSolverFrictionConstraintPool.size();
+							if (!cp.m_lateralFrictionInitialized)
+							{
+								cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel;
+								btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2();
+								if (lat_rel_vel > SIMD_EPSILON)//0.0f)
+								{
+									cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel);
+									addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+									cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
+									cp.m_lateralFrictionDir2.normalize();//??
+									addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+								} else
+								{
+									//re-calculate friction direction every frame, todo: check if this is really needed
+									
+									btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2);
+									addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+									addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+								}
+								cp.m_lateralFrictionInitialized = true;
+								
+							} else
+							{
+								addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+								addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+							}
+
+							{
+								btSolverConstraint& frictionConstraint1 = m_tmpSolverFrictionConstraintPool[solverConstraint.m_frictionIndex];
+								if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
+								{
+									frictionConstraint1.m_appliedImpulse = cp.m_appliedImpulseLateral1 * infoGlobal.m_warmstartingFactor;
+									if (rb0)
+										m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].internalApplyImpulse(frictionConstraint1.m_contactNormal*rb0->getInvMass(),frictionConstraint1.m_angularComponentA,frictionConstraint1.m_appliedImpulse);
+									if (rb1)
+										m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].internalApplyImpulse(frictionConstraint1.m_contactNormal*rb1->getInvMass(),frictionConstraint1.m_angularComponentB,-frictionConstraint1.m_appliedImpulse);
+								} else
+								{
+									frictionConstraint1.m_appliedImpulse = 0.f;
+								}
+							}
+							{
+								btSolverConstraint& frictionConstraint2 = m_tmpSolverFrictionConstraintPool[solverConstraint.m_frictionIndex+1];
+								if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
+								{
+									frictionConstraint2.m_appliedImpulse = cp.m_appliedImpulseLateral2 * infoGlobal.m_warmstartingFactor;
+									if (rb0)
+										m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].internalApplyImpulse(frictionConstraint2.m_contactNormal*rb0->getInvMass(),frictionConstraint2.m_angularComponentA,frictionConstraint2.m_appliedImpulse);
+									if (rb1)
+										m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].internalApplyImpulse(frictionConstraint2.m_contactNormal*rb1->getInvMass(),frictionConstraint2.m_angularComponentB,-frictionConstraint2.m_appliedImpulse);
+								} else
+								{
+									frictionConstraint2.m_appliedImpulse = 0.f;
+								}
+							}
+						}
+
+
+					}
+				}
+			}
+		}
+	}
+	
+	btContactSolverInfo info = infoGlobal;
+
+	{
+		int j;
+		for (j=0;j<numConstraints;j++)
+		{
+			btTypedConstraint* constraint = constraints[j];
+			constraint->buildJacobian();
+		}
+	}
+	
+	
+
+	int numConstraintPool = m_tmpSolverConstraintPool.size();
+	int numFrictionPool = m_tmpSolverFrictionConstraintPool.size();
+
+	///todo: use stack allocator for such temporarily memory, same for solver bodies/constraints
+	m_orderTmpConstraintPool.resize(numConstraintPool);
+	m_orderFrictionConstraintPool.resize(numFrictionPool);
+	{
+		int i;
+		for (i=0;i<numConstraintPool;i++)
+		{
+			m_orderTmpConstraintPool[i] = i;
+		}
+		for (i=0;i<numFrictionPool;i++)
+		{
+			m_orderFrictionConstraintPool[i] = i;
+		}
+	}
+
+
+
+	return 0.f;
+
+}
+
+btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** /*bodies */,int /*numBodies*/,btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* /*debugDrawer*/,btStackAlloc* /*stackAlloc*/)
+{
+	BT_PROFILE("solveGroupCacheFriendlyIterations");
+	int numConstraintPool = m_tmpSolverConstraintPool.size();
+	int numFrictionPool = m_tmpSolverFrictionConstraintPool.size();
+
+	//should traverse the contacts random order...
+	int iteration;
+	{
+		for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++)
+		{			
+
+			int j;
+			if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER)
+			{
+				if ((iteration & 7) == 0) {
+					for (j=0; j<numConstraintPool; ++j) {
+						int tmp = m_orderTmpConstraintPool[j];
+						int swapi = btRandInt2(j+1);
+						m_orderTmpConstraintPool[j] = m_orderTmpConstraintPool[swapi];
+						m_orderTmpConstraintPool[swapi] = tmp;
+					}
+
+					for (j=0; j<numFrictionPool; ++j) {
+						int tmp = m_orderFrictionConstraintPool[j];
+						int swapi = btRandInt2(j+1);
+						m_orderFrictionConstraintPool[j] = m_orderFrictionConstraintPool[swapi];
+						m_orderFrictionConstraintPool[swapi] = tmp;
+					}
+				}
+			}
+
+			for (j=0;j<numConstraints;j++)
+			{
+				btTypedConstraint* constraint = constraints[j];
+				///todo: use solver bodies, so we don't need to copy from/to btRigidBody
+
+				if ((constraint->getRigidBodyA().getIslandTag() >= 0) && (constraint->getRigidBodyA().getCompanionId() >= 0))
+				{
+					m_tmpSolverBodyPool[constraint->getRigidBodyA().getCompanionId()].writebackVelocity();
+				}
+				if ((constraint->getRigidBodyB().getIslandTag() >= 0) && (constraint->getRigidBodyB().getCompanionId() >= 0))
+				{
+					m_tmpSolverBodyPool[constraint->getRigidBodyB().getCompanionId()].writebackVelocity();
+				}
+
+				constraint->solveConstraint(infoGlobal.m_timeStep);
+
+				if ((constraint->getRigidBodyA().getIslandTag() >= 0) && (constraint->getRigidBodyA().getCompanionId() >= 0))
+				{
+					m_tmpSolverBodyPool[constraint->getRigidBodyA().getCompanionId()].readVelocity();
+				}
+				if ((constraint->getRigidBodyB().getIslandTag() >= 0) && (constraint->getRigidBodyB().getCompanionId() >= 0))
+				{
+					m_tmpSolverBodyPool[constraint->getRigidBodyB().getCompanionId()].readVelocity();
+				}
+
+			}
+
+			{
+				int numPoolConstraints = m_tmpSolverConstraintPool.size();
+				for (j=0;j<numPoolConstraints;j++)
+				{
+					
+					const btSolverConstraint& solveManifold = m_tmpSolverConstraintPool[m_orderTmpConstraintPool[j]];
+					resolveSingleCollisionCombinedCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
+						m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal);
+				}
+			}
+
+			{
+				 int numFrictionPoolConstraints = m_tmpSolverFrictionConstraintPool.size();
+				
+				 for (j=0;j<numFrictionPoolConstraints;j++)
+				{
+					const btSolverConstraint& solveManifold = m_tmpSolverFrictionConstraintPool[m_orderFrictionConstraintPool[j]];
+					btScalar totalImpulse = m_tmpSolverConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse+
+								m_tmpSolverConstraintPool[solveManifold.m_frictionIndex].m_appliedPushImpulse;			
+
+						resolveSingleFrictionCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
+							m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal,
+							totalImpulse);
+				}
+			}
+			
+
+
+		}
+	
+		if (infoGlobal.m_splitImpulse)
+		{
+			
+			for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++)
+			{
+				{
+					int numPoolConstraints = m_tmpSolverConstraintPool.size();
+					int j;
+					for (j=0;j<numPoolConstraints;j++)
+					{
+						const btSolverConstraint& solveManifold = m_tmpSolverConstraintPool[m_orderTmpConstraintPool[j]];
+
+						resolveSplitPenetrationImpulseCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
+							m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal);
+					}
+				}
+			}
+
+		}
+
+	}
+
+	return 0.f;
+}
+
+
+btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendly(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc)
+{
+	int i;
+
+	solveGroupCacheFriendlySetup( bodies, numBodies, manifoldPtr,  numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc);
+	solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr,  numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc);
+
+	int numPoolConstraints = m_tmpSolverConstraintPool.size();
+	int j;
+	for (j=0;j<numPoolConstraints;j++)
+	{
+		
+		const btSolverConstraint& solveManifold = m_tmpSolverConstraintPool[j];
+		btManifoldPoint* pt = (btManifoldPoint*) solveManifold.m_originalContactPoint;
+		btAssert(pt);
+		pt->m_appliedImpulse = solveManifold.m_appliedImpulse;
+		pt->m_appliedImpulseLateral1 = m_tmpSolverFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse;
+		pt->m_appliedImpulseLateral1 = m_tmpSolverFrictionConstraintPool[solveManifold.m_frictionIndex+1].m_appliedImpulse;
+
+		//do a callback here?
+
+	}
+
+	if (infoGlobal.m_splitImpulse)
+	{		
+		for ( i=0;i<m_tmpSolverBodyPool.size();i++)
+		{
+			m_tmpSolverBodyPool[i].writebackVelocity(infoGlobal.m_timeStep);
+		}
+	} else
+	{
+		for ( i=0;i<m_tmpSolverBodyPool.size();i++)
+        {
+                m_tmpSolverBodyPool[i].writebackVelocity();
+        }
+	}
+
+//	printf("m_tmpSolverConstraintPool.size() = %i\n",m_tmpSolverConstraintPool.size());
+
+/*
+	printf("m_tmpSolverBodyPool.size() = %i\n",m_tmpSolverBodyPool.size());
+	printf("m_tmpSolverConstraintPool.size() = %i\n",m_tmpSolverConstraintPool.size());
+	printf("m_tmpSolverFrictionConstraintPool.size() = %i\n",m_tmpSolverFrictionConstraintPool.size());
+
+	
+	printf("m_tmpSolverBodyPool.capacity() = %i\n",m_tmpSolverBodyPool.capacity());
+	printf("m_tmpSolverConstraintPool.capacity() = %i\n",m_tmpSolverConstraintPool.capacity());
+	printf("m_tmpSolverFrictionConstraintPool.capacity() = %i\n",m_tmpSolverFrictionConstraintPool.capacity());
+*/
+
+	m_tmpSolverBodyPool.resize(0);
+	m_tmpSolverConstraintPool.resize(0);
+	m_tmpSolverFrictionConstraintPool.resize(0);
+
+
+	return 0.f;
+}
+
+/// btSequentialImpulseConstraintSolver Sequentially applies impulses
+btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/)
+{
+	BT_PROFILE("solveGroup");
+	if (infoGlobal.m_solverMode & SOLVER_CACHE_FRIENDLY)
+	{
+		//you need to provide at least some bodies
+		//btSimpleDynamicsWorld needs to switch off SOLVER_CACHE_FRIENDLY
+		btAssert(bodies);
+		btAssert(numBodies);
+		return solveGroupCacheFriendly(bodies,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc);
+	}
+
+	
+
+	btContactSolverInfo info = infoGlobal;
+
+	int numiter = infoGlobal.m_numIterations;
+
+	int totalPoints = 0;
+
+
+	{
+		short j;
+		for (j=0;j<numManifolds;j++)
+		{
+			btPersistentManifold* manifold = manifoldPtr[j];
+			prepareConstraints(manifold,info,debugDrawer);
+
+			for (short p=0;p<manifoldPtr[j]->getNumContacts();p++)
+			{
+				gOrder[totalPoints].m_manifoldIndex = j;
+				gOrder[totalPoints].m_pointIndex = p;
+				totalPoints++;
+			}
+		}
+	}
+
+	{
+		int j;
+		for (j=0;j<numConstraints;j++)
+		{
+			btTypedConstraint* constraint = constraints[j];
+			constraint->buildJacobian();
+		}
+	}
+	
+
+	//should traverse the contacts random order...
+	int iteration;
+
+	{
+		for ( iteration = 0;iteration<numiter;iteration++)
+		{
+			int j;
+			if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER)
+			{
+				if ((iteration & 7) == 0) {
+					for (j=0; j<totalPoints; ++j) {
+						btOrderIndex tmp = gOrder[j];
+						int swapi = btRandInt2(j+1);
+						gOrder[j] = gOrder[swapi];
+						gOrder[swapi] = tmp;
+					}
+				}
+			}
+
+			for (j=0;j<numConstraints;j++)
+			{
+				btTypedConstraint* constraint = constraints[j];
+				constraint->solveConstraint(info.m_timeStep);
+			}
+
+			for (j=0;j<totalPoints;j++)
+			{
+				btPersistentManifold* manifold = manifoldPtr[gOrder[j].m_manifoldIndex];
+				solve( (btRigidBody*)manifold->getBody0(),
+									(btRigidBody*)manifold->getBody1()
+				,manifold->getContactPoint(gOrder[j].m_pointIndex),info,iteration,debugDrawer);
+			}
+		
+			for (j=0;j<totalPoints;j++)
+			{
+				btPersistentManifold* manifold = manifoldPtr[gOrder[j].m_manifoldIndex];
+				solveFriction((btRigidBody*)manifold->getBody0(),
+					(btRigidBody*)manifold->getBody1(),manifold->getContactPoint(gOrder[j].m_pointIndex),info,iteration,debugDrawer);
+			}
+			
+		}
+	}
+		
+
+
+
+	return btScalar(0.);
+}
+
+
+
+
+
+
+
+void	btSequentialImpulseConstraintSolver::prepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer)
+{
+
+	(void)debugDrawer;
+
+	btRigidBody* body0 = (btRigidBody*)manifoldPtr->getBody0();
+	btRigidBody* body1 = (btRigidBody*)manifoldPtr->getBody1();
+
+
+	//only necessary to refresh the manifold once (first iteration). The integration is done outside the loop
+	{
+#ifdef FORCE_REFESH_CONTACT_MANIFOLDS
+		manifoldPtr->refreshContactPoints(body0->getCenterOfMassTransform(),body1->getCenterOfMassTransform());
+#endif //FORCE_REFESH_CONTACT_MANIFOLDS		
+		int numpoints = manifoldPtr->getNumContacts();
+
+		gTotalContactPoints += numpoints;
+
+		
+		for (int i=0;i<numpoints ;i++)
+		{
+			btManifoldPoint& cp = manifoldPtr->getContactPoint(i);
+			if (cp.getDistance() <= btScalar(0.))
+			{
+				const btVector3& pos1 = cp.getPositionWorldOnA();
+				const btVector3& pos2 = cp.getPositionWorldOnB();
+
+				btVector3 rel_pos1 = pos1 - body0->getCenterOfMassPosition(); 
+				btVector3 rel_pos2 = pos2 - body1->getCenterOfMassPosition();
+				
+
+				//this jacobian entry is re-used for all iterations
+				btJacobianEntry jac(body0->getCenterOfMassTransform().getBasis().transpose(),
+					body1->getCenterOfMassTransform().getBasis().transpose(),
+					rel_pos1,rel_pos2,cp.m_normalWorldOnB,body0->getInvInertiaDiagLocal(),body0->getInvMass(),
+					body1->getInvInertiaDiagLocal(),body1->getInvMass());
+
+				
+				btScalar jacDiagAB = jac.getDiagonal();
+
+				btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData;
+				if (cpd)
+				{
+					//might be invalid
+					cpd->m_persistentLifeTime++;
+					if (cpd->m_persistentLifeTime != cp.getLifeTime())
+					{
+						//printf("Invalid: cpd->m_persistentLifeTime = %i cp.getLifeTime() = %i\n",cpd->m_persistentLifeTime,cp.getLifeTime());
+						new (cpd) btConstraintPersistentData;
+						cpd->m_persistentLifeTime = cp.getLifeTime();
+
+					} else
+					{
+						//printf("Persistent: cpd->m_persistentLifeTime = %i cp.getLifeTime() = %i\n",cpd->m_persistentLifeTime,cp.getLifeTime());
+						
+					}
+				} else
+				{
+						
+					//todo: should this be in a pool?
+					void* mem = btAlignedAlloc(sizeof(btConstraintPersistentData),16);
+					cpd = new (mem)btConstraintPersistentData;
+					assert(cpd);
+
+					totalCpd ++;
+					//printf("totalCpd = %i Created Ptr %x\n",totalCpd,cpd);
+					cp.m_userPersistentData = cpd;
+					cpd->m_persistentLifeTime = cp.getLifeTime();
+					//printf("CREATED: %x . cpd->m_persistentLifeTime = %i cp.getLifeTime() = %i\n",cpd,cpd->m_persistentLifeTime,cp.getLifeTime());
+					
+				}
+				assert(cpd);
+
+				cpd->m_jacDiagABInv = btScalar(1.) / jacDiagAB;
+
+				//Dependent on Rigidbody A and B types, fetch the contact/friction response func
+				//perhaps do a similar thing for friction/restutution combiner funcs...
+				
+				cpd->m_frictionSolverFunc = m_frictionDispatch[body0->m_frictionSolverType][body1->m_frictionSolverType];
+				cpd->m_contactSolverFunc = m_contactDispatch[body0->m_contactSolverType][body1->m_contactSolverType];
+				
+				btVector3 vel1 = body0->getVelocityInLocalPoint(rel_pos1);
+				btVector3 vel2 = body1->getVelocityInLocalPoint(rel_pos2);
+				btVector3 vel = vel1 - vel2;
+				btScalar rel_vel;
+				rel_vel = cp.m_normalWorldOnB.dot(vel);
+				
+				btScalar combinedRestitution = cp.m_combinedRestitution;
+				
+				cpd->m_penetration = cp.getDistance();///btScalar(info.m_numIterations);
+				cpd->m_friction = cp.m_combinedFriction;
+				cpd->m_restitution = restitutionCurve(rel_vel, combinedRestitution);
+				if (cpd->m_restitution <= btScalar(0.))
+				{
+					cpd->m_restitution = btScalar(0.0);
+
+				};
+				
+				//restitution and penetration work in same direction so
+				//rel_vel 
+				
+				btScalar penVel = -cpd->m_penetration/info.m_timeStep;
+
+				if (cpd->m_restitution > penVel)
+				{
+					cpd->m_penetration = btScalar(0.);
+				} 				
+				
+
+				btScalar relaxation = info.m_damping;
+				if (info.m_solverMode & SOLVER_USE_WARMSTARTING)
+				{
+					cpd->m_appliedImpulse *= relaxation;
+				} else
+				{
+					cpd->m_appliedImpulse =btScalar(0.);
+				}
+	
+				//for friction
+				cpd->m_prevAppliedImpulse = cpd->m_appliedImpulse;
+				
+				//re-calculate friction direction every frame, todo: check if this is really needed
+				btPlaneSpace1(cp.m_normalWorldOnB,cpd->m_frictionWorldTangential0,cpd->m_frictionWorldTangential1);
+
+
+#define NO_FRICTION_WARMSTART 1
+
+	#ifdef NO_FRICTION_WARMSTART
+				cpd->m_accumulatedTangentImpulse0 = btScalar(0.);
+				cpd->m_accumulatedTangentImpulse1 = btScalar(0.);
+	#endif //NO_FRICTION_WARMSTART
+				btScalar denom0 = body0->computeImpulseDenominator(pos1,cpd->m_frictionWorldTangential0);
+				btScalar denom1 = body1->computeImpulseDenominator(pos2,cpd->m_frictionWorldTangential0);
+				btScalar denom = relaxation/(denom0+denom1);
+				cpd->m_jacDiagABInvTangent0 = denom;
+
+
+				denom0 = body0->computeImpulseDenominator(pos1,cpd->m_frictionWorldTangential1);
+				denom1 = body1->computeImpulseDenominator(pos2,cpd->m_frictionWorldTangential1);
+				denom = relaxation/(denom0+denom1);
+				cpd->m_jacDiagABInvTangent1 = denom;
+
+				btVector3 totalImpulse = 
+	#ifndef NO_FRICTION_WARMSTART
+					cpd->m_frictionWorldTangential0*cpd->m_accumulatedTangentImpulse0+
+					cpd->m_frictionWorldTangential1*cpd->m_accumulatedTangentImpulse1+
+	#endif //NO_FRICTION_WARMSTART
+					cp.m_normalWorldOnB*cpd->m_appliedImpulse;
+
+
+
+				///
+				{
+				btVector3 torqueAxis0 = rel_pos1.cross(cp.m_normalWorldOnB);
+				cpd->m_angularComponentA = body0->getInvInertiaTensorWorld()*torqueAxis0;
+				btVector3 torqueAxis1 = rel_pos2.cross(cp.m_normalWorldOnB);		
+				cpd->m_angularComponentB = body1->getInvInertiaTensorWorld()*torqueAxis1;
+				}
+				{
+					btVector3 ftorqueAxis0 = rel_pos1.cross(cpd->m_frictionWorldTangential0);
+					cpd->m_frictionAngularComponent0A = body0->getInvInertiaTensorWorld()*ftorqueAxis0;
+				}
+				{
+					btVector3 ftorqueAxis1 = rel_pos1.cross(cpd->m_frictionWorldTangential1);
+					cpd->m_frictionAngularComponent1A = body0->getInvInertiaTensorWorld()*ftorqueAxis1;
+				}
+				{
+					btVector3 ftorqueAxis0 = rel_pos2.cross(cpd->m_frictionWorldTangential0);
+					cpd->m_frictionAngularComponent0B = body1->getInvInertiaTensorWorld()*ftorqueAxis0;
+				}
+				{
+					btVector3 ftorqueAxis1 = rel_pos2.cross(cpd->m_frictionWorldTangential1);
+					cpd->m_frictionAngularComponent1B = body1->getInvInertiaTensorWorld()*ftorqueAxis1;
+				}
+				
+				///
+
+
+
+				//apply previous frames impulse on both bodies
+				body0->applyImpulse(totalImpulse, rel_pos1);
+				body1->applyImpulse(-totalImpulse, rel_pos2);
+			}
+			
+		}
+	}
+}
+
+
+btScalar btSequentialImpulseConstraintSolver::solveCombinedContactFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer)
+{
+	btScalar maxImpulse = btScalar(0.);
+
+	{
+
+		
+		{
+			if (cp.getDistance() <= btScalar(0.))
+			{
+
+				
+
+				{
+
+					//btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData;
+					btScalar impulse = resolveSingleCollisionCombined(
+						*body0,*body1,
+						cp,
+						info);
+
+					if (maxImpulse < impulse)
+						maxImpulse  = impulse;
+
+				}
+			}
+		}
+	}
+	return maxImpulse;
+}
+
+
+
+btScalar btSequentialImpulseConstraintSolver::solve(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer)
+{
+
+	btScalar maxImpulse = btScalar(0.);
+
+	{
+
+		
+		{
+			if (cp.getDistance() <= btScalar(0.))
+			{
+
+				
+
+				{
+
+					btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData;
+					btScalar impulse = cpd->m_contactSolverFunc(
+						*body0,*body1,
+						cp,
+						info);
+
+					if (maxImpulse < impulse)
+						maxImpulse  = impulse;
+
+				}
+			}
+		}
+	}
+	return maxImpulse;
+}
+
+btScalar btSequentialImpulseConstraintSolver::solveFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer)
+{
+
+	(void)debugDrawer;
+	(void)iter;
+
+
+	{
+
+		
+		{
+			
+			if (cp.getDistance() <= btScalar(0.))
+			{
+
+				btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData;
+				cpd->m_frictionSolverFunc(
+					*body0,*body1,
+					cp,
+					info);
+
+				
+			}
+		}
+
+	
+	}
+	return btScalar(0.);
+}
+
+
+void	btSequentialImpulseConstraintSolver::reset()
+{
+	m_btSeed2 = 0;
+}
+
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h	(revision 2122)
@@ -0,0 +1,109 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
+#define SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
+
+#include "btConstraintSolver.h"
+class btIDebugDraw;
+#include "btContactConstraint.h"
+#include "btSolverBody.h"
+#include "btSolverConstraint.h"
+
+
+/// btSequentialImpulseConstraintSolver uses a Propagation Method and Sequentially applies impulses
+/// The approach is the 3D version of Erin Catto's GDC 2006 tutorial. See http://www.gphysics.com
+/// Although Sequential Impulse is more intuitive, it is mathematically equivalent to Projected Successive Overrelaxation (iterative LCP)
+/// Applies impulses for combined restitution and penetration recovery and to simulate friction
+class btSequentialImpulseConstraintSolver : public btConstraintSolver
+{
+
+	btAlignedObjectArray<btSolverBody>	m_tmpSolverBodyPool;
+	btAlignedObjectArray<btSolverConstraint>	m_tmpSolverConstraintPool;
+	btAlignedObjectArray<btSolverConstraint>	m_tmpSolverFrictionConstraintPool;
+	btAlignedObjectArray<int>	m_orderTmpConstraintPool;
+	btAlignedObjectArray<int>	m_orderFrictionConstraintPool;
+
+
+protected:
+	btScalar solve(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
+	btScalar solveFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
+	void  prepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer);
+	void	addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation);
+
+	ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
+	ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
+
+	
+	///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction
+	unsigned long	m_btSeed2;
+
+public:
+
+	
+	btSequentialImpulseConstraintSolver();
+
+	///Advanced: Override the default contact solving function for contacts, for certain types of rigidbody
+	///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionSolverType
+	void	setContactSolverFunc(ContactSolverFunc func,int type0,int type1)
+	{
+		m_contactDispatch[type0][type1] = func;
+	}
+	
+	///Advanced: Override the default friction solving function for contacts, for certain types of rigidbody
+	///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionSolverType
+	void	SetFrictionSolverFunc(ContactSolverFunc func,int type0,int type1)
+	{
+		m_frictionDispatch[type0][type1] = func;
+	}
+
+	virtual ~btSequentialImpulseConstraintSolver();
+	
+	virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
+
+	virtual btScalar solveGroupCacheFriendly(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
+	btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
+	btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
+
+
+	///clear internal cached data and reset random seed
+	virtual	void	reset();
+
+	btScalar solveCombinedContactFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
+
+
+	
+	unsigned long btRand2();
+
+	int btRandInt2 (int n);
+
+	void	setRandSeed(unsigned long seed)
+	{
+		m_btSeed2 = seed;
+	}
+	unsigned long	getRandSeed() const
+	{
+		return m_btSeed2;
+	}
+
+};
+
+#ifndef BT_PREFER_SIMD
+typedef btSequentialImpulseConstraintSolver btSequentialImpulseConstraintSolverPrefered;
+#endif
+
+
+#endif //SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp	(revision 2122)
@@ -0,0 +1,415 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+Added by Roman Ponomarev (rponom@gmail.com)
+April 04, 2008
+*/
+
+//-----------------------------------------------------------------------------
+
+#include "btSliderConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btTransformUtil.h"
+#include <new>
+
+//-----------------------------------------------------------------------------
+
+void btSliderConstraint::initParams()
+{
+    m_lowerLinLimit = btScalar(1.0);
+    m_upperLinLimit = btScalar(-1.0);
+    m_lowerAngLimit = btScalar(0.);
+    m_upperAngLimit = btScalar(0.);
+	m_softnessDirLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
+	m_restitutionDirLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
+	m_dampingDirLin = btScalar(0.);
+	m_softnessDirAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
+	m_restitutionDirAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
+	m_dampingDirAng = btScalar(0.);
+	m_softnessOrthoLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
+	m_restitutionOrthoLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
+	m_dampingOrthoLin = SLIDER_CONSTRAINT_DEF_DAMPING;
+	m_softnessOrthoAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
+	m_restitutionOrthoAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
+	m_dampingOrthoAng = SLIDER_CONSTRAINT_DEF_DAMPING;
+	m_softnessLimLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
+	m_restitutionLimLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
+	m_dampingLimLin = SLIDER_CONSTRAINT_DEF_DAMPING;
+	m_softnessLimAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
+	m_restitutionLimAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
+	m_dampingLimAng = SLIDER_CONSTRAINT_DEF_DAMPING;
+
+	m_poweredLinMotor = false;
+    m_targetLinMotorVelocity = btScalar(0.);
+    m_maxLinMotorForce = btScalar(0.);
+	m_accumulatedLinMotorImpulse = btScalar(0.0);
+
+	m_poweredAngMotor = false;
+    m_targetAngMotorVelocity = btScalar(0.);
+    m_maxAngMotorForce = btScalar(0.);
+	m_accumulatedAngMotorImpulse = btScalar(0.0);
+
+} // btSliderConstraint::initParams()
+
+//-----------------------------------------------------------------------------
+
+btSliderConstraint::btSliderConstraint()
+        :btTypedConstraint(SLIDER_CONSTRAINT_TYPE),
+		m_useLinearReferenceFrameA(true)
+{
+	initParams();
+} // btSliderConstraint::btSliderConstraint()
+
+//-----------------------------------------------------------------------------
+
+btSliderConstraint::btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA)
+        : btTypedConstraint(SLIDER_CONSTRAINT_TYPE, rbA, rbB)
+        , m_frameInA(frameInA)
+        , m_frameInB(frameInB),
+		m_useLinearReferenceFrameA(useLinearReferenceFrameA)
+{
+	initParams();
+} // btSliderConstraint::btSliderConstraint()
+
+//-----------------------------------------------------------------------------
+
+void btSliderConstraint::buildJacobian()
+{
+	if(m_useLinearReferenceFrameA)
+	{
+		buildJacobianInt(m_rbA, m_rbB, m_frameInA, m_frameInB);
+	}
+	else
+	{
+		buildJacobianInt(m_rbB, m_rbA, m_frameInB, m_frameInA);
+	}
+} // btSliderConstraint::buildJacobian()
+
+//-----------------------------------------------------------------------------
+
+void btSliderConstraint::buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB)
+{
+	//calculate transforms
+    m_calculatedTransformA = rbA.getCenterOfMassTransform() * frameInA;
+    m_calculatedTransformB = rbB.getCenterOfMassTransform() * frameInB;
+	m_realPivotAInW = m_calculatedTransformA.getOrigin();
+	m_realPivotBInW = m_calculatedTransformB.getOrigin();
+	m_sliderAxis = m_calculatedTransformA.getBasis().getColumn(0); // along X
+	m_delta = m_realPivotBInW - m_realPivotAInW;
+	m_projPivotInW = m_realPivotAInW + m_sliderAxis.dot(m_delta) * m_sliderAxis;
+	m_relPosA = m_projPivotInW - rbA.getCenterOfMassPosition();
+	m_relPosB = m_realPivotBInW - rbB.getCenterOfMassPosition();
+    btVector3 normalWorld;
+    int i;
+    //linear part
+    for(i = 0; i < 3; i++)
+    {
+		normalWorld = m_calculatedTransformA.getBasis().getColumn(i);
+		new (&m_jacLin[i]) btJacobianEntry(
+			rbA.getCenterOfMassTransform().getBasis().transpose(),
+			rbB.getCenterOfMassTransform().getBasis().transpose(),
+			m_relPosA,
+			m_relPosB,
+			normalWorld,
+			rbA.getInvInertiaDiagLocal(),
+			rbA.getInvMass(),
+			rbB.getInvInertiaDiagLocal(),
+			rbB.getInvMass()
+			);
+		m_jacLinDiagABInv[i] = btScalar(1.) / m_jacLin[i].getDiagonal();
+		m_depth[i] = m_delta.dot(normalWorld);
+    }
+	testLinLimits();
+    // angular part
+    for(i = 0; i < 3; i++)
+    {
+		normalWorld = m_calculatedTransformA.getBasis().getColumn(i);
+		new (&m_jacAng[i])	btJacobianEntry(
+			normalWorld,
+            rbA.getCenterOfMassTransform().getBasis().transpose(),
+            rbB.getCenterOfMassTransform().getBasis().transpose(),
+            rbA.getInvInertiaDiagLocal(),
+            rbB.getInvInertiaDiagLocal()
+			);
+	}
+	testAngLimits();
+	btVector3 axisA = m_calculatedTransformA.getBasis().getColumn(0);
+	m_kAngle = btScalar(1.0 )/ (rbA.computeAngularImpulseDenominator(axisA) + rbB.computeAngularImpulseDenominator(axisA));
+	// clear accumulator for motors
+	m_accumulatedLinMotorImpulse = btScalar(0.0);
+	m_accumulatedAngMotorImpulse = btScalar(0.0);
+} // btSliderConstraint::buildJacobianInt()
+
+//-----------------------------------------------------------------------------
+
+void btSliderConstraint::solveConstraint(btScalar timeStep)
+{
+    m_timeStep = timeStep;
+	if(m_useLinearReferenceFrameA)
+	{
+		solveConstraintInt(m_rbA, m_rbB);
+	}
+	else
+	{
+		solveConstraintInt(m_rbB, m_rbA);
+	}
+} // btSliderConstraint::solveConstraint()
+
+//-----------------------------------------------------------------------------
+
+void btSliderConstraint::solveConstraintInt(btRigidBody& rbA, btRigidBody& rbB)
+{
+    int i;
+    // linear
+    btVector3 velA = rbA.getVelocityInLocalPoint(m_relPosA);
+    btVector3 velB = rbB.getVelocityInLocalPoint(m_relPosB);
+    btVector3 vel = velA - velB;
+	for(i = 0; i < 3; i++)
+    {
+		const btVector3& normal = m_jacLin[i].m_linearJointAxis;
+		btScalar rel_vel = normal.dot(vel);
+		// calculate positional error
+		btScalar depth = m_depth[i];
+		// get parameters
+		btScalar softness = (i) ? m_softnessOrthoLin : (m_solveLinLim ? m_softnessLimLin : m_softnessDirLin);
+		btScalar restitution = (i) ? m_restitutionOrthoLin : (m_solveLinLim ? m_restitutionLimLin : m_restitutionDirLin);
+		btScalar damping = (i) ? m_dampingOrthoLin : (m_solveLinLim ? m_dampingLimLin : m_dampingDirLin);
+		// calcutate and apply impulse
+		btScalar normalImpulse = softness * (restitution * depth / m_timeStep - damping * rel_vel) * m_jacLinDiagABInv[i];
+		btVector3 impulse_vector = normal * normalImpulse;
+		rbA.applyImpulse( impulse_vector, m_relPosA);
+		rbB.applyImpulse(-impulse_vector, m_relPosB);
+		if(m_poweredLinMotor && (!i))
+		{ // apply linear motor
+			if(m_accumulatedLinMotorImpulse < m_maxLinMotorForce)
+			{
+				btScalar desiredMotorVel = m_targetLinMotorVelocity;
+				btScalar motor_relvel = desiredMotorVel + rel_vel;
+				normalImpulse = -motor_relvel * m_jacLinDiagABInv[i];
+				// clamp accumulated impulse
+				btScalar new_acc = m_accumulatedLinMotorImpulse + btFabs(normalImpulse);
+				if(new_acc  > m_maxLinMotorForce)
+				{
+					new_acc = m_maxLinMotorForce;
+				}
+				btScalar del = new_acc  - m_accumulatedLinMotorImpulse;
+				if(normalImpulse < btScalar(0.0))
+				{
+					normalImpulse = -del;
+				}
+				else
+				{
+					normalImpulse = del;
+				}
+				m_accumulatedLinMotorImpulse = new_acc;
+				// apply clamped impulse
+				impulse_vector = normal * normalImpulse;
+				rbA.applyImpulse( impulse_vector, m_relPosA);
+				rbB.applyImpulse(-impulse_vector, m_relPosB);
+			}
+		}
+    }
+	// angular 
+	// get axes in world space
+	btVector3 axisA =  m_calculatedTransformA.getBasis().getColumn(0);
+	btVector3 axisB =  m_calculatedTransformB.getBasis().getColumn(0);
+
+	const btVector3& angVelA = rbA.getAngularVelocity();
+	const btVector3& angVelB = rbB.getAngularVelocity();
+
+	btVector3 angVelAroundAxisA = axisA * axisA.dot(angVelA);
+	btVector3 angVelAroundAxisB = axisB * axisB.dot(angVelB);
+
+	btVector3 angAorthog = angVelA - angVelAroundAxisA;
+	btVector3 angBorthog = angVelB - angVelAroundAxisB;
+	btVector3 velrelOrthog = angAorthog-angBorthog;
+	//solve orthogonal angular velocity correction
+	btScalar len = velrelOrthog.length();
+	if (len > btScalar(0.00001))
+	{
+		btVector3 normal = velrelOrthog.normalized();
+		btScalar denom = rbA.computeAngularImpulseDenominator(normal) + rbB.computeAngularImpulseDenominator(normal);
+		velrelOrthog *= (btScalar(1.)/denom) * m_dampingOrthoAng * m_softnessOrthoAng;
+	}
+	//solve angular positional correction
+	btVector3 angularError = axisA.cross(axisB) *(btScalar(1.)/m_timeStep);
+	btScalar len2 = angularError.length();
+	if (len2>btScalar(0.00001))
+	{
+		btVector3 normal2 = angularError.normalized();
+		btScalar denom2 = rbA.computeAngularImpulseDenominator(normal2) + rbB.computeAngularImpulseDenominator(normal2);
+		angularError *= (btScalar(1.)/denom2) * m_restitutionOrthoAng * m_softnessOrthoAng;
+	}
+	// apply impulse
+	rbA.applyTorqueImpulse(-velrelOrthog+angularError);
+	rbB.applyTorqueImpulse(velrelOrthog-angularError);
+	btScalar impulseMag;
+	//solve angular limits
+	if(m_solveAngLim)
+	{
+		impulseMag = (angVelB - angVelA).dot(axisA) * m_dampingLimAng + m_angDepth * m_restitutionLimAng / m_timeStep;
+		impulseMag *= m_kAngle * m_softnessLimAng;
+	}
+	else
+	{
+		impulseMag = (angVelB - angVelA).dot(axisA) * m_dampingDirAng + m_angDepth * m_restitutionDirAng / m_timeStep;
+		impulseMag *= m_kAngle * m_softnessDirAng;
+	}
+	btVector3 impulse = axisA * impulseMag;
+	rbA.applyTorqueImpulse(impulse);
+	rbB.applyTorqueImpulse(-impulse);
+	//apply angular motor
+	if(m_poweredAngMotor) 
+	{
+		if(m_accumulatedAngMotorImpulse < m_maxAngMotorForce)
+		{
+			btVector3 velrel = angVelAroundAxisA - angVelAroundAxisB;
+			btScalar projRelVel = velrel.dot(axisA);
+
+			btScalar desiredMotorVel = m_targetAngMotorVelocity;
+			btScalar motor_relvel = desiredMotorVel - projRelVel;
+
+			btScalar angImpulse = m_kAngle * motor_relvel;
+			// clamp accumulated impulse
+			btScalar new_acc = m_accumulatedAngMotorImpulse + btFabs(angImpulse);
+			if(new_acc  > m_maxAngMotorForce)
+			{
+				new_acc = m_maxAngMotorForce;
+			}
+			btScalar del = new_acc  - m_accumulatedAngMotorImpulse;
+			if(angImpulse < btScalar(0.0))
+			{
+				angImpulse = -del;
+			}
+			else
+			{
+				angImpulse = del;
+			}
+			m_accumulatedAngMotorImpulse = new_acc;
+			// apply clamped impulse
+			btVector3 motorImp = angImpulse * axisA;
+			m_rbA.applyTorqueImpulse(motorImp);
+			m_rbB.applyTorqueImpulse(-motorImp);
+		}
+	}
+} // btSliderConstraint::solveConstraint()
+
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+
+void btSliderConstraint::calculateTransforms(void){
+	if(m_useLinearReferenceFrameA)
+	{
+		m_calculatedTransformA = m_rbA.getCenterOfMassTransform() * m_frameInA;
+		m_calculatedTransformB = m_rbB.getCenterOfMassTransform() * m_frameInB;
+	}
+	else
+	{
+		m_calculatedTransformA = m_rbB.getCenterOfMassTransform() * m_frameInB;
+		m_calculatedTransformB = m_rbA.getCenterOfMassTransform() * m_frameInA;
+	}
+	m_realPivotAInW = m_calculatedTransformA.getOrigin();
+	m_realPivotBInW = m_calculatedTransformB.getOrigin();
+	m_sliderAxis = m_calculatedTransformA.getBasis().getColumn(0); // along X
+	m_delta = m_realPivotBInW - m_realPivotAInW;
+	m_projPivotInW = m_realPivotAInW + m_sliderAxis.dot(m_delta) * m_sliderAxis;
+    btVector3 normalWorld;
+    int i;
+    //linear part
+    for(i = 0; i < 3; i++)
+    {
+		normalWorld = m_calculatedTransformA.getBasis().getColumn(i);
+		m_depth[i] = m_delta.dot(normalWorld);
+    }
+} // btSliderConstraint::calculateTransforms()
+ 
+//-----------------------------------------------------------------------------
+
+void btSliderConstraint::testLinLimits(void)
+{
+	m_solveLinLim = false;
+	m_linPos = m_depth[0];
+	if(m_lowerLinLimit <= m_upperLinLimit)
+	{
+		if(m_depth[0] > m_upperLinLimit)
+		{
+			m_depth[0] -= m_upperLinLimit;
+			m_solveLinLim = true;
+		}
+		else if(m_depth[0] < m_lowerLinLimit)
+		{
+			m_depth[0] -= m_lowerLinLimit;
+			m_solveLinLim = true;
+		}
+		else
+		{
+			m_depth[0] = btScalar(0.);
+		}
+	}
+	else
+	{
+		m_depth[0] = btScalar(0.);
+	}
+} // btSliderConstraint::testLinLimits()
+
+//-----------------------------------------------------------------------------
+ 
+
+void btSliderConstraint::testAngLimits(void)
+{
+	m_angDepth = btScalar(0.);
+	m_solveAngLim = false;
+	if(m_lowerAngLimit <= m_upperAngLimit)
+	{
+		const btVector3 axisA0 = m_calculatedTransformA.getBasis().getColumn(1);
+		const btVector3 axisA1 = m_calculatedTransformA.getBasis().getColumn(2);
+		const btVector3 axisB0 = m_calculatedTransformB.getBasis().getColumn(1);
+		btScalar rot = btAtan2Fast(axisB0.dot(axisA1), axisB0.dot(axisA0));  
+		if(rot < m_lowerAngLimit)
+		{
+			m_angDepth = rot - m_lowerAngLimit;
+			m_solveAngLim = true;
+		} 
+		else if(rot > m_upperAngLimit)
+		{
+			m_angDepth = rot - m_upperAngLimit;
+			m_solveAngLim = true;
+		}
+	}
+} // btSliderConstraint::testAngLimits()
+
+	
+//-----------------------------------------------------------------------------
+
+
+
+btVector3 btSliderConstraint::getAncorInA(void)
+{
+	btVector3 ancorInA;
+	ancorInA = m_realPivotAInW + (m_lowerLinLimit + m_upperLinLimit) * btScalar(0.5) * m_sliderAxis;
+	ancorInA = m_rbA.getCenterOfMassTransform().inverse() * ancorInA;
+	return ancorInA;
+} // btSliderConstraint::getAncorInA()
+
+//-----------------------------------------------------------------------------
+
+btVector3 btSliderConstraint::getAncorInB(void)
+{
+	btVector3 ancorInB;
+	ancorInB = m_frameInB.getOrigin();
+	return ancorInB;
+} // btSliderConstraint::getAncorInB();
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.h	(revision 2122)
@@ -0,0 +1,218 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+Added by Roman Ponomarev (rponom@gmail.com)
+April 04, 2008
+
+TODO:
+ - add clamping od accumulated impulse to improve stability
+ - add conversion for ODE constraint solver
+*/
+
+#ifndef SLIDER_CONSTRAINT_H
+#define SLIDER_CONSTRAINT_H
+
+//-----------------------------------------------------------------------------
+
+#include "LinearMath/btVector3.h"
+#include "btJacobianEntry.h"
+#include "btTypedConstraint.h"
+
+//-----------------------------------------------------------------------------
+
+class btRigidBody;
+
+//-----------------------------------------------------------------------------
+
+#define SLIDER_CONSTRAINT_DEF_SOFTNESS		(btScalar(1.0))
+#define SLIDER_CONSTRAINT_DEF_DAMPING		(btScalar(1.0))
+#define SLIDER_CONSTRAINT_DEF_RESTITUTION	(btScalar(0.7))
+
+//-----------------------------------------------------------------------------
+
+class btSliderConstraint : public btTypedConstraint
+{
+protected:
+	btTransform	m_frameInA;
+    btTransform	m_frameInB;
+	// use frameA fo define limits, if true
+	bool m_useLinearReferenceFrameA;
+	// linear limits
+	btScalar m_lowerLinLimit;
+	btScalar m_upperLinLimit;
+	// angular limits
+	btScalar m_lowerAngLimit;
+	btScalar m_upperAngLimit;
+	// softness, restitution and damping for different cases
+	// DirLin - moving inside linear limits
+	// LimLin - hitting linear limit
+	// DirAng - moving inside angular limits
+	// LimAng - hitting angular limit
+	// OrthoLin, OrthoAng - against constraint axis
+	btScalar m_softnessDirLin;
+	btScalar m_restitutionDirLin;
+	btScalar m_dampingDirLin;
+	btScalar m_softnessDirAng;
+	btScalar m_restitutionDirAng;
+	btScalar m_dampingDirAng;
+	btScalar m_softnessLimLin;
+	btScalar m_restitutionLimLin;
+	btScalar m_dampingLimLin;
+	btScalar m_softnessLimAng;
+	btScalar m_restitutionLimAng;
+	btScalar m_dampingLimAng;
+	btScalar m_softnessOrthoLin;
+	btScalar m_restitutionOrthoLin;
+	btScalar m_dampingOrthoLin;
+	btScalar m_softnessOrthoAng;
+	btScalar m_restitutionOrthoAng;
+	btScalar m_dampingOrthoAng;
+	
+	// for interlal use
+	bool m_solveLinLim;
+	bool m_solveAngLim;
+
+	btJacobianEntry	m_jacLin[3];
+	btScalar		m_jacLinDiagABInv[3];
+
+    btJacobianEntry	m_jacAng[3];
+
+	btScalar m_timeStep;
+    btTransform m_calculatedTransformA;
+    btTransform m_calculatedTransformB;
+
+	btVector3 m_sliderAxis;
+	btVector3 m_realPivotAInW;
+	btVector3 m_realPivotBInW;
+	btVector3 m_projPivotInW;
+	btVector3 m_delta;
+	btVector3 m_depth;
+	btVector3 m_relPosA;
+	btVector3 m_relPosB;
+
+	btScalar m_linPos;
+
+	btScalar m_angDepth;
+	btScalar m_kAngle;
+
+	bool	 m_poweredLinMotor;
+    btScalar m_targetLinMotorVelocity;
+    btScalar m_maxLinMotorForce;
+    btScalar m_accumulatedLinMotorImpulse;
+	
+	bool	 m_poweredAngMotor;
+    btScalar m_targetAngMotorVelocity;
+    btScalar m_maxAngMotorForce;
+    btScalar m_accumulatedAngMotorImpulse;
+
+	//------------------------    
+	void initParams();
+public:
+	// constructors
+    btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
+    btSliderConstraint();
+	// overrides
+    virtual void	buildJacobian();
+    virtual	void	solveConstraint(btScalar	timeStep);
+	// access
+    const btRigidBody& getRigidBodyA() const { return m_rbA; }
+    const btRigidBody& getRigidBodyB() const { return m_rbB; }
+    const btTransform & getCalculatedTransformA() const { return m_calculatedTransformA; }
+    const btTransform & getCalculatedTransformB() const { return m_calculatedTransformB; }
+    const btTransform & getFrameOffsetA() const { return m_frameInA; }
+    const btTransform & getFrameOffsetB() const { return m_frameInB; }
+    btTransform & getFrameOffsetA() { return m_frameInA; }
+    btTransform & getFrameOffsetB() { return m_frameInB; }
+    btScalar getLowerLinLimit() { return m_lowerLinLimit; }
+    void setLowerLinLimit(btScalar lowerLimit) { m_lowerLinLimit = lowerLimit; }
+    btScalar getUpperLinLimit() { return m_upperLinLimit; }
+    void setUpperLinLimit(btScalar upperLimit) { m_upperLinLimit = upperLimit; }
+    btScalar getLowerAngLimit() { return m_lowerAngLimit; }
+    void setLowerAngLimit(btScalar lowerLimit) { m_lowerAngLimit = lowerLimit; }
+    btScalar getUpperAngLimit() { return m_upperAngLimit; }
+    void setUpperAngLimit(btScalar upperLimit) { m_upperAngLimit = upperLimit; }
+	bool getUseLinearReferenceFrameA() { return m_useLinearReferenceFrameA; }
+	btScalar getSoftnessDirLin() { return m_softnessDirLin; }
+	btScalar getRestitutionDirLin() { return m_restitutionDirLin; }
+	btScalar getDampingDirLin() { return m_dampingDirLin ; }
+	btScalar getSoftnessDirAng() { return m_softnessDirAng; }
+	btScalar getRestitutionDirAng() { return m_restitutionDirAng; }
+	btScalar getDampingDirAng() { return m_dampingDirAng; }
+	btScalar getSoftnessLimLin() { return m_softnessLimLin; }
+	btScalar getRestitutionLimLin() { return m_restitutionLimLin; }
+	btScalar getDampingLimLin() { return m_dampingLimLin; }
+	btScalar getSoftnessLimAng() { return m_softnessLimAng; }
+	btScalar getRestitutionLimAng() { return m_restitutionLimAng; }
+	btScalar getDampingLimAng() { return m_dampingLimAng; }
+	btScalar getSoftnessOrthoLin() { return m_softnessOrthoLin; }
+	btScalar getRestitutionOrthoLin() { return m_restitutionOrthoLin; }
+	btScalar getDampingOrthoLin() { return m_dampingOrthoLin; }
+	btScalar getSoftnessOrthoAng() { return m_softnessOrthoAng; }
+	btScalar getRestitutionOrthoAng() { return m_restitutionOrthoAng; }
+	btScalar getDampingOrthoAng() { return m_dampingOrthoAng; }
+	void setSoftnessDirLin(btScalar softnessDirLin) { m_softnessDirLin = softnessDirLin; }
+	void setRestitutionDirLin(btScalar restitutionDirLin) { m_restitutionDirLin = restitutionDirLin; }
+	void setDampingDirLin(btScalar dampingDirLin) { m_dampingDirLin = dampingDirLin; }
+	void setSoftnessDirAng(btScalar softnessDirAng) { m_softnessDirAng = softnessDirAng; }
+	void setRestitutionDirAng(btScalar restitutionDirAng) { m_restitutionDirAng = restitutionDirAng; }
+	void setDampingDirAng(btScalar dampingDirAng) { m_dampingDirAng = dampingDirAng; }
+	void setSoftnessLimLin(btScalar softnessLimLin) { m_softnessLimLin = softnessLimLin; }
+	void setRestitutionLimLin(btScalar restitutionLimLin) { m_restitutionLimLin = restitutionLimLin; }
+	void setDampingLimLin(btScalar dampingLimLin) { m_dampingLimLin = dampingLimLin; }
+	void setSoftnessLimAng(btScalar softnessLimAng) { m_softnessLimAng = softnessLimAng; }
+	void setRestitutionLimAng(btScalar restitutionLimAng) { m_restitutionLimAng = restitutionLimAng; }
+	void setDampingLimAng(btScalar dampingLimAng) { m_dampingLimAng = dampingLimAng; }
+	void setSoftnessOrthoLin(btScalar softnessOrthoLin) { m_softnessOrthoLin = softnessOrthoLin; }
+	void setRestitutionOrthoLin(btScalar restitutionOrthoLin) { m_restitutionOrthoLin = restitutionOrthoLin; }
+	void setDampingOrthoLin(btScalar dampingOrthoLin) { m_dampingOrthoLin = dampingOrthoLin; }
+	void setSoftnessOrthoAng(btScalar softnessOrthoAng) { m_softnessOrthoAng = softnessOrthoAng; }
+	void setRestitutionOrthoAng(btScalar restitutionOrthoAng) { m_restitutionOrthoAng = restitutionOrthoAng; }
+	void setDampingOrthoAng(btScalar dampingOrthoAng) { m_dampingOrthoAng = dampingOrthoAng; }
+	void setPoweredLinMotor(bool onOff) { m_poweredLinMotor = onOff; }
+	bool getPoweredLinMotor() { return m_poweredLinMotor; }
+	void setTargetLinMotorVelocity(btScalar targetLinMotorVelocity) { m_targetLinMotorVelocity = targetLinMotorVelocity; }
+	btScalar getTargetLinMotorVelocity() { return m_targetLinMotorVelocity; }
+	void setMaxLinMotorForce(btScalar maxLinMotorForce) { m_maxLinMotorForce = maxLinMotorForce; }
+	btScalar getMaxLinMotorForce() { return m_maxLinMotorForce; }
+	void setPoweredAngMotor(bool onOff) { m_poweredAngMotor = onOff; }
+	bool getPoweredAngMotor() { return m_poweredAngMotor; }
+	void setTargetAngMotorVelocity(btScalar targetAngMotorVelocity) { m_targetAngMotorVelocity = targetAngMotorVelocity; }
+	btScalar getTargetAngMotorVelocity() { return m_targetAngMotorVelocity; }
+	void setMaxAngMotorForce(btScalar maxAngMotorForce) { m_maxAngMotorForce = maxAngMotorForce; }
+	btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; }
+	btScalar getLinearPos() { return m_linPos; }
+
+	// access for ODE solver
+	bool getSolveLinLimit() { return m_solveLinLim; }
+	btScalar getLinDepth() { return m_depth[0]; }
+	bool getSolveAngLimit() { return m_solveAngLim; }
+	btScalar getAngDepth() { return m_angDepth; }
+	// internal
+    void	buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB);
+    void	solveConstraintInt(btRigidBody& rbA, btRigidBody& rbB);
+	// shared code used by ODE solver
+	void	calculateTransforms(void);
+	void	testLinLimits(void);
+	void	testAngLimits(void);
+	// access for PE Solver
+	btVector3 getAncorInA(void);
+	btVector3 getAncorInB(void);
+};
+
+//-----------------------------------------------------------------------------
+
+#endif //SLIDER_CONSTRAINT_H
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp	(revision 2122)
@@ -0,0 +1,255 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#include "btSolve2LinearConstraint.h"
+
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btVector3.h"
+#include "btJacobianEntry.h"
+
+
+void btSolve2LinearConstraint::resolveUnilateralPairConstraint(
+												   btRigidBody* body1,
+		btRigidBody* body2,
+
+						const btMatrix3x3& world2A,
+						const btMatrix3x3& world2B,
+						
+						const btVector3& invInertiaADiag,
+						const btScalar invMassA,
+						const btVector3& linvelA,const btVector3& angvelA,
+						const btVector3& rel_posA1,
+						const btVector3& invInertiaBDiag,
+						const btScalar invMassB,
+						const btVector3& linvelB,const btVector3& angvelB,
+						const btVector3& rel_posA2,
+
+					  btScalar depthA, const btVector3& normalA, 
+					  const btVector3& rel_posB1,const btVector3& rel_posB2,
+					  btScalar depthB, const btVector3& normalB, 
+					  btScalar& imp0,btScalar& imp1)
+{
+	(void)linvelA;
+	(void)linvelB;
+	(void)angvelB;
+	(void)angvelA;
+
+
+
+	imp0 = btScalar(0.);
+	imp1 = btScalar(0.);
+
+	btScalar len = btFabs(normalA.length()) - btScalar(1.);
+	if (btFabs(len) >= SIMD_EPSILON)
+		return;
+
+	btAssert(len < SIMD_EPSILON);
+
+
+	//this jacobian entry could be re-used for all iterations
+	btJacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA,
+		invInertiaBDiag,invMassB);
+	btJacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA,
+		invInertiaBDiag,invMassB);
+	
+	//const btScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB);
+	//const btScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB);
+
+	const btScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1));
+	const btScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1));
+
+//	btScalar penetrationImpulse = (depth*contactTau*timeCorrection)  * massTerm;//jacDiagABInv
+	btScalar massTerm = btScalar(1.) / (invMassA + invMassB);
+
+
+	// calculate rhs (or error) terms
+	const btScalar dv0 = depthA  * m_tau * massTerm - vel0 * m_damping;
+	const btScalar dv1 = depthB  * m_tau * massTerm - vel1 * m_damping;
+
+
+	// dC/dv * dv = -C
+	
+	// jacobian * impulse = -error
+	//
+
+	//impulse = jacobianInverse * -error
+
+	// inverting 2x2 symmetric system (offdiagonal are equal!)
+	// 
+
+
+	btScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB);
+	btScalar	invDet = btScalar(1.0) / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag );
+	
+	//imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet;
+	//imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet;
+
+	imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet;
+	imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet;
+
+	//[a b]								  [d -c]
+	//[c d] inverse = (1 / determinant) * [-b a] where determinant is (ad - bc)
+
+	//[jA nD] * [imp0] = [dv0]
+	//[nD jB]   [imp1]   [dv1]
+
+}
+
+
+
+void btSolve2LinearConstraint::resolveBilateralPairConstraint(
+						btRigidBody* body1,
+						btRigidBody* body2,
+						const btMatrix3x3& world2A,
+						const btMatrix3x3& world2B,
+						
+						const btVector3& invInertiaADiag,
+						const btScalar invMassA,
+						const btVector3& linvelA,const btVector3& angvelA,
+						const btVector3& rel_posA1,
+						const btVector3& invInertiaBDiag,
+						const btScalar invMassB,
+						const btVector3& linvelB,const btVector3& angvelB,
+						const btVector3& rel_posA2,
+
+					  btScalar depthA, const btVector3& normalA, 
+					  const btVector3& rel_posB1,const btVector3& rel_posB2,
+					  btScalar depthB, const btVector3& normalB, 
+					  btScalar& imp0,btScalar& imp1)
+{
+
+	(void)linvelA;
+	(void)linvelB;
+	(void)angvelA;
+	(void)angvelB;
+
+
+
+	imp0 = btScalar(0.);
+	imp1 = btScalar(0.);
+
+	btScalar len = btFabs(normalA.length()) - btScalar(1.);
+	if (btFabs(len) >= SIMD_EPSILON)
+		return;
+
+	btAssert(len < SIMD_EPSILON);
+
+
+	//this jacobian entry could be re-used for all iterations
+	btJacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA,
+		invInertiaBDiag,invMassB);
+	btJacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA,
+		invInertiaBDiag,invMassB);
+	
+	//const btScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB);
+	//const btScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB);
+
+	const btScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1));
+	const btScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1));
+
+	// calculate rhs (or error) terms
+	const btScalar dv0 = depthA  * m_tau - vel0 * m_damping;
+	const btScalar dv1 = depthB  * m_tau - vel1 * m_damping;
+
+	// dC/dv * dv = -C
+	
+	// jacobian * impulse = -error
+	//
+
+	//impulse = jacobianInverse * -error
+
+	// inverting 2x2 symmetric system (offdiagonal are equal!)
+	// 
+
+
+	btScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB);
+	btScalar	invDet = btScalar(1.0) / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag );
+	
+	//imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet;
+	//imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet;
+
+	imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet;
+	imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet;
+
+	//[a b]								  [d -c]
+	//[c d] inverse = (1 / determinant) * [-b a] where determinant is (ad - bc)
+
+	//[jA nD] * [imp0] = [dv0]
+	//[nD jB]   [imp1]   [dv1]
+
+	if ( imp0 > btScalar(0.0))
+	{
+		if ( imp1 > btScalar(0.0) )
+		{
+			//both positive
+		}
+		else
+		{
+			imp1 = btScalar(0.);
+
+			// now imp0>0 imp1<0
+			imp0 = dv0 / jacA.getDiagonal();
+			if ( imp0 > btScalar(0.0) )
+			{
+			} else
+			{
+				imp0 = btScalar(0.);
+			}
+		}
+	}
+	else
+	{
+		imp0 = btScalar(0.);
+
+		imp1 = dv1 / jacB.getDiagonal();
+		if ( imp1 <= btScalar(0.0) )
+		{
+			imp1 = btScalar(0.);
+			// now imp0>0 imp1<0
+			imp0 = dv0 / jacA.getDiagonal();
+			if ( imp0 > btScalar(0.0) )
+			{
+			} else
+			{
+				imp0 = btScalar(0.);
+			}
+		} else
+		{
+		}
+	}
+}
+
+
+/*
+void btSolve2LinearConstraint::resolveAngularConstraint(	const btMatrix3x3& invInertiaAWS,
+											const btScalar invMassA,
+											const btVector3& linvelA,const btVector3& angvelA,
+											const btVector3& rel_posA1,
+											const btMatrix3x3& invInertiaBWS,
+											const btScalar invMassB,
+											const btVector3& linvelB,const btVector3& angvelB,
+											const btVector3& rel_posA2,
+
+											btScalar depthA, const btVector3& normalA, 
+											const btVector3& rel_posB1,const btVector3& rel_posB2,
+											btScalar depthB, const btVector3& normalB, 
+											btScalar& imp0,btScalar& imp1)
+{
+
+}
+*/
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SOLVE_2LINEAR_CONSTRAINT_H
+#define SOLVE_2LINEAR_CONSTRAINT_H
+
+#include "LinearMath/btMatrix3x3.h"
+#include "LinearMath/btVector3.h"
+
+
+class btRigidBody;
+
+
+
+/// constraint class used for lateral tyre friction.
+class	btSolve2LinearConstraint
+{
+	btScalar	m_tau;
+	btScalar	m_damping;
+
+public:
+
+	btSolve2LinearConstraint(btScalar tau,btScalar damping)
+	{
+		m_tau = tau;
+		m_damping = damping;
+	}
+	//
+	// solve unilateral constraint (equality, direct method)
+	//
+	void resolveUnilateralPairConstraint(		
+														   btRigidBody* body0,
+		btRigidBody* body1,
+
+		const btMatrix3x3& world2A,
+						const btMatrix3x3& world2B,
+						
+						const btVector3& invInertiaADiag,
+						const btScalar invMassA,
+						const btVector3& linvelA,const btVector3& angvelA,
+						const btVector3& rel_posA1,
+						const btVector3& invInertiaBDiag,
+						const btScalar invMassB,
+						const btVector3& linvelB,const btVector3& angvelB,
+						const btVector3& rel_posA2,
+
+					  btScalar depthA, const btVector3& normalA, 
+					  const btVector3& rel_posB1,const btVector3& rel_posB2,
+					  btScalar depthB, const btVector3& normalB, 
+					  btScalar& imp0,btScalar& imp1);
+
+
+	//
+	// solving 2x2 lcp problem (inequality, direct solution )
+	//
+	void resolveBilateralPairConstraint(
+			btRigidBody* body0,
+						btRigidBody* body1,
+		const btMatrix3x3& world2A,
+						const btMatrix3x3& world2B,
+						
+						const btVector3& invInertiaADiag,
+						const btScalar invMassA,
+						const btVector3& linvelA,const btVector3& angvelA,
+						const btVector3& rel_posA1,
+						const btVector3& invInertiaBDiag,
+						const btScalar invMassB,
+						const btVector3& linvelB,const btVector3& angvelB,
+						const btVector3& rel_posA2,
+
+					  btScalar depthA, const btVector3& normalA, 
+					  const btVector3& rel_posB1,const btVector3& rel_posB2,
+					  btScalar depthB, const btVector3& normalB, 
+					  btScalar& imp0,btScalar& imp1);
+
+/*
+	void resolveAngularConstraint(	const btMatrix3x3& invInertiaAWS,
+						const btScalar invMassA,
+						const btVector3& linvelA,const btVector3& angvelA,
+						const btVector3& rel_posA1,
+						const btMatrix3x3& invInertiaBWS,
+						const btScalar invMassB,
+						const btVector3& linvelB,const btVector3& angvelB,
+						const btVector3& rel_posA2,
+
+					  btScalar depthA, const btVector3& normalA, 
+					  const btVector3& rel_posB1,const btVector3& rel_posB2,
+					  btScalar depthB, const btVector3& normalB, 
+					  btScalar& imp0,btScalar& imp1);
+
+*/
+
+};
+
+#endif //SOLVE_2LINEAR_CONSTRAINT_H
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolverBody.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolverBody.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolverBody.h	(revision 2122)
@@ -0,0 +1,113 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_SOLVER_BODY_H
+#define BT_SOLVER_BODY_H
+
+class	btRigidBody;
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btMatrix3x3.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "LinearMath/btAlignedAllocator.h"
+#include "LinearMath/btTransformUtil.h"
+
+
+///btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance.
+ATTRIBUTE_ALIGNED16 (struct)	btSolverBody
+{
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+	
+	btVector3		m_angularVelocity;
+	float			m_angularFactor;
+	float			m_invMass;
+	float			m_friction;
+	btRigidBody*	m_originalBody;
+	btVector3		m_linearVelocity;
+	btVector3		m_centerOfMassPosition;
+	
+	btVector3		m_pushVelocity;
+	btVector3		m_turnVelocity;
+	
+	
+	SIMD_FORCE_INLINE void	getVelocityInLocalPoint(const btVector3& rel_pos, btVector3& velocity ) const
+	{
+		velocity = m_linearVelocity + m_angularVelocity.cross(rel_pos);
+	}
+
+	//Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position
+	SIMD_FORCE_INLINE void internalApplyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude)
+	{
+		if (m_invMass)
+		{
+			m_linearVelocity += linearComponent*impulseMagnitude;
+			m_angularVelocity += angularComponent*(impulseMagnitude*m_angularFactor);
+		}
+	}
+	
+	SIMD_FORCE_INLINE void internalApplyPushImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude)
+	{
+		if (m_invMass)
+		{
+			m_pushVelocity += linearComponent*impulseMagnitude;
+			m_turnVelocity += angularComponent*(impulseMagnitude*m_angularFactor);
+		}
+	}
+
+	
+	void	writebackVelocity()
+	{
+		if (m_invMass)
+		{
+			m_originalBody->setLinearVelocity(m_linearVelocity);
+			m_originalBody->setAngularVelocity(m_angularVelocity);
+			
+			//m_originalBody->setCompanionId(-1);
+		}
+	}
+	
+
+	void	writebackVelocity(btScalar timeStep)
+	{
+		if (m_invMass)
+		{
+			m_originalBody->setLinearVelocity(m_linearVelocity);
+			m_originalBody->setAngularVelocity(m_angularVelocity);
+			
+			//correct the position/orientation based on push/turn recovery
+			btTransform newTransform;
+			btTransformUtil::integrateTransform(m_originalBody->getWorldTransform(),m_pushVelocity,m_turnVelocity,timeStep,newTransform);
+			m_originalBody->setWorldTransform(newTransform);
+			
+			//m_originalBody->setCompanionId(-1);
+		}
+	}
+
+	void	readVelocity()
+	{
+		if (m_invMass)
+		{
+			m_linearVelocity = m_originalBody->getLinearVelocity();
+			m_angularVelocity = m_originalBody->getAngularVelocity();
+		}
+	}
+
+	
+
+
+};
+
+#endif //BT_SOLVER_BODY_H
+
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolverConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolverConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btSolverConstraint.h	(revision 2122)
@@ -0,0 +1,72 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_SOLVER_CONSTRAINT_H
+#define BT_SOLVER_CONSTRAINT_H
+
+class	btRigidBody;
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btMatrix3x3.h"
+
+//#define NO_FRICTION_TANGENTIALS 1
+
+///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints.
+ATTRIBUTE_ALIGNED16 (struct)	btSolverConstraint
+{
+	BT_DECLARE_ALIGNED_ALLOCATOR();
+
+	btVector3	m_relpos1CrossNormal;
+	btVector3	m_contactNormal;
+
+	btVector3	m_relpos2CrossNormal;
+	btVector3	m_angularComponentA;
+
+	btVector3	m_angularComponentB;
+
+	mutable btScalar	m_appliedPushImpulse;
+	
+	mutable btScalar	m_appliedImpulse;
+	int			m_solverBodyIdA;
+	int			m_solverBodyIdB;
+	
+	btScalar	m_friction;
+	btScalar	m_restitution;
+	btScalar	m_jacDiagABInv;
+	btScalar	m_penetration;
+	
+
+	
+	int			m_constraintType;
+	int			m_frictionIndex;
+	void*		m_originalContactPoint;
+	int			m_unusedPadding[1];
+
+
+	enum		btSolverConstraintType
+	{
+		BT_SOLVER_CONTACT_1D = 0,
+		BT_SOLVER_FRICTION_1D
+	};
+};
+
+
+
+
+
+
+#endif //BT_SOLVER_CONSTRAINT_H
+
+
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp	(revision 2122)
@@ -0,0 +1,56 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btTypedConstraint.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+static btRigidBody s_fixed(0, 0,0);
+
+btTypedConstraint::btTypedConstraint(btTypedConstraintType type)
+:m_userConstraintType(-1),
+m_userConstraintId(-1),
+m_constraintType (type),
+m_rbA(s_fixed),
+m_rbB(s_fixed),
+m_appliedImpulse(btScalar(0.))
+{
+	s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
+}
+btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA)
+:m_userConstraintType(-1),
+m_userConstraintId(-1),
+m_constraintType (type),
+m_rbA(rbA),
+m_rbB(s_fixed),
+m_appliedImpulse(btScalar(0.))
+{
+		s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
+
+}
+
+
+btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB)
+:m_userConstraintType(-1),
+m_userConstraintId(-1),
+m_constraintType (type),
+m_rbA(rbA),
+m_rbB(rbB),
+m_appliedImpulse(btScalar(0.))
+{
+		s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
+
+}
+
Index: /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.h	(revision 2122)
@@ -0,0 +1,120 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef TYPED_CONSTRAINT_H
+#define TYPED_CONSTRAINT_H
+
+class btRigidBody;
+#include "LinearMath/btScalar.h"
+
+enum btTypedConstraintType
+{
+	POINT2POINT_CONSTRAINT_TYPE,
+	HINGE_CONSTRAINT_TYPE,
+	CONETWIST_CONSTRAINT_TYPE,
+	D6_CONSTRAINT_TYPE,
+	VEHICLE_CONSTRAINT_TYPE,
+	SLIDER_CONSTRAINT_TYPE
+};
+
+///TypedConstraint is the baseclass for Bullet constraints and vehicles
+class btTypedConstraint
+{
+	int	m_userConstraintType;
+	int	m_userConstraintId;
+
+	btTypedConstraintType m_constraintType;
+
+	btTypedConstraint&	operator=(btTypedConstraint&	other)
+	{
+		btAssert(0);
+		(void) other;
+		return *this;
+	}
+
+protected:
+	btRigidBody&	m_rbA;
+	btRigidBody&	m_rbB;
+	btScalar	m_appliedImpulse;
+
+
+public:
+
+	btTypedConstraint(btTypedConstraintType type);
+	virtual ~btTypedConstraint() {};
+	btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA);
+
+	btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB);
+
+	virtual void	buildJacobian() = 0;
+
+	virtual	void	solveConstraint(btScalar	timeStep) = 0;
+
+	const btRigidBody& getRigidBodyA() const
+	{
+		return m_rbA;
+	}
+	const btRigidBody& getRigidBodyB() const
+	{
+		return m_rbB;
+	}
+
+	btRigidBody& getRigidBodyA() 
+	{
+		return m_rbA;
+	}
+	btRigidBody& getRigidBodyB()
+	{
+		return m_rbB;
+	}
+
+	int getUserConstraintType() const
+	{
+		return m_userConstraintType ;
+	}
+
+	void	setUserConstraintType(int userConstraintType)
+	{
+		m_userConstraintType = userConstraintType;
+	};
+
+	void	setUserConstraintId(int uid)
+	{
+		m_userConstraintId = uid;
+	}
+	
+	int getUserConstraintId() const
+	{
+		return m_userConstraintId;
+	}
+
+	int getUid() const
+	{
+		return m_userConstraintId;   
+	} 
+
+	btScalar	getAppliedImpulse() const
+	{
+		return m_appliedImpulse;
+	}
+
+	btTypedConstraintType getConstraintType () const
+	{
+		return m_constraintType;
+	}
+
+};
+
+#endif //TYPED_CONSTRAINT_H
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/Bullet-C-API.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/Bullet-C-API.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/Bullet-C-API.cpp	(revision 2122)
@@ -0,0 +1,400 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+	Draft high-level generic physics C-API. For low-level access, use the physics SDK native API's.
+	Work in progress, functionality will be added on demand.
+
+	If possible, use the richer Bullet C++ API, by including <src/btBulletDynamicsCommon.h>
+*/
+
+#include "Bullet-C-Api.h"
+#include "btBulletDynamicsCommon.h"
+#include "LinearMath/btAlignedAllocator.h"
+
+
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btScalar.h"	
+#include "LinearMath/btMatrix3x3.h"
+#include "LinearMath/btTransform.h"
+#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+
+#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
+#include "BulletCollision/NarrowPhaseCollision/btPointCollector.h"
+#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
+#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
+#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
+#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
+#include "LinearMath/btStackAlloc.h"
+
+/*
+	Create and Delete a Physics SDK	
+*/
+
+struct	btPhysicsSdk
+{
+
+//	btDispatcher*				m_dispatcher;
+//	btOverlappingPairCache*		m_pairCache;
+//	btConstraintSolver*			m_constraintSolver
+
+	btVector3	m_worldAabbMin;
+	btVector3	m_worldAabbMax;
+
+
+	//todo: version, hardware/optimization settings etc?
+	btPhysicsSdk()
+		:m_worldAabbMin(-1000,-1000,-1000),
+		m_worldAabbMax(1000,1000,1000)
+	{
+
+	}
+
+	
+};
+
+plPhysicsSdkHandle	plNewBulletSdk()
+{
+	void* mem = btAlignedAlloc(sizeof(btPhysicsSdk),16);
+	return (plPhysicsSdkHandle)new (mem)btPhysicsSdk;
+}
+
+void		plDeletePhysicsSdk(plPhysicsSdkHandle	physicsSdk)
+{
+	btPhysicsSdk* phys = reinterpret_cast<btPhysicsSdk*>(physicsSdk);
+	btAlignedFree(phys);	
+}
+
+
+/* Dynamics World */
+plDynamicsWorldHandle plCreateDynamicsWorld(plPhysicsSdkHandle physicsSdkHandle)
+{
+	btPhysicsSdk* physicsSdk = reinterpret_cast<btPhysicsSdk*>(physicsSdkHandle);
+	void* mem = btAlignedAlloc(sizeof(btDefaultCollisionConfiguration),16);
+	btDefaultCollisionConfiguration* collisionConfiguration = new (mem)btDefaultCollisionConfiguration();
+	mem = btAlignedAlloc(sizeof(btCollisionDispatcher),16);
+	btDispatcher*				dispatcher = new (mem)btCollisionDispatcher(collisionConfiguration);
+	mem = btAlignedAlloc(sizeof(btAxisSweep3),16);
+	btBroadphaseInterface*		pairCache = new (mem)btAxisSweep3(physicsSdk->m_worldAabbMin,physicsSdk->m_worldAabbMax);
+	mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16);
+	btConstraintSolver*			constraintSolver = new(mem) btSequentialImpulseConstraintSolver();
+
+	mem = btAlignedAlloc(sizeof(btDiscreteDynamicsWorld),16);
+	return (plDynamicsWorldHandle) new (mem)btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
+}
+void           plDeleteDynamicsWorld(plDynamicsWorldHandle world)
+{
+	//todo: also clean up the other allocations, axisSweep, pairCache,dispatcher,constraintSolver,collisionConfiguration
+	btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
+	btAlignedFree(dynamicsWorld);
+}
+
+void	plStepSimulation(plDynamicsWorldHandle world,	plReal	timeStep)
+{
+	btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
+	assert(dynamicsWorld);
+	dynamicsWorld->stepSimulation(timeStep);
+}
+
+void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object)
+{
+	btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
+	assert(dynamicsWorld);
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
+	assert(body);
+
+	dynamicsWorld->addRigidBody(body);
+}
+
+void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object)
+{
+	btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
+	assert(dynamicsWorld);
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
+	assert(body);
+
+	dynamicsWorld->removeRigidBody(body);
+}
+
+/* Rigid Body  */
+
+plRigidBodyHandle plCreateRigidBody(	void* user_data,  float mass, plCollisionShapeHandle cshape )
+{
+	btTransform trans;
+	trans.setIdentity();
+	btVector3 localInertia(0,0,0);
+	btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
+	assert(shape);
+	if (mass)
+	{
+		shape->calculateLocalInertia(mass,localInertia);
+	}
+	void* mem = btAlignedAlloc(sizeof(btRigidBody),16);
+	btRigidBody::btRigidBodyConstructionInfo rbci(mass, 0,shape,localInertia);
+	btRigidBody* body = new (mem)btRigidBody(rbci);
+	body->setWorldTransform(trans);
+	body->setUserPointer(user_data);
+	return (plRigidBodyHandle) body;
+}
+
+void plDeleteRigidBody(plRigidBodyHandle cbody)
+{
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(cbody);
+	assert(body);
+	btAlignedFree( body);
+}
+
+
+/* Collision Shape definition */
+
+plCollisionShapeHandle plNewSphereShape(plReal radius)
+{
+	void* mem = btAlignedAlloc(sizeof(btSphereShape),16);
+	return (plCollisionShapeHandle) new (mem)btSphereShape(radius);
+	
+}
+	
+plCollisionShapeHandle plNewBoxShape(plReal x, plReal y, plReal z)
+{
+	void* mem = btAlignedAlloc(sizeof(btBoxShape),16);
+	return (plCollisionShapeHandle) new (mem)btBoxShape(btVector3(x,y,z));
+}
+
+plCollisionShapeHandle plNewCapsuleShape(plReal radius, plReal height)
+{
+	//capsule is convex hull of 2 spheres, so use btMultiSphereShape
+	btVector3 inertiaHalfExtents(radius,height,radius);
+	const int numSpheres = 2;
+	btVector3 positions[numSpheres] = {btVector3(0,height,0),btVector3(0,-height,0)};
+	btScalar radi[numSpheres] = {radius,radius};
+	void* mem = btAlignedAlloc(sizeof(btMultiSphereShape),16);
+	return (plCollisionShapeHandle) new (mem)btMultiSphereShape(inertiaHalfExtents,positions,radi,numSpheres);
+}
+plCollisionShapeHandle plNewConeShape(plReal radius, plReal height)
+{
+	void* mem = btAlignedAlloc(sizeof(btConeShape),16);
+	return (plCollisionShapeHandle) new (mem)btConeShape(radius,height);
+}
+
+plCollisionShapeHandle plNewCylinderShape(plReal radius, plReal height)
+{
+	void* mem = btAlignedAlloc(sizeof(btCylinderShape),16);
+	return (plCollisionShapeHandle) new (mem)btCylinderShape(btVector3(radius,height,radius));
+}
+
+/* Convex Meshes */
+plCollisionShapeHandle plNewConvexHullShape()
+{
+	void* mem = btAlignedAlloc(sizeof(btConvexHullShape),16);
+	return (plCollisionShapeHandle) new (mem)btConvexHullShape();
+}
+
+
+/* Concave static triangle meshes */
+plMeshInterfaceHandle		   plNewMeshInterface()
+{
+	return 0;
+}
+
+plCollisionShapeHandle plNewCompoundShape()
+{
+	void* mem = btAlignedAlloc(sizeof(btCompoundShape),16);
+	return (plCollisionShapeHandle) new (mem)btCompoundShape();
+}
+
+void	plAddChildShape(plCollisionShapeHandle compoundShapeHandle,plCollisionShapeHandle childShapeHandle, plVector3 childPos,plQuaternion childOrn)
+{
+	btCollisionShape* colShape = reinterpret_cast<btCollisionShape*>(compoundShapeHandle);
+	btAssert(colShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE);
+	btCompoundShape* compoundShape = reinterpret_cast<btCompoundShape*>(colShape);
+	btCollisionShape* childShape = reinterpret_cast<btCollisionShape*>(childShapeHandle);
+	btTransform	localTrans;
+	localTrans.setIdentity();
+	localTrans.setOrigin(btVector3(childPos[0],childPos[1],childPos[2]));
+	localTrans.setRotation(btQuaternion(childOrn[0],childOrn[1],childOrn[2],childOrn[3]));
+	compoundShape->addChildShape(localTrans,childShape);
+}
+
+void plSetEuler(plReal yaw,plReal pitch,plReal roll, plQuaternion orient)
+{
+	btQuaternion orn;
+	orn.setEuler(yaw,pitch,roll);
+	orient[0] = orn.getX();
+	orient[1] = orn.getY();
+	orient[2] = orn.getZ();
+	orient[3] = orn.getW();
+
+}
+
+
+//	extern  void		plAddTriangle(plMeshInterfaceHandle meshHandle, plVector3 v0,plVector3 v1,plVector3 v2);
+//	extern  plCollisionShapeHandle plNewStaticTriangleMeshShape(plMeshInterfaceHandle);
+
+
+void		plAddVertex(plCollisionShapeHandle cshape, plReal x,plReal y,plReal z)
+{
+	btCollisionShape* colShape = reinterpret_cast<btCollisionShape*>( cshape);
+	(void)colShape;
+	btAssert(colShape->getShapeType()==CONVEX_HULL_SHAPE_PROXYTYPE);
+	btConvexHullShape* convexHullShape = reinterpret_cast<btConvexHullShape*>( cshape);
+	convexHullShape->addPoint(btPoint3(x,y,z));
+
+}
+
+void plDeleteShape(plCollisionShapeHandle cshape)
+{
+	btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
+	assert(shape);
+	btAlignedFree(shape);
+}
+void plSetScaling(plCollisionShapeHandle cshape, plVector3 cscaling)
+{
+	btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
+	assert(shape);
+	btVector3 scaling(cscaling[0],cscaling[1],cscaling[2]);
+	shape->setLocalScaling(scaling);	
+}
+
+
+
+void plSetPosition(plRigidBodyHandle object, const plVector3 position)
+{
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
+	btAssert(body);
+	btVector3 pos(position[0],position[1],position[2]);
+	btTransform worldTrans = body->getWorldTransform();
+	worldTrans.setOrigin(pos);
+	body->setWorldTransform(worldTrans);
+}
+
+void plSetOrientation(plRigidBodyHandle object, const plQuaternion orientation)
+{
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
+	btAssert(body);
+	btQuaternion orn(orientation[0],orientation[1],orientation[2],orientation[3]);
+	btTransform worldTrans = body->getWorldTransform();
+	worldTrans.setRotation(orn);
+	body->setWorldTransform(worldTrans);
+}
+
+void	plGetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix)
+{
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
+	btAssert(body);
+	body->getWorldTransform().getOpenGLMatrix(matrix);
+
+}
+
+void	plGetPosition(plRigidBodyHandle object,plVector3 position)
+{
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
+	btAssert(body);
+	const btVector3& pos = body->getWorldTransform().getOrigin();
+	position[0] = pos.getX();
+	position[1] = pos.getY();
+	position[2] = pos.getZ();
+}
+
+void plGetOrientation(plRigidBodyHandle object,plQuaternion orientation)
+{
+	btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
+	btAssert(body);
+	const btQuaternion& orn = body->getWorldTransform().getRotation();
+	orientation[0] = orn.getX();
+	orientation[1] = orn.getY();
+	orientation[2] = orn.getZ();
+	orientation[3] = orn.getW();
+}
+
+
+
+//plRigidBodyHandle plRayCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal);
+
+//	extern  plRigidBodyHandle plObjectCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal);
+
+double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float q2[3], float q3[3], float *pa, float *pb, float normal[3])
+{
+	btVector3 vp(p1[0], p1[1], p1[2]);
+	btTriangleShape trishapeA(vp, 
+				  btVector3(p2[0], p2[1], p2[2]), 
+				  btVector3(p3[0], p3[1], p3[2]));
+	trishapeA.setMargin(0.000001f);
+	btVector3 vq(q1[0], q1[1], q1[2]);
+	btTriangleShape trishapeB(vq, 
+				  btVector3(q2[0], q2[1], q2[2]), 
+				  btVector3(q3[0], q3[1], q3[2]));
+	trishapeB.setMargin(0.000001f);
+	
+	// btVoronoiSimplexSolver sGjkSimplexSolver;
+	// btGjkEpaPenetrationDepthSolver penSolverPtr;	
+	
+	static btSimplexSolverInterface sGjkSimplexSolver;
+	sGjkSimplexSolver.reset();
+	
+	static btGjkEpaPenetrationDepthSolver Solver0;
+	static btMinkowskiPenetrationDepthSolver Solver1;
+		
+	btConvexPenetrationDepthSolver* Solver = NULL;
+	
+	Solver = &Solver1;	
+		
+	btGjkPairDetector convexConvex(&trishapeA ,&trishapeB,&sGjkSimplexSolver,Solver);
+	
+	convexConvex.m_catchDegeneracies = 1;
+	
+	// btGjkPairDetector convexConvex(&trishapeA ,&trishapeB,&sGjkSimplexSolver,0);
+	
+	btPointCollector gjkOutput;
+	btGjkPairDetector::ClosestPointInput input;
+	
+	btStackAlloc gStackAlloc(1024*1024*2);
+ 
+	input.m_stackAlloc = &gStackAlloc;
+	
+	btTransform tr;
+	tr.setIdentity();
+	
+	input.m_transformA = tr;
+	input.m_transformB = tr;
+	
+	convexConvex.getClosestPoints(input, gjkOutput, 0);
+	
+	
+	if (gjkOutput.m_hasResult)
+	{
+		
+		pb[0] = pa[0] = gjkOutput.m_pointInWorld[0];
+		pb[1] = pa[1] = gjkOutput.m_pointInWorld[1];
+		pb[2] = pa[2] = gjkOutput.m_pointInWorld[2];
+
+		pb[0]+= gjkOutput.m_normalOnBInWorld[0] * gjkOutput.m_distance;
+		pb[1]+= gjkOutput.m_normalOnBInWorld[1] * gjkOutput.m_distance;
+		pb[2]+= gjkOutput.m_normalOnBInWorld[2] * gjkOutput.m_distance;
+		
+		normal[0] = gjkOutput.m_normalOnBInWorld[0];
+		normal[1] = gjkOutput.m_normalOnBInWorld[1];
+		normal[2] = gjkOutput.m_normalOnBInWorld[2];
+
+		return gjkOutput.m_distance;
+	}
+	return -1.0f;	
+}
+
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp	(revision 2122)
@@ -0,0 +1,193 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btContinuousDynamicsWorld.h"
+#include "LinearMath/btQuickprof.h"
+
+//collision detection
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
+
+//rigidbody & constraints
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
+#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
+#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
+
+
+
+#include <stdio.h>
+
+btContinuousDynamicsWorld::btContinuousDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
+:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration)
+{
+}
+
+btContinuousDynamicsWorld::~btContinuousDynamicsWorld()
+{
+}
+
+	
+void	btContinuousDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
+{
+	
+	startProfiling(timeStep);
+	
+
+	///update aabbs information
+	updateAabbs();
+	//static int frame=0;
+//	printf("frame %d\n",frame++);
+
+	///apply gravity, predict motion
+	predictUnconstraintMotion(timeStep);
+
+	btDispatcherInfo& dispatchInfo = getDispatchInfo();
+
+	dispatchInfo.m_timeStep = timeStep;
+	dispatchInfo.m_stepCount = 0;
+	dispatchInfo.m_debugDraw = getDebugDrawer();
+
+	///perform collision detection
+	performDiscreteCollisionDetection();
+
+	calculateSimulationIslands();
+
+	
+	getSolverInfo().m_timeStep = timeStep;
+	
+
+
+	///solve contact and other joint constraints
+	solveConstraints(getSolverInfo());
+	
+	///CallbackTriggers();
+	calculateTimeOfImpacts(timeStep);
+
+	btScalar toi = dispatchInfo.m_timeOfImpact;
+//	if (toi < 1.f)
+//		printf("toi = %f\n",toi);
+	if (toi < 0.f)
+		printf("toi = %f\n",toi);
+
+
+	///integrate transforms
+	integrateTransforms(timeStep * toi);
+
+	///update vehicle simulation
+	updateVehicles(timeStep);
+
+
+	updateActivationState( timeStep );
+	
+	if(0 != m_internalTickCallback) {
+		(*m_internalTickCallback)(this, timeStep);
+	}
+}
+
+void	btContinuousDynamicsWorld::calculateTimeOfImpacts(btScalar timeStep)
+{
+		///these should be 'temporal' aabbs!
+		updateTemporalAabbs(timeStep);
+		
+		///'toi' is the global smallest time of impact. However, we just calculate the time of impact for each object individually.
+		///so we handle the case moving versus static properly, and we cheat for moving versus moving
+		btScalar toi = 1.f;
+		
+	
+		btDispatcherInfo& dispatchInfo = getDispatchInfo();
+		dispatchInfo.m_timeStep = timeStep;
+		dispatchInfo.m_timeOfImpact = 1.f;
+		dispatchInfo.m_stepCount = 0;
+		dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS;
+
+		///calculate time of impact for overlapping pairs
+
+
+		btDispatcher* dispatcher = getDispatcher();
+		if (dispatcher)
+			dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1);
+
+		toi = dispatchInfo.m_timeOfImpact;
+
+		dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_DISCRETE;
+
+}
+
+void	btContinuousDynamicsWorld::updateTemporalAabbs(btScalar timeStep)
+{
+
+	btVector3 temporalAabbMin,temporalAabbMax;
+
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			body->getCollisionShape()->getAabb(m_collisionObjects[i]->getWorldTransform(),temporalAabbMin,temporalAabbMax);
+			const btVector3& linvel = body->getLinearVelocity();
+
+			//make the AABB temporal
+			btScalar temporalAabbMaxx = temporalAabbMax.getX();
+			btScalar temporalAabbMaxy = temporalAabbMax.getY();
+			btScalar temporalAabbMaxz = temporalAabbMax.getZ();
+			btScalar temporalAabbMinx = temporalAabbMin.getX();
+			btScalar temporalAabbMiny = temporalAabbMin.getY();
+			btScalar temporalAabbMinz = temporalAabbMin.getZ();
+
+			// add linear motion
+			btVector3 linMotion = linvel*timeStep;
+		
+			if (linMotion.x() > 0.f)
+				temporalAabbMaxx += linMotion.x(); 
+			else
+				temporalAabbMinx += linMotion.x();
+			if (linMotion.y() > 0.f)
+				temporalAabbMaxy += linMotion.y(); 
+			else
+				temporalAabbMiny += linMotion.y();
+			if (linMotion.z() > 0.f)
+				temporalAabbMaxz += linMotion.z(); 
+			else
+				temporalAabbMinz += linMotion.z();
+
+			//add conservative angular motion
+			btScalar angularMotion(0);// = angvel.length() * GetAngularMotionDisc() * timeStep;
+			btVector3 angularMotion3d(angularMotion,angularMotion,angularMotion);
+			temporalAabbMin = btVector3(temporalAabbMinx,temporalAabbMiny,temporalAabbMinz);
+			temporalAabbMax = btVector3(temporalAabbMaxx,temporalAabbMaxy,temporalAabbMaxz);
+
+			temporalAabbMin -= angularMotion3d;
+			temporalAabbMax += angularMotion3d;
+
+			m_broadphasePairCache->setAabb(body->getBroadphaseHandle(),temporalAabbMin,temporalAabbMax,m_dispatcher1);
+		}
+	}
+
+	//update aabb (of all moved objects)
+
+	m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1);
+	
+
+
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btContinuousDynamicsWorld.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btContinuousDynamicsWorld.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btContinuousDynamicsWorld.h	(revision 2122)
@@ -0,0 +1,46 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_CONTINUOUS_DYNAMICS_WORLD_H
+#define BT_CONTINUOUS_DYNAMICS_WORLD_H
+
+#include "btDiscreteDynamicsWorld.h"
+
+///btContinuousDynamicsWorld adds optional (per object) continuous collision detection for fast moving objects to the btDiscreteDynamicsWorld.
+///This copes with fast moving objects that otherwise would tunnel/miss collisions.
+///Under construction, don't use yet! Please use btDiscreteDynamicsWorld instead.
+class btContinuousDynamicsWorld : public btDiscreteDynamicsWorld
+{
+
+	void	updateTemporalAabbs(btScalar timeStep);
+
+	public:
+
+		btContinuousDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
+		virtual ~btContinuousDynamicsWorld();
+		
+		///time stepping with calculation of time of impact for selected fast moving objects
+		virtual void	internalSingleStepSimulation( btScalar timeStep);
+
+		virtual void	calculateTimeOfImpacts(btScalar timeStep);
+
+		virtual btDynamicsWorldType	getWorldType() const
+		{
+			return BT_CONTINUOUS_DYNAMICS_WORLD;
+		}
+
+};
+
+#endif //BT_CONTINUOUS_DYNAMICS_WORLD_H
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp	(revision 2122)
@@ -0,0 +1,1171 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btDiscreteDynamicsWorld.h"
+
+//collision detection
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
+#include "LinearMath/btTransformUtil.h"
+#include "LinearMath/btQuickprof.h"
+
+//rigidbody & constraints
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
+#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
+#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
+
+//for debug rendering
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
+#include "BulletCollision/CollisionShapes/btCompoundShape.h"
+#include "BulletCollision/CollisionShapes/btConeShape.h"
+#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btCylinderShape.h"
+#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
+#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleCallback.h"
+#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
+#include "LinearMath/btIDebugDraw.h"
+
+
+
+//vehicle
+#include "BulletDynamics/Vehicle/btRaycastVehicle.h"
+#include "BulletDynamics/Vehicle/btVehicleRaycaster.h"
+#include "BulletDynamics/Vehicle/btWheelInfo.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "LinearMath/btQuickprof.h"
+#include "LinearMath/btMotionState.h"
+
+
+
+
+
+btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver, btCollisionConfiguration* collisionConfiguration)
+:btDynamicsWorld(dispatcher,pairCache,collisionConfiguration),
+m_constraintSolver(constraintSolver),
+m_gravity(0,-10,0),
+m_localTime(btScalar(1.)/btScalar(60.)),
+m_profileTimings(0)
+{
+	if (!m_constraintSolver)
+	{
+		void* mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16);
+		m_constraintSolver = new (mem) btSequentialImpulseConstraintSolver;
+		m_ownsConstraintSolver = true;
+	} else
+	{
+		m_ownsConstraintSolver = false;
+	}
+
+	{
+		void* mem = btAlignedAlloc(sizeof(btSimulationIslandManager),16);
+		m_islandManager = new (mem) btSimulationIslandManager();
+	}
+
+	m_ownsIslandManager = true;
+}
+
+
+btDiscreteDynamicsWorld::~btDiscreteDynamicsWorld()
+{
+	//only delete it when we created it
+	if (m_ownsIslandManager)
+	{
+		m_islandManager->~btSimulationIslandManager();
+		btAlignedFree( m_islandManager);
+	}
+	if (m_ownsConstraintSolver)
+	{
+
+		m_constraintSolver->~btConstraintSolver();
+		btAlignedFree(m_constraintSolver);
+	}
+}
+
+void	btDiscreteDynamicsWorld::saveKinematicState(btScalar timeStep)
+{
+
+	for (int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+				btTransform predictedTrans;
+				if (body->getActivationState() != ISLAND_SLEEPING)
+				{
+					if (body->isKinematicObject())
+					{
+						//to calculate velocities next frame
+						body->saveKinematicState(timeStep);
+					}
+				}
+		}
+	}
+}
+
+void	btDiscreteDynamicsWorld::debugDrawWorld()
+{
+
+	if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
+	{
+		int numManifolds = getDispatcher()->getNumManifolds();
+		btVector3 color(0,0,0);
+		for (int i=0;i<numManifolds;i++)
+		{
+			btPersistentManifold* contactManifold = getDispatcher()->getManifoldByIndexInternal(i);
+			//btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
+			//btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
+
+			int numContacts = contactManifold->getNumContacts();
+			for (int j=0;j<numContacts;j++)
+			{
+				btManifoldPoint& cp = contactManifold->getContactPoint(j);
+				getDebugDrawer()->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color);
+			}
+		}
+	}
+
+
+	if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb))
+	{
+		int i;
+
+		//todo: iterate over awake simulation islands!
+		for (  i=0;i<m_collisionObjects.size();i++)
+		{
+			btCollisionObject* colObj = m_collisionObjects[i];
+			if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawWireframe)
+			{
+				btVector3 color(btScalar(255.),btScalar(255.),btScalar(255.));
+				switch(colObj->getActivationState())
+				{
+				case  ACTIVE_TAG:
+					color = btVector3(btScalar(255.),btScalar(255.),btScalar(255.)); break;
+				case ISLAND_SLEEPING:
+					color =  btVector3(btScalar(0.),btScalar(255.),btScalar(0.));break;
+				case WANTS_DEACTIVATION:
+					color = btVector3(btScalar(0.),btScalar(255.),btScalar(255.));break;
+				case DISABLE_DEACTIVATION:
+					color = btVector3(btScalar(255.),btScalar(0.),btScalar(0.));break;
+				case DISABLE_SIMULATION:
+					color = btVector3(btScalar(255.),btScalar(255.),btScalar(0.));break;
+				default:
+					{
+						color = btVector3(btScalar(255.),btScalar(0.),btScalar(0.));
+					}
+				};
+
+				debugDrawObject(colObj->getWorldTransform(),colObj->getCollisionShape(),color);
+			}
+			if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
+			{
+				btPoint3 minAabb,maxAabb;
+				btVector3 colorvec(1,0,0);
+				colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
+				m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec);
+			}
+
+		}
+	
+		for (  i=0;i<this->m_vehicles.size();i++)
+		{
+			for (int v=0;v<m_vehicles[i]->getNumWheels();v++)
+			{
+				btVector3 wheelColor(0,255,255);
+				if (m_vehicles[i]->getWheelInfo(v).m_raycastInfo.m_isInContact)
+				{
+					wheelColor.setValue(0,0,255);
+				} else
+				{
+					wheelColor.setValue(255,0,255);
+				}
+		
+				btVector3 wheelPosWS = m_vehicles[i]->getWheelInfo(v).m_worldTransform.getOrigin();
+
+				btVector3 axle = btVector3(	
+					m_vehicles[i]->getWheelInfo(v).m_worldTransform.getBasis()[0][m_vehicles[i]->getRightAxis()],
+					m_vehicles[i]->getWheelInfo(v).m_worldTransform.getBasis()[1][m_vehicles[i]->getRightAxis()],
+					m_vehicles[i]->getWheelInfo(v).m_worldTransform.getBasis()[2][m_vehicles[i]->getRightAxis()]);
+
+
+				//m_vehicles[i]->getWheelInfo(v).m_raycastInfo.m_wheelAxleWS
+				//debug wheels (cylinders)
+				m_debugDrawer->drawLine(wheelPosWS,wheelPosWS+axle,wheelColor);
+				m_debugDrawer->drawLine(wheelPosWS,m_vehicles[i]->getWheelInfo(v).m_raycastInfo.m_contactPointWS,wheelColor);
+
+			}
+		}
+	}
+}
+
+void	btDiscreteDynamicsWorld::clearForces()
+{
+	//todo: iterate over awake simulation islands!
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			body->clearForces();
+		}
+	}
+}	
+
+///apply gravity, call this once per timestep
+void	btDiscreteDynamicsWorld::applyGravity()
+{
+	//todo: iterate over awake simulation islands!
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body && body->isActive())
+		{
+			body->applyGravity();
+		}
+	}
+}
+
+
+
+void	btDiscreteDynamicsWorld::synchronizeMotionStates()
+{
+	{
+		//todo: iterate over awake simulation islands!
+		for ( int i=0;i<m_collisionObjects.size();i++)
+		{
+			btCollisionObject* colObj = m_collisionObjects[i];
+			
+			btRigidBody* body = btRigidBody::upcast(colObj);
+			if (body && body->getMotionState() && !body->isStaticOrKinematicObject())
+			{
+				//we need to call the update at least once, even for sleeping objects
+				//otherwise the 'graphics' transform never updates properly
+				//so todo: add 'dirty' flag
+				//if (body->getActivationState() != ISLAND_SLEEPING)
+				{
+					btTransform interpolatedTransform;
+					btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(),
+						body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),m_localTime*body->getHitFraction(),interpolatedTransform);
+					body->getMotionState()->setWorldTransform(interpolatedTransform);
+				}
+			}
+		}
+	}
+
+	if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawWireframe)
+	{
+		for ( int i=0;i<this->m_vehicles.size();i++)
+		{
+			for (int v=0;v<m_vehicles[i]->getNumWheels();v++)
+			{
+				//synchronize the wheels with the (interpolated) chassis worldtransform
+				m_vehicles[i]->updateWheelTransform(v,true);
+			}
+		}
+	}
+
+}
+
+
+int	btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btScalar fixedTimeStep)
+{
+	startProfiling(timeStep);
+
+	BT_PROFILE("stepSimulation");
+
+	int numSimulationSubSteps = 0;
+
+	if (maxSubSteps)
+	{
+		//fixed timestep with interpolation
+		m_localTime += timeStep;
+		if (m_localTime >= fixedTimeStep)
+		{
+			numSimulationSubSteps = int( m_localTime / fixedTimeStep);
+			m_localTime -= numSimulationSubSteps * fixedTimeStep;
+		}
+	} else
+	{
+		//variable timestep
+		fixedTimeStep = timeStep;
+		m_localTime = timeStep;
+		if (btFuzzyZero(timeStep))
+		{
+			numSimulationSubSteps = 0;
+			maxSubSteps = 0;
+		} else
+		{
+			numSimulationSubSteps = 1;
+			maxSubSteps = 1;
+		}
+	}
+
+	//process some debugging flags
+	if (getDebugDrawer())
+	{
+		gDisableDeactivation = (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_NoDeactivation) != 0;
+	}
+	if (numSimulationSubSteps)
+	{
+
+		saveKinematicState(fixedTimeStep);
+
+		applyGravity();
+
+		//clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
+		int clampedSimulationSteps = (numSimulationSubSteps > maxSubSteps)? maxSubSteps : numSimulationSubSteps;
+
+		for (int i=0;i<clampedSimulationSteps;i++)
+		{
+			internalSingleStepSimulation(fixedTimeStep);
+			synchronizeMotionStates();
+		}
+
+	} 
+
+	synchronizeMotionStates();
+
+	clearForces();
+
+#ifndef BT_NO_PROFILE
+	CProfileManager::Increment_Frame_Counter();
+#endif //BT_NO_PROFILE
+	
+	return numSimulationSubSteps;
+}
+
+void	btDiscreteDynamicsWorld::internalSingleStepSimulation(btScalar timeStep)
+{
+	
+	BT_PROFILE("internalSingleStepSimulation");
+
+	///apply gravity, predict motion
+	predictUnconstraintMotion(timeStep);
+
+	btDispatcherInfo& dispatchInfo = getDispatchInfo();
+
+	dispatchInfo.m_timeStep = timeStep;
+	dispatchInfo.m_stepCount = 0;
+	dispatchInfo.m_debugDraw = getDebugDrawer();
+
+	///perform collision detection
+	performDiscreteCollisionDetection();
+
+	calculateSimulationIslands();
+
+	
+	getSolverInfo().m_timeStep = timeStep;
+	
+
+
+	///solve contact and other joint constraints
+	solveConstraints(getSolverInfo());
+	
+	///CallbackTriggers();
+
+	///integrate transforms
+	integrateTransforms(timeStep);
+
+	///update vehicle simulation
+	updateVehicles(timeStep);
+
+
+	updateActivationState( timeStep );
+
+	if(0 != m_internalTickCallback) {
+		(*m_internalTickCallback)(this, timeStep);
+	}	
+}
+
+void	btDiscreteDynamicsWorld::setGravity(const btVector3& gravity)
+{
+	m_gravity = gravity;
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			body->setGravity(gravity);
+		}
+	}
+}
+
+btVector3 btDiscreteDynamicsWorld::getGravity () const
+{
+	return m_gravity;
+}
+
+
+void	btDiscreteDynamicsWorld::removeRigidBody(btRigidBody* body)
+{
+	removeCollisionObject(body);
+}
+
+void	btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body)
+{
+	if (!body->isStaticOrKinematicObject())
+	{
+		body->setGravity(m_gravity);
+	}
+
+	if (body->getCollisionShape())
+	{
+		bool isDynamic = !(body->isStaticObject() || body->isKinematicObject());
+		short collisionFilterGroup = isDynamic? short(btBroadphaseProxy::DefaultFilter) : short(btBroadphaseProxy::StaticFilter);
+		short collisionFilterMask = isDynamic? 	short(btBroadphaseProxy::AllFilter) : 	short(btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
+
+		addCollisionObject(body,collisionFilterGroup,collisionFilterMask);
+	}
+}
+
+void	btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body, short group, short mask)
+{
+	if (!body->isStaticOrKinematicObject())
+	{
+		body->setGravity(m_gravity);
+	}
+
+	if (body->getCollisionShape())
+	{
+		addCollisionObject(body,group,mask);
+	}
+}
+
+
+void	btDiscreteDynamicsWorld::updateVehicles(btScalar timeStep)
+{
+	BT_PROFILE("updateVehicles");
+	
+	for ( int i=0;i<m_vehicles.size();i++)
+	{
+		btRaycastVehicle* vehicle = m_vehicles[i];
+		vehicle->updateVehicle( timeStep);
+	}
+}
+
+void	btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep)
+{
+	BT_PROFILE("updateActivationState");
+
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			body->updateDeactivation(timeStep);
+
+			if (body->wantsSleeping())
+			{
+				if (body->isStaticOrKinematicObject())
+				{
+					body->setActivationState(ISLAND_SLEEPING);
+				} else
+				{
+					if (body->getActivationState() == ACTIVE_TAG)
+						body->setActivationState( WANTS_DEACTIVATION );
+					if (body->getActivationState() == ISLAND_SLEEPING) 
+					{
+						body->setAngularVelocity(btVector3(0,0,0));
+						body->setLinearVelocity(btVector3(0,0,0));
+					}
+
+				}
+			} else
+			{
+				if (body->getActivationState() != DISABLE_DEACTIVATION)
+					body->setActivationState( ACTIVE_TAG );
+			}
+		}
+	}
+}
+
+void	btDiscreteDynamicsWorld::addConstraint(btTypedConstraint* constraint,bool disableCollisionsBetweenLinkedBodies)
+{
+	m_constraints.push_back(constraint);
+	if (disableCollisionsBetweenLinkedBodies)
+	{
+		constraint->getRigidBodyA().addConstraintRef(constraint);
+		constraint->getRigidBodyB().addConstraintRef(constraint);
+	}
+}
+
+void	btDiscreteDynamicsWorld::removeConstraint(btTypedConstraint* constraint)
+{
+	m_constraints.remove(constraint);
+	constraint->getRigidBodyA().removeConstraintRef(constraint);
+	constraint->getRigidBodyB().removeConstraintRef(constraint);
+}
+
+void	btDiscreteDynamicsWorld::addVehicle(btRaycastVehicle* vehicle)
+{
+	m_vehicles.push_back(vehicle);
+}
+
+void	btDiscreteDynamicsWorld::removeVehicle(btRaycastVehicle* vehicle)
+{
+	m_vehicles.remove(vehicle);
+}
+
+SIMD_FORCE_INLINE	int	btGetConstraintIslandId(const btTypedConstraint* lhs)
+{
+	int islandId;
+	
+	const btCollisionObject& rcolObj0 = lhs->getRigidBodyA();
+	const btCollisionObject& rcolObj1 = lhs->getRigidBodyB();
+	islandId= rcolObj0.getIslandTag()>=0?rcolObj0.getIslandTag():rcolObj1.getIslandTag();
+	return islandId;
+
+}
+
+
+class btSortConstraintOnIslandPredicate
+{
+	public:
+
+		bool operator() ( const btTypedConstraint* lhs, const btTypedConstraint* rhs )
+		{
+			int rIslandId0,lIslandId0;
+			rIslandId0 = btGetConstraintIslandId(rhs);
+			lIslandId0 = btGetConstraintIslandId(lhs);
+			return lIslandId0 < rIslandId0;
+		}
+};
+
+
+
+
+void	btDiscreteDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
+{
+	BT_PROFILE("solveConstraints");
+	
+	struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCallback
+	{
+
+		btContactSolverInfo&	m_solverInfo;
+		btConstraintSolver*		m_solver;
+		btTypedConstraint**		m_sortedConstraints;
+		int						m_numConstraints;
+		btIDebugDraw*			m_debugDrawer;
+		btStackAlloc*			m_stackAlloc;
+		btDispatcher*			m_dispatcher;
+
+		InplaceSolverIslandCallback(
+			btContactSolverInfo& solverInfo,
+			btConstraintSolver*	solver,
+			btTypedConstraint** sortedConstraints,
+			int	numConstraints,
+			btIDebugDraw*	debugDrawer,
+			btStackAlloc*			stackAlloc,
+			btDispatcher* dispatcher)
+			:m_solverInfo(solverInfo),
+			m_solver(solver),
+			m_sortedConstraints(sortedConstraints),
+			m_numConstraints(numConstraints),
+			m_debugDrawer(debugDrawer),
+			m_stackAlloc(stackAlloc),
+			m_dispatcher(dispatcher)
+		{
+
+		}
+
+		InplaceSolverIslandCallback& operator=(InplaceSolverIslandCallback& other)
+		{
+			btAssert(0);
+			(void)other;
+			return *this;
+		}
+		virtual	void	ProcessIsland(btCollisionObject** bodies,int numBodies,btPersistentManifold**	manifolds,int numManifolds, int islandId)
+		{
+			if (islandId<0)
+			{
+				///we don't split islands, so all constraints/contact manifolds/bodies are passed into the solver regardless the island id
+				m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,&m_sortedConstraints[0],m_numConstraints,m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher);
+			} else
+			{
+					//also add all non-contact constraints/joints for this island
+				btTypedConstraint** startConstraint = 0;
+				int numCurConstraints = 0;
+				int i;
+				
+				//find the first constraint for this island
+				for (i=0;i<m_numConstraints;i++)
+				{
+					if (btGetConstraintIslandId(m_sortedConstraints[i]) == islandId)
+					{
+						startConstraint = &m_sortedConstraints[i];
+						break;
+					}
+				}
+				//count the number of constraints in this island
+				for (;i<m_numConstraints;i++)
+				{
+					if (btGetConstraintIslandId(m_sortedConstraints[i]) == islandId)
+					{
+						numCurConstraints++;
+					}
+				}
+
+				///only call solveGroup if there is some work: avoid virtual function call, its overhead can be excessive
+				if (numManifolds + numCurConstraints)
+				{
+					m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher);
+				}
+		
+			}
+		}
+
+	};
+
+	//sorted version of all btTypedConstraint, based on islandId
+	btAlignedObjectArray<btTypedConstraint*>	sortedConstraints;
+	sortedConstraints.resize( m_constraints.size());
+	int i; 
+	for (i=0;i<getNumConstraints();i++)
+	{
+		sortedConstraints[i] = m_constraints[i];
+	}
+
+//	assert(0);
+		
+	
+
+	sortedConstraints.quickSort(btSortConstraintOnIslandPredicate());
+	
+	btTypedConstraint** constraintsPtr = getNumConstraints() ? &sortedConstraints[0] : 0;
+	
+	InplaceSolverIslandCallback	solverCallback(	solverInfo,	m_constraintSolver, constraintsPtr,sortedConstraints.size(),	m_debugDrawer,m_stackAlloc,m_dispatcher1);
+	
+	m_constraintSolver->prepareSolve(getCollisionWorld()->getNumCollisionObjects(), getCollisionWorld()->getDispatcher()->getNumManifolds());
+	
+	/// solve all the constraints for this island
+	m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(),getCollisionWorld()->getCollisionObjectArray(),&solverCallback);
+
+	m_constraintSolver->allSolved(solverInfo, m_debugDrawer, m_stackAlloc);
+}
+
+
+
+
+void	btDiscreteDynamicsWorld::calculateSimulationIslands()
+{
+	BT_PROFILE("calculateSimulationIslands");
+
+	getSimulationIslandManager()->updateActivationState(getCollisionWorld(),getCollisionWorld()->getDispatcher());
+
+	{
+		int i;
+		int numConstraints = int(m_constraints.size());
+		for (i=0;i< numConstraints ; i++ )
+		{
+			btTypedConstraint* constraint = m_constraints[i];
+
+			const btRigidBody* colObj0 = &constraint->getRigidBodyA();
+			const btRigidBody* colObj1 = &constraint->getRigidBodyB();
+
+			if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
+				((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
+			{
+				if (colObj0->isActive() || colObj1->isActive())
+				{
+
+					getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),
+						(colObj1)->getIslandTag());
+				}
+			}
+		}
+	}
+
+	//Store the island id in each body
+	getSimulationIslandManager()->storeIslandActivationState(getCollisionWorld());
+
+	
+}
+
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+
+class btClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback
+{
+	btCollisionObject* m_me;
+	btScalar m_allowedPenetration;
+	btOverlappingPairCache* m_pairCache;
+
+
+public:
+	btClosestNotMeConvexResultCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache) : 
+	  btCollisionWorld::ClosestConvexResultCallback(fromA,toA),
+		m_allowedPenetration(0.0f),
+		m_me(me),
+		m_pairCache(pairCache)
+	{
+	}
+
+	virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult,bool normalInWorldSpace)
+	{
+		if (convexResult.m_hitCollisionObject == m_me)
+			return 1.0;
+
+		btVector3 linVelA,linVelB;
+		linVelA = m_convexToWorld-m_convexFromWorld;
+		linVelB = btVector3(0,0,0);//toB.getOrigin()-fromB.getOrigin();
+
+		btVector3 relativeVelocity = (linVelA-linVelB);
+		//don't report time of impact for motion away from the contact normal (or causes minor penetration)
+		if (convexResult.m_hitNormalLocal.dot(relativeVelocity)>=-m_allowedPenetration)
+			return 1.f;
+
+		return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace);
+	}
+
+	virtual bool needsCollision(btBroadphaseProxy* proxy0) const
+	{
+		//don't collide with itself
+		if (proxy0->m_clientObject == m_me)
+			return false;
+
+		///don't do CCD when the collision filters are not matching
+		if (!btCollisionWorld::ClosestConvexResultCallback::needsCollision(proxy0))
+			return false;
+
+		///don't do CCD when there are already contact points (touching contact/penetration)
+		btAlignedObjectArray<btPersistentManifold*> manifoldArray;
+		btBroadphasePair* collisionPair = m_pairCache->findPair(m_me->getBroadphaseHandle(),proxy0);
+		if (collisionPair)
+		{
+			if (collisionPair->m_algorithm)
+			{
+				manifoldArray.resize(0);
+				collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
+				for (int j=0;j<manifoldArray.size();j++)
+				{
+					btPersistentManifold* manifold = manifoldArray[j];
+					if (manifold->getNumContacts()>0)
+						return false;
+				}
+			}
+		}
+		return true;
+	}
+
+
+};
+
+///internal debugging variable. this value shouldn't be too high
+int gNumClampedCcdMotions=0;
+
+//#include "stdio.h"
+void	btDiscreteDynamicsWorld::integrateTransforms(btScalar timeStep)
+{
+	BT_PROFILE("integrateTransforms");
+	btTransform predictedTrans;
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			body->setHitFraction(1.f);
+
+			if (body->isActive() && (!body->isStaticOrKinematicObject()))
+			{
+				body->predictIntegratedTransform(timeStep, predictedTrans);
+				btScalar squareMotion = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2();
+
+				if (body->getCcdSquareMotionThreshold() && body->getCcdSquareMotionThreshold() < squareMotion)
+				{
+					BT_PROFILE("CCD motion clamping");
+					if (body->getCollisionShape()->isConvex())
+					{
+						gNumClampedCcdMotions++;
+						
+						btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache());
+						btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
+						btSphereShape tmpSphere(body->getCcdSweptSphereRadius());//btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
+						convexSweepTest(&tmpSphere,body->getWorldTransform(),predictedTrans,sweepResults);
+						if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f))
+						{
+							body->setHitFraction(sweepResults.m_closestHitFraction);
+							body->predictIntegratedTransform(timeStep*body->getHitFraction(), predictedTrans);
+							body->setHitFraction(0.f);
+//							printf("clamped integration to hit fraction = %f\n",fraction);
+						}
+					}
+				}
+				
+				body->proceedToTransform( predictedTrans);
+			}
+		}
+	}
+}
+
+
+
+void	btDiscreteDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
+{
+	BT_PROFILE("predictUnconstraintMotion");
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			if (!body->isStaticOrKinematicObject())
+			{
+				if (body->isActive())
+				{
+					body->integrateVelocities( timeStep);
+					//damping
+					body->applyDamping(timeStep);
+
+					body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform());
+				}
+			}
+		}
+	}
+}
+
+
+void	btDiscreteDynamicsWorld::startProfiling(btScalar timeStep)
+{
+	(void)timeStep;
+
+#ifndef BT_NO_PROFILE
+	CProfileManager::Reset();
+#endif //BT_NO_PROFILE
+
+}
+
+
+
+
+	
+
+class DebugDrawcallback : public btTriangleCallback, public btInternalTriangleIndexCallback
+{
+	btIDebugDraw*	m_debugDrawer;
+	btVector3	m_color;
+	btTransform	m_worldTrans;
+
+public:
+
+	DebugDrawcallback(btIDebugDraw*	debugDrawer,const btTransform& worldTrans,const btVector3& color) :
+                m_debugDrawer(debugDrawer),
+		m_color(color),
+		m_worldTrans(worldTrans)
+	{
+	}
+
+	virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int  triangleIndex)
+	{
+		processTriangle(triangle,partId,triangleIndex);
+	}
+
+	virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
+	{
+		(void)partId;
+		(void)triangleIndex;
+
+		btVector3 wv0,wv1,wv2;
+		wv0 = m_worldTrans*triangle[0];
+		wv1 = m_worldTrans*triangle[1];
+		wv2 = m_worldTrans*triangle[2];
+		m_debugDrawer->drawLine(wv0,wv1,m_color);
+		m_debugDrawer->drawLine(wv1,wv2,m_color);
+		m_debugDrawer->drawLine(wv2,wv0,m_color);
+	}
+};
+
+void btDiscreteDynamicsWorld::debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color)
+{
+	btVector3 start = transform.getOrigin();
+
+	const btVector3 xoffs = transform.getBasis() * btVector3(radius,0,0);
+	const btVector3 yoffs = transform.getBasis() * btVector3(0,radius,0);
+	const btVector3 zoffs = transform.getBasis() * btVector3(0,0,radius);
+
+	// XY 
+	getDebugDrawer()->drawLine(start-xoffs, start+yoffs, color);
+	getDebugDrawer()->drawLine(start+yoffs, start+xoffs, color);
+	getDebugDrawer()->drawLine(start+xoffs, start-yoffs, color);
+	getDebugDrawer()->drawLine(start-yoffs, start-xoffs, color);
+
+	// XZ
+	getDebugDrawer()->drawLine(start-xoffs, start+zoffs, color);
+	getDebugDrawer()->drawLine(start+zoffs, start+xoffs, color);
+	getDebugDrawer()->drawLine(start+xoffs, start-zoffs, color);
+	getDebugDrawer()->drawLine(start-zoffs, start-xoffs, color);
+
+	// YZ
+	getDebugDrawer()->drawLine(start-yoffs, start+zoffs, color);
+	getDebugDrawer()->drawLine(start+zoffs, start+yoffs, color);
+	getDebugDrawer()->drawLine(start+yoffs, start-zoffs, color);
+	getDebugDrawer()->drawLine(start-zoffs, start-yoffs, color);
+}
+
+void btDiscreteDynamicsWorld::debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color)
+{
+	// Draw a small simplex at the center of the object
+	{
+		btVector3 start = worldTransform.getOrigin();
+		getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(1,0,0), btVector3(1,0,0));
+		getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(0,1,0), btVector3(0,1,0));
+		getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(0,0,1), btVector3(0,0,1));
+	}
+
+	if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
+	{
+		const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
+		for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--)
+		{
+			btTransform childTrans = compoundShape->getChildTransform(i);
+			const btCollisionShape* colShape = compoundShape->getChildShape(i);
+			debugDrawObject(worldTransform*childTrans,colShape,color);
+		}
+
+	} else
+	{
+		switch (shape->getShapeType())
+		{
+
+		case SPHERE_SHAPE_PROXYTYPE:
+			{
+				const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
+				btScalar radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
+				
+				debugDrawSphere(radius, worldTransform, color);
+				break;
+			}
+		case MULTI_SPHERE_SHAPE_PROXYTYPE:
+			{
+				const btMultiSphereShape* multiSphereShape = static_cast<const btMultiSphereShape*>(shape);
+
+				for (int i = multiSphereShape->getSphereCount()-1; i>=0;i--)
+				{
+					btTransform childTransform = worldTransform;
+					childTransform.getOrigin() += multiSphereShape->getSpherePosition(i);
+					debugDrawSphere(multiSphereShape->getSphereRadius(i), childTransform, color);
+				}
+
+				break;
+			}
+		case CAPSULE_SHAPE_PROXYTYPE:
+			{
+				const btCapsuleShape* capsuleShape = static_cast<const btCapsuleShape*>(shape);
+
+				btScalar radius = capsuleShape->getRadius();
+				btScalar halfHeight = capsuleShape->getHalfHeight();
+				
+				int upAxis = capsuleShape->getUpAxis();
+
+				
+				btVector3 capStart(0.f,0.f,0.f);
+				capStart[upAxis] = -halfHeight;
+
+				btVector3 capEnd(0.f,0.f,0.f);
+				capEnd[upAxis] = halfHeight;
+
+				// Draw the ends
+				{
+					
+					btTransform childTransform = worldTransform;
+					childTransform.getOrigin() = worldTransform * capStart;
+					debugDrawSphere(radius, childTransform, color);
+				}
+
+				{
+					btTransform childTransform = worldTransform;
+					childTransform.getOrigin() = worldTransform * capEnd;
+					debugDrawSphere(radius, childTransform, color);
+				}
+
+				// Draw some additional lines
+				btVector3 start = worldTransform.getOrigin();
+
+				
+				capStart[(upAxis+1)%3] = radius;
+				capEnd[(upAxis+1)%3] = radius;
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
+				capStart[(upAxis+1)%3] = -radius;
+				capEnd[(upAxis+1)%3] = -radius;
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
+
+				capStart[(upAxis+1)%3] = 0.f;
+				capEnd[(upAxis+1)%3] = 0.f;
+
+				capStart[(upAxis+2)%3] = radius;
+				capEnd[(upAxis+2)%3] = radius;
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
+				capStart[(upAxis+2)%3] = -radius;
+				capEnd[(upAxis+2)%3] = -radius;
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
+
+				
+				break;
+			}
+		case CONE_SHAPE_PROXYTYPE:
+			{
+				const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
+				btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
+				btScalar height = coneShape->getHeight();//+coneShape->getMargin();
+				btVector3 start = worldTransform.getOrigin();
+
+				int upAxis= coneShape->getConeUpIndex();
+				
+
+				btVector3	offsetHeight(0,0,0);
+				offsetHeight[upAxis] = height * btScalar(0.5);
+				btVector3	offsetRadius(0,0,0);
+				offsetRadius[(upAxis+1)%3] = radius;
+				btVector3	offset2Radius(0,0,0);
+				offset2Radius[(upAxis+2)%3] = radius;
+
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color);
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color);
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color);
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color);
+
+
+
+				break;
+
+			}
+		case CYLINDER_SHAPE_PROXYTYPE:
+			{
+				const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
+				int upAxis = cylinder->getUpAxis();
+				btScalar radius = cylinder->getRadius();
+				btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
+				btVector3 start = worldTransform.getOrigin();
+				btVector3	offsetHeight(0,0,0);
+				offsetHeight[upAxis] = halfHeight;
+				btVector3	offsetRadius(0,0,0);
+				offsetRadius[(upAxis+1)%3] = radius;
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight+offsetRadius),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color);
+				getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight-offsetRadius),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color);
+				break;
+			}
+
+			case STATIC_PLANE_PROXYTYPE:
+				{
+					const btStaticPlaneShape* staticPlaneShape = static_cast<const btStaticPlaneShape*>(shape);
+					btScalar planeConst = staticPlaneShape->getPlaneConstant();
+					const btVector3& planeNormal = staticPlaneShape->getPlaneNormal();
+					btVector3 planeOrigin = planeNormal * planeConst;
+					btVector3 vec0,vec1;
+					btPlaneSpace1(planeNormal,vec0,vec1);
+					btScalar vecLen = 100.f;
+					btVector3 pt0 = planeOrigin + vec0*vecLen;
+					btVector3 pt1 = planeOrigin - vec0*vecLen;
+					btVector3 pt2 = planeOrigin + vec1*vecLen;
+					btVector3 pt3 = planeOrigin - vec1*vecLen;
+					getDebugDrawer()->drawLine(worldTransform*pt0,worldTransform*pt1,color);
+					getDebugDrawer()->drawLine(worldTransform*pt2,worldTransform*pt3,color);
+					break;
+
+				}
+		default:
+			{
+
+				if (shape->isConcave())
+				{
+					btConcaveShape* concaveMesh = (btConcaveShape*) shape;
+					
+					//todo pass camera, for some culling
+					btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+					btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+
+					DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
+					concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
+
+				}
+
+				if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
+				{
+					btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
+					//todo: pass camera for some culling			
+					btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+					btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+					//DebugDrawcallback drawCallback;
+					DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
+					convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
+				}
+
+
+				/// for polyhedral shapes
+				if (shape->isPolyhedral())
+				{
+					btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
+
+					int i;
+					for (i=0;i<polyshape->getNumEdges();i++)
+					{
+						btPoint3 a,b;
+						polyshape->getEdge(i,a,b);
+						btVector3 wa = worldTransform * a;
+						btVector3 wb = worldTransform * b;
+						getDebugDrawer()->drawLine(wa,wb,color);
+
+					}
+
+					
+				}
+			}
+		}
+	}
+}
+
+
+void	btDiscreteDynamicsWorld::setConstraintSolver(btConstraintSolver* solver)
+{
+	if (m_ownsConstraintSolver)
+	{
+		btAlignedFree( m_constraintSolver);
+	}
+	m_ownsConstraintSolver = false;
+	m_constraintSolver = solver;
+}
+
+btConstraintSolver* btDiscreteDynamicsWorld::getConstraintSolver()
+{
+	return m_constraintSolver;
+}
+
+
+int		btDiscreteDynamicsWorld::getNumConstraints() const
+{
+	return int(m_constraints.size());
+}
+btTypedConstraint* btDiscreteDynamicsWorld::getConstraint(int index)
+{
+	return m_constraints[index];
+}
+const btTypedConstraint* btDiscreteDynamicsWorld::getConstraint(int index) const
+{
+	return m_constraints[index];
+}
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h	(revision 2122)
@@ -0,0 +1,159 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_DISCRETE_DYNAMICS_WORLD_H
+#define BT_DISCRETE_DYNAMICS_WORLD_H
+
+#include "btDynamicsWorld.h"
+
+class btDispatcher;
+class btOverlappingPairCache;
+class btConstraintSolver;
+class btSimulationIslandManager;
+class btTypedConstraint;
+
+
+class btRaycastVehicle;
+class btIDebugDraw;
+#include "LinearMath/btAlignedObjectArray.h"
+
+
+///btDiscreteDynamicsWorld provides discrete rigid body simulation
+///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController
+class btDiscreteDynamicsWorld : public btDynamicsWorld
+{
+protected:
+
+	btConstraintSolver*	m_constraintSolver;
+
+	btSimulationIslandManager*	m_islandManager;
+
+	btAlignedObjectArray<btTypedConstraint*> m_constraints;
+
+
+	btVector3	m_gravity;
+
+	//for variable timesteps
+	btScalar	m_localTime;
+	//for variable timesteps
+
+	bool	m_ownsIslandManager;
+	bool	m_ownsConstraintSolver;
+
+	
+	btAlignedObjectArray<btRaycastVehicle*>	m_vehicles;
+
+	int	m_profileTimings;
+
+	virtual void	predictUnconstraintMotion(btScalar timeStep);
+	
+	virtual void	integrateTransforms(btScalar timeStep);
+		
+	void	calculateSimulationIslands();
+
+	void	solveConstraints(btContactSolverInfo& solverInfo);
+	
+	void	updateActivationState(btScalar timeStep);
+
+	void	updateVehicles(btScalar timeStep);
+
+	void	startProfiling(btScalar timeStep);
+
+	virtual void	internalSingleStepSimulation( btScalar timeStep);
+
+	void	synchronizeMotionStates();
+
+	void	saveKinematicState(btScalar timeStep);
+
+	void	debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color);
+
+public:
+
+
+	///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
+	btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
+
+	virtual ~btDiscreteDynamicsWorld();
+
+	///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
+	virtual int	stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
+
+
+	void	addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
+
+	void	removeConstraint(btTypedConstraint* constraint);
+
+	void	addVehicle(btRaycastVehicle* vehicle);
+
+	void	removeVehicle(btRaycastVehicle* vehicle);
+
+	btSimulationIslandManager*	getSimulationIslandManager()
+	{
+		return m_islandManager;
+	}
+
+	const btSimulationIslandManager*	getSimulationIslandManager() const 
+	{
+		return m_islandManager;
+	}
+
+	btCollisionWorld*	getCollisionWorld()
+	{
+		return this;
+	}
+
+
+	virtual void	setGravity(const btVector3& gravity);
+	virtual btVector3 getGravity () const;
+
+	virtual void	addRigidBody(btRigidBody* body);
+
+	virtual void	addRigidBody(btRigidBody* body, short group, short mask);
+
+	virtual void	removeRigidBody(btRigidBody* body);
+
+	void	debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
+
+	virtual void	debugDrawWorld();
+
+	virtual void	setConstraintSolver(btConstraintSolver* solver);
+
+	virtual btConstraintSolver* getConstraintSolver();
+	
+	virtual	int		getNumConstraints() const;
+
+	virtual btTypedConstraint* getConstraint(int index)	;
+
+	virtual const btTypedConstraint* getConstraint(int index) const;
+
+	
+	virtual btDynamicsWorldType	getWorldType() const
+	{
+		return BT_DISCRETE_DYNAMICS_WORLD;
+	}
+	
+	///the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
+	virtual void	clearForces();
+
+	///apply gravity, call this once per timestep
+	virtual void	applyGravity();
+
+	virtual void	setNumTasks(int numTasks)
+	{
+	}
+
+};
+
+#endif //BT_DISCRETE_DYNAMICS_WORLD_H
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDynamicsWorld.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDynamicsWorld.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btDynamicsWorld.h	(revision 2122)
@@ -0,0 +1,128 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_DYNAMICS_WORLD_H
+#define BT_DYNAMICS_WORLD_H
+
+#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
+#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
+
+class btTypedConstraint;
+class btRaycastVehicle;
+class btConstraintSolver;
+class btDynamicsWorld;
+
+/// Type for the callback for each tick
+typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep);
+
+enum btDynamicsWorldType
+{
+	BT_SIMPLE_DYNAMICS_WORLD=1,
+	BT_DISCRETE_DYNAMICS_WORLD=2,
+	BT_CONTINUOUS_DYNAMICS_WORLD=3
+};
+
+///The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc.
+class btDynamicsWorld : public btCollisionWorld
+{
+
+protected:
+		btInternalTickCallback m_internalTickCallback;
+		void*	m_worldUserInfo;
+
+		btContactSolverInfo	m_solverInfo;
+
+public:
+		
+
+		btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase,btCollisionConfiguration* collisionConfiguration)
+		:btCollisionWorld(dispatcher,broadphase,collisionConfiguration), m_internalTickCallback(0), m_worldUserInfo(0)
+		{
+		}
+
+		virtual ~btDynamicsWorld()
+		{
+		}
+		
+		///stepSimulation proceeds the simulation over 'timeStep', units in preferably in seconds.
+		///By default, Bullet will subdivide the timestep in constant substeps of each 'fixedTimeStep'.
+		///in order to keep the simulation real-time, the maximum number of substeps can be clamped to 'maxSubSteps'.
+		///You can disable subdividing the timestep/substepping by passing maxSubSteps=0 as second argument to stepSimulation, but in that case you have to keep the timeStep constant.
+		virtual int		stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0;
+			
+		virtual void	debugDrawWorld() = 0;
+				
+		virtual void	addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) 
+		{ 
+			(void)constraint; (void)disableCollisionsBetweenLinkedBodies;
+		}
+
+		virtual void	removeConstraint(btTypedConstraint* constraint) {(void)constraint;}
+
+		virtual void	addVehicle(btRaycastVehicle* vehicle) {(void)vehicle;}
+
+		virtual void	removeVehicle(btRaycastVehicle* vehicle) {(void)vehicle;}
+
+		//once a rigidbody is added to the dynamics world, it will get this gravity assigned
+		//existing rigidbodies in the world get gravity assigned too, during this method
+		virtual void	setGravity(const btVector3& gravity) = 0;
+		virtual btVector3 getGravity () const = 0;
+
+		virtual void	addRigidBody(btRigidBody* body) = 0;
+
+		virtual void	removeRigidBody(btRigidBody* body) = 0;
+
+		virtual void	setConstraintSolver(btConstraintSolver* solver) = 0;
+
+		virtual btConstraintSolver* getConstraintSolver() = 0;
+		
+		virtual	int		getNumConstraints() const {	return 0;		}
+		
+		virtual btTypedConstraint* getConstraint(int index)		{	(void)index;		return 0;		}
+		
+		virtual const btTypedConstraint* getConstraint(int index) const	{	(void)index;	return 0;	}
+
+		virtual btDynamicsWorldType	getWorldType() const=0;
+
+		virtual void	clearForces() = 0;
+
+		/// Set the callback for when an internal tick (simulation substep) happens, optional user info
+		void setInternalTickCallback(btInternalTickCallback cb,	void* worldUserInfo=0) 
+		{ 
+			m_internalTickCallback = cb; 
+			m_worldUserInfo = worldUserInfo;
+		}
+
+		void	setWorldUserInfo(void* worldUserInfo)
+		{
+			m_worldUserInfo = worldUserInfo;
+		}
+
+		void*	getWorldUserInfo() const
+		{
+			return m_worldUserInfo;
+		}
+
+		btContactSolverInfo& getSolverInfo()
+		{
+			return m_solverInfo;
+		}
+
+
+};
+
+#endif //BT_DYNAMICS_WORLD_H
+
+
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btRigidBody.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btRigidBody.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btRigidBody.cpp	(revision 2122)
@@ -0,0 +1,314 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btRigidBody.h"
+#include "BulletCollision/CollisionShapes/btConvexShape.h"
+#include "LinearMath/btMinMax.h"
+#include "LinearMath/btTransformUtil.h"
+#include "LinearMath/btMotionState.h"
+#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
+
+//'temporarily' global variables
+btScalar	gDeactivationTime = btScalar(2.);
+bool	gDisableDeactivation = false;
+static int uniqueId = 0;
+
+
+btRigidBody::btRigidBody(const btRigidBody::btRigidBodyConstructionInfo& constructionInfo)
+{
+	setupRigidBody(constructionInfo);
+}
+
+btRigidBody::btRigidBody(btScalar mass, btMotionState *motionState, btCollisionShape *collisionShape, const btVector3 &localInertia)
+{
+	btRigidBodyConstructionInfo cinfo(mass,motionState,collisionShape,localInertia);
+	setupRigidBody(cinfo);
+}
+
+void	btRigidBody::setupRigidBody(const btRigidBody::btRigidBodyConstructionInfo& constructionInfo)
+{
+
+	m_internalType=CO_RIGID_BODY;
+
+	m_linearVelocity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
+	m_angularVelocity.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+	m_angularFactor = btScalar(1.);
+	m_gravity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
+	m_totalForce.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
+	m_totalTorque.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)),
+	m_linearDamping = btScalar(0.);
+	m_angularDamping = btScalar(0.5);
+	m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold;
+	m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold;
+	m_optionalMotionState = constructionInfo.m_motionState;
+	m_contactSolverType = 0;
+	m_frictionSolverType = 0;
+	m_additionalDamping = constructionInfo.m_additionalDamping;
+	m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor;
+	m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr;
+	m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr;
+	m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor;
+
+	if (m_optionalMotionState)
+	{
+		m_optionalMotionState->getWorldTransform(m_worldTransform);
+	} else
+	{
+		m_worldTransform = constructionInfo.m_startWorldTransform;
+	}
+
+	m_interpolationWorldTransform = m_worldTransform;
+	m_interpolationLinearVelocity.setValue(0,0,0);
+	m_interpolationAngularVelocity.setValue(0,0,0);
+	
+	//moved to btCollisionObject
+	m_friction = constructionInfo.m_friction;
+	m_restitution = constructionInfo.m_restitution;
+
+	setCollisionShape( constructionInfo.m_collisionShape );
+	m_debugBodyId = uniqueId++;
+	
+	setMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia);
+    setDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping);
+	updateInertiaTensor();
+
+}
+
+
+void btRigidBody::predictIntegratedTransform(btScalar timeStep,btTransform& predictedTransform) 
+{
+	btTransformUtil::integrateTransform(m_worldTransform,m_linearVelocity,m_angularVelocity,timeStep,predictedTransform);
+}
+
+void			btRigidBody::saveKinematicState(btScalar timeStep)
+{
+	//todo: clamp to some (user definable) safe minimum timestep, to limit maximum angular/linear velocities
+	if (timeStep != btScalar(0.))
+	{
+		//if we use motionstate to synchronize world transforms, get the new kinematic/animated world transform
+		if (getMotionState())
+			getMotionState()->getWorldTransform(m_worldTransform);
+		btVector3 linVel,angVel;
+		
+		btTransformUtil::calculateVelocity(m_interpolationWorldTransform,m_worldTransform,timeStep,m_linearVelocity,m_angularVelocity);
+		m_interpolationLinearVelocity = m_linearVelocity;
+		m_interpolationAngularVelocity = m_angularVelocity;
+		m_interpolationWorldTransform = m_worldTransform;
+		//printf("angular = %f %f %f\n",m_angularVelocity.getX(),m_angularVelocity.getY(),m_angularVelocity.getZ());
+	}
+}
+	
+void	btRigidBody::getAabb(btVector3& aabbMin,btVector3& aabbMax) const
+{
+	getCollisionShape()->getAabb(m_worldTransform,aabbMin,aabbMax);
+}
+
+
+
+
+void btRigidBody::setGravity(const btVector3& acceleration) 
+{
+	if (m_inverseMass != btScalar(0.0))
+	{
+		m_gravity = acceleration * (btScalar(1.0) / m_inverseMass);
+	}
+}
+
+
+
+
+
+
+void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping)
+{
+	m_linearDamping = GEN_clamped(lin_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
+	m_angularDamping = GEN_clamped(ang_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
+}
+
+
+
+
+///applyDamping damps the velocity, using the given m_linearDamping and m_angularDamping
+void			btRigidBody::applyDamping(btScalar timeStep)
+{
+	//On new damping: see discussion/issue report here: http://code.google.com/p/bullet/issues/detail?id=74
+	//todo: do some performance comparisons (but other parts of the engine are probably bottleneck anyway
+
+//#define USE_OLD_DAMPING_METHOD 1
+#ifdef USE_OLD_DAMPING_METHOD
+	m_linearVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_linearDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
+	m_angularVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_angularDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
+#else
+	m_linearVelocity *= btPow(btScalar(1)-m_linearDamping, timeStep);
+	m_angularVelocity *= btPow(btScalar(1)-m_angularDamping, timeStep);
+#endif
+
+	if (m_additionalDamping)
+	{
+		//Additional damping can help avoiding lowpass jitter motion, help stability for ragdolls etc.
+		//Such damping is undesirable, so once the overall simulation quality of the rigid body dynamics system has improved, this should become obsolete
+		if ((m_angularVelocity.length2() < m_additionalAngularDampingThresholdSqr) &&
+			(m_linearVelocity.length2() < m_additionalLinearDampingThresholdSqr))
+		{
+			m_angularVelocity *= m_additionalDampingFactor;
+			m_linearVelocity *= m_additionalDampingFactor;
+		}
+	
+
+		btScalar speed = m_linearVelocity.length();
+		if (speed < m_linearDamping)
+		{
+			btScalar dampVel = btScalar(0.005);
+			if (speed > dampVel)
+			{
+				btVector3 dir = m_linearVelocity.normalized();
+				m_linearVelocity -=  dir * dampVel;
+			} else
+			{
+				m_linearVelocity.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+			}
+		}
+
+		btScalar angSpeed = m_angularVelocity.length();
+		if (angSpeed < m_angularDamping)
+		{
+			btScalar angDampVel = btScalar(0.005);
+			if (angSpeed > angDampVel)
+			{
+				btVector3 dir = m_angularVelocity.normalized();
+				m_angularVelocity -=  dir * angDampVel;
+			} else
+			{
+				m_angularVelocity.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
+			}
+		}
+	}
+}
+
+
+void btRigidBody::applyGravity()
+{
+	if (isStaticOrKinematicObject())
+		return;
+	
+	applyCentralForce(m_gravity);	
+
+}
+
+void btRigidBody::proceedToTransform(const btTransform& newTrans)
+{
+	setCenterOfMassTransform( newTrans );
+}
+	
+
+void btRigidBody::setMassProps(btScalar mass, const btVector3& inertia)
+{
+	if (mass == btScalar(0.))
+	{
+		m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
+		m_inverseMass = btScalar(0.);
+	} else
+	{
+		m_collisionFlags &= (~btCollisionObject::CF_STATIC_OBJECT);
+		m_inverseMass = btScalar(1.0) / mass;
+	}
+	
+	m_invInertiaLocal.setValue(inertia.x() != btScalar(0.0) ? btScalar(1.0) / inertia.x(): btScalar(0.0),
+				   inertia.y() != btScalar(0.0) ? btScalar(1.0) / inertia.y(): btScalar(0.0),
+				   inertia.z() != btScalar(0.0) ? btScalar(1.0) / inertia.z(): btScalar(0.0));
+
+}
+
+	
+
+void btRigidBody::updateInertiaTensor() 
+{
+	m_invInertiaTensorWorld = m_worldTransform.getBasis().scaled(m_invInertiaLocal) * m_worldTransform.getBasis().transpose();
+}
+
+
+void btRigidBody::integrateVelocities(btScalar step) 
+{
+	if (isStaticOrKinematicObject())
+		return;
+
+	m_linearVelocity += m_totalForce * (m_inverseMass * step);
+	m_angularVelocity += m_invInertiaTensorWorld * m_totalTorque * step;
+
+#define MAX_ANGVEL SIMD_HALF_PI
+	/// clamp angular velocity. collision calculations will fail on higher angular velocities	
+	btScalar angvel = m_angularVelocity.length();
+	if (angvel*step > MAX_ANGVEL)
+	{
+		m_angularVelocity *= (MAX_ANGVEL/step) /angvel;
+	}
+
+}
+
+btQuaternion btRigidBody::getOrientation() const
+{
+		btQuaternion orn;
+		m_worldTransform.getBasis().getRotation(orn);
+		return orn;
+}
+	
+	
+void btRigidBody::setCenterOfMassTransform(const btTransform& xform)
+{
+
+	if (isStaticOrKinematicObject())
+	{
+		m_interpolationWorldTransform = m_worldTransform;
+	} else
+	{
+		m_interpolationWorldTransform = xform;
+	}
+	m_interpolationLinearVelocity = getLinearVelocity();
+	m_interpolationAngularVelocity = getAngularVelocity();
+	m_worldTransform = xform;
+	updateInertiaTensor();
+}
+
+
+bool btRigidBody::checkCollideWithOverride(btCollisionObject* co)
+{
+	btRigidBody* otherRb = btRigidBody::upcast(co);
+	if (!otherRb)
+		return true;
+
+	for (int i = 0; i < m_constraintRefs.size(); ++i)
+	{
+		btTypedConstraint* c = m_constraintRefs[i];
+		if (&c->getRigidBodyA() == otherRb || &c->getRigidBodyB() == otherRb)
+			return false;
+	}
+
+	return true;
+}
+
+void btRigidBody::addConstraintRef(btTypedConstraint* c)
+{
+	int index = m_constraintRefs.findLinearSearch(c);
+	if (index == m_constraintRefs.size())
+		m_constraintRefs.push_back(c); 
+
+	m_checkCollideWith = true;
+}
+
+void btRigidBody::removeConstraintRef(btTypedConstraint* c)
+{
+	m_constraintRefs.remove(c);
+	m_checkCollideWith = m_constraintRefs.size() > 0;
+}
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btRigidBody.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btRigidBody.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btRigidBody.h	(revision 2122)
@@ -0,0 +1,482 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef RIGIDBODY_H
+#define RIGIDBODY_H
+
+#include "LinearMath/btAlignedObjectArray.h"
+#include "LinearMath/btPoint3.h"
+#include "LinearMath/btTransform.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+class btCollisionShape;
+class btMotionState;
+class btTypedConstraint;
+
+
+extern btScalar gDeactivationTime;
+extern bool gDisableDeactivation;
+
+
+///btRigidBody is the main class for rigid body objects. It is derived from btCollisionObject, so it keeps a pointer to a btCollisionShape.
+///It is recommended for performance and memory use to share btCollisionShape objects whenever possible.
+///There are 3 types of rigid bodies: 
+///- A) Dynamic rigid bodies, with positive mass. Motion is controlled by rigid body dynamics.
+///- B) Fixed objects with zero mass. They are not moving (basically collision objects)
+///- C) Kinematic objects, which are objects without mass, but the user can move them. There is on-way interaction, and Bullet calculates a velocity based on the timestep and previous and current world transform.
+///Bullet automatically deactivates dynamic rigid bodies, when the velocity is below a threshold for a given time.
+///Deactivated (sleeping) rigid bodies don't take any processing time, except a minor broadphase collision detection impact (to allow active objects to activate/wake up sleeping objects)
+class btRigidBody  : public btCollisionObject
+{
+
+	btMatrix3x3	m_invInertiaTensorWorld;
+	btVector3		m_linearVelocity;
+	btVector3		m_angularVelocity;
+	btScalar		m_inverseMass;
+	btScalar		m_angularFactor;
+
+	btVector3		m_gravity;	
+	btVector3		m_invInertiaLocal;
+	btVector3		m_totalForce;
+	btVector3		m_totalTorque;
+	
+	btScalar		m_linearDamping;
+	btScalar		m_angularDamping;
+
+	bool			m_additionalDamping;
+	btScalar		m_additionalDampingFactor;
+	btScalar		m_additionalLinearDampingThresholdSqr;
+	btScalar		m_additionalAngularDampingThresholdSqr;
+	btScalar		m_additionalAngularDampingFactor;
+
+
+	btScalar		m_linearSleepingThreshold;
+	btScalar		m_angularSleepingThreshold;
+
+	//m_optionalMotionState allows to automatic synchronize the world transform for active objects
+	btMotionState*	m_optionalMotionState;
+
+	//keep track of typed constraints referencing this rigid body
+	btAlignedObjectArray<btTypedConstraint*> m_constraintRefs;
+
+public:
+
+
+	///btRigidBodyConstructionInfo provides information to create a rigid body. Setting mass to zero creates a fixed (non-dynamic) rigid body.
+	///For dynamic objects, you can use the collision shape to approximate the local inertia tensor, otherwise use the zero vector (default argument)
+	///You can use the motion state to synchronize the world transform between physics and graphics objects. 
+	///And if the motion state is provided, the rigid body will initialize its initial world transform from the motion state,
+	///m_startWorldTransform is only used when you don't provide a motion state.
+	struct	btRigidBodyConstructionInfo
+	{
+		btScalar			m_mass;
+
+		///When a motionState is provided, the rigid body will initialize its world transform from the motion state
+		///In this case, m_startWorldTransform is ignored.
+		btMotionState*		m_motionState;
+		btTransform	m_startWorldTransform;
+
+		btCollisionShape*	m_collisionShape;
+		btVector3			m_localInertia;
+		btScalar			m_linearDamping;
+		btScalar			m_angularDamping;
+
+		///best simulation results when friction is non-zero
+		btScalar			m_friction;
+		///best simulation results using zero restitution.
+		btScalar			m_restitution;
+
+		btScalar			m_linearSleepingThreshold;
+		btScalar			m_angularSleepingThreshold;
+
+		//Additional damping can help avoiding lowpass jitter motion, help stability for ragdolls etc.
+		//Such damping is undesirable, so once the overall simulation quality of the rigid body dynamics system has improved, this should become obsolete
+		bool				m_additionalDamping;
+		btScalar			m_additionalDampingFactor;
+		btScalar			m_additionalLinearDampingThresholdSqr;
+		btScalar			m_additionalAngularDampingThresholdSqr;
+		btScalar			m_additionalAngularDampingFactor;
+
+		
+		btRigidBodyConstructionInfo(	btScalar mass, btMotionState* motionState, btCollisionShape* collisionShape, const btVector3& localInertia=btVector3(0,0,0)):
+		m_mass(mass),
+			m_motionState(motionState),
+			m_collisionShape(collisionShape),
+			m_localInertia(localInertia),
+			m_linearDamping(btScalar(0.)),
+			m_angularDamping(btScalar(0.)),
+			m_friction(btScalar(0.5)),
+			m_restitution(btScalar(0.)),
+			m_linearSleepingThreshold(btScalar(0.8)),
+			m_angularSleepingThreshold(btScalar(1.f)),
+			m_additionalDamping(false),
+			m_additionalDampingFactor(btScalar(0.005)),
+			m_additionalLinearDampingThresholdSqr(btScalar(0.01)),
+			m_additionalAngularDampingThresholdSqr(btScalar(0.01)),
+			m_additionalAngularDampingFactor(btScalar(0.01))
+		{
+			m_startWorldTransform.setIdentity();
+		}
+	};
+
+	///btRigidBody constructor using construction info
+	btRigidBody(	const btRigidBodyConstructionInfo& constructionInfo);
+
+	///btRigidBody constructor for backwards compatibility. 
+	///To specify friction (etc) during rigid body construction, please use the other constructor (using btRigidBodyConstructionInfo)
+	btRigidBody(	btScalar mass, btMotionState* motionState, btCollisionShape* collisionShape, const btVector3& localInertia=btVector3(0,0,0));
+
+
+	virtual ~btRigidBody()
+        { 
+                //No constraints should point to this rigidbody
+		//Remove constraints from the dynamics world before you delete the related rigidbodies. 
+                btAssert(m_constraintRefs.size()==0); 
+        }
+
+protected:
+
+	///setupRigidBody is only used internally by the constructor
+	void	setupRigidBody(const btRigidBodyConstructionInfo& constructionInfo);
+
+public:
+
+	void			proceedToTransform(const btTransform& newTrans); 
+	
+	///to keep collision detection and dynamics separate we don't store a rigidbody pointer
+	///but a rigidbody is derived from btCollisionObject, so we can safely perform an upcast
+	static const btRigidBody*	upcast(const btCollisionObject* colObj)
+	{
+		if (colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY)
+			return (const btRigidBody*)colObj;
+		return 0;
+	}
+	static btRigidBody*	upcast(btCollisionObject* colObj)
+	{
+		if (colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY)
+			return (btRigidBody*)colObj;
+		return 0;
+	}
+	
+	/// continuous collision detection needs prediction
+	void			predictIntegratedTransform(btScalar step, btTransform& predictedTransform) ;
+	
+	void			saveKinematicState(btScalar step);
+	
+	void			applyGravity();
+	
+	void			setGravity(const btVector3& acceleration);  
+
+	const btVector3&	getGravity() const
+	{
+		return m_gravity;
+	}
+
+	void			setDamping(btScalar lin_damping, btScalar ang_damping);
+
+	btScalar getLinearDamping() const
+	{
+		return m_linearDamping;
+	}
+
+	btScalar getAngularDamping() const
+	{
+		return m_angularDamping;
+	}
+
+	btScalar getLinearSleepingThreshold() const
+	{
+		return m_linearSleepingThreshold;
+	}
+
+	btScalar getAngularSleepingThreshold() const
+	{
+		return m_angularSleepingThreshold;
+	}
+
+	void			applyDamping(btScalar timeStep);
+
+	SIMD_FORCE_INLINE const btCollisionShape*	getCollisionShape() const {
+		return m_collisionShape;
+	}
+
+	SIMD_FORCE_INLINE btCollisionShape*	getCollisionShape() {
+			return m_collisionShape;
+	}
+	
+	void			setMassProps(btScalar mass, const btVector3& inertia);
+	
+	btScalar		getInvMass() const { return m_inverseMass; }
+	const btMatrix3x3& getInvInertiaTensorWorld() const { 
+		return m_invInertiaTensorWorld; 
+	}
+		
+	void			integrateVelocities(btScalar step);
+
+	void			setCenterOfMassTransform(const btTransform& xform);
+
+	void			applyCentralForce(const btVector3& force)
+	{
+		m_totalForce += force;
+	}
+    
+	const btVector3& getInvInertiaDiagLocal()
+	{
+		return m_invInertiaLocal;
+	};
+
+	void	setInvInertiaDiagLocal(const btVector3& diagInvInertia)
+	{
+		m_invInertiaLocal = diagInvInertia;
+	}
+
+	void	setSleepingThresholds(btScalar linear,btScalar angular)
+	{
+		m_linearSleepingThreshold = linear;
+		m_angularSleepingThreshold = angular;
+	}
+
+	void	applyTorque(const btVector3& torque)
+	{
+		m_totalTorque += torque;
+	}
+	
+	void	applyForce(const btVector3& force, const btVector3& rel_pos) 
+	{
+		applyCentralForce(force);
+		applyTorque(rel_pos.cross(force)*m_angularFactor);
+	}
+	
+	void applyCentralImpulse(const btVector3& impulse)
+	{
+		m_linearVelocity += impulse * m_inverseMass;
+	}
+	
+  	void applyTorqueImpulse(const btVector3& torque)
+	{
+			m_angularVelocity += m_invInertiaTensorWorld * torque;
+	}
+	
+	void applyImpulse(const btVector3& impulse, const btVector3& rel_pos) 
+	{
+		if (m_inverseMass != btScalar(0.))
+		{
+			applyCentralImpulse(impulse);
+			if (m_angularFactor)
+			{
+				applyTorqueImpulse(rel_pos.cross(impulse)*m_angularFactor);
+			}
+		}
+	}
+
+	//Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position
+	SIMD_FORCE_INLINE void internalApplyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude)
+	{
+		if (m_inverseMass != btScalar(0.))
+		{
+			m_linearVelocity += linearComponent*impulseMagnitude;
+			if (m_angularFactor)
+			{
+				m_angularVelocity += angularComponent*impulseMagnitude*m_angularFactor;
+			}
+		}
+	}
+	
+	void clearForces() 
+	{
+		m_totalForce.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
+		m_totalTorque.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
+	}
+	
+	void updateInertiaTensor();    
+	
+	const btPoint3&     getCenterOfMassPosition() const { 
+		return m_worldTransform.getOrigin(); 
+	}
+	btQuaternion getOrientation() const;
+	
+	const btTransform&  getCenterOfMassTransform() const { 
+		return m_worldTransform; 
+	}
+	const btVector3&   getLinearVelocity() const { 
+		return m_linearVelocity; 
+	}
+	const btVector3&    getAngularVelocity() const { 
+		return m_angularVelocity; 
+	}
+	
+
+	inline void setLinearVelocity(const btVector3& lin_vel)
+	{ 
+		assert (m_collisionFlags != btCollisionObject::CF_STATIC_OBJECT);
+		m_linearVelocity = lin_vel; 
+	}
+
+	inline void setAngularVelocity(const btVector3& ang_vel) { 
+		assert (m_collisionFlags != btCollisionObject::CF_STATIC_OBJECT);
+		{
+			m_angularVelocity = ang_vel; 
+		}
+	}
+
+	btVector3 getVelocityInLocalPoint(const btVector3& rel_pos) const
+	{
+		//we also calculate lin/ang velocity for kinematic objects
+		return m_linearVelocity + m_angularVelocity.cross(rel_pos);
+
+		//for kinematic objects, we could also use use:
+		//		return 	(m_worldTransform(rel_pos) - m_interpolationWorldTransform(rel_pos)) / m_kinematicTimeStep;
+	}
+
+	void translate(const btVector3& v) 
+	{
+		m_worldTransform.getOrigin() += v; 
+	}
+
+	
+	void	getAabb(btVector3& aabbMin,btVector3& aabbMax) const;
+
+
+
+
+	
+	SIMD_FORCE_INLINE btScalar computeImpulseDenominator(const btPoint3& pos, const btVector3& normal) const
+	{
+		btVector3 r0 = pos - getCenterOfMassPosition();
+
+		btVector3 c0 = (r0).cross(normal);
+
+		btVector3 vec = (c0 * getInvInertiaTensorWorld()).cross(r0);
+
+		return m_inverseMass + normal.dot(vec);
+
+	}
+
+	SIMD_FORCE_INLINE btScalar computeAngularImpulseDenominator(const btVector3& axis) const
+	{
+		btVector3 vec = axis * getInvInertiaTensorWorld();
+		return axis.dot(vec);
+	}
+
+	SIMD_FORCE_INLINE void	updateDeactivation(btScalar timeStep)
+	{
+		if ( (getActivationState() == ISLAND_SLEEPING) || (getActivationState() == DISABLE_DEACTIVATION))
+			return;
+
+		if ((getLinearVelocity().length2() < m_linearSleepingThreshold*m_linearSleepingThreshold) &&
+			(getAngularVelocity().length2() < m_angularSleepingThreshold*m_angularSleepingThreshold))
+		{
+			m_deactivationTime += timeStep;
+		} else
+		{
+			m_deactivationTime=btScalar(0.);
+			setActivationState(0);
+		}
+
+	}
+
+	SIMD_FORCE_INLINE bool	wantsSleeping()
+	{
+
+		if (getActivationState() == DISABLE_DEACTIVATION)
+			return false;
+
+		//disable deactivation
+		if (gDisableDeactivation || (gDeactivationTime == btScalar(0.)))
+			return false;
+
+		if ( (getActivationState() == ISLAND_SLEEPING) || (getActivationState() == WANTS_DEACTIVATION))
+			return true;
+
+		if (m_deactivationTime> gDeactivationTime)
+		{
+			return true;
+		}
+		return false;
+	}
+
+
+	
+	const btBroadphaseProxy*	getBroadphaseProxy() const
+	{
+		return m_broadphaseHandle;
+	}
+	btBroadphaseProxy*	getBroadphaseProxy() 
+	{
+		return m_broadphaseHandle;
+	}
+	void	setNewBroadphaseProxy(btBroadphaseProxy* broadphaseProxy)
+	{
+		m_broadphaseHandle = broadphaseProxy;
+	}
+
+	//btMotionState allows to automatic synchronize the world transform for active objects
+	btMotionState*	getMotionState()
+	{
+		return m_optionalMotionState;
+	}
+	const btMotionState*	getMotionState() const
+	{
+		return m_optionalMotionState;
+	}
+	void	setMotionState(btMotionState* motionState)
+	{
+		m_optionalMotionState = motionState;
+		if (m_optionalMotionState)
+			motionState->getWorldTransform(m_worldTransform);
+	}
+
+	//for experimental overriding of friction/contact solver func
+	int	m_contactSolverType;
+	int	m_frictionSolverType;
+
+	void	setAngularFactor(btScalar angFac)
+	{
+		m_angularFactor = angFac;
+	}
+	btScalar	getAngularFactor() const
+	{
+		return m_angularFactor;
+	}
+
+	//is this rigidbody added to a btCollisionWorld/btDynamicsWorld/btBroadphase?
+	bool	isInWorld() const
+	{
+		return (getBroadphaseProxy() != 0);
+	}
+
+	virtual bool checkCollideWithOverride(btCollisionObject* co);
+
+	void addConstraintRef(btTypedConstraint* c);
+	void removeConstraintRef(btTypedConstraint* c);
+
+	btTypedConstraint* getConstraintRef(int index)
+	{
+		return m_constraintRefs[index];
+	}
+
+	int getNumConstraintRefs()
+	{
+		return m_constraintRefs.size();
+	}
+
+	int	m_debugBodyId;
+};
+
+
+
+#endif
+
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp	(revision 2122)
@@ -0,0 +1,243 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSimpleDynamicsWorld.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
+#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
+#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
+
+
+/*
+  Make sure this dummy function never changes so that it
+  can be used by probes that are checking whether the
+  library is actually installed.
+*/
+extern "C" 
+{
+	void btBulletDynamicsProbe ();
+	void btBulletDynamicsProbe () {}
+}
+
+
+
+
+btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
+:btDynamicsWorld(dispatcher,pairCache,collisionConfiguration),
+m_constraintSolver(constraintSolver),
+m_ownsConstraintSolver(false),
+m_gravity(0,0,-10)
+{
+
+}
+
+
+btSimpleDynamicsWorld::~btSimpleDynamicsWorld()
+{
+	if (m_ownsConstraintSolver)
+		btAlignedFree( m_constraintSolver);
+}
+
+int		btSimpleDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btScalar fixedTimeStep)
+{
+	(void)fixedTimeStep;
+	(void)maxSubSteps;
+
+
+	///apply gravity, predict motion
+	predictUnconstraintMotion(timeStep);
+
+	btDispatcherInfo&	dispatchInfo = getDispatchInfo();
+	dispatchInfo.m_timeStep = timeStep;
+	dispatchInfo.m_stepCount = 0;
+	dispatchInfo.m_debugDraw = getDebugDrawer();
+
+	///perform collision detection
+	performDiscreteCollisionDetection();
+
+	///solve contact constraints
+	int numManifolds = m_dispatcher1->getNumManifolds();
+	if (numManifolds)
+	{
+		btPersistentManifold** manifoldPtr = ((btCollisionDispatcher*)m_dispatcher1)->getInternalManifoldPointer();
+		
+		btContactSolverInfo infoGlobal;
+		infoGlobal.m_timeStep = timeStep;
+		m_constraintSolver->prepareSolve(0,numManifolds);
+		m_constraintSolver->solveGroup(0,0,manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_stackAlloc,m_dispatcher1);
+		m_constraintSolver->allSolved(infoGlobal,m_debugDrawer, m_stackAlloc);
+	}
+
+	///integrate transforms
+	integrateTransforms(timeStep);
+		
+	updateAabbs();
+
+	synchronizeMotionStates();
+
+	clearForces();
+
+	return 1;
+
+}
+
+void	btSimpleDynamicsWorld::clearForces()
+{
+	//todo: iterate over awake simulation islands!
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			body->clearForces();
+		}
+	}
+}	
+
+
+void	btSimpleDynamicsWorld::setGravity(const btVector3& gravity)
+{
+	m_gravity = gravity;
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			body->setGravity(gravity);
+		}
+	}
+}
+
+btVector3 btSimpleDynamicsWorld::getGravity () const
+{
+	return m_gravity;
+}
+
+void	btSimpleDynamicsWorld::removeRigidBody(btRigidBody* body)
+{
+	removeCollisionObject(body);
+}
+
+void	btSimpleDynamicsWorld::addRigidBody(btRigidBody* body)
+{
+	body->setGravity(m_gravity);
+
+	if (body->getCollisionShape())
+	{
+		addCollisionObject(body);
+	}
+}
+
+void	btSimpleDynamicsWorld::updateAabbs()
+{
+	btTransform predictedTrans;
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			if (body->isActive() && (!body->isStaticObject()))
+			{
+				btPoint3 minAabb,maxAabb;
+				colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
+				btBroadphaseInterface* bp = getBroadphase();
+				bp->setAabb(body->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
+			}
+		}
+	}
+}
+
+void	btSimpleDynamicsWorld::integrateTransforms(btScalar timeStep)
+{
+	btTransform predictedTrans;
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			if (body->isActive() && (!body->isStaticObject()))
+			{
+				body->predictIntegratedTransform(timeStep, predictedTrans);
+				body->proceedToTransform( predictedTrans);
+			}
+		}
+	}
+}
+
+
+
+void	btSimpleDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
+{
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body)
+		{
+			if (!body->isStaticObject())
+			{
+				if (body->isActive())
+				{
+					body->applyGravity();
+					body->integrateVelocities( timeStep);
+					body->applyDamping(timeStep);
+					body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform());
+				}
+			}
+		}
+	}
+}
+
+
+void	btSimpleDynamicsWorld::synchronizeMotionStates()
+{
+	//todo: iterate over awake simulation islands!
+	for ( int i=0;i<m_collisionObjects.size();i++)
+	{
+		btCollisionObject* colObj = m_collisionObjects[i];
+		btRigidBody* body = btRigidBody::upcast(colObj);
+		if (body && body->getMotionState())
+		{
+			if (body->getActivationState() != ISLAND_SLEEPING)
+			{
+				body->getMotionState()->setWorldTransform(body->getWorldTransform());
+			}
+		}
+	}
+
+}
+
+
+void	btSimpleDynamicsWorld::setConstraintSolver(btConstraintSolver* solver)
+{
+	if (m_ownsConstraintSolver)
+	{
+		btAlignedFree(m_constraintSolver);
+	}
+	m_ownsConstraintSolver = false;
+	m_constraintSolver = solver;
+}
+
+btConstraintSolver* btSimpleDynamicsWorld::getConstraintSolver()
+{
+	return m_constraintSolver;
+}
Index: /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_SIMPLE_DYNAMICS_WORLD_H
+#define BT_SIMPLE_DYNAMICS_WORLD_H
+
+#include "btDynamicsWorld.h"
+
+class btDispatcher;
+class btOverlappingPairCache;
+class btConstraintSolver;
+
+///btSimpleDynamicsWorld serves as unit-test and to verify more complicated and optimized dynamics worlds.
+///Please use btDiscreteDynamicsWorld instead (or btContinuousDynamicsWorld once it is finished).
+class btSimpleDynamicsWorld : public btDynamicsWorld
+{
+protected:
+
+	btConstraintSolver*	m_constraintSolver;
+
+	bool	m_ownsConstraintSolver;
+
+	void	predictUnconstraintMotion(btScalar timeStep);
+	
+	void	integrateTransforms(btScalar timeStep);
+		
+	btVector3	m_gravity;
+	
+public:
+
+
+
+	///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
+	btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
+
+	virtual ~btSimpleDynamicsWorld();
+		
+	///maxSubSteps/fixedTimeStep for interpolation is currently ignored for btSimpleDynamicsWorld, use btDiscreteDynamicsWorld instead
+	virtual int	stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
+
+	virtual void	setGravity(const btVector3& gravity);
+
+	virtual btVector3 getGravity () const;
+
+	virtual void	addRigidBody(btRigidBody* body);
+
+	virtual void	removeRigidBody(btRigidBody* body);
+	
+	virtual void	updateAabbs();
+
+	void	synchronizeMotionStates();
+
+	virtual void	setConstraintSolver(btConstraintSolver* solver);
+
+	virtual btConstraintSolver* getConstraintSolver();
+
+	virtual btDynamicsWorldType	getWorldType() const
+	{
+		return BT_SIMPLE_DYNAMICS_WORLD;
+	}
+
+	virtual void	clearForces();
+
+};
+
+#endif //BT_SIMPLE_DYNAMICS_WORLD_H
Index: /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btRaycastVehicle.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btRaycastVehicle.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btRaycastVehicle.cpp	(revision 2122)
@@ -0,0 +1,729 @@
+/*
+ * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies.
+ * Erwin Coumans makes no representations about the suitability 
+ * of this software for any purpose.  
+ * It is provided "as is" without express or implied warranty.
+*/
+
+#include "LinearMath/btVector3.h"
+#include "btRaycastVehicle.h"
+
+#include "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h"
+#include "BulletDynamics/ConstraintSolver/btJacobianEntry.h"
+#include "LinearMath/btQuaternion.h"
+#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
+#include "btVehicleRaycaster.h"
+#include "btWheelInfo.h"
+#include "LinearMath/btMinMax.h"
+
+
+#include "BulletDynamics/ConstraintSolver/btContactConstraint.h"
+
+static btRigidBody s_fixedObject( 0,0,0);
+
+btRaycastVehicle::btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis,	btVehicleRaycaster* raycaster )
+: btTypedConstraint(VEHICLE_CONSTRAINT_TYPE),
+m_vehicleRaycaster(raycaster),
+m_pitchControl(btScalar(0.))
+{
+	m_chassisBody = chassis;
+	m_indexRightAxis = 0;
+	m_indexUpAxis = 2;
+	m_indexForwardAxis = 1;
+	defaultInit(tuning);
+}
+
+
+void btRaycastVehicle::defaultInit(const btVehicleTuning& tuning)
+{
+	(void)tuning;
+	m_currentVehicleSpeedKmHour = btScalar(0.);
+	m_steeringValue = btScalar(0.);
+	
+}
+
+	
+
+btRaycastVehicle::~btRaycastVehicle()
+{
+}
+
+
+//
+// basically most of the code is general for 2 or 4 wheel vehicles, but some of it needs to be reviewed
+//
+btWheelInfo&	btRaycastVehicle::addWheel( const btVector3& connectionPointCS, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel)
+{
+
+	btWheelInfoConstructionInfo ci;
+
+	ci.m_chassisConnectionCS = connectionPointCS;
+	ci.m_wheelDirectionCS = wheelDirectionCS0;
+	ci.m_wheelAxleCS = wheelAxleCS;
+	ci.m_suspensionRestLength = suspensionRestLength;
+	ci.m_wheelRadius = wheelRadius;
+	ci.m_suspensionStiffness = tuning.m_suspensionStiffness;
+	ci.m_wheelsDampingCompression = tuning.m_suspensionCompression;
+	ci.m_wheelsDampingRelaxation = tuning.m_suspensionDamping;
+	ci.m_frictionSlip = tuning.m_frictionSlip;
+	ci.m_bIsFrontWheel = isFrontWheel;
+	ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm;
+
+	m_wheelInfo.push_back( btWheelInfo(ci));
+	
+	btWheelInfo& wheel = m_wheelInfo[getNumWheels()-1];
+	
+	updateWheelTransformsWS( wheel , false );
+	updateWheelTransform(getNumWheels()-1,false);
+	return wheel;
+}
+
+
+
+
+const btTransform&	btRaycastVehicle::getWheelTransformWS( int wheelIndex ) const
+{
+	assert(wheelIndex < getNumWheels());
+	const btWheelInfo& wheel = m_wheelInfo[wheelIndex];
+	return wheel.m_worldTransform;
+
+}
+
+void	btRaycastVehicle::updateWheelTransform( int wheelIndex , bool interpolatedTransform)
+{
+	
+	btWheelInfo& wheel = m_wheelInfo[ wheelIndex ];
+	updateWheelTransformsWS(wheel,interpolatedTransform);
+	btVector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS;
+	const btVector3& right = wheel.m_raycastInfo.m_wheelAxleWS;
+	btVector3 fwd = up.cross(right);
+	fwd = fwd.normalize();
+//	up = right.cross(fwd);
+//	up.normalize();
+
+	//rotate around steering over de wheelAxleWS
+	btScalar steering = wheel.m_steering;
+	
+	btQuaternion steeringOrn(up,steering);//wheel.m_steering);
+	btMatrix3x3 steeringMat(steeringOrn);
+
+	btQuaternion rotatingOrn(right,-wheel.m_rotation);
+	btMatrix3x3 rotatingMat(rotatingOrn);
+
+	btMatrix3x3 basis2(
+		right[0],fwd[0],up[0],
+		right[1],fwd[1],up[1],
+		right[2],fwd[2],up[2]
+	);
+	
+	wheel.m_worldTransform.setBasis(steeringMat * rotatingMat * basis2);
+	wheel.m_worldTransform.setOrigin(
+		wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength
+	);
+}
+
+void btRaycastVehicle::resetSuspension()
+{
+
+	int i;
+	for (i=0;i<m_wheelInfo.size();	i++)
+	{
+			btWheelInfo& wheel = m_wheelInfo[i];
+			wheel.m_raycastInfo.m_suspensionLength = wheel.getSuspensionRestLength();
+			wheel.m_suspensionRelativeVelocity = btScalar(0.0);
+			
+			wheel.m_raycastInfo.m_contactNormalWS = - wheel.m_raycastInfo.m_wheelDirectionWS;
+			//wheel_info.setContactFriction(btScalar(0.0));
+			wheel.m_clippedInvContactDotSuspension = btScalar(1.0);
+	}
+}
+
+void	btRaycastVehicle::updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform)
+{
+	wheel.m_raycastInfo.m_isInContact = false;
+
+	btTransform chassisTrans = getChassisWorldTransform();
+	if (interpolatedTransform && (getRigidBody()->getMotionState()))
+	{
+		getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
+	}
+
+	wheel.m_raycastInfo.m_hardPointWS = chassisTrans( wheel.m_chassisConnectionPointCS );
+	wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.getBasis() *  wheel.m_wheelDirectionCS ;
+	wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.getBasis() * wheel.m_wheelAxleCS;
+}
+
+btScalar btRaycastVehicle::rayCast(btWheelInfo& wheel)
+{
+	updateWheelTransformsWS( wheel,false);
+
+	
+	btScalar depth = -1;
+	
+	btScalar raylen = wheel.getSuspensionRestLength()+wheel.m_wheelsRadius;
+
+	btVector3 rayvector = wheel.m_raycastInfo.m_wheelDirectionWS * (raylen);
+	const btVector3& source = wheel.m_raycastInfo.m_hardPointWS;
+	wheel.m_raycastInfo.m_contactPointWS = source + rayvector;
+	const btVector3& target = wheel.m_raycastInfo.m_contactPointWS;
+
+	btScalar param = btScalar(0.);
+	
+	btVehicleRaycaster::btVehicleRaycasterResult	rayResults;
+
+	assert(m_vehicleRaycaster);
+
+	void* object = m_vehicleRaycaster->castRay(source,target,rayResults);
+
+	wheel.m_raycastInfo.m_groundObject = 0;
+
+	if (object)
+	{
+		param = rayResults.m_distFraction;
+		depth = raylen * rayResults.m_distFraction;
+		wheel.m_raycastInfo.m_contactNormalWS  = rayResults.m_hitNormalInWorld;
+		wheel.m_raycastInfo.m_isInContact = true;
+		
+		wheel.m_raycastInfo.m_groundObject = &s_fixedObject;//todo for driving on dynamic/movable objects!;
+		//wheel.m_raycastInfo.m_groundObject = object;
+
+
+		btScalar hitDistance = param*raylen;
+		wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelsRadius;
+		//clamp on max suspension travel
+
+		btScalar  minSuspensionLength = wheel.getSuspensionRestLength() - wheel.m_maxSuspensionTravelCm*btScalar(0.01);
+		btScalar maxSuspensionLength = wheel.getSuspensionRestLength()+ wheel.m_maxSuspensionTravelCm*btScalar(0.01);
+		if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength)
+		{
+			wheel.m_raycastInfo.m_suspensionLength = minSuspensionLength;
+		}
+		if (wheel.m_raycastInfo.m_suspensionLength > maxSuspensionLength)
+		{
+			wheel.m_raycastInfo.m_suspensionLength = maxSuspensionLength;
+		}
+
+		wheel.m_raycastInfo.m_contactPointWS = rayResults.m_hitPointInWorld;
+
+		btScalar denominator= wheel.m_raycastInfo.m_contactNormalWS.dot( wheel.m_raycastInfo.m_wheelDirectionWS );
+
+		btVector3 chassis_velocity_at_contactPoint;
+		btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS-getRigidBody()->getCenterOfMassPosition();
+
+		chassis_velocity_at_contactPoint = getRigidBody()->getVelocityInLocalPoint(relpos);
+
+		btScalar projVel = wheel.m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint );
+
+		if ( denominator >= btScalar(-0.1))
+		{
+			wheel.m_suspensionRelativeVelocity = btScalar(0.0);
+			wheel.m_clippedInvContactDotSuspension = btScalar(1.0) / btScalar(0.1);
+		}
+		else
+		{
+			btScalar inv = btScalar(-1.) / denominator;
+			wheel.m_suspensionRelativeVelocity = projVel * inv;
+			wheel.m_clippedInvContactDotSuspension = inv;
+		}
+			
+	} else
+	{
+		//put wheel info as in rest position
+		wheel.m_raycastInfo.m_suspensionLength = wheel.getSuspensionRestLength();
+		wheel.m_suspensionRelativeVelocity = btScalar(0.0);
+		wheel.m_raycastInfo.m_contactNormalWS = - wheel.m_raycastInfo.m_wheelDirectionWS;
+		wheel.m_clippedInvContactDotSuspension = btScalar(1.0);
+	}
+
+	return depth;
+}
+
+
+const btTransform& btRaycastVehicle::getChassisWorldTransform() const
+{
+	/*if (getRigidBody()->getMotionState())
+	{
+		btTransform chassisWorldTrans;
+		getRigidBody()->getMotionState()->getWorldTransform(chassisWorldTrans);
+		return chassisWorldTrans;
+	}
+	*/
+
+	
+	return getRigidBody()->getCenterOfMassTransform();
+}
+
+
+void btRaycastVehicle::updateVehicle( btScalar step )
+{
+	{
+		for (int i=0;i<getNumWheels();i++)
+		{
+			updateWheelTransform(i,false);
+		}
+	}
+
+
+	m_currentVehicleSpeedKmHour = btScalar(3.6) * getRigidBody()->getLinearVelocity().length();
+	
+	const btTransform& chassisTrans = getChassisWorldTransform();
+
+	btVector3 forwardW (
+		chassisTrans.getBasis()[0][m_indexForwardAxis],
+		chassisTrans.getBasis()[1][m_indexForwardAxis],
+		chassisTrans.getBasis()[2][m_indexForwardAxis]);
+
+	if (forwardW.dot(getRigidBody()->getLinearVelocity()) < btScalar(0.))
+	{
+		m_currentVehicleSpeedKmHour *= btScalar(-1.);
+	}
+
+	//
+	// simulate suspension
+	//
+	
+	int i=0;
+	for (i=0;i<m_wheelInfo.size();i++)
+	{
+		btScalar depth; 
+		depth = rayCast( m_wheelInfo[i]);
+	}
+
+	updateSuspension(step);
+
+	
+	for (i=0;i<m_wheelInfo.size();i++)
+	{
+		//apply suspension force
+		btWheelInfo& wheel = m_wheelInfo[i];
+		
+		btScalar suspensionForce = wheel.m_wheelsSuspensionForce;
+		
+		btScalar gMaxSuspensionForce = btScalar(6000.);
+		if (suspensionForce > gMaxSuspensionForce)
+		{
+			suspensionForce = gMaxSuspensionForce;
+		}
+		btVector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step;
+		btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS - getRigidBody()->getCenterOfMassPosition();
+		
+		getRigidBody()->applyImpulse(impulse, relpos);
+	
+	}
+	
+
+	
+	updateFriction( step);
+
+	
+	for (i=0;i<m_wheelInfo.size();i++)
+	{
+		btWheelInfo& wheel = m_wheelInfo[i];
+		btVector3 relpos = wheel.m_raycastInfo.m_hardPointWS - getRigidBody()->getCenterOfMassPosition();
+		btVector3 vel = getRigidBody()->getVelocityInLocalPoint( relpos );
+
+		if (wheel.m_raycastInfo.m_isInContact)
+		{
+			const btTransform&	chassisWorldTransform = getChassisWorldTransform();
+
+			btVector3 fwd (
+				chassisWorldTransform.getBasis()[0][m_indexForwardAxis],
+				chassisWorldTransform.getBasis()[1][m_indexForwardAxis],
+				chassisWorldTransform.getBasis()[2][m_indexForwardAxis]);
+
+			btScalar proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS);
+			fwd -= wheel.m_raycastInfo.m_contactNormalWS * proj;
+
+			btScalar proj2 = fwd.dot(vel);
+			
+			wheel.m_deltaRotation = (proj2 * step) / (wheel.m_wheelsRadius);
+			wheel.m_rotation += wheel.m_deltaRotation;
+
+		} else
+		{
+			wheel.m_rotation += wheel.m_deltaRotation;
+		}
+		
+		wheel.m_deltaRotation *= btScalar(0.99);//damping of rotation when not in contact
+
+	}
+
+
+
+}
+
+
+void	btRaycastVehicle::setSteeringValue(btScalar steering,int wheel)
+{
+	assert(wheel>=0 && wheel < getNumWheels());
+
+	btWheelInfo& wheelInfo = getWheelInfo(wheel);
+	wheelInfo.m_steering = steering;
+}
+
+
+
+btScalar	btRaycastVehicle::getSteeringValue(int wheel) const
+{
+	return getWheelInfo(wheel).m_steering;
+}
+
+
+void	btRaycastVehicle::applyEngineForce(btScalar force, int wheel)
+{
+	assert(wheel>=0 && wheel < getNumWheels());
+	btWheelInfo& wheelInfo = getWheelInfo(wheel);
+	wheelInfo.m_engineForce = force;
+}
+
+
+const btWheelInfo&	btRaycastVehicle::getWheelInfo(int index) const
+{
+	btAssert((index >= 0) && (index < 	getNumWheels()));
+	
+	return m_wheelInfo[index];
+}
+
+btWheelInfo&	btRaycastVehicle::getWheelInfo(int index) 
+{
+	btAssert((index >= 0) && (index < 	getNumWheels()));
+	
+	return m_wheelInfo[index];
+}
+
+void btRaycastVehicle::setBrake(btScalar brake,int wheelIndex)
+{
+	btAssert((wheelIndex >= 0) && (wheelIndex < 	getNumWheels()));
+	getWheelInfo(wheelIndex).m_brake = brake;
+}
+
+
+void	btRaycastVehicle::updateSuspension(btScalar deltaTime)
+{
+	(void)deltaTime;
+
+	btScalar chassisMass = btScalar(1.) / m_chassisBody->getInvMass();
+	
+	for (int w_it=0; w_it<getNumWheels(); w_it++)
+	{
+		btWheelInfo &wheel_info = m_wheelInfo[w_it];
+		
+		if ( wheel_info.m_raycastInfo.m_isInContact )
+		{
+			btScalar force;
+			//	Spring
+			{
+				btScalar	susp_length			= wheel_info.getSuspensionRestLength();
+				btScalar	current_length = wheel_info.m_raycastInfo.m_suspensionLength;
+
+				btScalar length_diff = (susp_length - current_length);
+
+				force = wheel_info.m_suspensionStiffness
+					* length_diff * wheel_info.m_clippedInvContactDotSuspension;
+			}
+		
+			// Damper
+			{
+				btScalar projected_rel_vel = wheel_info.m_suspensionRelativeVelocity;
+				{
+					btScalar	susp_damping;
+					if ( projected_rel_vel < btScalar(0.0) )
+					{
+						susp_damping = wheel_info.m_wheelsDampingCompression;
+					}
+					else
+					{
+						susp_damping = wheel_info.m_wheelsDampingRelaxation;
+					}
+					force -= susp_damping * projected_rel_vel;
+				}
+			}
+
+			// RESULT
+			wheel_info.m_wheelsSuspensionForce = force * chassisMass;
+			if (wheel_info.m_wheelsSuspensionForce < btScalar(0.))
+			{
+				wheel_info.m_wheelsSuspensionForce = btScalar(0.);
+			}
+		}
+		else
+		{
+			wheel_info.m_wheelsSuspensionForce = btScalar(0.0);
+		}
+	}
+
+}
+
+
+struct btWheelContactPoint
+{
+	btRigidBody* m_body0;
+	btRigidBody* m_body1;
+	btVector3	m_frictionPositionWorld;
+	btVector3	m_frictionDirectionWorld;
+	btScalar	m_jacDiagABInv;
+	btScalar	m_maxImpulse;
+
+
+	btWheelContactPoint(btRigidBody* body0,btRigidBody* body1,const btVector3& frictionPosWorld,const btVector3& frictionDirectionWorld, btScalar maxImpulse)
+		:m_body0(body0),
+		m_body1(body1),
+		m_frictionPositionWorld(frictionPosWorld),
+		m_frictionDirectionWorld(frictionDirectionWorld),
+		m_maxImpulse(maxImpulse)
+	{
+		btScalar denom0 = body0->computeImpulseDenominator(frictionPosWorld,frictionDirectionWorld);
+		btScalar denom1 = body1->computeImpulseDenominator(frictionPosWorld,frictionDirectionWorld);
+		btScalar	relaxation = 1.f;
+		m_jacDiagABInv = relaxation/(denom0+denom1);
+	}
+
+
+
+};
+
+btScalar calcRollingFriction(btWheelContactPoint& contactPoint);
+btScalar calcRollingFriction(btWheelContactPoint& contactPoint)
+{
+
+	btScalar j1=0.f;
+
+	const btVector3& contactPosWorld = contactPoint.m_frictionPositionWorld;
+
+	btVector3 rel_pos1 = contactPosWorld - contactPoint.m_body0->getCenterOfMassPosition(); 
+	btVector3 rel_pos2 = contactPosWorld - contactPoint.m_body1->getCenterOfMassPosition();
+	
+	btScalar maxImpulse  = contactPoint.m_maxImpulse;
+	
+	btVector3 vel1 = contactPoint.m_body0->getVelocityInLocalPoint(rel_pos1);
+	btVector3 vel2 = contactPoint.m_body1->getVelocityInLocalPoint(rel_pos2);
+	btVector3 vel = vel1 - vel2;
+
+	btScalar vrel = contactPoint.m_frictionDirectionWorld.dot(vel);
+
+	// calculate j that moves us to zero relative velocity
+	j1 = -vrel * contactPoint.m_jacDiagABInv;
+	btSetMin(j1, maxImpulse);
+	btSetMax(j1, -maxImpulse);
+
+	return j1;
+}
+
+
+
+
+btScalar sideFrictionStiffness2 = btScalar(1.0);
+void	btRaycastVehicle::updateFriction(btScalar	timeStep)
+{
+
+		//calculate the impulse, so that the wheels don't move sidewards
+		int numWheel = getNumWheels();
+		if (!numWheel)
+			return;
+
+		m_forwardWS.resize(numWheel);
+		m_axle.resize(numWheel);
+		m_forwardImpulse.resize(numWheel);
+		m_sideImpulse.resize(numWheel);
+		
+		int numWheelsOnGround = 0;
+	
+
+		//collapse all those loops into one!
+		for (int i=0;i<getNumWheels();i++)
+		{
+			btWheelInfo& wheelInfo = m_wheelInfo[i];
+			class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;
+			if (groundObject)
+				numWheelsOnGround++;
+			m_sideImpulse[i] = btScalar(0.);
+			m_forwardImpulse[i] = btScalar(0.);
+
+		}
+	
+		{
+	
+			for (int i=0;i<getNumWheels();i++)
+			{
+
+				btWheelInfo& wheelInfo = m_wheelInfo[i];
+					
+				class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;
+
+				if (groundObject)
+				{
+
+					const btTransform& wheelTrans = getWheelTransformWS( i );
+
+					btMatrix3x3 wheelBasis0 = wheelTrans.getBasis();
+					m_axle[i] = btVector3(	
+						wheelBasis0[0][m_indexRightAxis],
+						wheelBasis0[1][m_indexRightAxis],
+						wheelBasis0[2][m_indexRightAxis]);
+					
+					const btVector3& surfNormalWS = wheelInfo.m_raycastInfo.m_contactNormalWS;
+					btScalar proj = m_axle[i].dot(surfNormalWS);
+					m_axle[i] -= surfNormalWS * proj;
+					m_axle[i] = m_axle[i].normalize();
+					
+					m_forwardWS[i] = surfNormalWS.cross(m_axle[i]);
+					m_forwardWS[i].normalize();
+
+				
+					resolveSingleBilateral(*m_chassisBody, wheelInfo.m_raycastInfo.m_contactPointWS,
+							  *groundObject, wheelInfo.m_raycastInfo.m_contactPointWS,
+							  btScalar(0.), m_axle[i],m_sideImpulse[i],timeStep);
+
+					m_sideImpulse[i] *= sideFrictionStiffness2;
+						
+				}
+				
+
+			}
+		}
+
+	btScalar sideFactor = btScalar(1.);
+	btScalar fwdFactor = 0.5;
+
+	bool sliding = false;
+	{
+		for (int wheel =0;wheel <getNumWheels();wheel++)
+		{
+			btWheelInfo& wheelInfo = m_wheelInfo[wheel];
+			class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;
+
+			btScalar	rollingFriction = 0.f;
+
+			if (groundObject)
+			{
+				if (wheelInfo.m_engineForce != 0.f)
+				{
+					rollingFriction = wheelInfo.m_engineForce* timeStep;
+				} else
+				{
+					btScalar defaultRollingFrictionImpulse = 0.f;
+					btScalar maxImpulse = wheelInfo.m_brake ? wheelInfo.m_brake : defaultRollingFrictionImpulse;
+					btWheelContactPoint contactPt(m_chassisBody,groundObject,wheelInfo.m_raycastInfo.m_contactPointWS,m_forwardWS[wheel],maxImpulse);
+					rollingFriction = calcRollingFriction(contactPt);
+				}
+			}
+
+			//switch between active rolling (throttle), braking and non-active rolling friction (no throttle/break)
+			
+
+
+
+			m_forwardImpulse[wheel] = btScalar(0.);
+			m_wheelInfo[wheel].m_skidInfo= btScalar(1.);
+
+			if (groundObject)
+			{
+				m_wheelInfo[wheel].m_skidInfo= btScalar(1.);
+				
+				btScalar maximp = wheelInfo.m_wheelsSuspensionForce * timeStep * wheelInfo.m_frictionSlip;
+				btScalar maximpSide = maximp;
+
+				btScalar maximpSquared = maximp * maximpSide;
+			
+
+				m_forwardImpulse[wheel] = rollingFriction;//wheelInfo.m_engineForce* timeStep;
+
+				btScalar x = (m_forwardImpulse[wheel] ) * fwdFactor;
+				btScalar y = (m_sideImpulse[wheel] ) * sideFactor;
+				
+				btScalar impulseSquared = (x*x + y*y);
+
+				if (impulseSquared > maximpSquared)
+				{
+					sliding = true;
+					
+					btScalar factor = maximp / btSqrt(impulseSquared);
+					
+					m_wheelInfo[wheel].m_skidInfo *= factor;
+				}
+			} 
+
+		}
+	}
+
+	
+
+
+		if (sliding)
+		{
+			for (int wheel = 0;wheel < getNumWheels(); wheel++)
+			{
+				if (m_sideImpulse[wheel] != btScalar(0.))
+				{
+					if (m_wheelInfo[wheel].m_skidInfo< btScalar(1.))
+					{
+						m_forwardImpulse[wheel] *=	m_wheelInfo[wheel].m_skidInfo;
+						m_sideImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo;
+					}
+				}
+			}
+		}
+
+		// apply the impulses
+		{
+			for (int wheel = 0;wheel<getNumWheels() ; wheel++)
+			{
+				btWheelInfo& wheelInfo = m_wheelInfo[wheel];
+
+				btVector3 rel_pos = wheelInfo.m_raycastInfo.m_contactPointWS - 
+						m_chassisBody->getCenterOfMassPosition();
+
+				if (m_forwardImpulse[wheel] != btScalar(0.))
+				{
+					m_chassisBody->applyImpulse(m_forwardWS[wheel]*(m_forwardImpulse[wheel]),rel_pos);
+				}
+				if (m_sideImpulse[wheel] != btScalar(0.))
+				{
+					class btRigidBody* groundObject = (class btRigidBody*) m_wheelInfo[wheel].m_raycastInfo.m_groundObject;
+
+					btVector3 rel_pos2 = wheelInfo.m_raycastInfo.m_contactPointWS - 
+						groundObject->getCenterOfMassPosition();
+
+					
+					btVector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel];
+
+					rel_pos[2] *= wheelInfo.m_rollInfluence;
+					m_chassisBody->applyImpulse(sideImp,rel_pos);
+
+					//apply friction impulse on the ground
+					groundObject->applyImpulse(-sideImp,rel_pos2);
+				}
+			}
+		}
+
+	
+}
+
+
+void* btDefaultVehicleRaycaster::castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result)
+{
+//	RayResultCallback& resultCallback;
+
+	btCollisionWorld::ClosestRayResultCallback rayCallback(from,to);
+
+	m_dynamicsWorld->rayTest(from, to, rayCallback);
+
+	if (rayCallback.hasHit())
+	{
+		
+		btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
+        if (body && body->hasContactResponse())
+		{
+			result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
+			result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld;
+			result.m_hitNormalInWorld.normalize();
+			result.m_distFraction = rayCallback.m_closestHitFraction;
+			return body;
+		}
+	}
+	return 0;
+}
Index: /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h	(revision 2122)
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies.
+ * Erwin Coumans makes no representations about the suitability 
+ * of this software for any purpose.  
+ * It is provided "as is" without express or implied warranty.
+*/
+#ifndef RAYCASTVEHICLE_H
+#define RAYCASTVEHICLE_H
+
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
+#include "btVehicleRaycaster.h"
+class btDynamicsWorld;
+#include "LinearMath/btAlignedObjectArray.h"
+#include "btWheelInfo.h"
+
+class btVehicleTuning;
+
+///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
+class btRaycastVehicle : public btTypedConstraint
+{
+
+		btAlignedObjectArray<btVector3>	m_forwardWS;
+		btAlignedObjectArray<btVector3>	m_axle;
+		btAlignedObjectArray<btScalar>	m_forwardImpulse;
+		btAlignedObjectArray<btScalar>	m_sideImpulse;
+
+public:
+	class btVehicleTuning
+		{
+			public:
+
+			btVehicleTuning()
+				:m_suspensionStiffness(btScalar(5.88)),
+				m_suspensionCompression(btScalar(0.83)),
+				m_suspensionDamping(btScalar(0.88)),
+				m_maxSuspensionTravelCm(btScalar(500.)),
+				m_frictionSlip(btScalar(10.5))
+			{
+			}
+			btScalar	m_suspensionStiffness;
+			btScalar	m_suspensionCompression;
+			btScalar	m_suspensionDamping;
+			btScalar	m_maxSuspensionTravelCm;
+			btScalar	m_frictionSlip;
+
+		};
+private:
+
+	btScalar	m_tau;
+	btScalar	m_damping;
+	btVehicleRaycaster*	m_vehicleRaycaster;
+	btScalar		m_pitchControl;
+	btScalar	m_steeringValue; 
+	btScalar m_currentVehicleSpeedKmHour;
+
+	btRigidBody* m_chassisBody;
+
+	int m_indexRightAxis;
+	int m_indexUpAxis;
+	int	m_indexForwardAxis;
+
+	void defaultInit(const btVehicleTuning& tuning);
+
+public:
+
+	//constructor to create a car from an existing rigidbody
+	btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis,	btVehicleRaycaster* raycaster );
+
+	virtual ~btRaycastVehicle() ;
+
+		
+	const btTransform& getChassisWorldTransform() const;
+	
+	btScalar rayCast(btWheelInfo& wheel);
+
+	virtual void updateVehicle(btScalar step);
+
+	void resetSuspension();
+
+	btScalar	getSteeringValue(int wheel) const;
+
+	void	setSteeringValue(btScalar steering,int wheel);
+
+
+	void	applyEngineForce(btScalar force, int wheel);
+
+	const btTransform&	getWheelTransformWS( int wheelIndex ) const;
+
+	void	updateWheelTransform( int wheelIndex, bool interpolatedTransform = true );
+	
+	void	setRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth);
+
+	btWheelInfo&	addWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel);
+
+	inline int		getNumWheels() const {
+		return int (m_wheelInfo.size());
+	}
+	
+	btAlignedObjectArray<btWheelInfo>	m_wheelInfo;
+
+
+	const btWheelInfo&	getWheelInfo(int index) const;
+
+	btWheelInfo&	getWheelInfo(int index);
+
+	void	updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform = true);
+
+	
+	void setBrake(btScalar brake,int wheelIndex);
+
+	void	setPitchControl(btScalar pitch)
+	{
+		m_pitchControl = pitch;
+	}
+	
+	void	updateSuspension(btScalar deltaTime);
+
+	virtual void	updateFriction(btScalar	timeStep);
+
+
+
+	inline btRigidBody* getRigidBody()
+	{
+		return m_chassisBody;
+	}
+
+	const btRigidBody* getRigidBody() const
+	{
+		return m_chassisBody;
+	}
+
+	inline int	getRightAxis() const
+	{
+		return m_indexRightAxis;
+	}
+	inline int getUpAxis() const
+	{
+		return m_indexUpAxis;
+	}
+
+	inline int getForwardAxis() const
+	{
+		return m_indexForwardAxis;
+	}
+
+	
+	///Worldspace forward vector
+	btVector3 getForwardVector() const
+	{
+		const btTransform& chassisTrans = getChassisWorldTransform(); 
+
+		btVector3 forwardW ( 
+			  chassisTrans.getBasis()[0][m_indexForwardAxis], 
+			  chassisTrans.getBasis()[1][m_indexForwardAxis], 
+			  chassisTrans.getBasis()[2][m_indexForwardAxis]); 
+
+		return forwardW;
+	}
+
+	///Velocity of vehicle (positive if velocity vector has same direction as foward vector)
+	btScalar	getCurrentSpeedKmHour() const
+	{
+		return m_currentVehicleSpeedKmHour;
+	}
+
+	virtual void	setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex)
+	{
+		m_indexRightAxis = rightIndex;
+		m_indexUpAxis = upIndex;
+		m_indexForwardAxis = forwardIndex;
+	}
+
+	virtual void	buildJacobian()
+	{
+		//not yet
+	}
+
+	virtual	void	solveConstraint(btScalar	timeStep)
+	{
+		(void)timeStep;
+		//not yet
+	}
+
+
+};
+
+class btDefaultVehicleRaycaster : public btVehicleRaycaster
+{
+	btDynamicsWorld*	m_dynamicsWorld;
+public:
+	btDefaultVehicleRaycaster(btDynamicsWorld* world)
+		:m_dynamicsWorld(world)
+	{
+	}
+
+	virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result);
+
+};
+
+
+#endif //RAYCASTVEHICLE_H
+
Index: /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btVehicleRaycaster.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btVehicleRaycaster.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btVehicleRaycaster.h	(revision 2122)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies.
+ * Erwin Coumans makes no representations about the suitability 
+ * of this software for any purpose.  
+ * It is provided "as is" without express or implied warranty.
+*/
+#ifndef VEHICLE_RAYCASTER_H
+#define VEHICLE_RAYCASTER_H
+
+#include "LinearMath/btVector3.h"
+
+/// btVehicleRaycaster is provides interface for between vehicle simulation and raycasting
+struct btVehicleRaycaster
+{
+virtual ~btVehicleRaycaster()
+{
+}
+	struct btVehicleRaycasterResult
+	{
+		btVehicleRaycasterResult() :m_distFraction(btScalar(-1.)){};
+		btVector3	m_hitPointInWorld;
+		btVector3	m_hitNormalInWorld;
+		btScalar	m_distFraction;
+	};
+
+	virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) = 0;
+
+};
+
+#endif //VEHICLE_RAYCASTER_H
+
Index: /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btWheelInfo.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btWheelInfo.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btWheelInfo.cpp	(revision 2122)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies.
+ * Erwin Coumans makes no representations about the suitability 
+ * of this software for any purpose.  
+ * It is provided "as is" without express or implied warranty.
+*/
+#include "btWheelInfo.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h" // for pointvelocity
+
+
+btScalar btWheelInfo::getSuspensionRestLength() const
+{
+
+	return m_suspensionRestLength1;
+
+}
+
+void	btWheelInfo::updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo)
+{
+	(void)raycastInfo;
+
+	
+	if (m_raycastInfo.m_isInContact)
+
+	{
+		btScalar	project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS );
+		btVector3	 chassis_velocity_at_contactPoint;
+		btVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.getCenterOfMassPosition();
+		chassis_velocity_at_contactPoint = chassis.getVelocityInLocalPoint( relpos );
+		btScalar projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint );
+		if ( project >= btScalar(-0.1))
+		{
+			m_suspensionRelativeVelocity = btScalar(0.0);
+			m_clippedInvContactDotSuspension = btScalar(1.0) / btScalar(0.1);
+		}
+		else
+		{
+			btScalar inv = btScalar(-1.) / project;
+			m_suspensionRelativeVelocity = projVel * inv;
+			m_clippedInvContactDotSuspension = inv;
+		}
+		
+	}
+
+	else	// Not in contact : position wheel in a nice (rest length) position
+	{
+		m_raycastInfo.m_suspensionLength = this->getSuspensionRestLength();
+		m_suspensionRelativeVelocity = btScalar(0.0);
+		m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS;
+		m_clippedInvContactDotSuspension = btScalar(1.0);
+	}
+}
Index: /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btWheelInfo.h
===================================================================
--- /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btWheelInfo.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletDynamics/Vehicle/btWheelInfo.h	(revision 2122)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies.
+ * Erwin Coumans makes no representations about the suitability 
+ * of this software for any purpose.  
+ * It is provided "as is" without express or implied warranty.
+*/
+#ifndef WHEEL_INFO_H
+#define WHEEL_INFO_H
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btTransform.h"
+
+class btRigidBody;
+
+struct btWheelInfoConstructionInfo
+{
+	btVector3	m_chassisConnectionCS;
+	btVector3	m_wheelDirectionCS;
+	btVector3	m_wheelAxleCS;
+	btScalar	m_suspensionRestLength;
+	btScalar	m_maxSuspensionTravelCm;
+	btScalar	m_wheelRadius;
+	
+	btScalar		m_suspensionStiffness;
+	btScalar		m_wheelsDampingCompression;
+	btScalar		m_wheelsDampingRelaxation;
+	btScalar		m_frictionSlip;
+	bool m_bIsFrontWheel;
+	
+};
+
+/// btWheelInfo contains information per wheel about friction and suspension.
+struct btWheelInfo
+{
+	struct RaycastInfo
+	{
+		//set by raycaster
+		btVector3	m_contactNormalWS;//contactnormal
+		btVector3	m_contactPointWS;//raycast hitpoint
+		btScalar	m_suspensionLength;
+		btVector3	m_hardPointWS;//raycast starting point
+		btVector3	m_wheelDirectionWS; //direction in worldspace
+		btVector3	m_wheelAxleWS; // axle in worldspace
+		bool		m_isInContact;
+		void*		m_groundObject; //could be general void* ptr
+	};
+
+	RaycastInfo	m_raycastInfo;
+
+	btTransform	m_worldTransform;
+	
+	btVector3	m_chassisConnectionPointCS; //const
+	btVector3	m_wheelDirectionCS;//const
+	btVector3	m_wheelAxleCS; // const or modified by steering
+	btScalar	m_suspensionRestLength1;//const
+	btScalar	m_maxSuspensionTravelCm;
+	btScalar getSuspensionRestLength() const;
+	btScalar	m_wheelsRadius;//const
+	btScalar	m_suspensionStiffness;//const
+	btScalar	m_wheelsDampingCompression;//const
+	btScalar	m_wheelsDampingRelaxation;//const
+	btScalar	m_frictionSlip;
+	btScalar	m_steering;
+	btScalar	m_rotation;
+	btScalar	m_deltaRotation;
+	btScalar	m_rollInfluence;
+
+	btScalar	m_engineForce;
+
+	btScalar	m_brake;
+	
+	bool m_bIsFrontWheel;
+	
+	void*		m_clientInfo;//can be used to store pointer to sync transforms...
+
+	btWheelInfo(btWheelInfoConstructionInfo& ci)
+
+	{
+
+		m_suspensionRestLength1 = ci.m_suspensionRestLength;
+		m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm;
+
+		m_wheelsRadius = ci.m_wheelRadius;
+		m_suspensionStiffness = ci.m_suspensionStiffness;
+		m_wheelsDampingCompression = ci.m_wheelsDampingCompression;
+		m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation;
+		m_chassisConnectionPointCS = ci.m_chassisConnectionCS;
+		m_wheelDirectionCS = ci.m_wheelDirectionCS;
+		m_wheelAxleCS = ci.m_wheelAxleCS;
+		m_frictionSlip = ci.m_frictionSlip;
+		m_steering = btScalar(0.);
+		m_engineForce = btScalar(0.);
+		m_rotation = btScalar(0.);
+		m_deltaRotation = btScalar(0.);
+		m_brake = btScalar(0.);
+		m_rollInfluence = btScalar(0.1);
+		m_bIsFrontWheel = ci.m_bIsFrontWheel;
+
+	}
+
+	void	updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo);
+
+	btScalar	m_clippedInvContactDotSuspension;
+	btScalar	m_suspensionRelativeVelocity;
+	//calculated by suspension
+	btScalar	m_wheelsSuspensionForce;
+	btScalar	m_skidInfo;
+
+};
+
+#endif //WHEEL_INFO_H
+
Index: /code/branches/physics/src/bullet/BulletLicense.txt
===================================================================
--- /code/branches/physics/src/bullet/BulletLicense.txt	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletLicense.txt	(revision 2122)
@@ -0,0 +1,17 @@
+/*
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+Free for commercial use, but please mail bullet@erwincoumans.com to report projects, and join the forum at
+www.continuousphysics.com/Bullet/phpBB2
Index: /code/branches/physics/src/bullet/BulletSoftBody/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,16 @@
+ADD_LIBRARY(LibBulletSoftBody SHARED
+	btSoftBody.cpp
+	btSoftBody.h
+	btSoftBodyHelpers.cpp
+	btSparseSDF.h
+	btSoftBodyHelpers.h
+	btSoftBodyRigidBodyCollisionConfiguration.cpp
+	btSoftRigidCollisionAlgorithm.cpp
+	btSoftRigidCollisionAlgorithm.h
+	btSoftSoftCollisionAlgorithm.cpp
+	btSoftSoftCollisionAlgorithm.h
+	btSoftBodyConcaveCollisionAlgorithm.cpp
+	btSoftBodyConcaveCollisionAlgorithm.h
+	btSoftRigidDynamicsWorld.h
+	btSoftRigidDynamicsWorld.cpp
+)
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.cpp	(revision 2122)
@@ -0,0 +1,2615 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btSoftBody implementation by Nathanael Presson
+
+#include "btSoftBodyInternals.h"
+
+//
+btSoftBody::btSoftBody(btSoftBodyWorldInfo*	worldInfo,int node_count,  const btVector3* x,  const btScalar* m)
+:m_worldInfo(worldInfo)
+{	
+	/* Init		*/ 
+	m_internalType		=	CO_SOFT_BODY;
+	m_cfg.aeromodel		=	eAeroModel::V_Point;
+	m_cfg.kVCF			=	1;
+	m_cfg.kDG			=	0;
+	m_cfg.kLF			=	0;
+	m_cfg.kDP			=	0;
+	m_cfg.kPR			=	0;
+	m_cfg.kVC			=	0;
+	m_cfg.kDF			=	(btScalar)0.2;
+	m_cfg.kMT			=	0;
+	m_cfg.kCHR			=	(btScalar)1.0;
+	m_cfg.kKHR			=	(btScalar)0.1;
+	m_cfg.kSHR			=	(btScalar)1.0;
+	m_cfg.kAHR			=	(btScalar)0.7;
+	m_cfg.kSRHR_CL		=	(btScalar)0.1;
+	m_cfg.kSKHR_CL		=	(btScalar)1;
+	m_cfg.kSSHR_CL		=	(btScalar)0.5;
+	m_cfg.kSR_SPLT_CL	=	(btScalar)0.5;
+	m_cfg.kSK_SPLT_CL	=	(btScalar)0.5;
+	m_cfg.kSS_SPLT_CL	=	(btScalar)0.5;
+	m_cfg.maxvolume		=	(btScalar)1;
+	m_cfg.timescale		=	1;
+	m_cfg.viterations	=	0;
+	m_cfg.piterations	=	1;	
+	m_cfg.diterations	=	0;
+	m_cfg.citerations	=	4;
+	m_cfg.collisions	=	fCollision::Default;
+	m_pose.m_bvolume	=	false;
+	m_pose.m_bframe		=	false;
+	m_pose.m_volume		=	0;
+	m_pose.m_com		=	btVector3(0,0,0);
+	m_pose.m_rot.setIdentity();
+	m_pose.m_scl.setIdentity();
+	m_tag				=	0;
+	m_timeacc			=	0;
+	m_bUpdateRtCst		=	true;
+	m_bounds[0]			=	btVector3(0,0,0);
+	m_bounds[1]			=	btVector3(0,0,0);
+	m_worldTransform.setIdentity();
+	setSolver(eSolverPresets::Positions);
+	/* Default material	*/ 
+	Material*	pm=appendMaterial();
+	pm->m_kLST	=	1;
+	pm->m_kAST	=	1;
+	pm->m_kVST	=	1;
+	pm->m_flags	=	fMaterial::Default;
+	/* Collision shape	*/ 
+	///for now, create a collision shape internally
+	m_collisionShape = new btSoftBodyCollisionShape(this);
+	m_collisionShape->setMargin(0.25);
+	/* Nodes			*/ 
+	const btScalar		margin=getCollisionShape()->getMargin();
+	m_nodes.resize(node_count);
+	for(int i=0,ni=node_count;i<ni;++i)
+	{	
+		Node&	n=m_nodes[i];
+		ZeroInitialize(n);
+		n.m_x		=	x?*x++:btVector3(0,0,0);
+		n.m_q		=	n.m_x;
+		n.m_im		=	m?*m++:1;
+		n.m_im		=	n.m_im>0?1/n.m_im:0;
+		n.m_leaf	=	m_ndbvt.insert(btDbvtVolume::FromCR(n.m_x,margin),&n);
+		n.m_material=	pm;
+	}
+	updateBounds();	
+
+
+}
+
+//
+btSoftBody::~btSoftBody()
+{
+	//for now, delete the internal shape
+	delete m_collisionShape;	
+	int i;
+
+	releaseClusters();
+	for(i=0;i<m_materials.size();++i) 
+		btAlignedFree(m_materials[i]);
+	for(i=0;i<m_joints.size();++i) 
+		btAlignedFree(m_joints[i]);
+}
+
+//
+bool			btSoftBody::checkLink(int node0,int node1) const
+{
+	return(checkLink(&m_nodes[node0],&m_nodes[node1]));
+}
+
+//
+bool			btSoftBody::checkLink(const Node* node0,const Node* node1) const
+{
+	const Node*	n[]={node0,node1};
+	for(int i=0,ni=m_links.size();i<ni;++i)
+	{
+		const Link&	l=m_links[i];
+		if(	(l.m_n[0]==n[0]&&l.m_n[1]==n[1])||
+			(l.m_n[0]==n[1]&&l.m_n[1]==n[0]))
+		{
+			return(true);
+		}
+	}
+	return(false);
+}
+
+//
+bool			btSoftBody::checkFace(int node0,int node1,int node2) const
+{
+	const Node*	n[]={	&m_nodes[node0],
+		&m_nodes[node1],
+		&m_nodes[node2]};
+	for(int i=0,ni=m_faces.size();i<ni;++i)
+	{
+		const Face&	f=m_faces[i];
+		int			c=0;
+		for(int j=0;j<3;++j)
+		{
+			if(	(f.m_n[j]==n[0])||
+				(f.m_n[j]==n[1])||
+				(f.m_n[j]==n[2])) c|=1<<j; else break;
+		}
+		if(c==7) return(true);
+	}
+	return(false);
+}
+
+//
+btSoftBody::Material*		btSoftBody::appendMaterial()
+{
+Material*	pm=new(btAlignedAlloc(sizeof(Material),16)) Material();
+if(m_materials.size()>0)
+	*pm=*m_materials[0];
+	else
+	ZeroInitialize(*pm);
+m_materials.push_back(pm);
+return(pm);
+}
+
+//
+void			btSoftBody::appendNote(	const char* text,
+										const btVector3& o,
+										const btVector4& c,
+										Node* n0,
+										Node* n1,
+										Node* n2,
+										Node* n3)
+{
+Note	n;
+ZeroInitialize(n);
+n.m_rank		=	0;
+n.m_text		=	text;
+n.m_offset		=	o;
+n.m_coords[0]	=	c.x();
+n.m_coords[1]	=	c.y();
+n.m_coords[2]	=	c.z();
+n.m_coords[3]	=	c.w();
+n.m_nodes[0]	=	n0;n.m_rank+=n0?1:0;
+n.m_nodes[1]	=	n1;n.m_rank+=n1?1:0;
+n.m_nodes[2]	=	n2;n.m_rank+=n2?1:0;
+n.m_nodes[3]	=	n3;n.m_rank+=n3?1:0;
+m_notes.push_back(n);
+}
+
+//
+void			btSoftBody::appendNote(	const char* text,
+										const btVector3& o,
+										Node* feature)
+{
+appendNote(text,o,btVector4(1,0,0,0),feature);
+}
+
+//
+void			btSoftBody::appendNote(	const char* text,
+										const btVector3& o,
+										Link* feature)
+{
+static const btScalar	w=1/(btScalar)2;
+appendNote(text,o,btVector4(w,w,0,0),	feature->m_n[0],
+										feature->m_n[1]);
+}
+								
+//
+void			btSoftBody::appendNote(	const char* text,
+										const btVector3& o,
+										Face* feature)
+{
+static const btScalar	w=1/(btScalar)3;
+appendNote(text,o,btVector4(w,w,w,0),	feature->m_n[0],
+										feature->m_n[1],
+										feature->m_n[2]);
+}
+
+//
+void			btSoftBody::appendNode(	const btVector3& x,btScalar m)
+{
+if(m_nodes.capacity()==m_nodes.size())
+	{
+	pointersToIndices();
+	m_nodes.reserve(m_nodes.size()*2+1);
+	indicesToPointers();
+	}
+const btScalar	margin=getCollisionShape()->getMargin();
+m_nodes.push_back(Node());
+Node&			n=m_nodes[m_nodes.size()-1];
+ZeroInitialize(n);
+n.m_x			=	x;
+n.m_q			=	n.m_x;
+n.m_im			=	m>0?1/m:0;
+n.m_material	=	m_materials[0];
+n.m_leaf		=	m_ndbvt.insert(btDbvtVolume::FromCR(n.m_x,margin),&n);
+}
+
+//
+void			btSoftBody::appendLink(int model,Material* mat)
+{
+Link	l;
+if(model>=0)
+	l=m_links[model];
+	else
+	{ ZeroInitialize(l);l.m_material=mat?mat:m_materials[0]; }
+m_links.push_back(l);
+}
+
+//
+void			btSoftBody::appendLink(	int node0,
+									   int node1,
+									   Material* mat,
+									   bool bcheckexist)
+{
+	appendLink(&m_nodes[node0],&m_nodes[node1],mat,bcheckexist);
+}
+
+//
+void			btSoftBody::appendLink(	Node* node0,
+									   Node* node1,
+									   Material* mat,
+									   bool bcheckexist)
+{
+	if((!bcheckexist)||(!checkLink(node0,node1)))
+	{
+		appendLink(-1,mat);
+		Link&	l=m_links[m_links.size()-1];
+		l.m_n[0]		=	node0;
+		l.m_n[1]		=	node1;
+		l.m_rl			=	(l.m_n[0]->m_x-l.m_n[1]->m_x).length();
+		m_bUpdateRtCst=true;
+	}
+}
+
+//
+void			btSoftBody::appendFace(int model,Material* mat)
+{
+Face	f;
+if(model>=0)
+	{ f=m_faces[model]; }
+	else
+	{ ZeroInitialize(f);f.m_material=mat?mat:m_materials[0]; }
+m_faces.push_back(f);
+}
+
+//
+void			btSoftBody::appendFace(int node0,int node1,int node2,Material* mat)
+{
+	if (node0==node1)
+		return;
+	if (node1==node2)
+		return;
+	if (node2==node0)
+		return;
+
+	appendFace(-1,mat);
+	Face&	f=m_faces[m_faces.size()-1];
+	btAssert(node0!=node1);
+	btAssert(node1!=node2);
+	btAssert(node2!=node0);
+	f.m_n[0]	=	&m_nodes[node0];
+	f.m_n[1]	=	&m_nodes[node1];
+	f.m_n[2]	=	&m_nodes[node2];
+	f.m_ra		=	AreaOf(	f.m_n[0]->m_x,
+		f.m_n[1]->m_x,
+		f.m_n[2]->m_x);	
+	m_bUpdateRtCst=true;
+}
+
+//
+void			btSoftBody::appendAnchor(int node,btRigidBody* body)
+{
+	Anchor	a;
+	a.m_node			=	&m_nodes[node];
+	a.m_body			=	body;
+	a.m_local			=	body->getInterpolationWorldTransform().inverse()*a.m_node->m_x;
+	a.m_node->m_battach	=	1;
+	m_anchors.push_back(a);
+}
+
+//
+void			btSoftBody::appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1)
+{
+LJoint*		pj	=	new(btAlignedAlloc(sizeof(LJoint),16)) LJoint();
+pj->m_bodies[0]	=	body0;
+pj->m_bodies[1]	=	body1;
+pj->m_refs[0]	=	pj->m_bodies[0].xform().inverse()*specs.position;
+pj->m_refs[1]	=	pj->m_bodies[1].xform().inverse()*specs.position;
+pj->m_cfm		=	specs.cfm;
+pj->m_erp		=	specs.erp;
+pj->m_split		=	specs.split;
+m_joints.push_back(pj);
+}
+
+//
+void			btSoftBody::appendLinearJoint(const LJoint::Specs& specs,Body body)
+{
+appendLinearJoint(specs,m_clusters[0],body);
+}
+
+//
+void			btSoftBody::appendLinearJoint(const LJoint::Specs& specs,btSoftBody* body)
+{
+appendLinearJoint(specs,m_clusters[0],body->m_clusters[0]);
+}
+
+//
+void			btSoftBody::appendAngularJoint(const AJoint::Specs& specs,Cluster* body0,Body body1)
+{
+AJoint*		pj	=	new(btAlignedAlloc(sizeof(AJoint),16)) AJoint();
+pj->m_bodies[0]	=	body0;
+pj->m_bodies[1]	=	body1;
+pj->m_refs[0]	=	pj->m_bodies[0].xform().inverse().getBasis()*specs.axis;
+pj->m_refs[1]	=	pj->m_bodies[1].xform().inverse().getBasis()*specs.axis;
+pj->m_cfm		=	specs.cfm;
+pj->m_erp		=	specs.erp;
+pj->m_split		=	specs.split;
+pj->m_icontrol	=	specs.icontrol;
+m_joints.push_back(pj);
+}
+
+//
+void			btSoftBody::appendAngularJoint(const AJoint::Specs& specs,Body body)
+{
+appendAngularJoint(specs,m_clusters[0],body);
+}
+
+//
+void			btSoftBody::appendAngularJoint(const AJoint::Specs& specs,btSoftBody* body)
+{
+appendAngularJoint(specs,m_clusters[0],body->m_clusters[0]);
+}
+
+//
+void			btSoftBody::addForce(const btVector3& force)
+{
+	for(int i=0,ni=m_nodes.size();i<ni;++i) addForce(force,i);
+}
+
+//
+void			btSoftBody::addForce(const btVector3& force,int node)
+{
+	Node&	n=m_nodes[node];
+	if(n.m_im>0)
+	{
+		n.m_f	+=	force;
+	}
+}
+
+//
+void			btSoftBody::addVelocity(const btVector3& velocity)
+{
+	for(int i=0,ni=m_nodes.size();i<ni;++i) addVelocity(velocity,i);
+}
+
+/* Set velocity for the entire body										*/ 
+void				btSoftBody::setVelocity(	const btVector3& velocity)
+{
+	for(int i=0,ni=m_nodes.size();i<ni;++i) 
+	{
+		Node&	n=m_nodes[i];
+		if(n.m_im>0)
+		{
+			n.m_v	=	velocity;
+		}
+	}
+}
+
+
+//
+void			btSoftBody::addVelocity(const btVector3& velocity,int node)
+{
+	Node&	n=m_nodes[node];
+	if(n.m_im>0)
+	{
+		n.m_v	+=	velocity;
+	}
+}
+
+//
+void			btSoftBody::setMass(int node,btScalar mass)
+{
+	m_nodes[node].m_im=mass>0?1/mass:0;
+	m_bUpdateRtCst=true;
+}
+
+//
+btScalar		btSoftBody::getMass(int node) const
+{
+	return(m_nodes[node].m_im>0?1/m_nodes[node].m_im:0);
+}
+
+//
+btScalar		btSoftBody::getTotalMass() const
+{
+	btScalar	mass=0;
+	for(int i=0;i<m_nodes.size();++i)
+	{
+		mass+=getMass(i);
+	}
+	return(mass);
+}
+
+//
+void			btSoftBody::setTotalMass(btScalar mass,bool fromfaces)
+{
+	int i;
+
+	if(fromfaces)
+	{
+
+		for(i=0;i<m_nodes.size();++i)
+		{
+			m_nodes[i].m_im=0;
+		}
+		for(i=0;i<m_faces.size();++i)
+		{
+			const Face&		f=m_faces[i];
+			const btScalar	twicearea=AreaOf(	f.m_n[0]->m_x,
+												f.m_n[1]->m_x,
+												f.m_n[2]->m_x);
+			for(int j=0;j<3;++j)
+			{
+				f.m_n[j]->m_im+=twicearea;
+			}
+		}
+		for( i=0;i<m_nodes.size();++i)
+		{
+			m_nodes[i].m_im=1/m_nodes[i].m_im;
+		}
+	}
+	const btScalar	tm=getTotalMass();
+	const btScalar	itm=1/tm;
+	for( i=0;i<m_nodes.size();++i)
+	{
+		m_nodes[i].m_im/=itm*mass;
+	}
+	m_bUpdateRtCst=true;
+}
+
+//
+void			btSoftBody::setTotalDensity(btScalar density)
+{
+	setTotalMass(getVolume()*density,true);
+}
+
+//
+void			btSoftBody::transform(const btTransform& trs)
+{
+	const btScalar	margin=getCollisionShape()->getMargin();
+	for(int i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		Node&	n=m_nodes[i];
+		n.m_x=trs*n.m_x;
+		n.m_q=trs*n.m_q;
+		n.m_n=trs.getBasis()*n.m_n;
+		m_ndbvt.update(n.m_leaf,btDbvtVolume::FromCR(n.m_x,margin));
+	}
+	updateNormals();
+	updateBounds();
+	updateConstants();
+}
+
+//
+void			btSoftBody::translate(const btVector3& trs)
+{
+btTransform	t;
+t.setIdentity();
+t.setOrigin(trs);
+transform(t);
+}
+
+//
+void			btSoftBody::rotate(	const btQuaternion& rot)
+{
+btTransform	t;
+t.setIdentity();
+t.setRotation(rot);
+transform(t);
+}
+
+//
+void			btSoftBody::scale(const btVector3& scl)
+{
+	const btScalar	margin=getCollisionShape()->getMargin();
+	for(int i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		Node&	n=m_nodes[i];
+		n.m_x*=scl;
+		n.m_q*=scl;
+		m_ndbvt.update(n.m_leaf,btDbvtVolume::FromCR(n.m_x,margin));
+	}
+	updateNormals();
+	updateBounds();
+	updateConstants();
+}
+
+//
+void			btSoftBody::setPose(bool bvolume,bool bframe)
+{
+	m_pose.m_bvolume	=	bvolume;
+	m_pose.m_bframe		=	bframe;
+	int i,ni;
+
+	/* Weights		*/ 
+	const btScalar	omass=getTotalMass();
+	const btScalar	kmass=omass*m_nodes.size()*1000;
+	btScalar		tmass=omass;
+	m_pose.m_wgh.resize(m_nodes.size());
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		if(m_nodes[i].m_im<=0) tmass+=kmass;
+	}
+	for( i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		Node&	n=m_nodes[i];
+		m_pose.m_wgh[i]=	n.m_im>0					?
+							1/(m_nodes[i].m_im*tmass)	:
+							kmass/tmass;
+	}
+	/* Pos		*/ 
+	const btVector3	com=evaluateCom();
+	m_pose.m_pos.resize(m_nodes.size());
+	for( i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		m_pose.m_pos[i]=m_nodes[i].m_x-com;
+	}
+	m_pose.m_volume	=	bvolume?getVolume():0;
+	m_pose.m_com	=	com;
+	m_pose.m_rot.setIdentity();
+	m_pose.m_scl.setIdentity();
+	/* Aqq		*/ 
+	m_pose.m_aqq[0]	=
+	m_pose.m_aqq[1]	=
+	m_pose.m_aqq[2]	=	btVector3(0,0,0);
+	for( i=0,ni=m_nodes.size();i<ni;++i)
+		{
+		const btVector3&	q=m_pose.m_pos[i];
+		const btVector3		mq=m_pose.m_wgh[i]*q;
+		m_pose.m_aqq[0]+=mq.x()*q;
+		m_pose.m_aqq[1]+=mq.y()*q;
+		m_pose.m_aqq[2]+=mq.z()*q;
+		}
+	m_pose.m_aqq=m_pose.m_aqq.inverse();
+	updateConstants();
+}
+
+//
+btScalar		btSoftBody::getVolume() const
+{
+	btScalar	vol=0;
+	if(m_nodes.size()>0)
+	{
+		int i,ni;
+
+		const btVector3	org=m_nodes[0].m_x;
+		for(i=0,ni=m_faces.size();i<ni;++i)
+		{
+			const Face&	f=m_faces[i];
+			vol+=dot(f.m_n[0]->m_x-org,cross(f.m_n[1]->m_x-org,f.m_n[2]->m_x-org));
+		}
+		vol/=(btScalar)6;
+	}
+	return(vol);
+}
+
+//
+int				btSoftBody::clusterCount() const
+{
+return(m_clusters.size());
+}
+
+//
+btVector3		btSoftBody::clusterCom(const Cluster* cluster)
+{
+btVector3		com(0,0,0);
+for(int i=0,ni=cluster->m_nodes.size();i<ni;++i)
+	{
+	com+=cluster->m_nodes[i]->m_x*cluster->m_masses[i];
+	}
+return(com*cluster->m_imass);
+}
+
+//
+btVector3		btSoftBody::clusterCom(int cluster) const
+{
+return(clusterCom(m_clusters[cluster]));
+}
+
+//
+btVector3		btSoftBody::clusterVelocity(const Cluster* cluster,const btVector3& rpos)
+{
+return(cluster->m_lv+cross(cluster->m_av,rpos));
+}
+
+//
+void			btSoftBody::clusterVImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse)
+{
+const btVector3	li=cluster->m_imass*impulse;
+const btVector3	ai=cluster->m_invwi*cross(rpos,impulse);
+cluster->m_vimpulses[0]+=li;cluster->m_lv+=li;
+cluster->m_vimpulses[1]+=ai;cluster->m_av+=ai;
+cluster->m_nvimpulses++;
+}
+
+//
+void			btSoftBody::clusterDImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse)
+{
+const btVector3	li=cluster->m_imass*impulse;
+const btVector3	ai=cluster->m_invwi*cross(rpos,impulse);
+cluster->m_dimpulses[0]+=li;
+cluster->m_dimpulses[1]+=ai;
+cluster->m_ndimpulses++;
+}
+
+//
+void			btSoftBody::clusterImpulse(Cluster* cluster,const btVector3& rpos,const Impulse& impulse)
+{
+if(impulse.m_asVelocity)	clusterVImpulse(cluster,rpos,impulse.m_velocity);
+if(impulse.m_asDrift)		clusterDImpulse(cluster,rpos,impulse.m_drift);
+}
+
+//
+void			btSoftBody::clusterVAImpulse(Cluster* cluster,const btVector3& impulse)
+{
+const btVector3	ai=cluster->m_invwi*impulse;
+cluster->m_vimpulses[1]+=ai;cluster->m_av+=ai;
+cluster->m_nvimpulses++;
+}
+
+//
+void			btSoftBody::clusterDAImpulse(Cluster* cluster,const btVector3& impulse)
+{
+const btVector3	ai=cluster->m_invwi*impulse;
+cluster->m_dimpulses[1]+=ai;
+cluster->m_ndimpulses++;
+}
+
+//
+void			btSoftBody::clusterAImpulse(Cluster* cluster,const Impulse& impulse)
+{
+if(impulse.m_asVelocity)	clusterVAImpulse(cluster,impulse.m_velocity);
+if(impulse.m_asDrift)		clusterDAImpulse(cluster,impulse.m_drift);
+}
+
+//
+void			btSoftBody::clusterDCImpulse(Cluster* cluster,const btVector3& impulse)
+{
+cluster->m_dimpulses[0]+=impulse*cluster->m_imass;
+cluster->m_ndimpulses++;
+}
+
+//
+int				btSoftBody::generateBendingConstraints(int distance,Material* mat)
+{
+	int i,j;
+
+	if(distance>1)
+	{
+		/* Build graph	*/ 
+		const int		n=m_nodes.size();
+		const unsigned	inf=(~(unsigned)0)>>1;
+		unsigned*		adj=new unsigned[n*n];
+#define IDX(_x_,_y_)	((_y_)*n+(_x_))
+		for(j=0;j<n;++j)
+		{
+			for(i=0;i<n;++i)
+			{
+				if(i!=j)	adj[IDX(i,j)]=adj[IDX(j,i)]=inf;
+				else
+					adj[IDX(i,j)]=adj[IDX(j,i)]=0;
+			}
+		}
+		for( i=0;i<m_links.size();++i)
+		{
+			const int	ia=(int)(m_links[i].m_n[0]-&m_nodes[0]);
+			const int	ib=(int)(m_links[i].m_n[1]-&m_nodes[0]);
+			adj[IDX(ia,ib)]=1;
+			adj[IDX(ib,ia)]=1;
+		}
+		for(int k=0;k<n;++k)
+		{
+			for(j=0;j<n;++j)
+			{
+				for(i=j+1;i<n;++i)
+				{
+					const unsigned	sum=adj[IDX(i,k)]+adj[IDX(k,j)];
+					if(adj[IDX(i,j)]>sum)
+					{
+						adj[IDX(i,j)]=adj[IDX(j,i)]=sum;
+					}
+				}
+			}
+		}
+		/* Build links	*/ 
+		int	nlinks=0;
+		for(j=0;j<n;++j)
+		{
+			for(i=j+1;i<n;++i)
+			{
+				if(adj[IDX(i,j)]==(unsigned)distance)
+				{
+					appendLink(i,j,mat);
+					m_links[m_links.size()-1].m_bbending=1;
+					++nlinks;
+				}
+			}
+		}
+		delete[] adj;		
+		return(nlinks);
+	}
+	return(0);
+}
+
+//
+void			btSoftBody::randomizeConstraints()
+{
+unsigned long	seed=243703;
+#define NEXTRAND (seed=(1664525L*seed+1013904223L)&0xffffffff)
+int i,ni;
+
+	for(i=0,ni=m_links.size();i<ni;++i)
+	{
+		btSwap(m_links[i],m_links[NEXTRAND%ni]);
+	}
+	for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+		btSwap(m_faces[i],m_faces[NEXTRAND%ni]);
+	}
+#undef NEXTRAND
+}
+
+//
+void			btSoftBody::releaseCluster(int index)
+{
+Cluster*	c=m_clusters[index];
+if(c->m_leaf) m_cdbvt.remove(c->m_leaf);
+c->~Cluster();
+btAlignedFree(c);
+m_clusters.remove(c);
+}
+
+//
+void			btSoftBody::releaseClusters()
+{
+while(m_clusters.size()>0) releaseCluster(0);
+}
+
+//
+int				btSoftBody::generateClusters(int k,int maxiterations)
+{
+int i;
+releaseClusters();
+m_clusters.resize(btMin(k,m_nodes.size()));
+for(i=0;i<m_clusters.size();++i)
+	{
+	m_clusters[i]			=	new(btAlignedAlloc(sizeof(Cluster),16)) Cluster();
+	m_clusters[i]->m_collide=	true;
+	}
+k=m_clusters.size();
+if(k>0)
+	{
+	/* Initialize		*/ 
+	btAlignedObjectArray<btVector3>	centers;
+	btVector3						cog(0,0,0);
+	int								i;
+	for(i=0;i<m_nodes.size();++i)
+		{
+		cog+=m_nodes[i].m_x;
+		m_clusters[(i*29873)%m_clusters.size()]->m_nodes.push_back(&m_nodes[i]);
+		}
+	cog/=(btScalar)m_nodes.size();
+	centers.resize(k,cog);
+	/* Iterate			*/ 
+	const btScalar	slope=16;
+	bool			changed;
+	int				iterations=0;
+	do	{
+		const btScalar	w=2-btMin<btScalar>(1,iterations/slope);
+		changed=false;
+		iterations++;	
+		int i;
+
+		for(i=0;i<k;++i)
+			{
+			btVector3	c(0,0,0);
+			for(int j=0;j<m_clusters[i]->m_nodes.size();++j)
+				{
+				c+=m_clusters[i]->m_nodes[j]->m_x;
+				}
+			if(m_clusters[i]->m_nodes.size())
+				{
+				c			/=	(btScalar)m_clusters[i]->m_nodes.size();
+				c			=	centers[i]+(c-centers[i])*w;
+				changed		|=	((c-centers[i]).length2()>SIMD_EPSILON);
+				centers[i]	=	c;
+				m_clusters[i]->m_nodes.resize(0);
+				}			
+			}
+		for(i=0;i<m_nodes.size();++i)
+			{
+			const btVector3	nx=m_nodes[i].m_x;
+			int				kbest=0;
+			btScalar		kdist=ClusterMetric(centers[0],nx);
+			for(int j=1;j<k;++j)
+				{
+				const btScalar	d=ClusterMetric(centers[j],nx);
+				if(d<kdist)
+					{
+					kbest=j;
+					kdist=d;
+					}
+				}
+			m_clusters[kbest]->m_nodes.push_back(&m_nodes[i]);
+			}		
+		} while(changed&&(iterations<maxiterations));
+	/* Merge		*/ 
+	btAlignedObjectArray<int>	cids;
+	cids.resize(m_nodes.size(),-1);
+	for(i=0;i<m_clusters.size();++i)
+		{
+		for(int j=0;j<m_clusters[i]->m_nodes.size();++j)
+			{
+			cids[int(m_clusters[i]->m_nodes[j]-&m_nodes[0])]=i;
+			}
+		}
+	for(i=0;i<m_faces.size();++i)
+		{
+		const int idx[]={	int(m_faces[i].m_n[0]-&m_nodes[0]),
+							int(m_faces[i].m_n[1]-&m_nodes[0]),
+							int(m_faces[i].m_n[2]-&m_nodes[0])};
+		for(int j=0;j<3;++j)
+			{
+			const int cid=cids[idx[j]];
+			for(int q=1;q<3;++q)
+				{
+				const int kid=idx[(j+q)%3];
+				if(cids[kid]!=cid)
+					{
+					if(m_clusters[cid]->m_nodes.findLinearSearch(&m_nodes[kid])==m_clusters[cid]->m_nodes.size())
+						{
+						m_clusters[cid]->m_nodes.push_back(&m_nodes[kid]);
+						}
+					}
+				}
+			}
+		}
+	/* Master		*/ 
+	if(m_clusters.size()>1)
+		{
+		Cluster*	pmaster=new(btAlignedAlloc(sizeof(Cluster),16)) Cluster();
+		pmaster->m_collide	=	false;
+		pmaster->m_nodes.reserve(m_nodes.size());
+		for(int i=0;i<m_nodes.size();++i) pmaster->m_nodes.push_back(&m_nodes[i]);
+		m_clusters.push_back(pmaster);
+		btSwap(m_clusters[0],m_clusters[m_clusters.size()-1]);
+		}
+	/* Terminate	*/ 
+	for(i=0;i<m_clusters.size();++i)
+		{
+		if(m_clusters[i]->m_nodes.size()==0)
+			{
+			releaseCluster(i--);
+			}
+		}
+		
+	initializeClusters();
+	updateClusters();
+	return(m_clusters.size());
+	}
+return(0);
+}
+
+//
+void			btSoftBody::refine(ImplicitFn* ifn,btScalar accurary,bool cut)
+{
+const Node*			nbase = &m_nodes[0];
+int					ncount = m_nodes.size();
+btSymMatrix<int>	edges(ncount,-2);
+int					newnodes=0;
+int i,j,k,ni;
+
+/* Filter out		*/ 
+for(i=0;i<m_links.size();++i)
+	{
+	Link&	l=m_links[i];
+	if(l.m_bbending)
+		{
+		if(!SameSign(ifn->Eval(l.m_n[0]->m_x),ifn->Eval(l.m_n[1]->m_x)))
+			{
+			btSwap(m_links[i],m_links[m_links.size()-1]);
+			m_links.pop_back();--i;
+			}
+		}	
+	}
+/* Fill edges		*/ 
+for(i=0;i<m_links.size();++i)
+	{
+	Link&	l=m_links[i];
+	edges(int(l.m_n[0]-nbase),int(l.m_n[1]-nbase))=-1;
+	}
+for(i=0;i<m_faces.size();++i)
+	{	
+	Face&	f=m_faces[i];
+	edges(int(f.m_n[0]-nbase),int(f.m_n[1]-nbase))=-1;
+	edges(int(f.m_n[1]-nbase),int(f.m_n[2]-nbase))=-1;
+	edges(int(f.m_n[2]-nbase),int(f.m_n[0]-nbase))=-1;
+	}
+/* Intersect		*/ 
+for(i=0;i<ncount;++i)
+	{
+	for(j=i+1;j<ncount;++j)
+		{
+		if(edges(i,j)==-1)
+			{
+			Node&			a=m_nodes[i];
+			Node&			b=m_nodes[j];
+			const btScalar	t=ImplicitSolve(ifn,a.m_x,b.m_x,accurary);
+			if(t>0)
+				{
+				const btVector3	x=Lerp(a.m_x,b.m_x,t);
+				const btVector3	v=Lerp(a.m_v,b.m_v,t);
+				btScalar		m=0;
+				if(a.m_im>0)
+					{
+					if(b.m_im>0)
+						{
+						const btScalar	ma=1/a.m_im;
+						const btScalar	mb=1/b.m_im;
+						const btScalar	mc=Lerp(ma,mb,t);
+						const btScalar	f=(ma+mb)/(ma+mb+mc);
+						a.m_im=1/(ma*f);
+						b.m_im=1/(mb*f);
+						m=mc*f;
+						}
+						else
+						{ a.m_im/=0.5;m=1/a.m_im; }
+					}
+					else
+					{
+					if(b.m_im>0)
+						{ b.m_im/=0.5;m=1/b.m_im; }
+						else
+						m=0;
+					}
+				appendNode(x,m);
+				edges(i,j)=m_nodes.size()-1;
+				m_nodes[edges(i,j)].m_v=v;
+				++newnodes;
+				}
+			}
+		}
+	}
+nbase=&m_nodes[0];
+/* Refine links		*/ 
+for(i=0,ni=m_links.size();i<ni;++i)
+	{
+	Link&		feat=m_links[i];
+	const int	idx[]={	int(feat.m_n[0]-nbase),
+						int(feat.m_n[1]-nbase)};
+	if((idx[0]<ncount)&&(idx[1]<ncount))
+		{
+		const int ni=edges(idx[0],idx[1]);
+		if(ni>0)
+			{
+			appendLink(i);
+			Link*		pft[]={	&m_links[i],
+								&m_links[m_links.size()-1]};			
+			pft[0]->m_n[0]=&m_nodes[idx[0]];
+			pft[0]->m_n[1]=&m_nodes[ni];
+			pft[1]->m_n[0]=&m_nodes[ni];
+			pft[1]->m_n[1]=&m_nodes[idx[1]];
+			}
+		}
+	}
+/* Refine faces		*/ 
+for(i=0;i<m_faces.size();++i)
+	{
+	const Face&	feat=m_faces[i];
+	const int	idx[]={	int(feat.m_n[0]-nbase),
+						int(feat.m_n[1]-nbase),
+						int(feat.m_n[2]-nbase)};
+	for(j=2,k=0;k<3;j=k++)
+		{
+		if((idx[j]<ncount)&&(idx[k]<ncount))
+			{
+			const int ni=edges(idx[j],idx[k]);
+			if(ni>0)
+				{
+				appendFace(i);
+				const int	l=(k+1)%3;
+				Face*		pft[]={	&m_faces[i],
+									&m_faces[m_faces.size()-1]};
+				pft[0]->m_n[0]=&m_nodes[idx[l]];
+				pft[0]->m_n[1]=&m_nodes[idx[j]];
+				pft[0]->m_n[2]=&m_nodes[ni];
+				pft[1]->m_n[0]=&m_nodes[ni];
+				pft[1]->m_n[1]=&m_nodes[idx[k]];
+				pft[1]->m_n[2]=&m_nodes[idx[l]];
+				appendLink(ni,idx[l],pft[0]->m_material);
+				--i;break;
+				}
+			}
+		}
+	}
+/* Cut				*/ 
+if(cut)
+	{	
+	btAlignedObjectArray<int>	cnodes;
+	const int					pcount=ncount;
+	int							i;
+	ncount=m_nodes.size();
+	cnodes.resize(ncount,0);
+	/* Nodes		*/ 
+	for(i=0;i<ncount;++i)
+		{
+		const btVector3	x=m_nodes[i].m_x;
+		if((i>=pcount)||(btFabs(ifn->Eval(x))<accurary))
+			{
+			const btVector3	v=m_nodes[i].m_v;
+			btScalar		m=getMass(i);
+			if(m>0) { m*=0.5;m_nodes[i].m_im/=0.5; }
+			appendNode(x,m);
+			cnodes[i]=m_nodes.size()-1;
+			m_nodes[cnodes[i]].m_v=v;
+			}
+		}
+	nbase=&m_nodes[0];
+	/* Links		*/ 
+	for(i=0,ni=m_links.size();i<ni;++i)
+		{
+		const int		id[]={	int(m_links[i].m_n[0]-nbase),
+								int(m_links[i].m_n[1]-nbase)};
+		int				todetach=0;
+		if(cnodes[id[0]]&&cnodes[id[1]])
+			{
+			appendLink(i);
+			todetach=m_links.size()-1;
+			}
+		else
+			{
+			if((	(ifn->Eval(m_nodes[id[0]].m_x)<accurary)&&
+					(ifn->Eval(m_nodes[id[1]].m_x)<accurary)))
+				todetach=i;
+			}
+		if(todetach)
+			{
+			Link&	l=m_links[todetach];
+			for(int j=0;j<2;++j)
+				{
+				int cn=cnodes[int(l.m_n[j]-nbase)];
+				if(cn) l.m_n[j]=&m_nodes[cn];
+				}			
+			}
+		}
+	/* Faces		*/ 
+	for(i=0,ni=m_faces.size();i<ni;++i)
+		{
+		Node**			n=	m_faces[i].m_n;
+		if(	(ifn->Eval(n[0]->m_x)<accurary)&&
+			(ifn->Eval(n[1]->m_x)<accurary)&&
+			(ifn->Eval(n[2]->m_x)<accurary))
+			{
+			for(int j=0;j<3;++j)
+				{
+				int cn=cnodes[int(n[j]-nbase)];
+				if(cn) n[j]=&m_nodes[cn];
+				}
+			}
+		}
+	/* Clean orphans	*/ 
+	int							nnodes=m_nodes.size();
+	btAlignedObjectArray<int>	ranks;
+	btAlignedObjectArray<int>	todelete;
+	ranks.resize(nnodes,0);
+	for(i=0,ni=m_links.size();i<ni;++i)
+		{
+		for(int j=0;j<2;++j) ranks[int(m_links[i].m_n[j]-nbase)]++;
+		}
+	for(i=0,ni=m_faces.size();i<ni;++i)
+		{
+		for(int j=0;j<3;++j) ranks[int(m_faces[i].m_n[j]-nbase)]++;
+		}
+	for(i=0;i<m_links.size();++i)
+		{
+		const int	id[]={	int(m_links[i].m_n[0]-nbase),
+							int(m_links[i].m_n[1]-nbase)};
+		const bool	sg[]={	ranks[id[0]]==1,
+							ranks[id[1]]==1};
+		if(sg[0]||sg[1])
+			{
+			--ranks[id[0]];
+			--ranks[id[1]];
+			btSwap(m_links[i],m_links[m_links.size()-1]);
+			m_links.pop_back();--i;
+			}
+		}
+	#if 0	
+	for(i=nnodes-1;i>=0;--i)
+		{
+		if(!ranks[i]) todelete.push_back(i);
+		}	
+	if(todelete.size())
+		{		
+		btAlignedObjectArray<int>&	map=ranks;
+		for(int i=0;i<nnodes;++i) map[i]=i;
+		PointersToIndices(this);
+		for(int i=0,ni=todelete.size();i<ni;++i)
+			{
+			int		j=todelete[i];
+			int&	a=map[j];
+			int&	b=map[--nnodes];
+			m_ndbvt.remove(m_nodes[a].m_leaf);m_nodes[a].m_leaf=0;
+			btSwap(m_nodes[a],m_nodes[b]);
+			j=a;a=b;b=j;			
+			}
+		IndicesToPointers(this,&map[0]);
+		m_nodes.resize(nnodes);
+		}
+	#endif
+	}
+m_bUpdateRtCst=true;
+}
+
+//
+bool			btSoftBody::cutLink(const Node* node0,const Node* node1,btScalar position)
+{
+return(cutLink(int(node0-&m_nodes[0]),int(node1-&m_nodes[0]),position));
+}
+
+//
+bool			btSoftBody::cutLink(int node0,int node1,btScalar position)
+{
+bool			done=false;
+int i,ni;
+const btVector3	d=m_nodes[node0].m_x-m_nodes[node1].m_x;
+const btVector3	x=Lerp(m_nodes[node0].m_x,m_nodes[node1].m_x,position);
+const btVector3	v=Lerp(m_nodes[node0].m_v,m_nodes[node1].m_v,position);
+const btScalar	m=1;
+appendNode(x,m);
+appendNode(x,m);
+Node*			pa=&m_nodes[node0];
+Node*			pb=&m_nodes[node1];
+Node*			pn[2]={	&m_nodes[m_nodes.size()-2],
+						&m_nodes[m_nodes.size()-1]};
+pn[0]->m_v=v;
+pn[1]->m_v=v;
+for(i=0,ni=m_links.size();i<ni;++i)
+	{
+	const int mtch=MatchEdge(m_links[i].m_n[0],m_links[i].m_n[1],pa,pb);
+	if(mtch!=-1)
+		{
+		appendLink(i);
+		Link*	pft[]={&m_links[i],&m_links[m_links.size()-1]};
+		pft[0]->m_n[1]=pn[mtch];
+		pft[1]->m_n[0]=pn[1-mtch];
+		done=true;
+		}
+	}
+for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+	for(int k=2,l=0;l<3;k=l++)
+		{
+		const int mtch=MatchEdge(m_faces[i].m_n[k],m_faces[i].m_n[l],pa,pb);
+		if(mtch!=-1)
+			{
+			appendFace(i);
+			Face*	pft[]={&m_faces[i],&m_faces[m_faces.size()-1]};
+			pft[0]->m_n[l]=pn[mtch];
+			pft[1]->m_n[k]=pn[1-mtch];
+			appendLink(pn[0],pft[0]->m_n[(l+1)%3],pft[0]->m_material,true);
+			appendLink(pn[1],pft[0]->m_n[(l+1)%3],pft[0]->m_material,true);
+			}
+		}
+	}
+if(!done)
+	{
+	m_ndbvt.remove(pn[0]->m_leaf);
+	m_ndbvt.remove(pn[1]->m_leaf);
+	m_nodes.pop_back();
+	m_nodes.pop_back();
+	}
+return(done);
+}
+
+//
+bool			btSoftBody::rayCast(const btVector3& org,
+									const btVector3& dir,
+									sRayCast& results,
+									btScalar maxtime)
+{
+if(m_faces.size()&&m_fdbvt.empty()) initializeFaceTree();
+results.body	=	this;
+results.time	=	maxtime;
+results.feature	=	eFeature::None;
+results.index	=	-1;
+return(rayCast(org,dir,results.time,results.feature,results.index,false)!=0);
+}
+
+//
+void			btSoftBody::setSolver(eSolverPresets::_ preset)
+{
+m_cfg.m_vsequence.clear();
+m_cfg.m_psequence.clear();
+m_cfg.m_dsequence.clear();
+switch(preset)
+	{
+	case	eSolverPresets::Positions:
+	m_cfg.m_psequence.push_back(ePSolver::Anchors);
+	m_cfg.m_psequence.push_back(ePSolver::RContacts);
+	m_cfg.m_psequence.push_back(ePSolver::SContacts);
+	m_cfg.m_psequence.push_back(ePSolver::Linear);	
+	break;	
+	case	eSolverPresets::Velocities:
+	m_cfg.m_vsequence.push_back(eVSolver::Linear);
+	
+	m_cfg.m_psequence.push_back(ePSolver::Anchors);
+	m_cfg.m_psequence.push_back(ePSolver::RContacts);
+	m_cfg.m_psequence.push_back(ePSolver::SContacts);
+	
+	m_cfg.m_dsequence.push_back(ePSolver::Linear);
+	break;
+	}
+}
+
+//
+void			btSoftBody::predictMotion(btScalar dt)
+{
+	int i,ni;
+
+	/* Update				*/ 
+	if(m_bUpdateRtCst)
+	{
+		m_bUpdateRtCst=false;
+		updateConstants();
+		m_fdbvt.clear();
+		if(m_cfg.collisions&fCollision::VF_SS)
+			{
+			initializeFaceTree();			
+			}
+	}
+		
+	/* Prepare				*/ 
+	m_sst.sdt		=	dt*m_cfg.timescale;
+	m_sst.isdt		=	1/m_sst.sdt;
+	m_sst.velmrg	=	m_sst.sdt*3;
+	m_sst.radmrg	=	getCollisionShape()->getMargin();
+	m_sst.updmrg	=	m_sst.radmrg*(btScalar)0.25;
+	/* Forces				*/ 
+	addVelocity(m_worldInfo->m_gravity*m_sst.sdt);
+	applyForces();
+	/* Integrate			*/ 
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		Node&	n=m_nodes[i];
+		n.m_q	=	n.m_x;
+		n.m_v	+=	n.m_f*n.m_im*m_sst.sdt;
+		n.m_x	+=	n.m_v*m_sst.sdt;
+		n.m_f	=	btVector3(0,0,0);
+	}
+	/* Clusters				*/ 
+	updateClusters();
+	/* Bounds				*/ 
+	updateBounds();	
+	/* Nodes				*/ 
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		Node&	n=m_nodes[i];
+		m_ndbvt.update(	n.m_leaf,
+						btDbvtVolume::FromCR(n.m_x,m_sst.radmrg),
+						n.m_v*m_sst.velmrg,
+						m_sst.updmrg);
+	}
+	/* Faces				*/ 
+	if(!m_fdbvt.empty())
+		{
+		for(int i=0;i<m_faces.size();++i)
+			{
+			Face&			f=m_faces[i];
+			const btVector3	v=(	f.m_n[0]->m_v+
+								f.m_n[1]->m_v+
+								f.m_n[2]->m_v)/3;
+			m_fdbvt.update(	f.m_leaf,
+							VolumeOf(f,m_sst.radmrg),
+							v*m_sst.velmrg,
+							m_sst.updmrg);
+			}
+		}
+	/* Pose					*/ 
+	updatePose();
+	/* Match				*/ 
+	if(m_pose.m_bframe&&(m_cfg.kMT>0))
+		{
+		const btMatrix3x3	posetrs=m_pose.m_rot;
+		for(int i=0,ni=m_nodes.size();i<ni;++i)
+			{
+			Node&	n=m_nodes[i];
+			if(n.m_im>0)
+				{
+				const btVector3	x=posetrs*m_pose.m_pos[i]+m_pose.m_com;
+				n.m_x=Lerp(n.m_x,x,m_cfg.kMT);
+				}
+			}
+		}
+	/* Clear contacts		*/ 
+	m_rcontacts.resize(0);
+	m_scontacts.resize(0);
+	/* Optimize dbvt's		*/ 
+	m_ndbvt.optimizeIncremental(1);
+	m_fdbvt.optimizeIncremental(1);
+	m_cdbvt.optimizeIncremental(1);
+}
+
+//
+void			btSoftBody::solveConstraints()
+{
+/* Apply clusters		*/ 
+applyClusters(false);
+/* Prepare links		*/ 
+
+int i,ni;
+
+for(i=0,ni=m_links.size();i<ni;++i)
+	{
+	Link&	l=m_links[i];
+	l.m_c3		=	l.m_n[1]->m_q-l.m_n[0]->m_q;
+	l.m_c2		=	1/(l.m_c3.length2()*l.m_c0);
+	}
+/* Prepare anchors		*/ 
+for(i=0,ni=m_anchors.size();i<ni;++i)
+	{
+	Anchor&			a=m_anchors[i];
+	const btVector3	ra=a.m_body->getWorldTransform().getBasis()*a.m_local;
+	a.m_c0	=	ImpulseMatrix(	m_sst.sdt,
+								a.m_node->m_im,
+								a.m_body->getInvMass(),
+								a.m_body->getInvInertiaTensorWorld(),
+								ra);
+	a.m_c1	=	ra;
+	a.m_c2	=	m_sst.sdt*a.m_node->m_im;
+	a.m_body->activate();
+	}
+/* Solve velocities		*/ 
+if(m_cfg.viterations>0)
+	{
+	/* Solve			*/ 
+	for(int isolve=0;isolve<m_cfg.viterations;++isolve)
+		{
+		for(int iseq=0;iseq<m_cfg.m_vsequence.size();++iseq)
+			{
+			getSolver(m_cfg.m_vsequence[iseq])(this,1);
+			}
+		}
+	/* Update			*/ 
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+		{
+		Node&	n=m_nodes[i];
+		n.m_x	=	n.m_q+n.m_v*m_sst.sdt;
+		}
+	}
+/* Solve positions		*/ 
+if(m_cfg.piterations>0)
+	{
+	for(int isolve=0;isolve<m_cfg.piterations;++isolve)
+		{
+		const btScalar ti=isolve/(btScalar)m_cfg.piterations;
+		for(int iseq=0;iseq<m_cfg.m_psequence.size();++iseq)
+			{
+			getSolver(m_cfg.m_psequence[iseq])(this,1,ti);
+			}
+		}
+	const btScalar	vc=m_sst.isdt*(1-m_cfg.kDP);
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+		{
+		Node&	n=m_nodes[i];
+		n.m_v	=	(n.m_x-n.m_q)*vc;
+		n.m_f	=	btVector3(0,0,0);		
+		}
+	}
+/* Solve drift			*/ 
+if(m_cfg.diterations>0)
+	{
+	const btScalar	vcf=m_cfg.kVCF*m_sst.isdt;
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+		{
+		Node&	n=m_nodes[i];
+		n.m_q	=	n.m_x;
+		}
+	for(int idrift=0;idrift<m_cfg.diterations;++idrift)
+		{
+		for(int iseq=0;iseq<m_cfg.m_dsequence.size();++iseq)
+			{
+			getSolver(m_cfg.m_dsequence[iseq])(this,1,0);
+			}
+		}
+	for(int i=0,ni=m_nodes.size();i<ni;++i)
+		{
+		Node&	n=m_nodes[i];
+		n.m_v	+=	(n.m_x-n.m_q)*vcf;
+		}
+	}
+/* Apply clusters		*/ 
+dampClusters();
+applyClusters(true);
+}
+
+//
+void			btSoftBody::staticSolve(int iterations)
+{
+for(int isolve=0;isolve<iterations;++isolve)
+	{
+	for(int iseq=0;iseq<m_cfg.m_psequence.size();++iseq)
+		{
+		getSolver(m_cfg.m_psequence[iseq])(this,1,0);
+		}
+	}
+}
+
+//
+void			btSoftBody::solveCommonConstraints(btSoftBody** /*bodies*/,int /*count*/,int /*iterations*/)
+{
+/// placeholder
+}
+
+//
+void			btSoftBody::solveClusters(const btAlignedObjectArray<btSoftBody*>& bodies)
+{
+const int	nb=bodies.size();
+int			iterations=0;
+int i;
+
+for(i=0;i<nb;++i)
+	{
+	iterations=btMax(iterations,bodies[i]->m_cfg.citerations);
+	}
+for(i=0;i<nb;++i)
+	{
+	bodies[i]->prepareClusters(iterations);
+	}
+for(i=0;i<iterations;++i)
+	{
+	const btScalar sor=1;
+	for(int j=0;j<nb;++j)
+		{
+		bodies[j]->solveClusters(sor);
+		}
+	}
+for(i=0;i<nb;++i)
+	{
+	bodies[i]->cleanupClusters();
+	}
+}
+
+//
+void			btSoftBody::integrateMotion()
+{
+	/* Update			*/ 
+	updateNormals();
+}
+
+//
+					btSoftBody::RayCaster::RayCaster(const btVector3& org,const btVector3& dir,btScalar mxt)
+{
+o		=	org;
+d		=	dir;
+mint	=	mxt;
+face	=	0;
+tests	=	0;
+}
+
+//
+void				btSoftBody::RayCaster::Process(const btDbvtNode* leaf)
+{
+btSoftBody::Face&	f=*(btSoftBody::Face*)leaf->data;
+const btScalar		t=rayTriangle(	o,d,
+									f.m_n[0]->m_x,
+									f.m_n[1]->m_x,
+									f.m_n[2]->m_x,
+									mint);
+if((t>0)&&(t<mint)) { mint=t;face=&f; }
+++tests;
+}
+
+//
+btScalar			btSoftBody::RayCaster::rayTriangle(	const btVector3& org,
+														const btVector3& dir,
+														const btVector3& a,
+														const btVector3& b,
+														const btVector3& c,
+														btScalar maxt)
+{
+	static const btScalar	ceps=-SIMD_EPSILON*10;
+	static const btScalar	teps=SIMD_EPSILON*10;
+	const btVector3			n=cross(b-a,c-a);
+	const btScalar			d=dot(a,n);
+	const btScalar			den=dot(dir,n);
+	if(!btFuzzyZero(den))
+	{
+		const btScalar		num=dot(org,n)-d;
+		const btScalar		t=-num/den;
+		if((t>teps)&&(t<maxt))
+		{
+			const btVector3	hit=org+dir*t;
+			if(	(dot(n,cross(a-hit,b-hit))>ceps)	&&			
+				(dot(n,cross(b-hit,c-hit))>ceps)	&&
+				(dot(n,cross(c-hit,a-hit))>ceps))
+			{
+				return(t);
+			}
+		}
+	}
+	return(-1);
+}
+
+//
+void				btSoftBody::pointersToIndices()
+{
+#define	PTR2IDX(_p_,_b_)	reinterpret_cast<btSoftBody::Node*>((_p_)-(_b_))
+	btSoftBody::Node*	base=&m_nodes[0];
+	int i,ni;
+
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		if(m_nodes[i].m_leaf)
+			{
+			m_nodes[i].m_leaf->data=*(void**)&i;
+			}
+	}
+	for(i=0,ni=m_links.size();i<ni;++i)
+	{
+		m_links[i].m_n[0]=PTR2IDX(m_links[i].m_n[0],base);
+		m_links[i].m_n[1]=PTR2IDX(m_links[i].m_n[1],base);
+	}
+	for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+		m_faces[i].m_n[0]=PTR2IDX(m_faces[i].m_n[0],base);
+		m_faces[i].m_n[1]=PTR2IDX(m_faces[i].m_n[1],base);
+		m_faces[i].m_n[2]=PTR2IDX(m_faces[i].m_n[2],base);
+		if(m_faces[i].m_leaf)
+			{
+			m_faces[i].m_leaf->data=*(void**)&i;
+			}
+	}
+	for(i=0,ni=m_anchors.size();i<ni;++i)
+		{
+		m_anchors[i].m_node=PTR2IDX(m_anchors[i].m_node,base);
+		}
+	for(i=0,ni=m_notes.size();i<ni;++i)
+		{
+		for(int j=0;j<m_notes[i].m_rank;++j)
+			{
+			m_notes[i].m_nodes[j]=PTR2IDX(m_notes[i].m_nodes[j],base);
+			}
+		}
+#undef	PTR2IDX
+}
+
+//
+void				btSoftBody::indicesToPointers(const int* map)
+{
+#define	IDX2PTR(_p_,_b_)	map?(&(_b_)[map[(((char*)_p_)-(char*)0)]]):	\
+								(&(_b_)[(((char*)_p_)-(char*)0)])
+	btSoftBody::Node*	base=&m_nodes[0];
+	int i,ni;
+
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		if(m_nodes[i].m_leaf)
+			{
+			m_nodes[i].m_leaf->data=&m_nodes[i];
+			}
+	}
+	for(i=0,ni=m_links.size();i<ni;++i)
+	{
+		m_links[i].m_n[0]=IDX2PTR(m_links[i].m_n[0],base);
+		m_links[i].m_n[1]=IDX2PTR(m_links[i].m_n[1],base);
+	}
+	for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+		m_faces[i].m_n[0]=IDX2PTR(m_faces[i].m_n[0],base);
+		m_faces[i].m_n[1]=IDX2PTR(m_faces[i].m_n[1],base);
+		m_faces[i].m_n[2]=IDX2PTR(m_faces[i].m_n[2],base);
+		if(m_faces[i].m_leaf)
+			{
+			m_faces[i].m_leaf->data=&m_faces[i];
+			}
+	}
+	for(i=0,ni=m_anchors.size();i<ni;++i)
+		{
+		m_anchors[i].m_node=IDX2PTR(m_anchors[i].m_node,base);
+		}
+	for(i=0,ni=m_notes.size();i<ni;++i)
+		{
+		for(int j=0;j<m_notes[i].m_rank;++j)
+			{
+			m_notes[i].m_nodes[j]=IDX2PTR(m_notes[i].m_nodes[j],base);
+			}
+		}
+#undef	IDX2PTR
+}
+
+//
+int					btSoftBody::rayCast(const btVector3& org,const btVector3& dir,
+										btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const
+{
+	int	cnt=0;
+	if(bcountonly||m_fdbvt.empty())
+		{/* Full search	*/ 
+		for(int i=0,ni=m_faces.size();i<ni;++i)
+			{
+			const btSoftBody::Face&	f=m_faces[i];
+			const btScalar			t=RayCaster::rayTriangle(	org,dir,
+																f.m_n[0]->m_x,
+																f.m_n[1]->m_x,
+																f.m_n[2]->m_x,
+																mint);
+			if(t>0)
+				{
+				++cnt;
+				if(!bcountonly)
+					{
+					feature=btSoftBody::eFeature::Face;
+					index=i;
+					mint=t;
+					}
+				}
+			}
+		}
+		else
+		{/* Use dbvt	*/ 
+		RayCaster	collider(org,dir,mint);
+		btDbvt::collideRAY(m_fdbvt.m_root,org,dir,collider);
+		if(collider.face)
+			{
+			mint=collider.mint;
+			feature=btSoftBody::eFeature::Face;
+			index=(int)(collider.face-&m_faces[0]);
+			cnt=1;
+			}
+		}
+	return(cnt);
+}
+
+//
+void			btSoftBody::initializeFaceTree()
+{
+m_fdbvt.clear();
+for(int i=0;i<m_faces.size();++i)
+	{
+	Face&	f=m_faces[i];
+	f.m_leaf=m_fdbvt.insert(VolumeOf(f,0),&f);
+	}
+}
+
+//
+btVector3		btSoftBody::evaluateCom() const
+{
+btVector3	com(0,0,0);
+if(m_pose.m_bframe)
+	{
+	for(int i=0,ni=m_nodes.size();i<ni;++i)
+		{
+		com+=m_nodes[i].m_x*m_pose.m_wgh[i];
+		}
+	}
+	return(com);
+}
+	
+//
+bool				btSoftBody::checkContact(	btRigidBody* prb,
+												const btVector3& x,
+												btScalar margin,
+												btSoftBody::sCti& cti) const
+{
+	btVector3			nrm;
+	btCollisionShape*	shp=prb->getCollisionShape();
+	const btTransform&	wtr=prb->getInterpolationWorldTransform();
+	btScalar			dst=m_worldInfo->m_sparsesdf.Evaluate(	wtr.invXform(x),
+																shp,
+																nrm,
+																margin);
+	if(dst<0)
+	{
+		cti.m_body		=	prb;
+		cti.m_normal	=	wtr.getBasis()*nrm;
+		cti.m_offset	=	-dot(	cti.m_normal,
+									x-cti.m_normal*dst);
+		return(true);
+	}
+	return(false);
+}
+
+//
+void					btSoftBody::updateNormals()
+{
+	const btVector3	zv(0,0,0);
+	int i,ni;
+
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		m_nodes[i].m_n=zv;
+	}
+	for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+		btSoftBody::Face&	f=m_faces[i];
+		const btVector3		n=cross(f.m_n[1]->m_x-f.m_n[0]->m_x,
+									f.m_n[2]->m_x-f.m_n[0]->m_x);
+		f.m_normal=n.normalized();
+		f.m_n[0]->m_n+=n;
+		f.m_n[1]->m_n+=n;
+		f.m_n[2]->m_n+=n;
+	}
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		btScalar len = m_nodes[i].m_n.length();
+		if (len>SIMD_EPSILON)
+			m_nodes[i].m_n /= len;
+	}
+}
+
+//
+void					btSoftBody::updateBounds()
+{
+	if(m_ndbvt.m_root)
+		{
+		const btVector3&	mins=m_ndbvt.m_root->volume.Mins();
+		const btVector3&	maxs=m_ndbvt.m_root->volume.Maxs();
+		const btScalar		csm=getCollisionShape()->getMargin();
+		const btVector3		mrg=btVector3(	csm,
+											csm,
+											csm)*1; // ??? to investigate...
+		m_bounds[0]=mins-mrg;
+		m_bounds[1]=maxs+mrg;
+			if(0!=getBroadphaseHandle())
+			{					
+				m_worldInfo->m_broadphase->setAabb(	getBroadphaseHandle(),
+													m_bounds[0],
+													m_bounds[1],
+													m_worldInfo->m_dispatcher);
+			}
+		}
+		else
+		{
+		m_bounds[0]=
+		m_bounds[1]=btVector3(0,0,0);
+		}		
+}
+
+
+//
+void					btSoftBody::updatePose()
+{
+	if(m_pose.m_bframe)
+	{
+		btSoftBody::Pose&	pose=m_pose;
+		const btVector3		com=evaluateCom();
+		/* Com			*/ 
+		pose.m_com	=	com;
+		/* Rotation		*/ 
+		btMatrix3x3		Apq;
+		const btScalar	eps=SIMD_EPSILON;
+		Apq[0]=Apq[1]=Apq[2]=btVector3(0,0,0);
+		Apq[0].setX(eps);Apq[1].setY(eps*2);Apq[2].setZ(eps*3);
+		for(int i=0,ni=m_nodes.size();i<ni;++i)
+		{
+			const btVector3		a=pose.m_wgh[i]*(m_nodes[i].m_x-com);
+			const btVector3&	b=pose.m_pos[i];
+			Apq[0]+=a.x()*b;
+			Apq[1]+=a.y()*b;
+			Apq[2]+=a.z()*b;
+		}
+		btMatrix3x3		r,s;
+		PolarDecompose(Apq,r,s);
+		pose.m_rot=r;
+		pose.m_scl=pose.m_aqq*r.transpose()*Apq;
+		if(m_cfg.maxvolume>1)
+			{
+			const btScalar	idet=Clamp<btScalar>(	1/pose.m_scl.determinant(),
+													1,m_cfg.maxvolume);
+			pose.m_scl=Mul(pose.m_scl,idet);
+			}
+		
+	}
+}
+
+//
+void				btSoftBody::updateConstants()
+{
+	int i,ni;
+
+	/* Links		*/ 
+	for(i=0,ni=m_links.size();i<ni;++i)
+	{
+		Link&		l=m_links[i];
+		Material&	m=*l.m_material;
+		l.m_rl	=	(l.m_n[0]->m_x-l.m_n[1]->m_x).length();
+		l.m_c0	=	(l.m_n[0]->m_im+l.m_n[1]->m_im)/m.m_kLST;
+		l.m_c1	=	l.m_rl*l.m_rl;
+	}
+	/* Faces		*/ 
+	for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+		Face&		f=m_faces[i];
+		f.m_ra	=	AreaOf(f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x);
+	}
+	/* Area's		*/ 
+	btAlignedObjectArray<int>	counts;
+	counts.resize(m_nodes.size(),0);
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		m_nodes[i].m_area	=	0;
+	}
+	for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+		btSoftBody::Face&	f=m_faces[i];
+		for(int j=0;j<3;++j)
+		{
+			const int index=(int)(f.m_n[j]-&m_nodes[0]);
+			counts[index]++;
+			f.m_n[j]->m_area+=btFabs(f.m_ra);
+		}
+	}
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		if(counts[i]>0)
+			m_nodes[i].m_area/=(btScalar)counts[i];
+		else
+			m_nodes[i].m_area=0;
+	}
+}
+
+//
+void					btSoftBody::initializeClusters()
+{
+	int i;
+
+for( i=0;i<m_clusters.size();++i)
+	{
+	Cluster&	c=*m_clusters[i];
+	c.m_imass=0;
+	c.m_masses.resize(c.m_nodes.size());
+	for(int j=0;j<c.m_nodes.size();++j)
+		{
+		c.m_masses[j]	=	c.m_nodes[j]->m_im>0?1/c.m_nodes[j]->m_im:0;
+		c.m_imass		+=	c.m_masses[j];
+		}
+	c.m_imass		=	1/c.m_imass;
+	c.m_com			=	btSoftBody::clusterCom(&c);
+	c.m_lv			=	btVector3(0,0,0);
+	c.m_av			=	btVector3(0,0,0);
+	c.m_leaf		=	0;
+	/* Inertia	*/ 
+	btMatrix3x3&	ii=c.m_locii;
+	ii[0]=ii[1]=ii[2]=btVector3(0,0,0);
+	{
+		int i,ni;
+
+		for(i=0,ni=c.m_nodes.size();i<ni;++i)
+		{
+			const btVector3	k=c.m_nodes[i]->m_x-c.m_com;
+			const btVector3	q=k*k;
+			const btScalar	m=c.m_masses[i];
+			ii[0][0]	+=	m*(q[1]+q[2]);
+			ii[1][1]	+=	m*(q[0]+q[2]);
+			ii[2][2]	+=	m*(q[0]+q[1]);
+			ii[0][1]	-=	m*k[0]*k[1];
+			ii[0][2]	-=	m*k[0]*k[2];
+			ii[1][2]	-=	m*k[1]*k[2];
+		}
+	}
+	ii[1][0]=ii[0][1];
+	ii[2][0]=ii[0][2];
+	ii[2][1]=ii[1][2];
+	ii=ii.inverse();
+	/* Frame	*/ 
+	c.m_framexform.setIdentity();
+	c.m_framexform.setOrigin(c.m_com);
+	c.m_framerefs.resize(c.m_nodes.size());
+	{
+		int i;
+		for(i=0;i<c.m_framerefs.size();++i)
+			{
+			c.m_framerefs[i]=c.m_nodes[i]->m_x-c.m_com;
+			}
+		}
+	}
+}
+
+//
+void					btSoftBody::updateClusters()
+{
+BT_PROFILE("UpdateClusters");
+int i;
+
+for(i=0;i<m_clusters.size();++i)
+	{
+	btSoftBody::Cluster&	c=*m_clusters[i];
+	const int				n=c.m_nodes.size();
+	const btScalar			invn=1/(btScalar)n;
+	if(n)
+		{
+		/* Frame				*/ 
+		const btScalar	eps=btScalar(0.0001);
+		btMatrix3x3		m,r,s;
+		m[0]=m[1]=m[2]=btVector3(0,0,0);
+		m[0][0]=eps*1;
+		m[1][1]=eps*2;
+		m[2][2]=eps*3;
+		c.m_com=clusterCom(&c);
+		for(int i=0;i<c.m_nodes.size();++i)
+			{
+			const btVector3		a=c.m_nodes[i]->m_x-c.m_com;
+			const btVector3&	b=c.m_framerefs[i];
+			m[0]+=a[0]*b;m[1]+=a[1]*b;m[2]+=a[2]*b;
+			}
+		PolarDecompose(m,r,s);
+		c.m_framexform.setOrigin(c.m_com);
+		c.m_framexform.setBasis(r);		
+		/* Inertia			*/ 
+		#if 1/* Constant	*/ 
+		c.m_invwi=c.m_framexform.getBasis()*c.m_locii*c.m_framexform.getBasis().transpose();
+		#else
+			#if 0/* Sphere	*/ 
+			const btScalar	rk=(2*c.m_extents.length2())/(5*c.m_imass);
+			const btVector3	inertia(rk,rk,rk);
+			const btVector3	iin(btFabs(inertia[0])>SIMD_EPSILON?1/inertia[0]:0,
+								btFabs(inertia[1])>SIMD_EPSILON?1/inertia[1]:0,
+								btFabs(inertia[2])>SIMD_EPSILON?1/inertia[2]:0);
+			
+			c.m_invwi=c.m_xform.getBasis().scaled(iin)*c.m_xform.getBasis().transpose();
+			#else/* Actual	*/ 		
+			c.m_invwi[0]=c.m_invwi[1]=c.m_invwi[2]=btVector3(0,0,0);
+			for(int i=0;i<n;++i)
+				{
+				const btVector3	k=c.m_nodes[i]->m_x-c.m_com;
+				const btVector3		q=k*k;
+				const btScalar		m=1/c.m_nodes[i]->m_im;
+				c.m_invwi[0][0]	+=	m*(q[1]+q[2]);
+				c.m_invwi[1][1]	+=	m*(q[0]+q[2]);
+				c.m_invwi[2][2]	+=	m*(q[0]+q[1]);
+				c.m_invwi[0][1]	-=	m*k[0]*k[1];
+				c.m_invwi[0][2]	-=	m*k[0]*k[2];
+				c.m_invwi[1][2]	-=	m*k[1]*k[2];
+				}
+			c.m_invwi[1][0]=c.m_invwi[0][1];
+			c.m_invwi[2][0]=c.m_invwi[0][2];
+			c.m_invwi[2][1]=c.m_invwi[1][2];
+			c.m_invwi=c.m_invwi.inverse();
+			#endif
+		#endif
+		/* Velocities			*/ 
+		c.m_lv=btVector3(0,0,0);
+		c.m_av=btVector3(0,0,0);
+		{
+			int i;
+
+			for(i=0;i<n;++i)
+			{
+				const btVector3	v=c.m_nodes[i]->m_v*c.m_masses[i];
+				c.m_lv	+=	v;
+				c.m_av	+=	cross(c.m_nodes[i]->m_x-c.m_com,v);
+			}
+		}
+		c.m_lv=c.m_imass*c.m_lv*(1-c.m_ldamping);
+		c.m_av=c.m_invwi*c.m_av*(1-c.m_adamping);
+		c.m_vimpulses[0]	=
+		c.m_vimpulses[1]	= btVector3(0,0,0);
+		c.m_dimpulses[0]	=
+		c.m_dimpulses[1]	= btVector3(0,0,0);
+		c.m_nvimpulses		= 0;
+		c.m_ndimpulses		= 0;
+		/* Matching				*/ 
+		if(c.m_matching>0)
+			{
+			for(int j=0;j<c.m_nodes.size();++j)
+				{
+				Node&			n=*c.m_nodes[j];
+				const btVector3	x=c.m_framexform*c.m_framerefs[j];
+				n.m_x=Lerp(n.m_x,x,c.m_matching);
+				}
+			}
+		/* Dbvt					*/ 
+		if(c.m_collide)
+			{
+			btVector3	mi=c.m_nodes[0]->m_x;
+			btVector3	mx=mi;
+			for(int j=1;j<n;++j)
+				{
+				mi.setMin(c.m_nodes[j]->m_x);
+				mx.setMax(c.m_nodes[j]->m_x);
+				}			
+			const ATTRIBUTE_ALIGNED16(btDbvtVolume)	bounds=btDbvtVolume::FromMM(mi,mx);
+			if(c.m_leaf)
+				m_cdbvt.update(c.m_leaf,bounds,c.m_lv*m_sst.sdt*3,m_sst.radmrg);
+				else
+				c.m_leaf=m_cdbvt.insert(bounds,&c);
+			}
+		}
+	}
+}
+
+//
+void					btSoftBody::cleanupClusters()
+{
+for(int i=0;i<m_joints.size();++i)
+	{
+	m_joints[i]->Terminate(m_sst.sdt);
+	if(m_joints[i]->m_delete)
+		{
+		btAlignedFree(m_joints[i]);
+		m_joints.remove(m_joints[i--]);
+		}	
+	}
+}
+
+//
+void					btSoftBody::prepareClusters(int iterations)
+{
+for(int i=0;i<m_joints.size();++i)
+	{
+	m_joints[i]->Prepare(m_sst.sdt,iterations);
+	}
+}
+
+
+//
+void					btSoftBody::solveClusters(btScalar sor)
+{
+for(int i=0,ni=m_joints.size();i<ni;++i)
+	{
+	m_joints[i]->Solve(m_sst.sdt,sor);
+	}
+}
+
+//
+void					btSoftBody::applyClusters(bool drift)
+{
+BT_PROFILE("ApplyClusters");
+const btScalar					f0=m_sst.sdt;
+const btScalar					f1=f0/2;
+btAlignedObjectArray<btVector3>	deltas;
+btAlignedObjectArray<btScalar>	weights;
+deltas.resize(m_nodes.size(),btVector3(0,0,0));
+weights.resize(m_nodes.size(),0);
+int i;
+
+if(drift)
+	{
+	for(i=0;i<m_clusters.size();++i)
+		{
+		Cluster&	c=*m_clusters[i];
+		if(c.m_ndimpulses)
+			{
+			c.m_dimpulses[0]/=(btScalar)c.m_ndimpulses;
+			c.m_dimpulses[1]/=(btScalar)c.m_ndimpulses;
+			}
+		}
+	}
+for(i=0;i<m_clusters.size();++i)
+	{
+	Cluster&	c=*m_clusters[i];	
+	if(0<(drift?c.m_ndimpulses:c.m_nvimpulses))
+		{
+		const btVector3		v=(drift?c.m_dimpulses[0]:c.m_vimpulses[0])*m_sst.sdt;
+		const btVector3		w=(drift?c.m_dimpulses[1]:c.m_vimpulses[1])*m_sst.sdt;
+		for(int j=0;j<c.m_nodes.size();++j)
+			{
+			const int			idx=int(c.m_nodes[j]-&m_nodes[0]);
+			const btVector3&	x=c.m_nodes[j]->m_x;
+			const btScalar		q=c.m_masses[j];
+			deltas[idx]		+=	(v+cross(w,x-c.m_com))*q;
+			weights[idx]	+=	q;
+			}
+		}
+	}
+	for(i=0;i<deltas.size();++i)
+	{
+		if(weights[i]>0) m_nodes[i].m_x+=deltas[i]/weights[i];
+	}
+}
+
+//
+void					btSoftBody::dampClusters()
+{
+	int i;
+
+for(i=0;i<m_clusters.size();++i)
+	{
+	Cluster&	c=*m_clusters[i];	
+	if(c.m_ndamping>0)
+		{
+		for(int j=0;j<c.m_nodes.size();++j)
+			{
+			Node&			n=*c.m_nodes[j];
+			if(n.m_im>0)
+				{
+				const btVector3	vx=c.m_lv+cross(c.m_av,c.m_nodes[j]->m_q-c.m_com);
+				n.m_v	+=	c.m_ndamping*(vx-n.m_v);
+				}
+			}
+		}
+	}
+}
+
+//
+void				btSoftBody::Joint::Prepare(btScalar dt,int)
+{
+m_bodies[0].activate();
+m_bodies[1].activate();
+}
+
+//
+void				btSoftBody::LJoint::Prepare(btScalar dt,int iterations)
+{
+static const btScalar	maxdrift=4;
+Joint::Prepare(dt,iterations);
+m_rpos[0]		=	m_bodies[0].xform()*m_refs[0];
+m_rpos[1]		=	m_bodies[1].xform()*m_refs[1];
+m_drift			=	Clamp(m_rpos[0]-m_rpos[1],maxdrift)*m_erp/dt;
+m_rpos[0]		-=	m_bodies[0].xform().getOrigin();
+m_rpos[1]		-=	m_bodies[1].xform().getOrigin();
+m_massmatrix	=	ImpulseMatrix(	m_bodies[0].invMass(),m_bodies[0].invWorldInertia(),m_rpos[0],
+									m_bodies[1].invMass(),m_bodies[1].invWorldInertia(),m_rpos[1]);
+if(m_split>0)
+	{
+	m_sdrift	=	m_massmatrix*(m_drift*m_split);
+	m_drift		*=	1-m_split;
+	}
+m_drift	/=(btScalar)iterations;
+}
+
+//
+void				btSoftBody::LJoint::Solve(btScalar dt,btScalar sor)
+{
+const btVector3		va=m_bodies[0].velocity(m_rpos[0]);
+const btVector3		vb=m_bodies[1].velocity(m_rpos[1]);
+const btVector3		vr=va-vb;
+btSoftBody::Impulse	impulse;
+impulse.m_asVelocity	=	1;
+impulse.m_velocity		=	m_massmatrix*(m_drift+vr*m_cfm)*sor;
+m_bodies[0].applyImpulse(-impulse,m_rpos[0]);
+m_bodies[1].applyImpulse( impulse,m_rpos[1]);
+}
+
+//
+void				btSoftBody::LJoint::Terminate(btScalar dt)
+{
+if(m_split>0)
+	{
+	m_bodies[0].applyDImpulse(-m_sdrift,m_rpos[0]);
+	m_bodies[1].applyDImpulse( m_sdrift,m_rpos[1]);
+	}
+}
+
+//
+void				btSoftBody::AJoint::Prepare(btScalar dt,int iterations)
+{
+static const btScalar	maxdrift=SIMD_PI/16;
+m_icontrol->Prepare(this);
+Joint::Prepare(dt,iterations);
+m_axis[0]	=	m_bodies[0].xform().getBasis()*m_refs[0];
+m_axis[1]	=	m_bodies[1].xform().getBasis()*m_refs[1];
+m_drift		=	NormalizeAny(cross(m_axis[1],m_axis[0]));
+m_drift		*=	btMin(maxdrift,btAcos(Clamp<btScalar>(dot(m_axis[0],m_axis[1]),-1,+1)));
+m_drift		*=	m_erp/dt;
+m_massmatrix=	AngularImpulseMatrix(m_bodies[0].invWorldInertia(),m_bodies[1].invWorldInertia());
+if(m_split>0)
+	{
+	m_sdrift	=	m_massmatrix*(m_drift*m_split);
+	m_drift		*=	1-m_split;
+	}
+m_drift	/=(btScalar)iterations;
+}
+
+//
+void				btSoftBody::AJoint::Solve(btScalar dt,btScalar sor)
+{
+const btVector3		va=m_bodies[0].angularVelocity();
+const btVector3		vb=m_bodies[1].angularVelocity();
+const btVector3		vr=va-vb;
+const btScalar		sp=dot(vr,m_axis[0]);
+const btVector3		vc=vr-m_axis[0]*m_icontrol->Speed(this,sp);
+btSoftBody::Impulse	impulse;
+impulse.m_asVelocity	=	1;
+impulse.m_velocity		=	m_massmatrix*(m_drift+vc*m_cfm)*sor;
+m_bodies[0].applyAImpulse(-impulse);
+m_bodies[1].applyAImpulse( impulse);
+}
+
+//
+void				btSoftBody::AJoint::Terminate(btScalar dt)
+{
+if(m_split>0)
+	{
+	m_bodies[0].applyDAImpulse(-m_sdrift);
+	m_bodies[1].applyDAImpulse( m_sdrift);
+	}
+}
+
+//
+void				btSoftBody::CJoint::Prepare(btScalar dt,int iterations)
+{
+Joint::Prepare(dt,iterations);
+const bool	dodrift=(m_life==0);
+m_delete=(++m_life)>m_maxlife;
+if(dodrift)
+	{
+	m_drift=m_drift*m_erp/dt;
+	if(m_split>0)
+		{
+		m_sdrift	=	m_massmatrix*(m_drift*m_split);
+		m_drift		*=	1-m_split;
+		}
+	m_drift/=(btScalar)iterations;
+	}
+	else
+	{
+	m_drift=m_sdrift=btVector3(0,0,0);
+	}
+}
+
+//
+void				btSoftBody::CJoint::Solve(btScalar dt,btScalar sor)
+{
+const btVector3		va=m_bodies[0].velocity(m_rpos[0]);
+const btVector3		vb=m_bodies[1].velocity(m_rpos[1]);
+const btVector3		vrel=va-vb;
+const btScalar		rvac=dot(vrel,m_normal);
+btSoftBody::Impulse	impulse;
+impulse.m_asVelocity	=	1;
+impulse.m_velocity		=	m_drift;
+if(rvac<0)
+	{
+	const btVector3	iv=m_normal*rvac;
+	const btVector3	fv=vrel-iv;
+	impulse.m_velocity	+=	iv+fv*m_friction;
+	}
+impulse.m_velocity=m_massmatrix*impulse.m_velocity*sor;
+m_bodies[0].applyImpulse(-impulse,m_rpos[0]);
+m_bodies[1].applyImpulse( impulse,m_rpos[1]);
+}
+
+//
+void				btSoftBody::CJoint::Terminate(btScalar dt)
+{
+if(m_split>0)
+	{
+	m_bodies[0].applyDImpulse(-m_sdrift,m_rpos[0]);
+	m_bodies[1].applyDImpulse( m_sdrift,m_rpos[1]);
+	}
+}
+
+//
+void				btSoftBody::applyForces()
+{
+	BT_PROFILE("SoftBody applyForces");
+	const btScalar					dt=m_sst.sdt;
+	const btScalar					kLF=m_cfg.kLF;
+	const btScalar					kDG=m_cfg.kDG;
+	const btScalar					kPR=m_cfg.kPR;
+	const btScalar					kVC=m_cfg.kVC;
+	const bool						as_lift=kLF>0;
+	const bool						as_drag=kDG>0;
+	const bool						as_pressure=kPR!=0;
+	const bool						as_volume=kVC>0;
+	const bool						as_aero=	as_lift		||
+												as_drag		;
+	const bool						as_vaero=	as_aero		&&
+												(m_cfg.aeromodel<btSoftBody::eAeroModel::F_TwoSided);
+	const bool						as_faero=	as_aero		&&
+												(m_cfg.aeromodel>=btSoftBody::eAeroModel::F_TwoSided);
+	const bool						use_medium=	as_aero;
+	const bool						use_volume=	as_pressure	||
+												as_volume	;
+	btScalar						volume=0;
+	btScalar						ivolumetp=0;
+	btScalar						dvolumetv=0;
+	btSoftBody::sMedium	medium;
+	if(use_volume)
+	{
+		volume		=	getVolume();
+		ivolumetp	=	1/btFabs(volume)*kPR;
+		dvolumetv	=	(m_pose.m_volume-volume)*kVC;
+	}
+	/* Per vertex forces			*/ 
+	int i,ni;
+
+	for(i=0,ni=m_nodes.size();i<ni;++i)
+	{
+		btSoftBody::Node&	n=m_nodes[i];
+		if(n.m_im>0)
+		{
+			if(use_medium)
+			{
+				EvaluateMedium(m_worldInfo,n.m_x,medium);
+				/* Aerodynamics			*/ 
+				if(as_vaero)
+				{				
+					const btVector3	rel_v=n.m_v-medium.m_velocity;
+					const btScalar	rel_v2=rel_v.length2();
+					if(rel_v2>SIMD_EPSILON)
+					{
+						btVector3	nrm=n.m_n;
+						/* Setup normal		*/ 
+						switch(m_cfg.aeromodel)
+						{
+						case	btSoftBody::eAeroModel::V_Point:
+							nrm=NormalizeAny(rel_v);break;
+						case	btSoftBody::eAeroModel::V_TwoSided:
+							nrm*=(btScalar)(dot(nrm,rel_v)<0?-1:+1);break;
+						}
+						const btScalar	dvn=dot(rel_v,nrm);
+						/* Compute forces	*/ 
+						if(dvn>0)
+						{
+							btVector3		force(0,0,0);
+							const btScalar	c0	=	n.m_area*dvn*rel_v2/2;
+							const btScalar	c1	=	c0*medium.m_density;
+							force	+=	nrm*(-c1*kLF);
+							force	+=	rel_v.normalized()*(-c1*kDG);
+							ApplyClampedForce(n,force,dt);
+						}
+					}
+				}
+			}
+			/* Pressure				*/ 
+			if(as_pressure)
+			{
+				n.m_f	+=	n.m_n*(n.m_area*ivolumetp);
+			}
+			/* Volume				*/ 
+			if(as_volume)
+			{
+				n.m_f	+=	n.m_n*(n.m_area*dvolumetv);
+			}
+		}
+	}
+	/* Per face forces				*/ 
+	for(i=0,ni=m_faces.size();i<ni;++i)
+	{
+		btSoftBody::Face&	f=m_faces[i];
+		if(as_faero)
+		{
+			const btVector3	v=(f.m_n[0]->m_v+f.m_n[1]->m_v+f.m_n[2]->m_v)/3;
+			const btVector3	x=(f.m_n[0]->m_x+f.m_n[1]->m_x+f.m_n[2]->m_x)/3;
+			EvaluateMedium(m_worldInfo,x,medium);
+			const btVector3	rel_v=v-medium.m_velocity;
+			const btScalar	rel_v2=rel_v.length2();
+			if(rel_v2>SIMD_EPSILON)
+			{
+				btVector3	nrm=f.m_normal;
+				/* Setup normal		*/ 
+				switch(m_cfg.aeromodel)
+				{
+				case	btSoftBody::eAeroModel::F_TwoSided:
+					nrm*=(btScalar)(dot(nrm,rel_v)<0?-1:+1);break;
+				}
+				const btScalar	dvn=dot(rel_v,nrm);
+				/* Compute forces	*/ 
+				if(dvn>0)
+				{
+					btVector3		force(0,0,0);
+					const btScalar	c0	=	f.m_ra*dvn*rel_v2;
+					const btScalar	c1	=	c0*medium.m_density;
+					force	+=	nrm*(-c1*kLF);
+					force	+=	rel_v.normalized()*(-c1*kDG);
+					force	/=	3;
+					for(int j=0;j<3;++j) ApplyClampedForce(*f.m_n[j],force,dt);
+				}
+			}
+		}
+	}
+}
+
+//
+void				btSoftBody::PSolve_Anchors(btSoftBody* psb,btScalar kst,btScalar ti)
+{
+	const btScalar	kAHR=psb->m_cfg.kAHR*kst;
+	const btScalar	dt=psb->m_sst.sdt;
+	for(int i=0,ni=psb->m_anchors.size();i<ni;++i)
+	{
+		const Anchor&		a=psb->m_anchors[i];
+		const btTransform&	t=a.m_body->getInterpolationWorldTransform();
+		Node&				n=*a.m_node;
+		const btVector3		wa=t*a.m_local;
+		const btVector3		va=a.m_body->getVelocityInLocalPoint(a.m_c1)*dt;
+		const btVector3		vb=n.m_x-n.m_q;
+		const btVector3		vr=(va-vb)+(wa-n.m_x)*kAHR;
+		const btVector3		impulse=a.m_c0*vr;
+		n.m_x+=impulse*a.m_c2;
+		a.m_body->applyImpulse(-impulse,a.m_c1);
+	}
+}
+
+//
+void				btSoftBody::PSolve_RContacts(btSoftBody* psb,btScalar kst,btScalar ti)
+{
+	const btScalar	dt=psb->m_sst.sdt;
+	const btScalar	mrg=psb->getCollisionShape()->getMargin();
+	for(int i=0,ni=psb->m_rcontacts.size();i<ni;++i)
+	{
+		const RContact&		c=psb->m_rcontacts[i];
+		const sCti&			cti=c.m_cti;	
+		const btVector3		va=cti.m_body->getVelocityInLocalPoint(c.m_c1)*dt;
+		const btVector3		vb=c.m_node->m_x-c.m_node->m_q;	
+		const btVector3		vr=vb-va;
+		const btScalar		dn=dot(vr,cti.m_normal);		
+		if(dn<=SIMD_EPSILON)
+		{
+			const btScalar		dp=btMin(dot(c.m_node->m_x,cti.m_normal)+cti.m_offset,mrg);
+			const btVector3		fv=vr-cti.m_normal*dn;
+			const btVector3		impulse=c.m_c0*((vr-fv*c.m_c3+cti.m_normal*(dp*c.m_c4))*kst);
+			c.m_node->m_x-=impulse*c.m_c2;
+			c.m_cti.m_body->applyImpulse(impulse,c.m_c1);
+		}
+	}
+}
+
+//
+void				btSoftBody::PSolve_SContacts(btSoftBody* psb,btScalar,btScalar ti)
+{
+for(int i=0,ni=psb->m_scontacts.size();i<ni;++i)
+	{
+	const SContact&		c=psb->m_scontacts[i];
+	const btVector3&	nr=c.m_normal;
+	Node&				n=*c.m_node;
+	Face&				f=*c.m_face;
+	const btVector3		p=BaryEval(	f.m_n[0]->m_x,
+									f.m_n[1]->m_x,
+									f.m_n[2]->m_x,
+									c.m_weights);
+	const btVector3		q=BaryEval(	f.m_n[0]->m_q,
+									f.m_n[1]->m_q,
+									f.m_n[2]->m_q,
+									c.m_weights);											
+	const btVector3		vr=(n.m_x-n.m_q)-(p-q);
+	btVector3			corr(0,0,0);
+	if(dot(vr,nr)<0)
+		{
+		const btScalar	j=c.m_margin-(dot(nr,n.m_x)-dot(nr,p));
+		corr+=c.m_normal*j;
+		}
+	corr			-=	ProjectOnPlane(vr,nr)*c.m_friction;
+	n.m_x			+=	corr*c.m_cfm[0];
+	f.m_n[0]->m_x	-=	corr*(c.m_cfm[1]*c.m_weights.x());
+	f.m_n[1]->m_x	-=	corr*(c.m_cfm[1]*c.m_weights.y());
+	f.m_n[2]->m_x	-=	corr*(c.m_cfm[1]*c.m_weights.z());
+	}
+}
+
+//
+void				btSoftBody::PSolve_Links(btSoftBody* psb,btScalar kst,btScalar ti)
+{
+	for(int i=0,ni=psb->m_links.size();i<ni;++i)
+	{			
+		Link&	l=psb->m_links[i];
+		if(l.m_c0>0)
+		{
+			Node&			a=*l.m_n[0];
+			Node&			b=*l.m_n[1];
+			const btVector3	del=b.m_x-a.m_x;
+			const btScalar	len=del.length2();
+			const btScalar	k=((l.m_c1-len)/(l.m_c0*(l.m_c1+len)))*kst;
+			const btScalar	t=k*a.m_im;
+			a.m_x-=del*(k*a.m_im);
+			b.m_x+=del*(k*b.m_im);
+		}
+	}
+}
+
+//
+void				btSoftBody::VSolve_Links(btSoftBody* psb,btScalar kst)
+{
+for(int i=0,ni=psb->m_links.size();i<ni;++i)
+	{			
+	Link&			l=psb->m_links[i];
+	Node**			n=l.m_n;
+	const btScalar	j=-dot(l.m_c3,n[0]->m_v-n[1]->m_v)*l.m_c2*kst;
+	n[0]->m_v+=	l.m_c3*(j*n[0]->m_im);
+	n[1]->m_v-=	l.m_c3*(j*n[1]->m_im);
+	}
+}
+
+//
+btSoftBody::psolver_t	btSoftBody::getSolver(ePSolver::_ solver)
+{
+switch(solver)
+	{
+	case	ePSolver::Anchors:		return(&btSoftBody::PSolve_Anchors);
+	case	ePSolver::Linear:		return(&btSoftBody::PSolve_Links);
+	case	ePSolver::RContacts:	return(&btSoftBody::PSolve_RContacts);
+	case	ePSolver::SContacts:	return(&btSoftBody::PSolve_SContacts);	
+	}
+return(0);
+}
+
+//
+btSoftBody::vsolver_t	btSoftBody::getSolver(eVSolver::_ solver)
+{
+switch(solver)
+	{
+	case	eVSolver::Linear:		return(&btSoftBody::VSolve_Links);
+	}
+return(0);
+}
+
+//
+void			btSoftBody::defaultCollisionHandler(btCollisionObject* pco)
+{
+switch(m_cfg.collisions&fCollision::RVSmask)
+	{
+	case	fCollision::SDF_RS:
+		{
+		btSoftColliders::CollideSDF_RS	docollide;		
+		btRigidBody*		prb=btRigidBody::upcast(pco);
+		const btTransform	wtr=prb->getInterpolationWorldTransform();
+		const btTransform	ctr=prb->getWorldTransform();
+		const btScalar		timemargin=(wtr.getOrigin()-ctr.getOrigin()).length();
+		const btScalar		basemargin=getCollisionShape()->getMargin();
+		btVector3			mins;
+		btVector3			maxs;
+		ATTRIBUTE_ALIGNED16(btDbvtVolume)		volume;
+		pco->getCollisionShape()->getAabb(	pco->getInterpolationWorldTransform(),
+											mins,
+											maxs);
+		volume=btDbvtVolume::FromMM(mins,maxs);
+		volume.Expand(btVector3(basemargin,basemargin,basemargin));		
+		docollide.psb		=	this;
+		docollide.prb		=	prb;
+		docollide.dynmargin	=	basemargin+timemargin;
+		docollide.stamargin	=	basemargin;
+		btDbvt::collideTV(m_ndbvt.m_root,volume,docollide);
+		}
+	break;
+	case	fCollision::CL_RS:
+		{
+		btSoftColliders::CollideCL_RS	collider;
+		collider.Process(this,btRigidBody::upcast(pco));
+		}
+	break;
+	}
+}
+
+//
+void			btSoftBody::defaultCollisionHandler(btSoftBody* psb)
+{
+const int cf=m_cfg.collisions&psb->m_cfg.collisions;
+switch(cf&fCollision::SVSmask)
+	{
+	case	fCollision::CL_SS:
+		{
+		btSoftColliders::CollideCL_SS	docollide;
+		docollide.Process(this,psb);
+		}
+	break;
+	case	fCollision::VF_SS:
+		{
+		btSoftColliders::CollideVF_SS	docollide;
+		/* common					*/ 
+		docollide.mrg=	getCollisionShape()->getMargin()+
+						psb->getCollisionShape()->getMargin();
+		/* psb0 nodes vs psb1 faces	*/ 
+		docollide.psb[0]=this;
+		docollide.psb[1]=psb;
+		btDbvt::collideTT(	docollide.psb[0]->m_ndbvt.m_root,
+							docollide.psb[1]->m_fdbvt.m_root,
+							docollide);
+		/* psb1 nodes vs psb0 faces	*/ 
+		docollide.psb[0]=psb;
+		docollide.psb[1]=this;
+		btDbvt::collideTT(	docollide.psb[0]->m_ndbvt.m_root,
+							docollide.psb[1]->m_fdbvt.m_root,
+							docollide);
+		}
+	break;
+	}
+}
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.h	(revision 2122)
@@ -0,0 +1,830 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btSoftBody implementation by Nathanael Presson
+
+#ifndef _BT_SOFT_BODY_H
+#define _BT_SOFT_BODY_H
+
+#include "LinearMath/btAlignedObjectArray.h"
+#include "LinearMath/btPoint3.h"
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+#include "BulletCollision/CollisionShapes/btConcaveShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+#include "btSparseSDF.h"
+#include "BulletCollision/BroadphaseCollision/btDbvt.h"
+
+class btBroadphaseInterface;
+class btDispatcher;
+
+/* btSoftBodyWorldInfo	*/ 
+struct	btSoftBodyWorldInfo
+{
+	btScalar				air_density;
+	btScalar				water_density;
+	btScalar				water_offset;
+	btVector3				water_normal;
+	btBroadphaseInterface*	m_broadphase;
+	btDispatcher*	m_dispatcher;
+	btVector3				m_gravity;
+	btSparseSdf<3>			m_sparsesdf;
+};	
+
+
+/// btSoftBody is work-in-progress
+class	btSoftBody : public btCollisionObject
+{
+public:
+	//
+	// Enumerations
+	//
+
+	///eAeroModel 
+	struct eAeroModel { enum _ {
+		V_Point,	///Vertex normals are oriented toward velocity
+		V_TwoSided,	///Vertex normals are fliped to match velocity	
+		V_OneSided,	///Vertex normals are taken as it is	
+		F_TwoSided,	///Face normals are fliped to match velocity
+		F_OneSided,	///Face normals are taken as it is
+		END
+	};};
+	
+	///eVSolver : velocities solvers
+	struct	eVSolver { enum _ {
+		Linear,		///Linear solver
+		END
+	};};
+	
+	///ePSolver : positions solvers
+	struct	ePSolver { enum _ {
+		Linear,		///Linear solver
+		Anchors,	///Anchor solver
+		RContacts,	///Rigid contacts solver
+		SContacts,	///Soft contacts solver
+		END
+	};};
+	
+	///eSolverPresets
+	struct	eSolverPresets { enum _ {
+		Positions,
+		Velocities,
+		Default	=	Positions,
+		END
+	};};
+	
+	///eFeature
+	struct	eFeature { enum _ {
+		None,
+		Node,
+		Link,
+		Face,
+		END
+	};};
+	
+	typedef btAlignedObjectArray<eVSolver::_>	tVSolverArray;
+	typedef btAlignedObjectArray<ePSolver::_>	tPSolverArray;
+	
+	//
+	// Flags
+	//
+	
+	///fCollision
+	struct fCollision { enum _ {
+		RVSmask	=	0x000f,	///Rigid versus soft mask
+		SDF_RS	=	0x0001,	///SDF based rigid vs soft
+		CL_RS	=	0x0002, ///Cluster vs convex rigid vs soft
+		
+		SVSmask	=	0x00f0,	///Rigid versus soft mask		
+		VF_SS	=	0x0010,	///Vertex vs face soft vs soft handling
+		CL_SS	=	0x0020, ///Cluster vs cluster soft vs soft handling
+		/* presets	*/ 
+		Default	=	SDF_RS,
+		END
+	};};
+	
+	///fMaterial
+	struct fMaterial { enum _ {
+		DebugDraw	=	0x0001,	/// Enable debug draw
+		/* presets	*/ 
+		Default		=	DebugDraw,
+		END
+	};};
+		
+	//
+	// API Types
+	//
+	
+	/* sRayCast		*/ 
+	struct sRayCast
+	{
+		btSoftBody*	body;		/// soft body
+		eFeature::_	feature;	/// feature type
+		int			index;		/// feature index
+		btScalar	time;		/// time of impact (rayorg+raydir*time)
+	};
+	
+	/* ImplicitFn	*/ 
+	struct	ImplicitFn
+	{
+		virtual btScalar	Eval(const btVector3& x)=0;
+	};
+	
+	//
+	// Internal types
+	//
+
+	typedef btAlignedObjectArray<btScalar>	tScalarArray;
+	typedef btAlignedObjectArray<btVector3>	tVector3Array;
+
+	/* sCti is Softbody contact info	*/ 
+	struct	sCti
+	{
+		btRigidBody*	m_body;		/* Rigid body			*/ 
+		btVector3		m_normal;	/* Outward normal		*/ 
+		btScalar		m_offset;	/* Offset from origin	*/ 
+	};	
+
+	/* sMedium		*/ 
+	struct	sMedium
+	{
+		btVector3		m_velocity;	/* Velocity				*/ 
+		btScalar		m_pressure;	/* Pressure				*/ 
+		btScalar		m_density;	/* Density				*/ 
+	};
+
+	/* Base type	*/ 
+	struct	Element
+	{
+		void*			m_tag;			// User data
+		Element() : m_tag(0) {}
+	};
+	/* Material		*/ 
+	struct	Material : Element
+	{
+		btScalar				m_kLST;			// Linear stiffness coefficient [0,1]
+		btScalar				m_kAST;			// Area/Angular stiffness coefficient [0,1]
+		btScalar				m_kVST;			// Volume stiffness coefficient [0,1]
+		int						m_flags;		// Flags
+	};
+		
+	/* Feature		*/ 
+	struct	Feature : Element
+	{
+		Material*				m_material;		// Material
+	};
+	/* Node			*/ 
+	struct	Node : Feature
+	{
+		btVector3				m_x;			// Position
+		btVector3				m_q;			// Previous step position
+		btVector3				m_v;			// Velocity
+		btVector3				m_f;			// Force accumulator
+		btVector3				m_n;			// Normal
+		btScalar				m_im;			// 1/mass
+		btScalar				m_area;			// Area
+		btDbvtNode*				m_leaf;			// Leaf data
+		int						m_battach:1;	// Attached
+	};
+	/* Link			*/ 
+	struct	Link : Feature
+	{
+		Node*					m_n[2];			// Node pointers
+		btScalar				m_rl;			// Rest length		
+		int						m_bbending:1;	// Bending link
+		btScalar				m_c0;			// (ima+imb)*kLST
+		btScalar				m_c1;			// rl^2
+		btScalar				m_c2;			// |gradient|^2/c0
+		btVector3				m_c3;			// gradient
+	};
+	/* Face			*/ 
+	struct	Face : Feature
+	{
+		Node*					m_n[3];			// Node pointers
+		btVector3				m_normal;		// Normal
+		btScalar				m_ra;			// Rest area
+		btDbvtNode*				m_leaf;			// Leaf data
+	};
+	/* RContact		*/ 
+	struct	RContact
+	{
+		sCti		m_cti;			// Contact infos
+		Node*					m_node;			// Owner node
+		btMatrix3x3				m_c0;			// Impulse matrix
+		btVector3				m_c1;			// Relative anchor
+		btScalar				m_c2;			// ima*dt
+		btScalar				m_c3;			// Friction
+		btScalar				m_c4;			// Hardness
+	};
+	/* SContact		*/ 
+	struct	SContact
+	{
+		Node*					m_node;			// Node
+		Face*					m_face;			// Face
+		btVector3				m_weights;		// Weigths
+		btVector3				m_normal;		// Normal
+		btScalar				m_margin;		// Margin
+		btScalar				m_friction;		// Friction
+		btScalar				m_cfm[2];		// Constraint force mixing
+	};
+	/* Anchor		*/ 
+	struct	Anchor
+	{
+		Node*					m_node;			// Node pointer
+		btVector3				m_local;		// Anchor position in body space
+		btRigidBody*			m_body;			// Body
+		btMatrix3x3				m_c0;			// Impulse matrix
+		btVector3				m_c1;			// Relative anchor
+		btScalar				m_c2;			// ima*dt
+	};
+	/* Note			*/ 
+	struct	Note : Element
+	{
+		const char*				m_text;			// Text
+		btVector3				m_offset;		// Offset
+		int						m_rank;			// Rank
+		Node*					m_nodes[4];		// Nodes
+		btScalar				m_coords[4];	// Coordinates
+	};	
+	/* Pose			*/ 
+	struct	Pose
+	{
+		bool					m_bvolume;		// Is valid
+		bool					m_bframe;		// Is frame
+		btScalar				m_volume;		// Rest volume
+		tVector3Array			m_pos;			// Reference positions
+		tScalarArray			m_wgh;			// Weights
+		btVector3				m_com;			// COM
+		btMatrix3x3				m_rot;			// Rotation
+		btMatrix3x3				m_scl;			// Scale
+		btMatrix3x3				m_aqq;			// Base scaling
+	};
+	/* Cluster		*/ 
+	struct	Cluster
+	{		
+		btAlignedObjectArray<Node*>	m_nodes;		
+		tScalarArray				m_masses;
+		tVector3Array				m_framerefs;
+		btTransform					m_framexform;
+		btScalar					m_idmass;
+		btScalar					m_imass;
+		btMatrix3x3					m_locii;
+		btMatrix3x3					m_invwi;
+		btVector3					m_com;
+		btVector3					m_vimpulses[2];
+		btVector3					m_dimpulses[2];
+		int							m_nvimpulses;
+		int							m_ndimpulses;
+		btVector3					m_lv;
+		btVector3					m_av;
+		btDbvtNode*					m_leaf;
+		btScalar					m_ndamping;
+		btScalar					m_ldamping;
+		btScalar					m_adamping;
+		btScalar					m_matching;
+		bool						m_collide;
+									Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
+	};
+	/* Impulse		*/ 
+	struct	Impulse
+	{
+		btVector3					m_velocity;
+		btVector3					m_drift;
+		int							m_asVelocity:1;
+		int							m_asDrift:1;
+		Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0),m_asDrift(0)	{}
+		Impulse						operator -() const
+			{
+			Impulse i=*this;
+			i.m_velocity=-i.m_velocity;
+			i.m_drift=-i.m_drift;
+			return(i);
+			}
+		Impulse						operator*(btScalar x) const
+			{
+			Impulse i=*this;
+			i.m_velocity*=x;
+			i.m_drift*=x;
+			return(i);
+			}
+	};
+	/* Body			*/ 
+	struct	Body
+	{
+		Cluster*		m_soft;
+		btRigidBody*				m_rigid;
+									Body() : m_soft(0),m_rigid(0)				{}
+									Body(Cluster* p) : m_soft(p),m_rigid(0)	{}
+									Body(btRigidBody* p) : m_soft(0),m_rigid(p)	{}
+		void						activate() const
+			{
+			if(m_rigid) m_rigid->activate();
+			}
+		const btMatrix3x3&			invWorldInertia() const
+			{
+			static const btMatrix3x3	iwi(0,0,0,0,0,0,0,0,0);
+			if(m_rigid) return(m_rigid->getInvInertiaTensorWorld());
+			if(m_soft)	return(m_soft->m_invwi);
+			return(iwi);
+			}
+		btScalar					invMass() const
+			{
+			if(m_rigid) return(m_rigid->getInvMass());
+			if(m_soft)	return(m_soft->m_imass);
+			return(0);
+			}
+		const btTransform&			xform() const
+			{
+			static const btTransform	identity=btTransform::getIdentity();		
+			if(m_rigid) return(m_rigid->getInterpolationWorldTransform());
+			if(m_soft)	return(m_soft->m_framexform);
+			return(identity);
+			}
+		btVector3					linearVelocity() const
+			{
+			if(m_rigid) return(m_rigid->getLinearVelocity());
+			if(m_soft)	return(m_soft->m_lv);
+			return(btVector3(0,0,0));
+			}
+		btVector3					angularVelocity(const btVector3& rpos) const
+			{			
+			if(m_rigid) return(cross(m_rigid->getAngularVelocity(),rpos));
+			if(m_soft)	return(cross(m_soft->m_av,rpos));
+			return(btVector3(0,0,0));
+			}
+		btVector3					angularVelocity() const
+			{			
+			if(m_rigid) return(m_rigid->getAngularVelocity());
+			if(m_soft)	return(m_soft->m_av);
+			return(btVector3(0,0,0));
+			}
+		btVector3					velocity(const btVector3& rpos) const
+			{
+			return(linearVelocity()+angularVelocity(rpos));
+			}
+		void						applyVImpulse(const btVector3& impulse,const btVector3& rpos) const
+			{
+			if(m_rigid)	m_rigid->applyImpulse(impulse,rpos);
+			if(m_soft)	btSoftBody::clusterVImpulse(m_soft,rpos,impulse);
+			}
+		void						applyDImpulse(const btVector3& impulse,const btVector3& rpos) const
+			{
+			if(m_rigid)	m_rigid->applyImpulse(impulse,rpos);
+			if(m_soft)	btSoftBody::clusterDImpulse(m_soft,rpos,impulse);
+			}		
+		void						applyImpulse(const Impulse& impulse,const btVector3& rpos) const
+			{
+			if(impulse.m_asVelocity)	applyVImpulse(impulse.m_velocity,rpos);
+			if(impulse.m_asDrift)		applyDImpulse(impulse.m_drift,rpos);
+			}
+		void						applyVAImpulse(const btVector3& impulse) const
+			{
+			if(m_rigid)	m_rigid->applyTorqueImpulse(impulse);
+			if(m_soft)	btSoftBody::clusterVAImpulse(m_soft,impulse);
+			}
+		void						applyDAImpulse(const btVector3& impulse) const
+			{
+			if(m_rigid)	m_rigid->applyTorqueImpulse(impulse);
+			if(m_soft)	btSoftBody::clusterDAImpulse(m_soft,impulse);
+			}
+		void						applyAImpulse(const Impulse& impulse) const
+			{
+			if(impulse.m_asVelocity)	applyVAImpulse(impulse.m_velocity);
+			if(impulse.m_asDrift)		applyDAImpulse(impulse.m_drift);
+			}
+		void						applyDCImpulse(const btVector3& impulse) const
+			{
+			if(m_rigid)	m_rigid->applyCentralImpulse(impulse);
+			if(m_soft)	btSoftBody::clusterDCImpulse(m_soft,impulse);
+			}
+	};
+	/* Joint		*/ 
+	struct	Joint
+	{
+		struct eType { enum _ {
+			Linear,
+			Angular,
+			Contact,
+		};};
+		struct Specs
+			{
+						Specs() : erp(1),cfm(1),split(1) {}
+			btScalar	erp;
+			btScalar	cfm;
+			btScalar	split;
+			};
+		Body						m_bodies[2];
+		btVector3					m_refs[2];
+		btScalar					m_cfm;
+		btScalar					m_erp;
+		btScalar					m_split;
+		btVector3					m_drift;
+		btVector3					m_sdrift;
+		btMatrix3x3					m_massmatrix;
+		bool						m_delete;
+		virtual						~Joint() {}
+									Joint() : m_delete(false) {}
+		virtual void				Prepare(btScalar dt,int iterations);
+		virtual void				Solve(btScalar dt,btScalar sor)=0;
+		virtual void				Terminate(btScalar dt)=0;
+		virtual eType::_			Type() const=0;
+	};
+	/* LJoint		*/ 
+	struct	LJoint : Joint
+	{
+		struct Specs : Joint::Specs
+			{
+			btVector3	position;
+			};		
+		btVector3					m_rpos[2];
+		void						Prepare(btScalar dt,int iterations);
+		void						Solve(btScalar dt,btScalar sor);
+		void						Terminate(btScalar dt);
+		eType::_					Type() const { return(eType::Linear); }
+	};
+	/* AJoint		*/ 
+	struct	AJoint : Joint
+	{
+		struct IControl
+			{
+			virtual void			Prepare(AJoint*)				{}
+			virtual btScalar		Speed(AJoint*,btScalar current) { return(current); }
+			static IControl*		Default()						{ static IControl def;return(&def); }
+			};
+		struct Specs : Joint::Specs
+			{
+						Specs() : icontrol(IControl::Default()) {}
+			btVector3	axis;
+			IControl*	icontrol;
+			};		
+		btVector3					m_axis[2];
+		IControl*					m_icontrol;
+		void						Prepare(btScalar dt,int iterations);
+		void						Solve(btScalar dt,btScalar sor);
+		void						Terminate(btScalar dt);
+		eType::_					Type() const { return(eType::Angular); }
+	};
+	/* CJoint		*/ 
+	struct	CJoint : Joint
+	{		
+		int							m_life;
+		int							m_maxlife;
+		btVector3					m_rpos[2];
+		btVector3					m_normal;
+		btScalar					m_friction;
+		void						Prepare(btScalar dt,int iterations);
+		void						Solve(btScalar dt,btScalar sor);
+		void						Terminate(btScalar dt);
+		eType::_					Type() const { return(eType::Contact); }
+	};
+	/* Config		*/ 
+	struct	Config
+	{
+		eAeroModel::_			aeromodel;		// Aerodynamic model (default: V_Point)
+		btScalar				kVCF;			// Velocities correction factor (Baumgarte)
+		btScalar				kDP;			// Damping coefficient [0,1]
+		btScalar				kDG;			// Drag coefficient [0,+inf]
+		btScalar				kLF;			// Lift coefficient [0,+inf]
+		btScalar				kPR;			// Pressure coefficient [-inf,+inf]
+		btScalar				kVC;			// Volume conversation coefficient [0,+inf]
+		btScalar				kDF;			// Dynamic friction coefficient [0,1]
+		btScalar				kMT;			// Pose matching coefficient [0,1]		
+		btScalar				kCHR;			// Rigid contacts hardness [0,1]
+		btScalar				kKHR;			// Kinetic contacts hardness [0,1]
+		btScalar				kSHR;			// Soft contacts hardness [0,1]
+		btScalar				kAHR;			// Anchors hardness [0,1]
+		btScalar				kSRHR_CL;		// Soft vs rigid hardness [0,1] (cluster only)
+		btScalar				kSKHR_CL;		// Soft vs kinetic hardness [0,1] (cluster only)
+		btScalar				kSSHR_CL;		// Soft vs soft hardness [0,1] (cluster only)
+		btScalar				kSR_SPLT_CL;	// Soft vs rigid impulse split [0,1] (cluster only)
+		btScalar				kSK_SPLT_CL;	// Soft vs rigid impulse split [0,1] (cluster only)
+		btScalar				kSS_SPLT_CL;	// Soft vs rigid impulse split [0,1] (cluster only)
+		btScalar				maxvolume;		// Maximum volume ratio for pose
+		btScalar				timescale;		// Time scale
+		int						viterations;	// Velocities solver iterations
+		int						piterations;	// Positions solver iterations
+		int						diterations;	// Drift solver iterations
+		int						citerations;	// Cluster solver iterations
+		int						collisions;		// Collisions flags
+		tVSolverArray			m_vsequence;	// Velocity solvers sequence
+		tPSolverArray			m_psequence;	// Position solvers sequence
+		tPSolverArray			m_dsequence;	// Drift solvers sequence
+	};
+	/* SolverState	*/ 
+	struct	SolverState
+	{
+		btScalar				sdt;			// dt*timescale
+		btScalar				isdt;			// 1/sdt
+		btScalar				velmrg;			// velocity margin
+		btScalar				radmrg;			// radial margin
+		btScalar				updmrg;			// Update margin
+	};	
+	/* RayCaster	*/ 
+	struct	RayCaster : btDbvt::ICollide
+		{
+		btVector3			o;
+		btVector3			d;
+		btScalar			mint;
+		Face*	face;
+		int					tests;
+								RayCaster(const btVector3& org,const btVector3& dir,btScalar mxt);
+		void					Process(const btDbvtNode* leaf);
+		static inline btScalar	rayTriangle(const btVector3& org,
+											const btVector3& dir,
+											const btVector3& a,
+											const btVector3& b,
+											const btVector3& c,
+											btScalar maxt=SIMD_INFINITY);
+		};
+
+	//
+	// Typedef's
+	//
+
+	typedef void								(*psolver_t)(btSoftBody*,btScalar,btScalar);
+	typedef void								(*vsolver_t)(btSoftBody*,btScalar);
+	typedef btAlignedObjectArray<Cluster*>		tClusterArray;
+	typedef btAlignedObjectArray<Note>			tNoteArray;
+	typedef btAlignedObjectArray<Node>			tNodeArray;
+	typedef btAlignedObjectArray<btDbvtNode*>	tLeafArray;
+	typedef btAlignedObjectArray<Link>			tLinkArray;
+	typedef btAlignedObjectArray<Face>			tFaceArray;
+	typedef btAlignedObjectArray<Anchor>		tAnchorArray;
+	typedef btAlignedObjectArray<RContact>		tRContactArray;
+	typedef btAlignedObjectArray<SContact>		tSContactArray;
+	typedef btAlignedObjectArray<Material*>		tMaterialArray;
+	typedef btAlignedObjectArray<Joint*>		tJointArray;
+	typedef btAlignedObjectArray<btSoftBody*>	tSoftBodyArray;	
+
+	//
+	// Fields
+	//
+
+	Config					m_cfg;			// Configuration
+	SolverState				m_sst;			// Solver state
+	Pose					m_pose;			// Pose
+	void*					m_tag;			// User data
+	btSoftBodyWorldInfo*	m_worldInfo;	// World info
+	tNoteArray				m_notes;		// Notes
+	tNodeArray				m_nodes;		// Nodes
+	tLinkArray				m_links;		// Links
+	tFaceArray				m_faces;		// Faces
+	tAnchorArray			m_anchors;		// Anchors
+	tRContactArray			m_rcontacts;	// Rigid contacts
+	tSContactArray			m_scontacts;	// Soft contacts
+	tJointArray				m_joints;		// Joints
+	tMaterialArray			m_materials;	// Materials
+	btScalar				m_timeacc;		// Time accumulator
+	btVector3				m_bounds[2];	// Spatial bounds	
+	bool					m_bUpdateRtCst;	// Update runtime constants
+	btDbvt					m_ndbvt;		// Nodes tree
+	btDbvt					m_fdbvt;		// Faces tree
+	btDbvt					m_cdbvt;		// Clusters tree
+	tClusterArray			m_clusters;		// Clusters
+		
+	//
+	// Api
+	//
+	
+	/* ctor																	*/ 
+	btSoftBody(	btSoftBodyWorldInfo* worldInfo,int node_count,
+				const btVector3* x,
+				const btScalar* m);
+	/* dtor																	*/ 
+	virtual ~btSoftBody();
+	/* Check for existing link												*/ 
+
+	btAlignedObjectArray<int>	m_userIndexMapping;
+
+	btSoftBodyWorldInfo*	getWorldInfo()
+	{
+		return m_worldInfo;
+	}
+
+	virtual void	setCollisionShape(btCollisionShape* collisionShape)
+	{
+		//don't do anything, due to the internal shape hack: todo: fix this
+	}
+
+	bool				checkLink(	int node0,
+		int node1) const;
+	bool				checkLink(	const Node* node0,
+									const Node* node1) const;
+	/* Check for existring face												*/ 
+	bool				checkFace(	int node0,
+									int node1,
+									int node2) const;
+	/* Append material														*/ 
+	Material*			appendMaterial();
+	/* Append note															*/ 
+	void				appendNote(	const char* text,
+									const btVector3& o,
+									const btVector4& c=btVector4(1,0,0,0),
+									Node* n0=0,
+									Node* n1=0,
+									Node* n2=0,
+									Node* n3=0);
+	void				appendNote(	const char* text,
+									const btVector3& o,
+									Node* feature);
+	void				appendNote(	const char* text,
+									const btVector3& o,
+									Link* feature);
+	void				appendNote(	const char* text,
+									const btVector3& o,
+									Face* feature);
+	/* Append node															*/ 
+	void				appendNode(	const btVector3& x,btScalar m);
+	/* Append link															*/ 
+	void				appendLink(int model=-1,Material* mat=0);
+	void				appendLink(	int node0,
+									int node1,
+									Material* mat=0,
+									bool bcheckexist=false);
+	void				appendLink(	Node* node0,
+									Node* node1,
+									Material* mat=0,
+									bool bcheckexist=false);
+	/* Append face															*/ 
+	void				appendFace(int model=-1,Material* mat=0);
+	void				appendFace(	int node0,
+									int node1,
+									int node2,
+									Material* mat=0);
+	/* Append anchor														*/ 
+	void				appendAnchor(	int node,
+										btRigidBody* body);
+	/* Append linear joint													*/ 
+	void				appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
+	void				appendLinearJoint(const LJoint::Specs& specs,Body body=Body());
+	void				appendLinearJoint(const LJoint::Specs& specs,btSoftBody* body);
+	/* Append linear joint													*/ 
+	void				appendAngularJoint(const AJoint::Specs& specs,Cluster* body0,Body body1);
+	void				appendAngularJoint(const AJoint::Specs& specs,Body body=Body());
+	void				appendAngularJoint(const AJoint::Specs& specs,btSoftBody* body);
+	/* Add force (or gravity) to the entire body							*/ 
+	void				addForce(		const btVector3& force);
+	/* Add force (or gravity) to a node of the body							*/ 
+	void				addForce(		const btVector3& force,
+										int node);
+	/* Add velocity to the entire body										*/ 
+	void				addVelocity(	const btVector3& velocity);
+
+	/* Set velocity for the entire body										*/ 
+	void				setVelocity(	const btVector3& velocity);
+
+	/* Add velocity to a node of the body									*/ 
+	void				addVelocity(	const btVector3& velocity,
+										int node);
+	/* Set mass																*/ 
+	void				setMass(		int node,
+										btScalar mass);
+	/* Get mass																*/ 
+	btScalar			getMass(		int node) const;
+	/* Get total mass														*/ 
+	btScalar			getTotalMass() const;
+	/* Set total mass (weighted by previous masses)							*/ 
+	void				setTotalMass(	btScalar mass,
+										bool fromfaces=false);
+	/* Set total density													*/ 
+	void				setTotalDensity(btScalar density);
+	/* Transform															*/ 
+	void				transform(		const btTransform& trs);
+	/* Translate															*/ 
+	void				translate(		const btVector3& trs);
+	/* Rotate															*/ 
+	void				rotate(	const btQuaternion& rot);
+	/* Scale																*/ 
+	void				scale(	const btVector3& scl);
+	/* Set current state as pose											*/ 
+	void				setPose(		bool bvolume,
+										bool bframe);
+	/* Return the volume													*/ 
+	btScalar			getVolume() const;
+	/* Cluster count														*/ 
+	int					clusterCount() const;
+	/* Cluster center of mass												*/ 
+	static btVector3	clusterCom(const Cluster* cluster);
+	btVector3			clusterCom(int cluster) const;
+	/* Cluster velocity at rpos												*/ 
+	static btVector3	clusterVelocity(const Cluster* cluster,const btVector3& rpos);
+	/* Cluster impulse														*/ 
+	static void			clusterVImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse);
+	static void			clusterDImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse);
+	static void			clusterImpulse(Cluster* cluster,const btVector3& rpos,const Impulse& impulse);
+	static void			clusterVAImpulse(Cluster* cluster,const btVector3& impulse);
+	static void			clusterDAImpulse(Cluster* cluster,const btVector3& impulse);
+	static void			clusterAImpulse(Cluster* cluster,const Impulse& impulse);
+	static void			clusterDCImpulse(Cluster* cluster,const btVector3& impulse);
+	/* Generate bending constraints based on distance in the adjency graph	*/ 
+	int					generateBendingConstraints(	int distance,
+													Material* mat=0);
+	/* Randomize constraints to reduce solver bias							*/ 
+	void				randomizeConstraints();
+	/* Release clusters														*/ 
+	void				releaseCluster(int index);
+	void				releaseClusters();
+	/* Generate clusters (K-mean)											*/ 
+	int					generateClusters(int k,int maxiterations=8192);
+	/* Refine																*/ 
+	void				refine(ImplicitFn* ifn,btScalar accurary,bool cut);
+	/* CutLink																*/ 
+	bool				cutLink(int node0,int node1,btScalar position);
+	bool				cutLink(const Node* node0,const Node* node1,btScalar position);
+	/* Ray casting															*/ 
+	bool				rayCast(const btVector3& org,
+								const btVector3& dir,
+								sRayCast& results,
+								btScalar maxtime=SIMD_INFINITY);
+	/* Solver presets														*/ 
+	void				setSolver(eSolverPresets::_ preset);
+	/* predictMotion														*/ 
+	void				predictMotion(btScalar dt);
+	/* solveConstraints														*/ 
+	void				solveConstraints();
+	/* staticSolve															*/ 
+	void				staticSolve(int iterations);
+	/* solveCommonConstraints												*/ 
+	static void			solveCommonConstraints(btSoftBody** bodies,int count,int iterations);
+	/* solveClusters														*/ 
+	static void			solveClusters(const btAlignedObjectArray<btSoftBody*>& bodies);
+	/* integrateMotion														*/ 
+	void				integrateMotion();
+	/* defaultCollisionHandlers												*/ 
+	void				defaultCollisionHandler(btCollisionObject* pco);
+	void				defaultCollisionHandler(btSoftBody* psb);
+		
+	//
+	// Cast
+	//
+		
+	static const btSoftBody*	upcast(const btCollisionObject* colObj)
+	{
+		if (colObj->getInternalType()==CO_SOFT_BODY)
+			return (const btSoftBody*)colObj;
+		return 0;
+	}
+	static btSoftBody*			upcast(btCollisionObject* colObj)
+	{
+		if (colObj->getInternalType()==CO_SOFT_BODY)
+			return (btSoftBody*)colObj;
+		return 0;
+	}
+
+	//
+	// ::btCollisionObject
+	//
+
+	virtual void getAabb(btVector3& aabbMin,btVector3& aabbMax) const
+	{
+		aabbMin = m_bounds[0];
+		aabbMax = m_bounds[1];
+	}
+	//
+	// Private
+	//
+	void				pointersToIndices();
+	void				indicesToPointers(const int* map=0);
+	int					rayCast(const btVector3& org,const btVector3& dir,
+								btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
+	void				initializeFaceTree();
+	btVector3			evaluateCom() const;
+	bool				checkContact(btRigidBody* prb,const btVector3& x,btScalar margin,btSoftBody::sCti& cti) const;
+	void				updateNormals();
+	void				updateBounds();
+	void				updatePose();
+	void				updateConstants();
+	void				initializeClusters();
+	void				updateClusters();
+	void				cleanupClusters();
+	void				prepareClusters(int iterations);
+	void				solveClusters(btScalar sor);
+	void				applyClusters(bool drift);
+	void				dampClusters();
+	void				applyForces();	
+	static void			PSolve_Anchors(btSoftBody* psb,btScalar kst,btScalar ti);
+	static void			PSolve_RContacts(btSoftBody* psb,btScalar kst,btScalar ti);
+	static void			PSolve_SContacts(btSoftBody* psb,btScalar,btScalar ti);
+	static void			PSolve_Links(btSoftBody* psb,btScalar kst,btScalar ti);
+	static void			VSolve_Links(btSoftBody* psb,btScalar kst);
+	static psolver_t	getSolver(ePSolver::_ solver);
+	static vsolver_t	getSolver(eVSolver::_ solver);
+	
+};
+
+
+
+#endif //_BT_SOFT_BODY_H
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,369 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btSoftBodyConcaveCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionShapes/btConcaveShape.h"
+#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
+#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "BulletCollision/CollisionShapes/btTetrahedronShape.h"
+#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
+
+
+
+#include "LinearMath/btIDebugDraw.h"
+#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+#include "BulletSoftBody/btSoftBody.h"
+
+#define BT_SOFTBODY_TRIANGLE_EXTRUSION btScalar(0.06)//make this configurable
+
+btSoftBodyConcaveCollisionAlgorithm::btSoftBodyConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
+: btCollisionAlgorithm(ci),
+m_isSwapped(isSwapped),
+m_btSoftBodyTriangleCallback(ci.m_dispatcher1,body0,body1,isSwapped)
+{
+}
+
+
+
+btSoftBodyConcaveCollisionAlgorithm::~btSoftBodyConcaveCollisionAlgorithm()
+{
+}
+
+
+
+btSoftBodyTriangleCallback::btSoftBodyTriangleCallback(btDispatcher*  dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped):
+	  m_dispatcher(dispatcher),
+	m_dispatchInfoPtr(0)
+{
+	m_softBody = (btSoftBody*) (isSwapped? body1:body0);
+	m_triBody = isSwapped? body0:body1;
+	
+	  //
+	  // create the manifold from the dispatcher 'manifold pool'
+	  //
+//	  m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody);
+
+  	  clearCache();
+}
+
+btSoftBodyTriangleCallback::~btSoftBodyTriangleCallback()
+{
+	clearCache();
+//	m_dispatcher->releaseManifold( m_manifoldPtr );
+  
+}
+  
+
+void	btSoftBodyTriangleCallback::clearCache()
+{
+	for (int i=0;i<m_shapeCache.size();i++)
+	{
+		btTriIndex* tmp = m_shapeCache.getAtIndex(i);
+		btAssert(tmp);
+		btAssert(tmp->m_childShape);
+		m_softBody->getWorldInfo()->m_sparsesdf.RemoveReferences(tmp->m_childShape);//necessary?
+		delete tmp->m_childShape;
+	}
+	m_shapeCache.clear();
+};
+
+
+void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
+{
+ 	//just for debugging purposes
+	//printf("triangle %d",m_triangleCount++);
+	btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
+	btCollisionAlgorithmConstructionInfo ci;
+	ci.m_dispatcher1 = m_dispatcher;
+
+		///debug drawing of the overlapping triangles
+	if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
+	{
+		btVector3 color(255,255,0);
+		btTransform& tr = ob->getWorldTransform();
+		m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color);
+		m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color);
+		m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
+	}
+
+	btTriIndex	triIndex(partId,triangleIndex,0);
+	btHashKey<btTriIndex> triKey(triIndex.getUid());
+
+	
+	btTriIndex* shapeIndex = m_shapeCache[triKey];
+	if (shapeIndex)
+	{
+		btCollisionShape* tm = shapeIndex->m_childShape;
+		btAssert(tm);
+
+		//copy over user pointers to temporary shape
+		tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
+		
+		btCollisionShape* tmpShape = ob->getCollisionShape();
+		ob->internalSetTemporaryCollisionShape( tm );
+		
+
+		btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
+		
+		colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
+		colAlgo->~btCollisionAlgorithm();
+		ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
+		ob->internalSetTemporaryCollisionShape( tmpShape);
+		return;
+	}
+
+	//aabb filter is already applied!	
+
+	//btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
+	
+//	if (m_softBody->getCollisionShape()->getShapeType()==
+	{
+//		btVector3 other;
+		btVector3 normal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]);
+		normal.normalize();
+		normal*= BT_SOFTBODY_TRIANGLE_EXTRUSION;
+//		other=(triangle[0]+triangle[1]+triangle[2])*0.333333f;
+//		other+=normal*22.f;
+		btVector3	pts[6] = {triangle[0]+normal,
+			triangle[1]+normal,
+		triangle[2]+normal,
+		triangle[0]-normal,
+		triangle[1]-normal,
+		triangle[2]-normal};
+
+		btConvexHullShape* tm = new btConvexHullShape(&pts[0].getX(),6);
+
+
+//		btBU_Simplex1to4 tm(triangle[0],triangle[1],triangle[2],other);
+		
+		//btTriangleShape tm(triangle[0],triangle[1],triangle[2]);	
+	//	tm.setMargin(m_collisionMarginTriangle);
+		
+		//copy over user pointers to temporary shape
+		tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
+		
+		btCollisionShape* tmpShape = ob->getCollisionShape();
+		ob->internalSetTemporaryCollisionShape( tm );
+		
+
+		btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
+		///this should use the btDispatcher, so the actual registered algorithm is used
+		//		btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
+
+		//m_resultOut->setShapeIdentifiers(-1,-1,partId,triangleIndex);
+	//	cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
+//		cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
+		colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
+		colAlgo->~btCollisionAlgorithm();
+		ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
+		
+		
+		ob->internalSetTemporaryCollisionShape( tmpShape );
+		triIndex.m_childShape = tm;
+		m_shapeCache.insert(triKey,triIndex);
+
+	}
+
+	
+
+}
+
+
+
+void	btSoftBodyTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	m_dispatchInfoPtr = &dispatchInfo;
+	m_collisionMarginTriangle = collisionMarginTriangle+btScalar(BT_SOFTBODY_TRIANGLE_EXTRUSION);
+	m_resultOut = resultOut;
+
+	
+	btVector3	aabbWorldSpaceMin,aabbWorldSpaceMax;
+	m_softBody->getAabb(aabbWorldSpaceMin,aabbWorldSpaceMax);
+	btVector3 halfExtents = (aabbWorldSpaceMax-aabbWorldSpaceMin)*btScalar(0.5);
+	btVector3 softBodyCenter = (aabbWorldSpaceMax+aabbWorldSpaceMin)*btScalar(0.5);
+
+	btTransform softTransform;
+	softTransform.setIdentity();
+	softTransform.setOrigin(softBodyCenter);
+
+	btTransform convexInTriangleSpace;
+	convexInTriangleSpace = m_triBody->getWorldTransform().inverse() * softTransform;
+	btTransformAabb(halfExtents,m_collisionMarginTriangle,convexInTriangleSpace,m_aabbMin,m_aabbMax);
+}
+
+void btSoftBodyConcaveCollisionAlgorithm::clearCache()
+{
+	m_btSoftBodyTriangleCallback.clearCache();
+
+}
+
+void btSoftBodyConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	
+	
+	btCollisionObject* convexBody = m_isSwapped ? body1 : body0;
+	btCollisionObject* triBody = m_isSwapped ? body0 : body1;
+
+	if (triBody->getCollisionShape()->isConcave())
+	{
+
+
+		btCollisionObject*	triOb = triBody;
+		btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
+		
+	//	if (convexBody->getCollisionShape()->isConvex())
+		{
+			btScalar collisionMarginTriangle = concaveShape->getMargin();
+					
+//			resultOut->setPersistentManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
+			m_btSoftBodyTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
+
+			//Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
+			//m_dispatcher->clearManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
+
+//			m_btSoftBodyTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody);
+
+
+			concaveShape->processAllTriangles( &m_btSoftBodyTriangleCallback,m_btSoftBodyTriangleCallback.getAabbMin(),m_btSoftBodyTriangleCallback.getAabbMax());
+			
+		//	resultOut->refreshContactPoints();
+	
+		}
+	
+	}
+
+}
+
+
+btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)resultOut;
+	(void)dispatchInfo;
+	btCollisionObject* convexbody = m_isSwapped ? body1 : body0;
+	btCollisionObject* triBody = m_isSwapped ? body0 : body1;
+
+
+	//quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast)
+
+	//only perform CCD above a certain threshold, this prevents blocking on the long run
+	//because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame...
+	btScalar squareMot0 = (convexbody->getInterpolationWorldTransform().getOrigin() - convexbody->getWorldTransform().getOrigin()).length2();
+	if (squareMot0 < convexbody->getCcdSquareMotionThreshold())
+	{
+		return btScalar(1.);
+	}
+
+	//const btVector3& from = convexbody->m_worldTransform.getOrigin();
+	//btVector3 to = convexbody->m_interpolationWorldTransform.getOrigin();
+	//todo: only do if the motion exceeds the 'radius'
+
+	btTransform triInv = triBody->getWorldTransform().inverse();
+	btTransform convexFromLocal = triInv * convexbody->getWorldTransform();
+	btTransform convexToLocal = triInv * convexbody->getInterpolationWorldTransform();
+
+	struct LocalTriangleSphereCastCallback	: public btTriangleCallback
+	{
+		btTransform m_ccdSphereFromTrans;
+		btTransform m_ccdSphereToTrans;
+		btTransform	m_meshTransform;
+
+		btScalar	m_ccdSphereRadius;
+		btScalar	m_hitFraction;
+	
+
+		LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction)
+			:m_ccdSphereFromTrans(from),
+			m_ccdSphereToTrans(to),
+			m_ccdSphereRadius(ccdSphereRadius),
+			m_hitFraction(hitFraction)
+		{			
+		}
+		
+		
+		virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
+		{
+			(void)partId;
+			(void)triangleIndex;
+			//do a swept sphere for now
+			btTransform ident;
+			ident.setIdentity();
+			btConvexCast::CastResult castResult;
+			castResult.m_fraction = m_hitFraction;
+			btSphereShape	pointShape(m_ccdSphereRadius);
+			btTriangleShape	triShape(triangle[0],triangle[1],triangle[2]);
+			btVoronoiSimplexSolver	simplexSolver;
+			btSubsimplexConvexCast convexCaster(&pointShape,&triShape,&simplexSolver);
+			//GjkConvexCast	convexCaster(&pointShape,convexShape,&simplexSolver);
+			//ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0);
+			//local space?
+
+			if (convexCaster.calcTimeOfImpact(m_ccdSphereFromTrans,m_ccdSphereToTrans,
+				ident,ident,castResult))
+			{
+				if (m_hitFraction > castResult.m_fraction)
+					m_hitFraction = castResult.m_fraction;
+			}
+
+		}
+
+	};
+
+
+	
+
+	
+	if (triBody->getCollisionShape()->isConcave())
+	{
+		btVector3 rayAabbMin = convexFromLocal.getOrigin();
+		rayAabbMin.setMin(convexToLocal.getOrigin());
+		btVector3 rayAabbMax = convexFromLocal.getOrigin();
+		rayAabbMax.setMax(convexToLocal.getOrigin());
+		btScalar ccdRadius0 = convexbody->getCcdSweptSphereRadius();
+		rayAabbMin -= btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
+		rayAabbMax += btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
+
+		btScalar curHitFraction = btScalar(1.); //is this available?
+		LocalTriangleSphereCastCallback raycastCallback(convexFromLocal,convexToLocal,
+			convexbody->getCcdSweptSphereRadius(),curHitFraction);
+
+		raycastCallback.m_hitFraction = convexbody->getHitFraction();
+
+		btCollisionObject* concavebody = triBody;
+
+		btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape();
+		
+		if (triangleMesh)
+		{
+			triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
+		}
+	
+
+
+		if (raycastCallback.m_hitFraction < convexbody->getHitFraction())
+		{
+			convexbody->setHitFraction( raycastCallback.m_hitFraction);
+			return raycastCallback.m_hitFraction;
+		}
+	}
+
+	return btScalar(1.);
+
+}
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,153 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H
+#define SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+#include "BulletCollision/CollisionShapes/btTriangleCallback.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
+class btDispatcher;
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+class btSoftBody;
+class btCollisionShape;
+
+#include "LinearMath/btHashMap.h"
+
+#include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" //for definition of MAX_NUM_PARTS_IN_BITS
+
+struct btTriIndex
+{
+	int m_PartIdTriangleIndex;
+	class btCollisionShape*	m_childShape;
+	
+	btTriIndex(int partId,int triangleIndex,btCollisionShape* shape)
+	{
+		m_PartIdTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
+		m_childShape = shape;
+	}
+
+	int	getTriangleIndex() const
+	{
+		// Get only the lower bits where the triangle index is stored
+		return (m_PartIdTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS)));
+	}
+	int	getPartId() const
+	{
+		// Get only the highest bits where the part index is stored
+		return (m_PartIdTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));
+	}
+	int	getUid() const
+	{
+		return m_PartIdTriangleIndex;
+	}
+};
+
+
+///For each triangle in the concave mesh that overlaps with the AABB of a soft body (m_softBody), processTriangle is called.
+class btSoftBodyTriangleCallback : public btTriangleCallback
+{
+	btSoftBody* m_softBody;
+	btCollisionObject* m_triBody;
+
+	btVector3	m_aabbMin;
+	btVector3	m_aabbMax ;
+
+	btManifoldResult* m_resultOut;
+
+	btDispatcher*	m_dispatcher;
+	const btDispatcherInfo* m_dispatchInfoPtr;
+	btScalar m_collisionMarginTriangle;
+
+	btHashMap<btHashKey<btTriIndex>,btTriIndex> m_shapeCache;
+	
+public:
+int	m_triangleCount;
+	
+//	btPersistentManifold*	m_manifoldPtr;
+
+	btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+
+	void	setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual ~btSoftBodyTriangleCallback();
+
+	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
+	
+	void clearCache();
+
+	SIMD_FORCE_INLINE const btVector3& getAabbMin() const
+	{
+		return m_aabbMin;
+	}
+	SIMD_FORCE_INLINE const btVector3& getAabbMax() const
+	{
+		return m_aabbMax;
+	}
+
+};
+
+
+
+
+/// btSoftBodyConcaveCollisionAlgorithm  supports collision between soft body shapes and (concave) trianges meshes.
+class btSoftBodyConcaveCollisionAlgorithm  : public btCollisionAlgorithm
+{
+
+	bool	m_isSwapped;
+
+	btSoftBodyTriangleCallback m_btSoftBodyTriangleCallback;
+
+public:
+
+	btSoftBodyConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+
+	virtual ~btSoftBodyConcaveCollisionAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	btScalar	calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		//we don't add any manifolds
+	}
+
+	void	clearCache();
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSoftBodyConcaveCollisionAlgorithm));
+			return new(mem) btSoftBodyConcaveCollisionAlgorithm(ci,body0,body1,false);
+		}
+	};
+
+	struct SwappedCreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSoftBodyConcaveCollisionAlgorithm));
+			return new(mem) btSoftBodyConcaveCollisionAlgorithm(ci,body0,body1,true);
+		}
+	};
+
+};
+
+#endif //SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyHelpers.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyHelpers.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyHelpers.cpp	(revision 2122)
@@ -0,0 +1,653 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btSoftBodyHelpers.cpp by Nathanael Presson
+
+#include "btSoftBodyInternals.h"
+#include <stdio.h>
+#include <string.h>
+#include "btSoftBodyHelpers.h"
+#include "LinearMath/btConvexHull.h"
+
+//
+static void				drawVertex(	btIDebugDraw* idraw,
+									const btVector3& x,btScalar s,const btVector3& c)
+	{
+		idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c);
+		idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c);
+		idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c);
+	}
+
+//
+static void				drawBox(	btIDebugDraw* idraw,
+									const btVector3& mins,
+									const btVector3& maxs,
+									const btVector3& color)
+{
+const btVector3	c[]={	btVector3(mins.x(),mins.y(),mins.z()),
+						btVector3(maxs.x(),mins.y(),mins.z()),
+						btVector3(maxs.x(),maxs.y(),mins.z()),
+						btVector3(mins.x(),maxs.y(),mins.z()),
+						btVector3(mins.x(),mins.y(),maxs.z()),
+						btVector3(maxs.x(),mins.y(),maxs.z()),
+						btVector3(maxs.x(),maxs.y(),maxs.z()),
+						btVector3(mins.x(),maxs.y(),maxs.z())};
+idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color);
+idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color);
+idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color);
+idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color);
+idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color);
+idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
+}
+
+//
+static void				drawTree(	btIDebugDraw* idraw,
+									const btDbvtNode* node,
+									int depth,
+									const btVector3& ncolor,
+									const btVector3& lcolor,
+									int mindepth,
+									int maxdepth)
+{
+if(node)
+	{
+	if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0)))
+		{
+		drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth);
+		drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth);
+		}
+	if(depth>=mindepth)
+		{
+		const btScalar	scl=(btScalar)(node->isinternal()?1:1);
+		const btVector3	mi=node->volume.Center()-node->volume.Extents()*scl;
+		const btVector3	mx=node->volume.Center()+node->volume.Extents()*scl;
+		drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor);
+		}
+	}
+}
+
+//
+template <typename T>
+static inline T				sum(const btAlignedObjectArray<T>& items)
+{
+T	v;
+if(items.size())
+	{
+	v=items[0];
+	for(int i=1,ni=items.size();i<ni;++i)
+		{
+		v+=items[i];
+		}
+	}
+return(v);
+}
+
+//
+template <typename T,typename Q>
+static inline void			add(btAlignedObjectArray<T>& items,const Q& value)
+{
+for(int i=0,ni=items.size();i<ni;++i)
+	{
+	items[i]+=value;
+	}
+}
+
+//
+template <typename T,typename Q>
+static inline void			mul(btAlignedObjectArray<T>& items,const Q& value)
+{
+for(int i=0,ni=items.size();i<ni;++i)
+	{
+	items[i]*=value;
+	}
+}
+
+//
+template <typename T>
+static inline T				average(const btAlignedObjectArray<T>& items)
+{
+const btScalar	n=(btScalar)(items.size()>0?items.size():1);
+return(sum(items)/n);
+}
+
+//
+static inline btScalar		tetravolume(const btVector3& x0,
+										const btVector3& x1,
+										const btVector3& x2,
+										const btVector3& x3)
+{
+	const btVector3	a=x1-x0;
+	const btVector3	b=x2-x0;
+	const btVector3	c=x3-x0;
+	return(dot(a,cross(b,c)));
+}
+
+//
+#if 0
+static btVector3		stresscolor(btScalar stress)
+	{
+	static const btVector3	spectrum[]=	{	btVector3(1,0,1),
+											btVector3(0,0,1),
+											btVector3(0,1,1),
+											btVector3(0,1,0),
+											btVector3(1,1,0),
+											btVector3(1,0,0),
+											btVector3(1,0,0)};
+	static const int		ncolors=sizeof(spectrum)/sizeof(spectrum[0])-1;
+	static const btScalar	one=1;
+	stress=btMax<btScalar>(0,btMin<btScalar>(1,stress))*ncolors;
+	const int				sel=(int)stress;
+	const btScalar			frc=stress-sel;
+	return(spectrum[sel]+(spectrum[sel+1]-spectrum[sel])*frc);
+	}
+#endif
+
+//
+void			btSoftBodyHelpers::Draw(	btSoftBody* psb,
+					 btIDebugDraw* idraw,
+					 int drawflags)
+{
+	const btScalar		scl=(btScalar)0.1;
+	const btScalar		nscl=scl*5;
+	const btVector3		lcolor=btVector3(0,0,0);
+	const btVector3		ncolor=btVector3(1,1,1);
+	const btVector3		ccolor=btVector3(1,0,0);
+	int i,j,nj;
+
+	/* Nodes	*/ 
+	if(0!=(drawflags&fDrawFlags::Nodes))
+	{
+		for(i=0;i<psb->m_nodes.size();++i)
+		{
+			const btSoftBody::Node&	n=psb->m_nodes[i];
+			if(0==(n.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue;
+			idraw->drawLine(n.m_x-btVector3(scl,0,0),n.m_x+btVector3(scl,0,0),btVector3(1,0,0));
+			idraw->drawLine(n.m_x-btVector3(0,scl,0),n.m_x+btVector3(0,scl,0),btVector3(0,1,0));
+			idraw->drawLine(n.m_x-btVector3(0,0,scl),n.m_x+btVector3(0,0,scl),btVector3(0,0,1));
+		}
+	}
+	/* Links	*/ 
+	if(0!=(drawflags&fDrawFlags::Links))
+	{
+		for(i=0;i<psb->m_links.size();++i)
+		{
+			const btSoftBody::Link&	l=psb->m_links[i];
+			if(0==(l.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue;
+			idraw->drawLine(l.m_n[0]->m_x,l.m_n[1]->m_x,lcolor);
+		}
+	}
+	/* Normals	*/ 
+	if(0!=(drawflags&fDrawFlags::Normals))
+	{
+		for(i=0;i<psb->m_nodes.size();++i)
+		{
+			const btSoftBody::Node&	n=psb->m_nodes[i];
+			if(0==(n.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue;
+			const btVector3			d=n.m_n*nscl;
+			idraw->drawLine(n.m_x,n.m_x+d,ncolor);
+			idraw->drawLine(n.m_x,n.m_x-d,ncolor*0.5);
+		}
+	}
+	/* Contacts	*/ 
+	if(0!=(drawflags&fDrawFlags::Contacts))
+	{
+		static const btVector3		axis[]={btVector3(1,0,0),
+			btVector3(0,1,0),
+			btVector3(0,0,1)};
+		for(i=0;i<psb->m_rcontacts.size();++i)
+		{		
+			const btSoftBody::RContact&	c=psb->m_rcontacts[i];
+			const btVector3				o=	c.m_node->m_x-c.m_cti.m_normal*
+				(dot(c.m_node->m_x,c.m_cti.m_normal)+c.m_cti.m_offset);
+			const btVector3				x=cross(c.m_cti.m_normal,axis[c.m_cti.m_normal.minAxis()]).normalized();
+			const btVector3				y=cross(x,c.m_cti.m_normal).normalized();
+			idraw->drawLine(o-x*nscl,o+x*nscl,ccolor);
+			idraw->drawLine(o-y*nscl,o+y*nscl,ccolor);
+			idraw->drawLine(o,o+c.m_cti.m_normal*nscl*3,btVector3(1,1,0));
+		}
+	}
+	/* Anchors	*/ 
+	if(0!=(drawflags&fDrawFlags::Anchors))
+	{
+		for(i=0;i<psb->m_anchors.size();++i)
+		{
+			const btSoftBody::Anchor&	a=psb->m_anchors[i];
+			const btVector3				q=a.m_body->getWorldTransform()*a.m_local;
+			drawVertex(idraw,a.m_node->m_x,0.25,btVector3(1,0,0));
+			drawVertex(idraw,q,0.25,btVector3(0,1,0));
+			idraw->drawLine(a.m_node->m_x,q,btVector3(1,1,1));
+		}
+		for(i=0;i<psb->m_nodes.size();++i)
+		{
+			const btSoftBody::Node&	n=psb->m_nodes[i];		
+			if(0==(n.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue;
+			if(n.m_im<=0)
+			{
+				drawVertex(idraw,n.m_x,0.25,btVector3(1,0,0));
+			}
+		}
+	}
+	/* Faces	*/ 
+	if(0!=(drawflags&fDrawFlags::Faces))
+	{
+		const btScalar	scl=(btScalar)0.8;
+		const btScalar	alp=(btScalar)1;
+		const btVector3	col(0,(btScalar)0.7,0);
+		for(i=0;i<psb->m_faces.size();++i)
+		{
+			const btSoftBody::Face&	f=psb->m_faces[i];
+			if(0==(f.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue;
+			const btVector3			x[]={f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x};
+			const btVector3			c=(x[0]+x[1]+x[2])/3;
+			idraw->drawTriangle((x[0]-c)*scl+c,
+								(x[1]-c)*scl+c,
+								(x[2]-c)*scl+c,
+								col,alp);
+		}	
+	}
+	/* Clusters	*/ 
+	if(0!=(drawflags&fDrawFlags::Clusters))
+		{
+		srand(1806);
+		for(i=0;i<psb->m_clusters.size();++i)
+			{
+			if(psb->m_clusters[i]->m_collide)
+				{
+				btVector3						color(	rand()/(btScalar)RAND_MAX,
+														rand()/(btScalar)RAND_MAX,
+														rand()/(btScalar)RAND_MAX);
+				color=color.normalized()*0.75;
+				btAlignedObjectArray<btVector3>	vertices;
+				vertices.resize(psb->m_clusters[i]->m_nodes.size());
+				for(j=0,nj=vertices.size();j<nj;++j)
+					{				
+					vertices[j]=psb->m_clusters[i]->m_nodes[j]->m_x;
+					}
+				HullDesc		hdsc(QF_TRIANGLES,vertices.size(),&vertices[0]);
+				HullResult		hres;
+				HullLibrary		hlib;
+				hdsc.mMaxVertices=vertices.size();
+				hlib.CreateConvexHull(hdsc,hres);
+				const btVector3	center=average(hres.m_OutputVertices);
+				add(hres.m_OutputVertices,-center);
+				mul(hres.m_OutputVertices,(btScalar)1);
+				add(hres.m_OutputVertices,center);
+				for(j=0;j<(int)hres.mNumFaces;++j)
+					{
+					const int idx[]={hres.m_Indices[j*3+0],hres.m_Indices[j*3+1],hres.m_Indices[j*3+2]};
+					idraw->drawTriangle(hres.m_OutputVertices[idx[0]],
+										hres.m_OutputVertices[idx[1]],
+										hres.m_OutputVertices[idx[2]],
+										color,1);
+					}
+				hlib.ReleaseResult(hres);
+				}
+			/* Velocities	*/ 
+			#if 0
+			for(int j=0;j<psb->m_clusters[i].m_nodes.size();++j)
+				{
+				const btSoftBody::Cluster&	c=psb->m_clusters[i];
+				const btVector3				r=c.m_nodes[j]->m_x-c.m_com;
+				const btVector3				v=c.m_lv+cross(c.m_av,r);
+				idraw->drawLine(c.m_nodes[j]->m_x,c.m_nodes[j]->m_x+v,btVector3(1,0,0));
+				}
+			#endif
+			/* Frame		*/ 
+			btSoftBody::Cluster& c=*psb->m_clusters[i];
+			idraw->drawLine(c.m_com,c.m_framexform*btVector3(10,0,0),btVector3(1,0,0));
+			idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,10,0),btVector3(0,1,0));
+			idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,0,10),btVector3(0,0,1));
+			}
+		}
+	/* Notes	*/ 
+	if(0!=(drawflags&fDrawFlags::Notes))
+	{
+		for(i=0;i<psb->m_notes.size();++i)
+		{
+			const btSoftBody::Note&	n=psb->m_notes[i];
+			btVector3				p=n.m_offset;
+			for(int j=0;j<n.m_rank;++j)
+				{
+				p+=n.m_nodes[j]->m_x*n.m_coords[j];
+				}
+			idraw->draw3dText(p,n.m_text);
+		}
+	}
+	/* Node tree	*/ 
+	if(0!=(drawflags&fDrawFlags::NodeTree))		DrawNodeTree(psb,idraw);
+	/* Face tree	*/ 
+	if(0!=(drawflags&fDrawFlags::FaceTree))		DrawFaceTree(psb,idraw);
+	/* Cluster tree	*/ 
+	if(0!=(drawflags&fDrawFlags::ClusterTree))	DrawClusterTree(psb,idraw);
+	/* Joints		*/ 
+	if(0!=(drawflags&fDrawFlags::Joints))
+	{
+	for(i=0;i<psb->m_joints.size();++i)
+		{
+		const btSoftBody::Joint*	pj=psb->m_joints[i];
+		switch(pj->Type())
+			{
+			case	btSoftBody::Joint::eType::Linear:
+				{
+				const btSoftBody::LJoint*	pjl=(const btSoftBody::LJoint*)pj;
+				const btVector3	a0=pj->m_bodies[0].xform()*pjl->m_refs[0];
+				const btVector3	a1=pj->m_bodies[1].xform()*pjl->m_refs[1];
+				idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0));
+				idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1));
+				drawVertex(idraw,a0,0.25,btVector3(1,1,0));
+				drawVertex(idraw,a1,0.25,btVector3(0,1,1));
+				}
+			break;
+			case	btSoftBody::Joint::eType::Angular:
+				{
+				const btSoftBody::AJoint*	pja=(const btSoftBody::AJoint*)pj;
+				const btVector3	o0=pj->m_bodies[0].xform().getOrigin();
+				const btVector3	o1=pj->m_bodies[1].xform().getOrigin();
+				const btVector3	a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0];
+				const btVector3	a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1];
+				idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0));
+				idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0));
+				idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1));
+				idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1));
+				}
+			}		
+		}
+	}
+}
+
+//
+void			btSoftBodyHelpers::DrawInfos(		btSoftBody* psb,
+						  btIDebugDraw* idraw,
+						  bool masses,
+						  bool areas,
+						  bool /*stress*/)
+{
+	for(int i=0;i<psb->m_nodes.size();++i)
+	{
+		const btSoftBody::Node&	n=psb->m_nodes[i];
+		char					text[2048]={0};
+		char					buff[1024];
+		if(masses)
+		{
+			sprintf(buff," M(%.2f)",1/n.m_im);
+			strcat(text,buff);
+		}
+		if(areas)
+		{
+			sprintf(buff," A(%.2f)",n.m_area);
+			strcat(text,buff);
+		}
+		if(text[0]) idraw->draw3dText(n.m_x,text);
+	}
+}
+
+//
+void			btSoftBodyHelpers::DrawNodeTree(	btSoftBody* psb,
+													btIDebugDraw* idraw,
+													int mindepth,
+													int maxdepth)
+{
+drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth);
+}
+
+//
+void			btSoftBodyHelpers::DrawFaceTree(	btSoftBody* psb,
+													btIDebugDraw* idraw,
+													int mindepth,
+													int maxdepth)
+{
+drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth);
+}
+
+//
+void			btSoftBodyHelpers::DrawClusterTree(	btSoftBody* psb,
+													btIDebugDraw* idraw,
+													int mindepth,
+													int maxdepth)
+{
+drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth);
+}
+
+//
+void			btSoftBodyHelpers::DrawFrame(		btSoftBody* psb,
+						  btIDebugDraw* idraw)
+{
+	if(psb->m_pose.m_bframe)
+	{
+		static const btScalar	ascl=10;
+		static const btScalar	nscl=(btScalar)0.1;
+		const btVector3			com=psb->m_pose.m_com;
+		const btMatrix3x3		trs=psb->m_pose.m_rot*psb->m_pose.m_scl;
+		const btVector3			Xaxis=(trs*btVector3(1,0,0)).normalized();
+		const btVector3			Yaxis=(trs*btVector3(0,1,0)).normalized();
+		const btVector3			Zaxis=(trs*btVector3(0,0,1)).normalized();
+		idraw->drawLine(com,com+Xaxis*ascl,btVector3(1,0,0));
+		idraw->drawLine(com,com+Yaxis*ascl,btVector3(0,1,0));
+		idraw->drawLine(com,com+Zaxis*ascl,btVector3(0,0,1));
+		for(int i=0;i<psb->m_pose.m_pos.size();++i)
+		{
+			const btVector3	x=com+trs*psb->m_pose.m_pos[i];
+			drawVertex(idraw,x,nscl,btVector3(1,0,1));
+		}
+	}
+}
+
+//
+btSoftBody*		btSoftBodyHelpers::CreateRope(	btSoftBodyWorldInfo& worldInfo, const btVector3& from,
+						   const btVector3& to,
+						   int res,
+						   int fixeds)
+{
+	/* Create nodes	*/ 
+	const int		r=res+2;
+	btVector3*		x=new btVector3[r];
+	btScalar*		m=new btScalar[r];
+	int i;
+
+	for(i=0;i<r;++i)
+	{
+		const btScalar	t=i/(btScalar)(r-1);
+		x[i]=lerp(from,to,t);
+		m[i]=1;
+	}
+	btSoftBody*		psb= new btSoftBody(&worldInfo,r,x,m);
+	if(fixeds&1) psb->setMass(0,0);
+	if(fixeds&2) psb->setMass(r-1,0);
+	delete[] x;
+	delete[] m;
+	/* Create links	*/ 
+	for(i=1;i<r;++i)
+	{
+		psb->appendLink(i-1,i);
+	}
+	/* Finished		*/ 
+	return(psb);
+}
+
+//
+btSoftBody*		btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const btVector3& corner00,
+							const btVector3& corner10,
+							const btVector3& corner01,
+							const btVector3& corner11,
+							int resx,
+							int resy,
+							int fixeds,
+							bool gendiags)
+{
+#define IDX(_x_,_y_)	((_y_)*rx+(_x_))
+	/* Create nodes	*/ 
+	if((resx<2)||(resy<2)) return(0);
+	const int	rx=resx;
+	const int	ry=resy;
+	const int	tot=rx*ry;
+	btVector3*	x=new btVector3[tot];
+	btScalar*	m=new btScalar[tot];
+	int iy;
+
+	for(iy=0;iy<ry;++iy)
+	{
+		const btScalar	ty=iy/(btScalar)(ry-1);
+		const btVector3	py0=lerp(corner00,corner01,ty);
+		const btVector3	py1=lerp(corner10,corner11,ty);
+		for(int ix=0;ix<rx;++ix)
+		{
+			const btScalar	tx=ix/(btScalar)(rx-1);
+			x[IDX(ix,iy)]=lerp(py0,py1,tx);
+			m[IDX(ix,iy)]=1;
+		}
+	}
+	btSoftBody*		psb=new btSoftBody(&worldInfo,tot,x,m);
+	if(fixeds&1)	psb->setMass(IDX(0,0),0);
+	if(fixeds&2)	psb->setMass(IDX(rx-1,0),0);
+	if(fixeds&4)	psb->setMass(IDX(0,ry-1),0);
+	if(fixeds&8)	psb->setMass(IDX(rx-1,ry-1),0);
+	delete[] x;
+	delete[] m;
+	/* Create links	and faces */ 
+	for(iy=0;iy<ry;++iy)
+	{
+		for(int ix=0;ix<rx;++ix)
+		{
+			const int	idx=IDX(ix,iy);
+			const bool	mdx=(ix+1)<rx;
+			const bool	mdy=(iy+1)<ry;
+			if(mdx) psb->appendLink(idx,IDX(ix+1,iy));
+			if(mdy) psb->appendLink(idx,IDX(ix,iy+1));
+			if(mdx&&mdy)
+			{
+				if((ix+iy)&1)
+				{
+					psb->appendFace(IDX(ix,iy),IDX(ix+1,iy),IDX(ix+1,iy+1));
+					psb->appendFace(IDX(ix,iy),IDX(ix+1,iy+1),IDX(ix,iy+1));
+					if(gendiags)
+					{
+						psb->appendLink(IDX(ix,iy),IDX(ix+1,iy+1));
+					}
+				}
+				else
+				{
+					psb->appendFace(IDX(ix,iy+1),IDX(ix,iy),IDX(ix+1,iy));
+					psb->appendFace(IDX(ix,iy+1),IDX(ix+1,iy),IDX(ix+1,iy+1));
+					if(gendiags)
+					{
+						psb->appendLink(IDX(ix+1,iy),IDX(ix,iy+1));
+					}
+				}
+			}
+		}
+	}
+	/* Finished		*/ 
+#undef IDX
+	return(psb);
+}
+
+//
+btSoftBody*		btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,const btVector3& center,
+								const btVector3& radius,
+								int res)
+{
+	struct	Hammersley
+	{
+		static void	Generate(btVector3* x,int n)
+		{
+			for(int i=0;i<n;i++)
+			{
+				btScalar	p=0.5,t=0;
+				for(int j=i;j;p*=0.5,j>>=1) if(j&1) t+=p;
+				btScalar	w=2*t-1;
+				btScalar	a=(SIMD_PI+2*i*SIMD_PI)/n;
+				btScalar	s=btSqrt(1-w*w);
+				*x++=btVector3(s*btCos(a),s*btSin(a),w);
+			}
+		}
+	};
+	btAlignedObjectArray<btVector3>	vtx;
+	vtx.resize(3+res);
+	Hammersley::Generate(&vtx[0],vtx.size());
+	for(int i=0;i<vtx.size();++i)
+	{
+		vtx[i]=vtx[i]*radius+center;
+	}
+	return(CreateFromConvexHull(worldInfo,&vtx[0],vtx.size()));
+}
+
+
+
+//
+btSoftBody*		btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,const btScalar*	vertices,
+								  const int* triangles,
+								  int ntriangles)
+{
+	int		maxidx=0;
+	int i,j,ni;
+
+	for(i=0,ni=ntriangles*3;i<ni;++i)
+	{
+		maxidx=btMax(triangles[i],maxidx);
+	}
+	++maxidx;
+	btAlignedObjectArray<bool>		chks;
+	btAlignedObjectArray<btVector3>	vtx;
+	chks.resize(maxidx*maxidx,false);
+	vtx.resize(maxidx);
+	for(i=0,j=0,ni=maxidx*3;i<ni;++j,i+=3)
+	{
+		vtx[j]=btVector3(vertices[i],vertices[i+1],vertices[i+2]);
+	}
+	btSoftBody*		psb=new btSoftBody(&worldInfo,vtx.size(),&vtx[0],0);
+	for( i=0,ni=ntriangles*3;i<ni;i+=3)
+	{
+		const int idx[]={triangles[i],triangles[i+1],triangles[i+2]};
+#define IDX(_x_,_y_) ((_y_)*maxidx+(_x_))
+		for(int j=2,k=0;k<3;j=k++)
+		{
+			if(!chks[IDX(idx[j],idx[k])])
+			{
+				chks[IDX(idx[j],idx[k])]=true;
+				chks[IDX(idx[k],idx[k])]=true;
+				psb->appendLink(idx[j],idx[k]);
+			}
+		}
+#undef IDX
+		psb->appendFace(idx[0],idx[1],idx[2]);
+	}
+	psb->randomizeConstraints();
+	return(psb);
+}
+
+//
+btSoftBody*		btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo,	const btVector3* vertices,
+									 int nvertices)
+{
+	HullDesc		hdsc(QF_TRIANGLES,nvertices,vertices);
+	HullResult		hres;
+	HullLibrary		hlib;/*??*/ 
+	hdsc.mMaxVertices=nvertices;
+	hlib.CreateConvexHull(hdsc,hres);
+	btSoftBody*		psb=new btSoftBody(&worldInfo,(int)hres.mNumOutputVertices,
+		&hres.m_OutputVertices[0],0);
+	for(int i=0;i<(int)hres.mNumFaces;++i)
+	{
+		const int idx[]={	hres.m_Indices[i*3+0],
+			hres.m_Indices[i*3+1],
+			hres.m_Indices[i*3+2]};
+		if(idx[0]<idx[1]) psb->appendLink(	idx[0],idx[1]);
+		if(idx[1]<idx[2]) psb->appendLink(	idx[1],idx[2]);
+		if(idx[2]<idx[0]) psb->appendLink(	idx[2],idx[0]);
+		psb->appendFace(idx[0],idx[1],idx[2]);
+	}
+	hlib.ReleaseResult(hres);
+	psb->randomizeConstraints();
+	return(psb);
+}
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyHelpers.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyHelpers.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyHelpers.h	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SOFT_BODY_HELPERS_H
+#define SOFT_BODY_HELPERS_H
+
+#include "btSoftBody.h"
+
+//
+// Helpers
+//
+
+/* fDrawFlags															*/ 
+struct	fDrawFlags { enum _ {
+	Nodes		=	0x0001,
+	Links		=	0x0002,
+	Faces		=	0x0004,
+	Tetras		=	0x0008,
+	Normals		=	0x0010,
+	Contacts	=	0x0020,
+	Anchors		=	0x0040,
+	Notes		=	0x0080,
+	Clusters	=	0x0100,
+	NodeTree	=	0x0200,
+	FaceTree	=	0x0400,
+	ClusterTree	=	0x0800,
+	Joints		=	0x1000,
+	/* presets	*/ 
+	Std			=	Links+Faces+Tetras+Anchors+Notes+Joints,
+	StdTetra	=	Std-Faces+Tetras,
+};};
+
+struct	btSoftBodyHelpers
+{
+	/* Draw body															*/ 
+	static void				Draw(		btSoftBody* psb,
+										btIDebugDraw* idraw,
+										int drawflags=fDrawFlags::Std);
+	/* Draw body infos														*/ 
+	static	void			DrawInfos(	btSoftBody* psb,
+										btIDebugDraw* idraw,
+										bool masses,
+										bool areas,
+										bool stress);
+	/* Draw node tree														*/ 
+	static void				DrawNodeTree(	btSoftBody* psb,
+											btIDebugDraw* idraw,
+											int mindepth=0,
+											int maxdepth=-1);
+	/* Draw face tree														*/ 
+	static void				DrawFaceTree(	btSoftBody* psb,
+											btIDebugDraw* idraw,
+											int mindepth=0,
+											int maxdepth=-1);
+	/* Draw cluster tree													*/ 
+	static void				DrawClusterTree(btSoftBody* psb,
+											btIDebugDraw* idraw,
+											int mindepth=0,
+											int maxdepth=-1);
+	/* Draw rigid frame														*/ 
+	static	void			DrawFrame(		btSoftBody* psb,
+											btIDebugDraw* idraw);
+	/* Create a rope														*/ 
+	static	btSoftBody*		CreateRope( btSoftBodyWorldInfo& worldInfo,
+										const btVector3& from,
+										const btVector3& to,
+										int res,
+										int fixeds);
+	/* Create a patch														*/ 
+	static	btSoftBody*		CreatePatch(btSoftBodyWorldInfo& worldInfo,
+										const btVector3& corner00,
+										const btVector3& corner10,
+										const btVector3& corner01,
+										const btVector3& corner11,
+										int resx,
+										int resy,
+										int fixeds,
+										bool gendiags);
+	/* Create an ellipsoid													*/ 
+	static	btSoftBody*		CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,
+											const btVector3& center,
+											const btVector3& radius,
+											int res);	
+	/* Create from trimesh													*/ 
+	static	btSoftBody*		CreateFromTriMesh(	btSoftBodyWorldInfo& worldInfo,
+												const btScalar*	vertices,
+												const int* triangles,
+												int ntriangles);
+	/* Create from convex-hull												*/ 
+	static	btSoftBody*		CreateFromConvexHull(	btSoftBodyWorldInfo& worldInfo,
+													const btVector3* vertices,
+													int nvertices);
+};
+
+#endif //SOFT_BODY_HELPERS_H
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyInternals.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyInternals.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyInternals.h	(revision 2122)
@@ -0,0 +1,893 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btSoftBody implementation by Nathanael Presson
+
+#ifndef _BT_SOFT_BODY_INTERNALS_H
+#define _BT_SOFT_BODY_INTERNALS_H
+
+#include "btSoftBody.h"
+
+#include "LinearMath/btQuickprof.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btConvexInternalShape.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
+
+//
+// btSymMatrix
+//
+template <typename T>
+struct btSymMatrix
+{
+						btSymMatrix() : dim(0)					{}
+						btSymMatrix(int n,const T& init=T())	{ resize(n,init); }
+void					resize(int n,const T& init=T())			{ dim=n;store.resize((n*(n+1))/2,init); }
+int						index(int c,int r) const				{ if(c>r) btSwap(c,r);btAssert(r<dim);return((r*(r+1))/2+c); }
+T&						operator()(int c,int r)					{ return(store[index(c,r)]); }
+const T&				operator()(int c,int r) const			{ return(store[index(c,r)]); }
+btAlignedObjectArray<T>	store;
+int						dim;
+};	
+
+//
+// btSoftBodyCollisionShape
+//
+class btSoftBodyCollisionShape : public btConcaveShape
+{
+public:
+	btSoftBody*						m_body;
+	
+	btSoftBodyCollisionShape(btSoftBody* backptr)
+	{
+		m_shapeType = SOFTBODY_SHAPE_PROXYTYPE;
+		m_body=backptr;
+	}
+
+	virtual ~btSoftBodyCollisionShape()
+	{
+
+	}
+
+	void	processAllTriangles(btTriangleCallback* /*callback*/,const btVector3& /*aabbMin*/,const btVector3& /*aabbMax*/) const
+	{
+		//not yet
+		btAssert(0);
+	}
+
+	///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+	{
+	/* t should be identity, but better be safe than...fast? */ 
+	const btVector3	mins=m_body->m_bounds[0];
+	const btVector3	maxs=m_body->m_bounds[1];
+	const btVector3	crns[]={t*btVector3(mins.x(),mins.y(),mins.z()),
+							t*btVector3(maxs.x(),mins.y(),mins.z()),
+							t*btVector3(maxs.x(),maxs.y(),mins.z()),
+							t*btVector3(mins.x(),maxs.y(),mins.z()),
+							t*btVector3(mins.x(),mins.y(),maxs.z()),
+							t*btVector3(maxs.x(),mins.y(),maxs.z()),
+							t*btVector3(maxs.x(),maxs.y(),maxs.z()),
+							t*btVector3(mins.x(),maxs.y(),maxs.z())};
+	aabbMin=aabbMax=crns[0];
+	for(int i=1;i<8;++i)
+		{
+		aabbMin.setMin(crns[i]);
+		aabbMax.setMax(crns[i]);
+		}
+	}
+
+	
+	virtual void	setLocalScaling(const btVector3& /*scaling*/)
+	{		
+		///na
+	}
+	virtual const btVector3& getLocalScaling() const
+	{
+	static const btVector3 dummy(1,1,1);
+	return dummy;
+	}
+	virtual void	calculateLocalInertia(btScalar /*mass*/,btVector3& /*inertia*/) const
+	{
+		///not yet
+		btAssert(0);
+	}
+	virtual const char*	getName()const
+	{
+		return "SoftBody";
+	}
+
+};
+
+//
+// btSoftClusterCollisionShape
+//
+class btSoftClusterCollisionShape : public btConvexInternalShape
+{
+public:
+	const btSoftBody::Cluster*	m_cluster;
+
+	btSoftClusterCollisionShape (const btSoftBody::Cluster* cluster) : m_cluster(cluster) { setMargin(0); }
+	
+	
+	virtual btVector3	localGetSupportingVertex(const btVector3& vec) const
+		{
+		btSoftBody::Node* const *						n=&m_cluster->m_nodes[0];
+		btScalar										d=dot(vec,n[0]->m_x);
+		int												j=0;
+		for(int i=1,ni=m_cluster->m_nodes.size();i<ni;++i)
+			{
+			const btScalar	k=dot(vec,n[i]->m_x);
+			if(k>d) { d=k;j=i; }
+			}
+		return(n[j]->m_x);
+		}
+	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+		{
+		return(localGetSupportingVertex(vec));
+		}
+	//notice that the vectors should be unit length
+	virtual void	batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+	{}
+
+
+	virtual void	calculateLocalInertia(btScalar mass,btVector3& inertia) const
+	{}
+
+	virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+	{}
+
+	virtual int	getShapeType() const { return SOFTBODY_SHAPE_PROXYTYPE; }
+	
+	//debugging
+	virtual const char*	getName()const {return "SOFTCLUSTER";}
+
+	virtual void	setMargin(btScalar margin)
+	{
+		btConvexInternalShape::setMargin(margin);
+	}
+	virtual btScalar	getMargin() const
+	{
+		return getMargin();
+	}
+};
+
+//
+// Inline's
+//
+
+//
+template <typename T>
+static inline void			ZeroInitialize(T& value)
+{
+static const T	zerodummy;
+value=zerodummy;
+}
+//
+template <typename T>
+static inline bool			CompLess(const T& a,const T& b)
+{ return(a<b); }
+//
+template <typename T>
+static inline bool			CompGreater(const T& a,const T& b)
+{ return(a>b); }
+//
+template <typename T>
+static inline T				Lerp(const T& a,const T& b,btScalar t)
+{ return(a+(b-a)*t); }
+//
+template <typename T>
+static inline T				InvLerp(const T& a,const T& b,btScalar t)
+{ return((b+a*t-b*t)/(a*b)); }
+//
+static inline btMatrix3x3	Lerp(	const btMatrix3x3& a,
+									const btMatrix3x3& b,
+									btScalar t)
+{
+btMatrix3x3	r;
+r[0]=Lerp(a[0],b[0],t);
+r[1]=Lerp(a[1],b[1],t);
+r[2]=Lerp(a[2],b[2],t);
+return(r);
+}
+//
+static inline btVector3		Clamp(const btVector3& v,btScalar maxlength)
+{
+const btScalar sql=v.length2();
+if(sql>(maxlength*maxlength))
+	return((v*maxlength)/btSqrt(sql));
+	else
+	return(v);
+}
+//
+template <typename T>
+static inline T				Clamp(const T& x,const T& l,const T& h)
+{ return(x<l?l:x>h?h:x); }
+//
+template <typename T>
+static inline T				Sq(const T& x)
+{ return(x*x); }
+//
+template <typename T>
+static inline T				Cube(const T& x)
+{ return(x*x*x); }
+//
+template <typename T>
+static inline T				Sign(const T& x)
+{ return((T)(x<0?-1:+1)); }
+//
+template <typename T>
+static inline bool			SameSign(const T& x,const T& y)
+{ return((x*y)>0); }
+//
+static inline btScalar		ClusterMetric(const btVector3& x,const btVector3& y)
+{
+const btVector3	d=x-y;
+return(btFabs(d[0])+btFabs(d[1])+btFabs(d[2]));
+}
+//
+static inline btMatrix3x3	ScaleAlongAxis(const btVector3& a,btScalar s)
+{
+	const btScalar	xx=a.x()*a.x();
+	const btScalar	yy=a.y()*a.y();
+	const btScalar	zz=a.z()*a.z();
+	const btScalar	xy=a.x()*a.y();
+	const btScalar	yz=a.y()*a.z();
+	const btScalar	zx=a.z()*a.x();
+	btMatrix3x3		m;
+	m[0]=btVector3(1-xx+xx*s,xy*s-xy,zx*s-zx);
+	m[1]=btVector3(xy*s-xy,1-yy+yy*s,yz*s-yz);
+	m[2]=btVector3(zx*s-zx,yz*s-yz,1-zz+zz*s);
+	return(m);
+}
+//
+static inline btMatrix3x3	Cross(const btVector3& v)
+{
+	btMatrix3x3	m;
+	m[0]=btVector3(0,-v.z(),+v.y());
+	m[1]=btVector3(+v.z(),0,-v.x());
+	m[2]=btVector3(-v.y(),+v.x(),0);
+	return(m);
+}
+//
+static inline btMatrix3x3	Diagonal(btScalar x)
+{
+	btMatrix3x3	m;
+	m[0]=btVector3(x,0,0);
+	m[1]=btVector3(0,x,0);
+	m[2]=btVector3(0,0,x);
+	return(m);
+}
+//
+static inline btMatrix3x3	Add(const btMatrix3x3& a,
+	const btMatrix3x3& b)
+{
+	btMatrix3x3	r;
+	for(int i=0;i<3;++i) r[i]=a[i]+b[i];
+	return(r);
+}
+//
+static inline btMatrix3x3	Sub(const btMatrix3x3& a,
+	const btMatrix3x3& b)
+{
+	btMatrix3x3	r;
+	for(int i=0;i<3;++i) r[i]=a[i]-b[i];
+	return(r);
+}
+//
+static inline btMatrix3x3	Mul(const btMatrix3x3& a,
+	btScalar b)
+{
+	btMatrix3x3	r;
+	for(int i=0;i<3;++i) r[i]=a[i]*b;
+	return(r);
+}
+//
+static inline void			Orthogonalize(btMatrix3x3& m)
+{
+m[2]=cross(m[0],m[1]).normalized();
+m[1]=cross(m[2],m[0]).normalized();
+m[0]=cross(m[1],m[2]).normalized();
+}
+//
+static inline btMatrix3x3	MassMatrix(btScalar im,const btMatrix3x3& iwi,const btVector3& r)
+{
+	const btMatrix3x3	cr=Cross(r);
+	return(Sub(Diagonal(im),cr*iwi*cr));
+}
+
+//
+static inline btMatrix3x3	ImpulseMatrix(	btScalar dt,
+	btScalar ima,
+	btScalar imb,
+	const btMatrix3x3& iwi,
+	const btVector3& r)
+{
+	return(Diagonal(1/dt)*Add(Diagonal(ima),MassMatrix(imb,iwi,r)).inverse());
+}
+
+//
+static inline btMatrix3x3	ImpulseMatrix(	btScalar ima,const btMatrix3x3& iia,const btVector3& ra,
+											btScalar imb,const btMatrix3x3& iib,const btVector3& rb)	
+{
+return(Add(MassMatrix(ima,iia,ra),MassMatrix(imb,iib,rb)).inverse());
+}
+
+//
+static inline btMatrix3x3	AngularImpulseMatrix(	const btMatrix3x3& iia,
+													const btMatrix3x3& iib)
+{
+return(Add(iia,iib).inverse());
+}
+
+//
+static inline btVector3		ProjectOnAxis(	const btVector3& v,
+	const btVector3& a)
+{
+	return(a*dot(v,a));
+}
+//
+static inline btVector3		ProjectOnPlane(	const btVector3& v,
+	const btVector3& a)
+{
+	return(v-ProjectOnAxis(v,a));
+}
+
+//
+static inline void			ProjectOrigin(	const btVector3& a,
+											const btVector3& b,
+											btVector3& prj,
+											btScalar& sqd)
+{
+const btVector3	d=b-a;
+const btScalar	m2=d.length2();
+if(m2>SIMD_EPSILON)
+	{	
+	const btScalar	t=Clamp<btScalar>(-dot(a,d)/m2,0,1);
+	const btVector3	p=a+d*t;
+	const btScalar	l2=p.length2();
+	if(l2<sqd)
+		{
+		prj=p;
+		sqd=l2;
+		}
+	}
+}
+//
+static inline void			ProjectOrigin(	const btVector3& a,
+											const btVector3& b,
+											const btVector3& c,
+											btVector3& prj,
+											btScalar& sqd)
+{
+const btVector3&	q=cross(b-a,c-a);
+const btScalar		m2=q.length2();
+if(m2>SIMD_EPSILON)
+	{
+	const btVector3	n=q/btSqrt(m2);
+	const btScalar	k=dot(a,n);
+	const btScalar	k2=k*k;
+	if(k2<sqd)
+		{
+		const btVector3	p=n*k;
+		if(	(dot(cross(a-p,b-p),q)>0)&&
+			(dot(cross(b-p,c-p),q)>0)&&
+			(dot(cross(c-p,a-p),q)>0))
+			{			
+			prj=p;
+			sqd=k2;
+			}
+			else
+			{
+			ProjectOrigin(a,b,prj,sqd);
+			ProjectOrigin(b,c,prj,sqd);
+			ProjectOrigin(c,a,prj,sqd);
+			}
+		}
+	}
+}
+
+//
+template <typename T>
+static inline T				BaryEval(		const T& a,
+											const T& b,
+											const T& c,
+											const btVector3& coord)
+{
+	return(a*coord.x()+b*coord.y()+c*coord.z());
+}
+//
+static inline btVector3		BaryCoord(	const btVector3& a,
+										const btVector3& b,
+										const btVector3& c,
+										const btVector3& p)
+{
+const btScalar	w[]={	cross(a-p,b-p).length(),
+						cross(b-p,c-p).length(),
+						cross(c-p,a-p).length()};
+const btScalar	isum=1/(w[0]+w[1]+w[2]);
+return(btVector3(w[1]*isum,w[2]*isum,w[0]*isum));
+}
+
+//
+static btScalar				ImplicitSolve(	btSoftBody::ImplicitFn* fn,
+											const btVector3& a,
+											const btVector3& b,
+											const btScalar accuracy,
+											const int maxiterations=256)
+{
+btScalar	span[2]={0,1};
+btScalar	values[2]={fn->Eval(a),fn->Eval(b)};
+if(values[0]>values[1])
+	{
+	btSwap(span[0],span[1]);
+	btSwap(values[0],values[1]);
+	}
+if(values[0]>-accuracy) return(-1);
+if(values[1]<+accuracy) return(-1);
+for(int i=0;i<maxiterations;++i)
+	{
+	const btScalar	t=Lerp(span[0],span[1],values[0]/(values[0]-values[1]));
+	const btScalar	v=fn->Eval(Lerp(a,b,t));
+	if((t<=0)||(t>=1))		break;
+	if(btFabs(v)<accuracy)	return(t);
+	if(v<0)
+		{ span[0]=t;values[0]=v; }
+		else
+		{ span[1]=t;values[1]=v; }
+	}
+return(-1);
+}
+
+//
+static inline btVector3		NormalizeAny(const btVector3& v)
+{
+	const btScalar l=v.length();
+	if(l>SIMD_EPSILON)
+		return(v/l);
+	else
+		return(btVector3(0,0,0));
+}
+
+//
+static inline btDbvtVolume	VolumeOf(	const btSoftBody::Face& f,
+										btScalar margin)
+{
+const btVector3*	pts[]={	&f.m_n[0]->m_x,
+							&f.m_n[1]->m_x,
+							&f.m_n[2]->m_x};
+btDbvtVolume		vol=btDbvtVolume::FromPoints(pts,3);
+vol.Expand(btVector3(margin,margin,margin));
+return(vol);
+}
+
+//
+static inline btVector3			CenterOf(	const btSoftBody::Face& f)
+{
+return((f.m_n[0]->m_x+f.m_n[1]->m_x+f.m_n[2]->m_x)/3);
+}
+
+//
+static inline btScalar			AreaOf(		const btVector3& x0,
+											const btVector3& x1,
+											const btVector3& x2)
+{
+	const btVector3	a=x1-x0;
+	const btVector3	b=x2-x0;
+	const btVector3	cr=cross(a,b);
+	const btScalar	area=cr.length();
+	return(area);
+}
+
+//
+static inline btScalar		VolumeOf(	const btVector3& x0,
+										const btVector3& x1,
+										const btVector3& x2,
+										const btVector3& x3)
+{
+	const btVector3	a=x1-x0;
+	const btVector3	b=x2-x0;
+	const btVector3	c=x3-x0;
+	return(dot(a,cross(b,c)));
+}
+
+//
+static void					EvaluateMedium(	const btSoftBodyWorldInfo* wfi,
+											const btVector3& x,
+											btSoftBody::sMedium& medium)
+{
+	medium.m_velocity	=	btVector3(0,0,0);
+	medium.m_pressure	=	0;
+	medium.m_density	=	wfi->air_density;
+	if(wfi->water_density>0)
+	{
+		const btScalar	depth=-(dot(x,wfi->water_normal)+wfi->water_offset);
+		if(depth>0)
+		{
+			medium.m_density	=	wfi->water_density;
+			medium.m_pressure	=	depth*wfi->water_density*wfi->m_gravity.length();
+		}
+	}
+}
+
+//
+static inline void			ApplyClampedForce(	btSoftBody::Node& n,
+												const btVector3& f,
+												btScalar dt)
+{
+	const btScalar	dtim=dt*n.m_im;
+	if((f*dtim).length2()>n.m_v.length2())
+	{/* Clamp	*/ 
+		n.m_f-=ProjectOnAxis(n.m_v,f.normalized())/dtim;						
+	}
+	else
+	{/* Apply	*/ 
+		n.m_f+=f;
+	}
+}
+
+//
+static inline int		MatchEdge(	const btSoftBody::Node* a,
+									const btSoftBody::Node* b,
+									const btSoftBody::Node* ma,
+									const btSoftBody::Node* mb)
+{
+if((a==ma)&&(b==mb)) return(0);
+if((a==mb)&&(b==ma)) return(1);
+return(-1);
+}
+
+//
+// btEigen : Extract eigen system,
+// straitforward implementation of http://math.fullerton.edu/mathews/n2003/JacobiMethodMod.html
+// outputs are NOT sorted.
+//
+struct	btEigen
+{
+static int			system(btMatrix3x3& a,btMatrix3x3* vectors,btVector3* values=0)
+	{
+	static const int		maxiterations=16;
+	static const btScalar	accuracy=(btScalar)0.0001;
+	btMatrix3x3&			v=*vectors;
+	int						iterations=0;
+	vectors->setIdentity();
+	do	{
+		int				p=0,q=1;
+		if(btFabs(a[p][q])<btFabs(a[0][2])) { p=0;q=2; }
+		if(btFabs(a[p][q])<btFabs(a[1][2])) { p=1;q=2; }
+		if(btFabs(a[p][q])>accuracy)
+			{
+			const btScalar	w=(a[q][q]-a[p][p])/(2*a[p][q]);
+			const btScalar	z=btFabs(w);
+			const btScalar	t=w/(z*(btSqrt(1+w*w)+z));
+			if(t==t)/* [WARNING] let hope that one does not get thrown aways by some compilers... */ 
+				{
+				const btScalar	c=1/btSqrt(t*t+1);
+				const btScalar	s=c*t;
+				mulPQ(a,c,s,p,q);
+				mulTPQ(a,c,s,p,q);
+				mulPQ(v,c,s,p,q);
+				} else break;
+			} else break;
+		} while((++iterations)<maxiterations);
+	if(values)
+		{
+		*values=btVector3(a[0][0],a[1][1],a[2][2]);
+		}
+	return(iterations);
+	}
+private:
+static inline void	mulTPQ(btMatrix3x3& a,btScalar c,btScalar s,int p,int q)
+	{
+	const btScalar	m[2][3]={	{a[p][0],a[p][1],a[p][2]},
+								{a[q][0],a[q][1],a[q][2]}};
+	int i;
+
+	for(i=0;i<3;++i) a[p][i]=c*m[0][i]-s*m[1][i];
+	for(i=0;i<3;++i) a[q][i]=c*m[1][i]+s*m[0][i];
+	}
+static inline void	mulPQ(btMatrix3x3& a,btScalar c,btScalar s,int p,int q)
+	{
+	const btScalar	m[2][3]={	{a[0][p],a[1][p],a[2][p]},
+								{a[0][q],a[1][q],a[2][q]}};
+	int i;
+
+	for(i=0;i<3;++i) a[i][p]=c*m[0][i]-s*m[1][i];
+	for(i=0;i<3;++i) a[i][q]=c*m[1][i]+s*m[0][i];
+	}
+};
+
+//
+// Polar decomposition,
+// "Computing the Polar Decomposition with Applications", Nicholas J. Higham, 1986.
+//
+static inline int			PolarDecompose(	const btMatrix3x3& m,btMatrix3x3& q,btMatrix3x3& s)
+{
+	static const btScalar	half=(btScalar)0.5;
+	static const btScalar	accuracy=(btScalar)0.0001;
+	static const int		maxiterations=16;
+	int						i=0;
+	btScalar				det=0;
+	q	=	Mul(m,1/btVector3(m[0][0],m[1][1],m[2][2]).length());
+	det	=	q.determinant();
+	if(!btFuzzyZero(det))
+	{
+		for(;i<maxiterations;++i)
+		{
+			q=Mul(Add(q,Mul(q.adjoint(),1/det).transpose()),half);
+			const btScalar	ndet=q.determinant();
+			if(Sq(ndet-det)>accuracy) det=ndet; else break;
+		}
+		/* Final orthogonalization	*/ 
+		Orthogonalize(q);
+		/* Compute 'S'				*/ 
+		s=q.transpose()*m;
+	}
+	else
+	{
+		q.setIdentity();
+		s.setIdentity();
+	}
+return(i);
+}
+
+//
+// btSoftColliders
+//
+struct btSoftColliders
+{
+	//
+	// ClusterBase
+	//
+	struct	ClusterBase : btDbvt::ICollide
+	{
+	btScalar			erp;
+	btScalar			idt;
+	btScalar			margin;
+	btScalar			friction;
+	btScalar			threshold;
+					ClusterBase()
+		{
+		erp			=(btScalar)1;
+		idt			=0;
+		margin		=0;
+		friction	=0;
+		threshold	=(btScalar)0;
+		}
+	bool				SolveContact(	const btGjkEpaSolver2::sResults& res,
+										btSoftBody::Body ba,btSoftBody::Body bb,
+										btSoftBody::CJoint& joint)
+		{
+		if(res.distance<margin)
+			{
+			const btVector3		ra=res.witnesses[0]-ba.xform().getOrigin();
+			const btVector3		rb=res.witnesses[1]-bb.xform().getOrigin();
+			const btVector3		va=ba.velocity(ra);
+			const btVector3		vb=bb.velocity(rb);
+			const btVector3		vrel=va-vb;
+			const btScalar		rvac=dot(vrel,res.normal);
+			const btScalar		depth=res.distance-margin;
+			const btVector3		iv=res.normal*rvac;
+			const btVector3		fv=vrel-iv;
+			joint.m_bodies[0]	=	ba;
+			joint.m_bodies[1]	=	bb;
+			joint.m_refs[0]		=	ra*ba.xform().getBasis();
+			joint.m_refs[1]		=	rb*bb.xform().getBasis();
+			joint.m_rpos[0]		=	ra;
+			joint.m_rpos[1]		=	rb;
+			joint.m_cfm			=	1;
+			joint.m_erp			=	1;
+			joint.m_life		=	0;
+			joint.m_maxlife		=	0;
+			joint.m_split		=	1;
+			joint.m_drift		=	depth*res.normal;
+			joint.m_normal		=	res.normal;
+			joint.m_delete		=	false;
+			joint.m_friction	=	fv.length2()<(-rvac*friction)?1:friction;
+			joint.m_massmatrix	=	ImpulseMatrix(	ba.invMass(),ba.invWorldInertia(),joint.m_rpos[0],
+													bb.invMass(),bb.invWorldInertia(),joint.m_rpos[1]);
+			return(true);
+			}
+		return(false);
+		}
+	};
+	//
+	// CollideCL_RS
+	//
+	struct	CollideCL_RS : ClusterBase
+	{
+	btSoftBody*		psb;
+	btRigidBody*	prb;
+	void		Process(const btDbvtNode* leaf)
+		{
+		btSoftBody::Cluster*		cluster=(btSoftBody::Cluster*)leaf->data;
+		btSoftClusterCollisionShape	cshape(cluster);
+		const btConvexShape*		rshape=(const btConvexShape*)prb->getCollisionShape();
+		btGjkEpaSolver2::sResults	res;		
+		if(btGjkEpaSolver2::SignedDistance(	&cshape,btTransform::getIdentity(),
+											rshape,prb->getInterpolationWorldTransform(),
+											btVector3(1,0,0),res))
+			{
+			btSoftBody::CJoint	joint;
+			if(SolveContact(res,cluster,prb,joint))
+				{
+				btSoftBody::CJoint*	pj=new(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint();
+				*pj=joint;psb->m_joints.push_back(pj);
+				if(prb->isStaticOrKinematicObject())
+					{
+					pj->m_erp	*=	psb->m_cfg.kSKHR_CL;
+					pj->m_split	*=	psb->m_cfg.kSK_SPLT_CL;
+					}
+					else
+					{
+					pj->m_erp	*=	psb->m_cfg.kSRHR_CL;
+					pj->m_split	*=	psb->m_cfg.kSR_SPLT_CL;
+					}
+				}
+			}
+		}
+	void		Process(btSoftBody* ps,btRigidBody* pr)
+		{
+		psb			=	ps;
+		prb			=	pr;
+		idt			=	ps->m_sst.isdt;
+		margin		=	ps->getCollisionShape()->getMargin()+
+						pr->getCollisionShape()->getMargin();
+		friction	=	btMin(psb->m_cfg.kDF,prb->getFriction());
+		btVector3			mins;
+		btVector3			maxs;
+		
+		ATTRIBUTE_ALIGNED16(btDbvtVolume)		volume;
+		pr->getCollisionShape()->getAabb(pr->getInterpolationWorldTransform(),mins,maxs);
+		volume=btDbvtVolume::FromMM(mins,maxs);
+		volume.Expand(btVector3(1,1,1)*margin);
+		btDbvt::collideTV(ps->m_cdbvt.m_root,volume,*this);
+		}	
+	};
+	//
+	// CollideCL_SS
+	//
+	struct	CollideCL_SS : ClusterBase
+	{
+	btSoftBody*	bodies[2];
+	void		Process(const btDbvtNode* la,const btDbvtNode* lb)
+		{
+		btSoftBody::Cluster*		cla=(btSoftBody::Cluster*)la->data;
+		btSoftBody::Cluster*		clb=(btSoftBody::Cluster*)lb->data;
+		btSoftClusterCollisionShape	csa(cla);
+		btSoftClusterCollisionShape	csb(clb);
+		btGjkEpaSolver2::sResults	res;		
+		if(btGjkEpaSolver2::SignedDistance(	&csa,btTransform::getIdentity(),
+											&csb,btTransform::getIdentity(),
+											cla->m_com-clb->m_com,res))
+			{
+			btSoftBody::CJoint	joint;
+			if(SolveContact(res,cla,clb,joint))
+				{
+				btSoftBody::CJoint*	pj=new(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint();
+				*pj=joint;bodies[0]->m_joints.push_back(pj);
+				pj->m_erp	*=	btMax(bodies[0]->m_cfg.kSSHR_CL,bodies[1]->m_cfg.kSSHR_CL);
+				pj->m_split	*=	(bodies[0]->m_cfg.kSS_SPLT_CL+bodies[1]->m_cfg.kSS_SPLT_CL)/2;
+				}
+			}
+		}
+	void		Process(btSoftBody* psa,btSoftBody* psb)
+		{
+		idt			=	psa->m_sst.isdt;
+		margin		=	(psa->getCollisionShape()->getMargin()+psb->getCollisionShape()->getMargin())/2;
+		friction	=	btMin(psa->m_cfg.kDF,psb->m_cfg.kDF);
+		bodies[0]	=	psa;
+		bodies[1]	=	psb;
+		btDbvt::collideTT(psa->m_cdbvt.m_root,psb->m_cdbvt.m_root,*this);
+		}	
+	};
+	//
+	// CollideSDF_RS
+	//
+	struct	CollideSDF_RS : btDbvt::ICollide
+	{
+	void		Process(const btDbvtNode* leaf)
+		{
+		btSoftBody::Node*	node=(btSoftBody::Node*)leaf->data;
+		DoNode(*node);
+		}
+	void		DoNode(btSoftBody::Node& n) const
+		{
+		const btScalar			m=n.m_im>0?dynmargin:stamargin;
+		btSoftBody::RContact	c;
+		if(	(!n.m_battach)&&
+			psb->checkContact(prb,n.m_x,m,c.m_cti))
+			{
+			const btScalar	ima=n.m_im;
+			const btScalar	imb=prb->getInvMass();
+			const btScalar	ms=ima+imb;
+			if(ms>0)
+				{
+				const btTransform&	wtr=prb->getInterpolationWorldTransform();
+				const btMatrix3x3&	iwi=prb->getInvInertiaTensorWorld();
+				const btVector3		ra=n.m_x-wtr.getOrigin();
+				const btVector3		va=prb->getVelocityInLocalPoint(ra)*psb->m_sst.sdt;
+				const btVector3		vb=n.m_x-n.m_q;	
+				const btVector3		vr=vb-va;
+				const btScalar		dn=dot(vr,c.m_cti.m_normal);
+				const btVector3		fv=vr-c.m_cti.m_normal*dn;
+				const btScalar		fc=psb->m_cfg.kDF*prb->getFriction();
+				c.m_node	=	&n;
+				c.m_c0		=	ImpulseMatrix(psb->m_sst.sdt,ima,imb,iwi,ra);
+				c.m_c1		=	ra;
+				c.m_c2		=	ima*psb->m_sst.sdt;
+				c.m_c3		=	fv.length2()<(btFabs(dn)*fc)?0:1-fc;
+				c.m_c4		=	prb->isStaticOrKinematicObject()?psb->m_cfg.kKHR:psb->m_cfg.kCHR;
+				psb->m_rcontacts.push_back(c);
+				prb->activate();
+				}
+			}
+		}
+	btSoftBody*		psb;
+	btRigidBody*	prb;
+	btScalar		dynmargin;
+	btScalar		stamargin;
+	};
+	//
+	// CollideVF_SS
+	//
+	struct	CollideVF_SS : btDbvt::ICollide
+	{
+	void		Process(const btDbvtNode* lnode,
+						const btDbvtNode* lface)
+		{
+		btSoftBody::Node*	node=(btSoftBody::Node*)lnode->data;
+		btSoftBody::Face*	face=(btSoftBody::Face*)lface->data;
+		btVector3			o=node->m_x;
+		btVector3			p;
+		btScalar			d=SIMD_INFINITY;
+		ProjectOrigin(	face->m_n[0]->m_x-o,
+						face->m_n[1]->m_x-o,
+						face->m_n[2]->m_x-o,
+						p,d);
+		const btScalar	m=mrg+(o-node->m_q).length()*2;
+		if(d<(m*m))
+			{
+			const btSoftBody::Node*	n[]={face->m_n[0],face->m_n[1],face->m_n[2]};
+			const btVector3			w=BaryCoord(n[0]->m_x,n[1]->m_x,n[2]->m_x,p+o);
+			const btScalar			ma=node->m_im;
+			btScalar				mb=BaryEval(n[0]->m_im,n[1]->m_im,n[2]->m_im,w);
+			if(	(n[0]->m_im<=0)||
+				(n[1]->m_im<=0)||
+				(n[2]->m_im<=0))
+				{
+				mb=0;
+				}
+			const btScalar	ms=ma+mb;
+			if(ms>0)
+				{
+				btSoftBody::SContact	c;
+				c.m_normal		=	p/-btSqrt(d);
+				c.m_margin		=	m;
+				c.m_node		=	node;
+				c.m_face		=	face;
+				c.m_weights		=	w;
+				c.m_friction	=	btMax(psb[0]->m_cfg.kDF,psb[1]->m_cfg.kDF);
+				c.m_cfm[0]		=	ma/ms*psb[0]->m_cfg.kSHR;
+				c.m_cfm[1]		=	mb/ms*psb[1]->m_cfg.kSHR;
+				psb[0]->m_scontacts.push_back(c);
+				}
+			}	
+		}
+	btSoftBody*		psb[2];
+	btScalar		mrg;
+	};
+};
+
+#endif //_BT_SOFT_BODY_INTERNALS_H
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp	(revision 2122)
@@ -0,0 +1,135 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSoftBodyRigidBodyCollisionConfiguration.h"
+#include "btSoftRigidCollisionAlgorithm.h"
+#include "btSoftBodyConcaveCollisionAlgorithm.h"
+#include "btSoftSoftCollisionAlgorithm.h"
+
+#include "LinearMath/btPoolAllocator.h"
+
+#define ENABLE_SOFTBODY_CONCAVE_COLLISIONS 1
+
+btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo)
+:btDefaultCollisionConfiguration(constructionInfo)
+{
+	void* mem;
+
+	mem = btAlignedAlloc(sizeof(btSoftSoftCollisionAlgorithm::CreateFunc),16);
+	m_softSoftCreateFunc = new(mem) btSoftSoftCollisionAlgorithm::CreateFunc;
+	
+	mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
+	m_softRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
+	
+	mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
+	m_swappedSoftRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
+	m_swappedSoftRigidConvexCreateFunc->m_swapped=true;
+
+#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS
+	mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
+	m_softRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::CreateFunc;
+	
+	mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
+	m_swappedSoftRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::SwappedCreateFunc;
+	m_swappedSoftRigidConcaveCreateFunc->m_swapped=true;
+#endif
+
+	//replace pool by a new one, with potential larger size
+	
+	if (m_ownsCollisionAlgorithmPool && m_collisionAlgorithmPool)
+	{
+		int curElemSize = m_collisionAlgorithmPool->getElementSize();
+		///calculate maximum element size, big enough to fit any collision algorithm in the memory pool
+		
+		
+		int maxSize0 = sizeof(btSoftSoftCollisionAlgorithm);
+		int maxSize1 = sizeof(btSoftRigidCollisionAlgorithm);
+		int maxSize2 = sizeof(btSoftBodyConcaveCollisionAlgorithm);
+
+		int	collisionAlgorithmMaxElementSize = btMax(maxSize0,maxSize1);
+		collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
+		if (collisionAlgorithmMaxElementSize > curElemSize)
+		{
+			btAlignedFree(m_collisionAlgorithmPool);
+			void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
+			m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
+		}
+	}
+
+
+
+
+}
+
+btSoftBodyRigidBodyCollisionConfiguration::~btSoftBodyRigidBodyCollisionConfiguration()
+{
+	m_softSoftCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree(	m_softSoftCreateFunc);
+
+	m_softRigidConvexCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree(	m_softRigidConvexCreateFunc);
+
+	m_swappedSoftRigidConvexCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree(	m_swappedSoftRigidConvexCreateFunc);
+
+#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS
+	m_softRigidConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree(	m_softRigidConcaveCreateFunc);
+
+	m_swappedSoftRigidConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
+	btAlignedFree(	m_swappedSoftRigidConcaveCreateFunc);
+#endif
+}
+	
+///creation of soft-soft and soft-rigid, and otherwise fallback to base class implementation
+btCollisionAlgorithmCreateFunc* btSoftBodyRigidBodyCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1)
+{
+
+	///try to handle the softbody interactions first
+
+	if ((proxyType0 == SOFTBODY_SHAPE_PROXYTYPE  ) && (proxyType1==SOFTBODY_SHAPE_PROXYTYPE))
+	{
+		return	m_softSoftCreateFunc;
+	}
+
+	///softbody versus convex
+	if (proxyType0 == SOFTBODY_SHAPE_PROXYTYPE  && btBroadphaseProxy::isConvex(proxyType1))
+	{
+		return	m_softRigidConvexCreateFunc;
+	}
+
+	///convex versus soft body
+	if (btBroadphaseProxy::isConvex(proxyType0) && proxyType1 == SOFTBODY_SHAPE_PROXYTYPE )
+	{
+		return	m_swappedSoftRigidConvexCreateFunc;
+	}
+
+#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS
+	///softbody versus convex
+	if (proxyType0 == SOFTBODY_SHAPE_PROXYTYPE  && btBroadphaseProxy::isConcave(proxyType1))
+	{
+		return	m_softRigidConcaveCreateFunc;
+	}
+
+	///convex versus soft body
+	if (btBroadphaseProxy::isConcave(proxyType0) && proxyType1 == SOFTBODY_SHAPE_PROXYTYPE )
+	{
+		return	m_swappedSoftRigidConcaveCreateFunc;
+	}
+#endif
+
+	///fallback to the regular rigid collision shape
+	return btDefaultCollisionConfiguration::getCollisionAlgorithmCreateFunc(proxyType0,proxyType1);
+}
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h	(revision 2122)
@@ -0,0 +1,48 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_SOFTBODY_RIGIDBODY_COLLISION_CONFIGURATION
+#define BT_SOFTBODY_RIGIDBODY_COLLISION_CONFIGURATION
+
+#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h"
+
+class btVoronoiSimplexSolver;
+class btGjkEpaPenetrationDepthSolver;
+
+
+///btSoftBodyRigidBodyCollisionConfiguration add softbody interaction on top of btDefaultCollisionConfiguration
+class	btSoftBodyRigidBodyCollisionConfiguration : public btDefaultCollisionConfiguration
+{
+
+	//default CreationFunctions, filling the m_doubleDispatch table
+	btCollisionAlgorithmCreateFunc*	m_softSoftCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_softRigidConvexCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_swappedSoftRigidConvexCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_softRigidConcaveCreateFunc;
+	btCollisionAlgorithmCreateFunc*	m_swappedSoftRigidConcaveCreateFunc;
+	
+public:
+
+	btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo());
+
+	virtual ~btSoftBodyRigidBodyCollisionConfiguration();
+
+	///creation of soft-soft and soft-rigid, and otherwise fallback to base class implementation
+	virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
+
+};
+
+#endif //BT_SOFTBODY_RIGIDBODY_COLLISION_CONFIGURATION
+
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSoftRigidCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "btSoftBody.h"
+///TODO: include all the shapes that the softbody can collide with
+///alternatively, implement special case collision algorithms (just like for rigid collision shapes)
+
+//#include <stdio.h>
+
+btSoftRigidCollisionAlgorithm::btSoftRigidCollisionAlgorithm(btPersistentManifold* /*mf*/,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* /*col0*/,btCollisionObject* /*col1*/, bool isSwapped)
+: btCollisionAlgorithm(ci),
+//m_ownManifold(false),
+//m_manifoldPtr(mf),
+m_isSwapped(isSwapped)
+{
+}
+
+
+btSoftRigidCollisionAlgorithm::~btSoftRigidCollisionAlgorithm()
+{
+	
+	//m_softBody->m_overlappingRigidBodies.remove(m_rigidCollisionObject);
+
+	/*if (m_ownManifold)
+	{
+		if (m_manifoldPtr)
+			m_dispatcher->releaseManifold(m_manifoldPtr);
+	}
+	*/
+
+}
+
+
+#include <stdio.h>
+
+void btSoftRigidCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)dispatchInfo;
+	(void)resultOut;
+	//printf("btSoftRigidCollisionAlgorithm\n");
+
+	btSoftBody* softBody =  m_isSwapped? (btSoftBody*)body1 : (btSoftBody*)body0;
+	btCollisionObject* rigidCollisionObject = m_isSwapped? body0 : body1;
+	
+	softBody->defaultCollisionHandler(rigidCollisionObject);
+
+
+}
+
+btScalar btSoftRigidCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+{
+	(void)resultOut;
+	(void)dispatchInfo;
+	(void)col0;
+	(void)col1;
+
+	//not yet
+	return btScalar(1.);
+}
+
+
+
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,75 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SOFT_RIGID_COLLISION_ALGORITHM_H
+#define SOFT_RIGID_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+class btPersistentManifold;
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+
+#include "LinearMath/btVector3.h"
+class btSoftBody;
+
+/// btSoftRigidCollisionAlgorithm  provides collision detection between btSoftBody and btRigidBody
+class btSoftRigidCollisionAlgorithm : public btCollisionAlgorithm
+{
+//	bool	m_ownManifold;
+//	btPersistentManifold*	m_manifoldPtr;
+
+	btSoftBody*				m_softBody;
+	btCollisionObject*		m_rigidCollisionObject;
+
+	///for rigid versus soft (instead of soft versus rigid), we use this swapped boolean
+	bool	m_isSwapped;
+	
+public:
+
+	btSoftRigidCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
+
+	virtual ~btSoftRigidCollisionAlgorithm();
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		//we don't add any manifolds
+	}
+
+	
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSoftRigidCollisionAlgorithm));
+			if (!m_swapped)
+			{
+				return new(mem) btSoftRigidCollisionAlgorithm(0,ci,body0,body1,false);
+			} else
+			{
+				return new(mem) btSoftRigidCollisionAlgorithm(0,ci,body0,body1,true);
+			}
+		}
+	};
+
+};
+
+#endif //SOFT_RIGID_COLLISION_ALGORITHM_H
+
+
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidDynamicsWorld.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidDynamicsWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidDynamicsWorld.cpp	(revision 2122)
@@ -0,0 +1,135 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#include "btSoftRigidDynamicsWorld.h"
+#include "LinearMath/btQuickprof.h"
+
+//softbody & helpers
+#include "btSoftBody.h"
+#include "btSoftBodyHelpers.h"
+
+
+
+
+
+btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
+:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration)
+{
+m_drawFlags			=	fDrawFlags::Std;
+m_drawNodeTree		=	true;
+m_drawFaceTree		=	false;
+m_drawClusterTree	=	false;
+m_sbi.m_broadphase = pairCache;
+m_sbi.m_dispatcher = dispatcher;
+m_sbi.m_sparsesdf.Initialize();
+m_sbi.m_sparsesdf.Reset();
+
+}
+		
+btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld()
+{
+
+}
+
+void	btSoftRigidDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
+{
+	btDiscreteDynamicsWorld::predictUnconstraintMotion( timeStep);
+
+	for ( int i=0;i<m_softBodies.size();++i)
+	{
+		btSoftBody*	psb= m_softBodies[i];
+
+		psb->predictMotion(timeStep);		
+	}
+}
+		
+void	btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
+{
+	btDiscreteDynamicsWorld::internalSingleStepSimulation( timeStep );
+
+	///solve soft bodies constraints
+	solveSoftBodiesConstraints();
+
+	///update soft bodies
+	updateSoftBodies();
+
+}
+
+void	btSoftRigidDynamicsWorld::updateSoftBodies()
+{
+	BT_PROFILE("updateSoftBodies");
+	
+	for ( int i=0;i<m_softBodies.size();i++)
+	{
+		btSoftBody*	psb=(btSoftBody*)m_softBodies[i];
+		psb->integrateMotion();	
+	}
+}
+
+void	btSoftRigidDynamicsWorld::solveSoftBodiesConstraints()
+{
+	BT_PROFILE("solveSoftConstraints");
+	
+	if(m_softBodies.size())
+		{
+		btSoftBody::solveClusters(m_softBodies);
+		}
+	
+	for(int i=0;i<m_softBodies.size();++i)
+	{
+		btSoftBody*	psb=(btSoftBody*)m_softBodies[i];
+		psb->solveConstraints();
+	}	
+}
+
+void	btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body)
+{
+	m_softBodies.push_back(body);
+
+	btCollisionWorld::addCollisionObject(body,
+					btBroadphaseProxy::DefaultFilter,
+					btBroadphaseProxy::AllFilter);
+
+}
+
+void	btSoftRigidDynamicsWorld::removeSoftBody(btSoftBody* body)
+{
+	m_softBodies.remove(body);
+
+	btCollisionWorld::removeCollisionObject(body);
+}
+
+void	btSoftRigidDynamicsWorld::debugDrawWorld()
+{
+	btDiscreteDynamicsWorld::debugDrawWorld();
+
+	if (getDebugDrawer())
+	{
+		int i;
+		for (  i=0;i<this->m_softBodies.size();i++)
+		{
+			btSoftBody*	psb=(btSoftBody*)this->m_softBodies[i];
+			btSoftBodyHelpers::DrawFrame(psb,m_debugDrawer);
+			btSoftBodyHelpers::Draw(psb,m_debugDrawer,m_drawFlags);
+			if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
+			{
+				if(m_drawNodeTree)		btSoftBodyHelpers::DrawNodeTree(psb,m_debugDrawer);
+				if(m_drawFaceTree)		btSoftBodyHelpers::DrawFaceTree(psb,m_debugDrawer);
+				if(m_drawClusterTree)	btSoftBodyHelpers::DrawClusterTree(psb,m_debugDrawer);
+			}
+		}		
+	}	
+}
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidDynamicsWorld.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidDynamicsWorld.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftRigidDynamicsWorld.h	(revision 2122)
@@ -0,0 +1,82 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_SOFT_RIGID_DYNAMICS_WORLD_H
+#define BT_SOFT_RIGID_DYNAMICS_WORLD_H
+
+#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
+#include "btSoftBody.h"
+
+typedef	btAlignedObjectArray<btSoftBody*> btSoftBodyArray;
+
+class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld
+{
+	
+	btSoftBodyArray	m_softBodies;
+	int				m_drawFlags;
+	bool			m_drawNodeTree;
+	bool			m_drawFaceTree;
+	bool			m_drawClusterTree;
+	btSoftBodyWorldInfo m_sbi;
+
+protected:
+	
+	virtual void	predictUnconstraintMotion(btScalar timeStep);
+	
+	virtual void	internalSingleStepSimulation( btScalar timeStep);
+
+	void	updateSoftBodies();
+
+	void	solveSoftBodiesConstraints();
+
+
+public:
+	
+	btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
+
+	virtual ~btSoftRigidDynamicsWorld();
+	
+	virtual void	debugDrawWorld();
+			
+	void	addSoftBody(btSoftBody* body);
+
+	void	removeSoftBody(btSoftBody* body);
+	
+	int		getDrawFlags() const { return(m_drawFlags); }
+	void	setDrawFlags(int f)	{ m_drawFlags=f; }
+
+	btSoftBodyWorldInfo&	getWorldInfo()
+	{
+		return m_sbi;
+	}
+	const btSoftBodyWorldInfo&	getWorldInfo() const
+	{
+		return m_sbi;
+	}
+
+			
+	btSoftBodyArray& getSoftBodyArray()
+	{
+		return m_softBodies;
+	}
+
+	const btSoftBodyArray& getSoftBodyArray() const
+	{
+		return m_softBodies;
+	}
+		
+};
+
+#endif //BT_SOFT_RIGID_DYNAMICS_WORLD_H
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp	(revision 2122)
@@ -0,0 +1,46 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btSoftSoftCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "btSoftBody.h"
+
+#define USE_PERSISTENT_CONTACTS 1
+
+btSoftSoftCollisionAlgorithm::btSoftSoftCollisionAlgorithm(btPersistentManifold* /*mf*/,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* /*obj0*/,btCollisionObject* /*obj1*/)
+: btCollisionAlgorithm(ci)
+//m_ownManifold(false),
+//m_manifoldPtr(mf)
+{
+}
+
+btSoftSoftCollisionAlgorithm::~btSoftSoftCollisionAlgorithm()
+{
+}
+
+void btSoftSoftCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/)
+{
+	btSoftBody* soft0 =	(btSoftBody*)body0;
+	btSoftBody* soft1 =	(btSoftBody*)body1;
+	soft0->defaultCollisionHandler(soft1);
+}
+
+btScalar btSoftSoftCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/,btCollisionObject* /*body1*/,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/)
+{
+	//not yet
+	return 1.f;
+}
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSoftSoftCollisionAlgorithm.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSoftSoftCollisionAlgorithm.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSoftSoftCollisionAlgorithm.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SOFT_SOFT_COLLISION_ALGORITHM_H
+#define SOFT_SOFT_COLLISION_ALGORITHM_H
+
+#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
+#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
+#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
+
+class btPersistentManifold;
+class btSoftBody;
+
+///collision detection between two btSoftBody shapes
+class btSoftSoftCollisionAlgorithm : public btCollisionAlgorithm
+{
+	bool	m_ownManifold;
+	btPersistentManifold*	m_manifoldPtr;
+
+	btSoftBody*	m_softBody0;
+	btSoftBody*	m_softBody1;
+
+	
+public:
+	btSoftSoftCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
+		: btCollisionAlgorithm(ci) {}
+
+	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+
+	virtual	void	getAllContactManifolds(btManifoldArray&	manifoldArray)
+	{
+		if (m_manifoldPtr && m_ownManifold)
+			manifoldArray.push_back(m_manifoldPtr);
+	}
+
+	btSoftSoftCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+
+	virtual ~btSoftSoftCollisionAlgorithm();
+
+	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
+	{
+		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+		{
+			int bbsize = sizeof(btSoftSoftCollisionAlgorithm);
+			void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
+			return new(ptr) btSoftSoftCollisionAlgorithm(0,ci,body0,body1);
+		}
+	};
+
+};
+
+#endif //SOFT_SOFT_COLLISION_ALGORITHM_H
+
+
Index: /code/branches/physics/src/bullet/BulletSoftBody/btSparseSDF.h
===================================================================
--- /code/branches/physics/src/bullet/BulletSoftBody/btSparseSDF.h	(revision 2122)
+++ /code/branches/physics/src/bullet/BulletSoftBody/btSparseSDF.h	(revision 2122)
@@ -0,0 +1,306 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+///btSparseSdf implementation by Nathanael Presson
+
+#ifndef _14F9D17F_EAE8_4aba_B41C_292DB2AA70F3_
+#define _14F9D17F_EAE8_4aba_B41C_292DB2AA70F3_
+
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
+
+// Modified Paul Hsieh hash
+template <const int DWORDLEN>
+unsigned int HsiehHash(const void* pdata)
+	{
+	const unsigned short*	data=(const unsigned short*)pdata;
+	unsigned				hash=DWORDLEN<<2,tmp;
+	for(int i=0;i<DWORDLEN;++i)
+		{
+		hash	+=	data[0];
+		tmp		=	(data[1]<<11)^hash;
+		hash	=	(hash<<16)^tmp;
+		data	+=	2;
+		hash	+=	hash>>11;
+		}
+	hash^=hash<<3;hash+=hash>>5;
+	hash^=hash<<4;hash+=hash>>17;
+	hash^=hash<<25;hash+=hash>>6;
+	return(hash);
+	}
+
+template <const int CELLSIZE>
+struct	btSparseSdf
+	{
+	//
+	// Inner types
+	//
+	struct IntFrac
+		{
+		int					b;
+		int					i;
+		btScalar			f;
+		};
+	struct	Cell
+		{
+		btScalar			d[CELLSIZE+1][CELLSIZE+1][CELLSIZE+1];
+		int					c[3];
+		int					puid;
+		unsigned			hash;
+		btCollisionShape*	pclient;
+		Cell*				next;
+		};
+	//
+	// Fields
+	//
+	
+	btAlignedObjectArray<Cell*>		cells;	
+	btScalar						voxelsz;
+	int								puid;
+	int								ncells;
+	int								nprobes;
+	int								nqueries;	
+	
+	//
+	// Methods
+	//
+	
+	//
+	void					Initialize(int hashsize=2383)
+		{
+		cells.resize(hashsize,0);
+		Reset();		
+		}
+	//
+	void					Reset()
+		{
+		for(int i=0,ni=cells.size();i<ni;++i)
+			{
+			Cell*	pc=cells[i];
+			cells[i]=0;
+			while(pc)
+				{
+				Cell*	pn=pc->next;
+				delete pc;
+				pc=pn;
+				}
+			}
+		voxelsz		=0.25;
+		puid		=0;
+		ncells		=0;
+		nprobes		=1;
+		nqueries	=1;
+		}
+	//
+	void					GarbageCollect(int lifetime=256)
+		{
+		const int life=puid-lifetime;
+		for(int i=0;i<cells.size();++i)
+			{
+			Cell*&	root=cells[i];
+			Cell*	pp=0;
+			Cell*	pc=root;
+			while(pc)
+				{
+				Cell*	pn=pc->next;
+				if(pc->puid<life)
+					{
+					if(pp) pp->next=pn; else root=pn;
+					delete pc;pc=pp;--ncells;
+					}
+				pp=pc;pc=pn;
+				}
+			}
+		//printf("GC[%d]: %d cells, PpQ: %f\r\n",puid,ncells,nprobes/(btScalar)nqueries);
+		nqueries=1;
+		nprobes=1;
+		++puid;	/* TODO: Reset puid's when int range limit is reached	*/ 
+				/* else setup a priority list...						*/ 
+		}
+	//
+	int						RemoveReferences(btCollisionShape* pcs)
+		{
+		int	refcount=0;
+		for(int i=0;i<cells.size();++i)
+			{
+			Cell*&	root=cells[i];
+			Cell*	pp=0;
+			Cell*	pc=root;
+			while(pc)
+				{
+				Cell*	pn=pc->next;
+				if(pc->pclient==pcs)
+					{
+					if(pp) pp->next=pn; else root=pn;
+					delete pc;pc=pp;++refcount;
+					}
+				pp=pc;pc=pn;
+				}
+			}
+		return(refcount);
+		}
+	//
+	btScalar				Evaluate(	const btVector3& x,
+										btCollisionShape* shape,
+										btVector3& normal,
+										btScalar margin)
+		{
+		/* Lookup cell			*/ 
+		const btVector3	scx=x/voxelsz;
+		const IntFrac	ix=Decompose(scx.x());
+		const IntFrac	iy=Decompose(scx.y());
+		const IntFrac	iz=Decompose(scx.z());
+		const unsigned	h=Hash(ix.b,iy.b,iz.b,shape);
+		Cell*&			root=cells[static_cast<int>(h%cells.size())];
+		Cell*			c=root;
+		++nqueries;
+		while(c)
+			{
+			++nprobes;
+			if(	(c->hash==h)	&&
+				(c->c[0]==ix.b)	&&
+				(c->c[1]==iy.b)	&&
+				(c->c[2]==iz.b)	&&
+				(c->pclient==shape))
+				{ break; }
+				else
+				{ c=c->next; }
+			}
+		if(!c)
+			{
+			++nprobes;		
+			++ncells;
+			c=new Cell();
+			c->next=root;root=c;
+			c->pclient=shape;
+			c->hash=h;
+			c->c[0]=ix.b;c->c[1]=iy.b;c->c[2]=iz.b;
+			BuildCell(*c);
+			}
+		c->puid=puid;
+		/* Extract infos		*/ 
+		const int		o[]={	ix.i,iy.i,iz.i};
+		const btScalar	d[]={	c->d[o[0]+0][o[1]+0][o[2]+0],
+								c->d[o[0]+1][o[1]+0][o[2]+0],
+								c->d[o[0]+1][o[1]+1][o[2]+0],
+								c->d[o[0]+0][o[1]+1][o[2]+0],
+								c->d[o[0]+0][o[1]+0][o[2]+1],
+								c->d[o[0]+1][o[1]+0][o[2]+1],
+								c->d[o[0]+1][o[1]+1][o[2]+1],
+								c->d[o[0]+0][o[1]+1][o[2]+1]};
+		/* Normal	*/ 
+		#if 1
+		const btScalar	gx[]={	d[1]-d[0],d[2]-d[3],
+								d[5]-d[4],d[6]-d[7]};
+		const btScalar	gy[]={	d[3]-d[0],d[2]-d[1],
+								d[7]-d[4],d[6]-d[5]};
+		const btScalar	gz[]={	d[4]-d[0],d[5]-d[1],
+								d[7]-d[3],d[6]-d[2]};
+		normal.setX(Lerp(	Lerp(gx[0],gx[1],iy.f),
+							Lerp(gx[2],gx[3],iy.f),iz.f));
+		normal.setY(Lerp(	Lerp(gy[0],gy[1],ix.f),
+							Lerp(gy[2],gy[3],ix.f),iz.f));
+		normal.setZ(Lerp(	Lerp(gz[0],gz[1],ix.f),
+							Lerp(gz[2],gz[3],ix.f),iy.f));
+		normal		=	normal.normalized();
+		#else
+		normal		=	btVector3(d[1]-d[0],d[3]-d[0],d[4]-d[0]).normalized();
+		#endif
+		/* Distance	*/ 
+		const btScalar	d0=Lerp(Lerp(d[0],d[1],ix.f),
+								Lerp(d[3],d[2],ix.f),iy.f);
+		const btScalar	d1=Lerp(Lerp(d[4],d[5],ix.f),
+								Lerp(d[7],d[6],ix.f),iy.f);
+		return(Lerp(d0,d1,iz.f)-margin);
+		}
+	//
+	void					BuildCell(Cell& c)
+		{
+		const btVector3	org=btVector3(	(btScalar)c.c[0],
+										(btScalar)c.c[1],
+										(btScalar)c.c[2])	*
+										CELLSIZE*voxelsz;
+		for(int k=0;k<=CELLSIZE;++k)
+			{
+			const btScalar	z=voxelsz*k+org.z();
+			for(int j=0;j<=CELLSIZE;++j)
+				{
+				const btScalar	y=voxelsz*j+org.y();
+				for(int i=0;i<=CELLSIZE;++i)
+					{
+					const btScalar	x=voxelsz*i+org.x();
+					c.d[i][j][k]=DistanceToShape(	btVector3(x,y,z),
+													c.pclient);
+					}
+				}
+			}
+		}
+	//
+	static inline btScalar	DistanceToShape(const btVector3& x,
+											btCollisionShape* shape)
+		{
+		btTransform	unit;
+		unit.setIdentity();
+		if(shape->isConvex())
+			{
+			btGjkEpaSolver2::sResults	res;
+			btConvexShape*				csh=static_cast<btConvexShape*>(shape);
+			return(btGjkEpaSolver2::SignedDistance(x,0,csh,unit,res));
+			}
+		return(0);
+		}
+	//
+	static inline IntFrac	Decompose(btScalar x)
+		{
+		/* That one need a lot of improvements...	*/
+		/* Remove test, faster floor...				*/ 
+		IntFrac			r;
+		x/=CELLSIZE;
+		const int		o=x<0?(int)(-x+1):0;
+		x+=o;r.b=(int)x;
+		const btScalar	k=(x-r.b)*CELLSIZE;
+		r.i=(int)k;r.f=k-r.i;r.b-=o;
+		return(r);
+		}
+	//
+	static inline btScalar	Lerp(btScalar a,btScalar b,btScalar t)
+		{
+		return(a+(b-a)*t);
+		}
+
+	
+
+	//
+	static inline unsigned int	Hash(int x,int y,int z,btCollisionShape* shape)
+		{
+		struct btS
+		{ 
+			int x,y,z;
+			void* p;
+		};
+
+		btS myset;
+		
+		myset.x=x;myset.y=y;myset.z=z;myset.p=shape;
+		const void* ptr = &myset;
+
+		unsigned int result = HsiehHash<sizeof(btS)/4> (ptr);
+		
+
+		return result;
+		}
+};
+	
+
+#endif
Index: /code/branches/physics/src/bullet/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/bullet/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/bullet/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,4 @@
+ADD_SUBDIRECTORY(BulletSoftBody)
+ADD_SUBDIRECTORY(BulletCollision)
+ADD_SUBDIRECTORY(BulletDynamics)
+ADD_SUBDIRECTORY(LinearMath)
Index: /code/branches/physics/src/bullet/ChangeLog
===================================================================
--- /code/branches/physics/src/bullet/ChangeLog	(revision 2122)
+++ /code/branches/physics/src/bullet/ChangeLog	(revision 2122)
@@ -0,0 +1,674 @@
+Bullet Continuous Collision Detection and Physics Library
+Primary author and maintainer: Erwin Coumans
+
+Todo: update changelog from April - July 2008
+See http://code.google.com/p/bullet/source/list for more complete log in Subversion
+
+
+2008 October 3
+	- Add support for autoconf automake
+	./autogen.sh and ./configure will create both Makefile and Jamfile. CMake and autogenerated Visual Studio projectfiles remain supported too.
+	- Improved ColladaConverter: plane shape export, and callback for shape construction to allow deletion of memory
+	
+2008 Sept 30
+	- Improved Soft Body support, fixed issues related to soft body colliding against concave triangle meshes
+	- Shared more code between regular version and SPU/BulletMultiThreaded, in particular GJK/EPA
+
+2008 Sept 28
+	- Fixed rotation issues in Dynamic Maya Plugin
+
+2008 Sept 11
+	- Enable CCD motion clamping for btDiscreteDynamicsWorld, to avoid tunneling. A more advanced solution will be implemented in btContinuousDynamicsWorld.
+
+2008 Sept 7
+	- Add btScaledBvhTriangleMeshShape, to allow re-use of btBvhTriangleMeshShape of different sizes, without copying of the BVH data.
+
+2008 Sept 5
+	- Enabled Demos/ForkLiftDemo
+	Thanks Roman Ponomarev.
+
+2008 Sept 4
+	- Added btCudaBroadphase in Extras/CUDA: some research into accelerating Bullet using CUDA.
+	Thanks to the particle demo from the NVidia CUDA SDK.
+	
+2008 Sept 3
+	- Several bug fixes and contributions related to inertia tensor, memory leaks etc.
+	Thanks to Ole K.
+
+2008 Sept 1
+	- Updated CDTestFramework, with latest version of OPCODE Array SAP. See Extras/CDTestFramework
+	Thanks to Pierre Terdiman for the update
+
+2008 August 25
+	- Walt Disney Studios contributes their in-house Maya Plugin for simulating Bullet physics, with options for other engines such as PhysBam or PhysX.
+	Thanks to Nicola Candussi and Arthur Shek
+	
+2008 August 14
+	- Improved performance for btDbvtBroadphase, based on dual dynamic AABB trees (one for static, one for dynamic objects, where objects can move from one to the other tree)
+	Thanks to Nathanael Presson again, for all his work.
+	
+2008 July 31
+	- Added Havok .hkx to COLLADA Physics .dae converter patch+information
+	- Fix btSubsimplexConvexCast
+	Thanks to Nacho, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2422)
+	- Fix in rendering, GL_STENCIL
+	- btTriangleIndexVertexArray indices should be unsigned int/unsigned short int,
+	- Made InternalProcessAllTriangles virtual, thanks to
+	Both thank to Fullmetalcoder, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2401
+	- clamp impulse for btPoint2PointConstraint
+	Thanks to Martijn Reuvers, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2418
+	- Free memory of bvh, pass in scaling factor (optional)
+	Thanks to Roy Eltham, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2375
+
+2008 July 27
+
+btDbvtBroadphase:
+	- Fixed a performance issues reported by 'reltham'
+	- Added btDbvtBroadphase::optimize() for people who want good performances right
+away or don't do dynamics.
+	- fixed compilation issues when DBVT_BP_PROFILE was set.
+btSoftBody:
+	- Fixed singular matrix issues related to polar decomposition (flat meshes).
+DemoApplication:
+	- Shadows (enable/disable through 'g' or DemoApplication::setShadows(bool)).
+	- Texture can be enable/disable through 'u'
+CDFramework:
+	- fixed compilation issues.
+	All thanks to Nathanael Presson
+
+2008 July 10
+	- Added btMultimaterialTriangleMeshShape and MultiMaterialDemo
+	Thanks to Alex Silverman for the contribution
+
+2008 June 30
+	- Added initial support for kinematic character controller
+	Thanks to John McCutchan
+
+2008 April 14
+	- Added ray cast support for Soft Bodies
+	Thanks to Nathanael Presson for the contribution
+	
+2008 April 9
+	- Cleanup of Stan Melax ConvexHull, removed Extras/ConvexHull, moved sources into LinearMath/BulletCollision
+
+2008 April 4
+	- Added btSliderConstraint and demo
+	Thanks Roman Ponomarev
+	
+2008 April 3
+	- Fixed btMinkowskiSumShape, and added hitpoint to btSubsimplexConvexCast
+
+2008 April 2
+	- Added Extras/CdTestFrameWork
+	Thanks Pierre Terdiman
+
+2008 April 1
+	- Added posix thread (pthread) support
+	Thanks Enrico
+
+2008 March 30
+	- Added Soft Body, cloth, rope and deformable volumes, including demos and interaction
+	Thanks Nathanael Presson for this great contribution
+	
+	2008 March 17
+	- Improved BulletColladaConverter
+	Thanks John McCutchan
+
+2008 March 15
+	- btMultiSapBroadphase in a working state. Needs more optimizations to be fully useable.
+	- Allow btOptimizedBvh to be used for arbitrary objects, not just triangles
+	- added quicksort to btAlignedObjectArray
+	- removed btTypedUserInfo, added btHashMap
+
+2008 March 30
+	- Moved quickstep solver and boxbox into Bullet/src folder
+	Thanks Russell L. Smith for permission to redistribute Open Dynamics Engine quickstep and box-box under the ZLib license	
+
+2008 Feb 27
+	- Added initial version for Character Control Demo
+	- Applied fixes to IBM Cell SDK 3.0 build makefiles
+	Thanks Jochen and mojo for reporting/providing patch: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1922
+
+2008 Feb 8
+	- Bugfixes in ConvexCast support against the world.
+	Thanks to Isgmasa for reporting/providing fix: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1823
+
+2008 Feb 6
+	- Added btCapsuleShapeX and btCapsuleShapeZ for capsules around X and Z axis (default capsule is around Y)
+	
+2008 Feb 3
+	- Added btTypedUserInfo, useful for serialization
+
+2008 Jan 31
+	- Add support for 16 and 32-bit indices for SPU / BulletMultiThreaded version.
+
+2008 Jan 29
+	- Added COLLADA Physics export/serialization/snapshot from any Bullet btDynamicsWorld. Saving the physics world into a text .xml file is useful for debugging etc.
+
+2008 Jan 23
+	- Added Stan Melax Convex Hull utility library in Extras/ConvexHull. This is useful to render non-polyhedral convex objects, and to simplify convex polyhedra.
+	
+2008 Jan 14
+	- Add support for batch raycasting on SPU / BulletMultiThreaded
+	
+2007 Dec 16
+	- Added btRigidBodyConstructionInfo, to make it easier to set individual setting (and leave other untouched) during rigid body construction.
+	Thanks Vangelis Kokkevis for pointing this out.
+	- Fixed memoryleak in the ConstraintDemo and Raytracer demo.
+	- Fixed issue with clearing forces/gravity at the end of the stepSimulation, instead of during internalSingleStepSimulation.
+	Thanks chunky for pointing this out: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1780
+	- Disabled additional damping in rigid body by default, but enable it in most demos. Set btRigidBodyConstructionInfo m_additionalDamping to true to enable this.
+	- Removed obsolete QUICKPROF BEGIN/END_PROFILE, and enabled BT_PROFILE. Profiling is enabled by default (see Bullet/Demos/OpenGL/DemoApplication.cpp how to use this).
+	User can switch off profiling by enabling define BT_NO_PROFILE in Bullet/src/btQuickprof.h.
+
+2007 Dec 14
+	- Added Hello World and BulletMultiThreaded demos
+	- Add portable version of BulletMultiThreaded, through SequentialThreadSupport (non-parallel but sharing the same code-path)
+	- Add Cmake support for AllBulletDemos
+	
+
+2007 Dec 11
+	- Moved the 'btRigidBody::clearForce' to the end of the stepSimulation, instead of in each substep.
+	See discussion http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1601
+	- Added btConvexPlaneCollisionAlgorithm, makes planes perform better, and prevents tunneling
+	Thanks Andy O'Neil for reporting the performance/functionality issue
+	- Fixes for IBM Cell SDK 3.0
+	Thanks to Jochen Roth for the patch.
+
+2007 Dec 10
+	- Fixes in btHeightfieldTerrainShape
+	Thanks to Jay Lee for the patch.
+
+2007	Dec 9
+	- Only update aabb of active objects
+	Thanks Peter Tchernev for reporting (http://bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1764 )
+	- Added workaround to compile libxml under Visual Studio 2008 Beta 2
+	- Make glui compile under MSVC 9.0 beta (vsnprintf is already defined)
+
+2007 Dec 6
+	- Added DynamicControlDemo, showing dynamic control through constraint motors
+		Thanks to Eddy Boxerman
+	- Add support for generic concave shapes for convex cast.
+	- Added convex cast query to collision world.
+	- Added workaround for OpenGL bug in Mac OS X 10.5.0 (Leopard)
+	- Added concave raycast demo
+		All above thanks to John McCutchan (JMC)
+	- Fixed issues that prevent Linux version to compile. 
+	Thanks to Enrico for reporting and patch, see
+	- Fixed misleading name 'numTriangleIndices' into 'numTriangles'
+	Thanks Sean Tasker for reporting:
+
+2007 Nov 28:
+	- Added raycast against trianglemesh. Will be extended to object cast soon.
+	Thanks John McCutchan (JMC)
+	- make getNumPoints const correct, add const getPoints(). 
+	Thanks Dirk Gregorius
+	- Bugfix: allow btCollisionObjects (non-btRigidBody) to interact properly with btRigidBody for cache-friendly btSequentialImpulseConstraintSolver.
+	Thanks Andy O'Neil for pointing this out.
+	- Bugfix: don't fail if spheres have identical center, use arbitrary separating normal (1,0,0)
+	Thanks Sean Tasker for reporting! http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1681
+
+
+2007, November 20
+	- Added hierarchical profiling
+	- Fixed memory leak in btMultiSapBroadphase,
+	- Fixed hash function (typo, should use 2 proxies)
+	Thanks to Stephen (shatcher) for reporting and fixes! http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1696
+
+2007 Nov 11
+	- Fixed parallel solver (BulletMultiThreaded) friction issue
+	- Terminate Win32 Threads when closing the CcdPhysicsDemo (when USE_PARALLEL_SOLVER/USE_PARALLEL_DISPATCHER is defined)
+
+2007 Nov 6
+	- Added support for 16-bit indices for triangle meshes
+	- Added support for multiple mesh parts using btBvhTriangleMeshShape.
+	Thanks to Tim Johansson
+	
+2007 Oct 22
+	- All memory allocations go through btAlignedAlloc/btAlignedFree. User can override this to verify memory leaks
+	- added a few more demos to AllBulletDemos
+	- fix for one of the constructors of btHingeConstraint
+	Thanks Marcus Hennix
+	
+2007 Oct 20
+	- included glui, a GLUT/OpenGL based toolkit for some graphical user elements
+	Removed dynamic_cast from glui, to allow linkage without rtti
+	- added Box2D framework using glui, allowing all demos to run within one executable
+	Thanks Erin Catto for the FrameWork skeleton (http://www.box2d.org)
+
+2007 Ocy 17
+	- Allow user to pass in their own memory (stack and pool) allocators, through collisionConfiguration. See demos how to use this
+
+2007 Oct 14
+	- Included working version of Cell SPU parallel optimized version for Libspe2 SPU task scheduler.
+	This version compiles and runs on Playstation 3 Linux and IBM CellBlade, see BulletSpuOptimized.pdf for build instructions
+	(Official Playstation 3 developers can request a SPURS version through Sony PS3 Devnet.)
+	Thanks to IBM 'Extreme Blue' project for the contribution
+	http://www-913.ibm.com/employment/us/extremeblue/ 
+	Thanks Minh Cuong Tran, Benjamin Hoeferlin, Frederick Roth and Martina Huellmann
+	for various contributions to get this initial Libspe2 parallel version up and running.
+
+2007 Oct 13
+	- made 'btCollisionShape::calculateLocalInertia' const
+	Thanks to cgripeos, see http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1514
+	- applied a large patch to remove warnings
+	Thanks to Enrico, see http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1568
+	- removed SSE includes, added #incude <string.h> for memset in Extras/quickstep, thanks Eternl Knight
+
+2007 Oct 11
+	- added Hashed Overlapping Pair Cache, recommended by Pierre Terdiman. It works like a charm, thanks Pierre and Erin Catto (code from Box2D)
+	- modified some margins inside btBoxShape, btCylinderShape and btSphereShape
+	- added cone debug rendering (for cones with x, y and z up-axis)
+	- added improvements for optional Extra/quickstep, thanks to Remotion
+	- some performance improvements for Bullet constraint solver
+
+2007 Sept 28
+	- upgraded GIMPACT to version 0.3
+	Thanks to Francisco Leon
+
+2007 Sept 27
+	- added contribution from IBM Extreme Blue project for Libspe2 support. This allow to execute BulletMultiThreaded on Cell SPU under PS3 Linux and Cell Blade. See http://www-913.ibm.com/employment/us/extremeblue
+	Thanks to Minh Cuong Tran, Frederick Roth, Martina Heullmann and Benjamin Hoeferlin.
+
+2007 Sept 13
+	- Improved btGenericD6Constraint. It can be used to create ragdolls (similar to the new btConeTwistConstraint). See GenericJointDemo
+	- Added support for Bullet constraints in the optional Extras/quickstep ODE solver. See CcdPhysicsDemo, enable #COMPARE_WITH_QUICKSTEP and add libquickstep to the dependencies.
+	For both patches/improvements thanks Francisco Leon/projectileman
+		
+2007 Sept 10
+	- removed union from btQuadWordStorage, it caused issues under certain version of gcc/Linux
+
+2007 Sept 10
+	- Reverted constraint solver, due to some issues. Need to review the recent memory allocation changes.
+	- Fixed issue with kinematic objects rotating at low speed: quaternion was de-normalized, passing value > 1 into acosf returns #IND00 invalid values
+	- 16 byte memory alignment for BVH serialization
+	- memory cleanup for btPoolAllocator
+
+2007 Sept 9
+	- Added serialization for BVH/btBvhTriangleMeshShape, including endian swapping. See ConcaveDemo for an example.
+	Thanks to Phil Knight for the contribution.
+	- Fixed issues related to stack allocator/compound collision algorithm
+	Thanks Proctoid, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=18&t=1460
+	- Increase some default memory pool settings, and added a fallback for the constraints solver to use heap memory
+	- Removed accidential testing code in btScalar.h related to operator new.	
+	- Enable btAxis3Sweep and bt32BitAxis3Sweep to be linked in at the same time, using template
+	
+2007 Sept 7
+	- Replaced several dynamic memory allocations by stack allocation and pool allocations
+	- Added branch-free quantized aabb bounding box overlap check, works better on Playstation 3 and XBox 360
+	Thanks to Phil Knight. Also see www.cellperformance.com for related articles
+	- Collision algorithms and settings for the memory/stack allocator can be done using btDefaultCollisionConfiguration
+	This is an API change. See demos how to modify existing implementations with a one-liner.
+	- Register several collision algorithms by default (sphere-sphere, sphere-box, sphere-triangle)
+	- Use other traveral method for BVH by default, this improves triangle mesh collision performance.
+	
+2007 Aug 31
+	- fixed MSVC 6 build
+	Thanks Proctoid, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1375
+	- fixed double precision build issues
+	Thanks Alex Silverman, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1434
+
+2007 Aug 24
+	- fixed bug in btMatrix3x3::transposeTimes(const btMatrix3x3& m) const. Luckily it wasn't used in core parts of the library (yet).
+	Thanks to Jay Lee
+	
+2007 Aug 15
+	- fixed bug in Extras/GIMPACT 0.2 related to moving triangle meshes
+	Thanks Thomas, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1368
+
+2007 Aug 14
+	- added parallel constraint solver. Works on Playstation 3 Cell SPU and multi core (Win Threads on PC and XBox 360).
+	  See Extras/BulletMultiThreaded for SpuSolverTask subfolder and SpuParallelSolver.cpp
+	  Thanks Marten Svanfeldt (Starbreeze Studios)	
+	- fixed some bugs related to parallel collision detection (Extras/BulletMultiThreaded)
+	  Thanks Marten Svanfeldt (Starbreeze Studios)	
+	
+2007 Aug 2
+	- added compound and concave-convex (swapped) case for BulletMultiThreaded collision detection, thanks to Marten Svanfeldt
+	- refactored broadphase and overlapping pair cache. This allows performance improvement by combining multiple broadphases. This helps add/remove of large batches of objects and large worlds. See also Pierre Terdiman forum topic:
+	http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
+
+
+2007 July 27
+	- added Ragdoll Demo
+		Thanks to Marten Svanfeldt (Starbreeze Studios)
+
+	- added Vector Math library for SIMD 3D graphics linear algebra (vector, matrix, quaternion)
+		See Bullet/Extras/vectormathlibrary
+		Supports SIMD SSE, PowerPC PPU and Cell SPU (including PS3 Linux and CellBlade), as well as generic portable scalar version
+		Will be used to improve BulletMultiThreaded performance
+		Open Sourced by Sony Computer Entertainment Inc. under the new BSD license
+	- added SIMD math library
+		4-way SIMD for common math functions like atan2f4, cosf4, floorf4, fabsf4, rsqrtf4 etc. Used by Vector Math library under PPU and SPU.
+		Supports PowerPC (PPU) and Cell SPU, including PS3 Linux and CellBlade.
+		See Bullet/Extras/simdmathlibrary
+		Open sourced by Sony Computer Entertainment Inc. under the new BSD license
+
+	
+2007 July 25
+	- added several patches: per-rigidbody sleeping threshold. added Assert to prevent deletion of rigidbody while constraints are still pointing at it
+		Thanks to Marten Svanfeldt (Starbreeze Studios)
+	
+2007 July 13
+	- fixed relative #include paths again. We can't use "../" relative paths: some compilers choke on it (it causes extreme long paths)
+		Within the libraries, we always need to start with "BulletCollision/" or "BulletDynamics/ or "LinearMath/"
+
+2007 July 10
+	- Updated Bullet User Manual
+
+2007 July 5
+	- added btConeTwistConstraint, especially useful for ragdolls. See Demos/RagdollDemo
+		Thanks to Marten Svanfeldt (Starbreeze Studios)
+
+2007 June 29
+	- btHeightfieldTerrainShape: Added heightfield support, with customizations
+	- Upgraded to GIMPACT 0.2, see Extras/GIMPACT and MovingConcaveDemo
+	- Several patches from Marten Svanfeldt (Starbreeze Studios)
+		Improved collision filtering (in broadphase and rigidbody)
+		Improved debug rendering
+		Allow to set collision filter group/mask in addRigidBody
+		
+		
+2007 June 15
+	- Changed btAlignedObjectArray to call copy constructor/replacement new for duplication, rather then assignment operator (operator=).
+
+2007 June 11
+	- Added multi-threading. Originally for Playstation 3 Cell SPU, but the same code can run using Win32 Threads using fake DMA transfers (memcpy)
+		Libspe2 support for Cell Blade / PS3 Linux is upcoming
+		See Extras/BulletMultiThreaded. Usage: replace btCollisionDispatcher by btSpuGatheringCollisionDispatcher
+
+	- Added managed Bullet library, entirely rewritten in C# for Windows and XBox 360 XNA
+		See Extras/BulletX
+		Thanks to KleMiX, aka Vsevolod Klementjev
+
+2007 May 31
+	- sign-bit went wrong in case of 32-bit broadphase, causing quantization problems. 
+		Thanks DevO for reporting.
+
+2007 May 23
+	- Fixed quantization problem for planar triangle meshes in btOptimizedBvh
+		Thanks Phil Knight for reporting and helping to fix this bug.
+		
+2007 May 20
+	- btAxisSweep3: Fixed a bug in btAxisSweep3 (sweep and prune) related to object removal. Only showed up when at least one btStaticPlaneShape was inserted.
+		Thanks tbp for more details on reproducing case.
+	- btAxisSweep3: Fixed issue with full 32bit precision btAxisSweep3 (define BP_USE_FIXEDPOINT_INT_32), it used only 0xffff/65536 for quantization instead of full integer space (0xffffffff)
+	- btRaycastVehicle: Added 'getForwardVector' and getCurrentSpeedKmHour utility functions
+	- Fixed local scaling issues (btConvexTriangleMeshShape, btBvhTriangleMeshShape, removed scaling from btMatrix3x3). 
+		Thanks Volker for reporting!
+	- Added second filename search, so that starting BspDemo and ConvexDecompositionDemo from within Visual Studio (without setting the starting path) still works
+
+2007 April 22
+	- Added braking functionality to btRaycastVehicle
+	- Removed tons of warnings, under MSVC 2005 compilation in -W4
+	
+2007 March 21
+	- Fixed issues: comma at end of enum causes errors for some compilers
+	- Fixed initialization bug in LocalRayResult (	m_localShapeInfo(localShapeInfo) )
+	
+2007 March 20
+	- Added refit tree to quantized stackless tree, and updated ConcaveDemo as example.
+	
+2007 March 17
+	- Added constraint solver optimizations, avoiding cross products during iterations, and gather rigidbody/constraint info in contiguous memory (btSolverBody/btSolverConstraint)
+	- These optimizations don't give large benefit yet, but it has good potential. Turned on by default. Can be switched off using solver->setSolverMode(SOLVER_RANDMIZE_ORDER).
+	- Enabled anti-jitter for rigid bodies. This is experimental, and can be switched off by setting a global (it is experimental so no proper interface) gJitterVelocityDampingFactor = 1.0;
+	- Fixed bug in islandmanifold.heapSort(btPersistentManifoldSortPredicate()); , thanks Noehrgel for reporting this (affected Sun Solaris)
+	
+2007 March 12
+	- Added compile-time toggle between on 16-bit and 32-bit fixed-point SAP broadphase. 
+		This allows the number of bodies to exceed 32767
+	- Enable useQuantizedAabbCompression on btTriangleMesh, see ColladaDemo
+	
+2007 March 8
+	- Fixed bug in constraint/island sorting (caused by replacing STL by dedicated btAlignedObjectArray with heapSort)
+		Thanks Clemens Unterkofler for pointing this out!
+
+2007 March 6
+	- removed STL from the Bullet library: replace std::vector by btAlignedObjectArray. Also removed the std::set for overlapping pair set, and turned it into an overlapping pair array. The SAP only adds objects, never removed. Removal is postponed for during traversal of overlapping pairs (duplicates and non-overlapping pairs are removed during that traversal).
+	- added heap sort and binary search/linear search to btAlignedObjectArray
+	- fixed wrong cast, thanks Hamstray, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1015
+
+
+2007 Feb 25
+	- Improved performance of convex collision shapes, cache local AABB instead of recomputation. This fixes issue with very slow performance in larger .bsp levels
+	
+2007 Feb 24
+	- Added compressed/quantized AABB tree, 16 bytes per node, while supporting 32-bit (triangle) indices. 
+	  Should be faster and smaller then original version (quantized aabb check is done in integer space)
+		Original aabb tree nodes are still supported. They are 44 bytes, with full floating point precision and additional subPart index.
+	- added meter-unit scaling support in ColladaConverter.cpp
+
+2007 Feb 21
+	- Build system: updated bullet.pc.in library names
+	- Updated EPA comparison integration (missing parameter)
+	
+2007 Jan 04
+	- fixed optimized AABB tree building: in some cases the tree building fails due to unbalanced trees, which generated stack overflow
+	
+2006 Dec 15
+	- added contribution to allow double precision collision detection/dynamics. Define BT_USE_DOUBLE_PRECISION in your project and libraries that include Bullet
+
+2006 Dec 14
+	- merged contact and non-contact constraint solving into one loop, will improve stability of jointed bodies during collisions
+	- added first draft for hingeConstraint motor
+	
+2006 Dec 8, Erwin Coumans
+	- preparation for SIMD: added btAlignedAllocator and btAlignedObjectArray, to replace stl std::vector, same interface, but compatible with 16 byte alignment
+	- cleaned up dependencies in autogenerated msvc projectfiles
+	- aligned btVector3 on 16 bytes boundary, under win32. see if developers will come up with problems
+
+2006 Dec 04, Erwin Coumans
+	Added btNearCallback. This is similar to Open Dynamics Engine (ODE) dNearCallback, but important differences:
+	- contact points are persistent (lifetime more then one frame, for warmstarting/incremental contact point management)
+	- continuous collision detection, time of impact
+	Added btRigidBody::isInWorld(), returns true if btRigidBody is inside a btCollisionWorld/btDynamicsWorld derived class
+	Added angularFactor to btRigidbody, this helps some character control (no angular impulse applied)
+
+
+2006 Nov 28
+	Moved StackAlloc from EPA into LinearMath/btStackAlloc
+	renamed internal class ConcaveShape into btConcaveShape
+	added btHeightfieldTerrainShape (not completed yet)
+		
+2006 Nov 15 Nathanael Presson
+	Added EPA penetration depth algorithm, Expanding Polytope Algorithm
+	Added Pierre Terdiman penetration depth comparison/test DEMO
+	Fixed Bullet's Minkowski sampling penetration depth solver
+	Contributed by Nathanael Presson
+	
+2006 Nov 11 Francisco León Nájera
+	Added GIMPACT trimesh collision detection: concave versus concave,
+	Contributed by Francisco León Nájera
+
+2006 Nov 2
+	Minor refactoring: btCollisionObject changes from struct into class, added accessor methods
+	Force use of btMotionState to synchronize graphics transform, disabled old btRigidBody constructor that accepts btTransform
+	Renamed treshold into threshold throughout the code
+	
+2006 Oct 30
+	Enable decoupling of physics and graphics framerate using interpolation and internal fixed timestep, based on btMotionState
+	Enabled raycast vehicle demo (still needs tuning)
+	Refresh contact points, even when they are already persistent.
+	Fixed debugDraw colors (thanks pc0de for reporting)
+	Use Dispatcher in ConcaveConvexCollisionAlgorithm (so it uses the registered collision algorithm, not hardcoded convexconcave)
+	Improved performance of constraint solver by precalculating the cross product/impulse arm
+	Added collision comparison code: ODE box-box, also sphere-triangle
+	Added safety check into GJK, and an assert for AABB's that are very large
+	Fixed kinematic support (deriving velocities for animated objects)
+	Updated comparison/optional quickstep solver in Extras
+	UserCollisionAlgorithm demonstrates btTriangleMesh usage (easier trimesh compared to index array version)
+	Removed scaling from btTransform (we only want to deal with rigid transforms)
+	
+2006 Oct 4
+	Fixed minor leak in btOptimizeBVH
+	Cleanup of btRigidBody construction
+	added getW() in btQuaternion
+	assert when setLinearVelocity is called on btRigidBody
+	renamed projectfile library from collada-dom to colladadom (to make VC6 happy)
+	
+2006 Sept 27
+	Big Refactoring: renamed and moved files, create a replacement for CcdPhysicsEnvironment/CcdPhysicsController.
+	All Bullet classes in LinearMath, BulletCollision and BulletDynamics start with bt, and methods start with lowercase.
+	Moved classes into src folder, which is the only include folder needed.
+	Added 2 headerfiles in src: btBulletCollisionCommon.h and btBulletDynamicsCommon.h
+
+2006 Sept 23
+	Fixed 2 bugs, causing crashes when removing objects. Should do better unit-testing. UnionFind and 3D SAP were involved.
+	
+2006 Sept 19
+	Allow programmable friction and contact solver model. User can register their own functions for several interaction types.
+	Improved performance, and removed hardcoded maximum overlaps (switched from C-array to stl::set)
+	
+2006 Sept 16
+	Added Bullet 2.0  User Manual
+	Allow registration of custom user collision algorithms
+
+2006 Sept 10
+	Started cleaning up demos
+	
+2006 Sept 4
+	Fixed concave collision bug (caused instability/missing collisions in meshes/compounds)
+	Fixed memoryleak in OptimizedBvh, added RayTestSingle to CollisionWorld
+	Prepared for VehicleDemo
+	Increased Performance (island generation for sleeping objects took too much time)
+	Better COLLADA 1.4.1 physics conformance in ColladaDemo
+
+2006 August 11
+	Added Quake BspDemo
+	Improved CCD for compound and non-convex objects
+
+2006 August 10
+	Added per-triangle material (friction/restitution) support for non-convex meshes. See ConcaveDemo for usage.
+
+2006 August 9
+	Added CMake support (see http://cmake.org)
+	This can autogenerate makefiles, projectfiles cross platform (including MacOS X Xcode )
+	Just run cmake . in the root folder and it will autogenerate build files
+	
+2006 July 26 Erwin Coumans
+	Upgraded to COLLADA-DOM 1.4.1, latest SVN version
+	ColladaDemo can export snapshots to .dae
+	
+2006 July 24 Erwin Coumans
+	Added Compound CollisionShape support
+	(this is still low performance -> requires stackless tree-versus-tree traversal for better performance)
+
+2006 July 15 Erwin Coumans
+	Added initial support for Parallel execution (collision detection, constraint solving)
+	See ParallelPhysicsEnvironment in Extras\PhysicsInterface\CcdPhysics
+	
+2006 July 10 Erwin Coumans
+	Added MacOS X support (some build issues mainly)
+		
+2006 July 5 Erwin Coumans
+	Improved COLLADA 1.4 physics import, both COLLADA-DOM and FCollada
+
+2006 June 29 Erwin Coumans
+	Refactoring of the broadphase
+	Moved some optional files to Extras: Algebraic ccd and EPA, quickstep
+	Moved the limits on bodies/overlap to 32k and 65k
+	
+2006 June 25 Erwin Coumans
+	Added basic Collision Filtering, during broadphase
+	Allow adding meshes to the TriangleIndexVertexArray,
+	(input for TriangleMeshShape) 
+	Preparation for CompoundShape
+
+2006 June 19 Erwin Coumans
+	Added support for COLLADA Physics Import.
+	Both jam and Visual Studio can compile ColladaDemo
+
+2006 June 18 Dirk Gregorius <dirk@dirkgregorius.de>
+	Started implementing Generic6DOF joint and setup basic interface
+
+
+2006 June 17 Frank Richter <resqu@gmx.ch>
+	Bumped version in configure.ac to 1.5.6 (assuming that "1.5f" is
+	  the next version released).
+	Updated files in mk/autoconf and mk/jam with copies from CS; fixes a 
+	  GLU detection issue on MinGW.
+	Set msvc/bullet_ico.ico as the default application icon.
+	Disabled exceptions for gcc builds.
+	Applied a patch from Michael D. Adams to fix a warning with gcc.
+2006 jUNE 16 Erwin Coumans
+	Constraints now merge simulation islands.
+
+2006 May 24
+	Improved GJK accuracy, fixed GjkConvexCast issue, thanks to ~MyXa~ for reporting
+	
+2006 May 19
+	Added restitution support
+	Moved out Friction and Dynamics info from ManifoldPoint (removed logical dependency)
+	Added a void* m_userPersistentData in ManifoldPoint.
+	Added a ContactDestroyedCallback, to allow user to handle destruction of m_userPersistentData
+
+2006 May 13
+	Fixed some bugs in friction / jacobian calculations. Reported by Dirk Gregorius. Thanks!
+
+2006 May 9
+	Fixed raycasting filtering
+	Moved repository to SVN at https://svn.sourceforge.net/svnroot/bullet
+		
+2006 April 27
+	Moved raycasting to CollisionWorld, to make it more generic
+	Added basic CCD option in the CcdCollisionDemo
+	Fixed 'noResponse' mode, for triggering rigidbodies (useful for Artificial Intelligence queries)
+	Improved Bullet/ODE sample (in Extras)
+		
+2006 April 10
+	Separating Axis Test (SAT) convex hull collision detector, contribution by Simon Hobbs
+	Added SIMD SSE Math classes (for above SAT)
+	Added Mouse picking in CcdPhysicsDemo
+	Improved penetration depth estimation in MinkowskiPenetrationDepthSolver, both accuracy and performance
+	Added Hinge constraint
+	Added quickprof profiling (see http://sourceforge.net/projects/quickprof )
+		
+2006 March 21 Frank Richter <resqu@gmx.ch>
+	Removed VC manifest files.
+	Removed superfluous "grpplugins" projects.
+
+2006 March 20 Erwin Coumans
+	Clamped the acculumated impulse rather then intermediate impulse (within the iteration)
+	Use the persistent contacts for reusing the impulse
+	Separated friction and normal solving for better stability
+	Decreased the default number of iterations of the constraint solver from 10 to 4
+
+2006 March 19 Frank Richter <resqu@gmx.ch>
+	Removed a couple of CSisms from the VC projects.
+	Fixed VC include & lib paths to go to the Addtional* options
+	  instead the command line arguments.
+	Added pkgconfig support.
+
+2006 March 14 Frank Richter <resqu@gmx.ch>
+	Added support for shipped GLUT on MinGW.
+	Fixed GLUT support on MinGW.
+
+2006 March 13 Frank Richter <resqu@gmx.ch>
+	Bolted on Jam-based build system.
+	Generated VC project files.
+	Fixed GCC warnings.
+	Fixed Linux build issues.
+
+2006 March 13
+Added 3D Sweep and Prune Broadphase Collision Detection, Contribution from Simon Hobbs.
+
+2006 March 2
+	Minor change in license to ZLib/LibPNG
+	This makes it legally a bit easier to deploy on Playstation 3
+	Prepared for more generic constraints, added ConstraintsDemo
+
+2006 Feb 23
+	Rearranged files and dependencies to allow for easier standalone Collision Detection without Bullet Dynamics.
+	See Demos/CollisionInterfaceDemo and Extras/ode/ode/test/test_BulletGjk.cpp for examples how to use.
+
+2005 August 6
+	Bullet 0.2 release with demos, sources, doxygen, draft manual
+
+2005 June 1
+	First public release of Bullet
+	
+
+... todo: add history
+
+2003 Initial version (continuous collision detection)
Index: /code/branches/physics/src/bullet/LICENSE
===================================================================
--- /code/branches/physics/src/bullet/LICENSE	(revision 2122)
+++ /code/branches/physics/src/bullet/LICENSE	(revision 2122)
@@ -0,0 +1,19 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+All files in the Bullet/src folder are under this Zlib license.
+Optional Extras/GIMPACT and Extras/GIMPACTBullet is also under ZLib license. Other optional external libraries in  Extras/Demos have own license,see respective files.
+
+This means Bullet can freely be used in any software, including commercial and console software. A Playstation 3 optimized version is available through Sony.
Index: /code/branches/physics/src/bullet/LinearMath/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,30 @@
+ADD_LIBRARY(LibLinearMath SHARED
+		btAlignedObjectArray.h
+		btList.h
+		btPoolAllocator.h
+		btRandom.h
+		btVector3.h
+		btDefaultMotionState.h
+		btMatrix3x3.h
+		btQuadWord.h
+		btHashMap.h
+		btScalar.h
+		btAabbUtil2.h
+		btConvexHull.h
+		btConvexHull.cpp
+		btMinMax.h
+		btQuaternion.h
+		btStackAlloc.h
+		btGeometryUtil.h
+		btMotionState.h
+		btTransform.h
+		btAlignedAllocator.h
+		btIDebugDraw.h
+		btPoint3.h
+		btQuickprof.h
+		btTransformUtil.h
+		btQuickprof.cpp
+		btGeometryUtil.cpp
+		btAlignedAllocator.cpp
+)
+
Index: /code/branches/physics/src/bullet/LinearMath/btAabbUtil2.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btAabbUtil2.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btAabbUtil2.h	(revision 2122)
@@ -0,0 +1,202 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef AABB_UTIL2
+#define AABB_UTIL2
+
+#include "btTransform.h"
+#include "btVector3.h"
+#include "btMinMax.h"
+
+SIMD_FORCE_INLINE void AabbExpand (btVector3& aabbMin,
+								   btVector3& aabbMax,
+								   const btVector3& expansionMin,
+								   const btVector3& expansionMax)
+{
+	aabbMin = aabbMin + expansionMin;
+	aabbMax = aabbMax + expansionMax;
+}
+
+
+/// conservative test for overlap between two aabbs
+SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1,
+								const btVector3 &aabbMin2, const btVector3 &aabbMax2)
+{
+	bool overlap = true;
+	overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
+	overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap;
+	overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap;
+	return overlap;
+}
+
+/// conservative test for overlap between triangle and aabb
+SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const btVector3 *vertices,
+									const btVector3 &aabbMin, const btVector3 &aabbMax)
+{
+	const btVector3 &p1 = vertices[0];
+	const btVector3 &p2 = vertices[1];
+	const btVector3 &p3 = vertices[2];
+
+	if (btMin(btMin(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false;
+	if (btMax(btMax(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false;
+
+	if (btMin(btMin(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false;
+	if (btMax(btMax(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false;
+  
+	if (btMin(btMin(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false;
+	if (btMax(btMax(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false;
+	return true;
+}
+
+
+SIMD_FORCE_INLINE int	btOutcode(const btVector3& p,const btVector3& halfExtent) 
+{
+	return (p.getX()  < -halfExtent.getX() ? 0x01 : 0x0) |    
+		   (p.getX() >  halfExtent.getX() ? 0x08 : 0x0) |
+		   (p.getY() < -halfExtent.getY() ? 0x02 : 0x0) |    
+		   (p.getY() >  halfExtent.getY() ? 0x10 : 0x0) |
+		   (p.getZ() < -halfExtent.getZ() ? 0x4 : 0x0) |    
+		   (p.getZ() >  halfExtent.getZ() ? 0x20 : 0x0);
+}
+
+
+SIMD_FORCE_INLINE bool btRayAabb2(const btVector3& rayFrom,
+								  const btVector3& rayInvDirection,
+								  const unsigned int raySign[3],
+								  const btVector3 bounds[2],
+								  btScalar& tmin,
+								  btScalar lambda_min,
+								  btScalar lambda_max)
+{
+	btScalar tmax, tymin, tymax, tzmin, tzmax;
+	tmin = (bounds[raySign[0]][0] - rayFrom[0]) * rayInvDirection[0];
+	tmax = (bounds[1-raySign[0]][0] - rayFrom[0]) * rayInvDirection[0];
+	tymin = (bounds[raySign[1]][1] - rayFrom[1]) * rayInvDirection[1];
+	tymax = (bounds[1-raySign[1]][1] - rayFrom[1]) * rayInvDirection[1];
+
+	if ( (tmin > tymax) || (tymin > tmax) )
+		return false;
+
+	if (tymin > tmin)
+		tmin = tymin;
+
+	if (tymax < tmax)
+		tmax = tymax;
+
+	tzmin = (bounds[raySign[2]][2] - rayFrom[2]) * rayInvDirection[2];
+	tzmax = (bounds[1-raySign[2]][2] - rayFrom[2]) * rayInvDirection[2];
+
+	if ( (tmin > tzmax) || (tzmin > tmax) )
+		return false;
+	if (tzmin > tmin)
+		tmin = tzmin;
+	if (tzmax < tmax)
+		tmax = tzmax;
+	return ( (tmin < lambda_max) && (tmax > lambda_min) );
+}
+
+SIMD_FORCE_INLINE bool btRayAabb(const btVector3& rayFrom, 
+								 const btVector3& rayTo, 
+								 const btVector3& aabbMin, 
+								 const btVector3& aabbMax,
+					  btScalar& param, btVector3& normal) 
+{
+	btVector3 aabbHalfExtent = (aabbMax-aabbMin)* btScalar(0.5);
+	btVector3 aabbCenter = (aabbMax+aabbMin)* btScalar(0.5);
+	btVector3	source = rayFrom - aabbCenter;
+	btVector3	target = rayTo - aabbCenter;
+	int	sourceOutcode = btOutcode(source,aabbHalfExtent);
+	int targetOutcode = btOutcode(target,aabbHalfExtent);
+	if ((sourceOutcode & targetOutcode) == 0x0)
+	{
+		btScalar lambda_enter = btScalar(0.0);
+		btScalar lambda_exit  = param;
+		btVector3 r = target - source;
+		int i;
+		btScalar	normSign = 1;
+		btVector3	hitNormal(0,0,0);
+		int bit=1;
+
+		for (int j=0;j<2;j++)
+		{
+			for (i = 0; i != 3; ++i)
+			{
+				if (sourceOutcode & bit)
+				{
+					btScalar lambda = (-source[i] - aabbHalfExtent[i]*normSign) / r[i];
+					if (lambda_enter <= lambda)
+					{
+						lambda_enter = lambda;
+						hitNormal.setValue(0,0,0);
+						hitNormal[i] = normSign;
+					}
+				}
+				else if (targetOutcode & bit) 
+				{
+					btScalar lambda = (-source[i] - aabbHalfExtent[i]*normSign) / r[i];
+					btSetMin(lambda_exit, lambda);
+				}
+				bit<<=1;
+			}
+			normSign = btScalar(-1.);
+		}
+		if (lambda_enter <= lambda_exit)
+		{
+			param = lambda_enter;
+			normal = hitNormal;
+			return true;
+		}
+	}
+	return false;
+}
+
+
+
+SIMD_FORCE_INLINE	void btTransformAabb(const btVector3& halfExtents, btScalar margin,const btTransform& t,btVector3& aabbMinOut,btVector3& aabbMaxOut)
+{
+	btVector3 halfExtentsWithMargin = halfExtents+btVector3(margin,margin,margin);
+	btMatrix3x3 abs_b = t.getBasis().absolute();  
+	btVector3 center = t.getOrigin();
+	btVector3 extent = btVector3(abs_b[0].dot(halfExtentsWithMargin),
+		   abs_b[1].dot(halfExtentsWithMargin),
+		  abs_b[2].dot(halfExtentsWithMargin));
+	aabbMinOut = center - extent;
+	aabbMaxOut = center + extent;
+}
+
+
+SIMD_FORCE_INLINE	void btTransformAabb(const btVector3& localAabbMin,const btVector3& localAabbMax, btScalar margin,const btTransform& trans,btVector3& aabbMinOut,btVector3& aabbMaxOut)
+{
+		btAssert(localAabbMin.getX() <= localAabbMax.getX());
+		btAssert(localAabbMin.getY() <= localAabbMax.getY());
+		btAssert(localAabbMin.getZ() <= localAabbMax.getZ());
+		btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin);
+		localHalfExtents+=btVector3(margin,margin,margin);
+
+		btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin);
+		btMatrix3x3 abs_b = trans.getBasis().absolute();  
+		btVector3 center = trans(localCenter);
+		btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
+			   abs_b[1].dot(localHalfExtents),
+			  abs_b[2].dot(localHalfExtents));
+		aabbMinOut = center-extent;
+		aabbMaxOut = center+extent;
+}
+
+
+#endif
+
+
Index: /code/branches/physics/src/bullet/LinearMath/btAlignedAllocator.cpp
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btAlignedAllocator.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btAlignedAllocator.cpp	(revision 2122)
@@ -0,0 +1,201 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "btAlignedAllocator.h"
+
+int gNumAlignedAllocs = 0;
+int gNumAlignedFree = 0;
+int gTotalBytesAlignedAllocs = 0;//detect memory leaks
+
+#if defined (BT_HAS_ALIGNED_ALLOCATOR)
+#include <malloc.h>
+static void *btAlignedAllocDefault(size_t size, int alignment)
+{
+	return _aligned_malloc(size, (size_t)alignment);
+}
+
+static void btAlignedFreeDefault(void *ptr)
+{
+	_aligned_free(ptr);
+}
+#elif defined(__CELLOS_LV2__)
+#include <stdlib.h>
+
+static inline void *btAlignedAllocDefault(size_t size, int alignment)
+{
+	return memalign(alignment, size);
+}
+
+static inline void btAlignedFreeDefault(void *ptr)
+{
+	free(ptr);
+}
+#else
+static inline void *btAlignedAllocDefault(size_t size, int alignment)
+{
+  void *ret;
+  char *real;
+  unsigned long offset;
+
+  real = (char *)malloc(size + sizeof(void *) + (alignment-1));
+  if (real) {
+    offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1);
+    ret = (void *)((real + sizeof(void *)) + offset);
+    *((void **)(ret)-1) = (void *)(real);
+  } else {
+    ret = (void *)(real);
+  }
+  return (ret);
+}
+
+static inline void btAlignedFreeDefault(void *ptr)
+{
+  void* real;
+
+  if (ptr) {
+    real = *((void **)(ptr)-1);
+    free(real);
+  }
+}
+#endif
+
+static void *btAllocDefault(size_t size)
+{
+	return malloc(size);
+}
+
+static void btFreeDefault(void *ptr)
+{
+	free(ptr);
+}
+
+static btAlignedAllocFunc *sAlignedAllocFunc = btAlignedAllocDefault;
+static btAlignedFreeFunc *sAlignedFreeFunc = btAlignedFreeDefault;
+static btAllocFunc *sAllocFunc = btAllocDefault;
+static btFreeFunc *sFreeFunc = btFreeDefault;
+
+void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc)
+{
+  sAlignedAllocFunc = allocFunc ? allocFunc : btAlignedAllocDefault;
+  sAlignedFreeFunc = freeFunc ? freeFunc : btAlignedFreeDefault;
+}
+
+void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc)
+{
+  sAllocFunc = allocFunc ? allocFunc : btAllocDefault;
+  sFreeFunc = freeFunc ? freeFunc : btFreeDefault;
+}
+
+#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
+//this generic allocator provides the total allocated number of bytes
+#include <stdio.h>
+
+void*   btAlignedAllocInternal  (size_t size, int alignment,int line,char* filename)
+{
+ void *ret;
+ char *real;
+ unsigned long offset;
+
+ gTotalBytesAlignedAllocs += size;
+ gNumAlignedAllocs++;
+
+ 
+ real = (char *)sAllocFunc(size + 2*sizeof(void *) + (alignment-1));
+ if (real) {
+   offset = (alignment - (unsigned long)(real + 2*sizeof(void *))) &
+(alignment-1);
+   ret = (void *)((real + 2*sizeof(void *)) + offset);
+   *((void **)(ret)-1) = (void *)(real);
+       *((int*)(ret)-2) = size;
+
+ } else {
+   ret = (void *)(real);//??
+ }
+
+ printf("allocation#%d at address %x, from %s,line %d, size %d\n",gNumAlignedAllocs,real, filename,line,size);
+
+ int* ptr = (int*)ret;
+ *ptr = 12;
+ return (ret);
+}
+
+void    btAlignedFreeInternal   (void* ptr,int line,char* filename)
+{
+
+ void* real;
+ gNumAlignedFree++;
+
+ if (ptr) {
+   real = *((void **)(ptr)-1);
+       int size = *((int*)(ptr)-2);
+       gTotalBytesAlignedAllocs -= size;
+
+	   printf("free #%d at address %x, from %s,line %d, size %d\n",gNumAlignedFree,real, filename,line,size);
+
+   sFreeFunc(real);
+ } else
+ {
+	 printf("NULL ptr\n");
+ }
+}
+
+#else //BT_DEBUG_MEMORY_ALLOCATIONS
+
+void*	btAlignedAllocInternal	(size_t size, int alignment)
+{
+	gNumAlignedAllocs++;
+  void* ptr;
+#if defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__)
+	ptr = sAlignedAllocFunc(size, alignment);
+#else
+  char *real;
+  unsigned long offset;
+
+  real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1));
+  if (real) {
+    offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1);
+    ptr = (void *)((real + sizeof(void *)) + offset);
+    *((void **)(ptr)-1) = (void *)(real);
+  } else {
+    ptr = (void *)(real);
+  }
+#endif  // defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__)
+//	printf("btAlignedAllocInternal %d, %x\n",size,ptr);
+	return ptr;
+}
+
+void	btAlignedFreeInternal	(void* ptr)
+{
+	if (!ptr)
+	{
+		return;
+	}
+
+	gNumAlignedFree++;
+//	printf("btAlignedFreeInternal %x\n",ptr);
+#if defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__)
+	sAlignedFreeFunc(ptr);
+#else
+  void* real;
+
+  if (ptr) {
+    real = *((void **)(ptr)-1);
+    sFreeFunc(real);
+  }
+#endif  // defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__)
+}
+
+#endif //BT_DEBUG_MEMORY_ALLOCATIONS
+
Index: /code/branches/physics/src/bullet/LinearMath/btAlignedAllocator.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btAlignedAllocator.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btAlignedAllocator.h	(revision 2122)
@@ -0,0 +1,104 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_ALIGNED_ALLOCATOR
+#define BT_ALIGNED_ALLOCATOR
+
+///we probably replace this with our own aligned memory allocator
+///so we replace _aligned_malloc and _aligned_free with our own
+///that is better portable and more predictable
+
+#include "btScalar.h"
+//#define BT_DEBUG_MEMORY_ALLOCATIONS 1
+#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
+
+#define btAlignedAlloc(a,b) \
+		btAlignedAllocInternal(a,b,__LINE__,__FILE__)
+
+#define btAlignedFree(ptr) \
+		btAlignedFreeInternal(ptr,__LINE__,__FILE__)
+
+void*	btAlignedAllocInternal	(size_t size, int alignment,int line,char* filename);
+
+void	btAlignedFreeInternal	(void* ptr,int line,char* filename);
+
+#else
+	void*	btAlignedAllocInternal	(size_t size, int alignment);
+	void	btAlignedFreeInternal	(void* ptr);
+
+	#define btAlignedAlloc(a,b) btAlignedAllocInternal(a,b)
+	#define btAlignedFree(ptr) btAlignedFreeInternal(ptr)
+
+#endif
+typedef int	size_type;
+
+typedef void *(btAlignedAllocFunc)(size_t size, int alignment);
+typedef void (btAlignedFreeFunc)(void *memblock);
+typedef void *(btAllocFunc)(size_t size);
+typedef void (btFreeFunc)(void *memblock);
+
+void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc);
+void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc);
+
+///The btAlignedAllocator is a portable class for aligned memory allocations.
+///Default implementations for unaligned and aligned allocations can be overridden by a custom allocator using btAlignedAllocSetCustom and btAlignedAllocSetCustomAligned.
+template < typename T , unsigned Alignment >
+class btAlignedAllocator {
+	
+	typedef btAlignedAllocator< T , Alignment > self_type;
+	
+public:
+
+	//just going down a list:
+	btAlignedAllocator() {}
+	/*
+	btAlignedAllocator( const self_type & ) {}
+	*/
+
+	template < typename Other >
+	btAlignedAllocator( const btAlignedAllocator< Other , Alignment > & ) {}
+
+	typedef const T*         const_pointer;
+	typedef const T&         const_reference;
+	typedef T*               pointer;
+	typedef T&               reference;
+	typedef T                value_type;
+
+	pointer       address   ( reference        ref ) const                           { return &ref; }
+	const_pointer address   ( const_reference  ref ) const                           { return &ref; }
+	pointer       allocate  ( size_type        n   , const_pointer *      hint = 0 ) {
+		(void)hint;
+		return reinterpret_cast< pointer >(btAlignedAlloc( sizeof(value_type) * n , Alignment ));
+	}
+	void          construct ( pointer          ptr , const value_type &   value    ) { new (ptr) value_type( value ); }
+	void          deallocate( pointer          ptr ) {
+		btAlignedFree( reinterpret_cast< void * >( ptr ) );
+	}
+	void          destroy   ( pointer          ptr )                                 { ptr->~value_type(); }
+	
+
+	template < typename O > struct rebind {
+		typedef btAlignedAllocator< O , Alignment > other;
+	};
+	template < typename O >
+	self_type & operator=( const btAlignedAllocator< O , Alignment > & ) { return *this; }
+
+	friend bool operator==( const self_type & , const self_type & ) { return true; }
+};
+
+
+
+#endif //BT_ALIGNED_ALLOCATOR
+
Index: /code/branches/physics/src/bullet/LinearMath/btAlignedObjectArray.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btAlignedObjectArray.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btAlignedObjectArray.h	(revision 2122)
@@ -0,0 +1,426 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef BT_OBJECT_ARRAY__
+#define BT_OBJECT_ARRAY__
+
+#include "btScalar.h" // has definitions like SIMD_FORCE_INLINE
+#include "btAlignedAllocator.h"
+
+///If the platform doesn't support placement new, you can disable BT_USE_PLACEMENT_NEW
+///then the btAlignedObjectArray doesn't support objects with virtual methods, and non-trivial constructors/destructors
+///You can enable BT_USE_MEMCPY, then swapping elements in the array will use memcpy instead of operator=
+///see discussion here: http://continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1231 and
+///http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1240
+
+#define BT_USE_PLACEMENT_NEW 1
+//#define BT_USE_MEMCPY 1 //disable, because it is cumbersome to find out for each platform where memcpy is defined. It can be in <memory.h> or <string.h> or otherwise...
+
+#ifdef BT_USE_MEMCPY
+#include <memory.h>
+#include <string.h>
+#endif //BT_USE_MEMCPY
+
+#ifdef BT_USE_PLACEMENT_NEW
+#include <new> //for placement new
+#endif //BT_USE_PLACEMENT_NEW
+
+
+///The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods
+///It is developed to replace stl::vector to avoid portability issues, including STL alignment issues to add SIMD/SSE data
+template <typename T> 
+//template <class T> 
+class btAlignedObjectArray
+{
+	btAlignedAllocator<T , 16>	m_allocator;
+
+	int					m_size;
+	int					m_capacity;
+	T*					m_data;
+	//PCK: added this line
+	bool				m_ownsMemory;
+
+	protected:
+		SIMD_FORCE_INLINE	int	allocSize(int size)
+		{
+			return (size ? size*2 : 1);
+		}
+		SIMD_FORCE_INLINE	void	copy(int start,int end, T* dest)
+		{
+			int i;
+			for (i=start;i<end;++i)
+#ifdef BT_USE_PLACEMENT_NEW
+				new (&dest[i]) T(m_data[i]);
+#else
+				dest[i] = m_data[i];
+#endif //BT_USE_PLACEMENT_NEW
+		}
+
+		SIMD_FORCE_INLINE	void	init()
+		{
+			//PCK: added this line
+			m_ownsMemory = true;
+			m_data = 0;
+			m_size = 0;
+			m_capacity = 0;
+		}
+		SIMD_FORCE_INLINE	void	destroy(int first,int last)
+		{
+			int i;
+			for (i=first; i<last;i++)
+			{
+				m_data[i].~T();
+			}
+		}
+
+		SIMD_FORCE_INLINE	void* allocate(int size)
+		{
+			if (size)
+				return m_allocator.allocate(size);
+			return 0;
+		}
+
+		SIMD_FORCE_INLINE	void	deallocate()
+		{
+			if(m_data)	{
+				//PCK: enclosed the deallocation in this block
+				if (m_ownsMemory)
+				{
+					m_allocator.deallocate(m_data);
+				}
+				m_data = 0;
+			}
+		}
+
+	
+
+
+	public:
+		
+		btAlignedObjectArray()
+		{
+			init();
+		}
+
+		~btAlignedObjectArray()
+		{
+			clear();
+		}
+
+		SIMD_FORCE_INLINE	int capacity() const
+		{	// return current length of allocated storage
+			return m_capacity;
+		}
+		
+		SIMD_FORCE_INLINE	int size() const
+		{	// return length of sequence
+			return m_size;
+		}
+		
+		SIMD_FORCE_INLINE const T& operator[](int n) const
+		{
+			return m_data[n];
+		}
+
+		SIMD_FORCE_INLINE T& operator[](int n)
+		{
+			return m_data[n];
+		}
+		
+
+		SIMD_FORCE_INLINE	void	clear()
+		{
+			destroy(0,size());
+			
+			deallocate();
+			
+			init();
+		}
+
+		SIMD_FORCE_INLINE	void	pop_back()
+		{
+			m_size--;
+			m_data[m_size].~T();
+		}
+
+		SIMD_FORCE_INLINE	void	resize(int newsize, const T& fillData=T())
+		{
+			int curSize = size();
+
+			if (newsize < size())
+			{
+				for(int i = curSize; i < newsize; i++)
+				{
+					m_data[i].~T();
+				}
+			} else
+			{
+				if (newsize > size())
+				{
+					reserve(newsize);
+				}
+#ifdef BT_USE_PLACEMENT_NEW
+				for (int i=curSize;i<newsize;i++)
+				{
+					new ( &m_data[i]) T(fillData);
+				}
+#endif //BT_USE_PLACEMENT_NEW
+
+			}
+
+			m_size = newsize;
+		}
+	
+
+		SIMD_FORCE_INLINE	T&  expand( const T& fillValue=T())
+		{	
+			int sz = size();
+			if( sz == capacity() )
+			{
+				reserve( allocSize(size()) );
+			}
+			m_size++;
+#ifdef BT_USE_PLACEMENT_NEW
+			new (&m_data[sz]) T(fillValue); //use the in-place new (not really allocating heap memory)
+#endif
+
+			return m_data[sz];		
+		}
+
+
+		SIMD_FORCE_INLINE	void push_back(const T& _Val)
+		{	
+			int sz = size();
+			if( sz == capacity() )
+			{
+				reserve( allocSize(size()) );
+			}
+			
+#ifdef BT_USE_PLACEMENT_NEW
+			new ( &m_data[m_size] ) T(_Val);
+#else
+			m_data[size()] = _Val;			
+#endif //BT_USE_PLACEMENT_NEW
+
+			m_size++;
+		}
+
+	
+		
+		SIMD_FORCE_INLINE	void reserve(int _Count)
+		{	// determine new minimum length of allocated storage
+			if (capacity() < _Count)
+			{	// not enough room, reallocate
+				T*	s = (T*)allocate(_Count);
+
+				copy(0, size(), s);
+
+				destroy(0,size());
+
+				deallocate();
+				
+				//PCK: added this line
+				m_ownsMemory = true;
+
+				m_data = s;
+				
+				m_capacity = _Count;
+
+			}
+		}
+
+
+		class less
+		{
+			public:
+
+				bool operator() ( const T& a, const T& b )
+				{
+					return ( a < b );
+				}
+		};
+	
+		template <typename L>
+		void quickSortInternal(L CompareFunc,int lo, int hi)
+		{
+		//  lo is the lower index, hi is the upper index
+		//  of the region of array a that is to be sorted
+			int i=lo, j=hi;
+			T x=m_data[(lo+hi)/2];
+
+			//  partition
+			do
+			{    
+				while (CompareFunc(m_data[i],x)) 
+					i++; 
+				while (CompareFunc(x,m_data[j])) 
+					j--;
+				if (i<=j)
+				{
+					swap(i,j);
+					i++; j--;
+				}
+			} while (i<=j);
+
+			//  recursion
+			if (lo<j) 
+				quickSortInternal( CompareFunc, lo, j);
+			if (i<hi) 
+				quickSortInternal( CompareFunc, i, hi);
+		}
+
+
+		template <typename L>
+		void quickSort(L CompareFunc)
+		{
+			//don't sort 0 or 1 elements
+			if (size()>1)
+			{
+				quickSortInternal(CompareFunc,0,size()-1);
+			}
+		}
+
+
+		///heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/
+		template <typename L>
+		void downHeap(T *pArr, int k, int n,L CompareFunc)
+		{
+			/*  PRE: a[k+1..N] is a heap */
+			/* POST:  a[k..N]  is a heap */
+			
+			T temp = pArr[k - 1];
+			/* k has child(s) */
+			while (k <= n/2) 
+			{
+				int child = 2*k;
+				
+				if ((child < n) && CompareFunc(pArr[child - 1] , pArr[child]))
+				{
+					child++;
+				}
+				/* pick larger child */
+				if (CompareFunc(temp , pArr[child - 1]))
+				{
+					/* move child up */
+					pArr[k - 1] = pArr[child - 1];
+					k = child;
+				}
+				else
+				{
+					break;
+				}
+			}
+			pArr[k - 1] = temp;
+		} /*downHeap*/
+
+		void	swap(int index0,int index1)
+		{
+#ifdef BT_USE_MEMCPY
+			char	temp[sizeof(T)];
+			memcpy(temp,&m_data[index0],sizeof(T));
+			memcpy(&m_data[index0],&m_data[index1],sizeof(T));
+			memcpy(&m_data[index1],temp,sizeof(T));
+#else
+			T temp = m_data[index0];
+			m_data[index0] = m_data[index1];
+			m_data[index1] = temp;
+#endif //BT_USE_PLACEMENT_NEW
+
+		}
+
+	template <typename L>
+	void heapSort(L CompareFunc)
+	{
+		/* sort a[0..N-1],  N.B. 0 to N-1 */
+		int k;
+		int n = m_size;
+		for (k = n/2; k > 0; k--) 
+		{
+			downHeap(m_data, k, n, CompareFunc);
+		}
+
+		/* a[1..N] is now a heap */
+		while ( n>=1 ) 
+		{
+			swap(0,n-1); /* largest of a[0..n-1] */
+
+
+			n = n - 1;
+			/* restore a[1..i-1] heap */
+			downHeap(m_data, 1, n, CompareFunc);
+		} 
+	}
+
+	///non-recursive binary search, assumes sorted array
+	int	findBinarySearch(const T& key) const
+	{
+		int first = 0;
+		int last = size();
+
+		//assume sorted array
+		while (first <= last) {
+			int mid = (first + last) / 2;  // compute mid point.
+			if (key > m_data[mid]) 
+				first = mid + 1;  // repeat search in top half.
+			else if (key < m_data[mid]) 
+				last = mid - 1; // repeat search in bottom half.
+			else
+				return mid;     // found it. return position /////
+		}
+		return size();    // failed to find key
+	}
+
+
+	int	findLinearSearch(const T& key) const
+	{
+		int index=size();
+		int i;
+
+		for (i=0;i<size();i++)
+		{
+			if (m_data[i] == key)
+			{
+				index = i;
+				break;
+			}
+		}
+		return index;
+	}
+
+	void	remove(const T& key)
+	{
+
+		int findIndex = findLinearSearch(key);
+		if (findIndex<size())
+		{
+			swap( findIndex,size()-1);
+			pop_back();
+		}
+	}
+
+	//PCK: whole function
+	void initializeFromBuffer(void *buffer, int size, int capacity)
+	{
+		clear();
+		m_ownsMemory = false;
+		m_data = (T*)buffer;
+		m_size = size;
+		m_capacity = capacity;
+	}
+
+};
+
+#endif //BT_OBJECT_ARRAY__
Index: /code/branches/physics/src/bullet/LinearMath/btConvexHull.cpp
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btConvexHull.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btConvexHull.cpp	(revision 2122)
@@ -0,0 +1,1174 @@
+/*
+Stan Melax Convex Hull Computation
+Copyright (c) 2003-2006 Stan Melax http://www.melax.com/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include <string.h>
+
+#include "btConvexHull.h"
+#include "LinearMath/btAlignedObjectArray.h"
+#include "LinearMath/btMinMax.h"
+#include "LinearMath/btVector3.h"
+
+
+
+template <class T>
+void Swap(T &a,T &b)
+{
+	T tmp = a;
+	a=b;
+	b=tmp;
+}
+
+
+//----------------------------------
+
+class int3  
+{
+public:
+	int x,y,z;
+	int3(){};
+	int3(int _x,int _y, int _z){x=_x;y=_y;z=_z;}
+	const int& operator[](int i) const {return (&x)[i];}
+	int& operator[](int i) {return (&x)[i];}
+};
+
+
+//------- btPlane ----------
+
+
+inline btPlane PlaneFlip(const btPlane &plane){return btPlane(-plane.normal,-plane.dist);}
+inline int operator==( const btPlane &a, const btPlane &b ) { return (a.normal==b.normal && a.dist==b.dist); }
+inline int coplanar( const btPlane &a, const btPlane &b ) { return (a==b || a==PlaneFlip(b)); }
+
+
+//--------- Utility Functions ------
+
+btVector3  PlaneLineIntersection(const btPlane &plane, const btVector3 &p0, const btVector3 &p1);
+btVector3  PlaneProject(const btPlane &plane, const btVector3 &point);
+
+btVector3  ThreePlaneIntersection(const btPlane &p0,const btPlane &p1, const btPlane &p2);
+btVector3  ThreePlaneIntersection(const btPlane &p0,const btPlane &p1, const btPlane &p2)
+{
+	btVector3 N1 = p0.normal;
+	btVector3 N2 = p1.normal;
+	btVector3 N3 = p2.normal;
+
+	btVector3 n2n3; n2n3 = N2.cross(N3);
+	btVector3 n3n1; n3n1 = N3.cross(N1);
+	btVector3 n1n2; n1n2 = N1.cross(N2);
+
+	btScalar quotient = (N1.dot(n2n3));
+
+	btAssert(btFabs(quotient) > btScalar(0.000001));
+	
+	quotient = btScalar(-1.) / quotient;
+	n2n3 *= p0.dist;
+	n3n1 *= p1.dist;
+	n1n2 *= p2.dist;
+	btVector3 potentialVertex = n2n3;
+	potentialVertex += n3n1;
+	potentialVertex += n1n2;
+	potentialVertex *= quotient;
+
+	btVector3 result(potentialVertex.getX(),potentialVertex.getY(),potentialVertex.getZ());
+	return result;
+
+}
+
+btScalar   DistanceBetweenLines(const btVector3 &ustart, const btVector3 &udir, const btVector3 &vstart, const btVector3 &vdir, btVector3 *upoint=NULL, btVector3 *vpoint=NULL);
+btVector3  TriNormal(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2);
+btVector3  NormalOf(const btVector3 *vert, const int n);
+
+
+btVector3 PlaneLineIntersection(const btPlane &plane, const btVector3 &p0, const btVector3 &p1)
+{
+	// returns the point where the line p0-p1 intersects the plane n&d
+				static btVector3 dif;
+		dif = p1-p0;
+				btScalar dn= dot(plane.normal,dif);
+				btScalar t = -(plane.dist+dot(plane.normal,p0) )/dn;
+				return p0 + (dif*t);
+}
+
+btVector3 PlaneProject(const btPlane &plane, const btVector3 &point)
+{
+	return point - plane.normal * (dot(point,plane.normal)+plane.dist);
+}
+
+btVector3 TriNormal(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2)
+{
+	// return the normal of the triangle
+	// inscribed by v0, v1, and v2
+	btVector3 cp=cross(v1-v0,v2-v1);
+	btScalar m=cp.length();
+	if(m==0) return btVector3(1,0,0);
+	return cp*(btScalar(1.0)/m);
+}
+
+
+btScalar DistanceBetweenLines(const btVector3 &ustart, const btVector3 &udir, const btVector3 &vstart, const btVector3 &vdir, btVector3 *upoint, btVector3 *vpoint)
+{
+	static btVector3 cp;
+	cp = cross(udir,vdir).normalized();
+
+	btScalar distu = -dot(cp,ustart);
+	btScalar distv = -dot(cp,vstart);
+	btScalar dist = (btScalar)fabs(distu-distv);
+	if(upoint) 
+		{
+		btPlane plane;
+		plane.normal = cross(vdir,cp).normalized();
+		plane.dist = -dot(plane.normal,vstart);
+		*upoint = PlaneLineIntersection(plane,ustart,ustart+udir);
+	}
+	if(vpoint) 
+		{
+		btPlane plane;
+		plane.normal = cross(udir,cp).normalized();
+		plane.dist = -dot(plane.normal,ustart);
+		*vpoint = PlaneLineIntersection(plane,vstart,vstart+vdir);
+	}
+	return dist;
+}
+
+
+
+
+
+
+
+#define COPLANAR   (0)
+#define UNDER      (1)
+#define OVER       (2)
+#define SPLIT      (OVER|UNDER)
+#define PAPERWIDTH (btScalar(0.001))
+
+btScalar planetestepsilon = PAPERWIDTH;
+
+
+
+typedef ConvexH::HalfEdge HalfEdge;
+
+ConvexH::ConvexH(int vertices_size,int edges_size,int facets_size)
+{
+	vertices.resize(vertices_size);
+	edges.resize(edges_size);
+	facets.resize(facets_size);
+}
+
+
+int PlaneTest(const btPlane &p, const btVector3 &v);
+int PlaneTest(const btPlane &p, const btVector3 &v) {
+	btScalar a  = dot(v,p.normal)+p.dist;
+	int   flag = (a>planetestepsilon)?OVER:((a<-planetestepsilon)?UNDER:COPLANAR);
+	return flag;
+}
+
+int SplitTest(ConvexH &convex,const btPlane &plane);
+int SplitTest(ConvexH &convex,const btPlane &plane) {
+	int flag=0;
+	for(int i=0;i<convex.vertices.size();i++) {
+		flag |= PlaneTest(plane,convex.vertices[i]);
+	}
+	return flag;
+}
+
+class VertFlag
+{
+public:
+	unsigned char planetest;
+	unsigned char junk;
+	unsigned char undermap;
+	unsigned char overmap;
+};
+class EdgeFlag 
+{
+public:
+	unsigned char planetest;
+	unsigned char fixes;
+	short undermap;
+	short overmap;
+};
+class PlaneFlag
+{
+public:
+	unsigned char undermap;
+	unsigned char overmap;
+};
+class Coplanar{
+public:
+	unsigned short ea;
+	unsigned char v0;
+	unsigned char v1;
+};
+
+
+
+
+
+
+
+
+template<class T>
+int maxdirfiltered(const T *p,int count,const T &dir,btAlignedObjectArray<int> &allow)
+{
+	btAssert(count);
+	int m=-1;
+	for(int i=0;i<count;i++) 
+		if(allow[i])
+		{
+			if(m==-1 || dot(p[i],dir)>dot(p[m],dir))
+				m=i;
+		}
+	btAssert(m!=-1);
+	return m;
+} 
+
+btVector3 orth(const btVector3 &v);
+btVector3 orth(const btVector3 &v)
+{
+	btVector3 a=cross(v,btVector3(0,0,1));
+	btVector3 b=cross(v,btVector3(0,1,0));
+	if (a.length() > b.length())
+	{
+		return a.normalized();
+	} else {
+		return b.normalized();
+	}
+}
+
+
+template<class T>
+int maxdirsterid(const T *p,int count,const T &dir,btAlignedObjectArray<int> &allow)
+{
+	int m=-1;
+	while(m==-1)
+	{
+		m = maxdirfiltered(p,count,dir,allow);
+		if(allow[m]==3) return m;
+		T u = orth(dir);
+		T v = cross(u,dir);
+		int ma=-1;
+		for(btScalar x = btScalar(0.0) ; x<= btScalar(360.0) ; x+= btScalar(45.0))
+		{
+			btScalar s = sinf(SIMD_RADS_PER_DEG*(x));
+			btScalar c = cosf(SIMD_RADS_PER_DEG*(x));
+			int mb = maxdirfiltered(p,count,dir+(u*s+v*c)*btScalar(0.025),allow);
+			if(ma==m && mb==m)
+			{
+				allow[m]=3;
+				return m;
+			}
+			if(ma!=-1 && ma!=mb)  // Yuck - this is really ugly
+			{
+				int mc = ma;
+				for(btScalar xx = x-btScalar(40.0) ; xx <= x ; xx+= btScalar(5.0))
+				{
+					btScalar s = sinf(SIMD_RADS_PER_DEG*(xx));
+					btScalar c = cosf(SIMD_RADS_PER_DEG*(xx));
+					int md = maxdirfiltered(p,count,dir+(u*s+v*c)*btScalar(0.025),allow);
+					if(mc==m && md==m)
+					{
+						allow[m]=3;
+						return m;
+					}
+					mc=md;
+				}
+			}
+			ma=mb;
+		}
+		allow[m]=0;
+		m=-1;
+	}
+	btAssert(0);
+	return m;
+} 
+
+
+
+
+int operator ==(const int3 &a,const int3 &b);
+int operator ==(const int3 &a,const int3 &b) 
+{
+	for(int i=0;i<3;i++) 
+	{
+		if(a[i]!=b[i]) return 0;
+	}
+	return 1;
+}
+
+
+int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilon);
+int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilon) 
+{
+	btVector3 n=TriNormal(vertices[t[0]],vertices[t[1]],vertices[t[2]]);
+	return (dot(n,p-vertices[t[0]]) > epsilon); // EPSILON???
+}
+int hasedge(const int3 &t, int a,int b);
+int hasedge(const int3 &t, int a,int b)
+{
+	for(int i=0;i<3;i++)
+	{
+		int i1= (i+1)%3;
+		if(t[i]==a && t[i1]==b) return 1;
+	}
+	return 0;
+}
+int hasvert(const int3 &t, int v);
+int hasvert(const int3 &t, int v)
+{
+	return (t[0]==v || t[1]==v || t[2]==v) ;
+}
+int shareedge(const int3 &a,const int3 &b);
+int shareedge(const int3 &a,const int3 &b)
+{
+	int i;
+	for(i=0;i<3;i++)
+	{
+		int i1= (i+1)%3;
+		if(hasedge(a,b[i1],b[i])) return 1;
+	}
+	return 0;
+}
+
+class Tri;
+
+
+
+class Tri : public int3
+{
+public:
+	int3 n;
+	int id;
+	int vmax;
+	btScalar rise;
+	Tri(int a,int b,int c):int3(a,b,c),n(-1,-1,-1)
+	{
+		vmax=-1;
+		rise = btScalar(0.0);
+	}
+	~Tri()
+	{
+	}
+	int &neib(int a,int b);
+};
+
+
+int &Tri::neib(int a,int b)
+{
+	static int er=-1;
+	int i;
+	for(i=0;i<3;i++) 
+	{
+		int i1=(i+1)%3;
+		int i2=(i+2)%3;
+		if((*this)[i]==a && (*this)[i1]==b) return n[i2];
+		if((*this)[i]==b && (*this)[i1]==a) return n[i2];
+	}
+	btAssert(0);
+	return er;
+}
+void HullLibrary::b2bfix(Tri* s,Tri*t)
+{
+	int i;
+	for(i=0;i<3;i++) 
+	{
+		int i1=(i+1)%3;
+		int i2=(i+2)%3;
+		int a = (*s)[i1];
+		int b = (*s)[i2];
+		btAssert(m_tris[s->neib(a,b)]->neib(b,a) == s->id);
+		btAssert(m_tris[t->neib(a,b)]->neib(b,a) == t->id);
+		m_tris[s->neib(a,b)]->neib(b,a) = t->neib(b,a);
+		m_tris[t->neib(b,a)]->neib(a,b) = s->neib(a,b);
+	}
+}
+
+void HullLibrary::removeb2b(Tri* s,Tri*t)
+{
+	b2bfix(s,t);
+	deAllocateTriangle(s);
+
+	deAllocateTriangle(t);
+}
+
+void HullLibrary::checkit(Tri *t)
+{
+	(void)t;
+
+	int i;
+	btAssert(m_tris[t->id]==t);
+	for(i=0;i<3;i++)
+	{
+		int i1=(i+1)%3;
+		int i2=(i+2)%3;
+		int a = (*t)[i1];
+		int b = (*t)[i2];
+
+		// release compile fix
+		(void)i1;
+		(void)i2;
+		(void)a;
+		(void)b;
+
+		btAssert(a!=b);
+		btAssert( m_tris[t->n[i]]->neib(b,a) == t->id);
+	}
+}
+
+Tri*	HullLibrary::allocateTriangle(int a,int b,int c)
+{
+	void* mem = btAlignedAlloc(sizeof(Tri),16);
+	Tri* tr = new (mem)Tri(a,b,c);
+	tr->id = m_tris.size();
+	m_tris.push_back(tr);
+
+	return tr;
+}
+
+void	HullLibrary::deAllocateTriangle(Tri* tri)
+{
+	btAssert(m_tris[tri->id]==tri);
+	m_tris[tri->id]=NULL;
+	tri->~Tri();
+	btAlignedFree(tri);
+}
+
+
+void HullLibrary::extrude(Tri *t0,int v)
+{
+	int3 t= *t0;
+	int n = m_tris.size();
+	Tri* ta = allocateTriangle(v,t[1],t[2]);
+	ta->n = int3(t0->n[0],n+1,n+2);
+	m_tris[t0->n[0]]->neib(t[1],t[2]) = n+0;
+	Tri* tb = allocateTriangle(v,t[2],t[0]);
+	tb->n = int3(t0->n[1],n+2,n+0);
+	m_tris[t0->n[1]]->neib(t[2],t[0]) = n+1;
+	Tri* tc = allocateTriangle(v,t[0],t[1]);
+	tc->n = int3(t0->n[2],n+0,n+1);
+	m_tris[t0->n[2]]->neib(t[0],t[1]) = n+2;
+	checkit(ta);
+	checkit(tb);
+	checkit(tc);
+	if(hasvert(*m_tris[ta->n[0]],v)) removeb2b(ta,m_tris[ta->n[0]]);
+	if(hasvert(*m_tris[tb->n[0]],v)) removeb2b(tb,m_tris[tb->n[0]]);
+	if(hasvert(*m_tris[tc->n[0]],v)) removeb2b(tc,m_tris[tc->n[0]]);
+	deAllocateTriangle(t0);
+
+}
+
+Tri* HullLibrary::extrudable(btScalar epsilon)
+{
+	int i;
+	Tri *t=NULL;
+	for(i=0;i<m_tris.size();i++)
+	{
+		if(!t || (m_tris[i] && t->rise<m_tris[i]->rise))
+		{
+			t = m_tris[i];
+		}
+	}
+	return (t->rise >epsilon)?t:NULL ;
+}
+
+
+
+
+int4 HullLibrary::FindSimplex(btVector3 *verts,int verts_count,btAlignedObjectArray<int> &allow)
+{
+	btVector3 basis[3];
+	basis[0] = btVector3( btScalar(0.01), btScalar(0.02), btScalar(1.0) );      
+	int p0 = maxdirsterid(verts,verts_count, basis[0],allow);   
+	int	p1 = maxdirsterid(verts,verts_count,-basis[0],allow);
+	basis[0] = verts[p0]-verts[p1];
+	if(p0==p1 || basis[0]==btVector3(0,0,0)) 
+		return int4(-1,-1,-1,-1);
+	basis[1] = cross(btVector3(     btScalar(1),btScalar(0.02), btScalar(0)),basis[0]);
+	basis[2] = cross(btVector3(btScalar(-0.02),     btScalar(1), btScalar(0)),basis[0]);
+	if (basis[1].length() > basis[2].length())
+	{
+		basis[1].normalize();
+	} else {
+		basis[1] = basis[2];
+		basis[1].normalize ();
+	}
+	int p2 = maxdirsterid(verts,verts_count,basis[1],allow);
+	if(p2 == p0 || p2 == p1)
+	{
+		p2 = maxdirsterid(verts,verts_count,-basis[1],allow);
+	}
+	if(p2 == p0 || p2 == p1) 
+		return int4(-1,-1,-1,-1);
+	basis[1] = verts[p2] - verts[p0];
+	basis[2] = cross(basis[1],basis[0]).normalized();
+	int p3 = maxdirsterid(verts,verts_count,basis[2],allow);
+	if(p3==p0||p3==p1||p3==p2) p3 = maxdirsterid(verts,verts_count,-basis[2],allow);
+	if(p3==p0||p3==p1||p3==p2) 
+		return int4(-1,-1,-1,-1);
+	btAssert(!(p0==p1||p0==p2||p0==p3||p1==p2||p1==p3||p2==p3));
+	if(dot(verts[p3]-verts[p0],cross(verts[p1]-verts[p0],verts[p2]-verts[p0])) <0) {Swap(p2,p3);}
+	return int4(p0,p1,p2,p3);
+}
+
+int HullLibrary::calchullgen(btVector3 *verts,int verts_count, int vlimit)
+{
+	if(verts_count <4) return 0;
+	if(vlimit==0) vlimit=1000000000;
+	int j;
+	btVector3 bmin(*verts),bmax(*verts);
+	btAlignedObjectArray<int> isextreme;
+	isextreme.reserve(verts_count);
+	btAlignedObjectArray<int> allow;
+	allow.reserve(verts_count);
+
+	for(j=0;j<verts_count;j++) 
+	{
+		allow.push_back(1);
+		isextreme.push_back(0);
+		bmin.setMin (verts[j]);
+		bmax.setMax (verts[j]);
+	}
+	btScalar epsilon = (bmax-bmin).length() * btScalar(0.001);
+	btAssert (epsilon != 0.0);
+
+
+	int4 p = FindSimplex(verts,verts_count,allow);
+	if(p.x==-1) return 0; // simplex failed
+
+
+
+	btVector3 center = (verts[p[0]]+verts[p[1]]+verts[p[2]]+verts[p[3]]) / btScalar(4.0);  // a valid interior point
+	Tri *t0 = allocateTriangle(p[2],p[3],p[1]); t0->n=int3(2,3,1);
+	Tri *t1 = allocateTriangle(p[3],p[2],p[0]); t1->n=int3(3,2,0);
+	Tri *t2 = allocateTriangle(p[0],p[1],p[3]); t2->n=int3(0,1,3);
+	Tri *t3 = allocateTriangle(p[1],p[0],p[2]); t3->n=int3(1,0,2);
+	isextreme[p[0]]=isextreme[p[1]]=isextreme[p[2]]=isextreme[p[3]]=1;
+	checkit(t0);checkit(t1);checkit(t2);checkit(t3);
+
+	for(j=0;j<m_tris.size();j++)
+	{
+		Tri *t=m_tris[j];
+		btAssert(t);
+		btAssert(t->vmax<0);
+		btVector3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
+		t->vmax = maxdirsterid(verts,verts_count,n,allow);
+		t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
+	}
+	Tri *te;
+	vlimit-=4;
+	while(vlimit >0 && ((te=extrudable(epsilon)) != 0))
+	{
+		int3 ti=*te;
+		int v=te->vmax;
+		btAssert(v != -1);
+		btAssert(!isextreme[v]);  // wtf we've already done this vertex
+		isextreme[v]=1;
+		//if(v==p0 || v==p1 || v==p2 || v==p3) continue; // done these already
+		j=m_tris.size();
+		while(j--) {
+			if(!m_tris[j]) continue;
+			int3 t=*m_tris[j];
+			if(above(verts,t,verts[v],btScalar(0.01)*epsilon)) 
+			{
+				extrude(m_tris[j],v);
+			}
+		}
+		// now check for those degenerate cases where we have a flipped triangle or a really skinny triangle
+		j=m_tris.size();
+		while(j--)
+		{
+			if(!m_tris[j]) continue;
+			if(!hasvert(*m_tris[j],v)) break;
+			int3 nt=*m_tris[j];
+			if(above(verts,nt,center,btScalar(0.01)*epsilon)  || cross(verts[nt[1]]-verts[nt[0]],verts[nt[2]]-verts[nt[1]]).length()< epsilon*epsilon*btScalar(0.1) )
+			{
+				Tri *nb = m_tris[m_tris[j]->n[0]];
+				btAssert(nb);btAssert(!hasvert(*nb,v));btAssert(nb->id<j);
+				extrude(nb,v);
+				j=m_tris.size(); 
+			}
+		} 
+		j=m_tris.size();
+		while(j--)
+		{
+			Tri *t=m_tris[j];
+			if(!t) continue;
+			if(t->vmax>=0) break;
+			btVector3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
+			t->vmax = maxdirsterid(verts,verts_count,n,allow);
+			if(isextreme[t->vmax]) 
+			{
+				t->vmax=-1; // already done that vertex - algorithm needs to be able to terminate.
+			}
+			else
+			{
+				t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
+			}
+		}
+		vlimit --;
+	}
+	return 1;
+}
+
+int HullLibrary::calchull(btVector3 *verts,int verts_count, TUIntArray& tris_out, int &tris_count,int vlimit) 
+{
+	int rc=calchullgen(verts,verts_count,  vlimit) ;
+	if(!rc) return 0;
+	btAlignedObjectArray<int> ts;
+	int i;
+
+	for(i=0;i<m_tris.size();i++)
+	{
+		if(m_tris[i])
+		{
+			for(int j=0;j<3;j++)
+				ts.push_back((*m_tris[i])[j]);
+			deAllocateTriangle(m_tris[i]);
+		}
+	}
+	tris_count = ts.size()/3;
+	tris_out.resize(ts.size());
+	
+	for (i=0;i<ts.size();i++)
+	{
+		tris_out[i] = static_cast<unsigned int>(ts[i]);
+	}
+	m_tris.resize(0);
+
+	return 1;
+}
+
+
+
+
+
+bool HullLibrary::ComputeHull(unsigned int vcount,const btVector3 *vertices,PHullResult &result,unsigned int vlimit)
+{
+	
+	int    tris_count;
+	int ret = calchull( (btVector3 *) vertices, (int) vcount, result.m_Indices, tris_count, static_cast<int>(vlimit) );
+	if(!ret) return false;
+	result.mIndexCount = (unsigned int) (tris_count*3);
+	result.mFaceCount  = (unsigned int) tris_count;
+	result.mVertices   = (btVector3*) vertices;
+	result.mVcount     = (unsigned int) vcount;
+	return true;
+
+}
+
+
+void ReleaseHull(PHullResult &result);
+void ReleaseHull(PHullResult &result)
+{
+	if ( result.m_Indices.size() )
+	{
+		result.m_Indices.clear();
+	}
+
+	result.mVcount = 0;
+	result.mIndexCount = 0;
+	result.mVertices = 0;
+}
+
+
+//*********************************************************************
+//*********************************************************************
+//********  HullLib header
+//*********************************************************************
+//*********************************************************************
+
+//*********************************************************************
+//*********************************************************************
+//********  HullLib implementation
+//*********************************************************************
+//*********************************************************************
+
+HullError HullLibrary::CreateConvexHull(const HullDesc       &desc,           // describes the input request
+																					HullResult           &result)         // contains the resulst
+{
+	HullError ret = QE_FAIL;
+
+
+	PHullResult hr;
+
+	unsigned int vcount = desc.mVcount;
+	if ( vcount < 8 ) vcount = 8;
+
+	btAlignedObjectArray<btVector3> vertexSource;
+	vertexSource.resize(static_cast<int>(vcount));
+
+	btVector3 scale;
+
+	unsigned int ovcount;
+
+	bool ok = CleanupVertices(desc.mVcount,desc.mVertices, desc.mVertexStride, ovcount, &vertexSource[0], desc.mNormalEpsilon, scale ); // normalize point cloud, remove duplicates!
+
+	if ( ok )
+	{
+
+
+//		if ( 1 ) // scale vertices back to their original size.
+		{
+			for (unsigned int i=0; i<ovcount; i++)
+			{
+				btVector3& v = vertexSource[static_cast<int>(i)];
+				v[0]*=scale[0];
+				v[1]*=scale[1];
+				v[2]*=scale[2];
+			}
+		}
+
+		ok = ComputeHull(ovcount,&vertexSource[0],hr,desc.mMaxVertices);
+
+		if ( ok )
+		{
+
+			// re-index triangle mesh so it refers to only used vertices, rebuild a new vertex table.
+			btAlignedObjectArray<btVector3>	vertexScratch;
+			vertexScratch.resize(static_cast<int>(hr.mVcount));
+
+			BringOutYourDead(hr.mVertices,hr.mVcount, &vertexScratch[0], ovcount, &hr.m_Indices[0], hr.mIndexCount );
+
+			ret = QE_OK;
+
+			if ( desc.HasHullFlag(QF_TRIANGLES) ) // if he wants the results as triangle!
+			{
+				result.mPolygons          = false;
+				result.mNumOutputVertices = ovcount;
+				result.m_OutputVertices.resize(static_cast<int>(ovcount));
+				result.mNumFaces          = hr.mFaceCount;
+				result.mNumIndices        = hr.mIndexCount;
+
+				result.m_Indices.resize(static_cast<int>(hr.mIndexCount));
+
+				memcpy(&result.m_OutputVertices[0], &vertexScratch[0], sizeof(btVector3)*ovcount );
+
+  			if ( desc.HasHullFlag(QF_REVERSE_ORDER) )
+				{
+
+					const unsigned int *source = &hr.m_Indices[0];
+					unsigned int *dest   = &result.m_Indices[0];
+
+					for (unsigned int i=0; i<hr.mFaceCount; i++)
+					{
+						dest[0] = source[2];
+						dest[1] = source[1];
+						dest[2] = source[0];
+						dest+=3;
+						source+=3;
+					}
+
+				}
+				else
+				{
+					memcpy(&result.m_Indices[0], &hr.m_Indices[0], sizeof(unsigned int)*hr.mIndexCount);
+				}
+			}
+			else
+			{
+				result.mPolygons          = true;
+				result.mNumOutputVertices = ovcount;
+				result.m_OutputVertices.resize(static_cast<int>(ovcount));
+				result.mNumFaces          = hr.mFaceCount;
+				result.mNumIndices        = hr.mIndexCount+hr.mFaceCount;
+				result.m_Indices.resize(static_cast<int>(result.mNumIndices));
+				memcpy(&result.m_OutputVertices[0], &vertexScratch[0], sizeof(btVector3)*ovcount );
+
+//				if ( 1 )
+				{
+					const unsigned int *source = &hr.m_Indices[0];
+					unsigned int *dest   = &result.m_Indices[0];
+					for (unsigned int i=0; i<hr.mFaceCount; i++)
+					{
+						dest[0] = 3;
+						if ( desc.HasHullFlag(QF_REVERSE_ORDER) )
+						{
+							dest[1] = source[2];
+							dest[2] = source[1];
+							dest[3] = source[0];
+						}
+						else
+						{
+							dest[1] = source[0];
+							dest[2] = source[1];
+							dest[3] = source[2];
+						}
+
+						dest+=4;
+						source+=3;
+					}
+				}
+			}
+			ReleaseHull(hr);
+		}
+	}
+
+	return ret;
+}
+
+
+
+HullError HullLibrary::ReleaseResult(HullResult &result) // release memory allocated for this result, we are done with it.
+{
+	if ( result.m_OutputVertices.size())
+	{
+		result.mNumOutputVertices=0;
+		result.m_OutputVertices.clear();
+	}
+	if ( result.m_Indices.size() )
+	{
+		result.mNumIndices=0;
+		result.m_Indices.clear();
+	}
+	return QE_OK;
+}
+
+
+static void addPoint(unsigned int &vcount,btVector3 *p,btScalar x,btScalar y,btScalar z)
+{
+	// XXX, might be broken
+	btVector3& dest = p[vcount];
+	dest[0] = x;
+	dest[1] = y;
+	dest[2] = z;
+	vcount++;
+}
+
+btScalar GetDist(btScalar px,btScalar py,btScalar pz,const btScalar *p2);
+btScalar GetDist(btScalar px,btScalar py,btScalar pz,const btScalar *p2)
+{
+
+	btScalar dx = px - p2[0];
+	btScalar dy = py - p2[1];
+	btScalar dz = pz - p2[2];
+
+	return dx*dx+dy*dy+dz*dz;
+}
+
+
+
+bool  HullLibrary::CleanupVertices(unsigned int svcount,
+				   const btVector3 *svertices,
+				   unsigned int stride,
+				   unsigned int &vcount,       // output number of vertices
+				   btVector3 *vertices,                 // location to store the results.
+				   btScalar  normalepsilon,
+				   btVector3& scale)
+{
+	if ( svcount == 0 ) return false;
+
+	m_vertexIndexMapping.resize(0);
+
+
+#define EPSILON btScalar(0.000001) /* close enough to consider two btScalaring point numbers to be 'the same'. */
+
+	vcount = 0;
+
+	btScalar recip[3];
+
+	if ( scale )
+	{
+		scale[0] = 1;
+		scale[1] = 1;
+		scale[2] = 1;
+	}
+
+	btScalar bmin[3] = {  FLT_MAX,  FLT_MAX,  FLT_MAX };
+	btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
+
+	const char *vtx = (const char *) svertices;
+
+//	if ( 1 )
+	{
+		for (unsigned int i=0; i<svcount; i++)
+		{
+			const btScalar *p = (const btScalar *) vtx;
+
+			vtx+=stride;
+
+			for (int j=0; j<3; j++)
+			{
+				if ( p[j] < bmin[j] ) bmin[j] = p[j];
+				if ( p[j] > bmax[j] ) bmax[j] = p[j];
+			}
+		}
+	}
+
+	btScalar dx = bmax[0] - bmin[0];
+	btScalar dy = bmax[1] - bmin[1];
+	btScalar dz = bmax[2] - bmin[2];
+
+	btVector3 center;
+
+	center[0] = dx*btScalar(0.5) + bmin[0];
+	center[1] = dy*btScalar(0.5) + bmin[1];
+	center[2] = dz*btScalar(0.5) + bmin[2];
+
+	if ( dx < EPSILON || dy < EPSILON || dz < EPSILON || svcount < 3 )
+	{
+
+		btScalar len = FLT_MAX;
+
+		if ( dx > EPSILON && dx < len ) len = dx;
+		if ( dy > EPSILON && dy < len ) len = dy;
+		if ( dz > EPSILON && dz < len ) len = dz;
+
+		if ( len == FLT_MAX )
+		{
+			dx = dy = dz = btScalar(0.01); // one centimeter
+		}
+		else
+		{
+			if ( dx < EPSILON ) dx = len * btScalar(0.05); // 1/5th the shortest non-zero edge.
+			if ( dy < EPSILON ) dy = len * btScalar(0.05);
+			if ( dz < EPSILON ) dz = len * btScalar(0.05);
+		}
+
+		btScalar x1 = center[0] - dx;
+		btScalar x2 = center[0] + dx;
+
+		btScalar y1 = center[1] - dy;
+		btScalar y2 = center[1] + dy;
+
+		btScalar z1 = center[2] - dz;
+		btScalar z2 = center[2] + dz;
+
+		addPoint(vcount,vertices,x1,y1,z1);
+		addPoint(vcount,vertices,x2,y1,z1);
+		addPoint(vcount,vertices,x2,y2,z1);
+		addPoint(vcount,vertices,x1,y2,z1);
+		addPoint(vcount,vertices,x1,y1,z2);
+		addPoint(vcount,vertices,x2,y1,z2);
+		addPoint(vcount,vertices,x2,y2,z2);
+		addPoint(vcount,vertices,x1,y2,z2);
+
+		return true; // return cube
+
+
+	}
+	else
+	{
+		if ( scale )
+		{
+			scale[0] = dx;
+			scale[1] = dy;
+			scale[2] = dz;
+
+			recip[0] = 1 / dx;
+			recip[1] = 1 / dy;
+			recip[2] = 1 / dz;
+
+			center[0]*=recip[0];
+			center[1]*=recip[1];
+			center[2]*=recip[2];
+
+		}
+
+	}
+
+
+
+	vtx = (const char *) svertices;
+
+	for (unsigned int i=0; i<svcount; i++)
+	{
+		const btVector3 *p = (const btVector3 *)vtx;
+		vtx+=stride;
+
+		btScalar px = p->getX();
+		btScalar py = p->getY();
+		btScalar pz = p->getZ();
+
+		if ( scale )
+		{
+			px = px*recip[0]; // normalize
+			py = py*recip[1]; // normalize
+			pz = pz*recip[2]; // normalize
+		}
+
+//		if ( 1 )
+		{
+			unsigned int j;
+
+			for (j=0; j<vcount; j++)
+			{
+				/// XXX might be broken
+				btVector3& v = vertices[j];
+
+				btScalar x = v[0];
+				btScalar y = v[1];
+				btScalar z = v[2];
+
+				btScalar dx = fabsf(x - px );
+				btScalar dy = fabsf(y - py );
+				btScalar dz = fabsf(z - pz );
+
+				if ( dx < normalepsilon && dy < normalepsilon && dz < normalepsilon )
+				{
+					// ok, it is close enough to the old one
+					// now let us see if it is further from the center of the point cloud than the one we already recorded.
+					// in which case we keep this one instead.
+
+					btScalar dist1 = GetDist(px,py,pz,center);
+					btScalar dist2 = GetDist(v[0],v[1],v[2],center);
+
+					if ( dist1 > dist2 )
+					{
+						v[0] = px;
+						v[1] = py;
+						v[2] = pz;
+						
+					}
+
+					break;
+				}
+			}
+
+			if ( j == vcount )
+			{
+				btVector3& dest = vertices[vcount];
+				dest[0] = px;
+				dest[1] = py;
+				dest[2] = pz;
+				vcount++;
+			}
+			m_vertexIndexMapping.push_back(j);
+		}
+	}
+
+	// ok..now make sure we didn't prune so many vertices it is now invalid.
+//	if ( 1 )
+	{
+		btScalar bmin[3] = {  FLT_MAX,  FLT_MAX,  FLT_MAX };
+		btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
+
+		for (unsigned int i=0; i<vcount; i++)
+		{
+			const btVector3& p = vertices[i];
+			for (int j=0; j<3; j++)
+			{
+				if ( p[j] < bmin[j] ) bmin[j] = p[j];
+				if ( p[j] > bmax[j] ) bmax[j] = p[j];
+			}
+		}
+
+		btScalar dx = bmax[0] - bmin[0];
+		btScalar dy = bmax[1] - bmin[1];
+		btScalar dz = bmax[2] - bmin[2];
+
+		if ( dx < EPSILON || dy < EPSILON || dz < EPSILON || vcount < 3)
+		{
+			btScalar cx = dx*btScalar(0.5) + bmin[0];
+			btScalar cy = dy*btScalar(0.5) + bmin[1];
+			btScalar cz = dz*btScalar(0.5) + bmin[2];
+
+			btScalar len = FLT_MAX;
+
+			if ( dx >= EPSILON && dx < len ) len = dx;
+			if ( dy >= EPSILON && dy < len ) len = dy;
+			if ( dz >= EPSILON && dz < len ) len = dz;
+
+			if ( len == FLT_MAX )
+			{
+				dx = dy = dz = btScalar(0.01); // one centimeter
+			}
+			else
+			{
+				if ( dx < EPSILON ) dx = len * btScalar(0.05); // 1/5th the shortest non-zero edge.
+				if ( dy < EPSILON ) dy = len * btScalar(0.05);
+				if ( dz < EPSILON ) dz = len * btScalar(0.05);
+			}
+
+			btScalar x1 = cx - dx;
+			btScalar x2 = cx + dx;
+
+			btScalar y1 = cy - dy;
+			btScalar y2 = cy + dy;
+
+			btScalar z1 = cz - dz;
+			btScalar z2 = cz + dz;
+
+			vcount = 0; // add box
+
+			addPoint(vcount,vertices,x1,y1,z1);
+			addPoint(vcount,vertices,x2,y1,z1);
+			addPoint(vcount,vertices,x2,y2,z1);
+			addPoint(vcount,vertices,x1,y2,z1);
+			addPoint(vcount,vertices,x1,y1,z2);
+			addPoint(vcount,vertices,x2,y1,z2);
+			addPoint(vcount,vertices,x2,y2,z2);
+			addPoint(vcount,vertices,x1,y2,z2);
+
+			return true;
+		}
+	}
+
+	return true;
+}
+
+void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int *indices,unsigned indexcount)
+{
+	btAlignedObjectArray<int>tmpIndices;
+	tmpIndices.resize(m_vertexIndexMapping.size());
+	int i;
+
+	for (i=0;i<m_vertexIndexMapping.size();i++)
+	{
+		tmpIndices[i] = m_vertexIndexMapping[i];
+	}
+
+	TUIntArray usedIndices;
+	usedIndices.resize(static_cast<int>(vcount));
+	memset(&usedIndices[0],0,sizeof(unsigned int)*vcount);
+
+	ocount = 0;
+
+	for (i=0; i<indexcount; i++)
+	{
+		unsigned int v = indices[i]; // original array index
+
+		btAssert( v >= 0 && v < vcount );
+
+		if ( usedIndices[static_cast<int>(v)] ) // if already remapped
+		{
+			indices[i] = usedIndices[static_cast<int>(v)]-1; // index to new array
+		}
+		else
+		{
+
+			indices[i] = ocount;      // new index mapping
+
+			overts[ocount][0] = verts[v][0]; // copy old vert to new vert array
+			overts[ocount][1] = verts[v][1];
+			overts[ocount][2] = verts[v][2];
+
+			for (int k=0;k<m_vertexIndexMapping.size();k++)
+			{
+				if (tmpIndices[k]==v)
+					m_vertexIndexMapping[k]=ocount;
+			}
+
+			ocount++; // increment output vert count
+
+			btAssert( ocount >=0 && ocount <= vcount );
+
+			usedIndices[static_cast<int>(v)] = ocount; // assign new index remapping
+
+		
+		}
+	}
+
+	
+}
Index: /code/branches/physics/src/bullet/LinearMath/btConvexHull.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btConvexHull.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btConvexHull.h	(revision 2122)
@@ -0,0 +1,245 @@
+
+/*
+Stan Melax Convex Hull Computation
+Copyright (c) 2008 Stan Melax http://www.melax.com/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+///includes modifications/improvements by John Ratcliff, see BringOutYourDead below.
+
+#ifndef CD_HULL_H
+#define CD_HULL_H
+
+#include "LinearMath/btVector3.h"
+#include "LinearMath/btAlignedObjectArray.h"
+
+typedef btAlignedObjectArray<unsigned int> TUIntArray;
+
+class HullResult
+{
+public:
+	HullResult(void)
+	{
+		mPolygons = true;
+		mNumOutputVertices = 0;
+		mNumFaces = 0;
+		mNumIndices = 0;
+	}
+	bool                    mPolygons;                  // true if indices represents polygons, false indices are triangles
+	unsigned int            mNumOutputVertices;         // number of vertices in the output hull
+	btAlignedObjectArray<btVector3>	m_OutputVertices;            // array of vertices
+	unsigned int            mNumFaces;                  // the number of faces produced
+	unsigned int            mNumIndices;                // the total number of indices
+	btAlignedObjectArray<unsigned int>    m_Indices;                   // pointer to indices.
+
+// If triangles, then indices are array indexes into the vertex list.
+// If polygons, indices are in the form (number of points in face) (p1, p2, p3, ..) etc..
+};
+
+enum HullFlag
+{
+	QF_TRIANGLES         = (1<<0),             // report results as triangles, not polygons.
+	QF_REVERSE_ORDER     = (1<<1),             // reverse order of the triangle indices.
+	QF_DEFAULT           = QF_TRIANGLES
+};
+
+
+class HullDesc
+{
+public:
+	HullDesc(void)
+	{
+		mFlags          = QF_DEFAULT;
+		mVcount         = 0;
+		mVertices       = 0;
+		mVertexStride   = sizeof(btVector3);
+		mNormalEpsilon  = 0.001f;
+		mMaxVertices	= 4096; // maximum number of points to be considered for a convex hull.
+		mMaxFaces	= 4096;
+	};
+
+	HullDesc(HullFlag flag,
+		 unsigned int vcount,
+		 const btVector3 *vertices,
+		 unsigned int stride = sizeof(btVector3))
+	{
+		mFlags          = flag;
+		mVcount         = vcount;
+		mVertices       = vertices;
+		mVertexStride   = stride;
+		mNormalEpsilon  = btScalar(0.001);
+		mMaxVertices    = 4096;
+	}
+
+	bool HasHullFlag(HullFlag flag) const
+	{
+		if ( mFlags & flag ) return true;
+		return false;
+	}
+
+	void SetHullFlag(HullFlag flag)
+	{
+		mFlags|=flag;
+	}
+
+	void ClearHullFlag(HullFlag flag)
+	{
+		mFlags&=~flag;
+	}
+
+	unsigned int      mFlags;           // flags to use when generating the convex hull.
+	unsigned int      mVcount;          // number of vertices in the input point cloud
+	const btVector3  *mVertices;        // the array of vertices.
+	unsigned int      mVertexStride;    // the stride of each vertex, in bytes.
+	btScalar             mNormalEpsilon;   // the epsilon for removing duplicates.  This is a normalized value, if normalized bit is on.
+	unsigned int      mMaxVertices;     // maximum number of vertices to be considered for the hull!
+	unsigned int      mMaxFaces;
+};
+
+enum HullError
+{
+	QE_OK,            // success!
+	QE_FAIL           // failed.
+};
+
+class btPlane
+{
+	public:
+	btVector3	normal;
+	btScalar	dist;   // distance below origin - the D from plane equasion Ax+By+Cz+D=0
+			btPlane(const btVector3 &n,btScalar d):normal(n),dist(d){}
+			btPlane():normal(),dist(0){}
+	
+};
+
+
+
+class ConvexH 
+{
+  public:
+	class HalfEdge
+	{
+	  public:
+		short ea;         // the other half of the edge (index into edges list)
+		unsigned char v;  // the vertex at the start of this edge (index into vertices list)
+		unsigned char p;  // the facet on which this edge lies (index into facets list)
+		HalfEdge(){}
+		HalfEdge(short _ea,unsigned char _v, unsigned char _p):ea(_ea),v(_v),p(_p){}
+	};
+	ConvexH()
+	{
+		int i;
+		i=0;
+	}
+	~ConvexH()
+	{
+		int i;
+		i=0;
+	}
+	btAlignedObjectArray<btVector3> vertices;
+	btAlignedObjectArray<HalfEdge> edges;
+	btAlignedObjectArray<btPlane>  facets;
+	ConvexH(int vertices_size,int edges_size,int facets_size);
+};
+
+
+class int4
+{
+public:
+	int x,y,z,w;
+	int4(){};
+	int4(int _x,int _y, int _z,int _w){x=_x;y=_y;z=_z;w=_w;}
+	const int& operator[](int i) const {return (&x)[i];}
+	int& operator[](int i) {return (&x)[i];}
+};
+
+class PHullResult
+{
+public:
+
+	PHullResult(void)
+	{
+		mVcount = 0;
+		mIndexCount = 0;
+		mFaceCount = 0;
+		mVertices = 0;
+	}
+
+	unsigned int mVcount;
+	unsigned int mIndexCount;
+	unsigned int mFaceCount;
+	btVector3*   mVertices;
+	TUIntArray m_Indices;
+};
+
+
+
+///The HullLibrary class can create a convex hull from a collection of vertices, using the ComputeHull method.
+///The btShapeHull class uses this HullLibrary to create a approximate convex mesh given a general (non-polyhedral) convex shape.
+class HullLibrary
+{
+
+	btAlignedObjectArray<class Tri*> m_tris;
+
+public:
+
+	btAlignedObjectArray<int> m_vertexIndexMapping;
+
+
+	HullError CreateConvexHull(const HullDesc& desc, // describes the input request
+				   HullResult&     result);        // contains the resulst
+	HullError ReleaseResult(HullResult &result); // release memory allocated for this result, we are done with it.
+
+private:
+
+	bool ComputeHull(unsigned int vcount,const btVector3 *vertices,PHullResult &result,unsigned int vlimit);
+
+	class Tri*	allocateTriangle(int a,int b,int c);
+	void	deAllocateTriangle(Tri*);
+	void b2bfix(Tri* s,Tri*t);
+
+	void removeb2b(Tri* s,Tri*t);
+
+	void checkit(Tri *t);
+
+	Tri* extrudable(btScalar epsilon);
+
+	int calchull(btVector3 *verts,int verts_count, TUIntArray& tris_out, int &tris_count,int vlimit);
+
+	int calchullgen(btVector3 *verts,int verts_count, int vlimit);
+
+	int4 FindSimplex(btVector3 *verts,int verts_count,btAlignedObjectArray<int> &allow);
+
+	class ConvexH* ConvexHCrop(ConvexH& convex,const btPlane& slice);
+
+	void extrude(class Tri* t0,int v);
+
+	ConvexH* test_cube();
+
+	//BringOutYourDead (John Ratcliff): When you create a convex hull you hand it a large input set of vertices forming a 'point cloud'. 
+	//After the hull is generated it give you back a set of polygon faces which index the *original* point cloud.
+	//The thing is, often times, there are many 'dead vertices' in the point cloud that are on longer referenced by the hull.
+	//The routine 'BringOutYourDead' find only the referenced vertices, copies them to an new buffer, and re-indexes the hull so that it is a minimal representation.
+	void BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int* indices,unsigned indexcount);
+
+	bool CleanupVertices(unsigned int svcount,
+			     const btVector3* svertices,
+			     unsigned int stride,
+			     unsigned int &vcount, // output number of vertices
+			     btVector3* vertices, // location to store the results.
+			     btScalar  normalepsilon,
+			     btVector3& scale);
+};
+
+
+#endif
+
Index: /code/branches/physics/src/bullet/LinearMath/btDefaultMotionState.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btDefaultMotionState.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btDefaultMotionState.h	(revision 2122)
@@ -0,0 +1,38 @@
+#ifndef DEFAULT_MOTION_STATE_H
+#define DEFAULT_MOTION_STATE_H
+
+///The btDefaultMotionState provides a common implementation to synchronize world transforms with offsets.
+struct	btDefaultMotionState : public btMotionState
+{
+	btTransform m_graphicsWorldTrans;
+	btTransform	m_centerOfMassOffset;
+	btTransform m_startWorldTrans;
+	void*		m_userPointer;
+
+	btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(),const btTransform& centerOfMassOffset = btTransform::getIdentity())
+		: m_graphicsWorldTrans(startTrans),
+		m_centerOfMassOffset(centerOfMassOffset),
+		m_startWorldTrans(startTrans),
+		m_userPointer(0)
+
+	{
+	}
+
+	///synchronizes world transform from user to physics
+	virtual void	getWorldTransform(btTransform& centerOfMassWorldTrans ) const 
+	{
+			centerOfMassWorldTrans = 	m_centerOfMassOffset.inverse() * m_graphicsWorldTrans ;
+	}
+
+	///synchronizes world transform from physics to user
+	///Bullet only calls the update of worldtransform for active objects
+	virtual void	setWorldTransform(const btTransform& centerOfMassWorldTrans)
+	{
+			m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset ;
+	}
+
+	
+
+};
+
+#endif //DEFAULT_MOTION_STATE_H
Index: /code/branches/physics/src/bullet/LinearMath/btGeometryUtil.cpp
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btGeometryUtil.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btGeometryUtil.cpp	(revision 2122)
@@ -0,0 +1,185 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#include "btGeometryUtil.h"
+
+
+/*
+  Make sure this dummy function never changes so that it
+  can be used by probes that are checking whether the
+  library is actually installed.
+*/
+extern "C"
+{	
+	void btBulletMathProbe ();
+
+	void btBulletMathProbe () {}
+}
+
+
+bool	btGeometryUtil::isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, btScalar	margin)
+{
+	int numbrushes = planeEquations.size();
+	for (int i=0;i<numbrushes;i++)
+	{
+		const btVector3& N1 = planeEquations[i];
+		btScalar dist = btScalar(N1.dot(point))+btScalar(N1[3])-margin;
+		if (dist>btScalar(0.))
+		{
+			return false;
+		}
+	}
+	return true;
+		
+}
+
+
+bool	btGeometryUtil::areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray<btVector3>& vertices, btScalar	margin)
+{
+	int numvertices = vertices.size();
+	for (int i=0;i<numvertices;i++)
+	{
+		const btVector3& N1 = vertices[i];
+		btScalar dist = btScalar(planeNormal.dot(N1))+btScalar(planeNormal[3])-margin;
+		if (dist>btScalar(0.))
+		{
+			return false;
+		}
+	}
+	return true;
+}
+
+bool notExist(const btVector3& planeEquation,const btAlignedObjectArray<btVector3>& planeEquations);
+
+bool notExist(const btVector3& planeEquation,const btAlignedObjectArray<btVector3>& planeEquations)
+{
+	int numbrushes = planeEquations.size();
+	for (int i=0;i<numbrushes;i++)
+	{
+		const btVector3& N1 = planeEquations[i];
+		if (planeEquation.dot(N1) > btScalar(0.999))
+		{
+			return false;
+		} 
+	}
+	return true;
+}
+
+void	btGeometryUtil::getPlaneEquationsFromVertices(btAlignedObjectArray<btVector3>& vertices, btAlignedObjectArray<btVector3>& planeEquationsOut )
+{
+		const int numvertices = vertices.size();
+	// brute force:
+	for (int i=0;i<numvertices;i++)
+	{
+		const btVector3& N1 = vertices[i];
+		
+
+		for (int j=i+1;j<numvertices;j++)
+		{
+			const btVector3& N2 = vertices[j];
+				
+			for (int k=j+1;k<numvertices;k++)
+			{
+
+				const btVector3& N3 = vertices[k];
+
+				btVector3 planeEquation,edge0,edge1;
+				edge0 = N2-N1;
+				edge1 = N3-N1;
+				btScalar normalSign = btScalar(1.);
+				for (int ww=0;ww<2;ww++)
+				{
+					planeEquation = normalSign * edge0.cross(edge1);
+					if (planeEquation.length2() > btScalar(0.0001))
+					{
+						planeEquation.normalize();
+						if (notExist(planeEquation,planeEquationsOut))
+						{
+							planeEquation[3] = -planeEquation.dot(N1);
+							
+								//check if inside, and replace supportingVertexOut if needed
+								if (areVerticesBehindPlane(planeEquation,vertices,btScalar(0.01)))
+								{
+									planeEquationsOut.push_back(planeEquation);
+								}
+						}
+					}
+					normalSign = btScalar(-1.);
+				}
+			
+			}
+		}
+	}
+
+}
+
+void	btGeometryUtil::getVerticesFromPlaneEquations(const btAlignedObjectArray<btVector3>& planeEquations , btAlignedObjectArray<btVector3>& verticesOut )
+{
+	const int numbrushes = planeEquations.size();
+	// brute force:
+	for (int i=0;i<numbrushes;i++)
+	{
+		const btVector3& N1 = planeEquations[i];
+		
+
+		for (int j=i+1;j<numbrushes;j++)
+		{
+			const btVector3& N2 = planeEquations[j];
+				
+			for (int k=j+1;k<numbrushes;k++)
+			{
+
+				const btVector3& N3 = planeEquations[k];
+
+				btVector3 n2n3; n2n3 = N2.cross(N3);
+				btVector3 n3n1; n3n1 = N3.cross(N1);
+				btVector3 n1n2; n1n2 = N1.cross(N2);
+				
+				if ( ( n2n3.length2() > btScalar(0.0001) ) &&
+					 ( n3n1.length2() > btScalar(0.0001) ) &&
+					 ( n1n2.length2() > btScalar(0.0001) ) )
+				{
+					//point P out of 3 plane equations:
+
+					//	d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 )  
+					//P =  -------------------------------------------------------------------------  
+					//   N1 . ( N2 * N3 )  
+
+
+					btScalar quotient = (N1.dot(n2n3));
+					if (btFabs(quotient) > btScalar(0.000001))
+					{
+						quotient = btScalar(-1.) / quotient;
+						n2n3 *= N1[3];
+						n3n1 *= N2[3];
+						n1n2 *= N3[3];
+						btVector3 potentialVertex = n2n3;
+						potentialVertex += n3n1;
+						potentialVertex += n1n2;
+						potentialVertex *= quotient;
+
+						//check if inside, and replace supportingVertexOut if needed
+						if (isPointInsidePlanes(planeEquations,potentialVertex,btScalar(0.01)))
+						{
+							verticesOut.push_back(potentialVertex);
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
Index: /code/branches/physics/src/bullet/LinearMath/btGeometryUtil.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btGeometryUtil.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btGeometryUtil.h	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef BT_GEOMETRY_UTIL_H
+#define BT_GEOMETRY_UTIL_H
+
+#include "btVector3.h"
+#include "btAlignedObjectArray.h"
+
+///The btGeometryUtil helper class provides a few methods to convert between plane equations and vertices.
+class btGeometryUtil
+{
+	public:
+	
+	
+		static void	getPlaneEquationsFromVertices(btAlignedObjectArray<btVector3>& vertices, btAlignedObjectArray<btVector3>& planeEquationsOut );
+
+		static void	getVerticesFromPlaneEquations(const btAlignedObjectArray<btVector3>& planeEquations , btAlignedObjectArray<btVector3>& verticesOut );
+	
+		static bool	isInside(const btAlignedObjectArray<btVector3>& vertices, const btVector3& planeNormal, btScalar	margin);
+		
+		static bool	isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, btScalar	margin);
+
+		static bool	areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray<btVector3>& vertices, btScalar	margin);
+
+};
+
+
+#endif //BT_GEOMETRY_UTIL_H
+
Index: /code/branches/physics/src/bullet/LinearMath/btHashMap.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btHashMap.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btHashMap.h	(revision 2122)
@@ -0,0 +1,303 @@
+#ifndef BT_HASH_MAP_H
+#define BT_HASH_MAP_H
+
+#include "btAlignedObjectArray.h"
+
+const int BT_HASH_NULL=0xffffffff;
+
+template <class Value>
+class btHashKey
+{
+	int	m_uid;
+public:
+
+	btHashKey(int uid)
+		:m_uid(uid)
+	{
+	}
+
+	int	getUid() const
+	{
+		return m_uid;
+	}
+
+	//to our success
+	SIMD_FORCE_INLINE	unsigned int getHash()const
+	{
+		int key = m_uid;
+		// Thomas Wang's hash
+		key += ~(key << 15);
+		key ^=  (key >> 10);
+		key +=  (key << 3);
+		key ^=  (key >> 6);
+		key += ~(key << 11);
+		key ^=  (key >> 16);
+		return key;
+	}
+
+	btHashKey	getKey(const Value& value) const
+	{
+		return btHashKey(value.getUid());
+	}
+};
+
+
+template <class Value>
+class btHashKeyPtr
+{
+	int	m_uid;
+public:
+
+	btHashKeyPtr(int uid)
+		:m_uid(uid)
+	{
+	}
+
+	int	getUid() const
+	{
+		return m_uid;
+	}
+
+	//to our success
+	SIMD_FORCE_INLINE	unsigned int getHash()const
+	{
+		int key = m_uid;
+		// Thomas Wang's hash
+		key += ~(key << 15);
+		key ^=  (key >> 10);
+		key +=  (key << 3);
+		key ^=  (key >> 6);
+		key += ~(key << 11);
+		key ^=  (key >> 16);
+		return key;
+	}
+
+	btHashKeyPtr	getKey(const Value& value) const
+	{
+		return btHashKeyPtr(value->getUid());
+	}
+};
+
+///The btHashMap template class implements a generic and lightweight hashmap.
+///A basic sample of how to use btHashMap is located in Demos\BasicDemo\main.cpp
+template <class Key, class Value>
+class btHashMap
+{
+
+	btAlignedObjectArray<int>		m_hashTable;
+	btAlignedObjectArray<int>		m_next;
+	btAlignedObjectArray<Value>		m_valueArray;
+
+
+
+	void	growTables(const Key& key)
+	{
+		int newCapacity = m_valueArray.capacity();
+
+		if (m_hashTable.size() < newCapacity)
+		{
+			//grow hashtable and next table
+			int curHashtableSize = m_hashTable.size();
+
+			m_hashTable.resize(newCapacity);
+			m_next.resize(newCapacity);
+
+			int i;
+
+			for (i= 0; i < newCapacity; ++i)
+			{
+				m_hashTable[i] = BT_HASH_NULL;
+			}
+			for (i = 0; i < newCapacity; ++i)
+			{
+				m_next[i] = BT_HASH_NULL;
+			}
+
+			for(i=0;i<curHashtableSize;i++)
+			{
+				const Value& value = m_valueArray[i];
+
+				int	hashValue = key.getKey(value).getHash() & (m_valueArray.capacity()-1);	// New hash value with new mask
+				m_next[i] = m_hashTable[hashValue];
+				m_hashTable[hashValue] = i;
+			}
+
+
+		}
+	}
+
+	public:
+
+	void insert(const Key& key, const Value& value) {
+		int hash = key.getHash() & (m_valueArray.capacity()-1);
+		//don't add it if it is already there
+		if (find(key))
+		{
+			return;
+		}
+		int count = m_valueArray.size();
+		int oldCapacity = m_valueArray.capacity();
+		m_valueArray.push_back(value);
+		int newCapacity = m_valueArray.capacity();
+		if (oldCapacity < newCapacity)
+		{
+			growTables(key);
+			//hash with new capacity
+			hash = key.getHash() & (m_valueArray.capacity()-1);
+		}
+		m_next[count] = m_hashTable[hash];
+		m_hashTable[hash] = count;
+	}
+
+	void remove(const Key& key) {
+
+		int hash = key.getHash() & (m_valueArray.capacity()-1);
+
+		int pairIndex = findIndex(key);
+		
+		if (pairIndex ==BT_HASH_NULL)
+		{
+			return;
+		}
+
+		// Remove the pair from the hash table.
+		int index = m_hashTable[hash];
+		btAssert(index != BT_HASH_NULL);
+
+		int previous = BT_HASH_NULL;
+		while (index != pairIndex)
+		{
+			previous = index;
+			index = m_next[index];
+		}
+
+		if (previous != BT_HASH_NULL)
+		{
+			btAssert(m_next[previous] == pairIndex);
+			m_next[previous] = m_next[pairIndex];
+		}
+		else
+		{
+			m_hashTable[hash] = m_next[pairIndex];
+		}
+
+		// We now move the last pair into spot of the
+		// pair being removed. We need to fix the hash
+		// table indices to support the move.
+
+		int lastPairIndex = m_valueArray.size() - 1;
+
+		// If the removed pair is the last pair, we are done.
+		if (lastPairIndex == pairIndex)
+		{
+			m_valueArray.pop_back();
+			return;
+		}
+
+		// Remove the last pair from the hash table.
+		const Value* lastValue = &m_valueArray[lastPairIndex];
+		int lastHash = key.getKey(*lastValue).getHash() & (m_valueArray.capacity()-1);
+
+		index = m_hashTable[lastHash];
+		btAssert(index != BT_HASH_NULL);
+
+		previous = BT_HASH_NULL;
+		while (index != lastPairIndex)
+		{
+			previous = index;
+			index = m_next[index];
+		}
+
+		if (previous != BT_HASH_NULL)
+		{
+			btAssert(m_next[previous] == lastPairIndex);
+			m_next[previous] = m_next[lastPairIndex];
+		}
+		else
+		{
+			m_hashTable[lastHash] = m_next[lastPairIndex];
+		}
+
+		// Copy the last pair into the remove pair's spot.
+		m_valueArray[pairIndex] = m_valueArray[lastPairIndex];
+
+		// Insert the last pair into the hash table
+		m_next[pairIndex] = m_hashTable[lastHash];
+		m_hashTable[lastHash] = pairIndex;
+
+		m_valueArray.pop_back();
+
+	}
+
+
+	int size() const
+	{
+		return m_valueArray.size();
+	}
+
+	const Value* getAtIndex(int index) const
+	{
+		btAssert(index < m_valueArray.size());
+
+		return &m_valueArray[index];
+	}
+
+	Value* getAtIndex(int index)
+	{
+		btAssert(index < m_valueArray.size());
+
+		return &m_valueArray[index];
+	}
+
+	Value* operator[](const Key& key) {
+		return find(key);
+	}
+
+	const Value*	find(const Key& key) const
+	{
+		int index = findIndex(key);
+		if (index == BT_HASH_NULL)
+		{
+			return NULL;
+		}
+		return &m_valueArray[index];
+	}
+
+	Value*	find(const Key& key)
+	{
+		int index = findIndex(key);
+		if (index == BT_HASH_NULL)
+		{
+			return NULL;
+		}
+		return &m_valueArray[index];
+	}
+
+
+	int	findIndex(const Key& key) const
+	{
+		int hash = key.getHash() & (m_valueArray.capacity()-1);
+
+		if (hash >= m_hashTable.size())
+		{
+			return BT_HASH_NULL;
+		}
+
+		int index = m_hashTable[hash];
+		while ((index != BT_HASH_NULL) && (key.getUid() == key.getKey(m_valueArray[index]).getUid()) == false)
+		{
+			index = m_next[index];
+		}
+		return index;
+	}
+
+	void	clear()
+	{
+		m_hashTable.clear();
+		m_next.clear();
+		m_valueArray.clear();
+	}
+
+};
+
+#endif //BT_HASH_MAP_H
Index: /code/branches/physics/src/bullet/LinearMath/btIDebugDraw.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btIDebugDraw.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btIDebugDraw.h	(revision 2122)
@@ -0,0 +1,116 @@
+/*
+Copyright (c) 2005 Gino van den Bergen / Erwin Coumans http://continuousphysics.com
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#ifndef IDEBUG_DRAW__H
+#define IDEBUG_DRAW__H
+
+#include "btVector3.h"
+
+
+///The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
+///Typical use case: create a debug drawer object, and assign it to a btCollisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld.
+///A class that implements the btIDebugDraw interface has to implement the drawLine method at a minimum.
+class	btIDebugDraw
+{
+	public:
+
+	enum	DebugDrawModes
+	{
+		DBG_NoDebug=0,
+		DBG_DrawWireframe = 1,
+		DBG_DrawAabb=2,
+		DBG_DrawFeaturesText=4,
+		DBG_DrawContactPoints=8,
+		DBG_NoDeactivation=16,
+		DBG_NoHelpText = 32,
+		DBG_DrawText=64,
+		DBG_ProfileTimings = 128,
+		DBG_EnableSatComparison = 256,
+		DBG_DisableBulletLCP = 512,
+		DBG_EnableCCD = 1024,
+		DBG_MAX_DEBUG_DRAW_MODE
+	};
+
+	virtual ~btIDebugDraw() {};
+
+	virtual void	drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0;
+	
+	virtual	void	drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& /*n0*/,const btVector3& /*n1*/,const btVector3& /*n2*/,const btVector3& color, btScalar alpha)
+	{
+		drawTriangle(v0,v1,v2,color,alpha);
+	}
+	virtual	void	drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& color, btScalar /*alpha*/)
+	{
+		drawLine(v0,v1,color);
+		drawLine(v1,v2,color);
+		drawLine(v2,v0,color);
+	}
+
+	virtual void	drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)=0;
+
+	virtual void	reportErrorWarning(const char* warningString) = 0;
+
+	virtual void	draw3dText(const btVector3& location,const char* textString) = 0;
+	
+	virtual void	setDebugMode(int debugMode) =0;
+	
+	virtual int		getDebugMode() const = 0;
+
+	inline void drawAabb(const btVector3& from,const btVector3& to,const btVector3& color)
+	{
+
+		btVector3 halfExtents = (to-from)* 0.5f;
+		btVector3 center = (to+from) *0.5f;
+		int i,j;
+
+		btVector3 edgecoord(1.f,1.f,1.f),pa,pb;
+		for (i=0;i<4;i++)
+		{
+			for (j=0;j<3;j++)
+			{
+				pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],		
+					edgecoord[2]*halfExtents[2]);
+				pa+=center;
+
+				int othercoord = j%3;
+				edgecoord[othercoord]*=-1.f;
+				pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],	
+					edgecoord[2]*halfExtents[2]);
+				pb+=center;
+
+				drawLine(pa,pb,color);
+			}
+			edgecoord = btVector3(-1.f,-1.f,-1.f);
+			if (i<3)
+				edgecoord[i]*=-1.f;
+		}
+	}
+};
+
+
+#endif //IDEBUG_DRAW__H
+
Index: /code/branches/physics/src/bullet/LinearMath/btList.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btList.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btList.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef GEN_LIST_H
+#define GEN_LIST_H
+
+class btGEN_Link {
+public:
+    btGEN_Link() : m_next(0), m_prev(0) {}
+    btGEN_Link(btGEN_Link *next, btGEN_Link *prev) : m_next(next), m_prev(prev) {}
+    
+    btGEN_Link *getNext() const { return m_next; }  
+    btGEN_Link *getPrev() const { return m_prev; }  
+
+    bool isHead() const { return m_prev == 0; }
+    bool isTail() const { return m_next == 0; }
+
+    void insertBefore(btGEN_Link *link) {
+        m_next         = link;
+        m_prev         = link->m_prev;
+        m_next->m_prev = this;
+        m_prev->m_next = this;
+    } 
+
+    void insertAfter(btGEN_Link *link) {
+        m_next         = link->m_next;
+        m_prev         = link;
+        m_next->m_prev = this;
+        m_prev->m_next = this;
+    } 
+
+    void remove() { 
+        m_next->m_prev = m_prev; 
+        m_prev->m_next = m_next;
+    }
+
+private:  
+    btGEN_Link  *m_next;
+    btGEN_Link  *m_prev;
+};
+
+class btGEN_List {
+public:
+    btGEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {}
+
+    btGEN_Link *getHead() const { return m_head.getNext(); } 
+    btGEN_Link *getTail() const { return m_tail.getPrev(); } 
+
+    void addHead(btGEN_Link *link) { link->insertAfter(&m_head); }
+    void addTail(btGEN_Link *link) { link->insertBefore(&m_tail); }
+    
+private:
+    btGEN_Link m_head;
+    btGEN_Link m_tail;
+};
+
+#endif
+
+
+
Index: /code/branches/physics/src/bullet/LinearMath/btMatrix3x3.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btMatrix3x3.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btMatrix3x3.h	(revision 2122)
@@ -0,0 +1,504 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef btMatrix3x3_H
+#define btMatrix3x3_H
+
+#include "btScalar.h"
+
+#include "btVector3.h"
+#include "btQuaternion.h"
+
+
+
+///The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with btQuaternion, btTransform and btVector3.
+///Make sure to only include a pure orthogonal matrix without scaling.
+class btMatrix3x3 {
+	public:
+		btMatrix3x3 () {}
+		
+//		explicit btMatrix3x3(const btScalar *m) { setFromOpenGLSubMatrix(m); }
+		
+		explicit btMatrix3x3(const btQuaternion& q) { setRotation(q); }
+		/*
+		template <typename btScalar>
+		Matrix3x3(const btScalar& yaw, const btScalar& pitch, const btScalar& roll)
+		{ 
+			setEulerYPR(yaw, pitch, roll);
+		}
+		*/
+		btMatrix3x3(const btScalar& xx, const btScalar& xy, const btScalar& xz,
+				  const btScalar& yx, const btScalar& yy, const btScalar& yz,
+				  const btScalar& zx, const btScalar& zy, const btScalar& zz)
+		{ 
+			setValue(xx, xy, xz, 
+					 yx, yy, yz, 
+					 zx, zy, zz);
+		}
+		
+		SIMD_FORCE_INLINE btMatrix3x3 (const btMatrix3x3& other)
+		{
+			m_el[0] = other.m_el[0];
+			m_el[1] = other.m_el[1];
+			m_el[2] = other.m_el[2];
+		}
+
+		SIMD_FORCE_INLINE btMatrix3x3& operator=(const btMatrix3x3& other)
+		{
+			m_el[0] = other.m_el[0];
+			m_el[1] = other.m_el[1];
+			m_el[2] = other.m_el[2];
+			return *this;
+		}
+
+		SIMD_FORCE_INLINE btVector3 getColumn(int i) const
+		{
+			return btVector3(m_el[0][i],m_el[1][i],m_el[2][i]);
+		}
+		
+
+
+		SIMD_FORCE_INLINE const btVector3& getRow(int i) const
+		{
+			return m_el[i];
+		}
+
+
+		SIMD_FORCE_INLINE btVector3&  operator[](int i)
+		{ 
+			btFullAssert(0 <= i && i < 3);
+			return m_el[i]; 
+		}
+		
+		SIMD_FORCE_INLINE const btVector3& operator[](int i) const
+		{
+			btFullAssert(0 <= i && i < 3);
+			return m_el[i]; 
+		}
+		
+		btMatrix3x3& operator*=(const btMatrix3x3& m); 
+		
+	
+	void setFromOpenGLSubMatrix(const btScalar *m)
+		{
+			m_el[0].setValue(m[0],m[4],m[8]);
+			m_el[1].setValue(m[1],m[5],m[9]);
+			m_el[2].setValue(m[2],m[6],m[10]);
+
+		}
+
+		void setValue(const btScalar& xx, const btScalar& xy, const btScalar& xz, 
+					  const btScalar& yx, const btScalar& yy, const btScalar& yz, 
+					  const btScalar& zx, const btScalar& zy, const btScalar& zz)
+		{
+			m_el[0].setValue(xx,xy,xz);
+			m_el[1].setValue(yx,yy,yz);
+			m_el[2].setValue(zx,zy,zz);
+		}
+  
+		void setRotation(const btQuaternion& q) 
+		{
+			btScalar d = q.length2();
+			btFullAssert(d != btScalar(0.0));
+			btScalar s = btScalar(2.0) / d;
+			btScalar xs = q.x() * s,   ys = q.y() * s,   zs = q.z() * s;
+			btScalar wx = q.w() * xs,  wy = q.w() * ys,  wz = q.w() * zs;
+			btScalar xx = q.x() * xs,  xy = q.x() * ys,  xz = q.x() * zs;
+			btScalar yy = q.y() * ys,  yz = q.y() * zs,  zz = q.z() * zs;
+			setValue(btScalar(1.0) - (yy + zz), xy - wz, xz + wy,
+					 xy + wz, btScalar(1.0) - (xx + zz), yz - wx,
+					 xz - wy, yz + wx, btScalar(1.0) - (xx + yy));
+		}
+		
+
+
+		void setEulerYPR(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) 
+		{
+
+			btScalar cy(btCos(yaw)); 
+			btScalar  sy(btSin(yaw)); 
+			btScalar  cp(btCos(pitch)); 
+			btScalar  sp(btSin(pitch)); 
+			btScalar  cr(btCos(roll));
+			btScalar  sr(btSin(roll));
+			btScalar  cc = cy * cr; 
+			btScalar  cs = cy * sr; 
+			btScalar  sc = sy * cr; 
+			btScalar  ss = sy * sr;
+			setValue(cc - sp * ss, -cs - sp * sc, -sy * cp,
+                     cp * sr,       cp * cr,      -sp,
+					 sc + sp * cs, -ss + sp * cc,  cy * cp);
+		
+		}
+
+	/**
+	 * setEulerZYX
+	 * @param euler a const reference to a btVector3 of euler angles
+	 * These angles are used to produce a rotation matrix. The euler
+	 * angles are applied in ZYX order. I.e a vector is first rotated 
+	 * about X then Y and then Z
+	 **/
+	
+	void setEulerZYX(btScalar eulerX,btScalar eulerY,btScalar eulerZ) {
+		btScalar ci ( btCos(eulerX)); 
+		btScalar cj ( btCos(eulerY)); 
+		btScalar ch ( btCos(eulerZ)); 
+		btScalar si ( btSin(eulerX)); 
+		btScalar sj ( btSin(eulerY)); 
+		btScalar sh ( btSin(eulerZ)); 
+		btScalar cc = ci * ch; 
+		btScalar cs = ci * sh; 
+		btScalar sc = si * ch; 
+		btScalar ss = si * sh;
+		
+		setValue(cj * ch, sj * sc - cs, sj * cc + ss,
+				 cj * sh, sj * ss + cc, sj * cs - sc, 
+	       			 -sj,      cj * si,      cj * ci);
+	}
+
+		void setIdentity()
+		{ 
+			setValue(btScalar(1.0), btScalar(0.0), btScalar(0.0), 
+					 btScalar(0.0), btScalar(1.0), btScalar(0.0), 
+					 btScalar(0.0), btScalar(0.0), btScalar(1.0)); 
+		}
+    
+		void getOpenGLSubMatrix(btScalar *m) const 
+		{
+			m[0]  = btScalar(m_el[0].x()); 
+			m[1]  = btScalar(m_el[1].x());
+			m[2]  = btScalar(m_el[2].x());
+			m[3]  = btScalar(0.0); 
+			m[4]  = btScalar(m_el[0].y());
+			m[5]  = btScalar(m_el[1].y());
+			m[6]  = btScalar(m_el[2].y());
+			m[7]  = btScalar(0.0); 
+			m[8]  = btScalar(m_el[0].z()); 
+			m[9]  = btScalar(m_el[1].z());
+			m[10] = btScalar(m_el[2].z());
+			m[11] = btScalar(0.0); 
+		}
+
+		void getRotation(btQuaternion& q) const
+		{
+			btScalar trace = m_el[0].x() + m_el[1].y() + m_el[2].z();
+			btScalar temp[4];
+			
+			if (trace > btScalar(0.0)) 
+			{
+				btScalar s = btSqrt(trace + btScalar(1.0));
+				temp[3]=(s * btScalar(0.5));
+				s = btScalar(0.5) / s;
+				
+				temp[0]=((m_el[2].y() - m_el[1].z()) * s);
+				temp[1]=((m_el[0].z() - m_el[2].x()) * s);
+				temp[2]=((m_el[1].x() - m_el[0].y()) * s);
+			} 
+			else 
+			{
+				int i = m_el[0].x() < m_el[1].y() ? 
+					(m_el[1].y() < m_el[2].z() ? 2 : 1) :
+					(m_el[0].x() < m_el[2].z() ? 2 : 0); 
+				int j = (i + 1) % 3;  
+				int k = (i + 2) % 3;
+				
+				btScalar s = btSqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + btScalar(1.0));
+				temp[i] = s * btScalar(0.5);
+				s = btScalar(0.5) / s;
+				
+				temp[3] = (m_el[k][j] - m_el[j][k]) * s;
+				temp[j] = (m_el[j][i] + m_el[i][j]) * s;
+				temp[k] = (m_el[k][i] + m_el[i][k]) * s;
+			}
+			q.setValue(temp[0],temp[1],temp[2],temp[3]);
+		}
+	
+		void getEuler(btScalar& yaw, btScalar& pitch, btScalar& roll) const
+		{
+			
+			if (btScalar(m_el[1].z()) < btScalar(1))
+			{
+				if (btScalar(m_el[1].z()) > -btScalar(1))
+				{
+					yaw = btScalar(btAtan2(m_el[1].x(), m_el[0].x()));
+					pitch = btScalar(btAsin(-m_el[1].y()));
+					roll = btScalar(btAtan2(m_el[2].y(), m_el[2].z()));
+				}
+				else 
+				{
+					yaw = btScalar(-btAtan2(-m_el[0].y(), m_el[0].z()));
+					pitch = SIMD_HALF_PI;
+					roll = btScalar(0.0);
+				}
+			}
+			else
+			{
+				yaw = btScalar(btAtan2(-m_el[0].y(), m_el[0].z()));
+				pitch = -SIMD_HALF_PI;
+				roll = btScalar(0.0);
+			}
+		}
+		
+
+	
+		
+		btMatrix3x3 scaled(const btVector3& s) const
+		{
+			return btMatrix3x3(m_el[0].x() * s.x(), m_el[0].y() * s.y(), m_el[0].z() * s.z(),
+									 m_el[1].x() * s.x(), m_el[1].y() * s.y(), m_el[1].z() * s.z(),
+									 m_el[2].x() * s.x(), m_el[2].y() * s.y(), m_el[2].z() * s.z());
+		}
+
+		btScalar            determinant() const;
+		btMatrix3x3 adjoint() const;
+		btMatrix3x3 absolute() const;
+		btMatrix3x3 transpose() const;
+		btMatrix3x3 inverse() const; 
+		
+		btMatrix3x3 transposeTimes(const btMatrix3x3& m) const;
+		btMatrix3x3 timesTranspose(const btMatrix3x3& m) const;
+		
+		SIMD_FORCE_INLINE btScalar tdotx(const btVector3& v) const 
+		{
+			return m_el[0].x() * v.x() + m_el[1].x() * v.y() + m_el[2].x() * v.z();
+		}
+		SIMD_FORCE_INLINE btScalar tdoty(const btVector3& v) const 
+		{
+			return m_el[0].y() * v.x() + m_el[1].y() * v.y() + m_el[2].y() * v.z();
+		}
+		SIMD_FORCE_INLINE btScalar tdotz(const btVector3& v) const 
+		{
+			return m_el[0].z() * v.x() + m_el[1].z() * v.y() + m_el[2].z() * v.z();
+		}
+		
+
+		///diagonalizes this matrix by the Jacobi method. rot stores the rotation
+		///from the coordinate system in which the matrix is diagonal to the original
+		///coordinate system, i.e., old_this = rot * new_this * rot^T. The iteration
+		///stops when all off-diagonal elements are less than the threshold multiplied
+		///by the sum of the absolute values of the diagonal, or when maxSteps have
+		///been executed. Note that this matrix is assumed to be symmetric.
+		void diagonalize(btMatrix3x3& rot, btScalar threshold, int maxSteps)
+		{
+		 rot.setIdentity();
+		 for (int step = maxSteps; step > 0; step--)
+		 {
+			// find off-diagonal element [p][q] with largest magnitude
+			int p = 0;
+			int q = 1;
+			int r = 2;
+			btScalar max = btFabs(m_el[0][1]);
+			btScalar v = btFabs(m_el[0][2]);
+			if (v > max)
+			{
+			   q = 2;
+			   r = 1;
+			   max = v;
+			}
+			v = btFabs(m_el[1][2]);
+			if (v > max)
+			{
+			   p = 1;
+			   q = 2;
+			   r = 0;
+			   max = v;
+			}
+
+			btScalar t = threshold * (btFabs(m_el[0][0]) + btFabs(m_el[1][1]) + btFabs(m_el[2][2]));
+			if (max <= t)
+			{
+			   if (max <= SIMD_EPSILON * t)
+			   {
+				  return;
+			   }
+			   step = 1;
+			}
+
+			// compute Jacobi rotation J which leads to a zero for element [p][q] 
+			btScalar mpq = m_el[p][q];
+			btScalar theta = (m_el[q][q] - m_el[p][p]) / (2 * mpq);
+			btScalar theta2 = theta * theta;
+			btScalar cos;
+			btScalar sin;
+			if (theta2 * theta2 < btScalar(10 / SIMD_EPSILON))
+			{
+			   t = (theta >= 0) ? 1 / (theta + btSqrt(1 + theta2))
+										: 1 / (theta - btSqrt(1 + theta2));
+			   cos = 1 / btSqrt(1 + t * t);
+			   sin = cos * t;
+			}
+			else
+			{
+			   // approximation for large theta-value, i.e., a nearly diagonal matrix
+			   t = 1 / (theta * (2 + btScalar(0.5) / theta2));
+			   cos = 1 - btScalar(0.5) * t * t;
+			   sin = cos * t;
+			}
+
+			// apply rotation to matrix (this = J^T * this * J)
+			m_el[p][q] = m_el[q][p] = 0;
+			m_el[p][p] -= t * mpq;
+			m_el[q][q] += t * mpq;
+			btScalar mrp = m_el[r][p];
+			btScalar mrq = m_el[r][q];
+			m_el[r][p] = m_el[p][r] = cos * mrp - sin * mrq;
+			m_el[r][q] = m_el[q][r] = cos * mrq + sin * mrp;
+
+			// apply rotation to rot (rot = rot * J)
+			for (int i = 0; i < 3; i++)
+			{
+			   btVector3& row = rot[i];
+			   mrp = row[p];
+			   mrq = row[q];
+			   row[p] = cos * mrp - sin * mrq;
+			   row[q] = cos * mrq + sin * mrp;
+			}
+		 }
+		}
+
+
+		
+	protected:
+		btScalar cofac(int r1, int c1, int r2, int c2) const 
+		{
+			return m_el[r1][c1] * m_el[r2][c2] - m_el[r1][c2] * m_el[r2][c1];
+		}
+
+		btVector3 m_el[3];
+	};
+	
+	SIMD_FORCE_INLINE btMatrix3x3& 
+	btMatrix3x3::operator*=(const btMatrix3x3& m)
+	{
+		setValue(m.tdotx(m_el[0]), m.tdoty(m_el[0]), m.tdotz(m_el[0]),
+				 m.tdotx(m_el[1]), m.tdoty(m_el[1]), m.tdotz(m_el[1]),
+				 m.tdotx(m_el[2]), m.tdoty(m_el[2]), m.tdotz(m_el[2]));
+		return *this;
+	}
+	
+	SIMD_FORCE_INLINE btScalar 
+	btMatrix3x3::determinant() const
+	{ 
+		return triple((*this)[0], (*this)[1], (*this)[2]);
+	}
+	
+
+	SIMD_FORCE_INLINE btMatrix3x3 
+	btMatrix3x3::absolute() const
+	{
+		return btMatrix3x3(
+			btFabs(m_el[0].x()), btFabs(m_el[0].y()), btFabs(m_el[0].z()),
+			btFabs(m_el[1].x()), btFabs(m_el[1].y()), btFabs(m_el[1].z()),
+			btFabs(m_el[2].x()), btFabs(m_el[2].y()), btFabs(m_el[2].z()));
+	}
+
+	SIMD_FORCE_INLINE btMatrix3x3 
+	btMatrix3x3::transpose() const 
+	{
+		return btMatrix3x3(m_el[0].x(), m_el[1].x(), m_el[2].x(),
+								 m_el[0].y(), m_el[1].y(), m_el[2].y(),
+								 m_el[0].z(), m_el[1].z(), m_el[2].z());
+	}
+	
+	SIMD_FORCE_INLINE btMatrix3x3 
+	btMatrix3x3::adjoint() const 
+	{
+		return btMatrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2),
+								 cofac(1, 2, 2, 0), cofac(0, 0, 2, 2), cofac(0, 2, 1, 0),
+								 cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1));
+	}
+	
+	SIMD_FORCE_INLINE btMatrix3x3 
+	btMatrix3x3::inverse() const
+	{
+		btVector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1));
+		btScalar det = (*this)[0].dot(co);
+		btFullAssert(det != btScalar(0.0));
+		btScalar s = btScalar(1.0) / det;
+		return btMatrix3x3(co.x() * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s,
+								 co.y() * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s,
+								 co.z() * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s);
+	}
+	
+	SIMD_FORCE_INLINE btMatrix3x3 
+	btMatrix3x3::transposeTimes(const btMatrix3x3& m) const
+	{
+		return btMatrix3x3(
+			m_el[0].x() * m[0].x() + m_el[1].x() * m[1].x() + m_el[2].x() * m[2].x(),
+			m_el[0].x() * m[0].y() + m_el[1].x() * m[1].y() + m_el[2].x() * m[2].y(),
+			m_el[0].x() * m[0].z() + m_el[1].x() * m[1].z() + m_el[2].x() * m[2].z(),
+			m_el[0].y() * m[0].x() + m_el[1].y() * m[1].x() + m_el[2].y() * m[2].x(),
+			m_el[0].y() * m[0].y() + m_el[1].y() * m[1].y() + m_el[2].y() * m[2].y(),
+			m_el[0].y() * m[0].z() + m_el[1].y() * m[1].z() + m_el[2].y() * m[2].z(),
+			m_el[0].z() * m[0].x() + m_el[1].z() * m[1].x() + m_el[2].z() * m[2].x(),
+			m_el[0].z() * m[0].y() + m_el[1].z() * m[1].y() + m_el[2].z() * m[2].y(),
+			m_el[0].z() * m[0].z() + m_el[1].z() * m[1].z() + m_el[2].z() * m[2].z());
+	}
+	
+	SIMD_FORCE_INLINE btMatrix3x3 
+	btMatrix3x3::timesTranspose(const btMatrix3x3& m) const
+	{
+		return btMatrix3x3(
+			m_el[0].dot(m[0]), m_el[0].dot(m[1]), m_el[0].dot(m[2]),
+			m_el[1].dot(m[0]), m_el[1].dot(m[1]), m_el[1].dot(m[2]),
+			m_el[2].dot(m[0]), m_el[2].dot(m[1]), m_el[2].dot(m[2]));
+		
+	}
+
+	SIMD_FORCE_INLINE btVector3 
+	operator*(const btMatrix3x3& m, const btVector3& v) 
+	{
+		return btVector3(m[0].dot(v), m[1].dot(v), m[2].dot(v));
+	}
+	
+
+	SIMD_FORCE_INLINE btVector3
+	operator*(const btVector3& v, const btMatrix3x3& m)
+	{
+		return btVector3(m.tdotx(v), m.tdoty(v), m.tdotz(v));
+	}
+
+	SIMD_FORCE_INLINE btMatrix3x3 
+	operator*(const btMatrix3x3& m1, const btMatrix3x3& m2)
+	{
+		return btMatrix3x3(
+			m2.tdotx( m1[0]), m2.tdoty( m1[0]), m2.tdotz( m1[0]),
+			m2.tdotx( m1[1]), m2.tdoty( m1[1]), m2.tdotz( m1[1]),
+			m2.tdotx( m1[2]), m2.tdoty( m1[2]), m2.tdotz( m1[2]));
+	}
+
+/*
+	SIMD_FORCE_INLINE btMatrix3x3 btMultTransposeLeft(const btMatrix3x3& m1, const btMatrix3x3& m2) {
+    return btMatrix3x3(
+        m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0],
+        m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1],
+        m1[0][0] * m2[0][2] + m1[1][0] * m2[1][2] + m1[2][0] * m2[2][2],
+        m1[0][1] * m2[0][0] + m1[1][1] * m2[1][0] + m1[2][1] * m2[2][0],
+        m1[0][1] * m2[0][1] + m1[1][1] * m2[1][1] + m1[2][1] * m2[2][1],
+        m1[0][1] * m2[0][2] + m1[1][1] * m2[1][2] + m1[2][1] * m2[2][2],
+        m1[0][2] * m2[0][0] + m1[1][2] * m2[1][0] + m1[2][2] * m2[2][0],
+        m1[0][2] * m2[0][1] + m1[1][2] * m2[1][1] + m1[2][2] * m2[2][1],
+        m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]);
+}
+*/
+
+SIMD_FORCE_INLINE bool operator==(const btMatrix3x3& m1, const btMatrix3x3& m2)
+{
+   return ( m1[0][0] == m2[0][0] && m1[1][0] == m2[1][0] && m1[2][0] == m2[2][0] &&
+            m1[0][1] == m2[0][1] && m1[1][1] == m2[1][1] && m1[2][1] == m2[2][1] &&
+            m1[0][2] == m2[0][2] && m1[1][2] == m2[1][2] && m1[2][2] == m2[2][2] );
+}
+
+#endif
Index: /code/branches/physics/src/bullet/LinearMath/btMinMax.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btMinMax.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btMinMax.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef GEN_MINMAX_H
+#define GEN_MINMAX_H
+
+template <class T>
+SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b) 
+{
+  return a < b ? a : b ;
+}
+
+template <class T>
+SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b) 
+{
+  return  a > b ? a : b;
+}
+
+template <class T>
+SIMD_FORCE_INLINE const T& GEN_clamped(const T& a, const T& lb, const T& ub) 
+{
+	return a < lb ? lb : (ub < a ? ub : a); 
+}
+
+template <class T>
+SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) 
+{
+    if (b < a) 
+	{
+		a = b;
+	}
+}
+
+template <class T>
+SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) 
+{
+    if (a < b) 
+	{
+		a = b;
+	}
+}
+
+template <class T>
+SIMD_FORCE_INLINE void GEN_clamp(T& a, const T& lb, const T& ub) 
+{
+	if (a < lb) 
+	{
+		a = lb; 
+	}
+	else if (ub < a) 
+	{
+		a = ub;
+	}
+}
+
+#endif
Index: /code/branches/physics/src/bullet/LinearMath/btMotionState.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btMotionState.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btMotionState.h	(revision 2122)
@@ -0,0 +1,40 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_MOTIONSTATE_H
+#define BT_MOTIONSTATE_H
+
+#include "btTransform.h"
+
+///The btMotionState interface class allows the dynamics world to synchronize and interpolate the updated world transforms with graphics
+///For optimizations, potentially only moving objects get synchronized (using setWorldPosition/setWorldOrientation)
+class	btMotionState
+{
+	public:
+		
+		virtual ~btMotionState()
+		{
+			
+		}
+		
+		virtual void	getWorldTransform(btTransform& worldTrans ) const =0;
+
+		//Bullet only calls the update of worldtransform for active objects
+		virtual void	setWorldTransform(const btTransform& worldTrans)=0;
+		
+	
+};
+
+#endif //BT_MOTIONSTATE_H
Index: /code/branches/physics/src/bullet/LinearMath/btPoint3.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btPoint3.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btPoint3.h	(revision 2122)
@@ -0,0 +1,24 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef btPoint3_H
+#define btPoint3_H
+
+#include "btVector3.h"
+
+typedef btVector3 btPoint3;
+
+#endif
Index: /code/branches/physics/src/bullet/LinearMath/btPoolAllocator.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btPoolAllocator.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btPoolAllocator.h	(revision 2122)
@@ -0,0 +1,102 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef _BT_POOL_ALLOCATOR_H
+#define _BT_POOL_ALLOCATOR_H
+
+#include "btScalar.h"
+#include "btAlignedAllocator.h"
+
+///The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamically allocating them separately.
+class btPoolAllocator
+{
+	int				m_elemSize;
+	int				m_maxElements;
+	int				m_freeCount;
+	void*			m_firstFree;
+	unsigned char*	m_pool;
+
+public:
+
+	btPoolAllocator(int elemSize, int maxElements)
+		:m_elemSize(elemSize),
+		m_maxElements(maxElements)
+	{
+		m_pool = (unsigned char*) btAlignedAlloc( static_cast<unsigned int>(m_elemSize*m_maxElements),16);
+
+		unsigned char* p = m_pool;
+        m_firstFree = p;
+        m_freeCount = m_maxElements;
+        int count = m_maxElements;
+        while (--count) {
+            *(void**)p = (p + m_elemSize);
+            p += m_elemSize;
+        }
+        *(void**)p = 0;
+    }
+
+	~btPoolAllocator()
+	{
+		btAlignedFree( m_pool);
+	}
+
+	int	getFreeCount() const
+	{
+		return m_freeCount;
+	}
+
+	void*	allocate(int size)
+	{
+		// release mode fix
+		(void)size;
+		btAssert(!size || size<=m_elemSize);
+		btAssert(m_freeCount>0);
+        void* result = m_firstFree;
+        m_firstFree = *(void**)m_firstFree;
+        --m_freeCount;
+        return result;
+	}
+
+	bool validPtr(void* ptr)
+	{
+		if (ptr) {
+			if (((unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize))
+			{
+				return true;
+			}
+		}
+		return false;
+	}
+
+	void	freeMemory(void* ptr)
+	{
+		 if (ptr) {
+            btAssert((unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize);
+
+            *(void**)ptr = m_firstFree;
+            m_firstFree = ptr;
+            ++m_freeCount;
+        }
+	}
+
+	int	getElementSize() const
+	{
+		return m_elemSize;
+	}
+
+
+};
+
+#endif //_BT_POOL_ALLOCATOR_H
Index: /code/branches/physics/src/bullet/LinearMath/btQuadWord.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btQuadWord.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btQuadWord.h	(revision 2122)
@@ -0,0 +1,142 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef SIMD_QUADWORD_H
+#define SIMD_QUADWORD_H
+
+#include "btScalar.h"
+#include "btMinMax.h"
+#include <math.h>
+
+
+
+///The btQuadWordStorage class is base class for btVector3 and btQuaternion. 
+///Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. todo: look into this
+///ATTRIBUTE_ALIGNED16(class) btQuadWordStorage
+class btQuadWordStorage
+{
+protected:
+
+	btScalar	m_x;
+	btScalar	m_y;
+	btScalar	m_z;
+	btScalar	m_unusedW;
+
+public:
+
+};
+
+
+///btQuadWord is base-class for vectors, points
+class	btQuadWord : public btQuadWordStorage
+{
+	public:
+	
+//		SIMD_FORCE_INLINE btScalar&       operator[](int i)       { return (&m_x)[i];	}      
+//		SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_x)[i]; }
+
+		SIMD_FORCE_INLINE const btScalar& getX() const { return m_x; }
+
+		SIMD_FORCE_INLINE const btScalar& getY() const { return m_y; }
+
+		SIMD_FORCE_INLINE const btScalar& getZ() const { return m_z; }
+
+		SIMD_FORCE_INLINE void	setX(btScalar x) { m_x = x;};
+
+		SIMD_FORCE_INLINE void	setY(btScalar y) { m_y = y;};
+
+		SIMD_FORCE_INLINE void	setZ(btScalar z) { m_z = z;};
+
+		SIMD_FORCE_INLINE void	setW(btScalar w) { m_unusedW = w;};
+
+		SIMD_FORCE_INLINE const btScalar& x() const { return m_x; }
+
+		SIMD_FORCE_INLINE const btScalar& y() const { return m_y; }
+
+		SIMD_FORCE_INLINE const btScalar& z() const { return m_z; }
+
+		SIMD_FORCE_INLINE const btScalar& w() const { return m_unusedW; }
+
+
+		SIMD_FORCE_INLINE	operator       btScalar *()       { return &m_x; }
+		SIMD_FORCE_INLINE	operator const btScalar *() const { return &m_x; }
+
+
+
+		SIMD_FORCE_INLINE void 	setValue(const btScalar& x, const btScalar& y, const btScalar& z)
+		{
+			m_x=x;
+			m_y=y;
+			m_z=z;
+			m_unusedW = 0.f;
+		}
+
+/*		void getValue(btScalar *m) const 
+		{
+			m[0] = m_x;
+			m[1] = m_y;
+			m[2] = m_z;
+		}
+*/
+		SIMD_FORCE_INLINE void	setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w)
+		{
+			m_x=x;
+			m_y=y;
+			m_z=z;
+			m_unusedW=w;
+		}
+
+		SIMD_FORCE_INLINE btQuadWord()
+		//	:m_x(btScalar(0.)),m_y(btScalar(0.)),m_z(btScalar(0.)),m_unusedW(btScalar(0.))
+		{
+		}
+
+		SIMD_FORCE_INLINE btQuadWord(const btQuadWordStorage& q)
+		{
+			*((btQuadWordStorage*)this) = q;
+		}
+
+		SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)		
+		{
+			m_x = x, m_y = y, m_z = z, m_unusedW = 0.0f;
+		}
+
+		SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 
+		{
+			m_x = x, m_y = y, m_z = z, m_unusedW = w;
+		}
+
+
+		SIMD_FORCE_INLINE void	setMax(const btQuadWord& other)
+		{
+			btSetMax(m_x, other.m_x);
+			btSetMax(m_y, other.m_y);
+			btSetMax(m_z, other.m_z);
+			btSetMax(m_unusedW, other.m_unusedW);
+		}
+
+		SIMD_FORCE_INLINE void	setMin(const btQuadWord& other)
+		{
+			btSetMin(m_x, other.m_x);
+			btSetMin(m_y, other.m_y);
+			btSetMin(m_z, other.m_z);
+			btSetMin(m_unusedW, other.m_unusedW);
+		}
+
+
+
+};
+
+#endif //SIMD_QUADWORD_H
Index: /code/branches/physics/src/bullet/LinearMath/btQuaternion.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btQuaternion.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btQuaternion.h	(revision 2122)
@@ -0,0 +1,323 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef SIMD__QUATERNION_H_
+#define SIMD__QUATERNION_H_
+
+#include "btVector3.h"
+
+///The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatrix3x3, btVector3 and btTransform.
+class btQuaternion : public btQuadWord {
+public:
+	btQuaternion() {}
+
+	//		template <typename btScalar>
+	//		explicit Quaternion(const btScalar *v) : Tuple4<btScalar>(v) {}
+
+	btQuaternion(const btScalar& x, const btScalar& y, const btScalar& z, const btScalar& w) 
+		: btQuadWord(x, y, z, w) 
+	{}
+
+	btQuaternion(const btVector3& axis, const btScalar& angle) 
+	{ 
+		setRotation(axis, angle); 
+	}
+
+	btQuaternion(const btScalar& yaw, const btScalar& pitch, const btScalar& roll)
+	{ 
+		setEuler(yaw, pitch, roll); 
+	}
+
+	void setRotation(const btVector3& axis, const btScalar& angle)
+	{
+		btScalar d = axis.length();
+		assert(d != btScalar(0.0));
+		btScalar s = btSin(angle * btScalar(0.5)) / d;
+		setValue(axis.x() * s, axis.y() * s, axis.z() * s, 
+			btCos(angle * btScalar(0.5)));
+	}
+
+	void setEuler(const btScalar& yaw, const btScalar& pitch, const btScalar& roll)
+	{
+		btScalar halfYaw = btScalar(yaw) * btScalar(0.5);  
+		btScalar halfPitch = btScalar(pitch) * btScalar(0.5);  
+		btScalar halfRoll = btScalar(roll) * btScalar(0.5);  
+		btScalar cosYaw = btCos(halfYaw);
+		btScalar sinYaw = btSin(halfYaw);
+		btScalar cosPitch = btCos(halfPitch);
+		btScalar sinPitch = btSin(halfPitch);
+		btScalar cosRoll = btCos(halfRoll);
+		btScalar sinRoll = btSin(halfRoll);
+		setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw,
+			cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw,
+			sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw,
+			cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw);
+	}
+
+	btQuaternion& operator+=(const btQuaternion& q)
+	{
+		m_x += q.x(); m_y += q.y(); m_z += q.z(); m_unusedW += q.m_unusedW;
+		return *this;
+	}
+
+	btQuaternion& operator-=(const btQuaternion& q) 
+	{
+		m_x -= q.x(); m_y -= q.y(); m_z -= q.z(); m_unusedW -= q.m_unusedW;
+		return *this;
+	}
+
+	btQuaternion& operator*=(const btScalar& s)
+	{
+		m_x *= s; m_y *= s; m_z *= s; m_unusedW *= s;
+		return *this;
+	}
+
+
+	btQuaternion& operator*=(const btQuaternion& q)
+	{
+		setValue(m_unusedW * q.x() + m_x * q.m_unusedW + m_y * q.z() - m_z * q.y(),
+			m_unusedW * q.y() + m_y * q.m_unusedW + m_z * q.x() - m_x * q.z(),
+			m_unusedW * q.z() + m_z * q.m_unusedW + m_x * q.y() - m_y * q.x(),
+			m_unusedW * q.m_unusedW - m_x * q.x() - m_y * q.y() - m_z * q.z());
+		return *this;
+	}
+
+	btScalar dot(const btQuaternion& q) const
+	{
+		return m_x * q.x() + m_y * q.y() + m_z * q.z() + m_unusedW * q.m_unusedW;
+	}
+
+	btScalar length2() const
+	{
+		return dot(*this);
+	}
+
+	btScalar length() const
+	{
+		return btSqrt(length2());
+	}
+
+	btQuaternion& normalize() 
+	{
+		return *this /= length();
+	}
+
+	SIMD_FORCE_INLINE btQuaternion
+	operator*(const btScalar& s) const
+	{
+		return btQuaternion(x() * s, y() * s, z() * s, m_unusedW * s);
+	}
+
+
+
+	btQuaternion operator/(const btScalar& s) const
+	{
+		assert(s != btScalar(0.0));
+		return *this * (btScalar(1.0) / s);
+	}
+
+
+	btQuaternion& operator/=(const btScalar& s) 
+	{
+		assert(s != btScalar(0.0));
+		return *this *= btScalar(1.0) / s;
+	}
+
+
+	btQuaternion normalized() const 
+	{
+		return *this / length();
+	} 
+
+	btScalar angle(const btQuaternion& q) const 
+	{
+		btScalar s = btSqrt(length2() * q.length2());
+		assert(s != btScalar(0.0));
+		return btAcos(dot(q) / s);
+	}
+
+	btScalar getAngle() const 
+	{
+		btScalar s = btScalar(2.) * btAcos(m_unusedW);
+		return s;
+	}
+
+
+
+	btQuaternion inverse() const
+	{
+		return btQuaternion(-m_x, -m_y, -m_z, m_unusedW);
+	}
+
+	SIMD_FORCE_INLINE btQuaternion
+	operator+(const btQuaternion& q2) const
+	{
+		const btQuaternion& q1 = *this;
+		return btQuaternion(q1.x() + q2.x(), q1.y() + q2.y(), q1.z() + q2.z(), q1.m_unusedW + q2.m_unusedW);
+	}
+
+	SIMD_FORCE_INLINE btQuaternion
+	operator-(const btQuaternion& q2) const
+	{
+		const btQuaternion& q1 = *this;
+		return btQuaternion(q1.x() - q2.x(), q1.y() - q2.y(), q1.z() - q2.z(), q1.m_unusedW - q2.m_unusedW);
+	}
+
+	SIMD_FORCE_INLINE btQuaternion operator-() const
+	{
+		const btQuaternion& q2 = *this;
+		return btQuaternion( - q2.x(), - q2.y(),  - q2.z(),  - q2.m_unusedW);
+	}
+
+	SIMD_FORCE_INLINE btQuaternion farthest( const btQuaternion& qd) const 
+	{
+		btQuaternion diff,sum;
+		diff = *this - qd;
+		sum = *this + qd;
+		if( diff.dot(diff) > sum.dot(sum) )
+			return qd;
+		return (-qd);
+	}
+
+	btQuaternion slerp(const btQuaternion& q, const btScalar& t) const
+	{
+		btScalar theta = angle(q);
+		if (theta != btScalar(0.0))
+		{
+			btScalar d = btScalar(1.0) / btSin(theta);
+			btScalar s0 = btSin((btScalar(1.0) - t) * theta);
+			btScalar s1 = btSin(t * theta);   
+			return btQuaternion((m_x * s0 + q.x() * s1) * d,
+				(m_y * s0 + q.y() * s1) * d,
+				(m_z * s0 + q.z() * s1) * d,
+				(m_unusedW * s0 + q.m_unusedW * s1) * d);
+		}
+		else
+		{
+			return *this;
+		}
+	}
+
+	SIMD_FORCE_INLINE const btScalar& getW() const { return m_unusedW; }
+
+	
+};
+
+
+
+SIMD_FORCE_INLINE btQuaternion
+operator-(const btQuaternion& q)
+{
+	return btQuaternion(-q.x(), -q.y(), -q.z(), -q.w());
+}
+
+
+
+
+SIMD_FORCE_INLINE btQuaternion
+operator*(const btQuaternion& q1, const btQuaternion& q2) {
+	return btQuaternion(q1.w() * q2.x() + q1.x() * q2.w() + q1.y() * q2.z() - q1.z() * q2.y(),
+		q1.w() * q2.y() + q1.y() * q2.w() + q1.z() * q2.x() - q1.x() * q2.z(),
+		q1.w() * q2.z() + q1.z() * q2.w() + q1.x() * q2.y() - q1.y() * q2.x(),
+		q1.w() * q2.w() - q1.x() * q2.x() - q1.y() * q2.y() - q1.z() * q2.z()); 
+}
+
+SIMD_FORCE_INLINE btQuaternion
+operator*(const btQuaternion& q, const btVector3& w)
+{
+	return btQuaternion( q.w() * w.x() + q.y() * w.z() - q.z() * w.y(),
+		q.w() * w.y() + q.z() * w.x() - q.x() * w.z(),
+		q.w() * w.z() + q.x() * w.y() - q.y() * w.x(),
+		-q.x() * w.x() - q.y() * w.y() - q.z() * w.z()); 
+}
+
+SIMD_FORCE_INLINE btQuaternion
+operator*(const btVector3& w, const btQuaternion& q)
+{
+	return btQuaternion( w.x() * q.w() + w.y() * q.z() - w.z() * q.y(),
+		w.y() * q.w() + w.z() * q.x() - w.x() * q.z(),
+		w.z() * q.w() + w.x() * q.y() - w.y() * q.x(),
+		-w.x() * q.x() - w.y() * q.y() - w.z() * q.z()); 
+}
+
+SIMD_FORCE_INLINE btScalar 
+dot(const btQuaternion& q1, const btQuaternion& q2) 
+{ 
+	return q1.dot(q2); 
+}
+
+
+SIMD_FORCE_INLINE btScalar
+length(const btQuaternion& q) 
+{ 
+	return q.length(); 
+}
+
+SIMD_FORCE_INLINE btScalar
+angle(const btQuaternion& q1, const btQuaternion& q2) 
+{ 
+	return q1.angle(q2); 
+}
+
+
+SIMD_FORCE_INLINE btQuaternion
+inverse(const btQuaternion& q) 
+{
+	return q.inverse();
+}
+
+SIMD_FORCE_INLINE btQuaternion
+slerp(const btQuaternion& q1, const btQuaternion& q2, const btScalar& t) 
+{
+	return q1.slerp(q2, t);
+}
+
+SIMD_FORCE_INLINE btVector3 
+quatRotate(const btQuaternion& rotation, const btVector3& v) 
+{
+	btQuaternion q = rotation * v;
+	q *= rotation.inverse();
+	return btVector3(q.getX(),q.getY(),q.getZ());
+}
+
+SIMD_FORCE_INLINE btQuaternion 
+shortestArcQuat(const btVector3& v0, const btVector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized
+{
+	btVector3 c = v0.cross(v1);
+	btScalar  d = v0.dot(v1);
+
+	if (d < -1.0 + SIMD_EPSILON)
+		return btQuaternion(0.0f,1.0f,0.0f,0.0f); // just pick any vector
+
+	btScalar  s = btSqrt((1.0f + d) * 2.0f);
+	btScalar rs = 1.0f / s;
+
+	return btQuaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f);
+}
+
+SIMD_FORCE_INLINE btQuaternion 
+shortestArcQuatNormalize2(btVector3& v0,btVector3& v1)
+{
+	v0.normalize();
+	v1.normalize();
+	return shortestArcQuat(v0,v1);
+}
+
+#endif
+
+
+
+
Index: /code/branches/physics/src/bullet/LinearMath/btQuickprof.cpp
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btQuickprof.cpp	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btQuickprof.cpp	(revision 2122)
@@ -0,0 +1,282 @@
+/*
+
+/***************************************************************************************************
+**
+** profile.cpp
+**
+** Real-Time Hierarchical Profiling for Game Programming Gems 3
+**
+** by Greg Hjelstrom & Byon Garrabrant
+**
+***************************************************************************************************/
+
+// Credits: The Clock class was inspired by the Timer classes in 
+// Ogre (www.ogre3d.org).
+
+#include "LinearMath/btQuickprof.h"
+
+
+#ifdef USE_BT_CLOCK
+
+static btClock gProfileClock;
+
+inline void Profile_Get_Ticks(unsigned long int * ticks)
+{
+	*ticks = gProfileClock.getTimeMicroseconds();
+}
+
+inline float Profile_Get_Tick_Rate(void)
+{
+//	return 1000000.f;
+	return 1000.f;
+
+}
+
+
+
+/***************************************************************************************************
+**
+** CProfileNode
+**
+***************************************************************************************************/
+
+/***********************************************************************************************
+ * INPUT:                                                                                      *
+ * name - pointer to a static string which is the name of this profile node                    *
+ * parent - parent pointer                                                                     *
+ *                                                                                             *
+ * WARNINGS:                                                                                   *
+ * The name is assumed to be a static pointer, only the pointer is stored and compared for     *
+ * efficiency reasons.                                                                         *
+ *=============================================================================================*/
+CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) :
+	Name( name ),
+	TotalCalls( 0 ),
+	TotalTime( 0 ),
+	StartTime( 0 ),
+	RecursionCounter( 0 ),
+	Parent( parent ),
+	Child( NULL ),
+	Sibling( NULL )
+{
+	Reset();
+}
+
+
+void	CProfileNode::CleanupMemory()
+{
+	delete ( Child);
+	Child = NULL;
+	delete ( Sibling);
+	Sibling = NULL;
+}
+
+CProfileNode::~CProfileNode( void )
+{
+	delete ( Child);
+	delete ( Sibling);
+}
+
+
+/***********************************************************************************************
+ * INPUT:                                                                                      *
+ * name - static string pointer to the name of the node we are searching for                   *
+ *                                                                                             *
+ * WARNINGS:                                                                                   *
+ * All profile names are assumed to be static strings so this function uses pointer compares   *
+ * to find the named node.                                                                     *
+ *=============================================================================================*/
+CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
+{
+	// Try to find this sub node
+	CProfileNode * child = Child;
+	while ( child ) {
+		if ( child->Name == name ) {
+			return child;
+		}
+		child = child->Sibling;
+	}
+
+	// We didn't find it, so add it
+	
+	CProfileNode * node = new CProfileNode( name, this );
+	node->Sibling = Child;
+	Child = node;
+	return node;
+}
+
+
+void	CProfileNode::Reset( void )
+{
+	TotalCalls = 0;
+	TotalTime = 0.0f;
+	gProfileClock.reset();
+
+	if ( Child ) {
+		Child->Reset();
+	}
+	if ( Sibling ) {
+		Sibling->Reset();
+	}
+}
+
+
+void	CProfileNode::Call( void )
+{
+	TotalCalls++;
+	if (RecursionCounter++ == 0) {
+		Profile_Get_Ticks(&StartTime);
+	}
+}
+
+
+bool	CProfileNode::Return( void )
+{
+	if ( --RecursionCounter == 0 && TotalCalls != 0 ) { 
+		unsigned long int time;
+		Profile_Get_Ticks(&time);
+		time-=StartTime;
+		TotalTime += (float)time / Profile_Get_Tick_Rate();
+	}
+	return ( RecursionCounter == 0 );
+}
+
+
+/***************************************************************************************************
+**
+** CProfileIterator
+**
+***************************************************************************************************/
+CProfileIterator::CProfileIterator( CProfileNode * start )
+{
+	CurrentParent = start;
+	CurrentChild = CurrentParent->Get_Child();
+}
+
+
+void	CProfileIterator::First(void)
+{
+	CurrentChild = CurrentParent->Get_Child();
+}
+
+
+void	CProfileIterator::Next(void)
+{
+	CurrentChild = CurrentChild->Get_Sibling();
+}
+
+
+bool	CProfileIterator::Is_Done(void)
+{
+	return CurrentChild == NULL;
+}
+
+
+void	CProfileIterator::Enter_Child( int index )
+{
+	CurrentChild = CurrentParent->Get_Child();
+	while ( (CurrentChild != NULL) && (index != 0) ) {
+		index--;
+		CurrentChild = CurrentChild->Get_Sibling();
+	}
+
+	if ( CurrentChild != NULL ) {
+		CurrentParent = CurrentChild;
+		CurrentChild = CurrentParent->Get_Child();
+	}
+}
+
+
+void	CProfileIterator::Enter_Parent( void )
+{
+	if ( CurrentParent->Get_Parent() != NULL ) {
+		CurrentParent = CurrentParent->Get_Parent();
+	}
+	CurrentChild = CurrentParent->Get_Child();
+}
+
+
+/***************************************************************************************************
+**
+** CProfileManager
+**
+***************************************************************************************************/
+
+CProfileNode	CProfileManager::Root( "Root", NULL );
+CProfileNode *	CProfileManager::CurrentNode = &CProfileManager::Root;
+int				CProfileManager::FrameCounter = 0;
+unsigned long int			CProfileManager::ResetTime = 0;
+
+
+/***********************************************************************************************
+ * CProfileManager::Start_Profile -- Begin a named profile                                    *
+ *                                                                                             *
+ * Steps one level deeper into the tree, if a child already exists with the specified name     *
+ * then it accumulates the profiling; otherwise a new child node is added to the profile tree. *
+ *                                                                                             *
+ * INPUT:                                                                                      *
+ * name - name of this profiling record                                                        *
+ *                                                                                             *
+ * WARNINGS:                                                                                   *
+ * The string used is assumed to be a static string; pointer compares are used throughout      *
+ * the profiling code for efficiency.                                                          *
+ *=============================================================================================*/
+void	CProfileManager::Start_Profile( const char * name )
+{
+	if (name != CurrentNode->Get_Name()) {
+		CurrentNode = CurrentNode->Get_Sub_Node( name );
+	} 
+	
+	CurrentNode->Call();
+}
+
+
+/***********************************************************************************************
+ * CProfileManager::Stop_Profile -- Stop timing and record the results.                       *
+ *=============================================================================================*/
+void	CProfileManager::Stop_Profile( void )
+{
+	// Return will indicate whether we should back up to our parent (we may
+	// be profiling a recursive function)
+	if (CurrentNode->Return()) {
+		CurrentNode = CurrentNode->Get_Parent();
+	}
+}
+
+
+/***********************************************************************************************
+ * CProfileManager::Reset -- Reset the contents of the profiling system                       *
+ *                                                                                             *
+ *    This resets everything except for the tree structure.  All of the timing data is reset.  *
+ *=============================================================================================*/
+void	CProfileManager::Reset( void )
+{ 
+	Root.Reset();
+    Root.Call();
+	FrameCounter = 0;
+	Profile_Get_Ticks(&ResetTime);
+}
+
+
+/***********************************************************************************************
+ * CProfileManager::Increment_Frame_Counter -- Increment the frame counter                    *
+ *=============================================================================================*/
+void CProfileManager::Increment_Frame_Counter( void )
+{
+	FrameCounter++;
+}
+
+
+/***********************************************************************************************
+ * CProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset         *
+ *=============================================================================================*/
+float CProfileManager::Get_Time_Since_Reset( void )
+{
+	unsigned long int time;
+	Profile_Get_Ticks(&time);
+	time -= ResetTime;
+	return (float)time / Profile_Get_Tick_Rate();
+}
+
+#endif //USE_BT_CLOCK
+
Index: /code/branches/physics/src/bullet/LinearMath/btQuickprof.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btQuickprof.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btQuickprof.h	(revision 2122)
@@ -0,0 +1,358 @@
+
+/***************************************************************************************************
+**
+** Real-Time Hierarchical Profiling for Game Programming Gems 3
+**
+** by Greg Hjelstrom & Byon Garrabrant
+**
+***************************************************************************************************/
+
+// Credits: The Clock class was inspired by the Timer classes in 
+// Ogre (www.ogre3d.org).
+
+#ifndef QUICK_PROF_H
+#define QUICK_PROF_H
+
+#include "btScalar.h"
+#include "LinearMath/btAlignedAllocator.h"
+#include <new>
+//To disable built-in profiling, please comment out next line
+//#define BT_NO_PROFILE 1
+
+
+//if you don't need btClock, you can comment next line
+#define USE_BT_CLOCK 1
+
+#ifdef USE_BT_CLOCK
+#ifdef __CELLOS_LV2__
+#include <sys/sys_time.h>
+#include <sys/time_util.h>
+#include <stdio.h>
+#endif
+
+#if defined (SUNOS) || defined (__SUNOS__) 
+#include <stdio.h> 
+#endif
+
+#if defined(WIN32) || defined(_WIN32)
+
+#define USE_WINDOWS_TIMERS 
+#define WIN32_LEAN_AND_MEAN 
+#define NOWINRES 
+#define NOMCX 
+#define NOIME 
+#ifdef _XBOX
+#include <Xtl.h>
+#else
+#include <windows.h>
+#endif
+#include <time.h>
+
+#else
+#include <sys/time.h>
+#endif
+
+#define mymin(a,b) (a > b ? a : b)
+
+///The btClock is a portable basic clock that measures accurate time in seconds, use for profiling.
+class btClock
+{
+public:
+	btClock()
+	{
+#ifdef USE_WINDOWS_TIMERS
+		QueryPerformanceFrequency(&mClockFrequency);
+#endif
+		reset();
+	}
+
+	~btClock()
+	{
+	}
+
+	/// Resets the initial reference time.
+	void reset()
+	{
+#ifdef USE_WINDOWS_TIMERS
+		QueryPerformanceCounter(&mStartTime);
+		mStartTick = GetTickCount();
+		mPrevElapsedTime = 0;
+#else
+#ifdef __CELLOS_LV2__
+
+		typedef uint64_t  ClockSize;
+		ClockSize newTime;
+		//__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory");
+		SYS_TIMEBASE_GET( newTime );
+		mStartTime = newTime;
+#else
+		gettimeofday(&mStartTime, 0);
+#endif
+
+#endif
+	}
+
+	/// Returns the time in ms since the last call to reset or since 
+	/// the btClock was created.
+	unsigned long int getTimeMilliseconds()
+	{
+#ifdef USE_WINDOWS_TIMERS
+		LARGE_INTEGER currentTime;
+		QueryPerformanceCounter(&currentTime);
+		LONGLONG elapsedTime = currentTime.QuadPart - 
+			mStartTime.QuadPart;
+
+		// Compute the number of millisecond ticks elapsed.
+		unsigned long msecTicks = (unsigned long)(1000 * elapsedTime / 
+			mClockFrequency.QuadPart);
+
+		// Check for unexpected leaps in the Win32 performance counter.  
+		// (This is caused by unexpected data across the PCI to ISA 
+		// bridge, aka south bridge.  See Microsoft KB274323.)
+		unsigned long elapsedTicks = GetTickCount() - mStartTick;
+		signed long msecOff = (signed long)(msecTicks - elapsedTicks);
+		if (msecOff < -100 || msecOff > 100)
+		{
+			// Adjust the starting time forwards.
+			LONGLONG msecAdjustment = mymin(msecOff * 
+				mClockFrequency.QuadPart / 1000, elapsedTime - 
+				mPrevElapsedTime);
+			mStartTime.QuadPart += msecAdjustment;
+			elapsedTime -= msecAdjustment;
+
+			// Recompute the number of millisecond ticks elapsed.
+			msecTicks = (unsigned long)(1000 * elapsedTime / 
+				mClockFrequency.QuadPart);
+		}
+
+		// Store the current elapsed time for adjustments next time.
+		mPrevElapsedTime = elapsedTime;
+
+		return msecTicks;
+#else
+
+#ifdef __CELLOS_LV2__
+		uint64_t freq=sys_time_get_timebase_frequency();
+		double dFreq=((double) freq) / 1000.0;
+		typedef uint64_t  ClockSize;
+		ClockSize newTime;
+		SYS_TIMEBASE_GET( newTime );
+		//__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory");
+
+		return (unsigned long int)((double(newTime-mStartTime)) / dFreq);
+#else
+
+		struct timeval currentTime;
+		gettimeofday(&currentTime, 0);
+		return (currentTime.tv_sec - mStartTime.tv_sec) * 1000 + 
+			(currentTime.tv_usec - mStartTime.tv_usec) / 1000;
+#endif //__CELLOS_LV2__
+#endif
+	}
+
+	/// Returns the time in us since the last call to reset or since 
+	/// the Clock was created.
+	unsigned long int getTimeMicroseconds()
+	{
+#ifdef USE_WINDOWS_TIMERS
+		LARGE_INTEGER currentTime;
+		QueryPerformanceCounter(&currentTime);
+		LONGLONG elapsedTime = currentTime.QuadPart - 
+			mStartTime.QuadPart;
+
+		// Compute the number of millisecond ticks elapsed.
+		unsigned long msecTicks = (unsigned long)(1000 * elapsedTime / 
+			mClockFrequency.QuadPart);
+
+		// Check for unexpected leaps in the Win32 performance counter.  
+		// (This is caused by unexpected data across the PCI to ISA 
+		// bridge, aka south bridge.  See Microsoft KB274323.)
+		unsigned long elapsedTicks = GetTickCount() - mStartTick;
+		signed long msecOff = (signed long)(msecTicks - elapsedTicks);
+		if (msecOff < -100 || msecOff > 100)
+		{
+			// Adjust the starting time forwards.
+			LONGLONG msecAdjustment = mymin(msecOff * 
+				mClockFrequency.QuadPart / 1000, elapsedTime - 
+				mPrevElapsedTime);
+			mStartTime.QuadPart += msecAdjustment;
+			elapsedTime -= msecAdjustment;
+		}
+
+		// Store the current elapsed time for adjustments next time.
+		mPrevElapsedTime = elapsedTime;
+
+		// Convert to microseconds.
+		unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime / 
+			mClockFrequency.QuadPart);
+
+		return usecTicks;
+#else
+
+#ifdef __CELLOS_LV2__
+		uint64_t freq=sys_time_get_timebase_frequency();
+		double dFreq=((double) freq)/ 1000000.0;
+		typedef uint64_t  ClockSize;
+		ClockSize newTime;
+		//__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory");
+		SYS_TIMEBASE_GET( newTime );
+
+		return (unsigned long int)((double(newTime-mStartTime)) / dFreq);
+#else
+
+		struct timeval currentTime;
+		gettimeofday(&currentTime, 0);
+		return (currentTime.tv_sec - mStartTime.tv_sec) * 1000000 + 
+			(currentTime.tv_usec - mStartTime.tv_usec);
+#endif//__CELLOS_LV2__
+#endif 
+	}
+
+private:
+#ifdef USE_WINDOWS_TIMERS
+	LARGE_INTEGER mClockFrequency;
+	DWORD mStartTick;
+	LONGLONG mPrevElapsedTime;
+	LARGE_INTEGER mStartTime;
+#else
+#ifdef __CELLOS_LV2__
+	uint64_t	mStartTime;
+#else
+	struct timeval mStartTime;
+#endif
+#endif //__CELLOS_LV2__
+
+};
+
+#endif //USE_BT_CLOCK
+
+
+
+
+///A node in the Profile Hierarchy Tree
+class	CProfileNode {
+
+public:
+	CProfileNode( const char * name, CProfileNode * parent );
+	~CProfileNode( void );
+
+	CProfileNode * Get_Sub_Node( const char * name );
+
+	CProfileNode * Get_Parent( void )		{ return Parent; }
+	CProfileNode * Get_Sibling( void )		{ return Sibling; }
+	CProfileNode * Get_Child( void )			{ return Child; }
+
+	void				CleanupMemory();
+	void				Reset( void );
+	void				Call( void );
+	bool				Return( void );
+
+	const char *	Get_Name( void )				{ return Name; }
+	int				Get_Total_Calls( void )		{ return TotalCalls; }
+	float				Get_Total_Time( void )		{ return TotalTime; }
+
+protected:
+
+	const char *	Name;
+	int				TotalCalls;
+	float				TotalTime;
+	unsigned long int			StartTime;
+	int				RecursionCounter;
+
+	CProfileNode *	Parent;
+	CProfileNode *	Child;
+	CProfileNode *	Sibling;
+};
+
+///An iterator to navigate through the tree
+class CProfileIterator
+{
+public:
+	// Access all the children of the current parent
+	void				First(void);
+	void				Next(void);
+	bool				Is_Done(void);
+	bool                Is_Root(void) { return (CurrentParent->Get_Parent() == 0); }
+
+	void				Enter_Child( int index );		// Make the given child the new parent
+	void				Enter_Largest_Child( void );	// Make the largest child the new parent
+	void				Enter_Parent( void );			// Make the current parent's parent the new parent
+
+	// Access the current child
+	const char *	Get_Current_Name( void )			{ return CurrentChild->Get_Name(); }
+	int				Get_Current_Total_Calls( void )	{ return CurrentChild->Get_Total_Calls(); }
+	float				Get_Current_Total_Time( void )	{ return CurrentChild->Get_Total_Time(); }
+
+	// Access the current parent
+	const char *	Get_Current_Parent_Name( void )			{ return CurrentParent->Get_Name(); }
+	int				Get_Current_Parent_Total_Calls( void )	{ return CurrentParent->Get_Total_Calls(); }
+	float				Get_Current_Parent_Total_Time( void )	{ return CurrentParent->Get_Total_Time(); }
+
+protected:
+
+	CProfileNode *	CurrentParent;
+	CProfileNode *	CurrentChild;
+
+	CProfileIterator( CProfileNode * start );
+	friend	class		CProfileManager;
+};
+
+
+///The Manager for the Profile system
+class	CProfileManager {
+public:
+	static	void						Start_Profile( const char * name );
+	static	void						Stop_Profile( void );
+
+	static	void						CleanupMemory(void)
+	{
+		Root.CleanupMemory();
+	}
+
+	static	void						Reset( void );
+	static	void						Increment_Frame_Counter( void );
+	static	int						Get_Frame_Count_Since_Reset( void )		{ return FrameCounter; }
+	static	float						Get_Time_Since_Reset( void );
+
+	static	CProfileIterator *	Get_Iterator( void )	
+	{ 
+		
+		return new CProfileIterator( &Root ); 
+	}
+	static	void						Release_Iterator( CProfileIterator * iterator ) { delete ( iterator); }
+
+private:
+	static	CProfileNode			Root;
+	static	CProfileNode *			CurrentNode;
+	static	int						FrameCounter;
+	static	unsigned long int					ResetTime;
+};
+
+
+///ProfileSampleClass is a simple way to profile a function's scope
+///Use the BT_PROFILE macro at the start of scope to time
+class	CProfileSample {
+public:
+	CProfileSample( const char * name )
+	{ 
+		CProfileManager::Start_Profile( name ); 
+	}
+
+	~CProfileSample( void )					
+	{ 
+		CProfileManager::Stop_Profile(); 
+	}
+};
+
+#if !defined(BT_NO_PROFILE)
+#define	BT_PROFILE( name )			CProfileSample __profile( name )
+#else
+#define	BT_PROFILE( name )
+#endif
+
+
+
+
+#endif //QUICK_PROF_H
+
+
Index: /code/branches/physics/src/bullet/LinearMath/btRandom.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btRandom.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btRandom.h	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef GEN_RANDOM_H
+#define GEN_RANDOM_H
+
+#ifdef MT19937
+
+#include <limits.h>
+#include <mt19937.h>
+
+#define GEN_RAND_MAX UINT_MAX
+
+SIMD_FORCE_INLINE void         GEN_srand(unsigned int seed) { init_genrand(seed); }
+SIMD_FORCE_INLINE unsigned int GEN_rand()                   { return genrand_int32(); }
+
+#else
+
+#include <stdlib.h>
+
+#define GEN_RAND_MAX RAND_MAX
+
+SIMD_FORCE_INLINE void         GEN_srand(unsigned int seed) { srand(seed); } 
+SIMD_FORCE_INLINE unsigned int GEN_rand()                   { return rand(); }
+
+#endif
+
+#endif
+
Index: /code/branches/physics/src/bullet/LinearMath/btScalar.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btScalar.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btScalar.h	(revision 2122)
@@ -0,0 +1,421 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef SIMD___SCALAR_H
+#define SIMD___SCALAR_H
+
+#include <math.h>
+#include <stdlib.h>//size_t for MSVC 6.0
+
+#include <cstdlib>
+#include <cfloat>
+#include <float.h>
+
+#define BT_BULLET_VERSION 272
+
+inline int	btGetVersion()
+{
+	return BT_BULLET_VERSION;
+}
+
+#if defined(DEBUG) || defined (_DEBUG)
+#define BT_DEBUG
+#endif
+
+
+#ifdef WIN32
+
+		#if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)
+
+			#define SIMD_FORCE_INLINE inline
+			#define ATTRIBUTE_ALIGNED16(a) a
+			#define ATTRIBUTE_ALIGNED128(a) a
+		#else
+			#define BT_HAS_ALIGNED_ALLOCATOR
+			#pragma warning(disable : 4324) // disable padding warning
+//			#pragma warning(disable:4530) // Disable the exception disable but used in MSCV Stl warning.
+//			#pragma warning(disable:4996) //Turn off warnings about deprecated C routines
+//			#pragma warning(disable:4786) // Disable the "debug name too long" warning
+
+			#define SIMD_FORCE_INLINE __forceinline
+			#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
+			#define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
+		#ifdef _XBOX
+			#define BT_USE_VMX128
+
+			#include <ppcintrinsics.h>
+ 			#define BT_HAVE_NATIVE_FSEL
+ 			#define btFsel(a,b,c) __fsel((a),(b),(c))
+		#else
+			#define BT_USE_SSE
+		#endif
+		#endif //__MINGW32__
+
+		#include <assert.h>
+#if defined(DEBUG) || defined (_DEBUG)
+		#define btAssert assert
+#else
+		#define btAssert(x)
+#endif
+		//btFullAssert is optional, slows down a lot
+		#define btFullAssert(x)
+
+		#define btLikely(_c)  _c
+		#define btUnlikely(_c) _c
+
+#else
+	
+#if defined	(__CELLOS_LV2__)
+		#define SIMD_FORCE_INLINE inline
+		#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
+		#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
+		#ifndef assert
+		#include <assert.h>
+		#endif
+		#define btAssert assert
+		//btFullAssert is optional, slows down a lot
+		#define btFullAssert(x)
+
+		#define btLikely(_c)  _c
+		#define btUnlikely(_c) _c
+
+#else
+
+#ifdef USE_LIBSPE2
+
+		#define SIMD_FORCE_INLINE __inline
+		#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
+		#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
+		#ifndef assert
+		#include <assert.h>
+		#endif
+		#define btAssert assert
+		//btFullAssert is optional, slows down a lot
+		#define btFullAssert(x)
+
+
+		#define btLikely(_c)   __builtin_expect((_c), 1)
+		#define btUnlikely(_c) __builtin_expect((_c), 0)
+		
+
+#else
+	//non-windows systems
+
+		#define SIMD_FORCE_INLINE inline
+		#define ATTRIBUTE_ALIGNED16(a) a
+		#define ATTRIBUTE_ALIGNED128(a) a
+		#ifndef assert
+		#include <assert.h>
+		#endif
+
+#if defined(DEBUG) || defined (_DEBUG)
+		#define btAssert assert
+#else
+		#define btAssert(x)
+#endif
+
+		//btFullAssert is optional, slows down a lot
+		#define btFullAssert(x)
+		#define btLikely(_c)  _c
+		#define btUnlikely(_c) _c
+
+
+#endif // LIBSPE2
+
+#endif	//__CELLOS_LV2__
+#endif
+
+/// older compilers (gcc 3.x) and Sun needs double version of sqrt etc.
+/// exclude Apple Intel (i's assumed to be a Macbook or new Intel Dual Core Processor)
+#if defined (__sun) || defined (__sun__) || defined (__sparc) || (defined (__APPLE__) && ! defined (__i386__))
+//use slow double float precision operation on those platforms
+#ifndef BT_USE_DOUBLE_PRECISION
+#define BT_FORCE_DOUBLE_FUNCTIONS
+#endif
+#endif
+
+///The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision.
+#if defined(BT_USE_DOUBLE_PRECISION)
+typedef double btScalar;
+#else
+typedef float btScalar;
+#endif
+
+
+
+#define BT_DECLARE_ALIGNED_ALLOCATOR() \
+   SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes)   { return btAlignedAlloc(sizeInBytes,16); }   \
+   SIMD_FORCE_INLINE void  operator delete(void* ptr)         { btAlignedFree(ptr); }   \
+   SIMD_FORCE_INLINE void* operator new(size_t, void* ptr)   { return ptr; }   \
+   SIMD_FORCE_INLINE void  operator delete(void*, void*)      { }   \
+   SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes)   { return btAlignedAlloc(sizeInBytes,16); }   \
+   SIMD_FORCE_INLINE void  operator delete[](void* ptr)         { btAlignedFree(ptr); }   \
+   SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr)   { return ptr; }   \
+   SIMD_FORCE_INLINE void  operator delete[](void*, void*)      { }   \
+
+
+
+#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)
+		
+SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); }
+SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabs(x); }
+SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cos(x); }
+SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sin(x); }
+SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tan(x); }
+SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { return acos(x); }
+SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asin(x); }
+SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atan(x); }
+SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2(x, y); }
+SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return exp(x); }
+SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return log(x); }
+SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return pow(x,y); }
+
+#else
+		
+SIMD_FORCE_INLINE btScalar btSqrt(btScalar y) 
+{ 
+#ifdef USE_APPROXIMATION
+    double x, z, tempf;
+    unsigned long *tfptr = ((unsigned long *)&tempf) + 1;
+
+	tempf = y;
+	*tfptr = (0xbfcdd90a - *tfptr)>>1; /* estimate of 1/sqrt(y) */
+	x =  tempf;
+	z =  y*btScalar(0.5);                        /* hoist out the /2    */
+	x = (btScalar(1.5)*x)-(x*x)*(x*z);         /* iteration formula     */
+	x = (btScalar(1.5)*x)-(x*x)*(x*z);
+	x = (btScalar(1.5)*x)-(x*x)*(x*z);
+	x = (btScalar(1.5)*x)-(x*x)*(x*z);
+	x = (btScalar(1.5)*x)-(x*x)*(x*z);
+	return x*y;
+#else
+	return sqrtf(y); 
+#endif
+}
+SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabsf(x); }
+SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cosf(x); }
+SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sinf(x); }
+SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tanf(x); }
+SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { 
+	btAssert(x <= btScalar(1.));
+	return acosf(x); 
+}
+SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asinf(x); }
+SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atanf(x); }
+SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2f(x, y); }
+SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return expf(x); }
+SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return logf(x); }
+SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return powf(x,y); }
+	
+#endif
+
+#define SIMD_2_PI         btScalar(6.283185307179586232)
+#define SIMD_PI           (SIMD_2_PI * btScalar(0.5))
+#define SIMD_HALF_PI      (SIMD_2_PI * btScalar(0.25))
+#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))
+#define SIMD_DEGS_PER_RAD  (btScalar(360.0) / SIMD_2_PI)
+
+#ifdef BT_USE_DOUBLE_PRECISION
+#define SIMD_EPSILON      DBL_EPSILON
+#define SIMD_INFINITY     DBL_MAX
+#else
+#define SIMD_EPSILON      FLT_EPSILON
+#define SIMD_INFINITY     FLT_MAX
+#endif
+
+SIMD_FORCE_INLINE btScalar btAtan2Fast(btScalar y, btScalar x) 
+{
+	btScalar coeff_1 = SIMD_PI / 4.0f;
+	btScalar coeff_2 = 3.0f * coeff_1;
+	btScalar abs_y = btFabs(y);
+	btScalar angle;
+	if (x >= 0.0f) {
+		btScalar r = (x - abs_y) / (x + abs_y);
+		angle = coeff_1 - coeff_1 * r;
+	} else {
+		btScalar r = (x + abs_y) / (abs_y - x);
+		angle = coeff_2 - coeff_1 * r;
+	}
+	return (y < 0.0f) ? -angle : angle;
+}
+
+SIMD_FORCE_INLINE bool      btFuzzyZero(btScalar x) { return btFabs(x) < SIMD_EPSILON; }
+
+SIMD_FORCE_INLINE bool	btEqual(btScalar a, btScalar eps) {
+	return (((a) <= eps) && !((a) < -eps));
+}
+SIMD_FORCE_INLINE bool	btGreaterEqual (btScalar a, btScalar eps) {
+	return (!((a) <= eps));
+}
+
+
+SIMD_FORCE_INLINE int       btIsNegative(btScalar x) {
+    return x < btScalar(0.0) ? 1 : 0;
+}
+
+SIMD_FORCE_INLINE btScalar btRadians(btScalar x) { return x * SIMD_RADS_PER_DEG; }
+SIMD_FORCE_INLINE btScalar btDegrees(btScalar x) { return x * SIMD_DEGS_PER_RAD; }
+
+#define BT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
+
+#ifndef btFsel
+SIMD_FORCE_INLINE btScalar btFsel(btScalar a, btScalar b, btScalar c)
+{
+	return a >= 0 ? b : c;
+}
+#endif
+#define btFsels(a,b,c) (btScalar)btFsel(a,b,c)
+
+
+SIMD_FORCE_INLINE bool btMachineIsLittleEndian()
+{
+   long int i = 1;
+   const char *p = (const char *) &i;
+   if (p[0] == 1)  // Lowest address contains the least significant byte
+	   return true;
+   else
+	   return false;
+}
+
+
+
+///btSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360
+///Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html
+SIMD_FORCE_INLINE unsigned btSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero) 
+{
+    // Set testNz to 0xFFFFFFFF if condition is nonzero, 0x00000000 if condition is zero
+    // Rely on positive value or'ed with its negative having sign bit on
+    // and zero value or'ed with its negative (which is still zero) having sign bit off 
+    // Use arithmetic shift right, shifting the sign bit through all 32 bits
+    unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31);
+    unsigned testEqz = ~testNz;
+    return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); 
+}
+SIMD_FORCE_INLINE int btSelect(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero)
+{
+    unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31);
+    unsigned testEqz = ~testNz; 
+    return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
+}
+SIMD_FORCE_INLINE float btSelect(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero)
+{
+#ifdef BT_HAVE_NATIVE_FSEL
+    return (float)btFsel((btScalar)condition - btScalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
+#else
+    return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero; 
+#endif
+}
+
+template<typename T> SIMD_FORCE_INLINE void btSwap(T& a, T& b)
+{
+	T tmp = a;
+	a = b;
+	b = tmp;
+}
+
+
+//PCK: endian swapping functions
+SIMD_FORCE_INLINE unsigned btSwapEndian(unsigned val)
+{
+	return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8)  | ((val & 0x000000ff) << 24));
+}
+
+SIMD_FORCE_INLINE unsigned short btSwapEndian(unsigned short val)
+{
+	return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
+}
+
+SIMD_FORCE_INLINE unsigned btSwapEndian(int val)
+{
+	return btSwapEndian((unsigned)val);
+}
+
+SIMD_FORCE_INLINE unsigned short btSwapEndian(short val)
+{
+	return btSwapEndian((unsigned short) val);
+}
+
+///btSwapFloat uses using char pointers to swap the endianness
+////btSwapFloat/btSwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values
+///Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754. 
+///When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. 
+///In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. 
+///so instead of returning a float/double, we return integer/long long integer
+SIMD_FORCE_INLINE unsigned int  btSwapEndianFloat(float d)
+{
+    unsigned int a = 0;
+    unsigned char *dst = (unsigned char *)&a;
+    unsigned char *src = (unsigned char *)&d;
+
+    dst[0] = src[3];
+    dst[1] = src[2];
+    dst[2] = src[1];
+    dst[3] = src[0];
+    return a;
+}
+
+// unswap using char pointers
+SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a) 
+{
+    float d = 0.0f;
+    unsigned char *src = (unsigned char *)&a;
+    unsigned char *dst = (unsigned char *)&d;
+
+    dst[0] = src[3];
+    dst[1] = src[2];
+    dst[2] = src[1];
+    dst[3] = src[0];
+
+    return d;
+}
+
+
+// swap using char pointers
+SIMD_FORCE_INLINE void  btSwapEndianDouble(double d, unsigned char* dst)
+{
+    unsigned char *src = (unsigned char *)&d;
+
+    dst[0] = src[7];
+    dst[1] = src[6];
+    dst[2] = src[5];
+    dst[3] = src[4];
+    dst[4] = src[3];
+    dst[5] = src[2];
+    dst[6] = src[1];
+    dst[7] = src[0];
+
+}
+
+// unswap using char pointers
+SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src) 
+{
+    double d = 0.0;
+    unsigned char *dst = (unsigned char *)&d;
+
+    dst[0] = src[7];
+    dst[1] = src[6];
+    dst[2] = src[5];
+    dst[3] = src[4];
+    dst[4] = src[3];
+    dst[5] = src[2];
+    dst[6] = src[1];
+    dst[7] = src[0];
+
+	return d;
+}
+
+
+#endif //SIMD___SCALAR_H
Index: /code/branches/physics/src/bullet/LinearMath/btStackAlloc.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btStackAlloc.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btStackAlloc.h	(revision 2122)
@@ -0,0 +1,115 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+StackAlloc extracted from GJK-EPA collision solver by Nathanael Presson
+Nov.2006
+*/
+
+#ifndef BT_STACK_ALLOC
+#define BT_STACK_ALLOC
+
+#include "btScalar.h" //for btAssert
+#include "btAlignedAllocator.h"
+
+struct btBlock
+{
+	btBlock*			previous;
+	unsigned char*		address;
+};
+
+///The StackAlloc class provides some fast stack-based memory allocator (LIFO last-in first-out)
+class btStackAlloc
+{
+public:
+
+	btStackAlloc(unsigned int size)	{ ctor();create(size); }
+	~btStackAlloc()		{ destroy(); }
+	
+	inline void		create(unsigned int size)
+	{
+		destroy();
+		data		=  (unsigned char*) btAlignedAlloc(size,16);
+		totalsize	=	size;
+	}
+	inline void		destroy()
+	{
+		btAssert(usedsize==0);
+		//Raise(L"StackAlloc is still in use");
+
+		if(usedsize==0)
+		{
+			if(!ischild && data)		
+				btAlignedFree(data);
+
+			data				=	0;
+			usedsize			=	0;
+		}
+		
+	}
+
+	int	getAvailableMemory() const
+	{
+		return static_cast<int>(totalsize - usedsize);
+	}
+
+	unsigned char*			allocate(unsigned int size)
+	{
+		const unsigned int	nus(usedsize+size);
+		if(nus<totalsize)
+		{
+			usedsize=nus;
+			return(data+(usedsize-size));
+		}
+		btAssert(0);
+		//&& (L"Not enough memory"));
+		
+		return(0);
+	}
+	SIMD_FORCE_INLINE btBlock*		beginBlock()
+	{
+		btBlock*	pb = (btBlock*)allocate(sizeof(btBlock));
+		pb->previous	=	current;
+		pb->address		=	data+usedsize;
+		current			=	pb;
+		return(pb);
+	}
+	SIMD_FORCE_INLINE void		endBlock(btBlock* block)
+	{
+		btAssert(block==current);
+		//Raise(L"Unmatched blocks");
+		if(block==current)
+		{
+			current		=	block->previous;
+			usedsize	=	(unsigned int)((block->address-data)-sizeof(btBlock));
+		}
+	}
+
+private:
+	void		ctor()
+	{
+		data		=	0;
+		totalsize	=	0;
+		usedsize	=	0;
+		current		=	0;
+		ischild		=	false;
+	}
+	unsigned char*		data;
+	unsigned int		totalsize;
+	unsigned int		usedsize;
+	btBlock*	current;
+	bool		ischild;
+};
+
+#endif //BT_STACK_ALLOC
Index: /code/branches/physics/src/bullet/LinearMath/btTransform.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btTransform.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btTransform.h	(revision 2122)
@@ -0,0 +1,207 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef btTransform_H
+#define btTransform_H
+
+#include "btVector3.h"
+#include "btMatrix3x3.h"
+
+
+///The btTransform class supports rigid transforms with only translation and rotation and no scaling/shear.
+///It can be used in combination with btVector3, btQuaternion and btMatrix3x3 linear algebra classes.
+class btTransform {
+	
+
+public:
+	
+	
+	btTransform() {}
+
+	explicit SIMD_FORCE_INLINE btTransform(const btQuaternion& q, 
+		const btVector3& c = btVector3(btScalar(0), btScalar(0), btScalar(0))) 
+		: m_basis(q),
+		m_origin(c)
+	{}
+
+	explicit SIMD_FORCE_INLINE btTransform(const btMatrix3x3& b, 
+		const btVector3& c = btVector3(btScalar(0), btScalar(0), btScalar(0)))
+		: m_basis(b),
+		m_origin(c)
+	{}
+
+	SIMD_FORCE_INLINE btTransform (const btTransform& other)
+		: m_basis(other.m_basis),
+		m_origin(other.m_origin)
+	{
+	}
+
+	SIMD_FORCE_INLINE btTransform& operator=(const btTransform& other)
+	{
+		m_basis = other.m_basis;
+		m_origin = other.m_origin;
+		return *this;
+	}
+
+
+		SIMD_FORCE_INLINE void mult(const btTransform& t1, const btTransform& t2) {
+			m_basis = t1.m_basis * t2.m_basis;
+			m_origin = t1(t2.m_origin);
+		}
+
+/*		void multInverseLeft(const btTransform& t1, const btTransform& t2) {
+			btVector3 v = t2.m_origin - t1.m_origin;
+			m_basis = btMultTransposeLeft(t1.m_basis, t2.m_basis);
+			m_origin = v * t1.m_basis;
+		}
+		*/
+
+
+	SIMD_FORCE_INLINE btVector3 operator()(const btVector3& x) const
+	{
+		return btVector3(m_basis[0].dot(x) + m_origin.x(), 
+			m_basis[1].dot(x) + m_origin.y(), 
+			m_basis[2].dot(x) + m_origin.z());
+	}
+
+	SIMD_FORCE_INLINE btVector3 operator*(const btVector3& x) const
+	{
+		return (*this)(x);
+	}
+
+	SIMD_FORCE_INLINE btMatrix3x3&       getBasis()          { return m_basis; }
+	SIMD_FORCE_INLINE const btMatrix3x3& getBasis()    const { return m_basis; }
+
+	SIMD_FORCE_INLINE btVector3&         getOrigin()         { return m_origin; }
+	SIMD_FORCE_INLINE const btVector3&   getOrigin()   const { return m_origin; }
+
+	btQuaternion getRotation() const { 
+		btQuaternion q;
+		m_basis.getRotation(q);
+		return q;
+	}
+	
+	
+	void setFromOpenGLMatrix(const btScalar *m)
+	{
+		m_basis.setFromOpenGLSubMatrix(m);
+		m_origin.setValue(m[12],m[13],m[14]);
+	}
+
+	void getOpenGLMatrix(btScalar *m) const 
+	{
+		m_basis.getOpenGLSubMatrix(m);
+		m[12] = m_origin.x();
+		m[13] = m_origin.y();
+		m[14] = m_origin.z();
+		m[15] = btScalar(1.0);
+	}
+
+	SIMD_FORCE_INLINE void setOrigin(const btVector3& origin) 
+	{ 
+		m_origin = origin;
+	}
+
+	SIMD_FORCE_INLINE btVector3 invXform(const btVector3& inVec) const;
+
+
+
+	SIMD_FORCE_INLINE void setBasis(const btMatrix3x3& basis)
+	{ 
+		m_basis = basis;
+	}
+
+	SIMD_FORCE_INLINE void setRotation(const btQuaternion& q)
+	{
+		m_basis.setRotation(q);
+	}
+
+
+
+	void setIdentity()
+	{
+		m_basis.setIdentity();
+		m_origin.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
+	}
+
+	
+	btTransform& operator*=(const btTransform& t) 
+	{
+		m_origin += m_basis * t.m_origin;
+		m_basis *= t.m_basis;
+		return *this;
+	}
+
+	btTransform inverse() const
+	{ 
+		btMatrix3x3 inv = m_basis.transpose();
+		return btTransform(inv, inv * -m_origin);
+	}
+
+	btTransform inverseTimes(const btTransform& t) const;  
+
+	btTransform operator*(const btTransform& t) const;
+
+	static btTransform	getIdentity()
+	{
+		btTransform tr;
+		tr.setIdentity();
+		return tr;
+	}
+	
+private:
+
+	btMatrix3x3 m_basis;
+	btVector3   m_origin;
+};
+
+
+SIMD_FORCE_INLINE btVector3
+btTransform::invXform(const btVector3& inVec) const
+{
+	btVector3 v = inVec - m_origin;
+	return (m_basis.transpose() * v);
+}
+
+SIMD_FORCE_INLINE btTransform 
+btTransform::inverseTimes(const btTransform& t) const  
+{
+	btVector3 v = t.getOrigin() - m_origin;
+		return btTransform(m_basis.transposeTimes(t.m_basis),
+			v * m_basis);
+}
+
+SIMD_FORCE_INLINE btTransform 
+btTransform::operator*(const btTransform& t) const
+{
+	return btTransform(m_basis * t.m_basis, 
+		(*this)(t.m_origin));
+}
+
+SIMD_FORCE_INLINE bool operator==(const btTransform& t1, const btTransform& t2)
+{
+   return ( t1.getBasis()  == t2.getBasis() &&
+            t1.getOrigin() == t2.getOrigin() );
+}
+
+
+#endif
+
+
+
+
+
+
Index: /code/branches/physics/src/bullet/LinearMath/btTransformUtil.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btTransformUtil.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btTransformUtil.h	(revision 2122)
@@ -0,0 +1,144 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+#ifndef SIMD_TRANSFORM_UTIL_H
+#define SIMD_TRANSFORM_UTIL_H
+
+#include "btTransform.h"
+#define ANGULAR_MOTION_THRESHOLD btScalar(0.5)*SIMD_HALF_PI
+
+
+
+#define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490)
+
+#define btRecipSqrt(x) ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x))))		/* reciprocal square root */
+
+SIMD_FORCE_INLINE btVector3 btAabbSupport(const btVector3& halfExtents,const btVector3& supportDir)
+{
+	return btVector3(supportDir.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
+      supportDir.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
+      supportDir.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z()); 
+}
+
+
+SIMD_FORCE_INLINE void btPlaneSpace1 (const btVector3& n, btVector3& p, btVector3& q)
+{
+  if (btFabs(n.z()) > SIMDSQRT12) {
+    // choose p in y-z plane
+    btScalar a = n[1]*n[1] + n[2]*n[2];
+    btScalar k = btRecipSqrt (a);
+    p.setValue(0,-n[2]*k,n[1]*k);
+    // set q = n x p
+    q.setValue(a*k,-n[0]*p[2],n[0]*p[1]);
+  }
+  else {
+    // choose p in x-y plane
+    btScalar a = n.x()*n.x() + n.y()*n.y();
+    btScalar k = btRecipSqrt (a);
+    p.setValue(-n.y()*k,n.x()*k,0);
+    // set q = n x p
+    q.setValue(-n.z()*p.y(),n.z()*p.x(),a*k);
+  }
+}
+
+
+
+/// Utils related to temporal transforms
+class btTransformUtil
+{
+
+public:
+
+	static void integrateTransform(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep,btTransform& predictedTransform)
+	{
+		predictedTransform.setOrigin(curTrans.getOrigin() + linvel * timeStep);
+//	#define QUATERNION_DERIVATIVE
+	#ifdef QUATERNION_DERIVATIVE
+		btQuaternion predictedOrn = curTrans.getRotation();
+		predictedOrn += (angvel * predictedOrn) * (timeStep * btScalar(0.5));
+		predictedOrn.normalize();
+	#else
+		//Exponential map
+		//google for "Practical Parameterization of Rotations Using the Exponential Map", F. Sebastian Grassia
+
+		btVector3 axis;
+		btScalar	fAngle = angvel.length(); 
+		//limit the angular motion
+		if (fAngle*timeStep > ANGULAR_MOTION_THRESHOLD)
+		{
+			fAngle = ANGULAR_MOTION_THRESHOLD / timeStep;
+		}
+
+		if ( fAngle < btScalar(0.001) )
+		{
+			// use Taylor's expansions of sync function
+			axis   = angvel*( btScalar(0.5)*timeStep-(timeStep*timeStep*timeStep)*(btScalar(0.020833333333))*fAngle*fAngle );
+		}
+		else
+		{
+			// sync(fAngle) = sin(c*fAngle)/t
+			axis   = angvel*( btSin(btScalar(0.5)*fAngle*timeStep)/fAngle );
+		}
+		btQuaternion dorn (axis.x(),axis.y(),axis.z(),btCos( fAngle*timeStep*btScalar(0.5) ));
+		btQuaternion orn0 = curTrans.getRotation();
+
+		btQuaternion predictedOrn = dorn * orn0;
+		predictedOrn.normalize();
+	#endif
+		predictedTransform.setRotation(predictedOrn);
+	}
+
+	static void	calculateVelocity(const btTransform& transform0,const btTransform& transform1,btScalar timeStep,btVector3& linVel,btVector3& angVel)
+	{
+		linVel = (transform1.getOrigin() - transform0.getOrigin()) / timeStep;
+		btVector3 axis;
+		btScalar  angle;
+		calculateDiffAxisAngle(transform0,transform1,axis,angle);
+		angVel = axis * angle / timeStep;
+	}
+
+	static void calculateDiffAxisAngle(const btTransform& transform0,const btTransform& transform1,btVector3& axis,btScalar& angle)
+	{
+	
+	#ifdef USE_QUATERNION_DIFF
+		btQuaternion orn0 = transform0.getRotation();
+		btQuaternion orn1a = transform1.getRotation();
+		btQuaternion orn1 = orn0.farthest(orn1a);
+		btQuaternion dorn = orn1 * orn0.inverse();
+#else
+		btMatrix3x3 dmat = transform1.getBasis() * transform0.getBasis().inverse();
+		btQuaternion dorn;
+		dmat.getRotation(dorn);
+#endif//USE_QUATERNION_DIFF
+	
+		///floating point inaccuracy can lead to w component > 1..., which breaks 
+
+		dorn.normalize();
+		
+		angle = dorn.getAngle();
+		axis = btVector3(dorn.x(),dorn.y(),dorn.z());
+		axis[3] = btScalar(0.);
+		//check for axis length
+		btScalar len = axis.length2();
+		if (len < SIMD_EPSILON*SIMD_EPSILON)
+			axis = btVector3(btScalar(1.),btScalar(0.),btScalar(0.));
+		else
+			axis /= btSqrt(len);
+	}
+
+};
+
+#endif //SIMD_TRANSFORM_UTIL_H
+
Index: /code/branches/physics/src/bullet/LinearMath/btVector3.h
===================================================================
--- /code/branches/physics/src/bullet/LinearMath/btVector3.h	(revision 2122)
+++ /code/branches/physics/src/bullet/LinearMath/btVector3.h	(revision 2122)
@@ -0,0 +1,453 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+
+
+#ifndef SIMD__VECTOR3_H
+#define SIMD__VECTOR3_H
+
+#include "btQuadWord.h"
+
+///btVector3 can be used to represent 3D points and vectors.
+///It has an un-used w component to suit 16-byte alignment when btVector3 is stored in containers. This extra component can be used by derived classes (Quaternion?) or by user
+///Ideally, this class should be replaced by a platform optimized SIMD version that keeps the data in registers
+class	btVector3 : public btQuadWord {
+
+public:
+	SIMD_FORCE_INLINE btVector3() {}
+
+	SIMD_FORCE_INLINE btVector3(const btQuadWordStorage& q) 
+		: btQuadWord(q)
+	{
+	}
+	
+
+	SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, const btScalar& z) 
+		:btQuadWord(x,y,z,btScalar(0.))
+	{
+	}
+
+//	SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 
+//		: btQuadWord(x,y,z,w)
+//	{
+//	}
+
+	
+
+	SIMD_FORCE_INLINE btVector3& operator+=(const btVector3& v)
+	{
+
+		m_x += v.x(); m_y += v.y(); m_z += v.z();
+		return *this;
+	}
+
+
+
+	SIMD_FORCE_INLINE btVector3& operator-=(const btVector3& v) 
+	{
+		m_x -= v.x(); m_y -= v.y(); m_z -= v.z();
+		return *this;
+	}
+
+	SIMD_FORCE_INLINE btVector3& operator*=(const btScalar& s)
+	{
+		m_x *= s; m_y *= s; m_z *= s;
+		return *this;
+	}
+
+	SIMD_FORCE_INLINE btVector3& operator/=(const btScalar& s) 
+	{
+		btFullAssert(s != btScalar(0.0));
+		return *this *= btScalar(1.0) / s;
+	}
+
+	SIMD_FORCE_INLINE btScalar dot(const btVector3& v) const
+	{
+		return m_x * v.x() + m_y * v.y() + m_z * v.z();
+	}
+
+	SIMD_FORCE_INLINE btScalar length2() const
+	{
+		return dot(*this);
+	}
+
+	SIMD_FORCE_INLINE btScalar length() const
+	{
+		return btSqrt(length2());
+	}
+
+	SIMD_FORCE_INLINE btScalar distance2(const btVector3& v) const;
+
+	SIMD_FORCE_INLINE btScalar distance(const btVector3& v) const;
+
+	SIMD_FORCE_INLINE btVector3& normalize() 
+	{
+		return *this /= length();
+	}
+
+	SIMD_FORCE_INLINE btVector3 normalized() const;
+
+	SIMD_FORCE_INLINE btVector3 rotate( const btVector3& wAxis, const btScalar angle );
+
+	SIMD_FORCE_INLINE btScalar angle(const btVector3& v) const 
+	{
+		btScalar s = btSqrt(length2() * v.length2());
+		btFullAssert(s != btScalar(0.0));
+		return btAcos(dot(v) / s);
+	}
+
+	SIMD_FORCE_INLINE btVector3 absolute() const 
+	{
+		return btVector3(
+			btFabs(m_x), 
+			btFabs(m_y), 
+			btFabs(m_z));
+	}
+
+	SIMD_FORCE_INLINE btVector3 cross(const btVector3& v) const
+	{
+		return btVector3(
+			m_y * v.z() - m_z * v.y(),
+			m_z * v.x() - m_x * v.z(),
+			m_x * v.y() - m_y * v.x());
+	}
+
+	SIMD_FORCE_INLINE btScalar triple(const btVector3& v1, const btVector3& v2) const
+	{
+		return m_x * (v1.y() * v2.z() - v1.z() * v2.y()) + 
+			m_y * (v1.z() * v2.x() - v1.x() * v2.z()) + 
+			m_z * (v1.x() * v2.y() - v1.y() * v2.x());
+	}
+
+	SIMD_FORCE_INLINE int minAxis() const
+	{
+		return m_x < m_y ? (m_x < m_z ? 0 : 2) : (m_y < m_z ? 1 : 2);
+	}
+
+	SIMD_FORCE_INLINE int maxAxis() const 
+	{
+		return m_x < m_y ? (m_y < m_z ? 2 : 1) : (m_x < m_z ? 2 : 0);
+	}
+
+	SIMD_FORCE_INLINE int furthestAxis() const
+	{
+		return absolute().minAxis();
+	}
+
+	SIMD_FORCE_INLINE int closestAxis() const 
+	{
+		return absolute().maxAxis();
+	}
+
+	SIMD_FORCE_INLINE void setInterpolate3(const btVector3& v0, const btVector3& v1, btScalar rt)
+	{
+		btScalar s = btScalar(1.0) - rt;
+		m_x = s * v0.x() + rt * v1.x();
+		m_y = s * v0.y() + rt * v1.y();
+		m_z = s * v0.z() + rt * v1.z();
+		//don't do the unused w component
+		//		m_co[3] = s * v0[3] + rt * v1[3];
+	}
+
+	SIMD_FORCE_INLINE btVector3 lerp(const btVector3& v, const btScalar& t) const 
+	{
+		return btVector3(m_x + (v.x() - m_x) * t,
+			m_y + (v.y() - m_y) * t,
+			m_z + (v.z() - m_z) * t);
+	}
+
+
+	SIMD_FORCE_INLINE btVector3& operator*=(const btVector3& v)
+	{
+		m_x *= v.x(); m_y *= v.y(); m_z *= v.z();
+		return *this;
+	}
+
+	
+
+};
+
+SIMD_FORCE_INLINE btVector3 
+operator+(const btVector3& v1, const btVector3& v2) 
+{
+	return btVector3(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z());
+}
+
+SIMD_FORCE_INLINE btVector3 
+operator*(const btVector3& v1, const btVector3& v2) 
+{
+	return btVector3(v1.x() * v2.x(), v1.y() * v2.y(), v1.z() * v2.z());
+}
+
+SIMD_FORCE_INLINE btVector3 
+operator-(const btVector3& v1, const btVector3& v2)
+{
+	return btVector3(v1.x() - v2.x(), v1.y() - v2.y(), v1.z() - v2.z());
+}
+
+SIMD_FORCE_INLINE btVector3 
+operator-(const btVector3& v)
+{
+	return btVector3(-v.x(), -v.y(), -v.z());
+}
+
+SIMD_FORCE_INLINE btVector3 
+operator*(const btVector3& v, const btScalar& s)
+{
+	return btVector3(v.x() * s, v.y() * s, v.z() * s);
+}
+
+SIMD_FORCE_INLINE btVector3 
+operator*(const btScalar& s, const btVector3& v)
+{ 
+	return v * s; 
+}
+
+SIMD_FORCE_INLINE btVector3
+operator/(const btVector3& v, const btScalar& s)
+{
+	btFullAssert(s != btScalar(0.0));
+	return v * (btScalar(1.0) / s);
+}
+
+SIMD_FORCE_INLINE btVector3
+operator/(const btVector3& v1, const btVector3& v2)
+{
+	return btVector3(v1.x() / v2.x(),v1.y() / v2.y(),v1.z() / v2.z());
+}
+
+SIMD_FORCE_INLINE btScalar 
+dot(const btVector3& v1, const btVector3& v2) 
+{ 
+	return v1.dot(v2); 
+}
+
+
+
+SIMD_FORCE_INLINE btScalar
+distance2(const btVector3& v1, const btVector3& v2) 
+{ 
+	return v1.distance2(v2); 
+}
+
+
+SIMD_FORCE_INLINE btScalar
+distance(const btVector3& v1, const btVector3& v2) 
+{ 
+	return v1.distance(v2); 
+}
+
+SIMD_FORCE_INLINE btScalar
+angle(const btVector3& v1, const btVector3& v2) 
+{ 
+	return v1.angle(v2); 
+}
+
+SIMD_FORCE_INLINE btVector3 
+cross(const btVector3& v1, const btVector3& v2) 
+{ 
+	return v1.cross(v2); 
+}
+
+SIMD_FORCE_INLINE btScalar
+triple(const btVector3& v1, const btVector3& v2, const btVector3& v3)
+{
+	return v1.triple(v2, v3);
+}
+
+SIMD_FORCE_INLINE btVector3 
+lerp(const btVector3& v1, const btVector3& v2, const btScalar& t)
+{
+	return v1.lerp(v2, t);
+}
+
+
+SIMD_FORCE_INLINE bool operator==(const btVector3& p1, const btVector3& p2) 
+{
+	return p1.x() == p2.x() && p1.y() == p2.y() && p1.z() == p2.z();
+}
+
+SIMD_FORCE_INLINE btScalar btVector3::distance2(const btVector3& v) const
+{
+	return (v - *this).length2();
+}
+
+SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const
+{
+	return (v - *this).length();
+}
+
+SIMD_FORCE_INLINE btVector3 btVector3::normalized() const
+{
+	return *this / length();
+} 
+
+SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btScalar angle )
+{
+	// wAxis must be a unit lenght vector
+
+	btVector3 o = wAxis * wAxis.dot( *this );
+	btVector3 x = *this - o;
+	btVector3 y;
+
+	y = wAxis.cross( *this );
+
+	return ( o + x * btCos( angle ) + y * btSin( angle ) );
+}
+
+class btVector4 : public btVector3
+{
+public:
+
+	SIMD_FORCE_INLINE btVector4() {}
+
+
+	SIMD_FORCE_INLINE btVector4(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) 
+		: btVector3(x,y,z)
+	{
+		m_unusedW = w;
+	}
+
+
+	SIMD_FORCE_INLINE btVector4 absolute4() const 
+	{
+		return btVector4(
+			btFabs(m_x), 
+			btFabs(m_y), 
+			btFabs(m_z),
+			btFabs(m_unusedW));
+	}
+
+
+
+	btScalar	getW() const { return m_unusedW;}
+
+
+		SIMD_FORCE_INLINE int maxAxis4() const
+	{
+		int maxIndex = -1;
+		btScalar maxVal = btScalar(-1e30);
+		if (m_x > maxVal)
+		{
+			maxIndex = 0;
+			maxVal = m_x;
+		}
+		if (m_y > maxVal)
+		{
+			maxIndex = 1;
+			maxVal = m_y;
+		}
+		if (m_z > maxVal)
+		{
+			maxIndex = 2;
+			maxVal = m_z;
+		}
+		if (m_unusedW > maxVal)
+		{
+			maxIndex = 3;
+			maxVal = m_unusedW;
+		}
+		
+		
+		
+
+		return maxIndex;
+
+	}
+
+
+	SIMD_FORCE_INLINE int minAxis4() const
+	{
+		int minIndex = -1;
+		btScalar minVal = btScalar(1e30);
+		if (m_x < minVal)
+		{
+			minIndex = 0;
+			minVal = m_x;
+		}
+		if (m_y < minVal)
+		{
+			minIndex = 1;
+			minVal = m_y;
+		}
+		if (m_z < minVal)
+		{
+			minIndex = 2;
+			minVal = m_z;
+		}
+		if (m_unusedW < minVal)
+		{
+			minIndex = 3;
+			minVal = m_unusedW;
+		}
+		
+		return minIndex;
+
+	}
+
+
+	SIMD_FORCE_INLINE int closestAxis4() const 
+	{
+		return absolute4().maxAxis4();
+	}
+
+};
+
+
+///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
+SIMD_FORCE_INLINE void	btSwapScalarEndian(const btScalar& sourceVal, btScalar& destVal)
+{
+	#ifdef BT_USE_DOUBLE_PRECISION
+	unsigned char* dest = (unsigned char*) &destVal;
+	unsigned char* src  = (unsigned char*) &sourceVal;
+	dest[0] = src[7];
+    dest[1] = src[6];
+    dest[2] = src[5];
+    dest[3] = src[4];
+    dest[4] = src[3];
+    dest[5] = src[2];
+    dest[6] = src[1];
+    dest[7] = src[0];
+#else
+	unsigned char* dest = (unsigned char*) &destVal;
+	unsigned char* src  = (unsigned char*) &sourceVal;
+	dest[0] = src[3];
+    dest[1] = src[2];
+    dest[2] = src[1];
+    dest[3] = src[0];
+#endif //BT_USE_DOUBLE_PRECISION
+}
+///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
+SIMD_FORCE_INLINE void	btSwapVector3Endian(const btVector3& sourceVec, btVector3& destVec)
+{
+	for (int i=0;i<4;i++)
+	{
+		btSwapScalarEndian(sourceVec[i],destVec[i]);
+	}
+
+}
+
+///btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
+SIMD_FORCE_INLINE void	btUnSwapVector3Endian(btVector3& vector)
+{
+
+	btVector3	swappedVec;
+	for (int i=0;i<4;i++)
+	{
+		btSwapScalarEndian(vector[i],swappedVec[i]);
+	}
+	vector = swappedVec;
+}
+
+#endif //SIMD__VECTOR3_H
Index: /code/branches/physics/src/bullet/NEWS
===================================================================
--- /code/branches/physics/src/bullet/NEWS	(revision 2122)
+++ /code/branches/physics/src/bullet/NEWS	(revision 2122)
@@ -0,0 +1,4 @@
+
+For news, visit the Bullet Physics Forum at
+http://www.continuousphysics.com/Bullet/phpBB2/viewforum.php?f=9
+
Index: /code/branches/physics/src/bullet/README
===================================================================
--- /code/branches/physics/src/bullet/README	(revision 2122)
+++ /code/branches/physics/src/bullet/README	(revision 2122)
@@ -0,0 +1,7 @@
+
+Bullet is a 3D Collision Detection and Rigid Body Dynamics Library for games and animation.
+Free for commercial use, including Playstation 3, open source under the ZLib License.
+Discrete and continuous collision detection, integrated into Blender 3D, and COLLADA 1.4 Physics import. 
+
+See the Bullet_User_Manual.pdf for more info and visit the Bullet Physics Forum at
+http://bulletphysics.com
Index: /code/branches/physics/src/bullet/VERSION
===================================================================
--- /code/branches/physics/src/bullet/VERSION	(revision 2122)
+++ /code/branches/physics/src/bullet/VERSION	(revision 2122)
@@ -0,0 +1,2 @@
+Bullet Collision Detection and Physics Library version 2.72
+http://bullet.googlecode.com
Index: /code/branches/physics/src/bullet/btBulletCollisionCommon.h
===================================================================
--- /code/branches/physics/src/bullet/btBulletCollisionCommon.h	(revision 2122)
+++ /code/branches/physics/src/bullet/btBulletCollisionCommon.h	(revision 2122)
@@ -0,0 +1,66 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BULLET_COLLISION_COMMON_H
+#define BULLET_COLLISION_COMMON_H
+
+///Common headerfile includes for Bullet Collision Detection
+
+///Bullet's btCollisionWorld and btCollisionObject definitions
+#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
+
+///Collision Shapes
+#include "BulletCollision/CollisionShapes/btBoxShape.h"
+#include "BulletCollision/CollisionShapes/btSphereShape.h"
+#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
+#include "BulletCollision/CollisionShapes/btCylinderShape.h"
+#include "BulletCollision/CollisionShapes/btConeShape.h"
+#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
+#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleMesh.h"
+#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h"
+#include "BulletCollision/CollisionShapes/btCompoundShape.h"
+#include "BulletCollision/CollisionShapes/btTetrahedronShape.h"
+#include "BulletCollision/CollisionShapes/btEmptyShape.h"
+#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
+#include "BulletCollision/CollisionShapes/btUniformScalingShape.h"
+
+///Narrowphase Collision Detector
+#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h"
+
+//btSphereBoxCollisionAlgorithm is broken, use gjk for now
+//#include "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h"
+
+///Dispatching and generation of collision pairs (broadphase)
+#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
+#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h"
+#include "BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h"
+#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
+
+///Math library & Utils
+#include "LinearMath/btQuaternion.h"
+#include "LinearMath/btTransform.h"
+#include "LinearMath/btDefaultMotionState.h"
+#include "LinearMath/btQuickprof.h"
+#include "LinearMath/btIDebugDraw.h"
+
+#endif //BULLET_COLLISION_COMMON_H
+
Index: /code/branches/physics/src/bullet/btBulletDynamicsCommon.h
===================================================================
--- /code/branches/physics/src/bullet/btBulletDynamicsCommon.h	(revision 2122)
+++ /code/branches/physics/src/bullet/btBulletDynamicsCommon.h	(revision 2122)
@@ -0,0 +1,46 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose, 
+including commercial applications, and to alter it and redistribute it freely, 
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BULLET_DYNAMICS_COMMON_H
+#define BULLET_DYNAMICS_COMMON_H
+
+///Common headerfile includes for Bullet Dynamics, including Collision Detection
+#include "btBulletCollisionCommon.h"
+
+#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
+#include "BulletDynamics/Dynamics/btContinuousDynamicsWorld.h"
+
+#include "BulletDynamics/Dynamics/btSimpleDynamicsWorld.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+#include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h"
+#include "BulletDynamics/ConstraintSolver/btHingeConstraint.h"
+#include "BulletDynamics/ConstraintSolver/btConeTwistConstraint.h"
+#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
+#include "BulletDynamics/ConstraintSolver/btSliderConstraint.h"
+
+#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
+
+
+///Vehicle simulation, with wheel contact simulated by raycasts
+#include "BulletDynamics/Vehicle/btRaycastVehicle.h"
+
+
+
+
+
+
+#endif //BULLET_DYNAMICS_COMMON_H
+
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILua.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILua.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILua.cpp	(revision 2122)
@@ -0,0 +1,294 @@
+/***********************************************************************
+	filename: CEGUILua.cpp
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+	
+	purpose:  Implementation for LuaScriptModule class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#include "CEGUI.h"
+#include "CEGUIPropertyHelper.h"
+#include "CEGUILua.h"
+#include "CEGUILuaFunctor.h"
+#include <vector>
+
+// include Lua libs and tolua++
+#include "lua/lua.hpp"
+#include "tolua/tolua++.h"
+
+// prototype for bindings initialisation function
+int tolua_CEGUI_open(lua_State* tolua_S);
+
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*************************************************************************
+	Constructor (creates Lua state)
+*************************************************************************/
+LuaScriptModule::LuaScriptModule()
+{
+    static const luaL_Reg lualibs[] = {
+        {"", luaopen_base},
+        {LUA_LOADLIBNAME, luaopen_package},
+        {LUA_TABLIBNAME, luaopen_table},
+        {LUA_IOLIBNAME, luaopen_io},
+        {LUA_OSLIBNAME, luaopen_os},
+        {LUA_STRLIBNAME, luaopen_string},
+        {LUA_MATHLIBNAME, luaopen_math},
+    #if defined(DEBUG) || defined (_DEBUG)
+        {LUA_DBLIBNAME, luaopen_debug},
+    #endif
+        {0, 0}
+    };
+
+    // create a lua state
+    d_ownsState = true;
+    d_state = lua_open();
+
+    // init all standard libraries
+    const luaL_Reg *lib = lualibs;
+    for (; lib->func; lib++)
+    {
+        lua_pushcfunction(d_state, lib->func);
+        lua_pushstring(d_state, lib->name);
+        lua_call(d_state, 1, 0);
+    }
+
+    setModuleIdentifierString();
+}
+
+
+/*************************************************************************
+	Constructor (uses given Lua state)
+*************************************************************************/
+LuaScriptModule::LuaScriptModule(lua_State* state)
+{
+	// just use the given state
+	d_ownsState = false;
+	d_state = state;
+
+	setModuleIdentifierString();
+}
+
+
+/*************************************************************************
+	Destructor
+*************************************************************************/
+LuaScriptModule::~LuaScriptModule()
+{
+	if ( d_ownsState && d_state )
+	{
+		lua_close( d_state );
+	}
+}
+
+
+/*************************************************************************
+	Execute script file
+*************************************************************************/
+void LuaScriptModule::executeScriptFile(const String& filename, const String& resourceGroup)
+{
+	// load file
+	RawDataContainer raw;
+	System::getSingleton().getResourceProvider()->loadRawDataContainer(filename,
+        raw, resourceGroup.empty() ? d_defaultResourceGroup : resourceGroup);
+
+	// load code into lua
+	int top = lua_gettop(d_state);
+	int loaderr = luaL_loadbuffer(d_state, (char*)raw.getDataPtr(), raw.getSize(), filename.c_str());
+	System::getSingleton().getResourceProvider()->unloadRawDataContainer( raw );
+	if (loaderr)
+	{
+	    String errMsg = lua_tostring(d_state,-1);
+		lua_settop(d_state,top);
+		throw ScriptException("Unable to execute Lua script file: '"+filename+"'\n\n"+errMsg+"\n");
+	}
+    
+    // call it
+	if (lua_pcall(d_state,0,0,0))
+	{
+	    String errMsg = lua_tostring(d_state,-1);
+		lua_settop(d_state,top);
+		throw ScriptException("Unable to execute Lua script file: '"+filename+"'\n\n"+errMsg+"\n");
+	}
+
+	lua_settop(d_state,top); // just in case :P
+}
+
+
+/*************************************************************************
+	Execute global script function
+*************************************************************************/
+int	LuaScriptModule::executeScriptGlobal(const String& function_name)
+{
+    int top = lua_gettop(d_state);
+
+    // get the function from lua
+    lua_getglobal(d_state, function_name.c_str());
+
+    // is it a function
+    if (!lua_isfunction(d_state,-1))
+    {
+        lua_settop(d_state,top);
+        throw ScriptException("Unable to get Lua global: '"+function_name+"' as name not represent a global Lua function" );
+    }
+
+    // call it
+    int error = lua_pcall(d_state,0,1,0);		
+
+    // handle errors
+    if (error)
+    {
+        String errMsg = lua_tostring(d_state,-1);
+        lua_pop(d_state,1);
+        throw ScriptException("Unable to evaluate Lua global: '"+function_name+"\n\n"+errMsg+"\n");
+    }
+
+    // get return value
+    if (!lua_isnumber(d_state,-1))
+    {
+        // log that return value is invalid. return -1 and move on.
+        lua_settop(d_state,top);
+        ScriptException("Unable to get Lua global : '"+function_name+"' return value as it's not a number" );
+        return -1;
+    }
+
+    int ret = (int)lua_tonumber(d_state,-1);
+    lua_pop(d_state,1);
+
+    // return it
+    return ret;
+}
+
+
+/*************************************************************************
+	Execute scripted event handler
+*************************************************************************/
+bool LuaScriptModule::executeScriptedEventHandler(const String& handler_name, const EventArgs& e)
+{
+    LuaFunctor::pushNamedFunction(d_state, handler_name);
+
+    // push EventArgs as the first parameter
+    tolua_pushusertype(d_state,(void*)&e,"const CEGUI::EventArgs");
+
+    // call it
+    int error = lua_pcall(d_state,1,0,0);
+
+    // handle errors
+    if (error)
+    {
+        String errStr(lua_tostring(d_state,-1));
+        lua_pop(d_state,1);
+        throw ScriptException("Unable to evaluate the Lua event handler: '"+handler_name+"'\n\n"+errStr+"\n");
+    }
+
+    return true;
+}
+
+
+/*************************************************************************
+	Execute script code string
+*************************************************************************/
+void LuaScriptModule::executeString(const String& str)
+{
+    int top = lua_gettop(d_state);
+
+    // load code into lua and call it
+    int error =	luaL_loadbuffer(d_state, str.c_str(), str.length(), str.c_str()) || lua_pcall(d_state,0,0,0);
+
+    // handle errors
+    if (error)
+    {
+        String errMsg = lua_tostring(d_state,-1);
+        lua_settop(d_state,top);
+        throw ScriptException("Unable to execute Lua script string: '"+str+"'\n\n"+errMsg+"\n");
+    }
+}
+	
+
+/*************************************************************************
+	Create Lua bindings
+*************************************************************************/
+void LuaScriptModule::createBindings(void)
+{
+	CEGUI::Logger::getSingleton().logEvent( "---- Creating Lua bindings ----" );
+	// init CEGUI module
+	tolua_CEGUI_open(d_state);
+}
+
+
+/*************************************************************************
+	Destroy Lua bindings
+*************************************************************************/
+void LuaScriptModule::destroyBindings(void)
+{
+	CEGUI::Logger::getSingleton().logEvent( "---- Destroying Lua bindings ----" );
+	// is this ok ?
+	lua_pushnil(d_state);
+	lua_setglobal(d_state,"CEGUI");
+}
+
+
+/*************************************************************************
+	Set the ID string for the module
+*************************************************************************/
+void LuaScriptModule::setModuleIdentifierString()
+{
+    // set ID string
+    d_identifierString = "CEGUI::LuaScriptModule - Official Lua based scripting module for CEGUI";
+}
+
+
+/*************************************************************************
+	Subscribe to a scripted event handler
+*************************************************************************/
+Event::Connection LuaScriptModule::subscribeEvent(EventSet* target, const String& event_name, const String& subscriber_name)
+{
+    // do the real subscription
+    LuaFunctor functor(d_state,subscriber_name,LUA_NOREF);
+    Event::Connection con = target->subscribeEvent(event_name, Event::Subscriber(functor));
+    // make sure we don't release the reference we just made when this call returns
+    functor.index = LUA_NOREF;
+
+    // return the event connection
+    return con;
+}
+
+
+/*************************************************************************
+	Subscribe to a scripted event handler
+*************************************************************************/
+Event::Connection LuaScriptModule::subscribeEvent(EventSet* target, const String& event_name, Event::Group group, const String& subscriber_name)
+{
+    // do the real subscription
+    LuaFunctor functor(d_state,subscriber_name,LUA_NOREF);
+    Event::Connection con = target->subscribeEvent(event_name, group, Event::Subscriber(functor));
+
+    // return the event connection
+    return con;
+}
+
+} // namespace CEGUI
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILua.h
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILua.h	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILua.h	(revision 2122)
@@ -0,0 +1,254 @@
+/***********************************************************************
+	filename: CEGUILua.h
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+	
+	purpose:  Defines interface for LuaScriptModule class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#ifndef _CEGUILua_h_
+#define _CEGUILua_h_
+
+
+/*** CHANGES BY ORXONOX TEAM FOR MINGW32 ***/
+/*************************************************************************
+	Import / Export control macros
+*************************************************************************/
+#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
+#   ifdef CEGUILUA_EXPORTS
+#       define CEGUILUA_API __declspec(dllexport)
+#   else
+#      if defined( __MINGW32__ )
+#          define CEGUILUA_API
+#      else
+#          define CEGUILUA_API __declspec(dllimport)
+#      endif
+#   endif
+#else
+#   define CEGUILUA_API
+#endif
+
+
+#include "CEGUIScriptModule.h"
+
+struct lua_State;
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*!
+\brief
+	Interface for the LuaScriptModule class
+*/
+class CEGUILUA_API LuaScriptModule : public CEGUI::ScriptModule
+{
+public:
+	/*************************************************************************
+		Construction and Destruction
+	*************************************************************************/
+	/*!
+	\brief
+		Constructor for LuaScriptModule class which create a lua_State
+	*/
+	LuaScriptModule();
+
+
+	/*!
+	\brief
+		Constructor for LuaScriptModule class which takes a lua_State
+
+	\param state
+		Pointer to the lua_State that the script module should attach to.
+	*/
+	LuaScriptModule(lua_State* state);
+
+
+	/*!
+	\brief
+		Destructor for LuaScriptModule class.
+	*/
+	~LuaScriptModule();
+
+
+	/*************************************************************************
+		Script Execution Functions
+	*************************************************************************/
+	/*!
+	\brief
+		Execute a script file.
+
+	\param filename
+		String object holding the filename of the script file that is to be executed
+		
+	\param resourceGroup
+		Resource group idendifier to be passed to the ResourceProvider when loading the script file.
+	*/
+	void executeScriptFile(const String& filename, const String& resourceGroup);
+
+
+	/*!
+	\brief
+		Execute a scripted global function.  The function should not take any parameters and should return an integer.
+
+	\param function_name
+		String object holding the name of the function, in the global script environment, that
+		is to be executed.
+
+	\return
+		The integer value returned from the script function.
+	*/
+	int executeScriptGlobal(const String& function_name);
+
+
+    /*!
+    \brief
+        Execute a scripted global 'event handler' function by looking it up by name.
+
+    \param handler_name
+        String object holding the name of the scripted handler function.
+        If this string contains dots '.' it will be parsed as tables containing a function field.
+        For example: 'mytable.subtable.func'
+
+    \param e
+        EventArgs based object that should be passed, by any appropriate means, to the scripted function.
+
+    \return
+        - true if the event was handled.
+        - false if the event was not handled.
+    */
+    bool executeScriptedEventHandler(const String& handler_name, const EventArgs& e);
+
+
+    /*!
+    \brief
+        Execute script code contained in the given CEGUI::String object.
+
+    \param str
+        String object holding the valid script code that should be executed.
+
+    \return
+        Nothing.
+    */
+    void executeString(const String& str);
+
+    /*************************************************************************
+        Event subscription
+    *************************************************************************/
+    /*!
+    \brief
+            Subscribes the named Event to a scripted funtion
+
+    \param target
+            The target EventSet for the subscription.
+
+    \param name
+            String object containing the name of the Event to subscribe to.
+
+    \param subscriber_name
+            String object containing the name of the script funtion that is to be subscribed to the Event.
+
+    \return
+            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
+
+    \exception UnknownObjectException	Thrown if an Event named \a name is not in the EventSet
+    */
+    Event::Connection	subscribeEvent(EventSet* target, const String& name, const String& subscriber_name);
+
+    /*!
+    \brief
+            Subscribes the specified group of the named Event to a scripted funtion.
+
+    \param target
+            The target EventSet for the subscription.
+
+    \param name
+            String object containing the name of the Event to subscribe to.
+
+    \param group
+            Group which is to be subscribed to.  Subscription groups are called in ascending order.
+
+    \param subscriber_name
+            String object containing the name of the script funtion that is to be subscribed to the Event.
+
+    \return
+            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
+
+    \exception UnknownObjectException	Thrown if an Event named \a name is not in the EventSet
+    */
+    Event::Connection	subscribeEvent(EventSet* target, const String& name, Event::Group group, const String& subscriber_name);
+
+    /*************************************************************************
+        Bindings creation / destruction
+    *************************************************************************/
+    /*!
+    \brief
+        Method called during system initialisation, prior to running any scripts via the ScriptModule, to enable the ScriptModule
+        to perform any operations required to complete initialisation or binding of the script language to the gui system objects.
+
+    \return
+        Nothing.
+    */
+    void createBindings(void);
+
+
+    /*!
+    \brief
+        Method called during system destruction, after all scripts have been run via the ScriptModule, to enable the ScriptModule
+        to perform any operations required to cleanup bindings of the script language to the gui system objects, as set-up in the
+        earlier createBindings call.
+
+    \return
+        Nothing.
+    */
+    void destroyBindings(void);
+
+    /*************************************************************************
+        Accessor type functions
+    *************************************************************************/
+    /*!
+    \brief
+        Method used to get a pointer to the lua_State that the script module is attached to.
+
+    \return
+        A pointer to the lua_State that the script module is attached to.
+    */
+    lua_State* getLuaState(void) const {return d_state;}
+
+private:
+    /*************************************************************************
+        Implementation Functions
+    *************************************************************************/
+    void setModuleIdentifierString();
+
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    bool d_ownsState;      //!< true when the attached lua_State was created by this script module
+    lua_State* d_state;    //!< The lua_State that this script module uses.
+};
+
+} // namespace CEGUI
+
+#endif // end of guard _CEGUILua_h_
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILuaFunctor.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILuaFunctor.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILuaFunctor.cpp	(revision 2122)
@@ -0,0 +1,254 @@
+/***********************************************************************
+    filename: CEGUILuaFunctor.cpp
+    created:  Thu Jan 26 2006
+    author:   Tomas Lindquist Olsen <tomas@famolsen.dk>
+
+    purpose:  Implementation for LuaFunctor class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#include "CEGUILuaFunctor.h"
+#include "CEGUILogger.h"
+#include "CEGUIExceptions.h"
+#include "CEGUIPropertyHelper.h"
+
+// include Lua libs and tolua++
+#include "lua/lua.hpp"
+#include "tolua/tolua++.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+LuaFunctor::LuaFunctor(lua_State* state, int func, int selfIndex) :
+    L(state),
+    index(func),
+    self(selfIndex),
+    needs_lookup(false)
+{
+}
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+LuaFunctor::LuaFunctor(lua_State* state, const String& func, int selfIndex) :
+    L(state),
+    index(LUA_NOREF),
+    self(selfIndex),
+    needs_lookup(true),
+    function_name(func)
+{
+}
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+LuaFunctor::LuaFunctor(const LuaFunctor& cp) :
+    L(cp.L),
+    index(cp.index),
+    self(cp.self),
+    needs_lookup(cp.needs_lookup),
+    function_name(cp.function_name)
+{
+}
+
+/*************************************************************************
+    Destructor
+*************************************************************************/
+LuaFunctor::~LuaFunctor()
+{
+    if (self!=LUA_NOREF)
+    {
+        luaL_unref(L, LUA_REGISTRYINDEX, self);
+    }
+    if (index!=LUA_NOREF)
+    {
+        luaL_unref(L, LUA_REGISTRYINDEX, index);
+    }
+}
+
+/*************************************************************************
+    Call operator
+*************************************************************************/
+bool LuaFunctor::operator()(const EventArgs& args) const
+{
+    // is this a late binding?
+    if (needs_lookup)
+    {
+        pushNamedFunction(L, function_name);
+        // reference function
+        index = luaL_ref(L, LUA_REGISTRYINDEX);
+        needs_lookup = false;
+        CEGUI_LOGINSANE("Late binding of callback '"+function_name+"' performed");
+        function_name.clear();
+    }
+
+    // retrieve function
+    lua_rawgeti(L, LUA_REGISTRYINDEX, index);
+
+    // possibly self as well?
+    int nargs = 1;
+    if (self != LUA_NOREF)
+    {
+        lua_rawgeti(L, LUA_REGISTRYINDEX, self);
+        ++nargs;
+    }
+
+    // push EventArgs  parameter
+    tolua_pushusertype(L, (void*)&args, "const CEGUI::EventArgs");
+
+    // call it
+    int error = lua_pcall(L, nargs, 0, 0);
+
+    // handle errors
+    if (error)
+    {
+        String errStr(lua_tostring(L, -1));
+        lua_pop(L, 1);
+        throw ScriptException("Unable to call Lua event handler:\n\n"+errStr+"\n");
+    }
+
+    return true;
+}
+
+/*************************************************************************
+    do event subscription by reference instead of by name
+*************************************************************************/
+Event::Connection LuaFunctor::SubscribeEvent(EventSet* self, const String& event_name, int funcIndex, int selfIndex, lua_State* L)
+{
+    // should we pass a self to the callback?
+    int thisIndex = LUA_NOREF;
+    if (selfIndex != LUA_NOREF)
+    {
+        // reference self
+        thisIndex = luaL_ref(L, LUA_REGISTRYINDEX);
+    }
+
+    // do the real subscription
+    int type = lua_type(L,-1);
+    Event::Connection con;
+    if (type == LUA_TFUNCTION)
+    {
+        // reference function
+        int index = luaL_ref(L, LUA_REGISTRYINDEX);
+        LuaFunctor functor(L,index,thisIndex);
+        con = self->subscribeEvent(String(event_name), Event::Subscriber(functor));
+        // make sure we don't release the reference(s) we just made when this call returns
+        functor.index = LUA_NOREF;
+        functor.self = LUA_NOREF;
+    }
+    else if (type == LUA_TSTRING)
+    {
+        const char* str = lua_tostring(L, -1);
+        LuaFunctor functor(L,String(str),thisIndex);
+        con = self->subscribeEvent(String(event_name), Event::Subscriber(functor));
+        // make sure we don't release the reference we just (maybe) made when this call returns
+        functor.self = LUA_NOREF;
+    }
+    else
+    {
+        luaL_error(L,"bad function passed to subscribe function. must be a real function, or a string for late binding");
+    }
+
+    // return the event connection
+    return con;
+}
+
+/*************************************************************************
+    Pushes a named function on the stack
+*************************************************************************/
+void LuaFunctor::pushNamedFunction(lua_State* L, const String& handler_name)
+{
+    int top = lua_gettop(L);
+
+    // do we have any dots in the handler name? if so we grab the function as a table field
+    String::size_type i = handler_name.find_first_of((utf32)'.');
+    if (i!=String::npos)
+    {
+        // split the rest of the string up in parts seperated by '.'
+        // TODO: count the dots and size the vector accordingly from the beginning.
+        std::vector<String> parts;
+        String::size_type start = 0;
+        do
+        {
+            parts.push_back(handler_name.substr(start,i-start));
+            start = i+1;
+            i = handler_name.find_first_of((utf32)'.',start);
+        } while(i!=String::npos);
+
+        // add last part
+        parts.push_back(handler_name.substr(start));
+
+        // first part is the global
+        lua_getglobal(L, parts[0].c_str());
+        if (!lua_istable(L,-1))
+        {
+            lua_settop(L,top);
+            throw ScriptException("Unable to get the Lua event handler: '"+handler_name+"' as first part is not a table");
+        }
+
+        // if there is more than two parts, we have more tables to go through
+        std::vector<String>::size_type visz = parts.size();
+        if (visz-- > 2) // avoid subtracting one later on
+        {
+            // go through all the remaining parts to (hopefully) have a valid Lua function in the end
+            std::vector<String>::size_type vi = 1;
+            while (vi<visz)
+            {
+                // push key, and get the next table
+                lua_pushstring(L,parts[vi].c_str());
+                lua_gettable(L,-2);
+                if (!lua_istable(L,-1))
+                {
+                    lua_settop(L,top);
+                    throw ScriptException("Unable to get the Lua event handler: '"+handler_name+"' as part #"+PropertyHelper::uintToString(uint(vi+1))+" ("+parts[vi]+") is not a table");
+                }
+                // get rid of the last table and move on
+                lua_remove(L,-2);
+                vi++;
+            }
+        }
+
+        // now we are ready to get the function to call ... phew :)
+        lua_pushstring(L,parts[visz].c_str());
+        lua_gettable(L,-2);
+        lua_remove(L,-2); // get rid of the table
+    }
+    // just a regular global function
+    else
+    {
+        lua_getglobal(L, handler_name.c_str());
+    }
+
+    // is it a function
+    if (!lua_isfunction(L,-1))
+    {
+        lua_settop(L,top);
+        throw ScriptException("The Lua event handler: '"+handler_name+"' does not represent a Lua function");
+    }
+}
+
+} // namespace CEGUI
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILuaFunctor.h
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILuaFunctor.h	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CEGUILuaFunctor.h	(revision 2122)
@@ -0,0 +1,85 @@
+/***********************************************************************
+    filename: CEGUILuaFunctor.h
+    created:  Thu Jan 26 2006
+    author:   Tomas Lindquist Olsen <tomas@famolsen.dk>
+
+    purpose:  Defines interface for LuaFunctor class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#ifndef _CEGUILuaFunctor_h_
+#define _CEGUILuaFunctor_h_
+
+#include "CEGUIEventSet.h"
+
+struct lua_State;
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+// forward declaration
+class LuaScriptModule;
+
+/*!
+\brief
+    Functor class used for subscribing Lua functions to CEGUI events
+*/
+class LuaFunctor
+{
+public:
+    LuaFunctor(lua_State* state, int func, int selfIndex);
+    LuaFunctor(lua_State* state, const String& func, int selfIndex);
+    LuaFunctor(const LuaFunctor& cp);
+    ~LuaFunctor();
+
+    bool operator()(const EventArgs& args) const;
+
+    /*!
+    \brief
+        function used to subscribe any Lua function as event handler.
+        References using the Lua registry.
+        To be called from Lua only.
+    */
+    static Event::Connection SubscribeEvent(EventSet* self, const String& eventName, int funcIndex, int selfIndex, lua_State* L);
+
+    /*!
+    \brief
+        Pushes the Lua function named \param name on top of the Lua stack.
+        The name may contain '.' (dots) character for (nested) table values.
+    */
+    static void pushNamedFunction(lua_State* L, const String& name);
+
+private:
+    lua_State* L;
+    mutable int index;
+    int self;
+    mutable bool needs_lookup;
+    mutable String function_name;
+
+    friend class LuaScriptModule;
+};
+
+} // namespace CEGUI
+
+#endif // end of guard _CEGUILuaFunctor_h_
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,16 @@
+INCLUDE_DIRECTORIES(.)
+
+SET( CEGUILUA_SRC_FILES
+  CEGUILua.cpp
+  CEGUILuaFunctor.cpp
+  lua_CEGUI.cpp
+  required.cpp
+)
+
+ADD_LIBRARY( ceguilua_orxonox SHARED ${CEGUILUA_SRC_FILES} )
+
+TARGET_LINK_LIBRARIES(ceguilua_orxonox
+  lua_orxonox
+  tolualib_orxonox
+  ${CEGUI_LIBRARIES}
+)
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/lua_CEGUI.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/lua_CEGUI.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/lua_CEGUI.cpp	(revision 2122)
@@ -0,0 +1,49778 @@
+/*
+** Lua binding: CEGUI
+** Generated automatically by tolua++-1.0.92 on 08/27/06 20:58:20.
+*/
+
+#ifndef __cplusplus
+#include "stdlib.h"
+#endif
+#include "string.h"
+
+#include "tolua/tolua++.h"
+
+/* Exported function */
+int tolua_CEGUI_open (lua_State* tolua_S);
+
+#include "required.h"
+#include "CEGUIPropertyHelper.h"
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_CEGUI__Image (lua_State* tolua_S)
+{
+ CEGUI::Image* self = (CEGUI::Image*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__SchemeIterator (lua_State* tolua_S)
+{
+ CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetDim (lua_State* tolua_S)
+{
+ CEGUI::WidgetDim* self = (CEGUI::WidgetDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FalagardWindowMapping (lua_State* tolua_S)
+{
+ CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__MouseEventArgs (lua_State* tolua_S)
+{
+ CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImageIterator (lua_State* tolua_S)
+{
+ CEGUI::ImageIterator* self = (CEGUI::ImageIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImagesetIterator (lua_State* tolua_S)
+{
+ CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Dimension (lua_State* tolua_S)
+{
+ CEGUI::Dimension* self = (CEGUI::Dimension*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetLookFeel (lua_State* tolua_S)
+{
+ CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__DragDropEventArgs (lua_State* tolua_S)
+{
+ CEGUI::DragDropEventArgs* self = (CEGUI::DragDropEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetLookManager (lua_State* tolua_S)
+{
+ CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FileStream (lua_State* tolua_S)
+{
+ CEGUI::FileStream* self = (CEGUI::FileStream*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__EventIterator (lua_State* tolua_S)
+{
+ CEGUI::EventIterator* self = (CEGUI::EventIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ColourRect (lua_State* tolua_S)
+{
+ CEGUI::ColourRect* self = (CEGUI::ColourRect*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__SectionSpecification (lua_State* tolua_S)
+{
+ CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__LayerSpecification (lua_State* tolua_S)
+{
+ CEGUI::LayerSpecification* self = (CEGUI::LayerSpecification*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__StateImagery (lua_State* tolua_S)
+{
+ CEGUI::StateImagery* self = (CEGUI::StateImagery*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__EventConnection (lua_State* tolua_S)
+{
+ CEGUI::EventConnection* self = (CEGUI::EventConnection*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImagerySection (lua_State* tolua_S)
+{
+ CEGUI::ImagerySection* self = (CEGUI::ImagerySection*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__TextComponent (lua_State* tolua_S)
+{
+ CEGUI::TextComponent* self = (CEGUI::TextComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Vector2 (lua_State* tolua_S)
+{
+ CEGUI::Vector2* self = (CEGUI::Vector2*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__String (lua_State* tolua_S)
+{
+ CEGUI::String* self = (CEGUI::String*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__NamedArea (lua_State* tolua_S)
+{
+ CEGUI::NamedArea* self = (CEGUI::NamedArea*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImageDim (lua_State* tolua_S)
+{
+ CEGUI::ImageDim* self = (CEGUI::ImageDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FrameComponent (lua_State* tolua_S)
+{
+ CEGUI::FrameComponent* self = (CEGUI::FrameComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WindowEventArgs (lua_State* tolua_S)
+{
+ CEGUI::WindowEventArgs* self = (CEGUI::WindowEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WindowIterator (lua_State* tolua_S)
+{
+ CEGUI::WindowIterator* self = (CEGUI::WindowIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WindowFactoryIterator (lua_State* tolua_S)
+{
+ CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__MCLGridRef (lua_State* tolua_S)
+{
+ CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FontIterator (lua_State* tolua_S)
+{
+ CEGUI::FontIterator* self = (CEGUI::FontIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ActivationEventArgs (lua_State* tolua_S)
+{
+ CEGUI::ActivationEventArgs* self = (CEGUI::ActivationEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyLinkDefinition (lua_State* tolua_S)
+{
+ CEGUI::PropertyLinkDefinition* self = (CEGUI::PropertyLinkDefinition*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyInitialiser (lua_State* tolua_S)
+{
+ CEGUI::PropertyInitialiser* self = (CEGUI::PropertyInitialiser*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FalagardMappingIterator (lua_State* tolua_S)
+{
+ CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__EventArgs (lua_State* tolua_S)
+{
+ CEGUI::EventArgs* self = (CEGUI::EventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyDefinition (lua_State* tolua_S)
+{
+ CEGUI::PropertyDefinition* self = (CEGUI::PropertyDefinition*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__UVector2 (lua_State* tolua_S)
+{
+ CEGUI::UVector2* self = (CEGUI::UVector2*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ComponentArea (lua_State* tolua_S)
+{
+ CEGUI::ComponentArea* self = (CEGUI::ComponentArea*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyIterator (lua_State* tolua_S)
+{
+ CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__AbsoluteDim (lua_State* tolua_S)
+{
+ CEGUI::AbsoluteDim* self = (CEGUI::AbsoluteDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__HeaderSequenceEventArgs (lua_State* tolua_S)
+{
+ CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyDim (lua_State* tolua_S)
+{
+ CEGUI::PropertyDim* self = (CEGUI::PropertyDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FontDim (lua_State* tolua_S)
+{
+ CEGUI::FontDim* self = (CEGUI::FontDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__URect (lua_State* tolua_S)
+{
+ CEGUI::URect* self = (CEGUI::URect*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__UnifiedDim (lua_State* tolua_S)
+{
+ CEGUI::UnifiedDim* self = (CEGUI::UnifiedDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImageryComponent (lua_State* tolua_S)
+{
+ CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetComponent (lua_State* tolua_S)
+{
+ CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__KeyEventArgs (lua_State* tolua_S)
+{
+ CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__UDim (lua_State* tolua_S)
+{
+ CEGUI::UDim* self = (CEGUI::UDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__colour (lua_State* tolua_S)
+{
+ CEGUI::colour* self = (CEGUI::colour*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Size (lua_State* tolua_S)
+{
+ CEGUI::Size* self = (CEGUI::Size*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__MouseCursorEventArgs (lua_State* tolua_S)
+{
+ CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Rect (lua_State* tolua_S)
+{
+ CEGUI::Rect* self = (CEGUI::Rect*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+
+/* function to register type */
+static void tolua_reg_types (lua_State* tolua_S)
+{
+ tolua_usertype(tolua_S,"CEGUI::Logger");
+ tolua_usertype(tolua_S,"CEGUI::Image");
+ tolua_usertype(tolua_S,"CEGUI::MenuBase");
+ tolua_usertype(tolua_S,"CEGUI::Renderer");
+ tolua_usertype(tolua_S,"CEGUI::SchemeIterator");
+ tolua_usertype(tolua_S,"CEGUI::FalagardComponentBase");
+ tolua_usertype(tolua_S,"CEGUI::Scrollbar");
+ tolua_usertype(tolua_S,"CEGUI::MouseEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::ImageIterator");
+ tolua_usertype(tolua_S,"CEGUI::ImagesetIterator");
+ tolua_usertype(tolua_S,"CEGUI::ItemListBase");
+ tolua_usertype(tolua_S,"CEGUI::Dimension");
+ tolua_usertype(tolua_S,"CEGUI::WindowFactory");
+ tolua_usertype(tolua_S,"CEGUI::MouseCursor");
+ tolua_usertype(tolua_S,"CEGUI::ItemListbox");
+ tolua_usertype(tolua_S,"CEGUI::ComboDropList");
+ tolua_usertype(tolua_S,"CEGUI::FrameWindow");
+ tolua_usertype(tolua_S,"CEGUI::ButtonBase");
+ tolua_usertype(tolua_S,"CEGUI::EventConnection");
+ tolua_usertype(tolua_S,"CEGUI::ListboxItem");
+ tolua_usertype(tolua_S,"CEGUI::Imageset");
+ tolua_usertype(tolua_S,"CEGUI::Property");
+ tolua_usertype(tolua_S,"CEGUI::EventIterator");
+ tolua_usertype(tolua_S,"CEGUI::FileStream");
+ tolua_usertype(tolua_S,"CEGUI::WindowFactoryIterator");
+ tolua_usertype(tolua_S,"CEGUI::OutStream");
+ tolua_usertype(tolua_S,"CEGUI::PropertyHelper");
+ tolua_usertype(tolua_S,"CEGUI::WidgetLookManager");
+ tolua_usertype(tolua_S,"CEGUI::WidgetLookFeel");
+ tolua_usertype(tolua_S,"CEGUI::PropertyDefinitionBase");
+ tolua_usertype(tolua_S,"CEGUI::ProgressBar");
+ tolua_usertype(tolua_S,"CEGUI::Editbox");
+ tolua_usertype(tolua_S,"CEGUI::LayerSpecification");
+ tolua_usertype(tolua_S,"CEGUI::UVector2");
+ tolua_usertype(tolua_S,"CEGUI::SectionSpecification");
+ tolua_usertype(tolua_S,"CEGUI::ImagerySection");
+ tolua_usertype(tolua_S,"CEGUI::Spinner");
+ tolua_usertype(tolua_S,"CEGUI::TextComponent");
+ tolua_usertype(tolua_S,"CEGUI::PropertyDefinition");
+ tolua_usertype(tolua_S,"CEGUI::FrameComponent");
+ tolua_usertype(tolua_S,"CEGUI::PropertyLinkDefinition");
+ tolua_usertype(tolua_S,"CEGUI::PropertyInitialiser");
+ tolua_usertype(tolua_S,"CEGUI::ImageryComponent");
+ tolua_usertype(tolua_S,"CEGUI::WidgetComponent");
+ tolua_usertype(tolua_S,"CEGUI::KeyEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::FontManager");
+ tolua_usertype(tolua_S,"CEGUI::Tooltip");
+ tolua_usertype(tolua_S,"CEGUI::ImagesetManager");
+ tolua_usertype(tolua_S,"CEGUI::ComponentArea");
+ tolua_usertype(tolua_S,"CEGUI::GlobalEventSet");
+ tolua_usertype(tolua_S,"CEGUI::PropertyDim");
+ tolua_usertype(tolua_S,"CEGUI::FontDim");
+ tolua_usertype(tolua_S,"CEGUI::UnifiedDim");
+ tolua_usertype(tolua_S,"CEGUI::WidgetDim");
+ tolua_usertype(tolua_S,"CEGUI::ImageDim");
+ tolua_usertype(tolua_S,"CEGUI::MultiLineEditbox");
+ tolua_usertype(tolua_S,"CEGUI::RadioButton");
+ tolua_usertype(tolua_S,"CEGUI::BaseDim");
+ tolua_usertype(tolua_S,"CEGUI::FalagardWindowMapping");
+ tolua_usertype(tolua_S,"CEGUI::WindowManager");
+ tolua_usertype(tolua_S,"CEGUI::ScrolledItemListBase");
+ tolua_usertype(tolua_S,"CEGUI::Checkbox");
+ tolua_usertype(tolua_S,"CEGUI::ListHeader");
+ tolua_usertype(tolua_S,"CEGUI::MenuItem");
+ tolua_usertype(tolua_S,"CEGUI::ScrolledContainer");
+ tolua_usertype(tolua_S,"CEGUI::PushButton");
+ tolua_usertype(tolua_S,"CEGUI::PopupMenu");
+ tolua_usertype(tolua_S,"CEGUI::TabControl");
+ tolua_usertype(tolua_S,"CEGUI::ItemEntry");
+ tolua_usertype(tolua_S,"CEGUI::MultiColumnList");
+ tolua_usertype(tolua_S,"CEGUI::MCLGridRef");
+ tolua_usertype(tolua_S,"CEGUI::ListHeaderSegment");
+ tolua_usertype(tolua_S,"CEGUI::Listbox");
+ tolua_usertype(tolua_S,"CEGUI::Combobox");
+ tolua_usertype(tolua_S,"CEGUI::ColourRect");
+ tolua_usertype(tolua_S,"CEGUI::Slider");
+ tolua_usertype(tolua_S,"CEGUI::System");
+ tolua_usertype(tolua_S,"CEGUI::StateImagery");
+ tolua_usertype(tolua_S,"CEGUI::ListboxTextItem");
+ tolua_usertype(tolua_S,"CEGUI::Menubar");
+ tolua_usertype(tolua_S,"CEGUI::Titlebar");
+ tolua_usertype(tolua_S,"CEGUI::Vector2");
+ tolua_usertype(tolua_S,"CEGUI::String");
+ tolua_usertype(tolua_S,"CEGUI::NamedArea");
+ tolua_usertype(tolua_S,"CEGUI::DragContainer");
+ tolua_usertype(tolua_S,"CEGUI::MouseCursorEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::WindowEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::WindowIterator");
+ tolua_usertype(tolua_S,"CEGUI::colour");
+ tolua_usertype(tolua_S,"CEGUI::Font");
+ tolua_usertype(tolua_S,"CEGUI::FontIterator");
+ tolua_usertype(tolua_S,"CEGUI::Texture");
+ tolua_usertype(tolua_S,"CEGUI::Thumb");
+ tolua_usertype(tolua_S,"CEGUI::DragDropEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::FalagardMappingIterator");
+ tolua_usertype(tolua_S,"CEGUI::EventArgs");
+ tolua_usertype(tolua_S,"CEGUI::ScrollablePane");
+ tolua_usertype(tolua_S,"CEGUI::EventSet");
+ tolua_usertype(tolua_S,"CEGUI::TabButton");
+ tolua_usertype(tolua_S,"CEGUI::PropertyIterator");
+ tolua_usertype(tolua_S,"CEGUI::AbsoluteDim");
+ tolua_usertype(tolua_S,"CEGUI::HeaderSequenceEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::Event");
+ tolua_usertype(tolua_S,"CEGUI::GUISheet");
+ tolua_usertype(tolua_S,"CEGUI::URect");
+ tolua_usertype(tolua_S,"CEGUI::CoordConverter");
+ tolua_usertype(tolua_S,"CEGUI::SchemeManager");
+ tolua_usertype(tolua_S,"CEGUI::Scheme");
+ tolua_usertype(tolua_S,"CEGUI::WindowFactoryManager");
+ tolua_usertype(tolua_S,"CEGUI::UDim");
+ tolua_usertype(tolua_S,"CEGUI::Size");
+ tolua_usertype(tolua_S,"CEGUI::ActivationEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::Window");
+ tolua_usertype(tolua_S,"CEGUI::Rect");
+}
+
+/* get function: d_x of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Vector2_x
+static int tolua_get_CEGUI__Vector2_x(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_x);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_x of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Vector2_x
+static int tolua_set_CEGUI__Vector2_x(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_x = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_y of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Vector2_y
+static int tolua_get_CEGUI__Vector2_y(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_y);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_y of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Vector2_y
+static int tolua_set_CEGUI__Vector2_y(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_y = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__add00
+static int tolua_CEGUI_CEGUI_Vector2__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->operator+(*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__sub00
+static int tolua_CEGUI_CEGUI_Vector2__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->operator-(*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__mul00
+static int tolua_CEGUI_CEGUI_Vector2__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->operator*(*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__eq00
+static int tolua_CEGUI_CEGUI_Vector2__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*vec);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new00
+static int tolua_CEGUI_CEGUI_Vector2_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new00_local
+static int tolua_CEGUI_CEGUI_Vector2_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new01
+static int tolua_CEGUI_CEGUI_Vector2_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2(x,y);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Vector2_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new01_local
+static int tolua_CEGUI_CEGUI_Vector2_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2(x,y);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Vector2_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_width of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Size_width
+static int tolua_get_CEGUI__Size_width(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_width'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_width);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_width of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Size_width
+static int tolua_set_CEGUI__Size_width(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_width'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_width = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_height of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Size_height
+static int tolua_get_CEGUI__Size_height(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_height'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_height);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_height of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Size_height
+static int tolua_set_CEGUI__Size_height(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_height'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_height = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size__eq00
+static int tolua_CEGUI_CEGUI_Size__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Size* self = (const CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*sz);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new00
+static int tolua_CEGUI_CEGUI_Size_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new00_local
+static int tolua_CEGUI_CEGUI_Size_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new01
+static int tolua_CEGUI_CEGUI_Size_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float w = ((float)  tolua_tonumber(tolua_S,2,0));
+  float h = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size(w,h);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Size_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new01_local
+static int tolua_CEGUI_CEGUI_Size_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float w = ((float)  tolua_tonumber(tolua_S,2,0));
+  float h = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size(w,h);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Size_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_top
+static int tolua_get_CEGUI__Rect_top(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_top);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_top
+static int tolua_set_CEGUI__Rect_top(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_bottom
+static int tolua_get_CEGUI__Rect_bottom(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_bottom);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_bottom
+static int tolua_set_CEGUI__Rect_bottom(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_left of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_left
+static int tolua_get_CEGUI__Rect_left(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_left);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_left of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_left
+static int tolua_set_CEGUI__Rect_left(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_left = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_right of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_right
+static int tolua_get_CEGUI__Rect_right(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_right);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_right of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_right
+static int tolua_set_CEGUI__Rect_right(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_right = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getPosition00
+static int tolua_CEGUI_CEGUI_Rect_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getPosition();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getWidth00
+static int tolua_CEGUI_CEGUI_Rect_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getHeight00
+static int tolua_CEGUI_CEGUI_Rect_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getSize00
+static int tolua_CEGUI_CEGUI_Rect_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIntersection of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getIntersection00
+static int tolua_CEGUI_CEGUI_Rect_getIntersection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIntersection'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getIntersection(*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIntersection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPointInRect of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_isPointInRect00
+static int tolua_CEGUI_CEGUI_Rect_isPointInRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* p = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPointInRect'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPointInRect(*p);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPointInRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setPosition00
+static int tolua_CEGUI_CEGUI_Rect_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* p = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*p);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidth of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setWidth00
+static int tolua_CEGUI_CEGUI_Rect_setWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  float w = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidth'",NULL);
+#endif
+ {
+  self->setWidth(w);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHeight of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setHeight00
+static int tolua_CEGUI_CEGUI_Rect_setHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  float h = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHeight'",NULL);
+#endif
+ {
+  self->setHeight(h);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSize of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setSize00
+static int tolua_CEGUI_CEGUI_Rect_setSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSize'",NULL);
+#endif
+ {
+  self->setSize(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offset of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_offset00
+static int tolua_CEGUI_CEGUI_Rect_offset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* p = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offset'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->offset(*p);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: constrainSizeMax of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_constrainSizeMax00
+static int tolua_CEGUI_CEGUI_Rect_constrainSizeMax00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'constrainSizeMax'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->constrainSizeMax(*sz);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'constrainSizeMax'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: constrainSizeMin of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_constrainSizeMin00
+static int tolua_CEGUI_CEGUI_Rect_constrainSizeMin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'constrainSizeMin'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->constrainSizeMin(*sz);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'constrainSizeMin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: constrainSize of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_constrainSize00
+static int tolua_CEGUI_CEGUI_Rect_constrainSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* min = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Size* max = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'constrainSize'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->constrainSize(*min,*max);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'constrainSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect__eq00
+static int tolua_CEGUI_CEGUI_Rect__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* r = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*r);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new00
+static int tolua_CEGUI_CEGUI_Rect_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new00_local
+static int tolua_CEGUI_CEGUI_Rect_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new01
+static int tolua_CEGUI_CEGUI_Rect_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float l = ((float)  tolua_tonumber(tolua_S,2,0));
+  float t = ((float)  tolua_tonumber(tolua_S,3,0));
+  float r = ((float)  tolua_tonumber(tolua_S,4,0));
+  float b = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect(l,t,r,b);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Rect_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new01_local
+static int tolua_CEGUI_CEGUI_Rect_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float l = ((float)  tolua_tonumber(tolua_S,2,0));
+  float t = ((float)  tolua_tonumber(tolua_S,3,0));
+  float r = ((float)  tolua_tonumber(tolua_S,4,0));
+  float b = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect(l,t,r,b);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Rect_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAlpha of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getAlpha00
+static int tolua_CEGUI_CEGUI_colour_getAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRed of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getRed00
+static int tolua_CEGUI_CEGUI_colour_getRed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRed'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getRed();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getGreen of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getGreen00
+static int tolua_CEGUI_CEGUI_colour_getGreen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getGreen'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getGreen();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getGreen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBlue of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getBlue00
+static int tolua_CEGUI_CEGUI_colour_getBlue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBlue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getBlue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBlue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHue of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getHue00
+static int tolua_CEGUI_CEGUI_colour_getHue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSaturation of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getSaturation00
+static int tolua_CEGUI_CEGUI_colour_getSaturation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSaturation'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getSaturation();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSaturation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLumination of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getLumination00
+static int tolua_CEGUI_CEGUI_colour_getLumination00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLumination'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getLumination();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLumination'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_set00
+static int tolua_CEGUI_CEGUI_colour_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+  float a = ((float)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(r,g,b,a);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlpha of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setAlpha00
+static int tolua_CEGUI_CEGUI_colour_setAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float a = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlpha'",NULL);
+#endif
+ {
+  self->setAlpha(a);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRed of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setRed00
+static int tolua_CEGUI_CEGUI_colour_setRed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRed'",NULL);
+#endif
+ {
+  self->setRed(r);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setGreen of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setGreen00
+static int tolua_CEGUI_CEGUI_colour_setGreen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float g = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setGreen'",NULL);
+#endif
+ {
+  self->setGreen(g);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setGreen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBlue of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setBlue00
+static int tolua_CEGUI_CEGUI_colour_setBlue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float b = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBlue'",NULL);
+#endif
+ {
+  self->setBlue(b);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBlue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRGB of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setRGB00
+static int tolua_CEGUI_CEGUI_colour_setRGB00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRGB'",NULL);
+#endif
+ {
+  self->setRGB(r,g,b);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRGB'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHSL of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setHSL00
+static int tolua_CEGUI_CEGUI_colour_setHSL00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float hue = ((float)  tolua_tonumber(tolua_S,2,0));
+  float saturation = ((float)  tolua_tonumber(tolua_S,3,0));
+  float luminance = ((float)  tolua_tonumber(tolua_S,4,0));
+  float alpha = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHSL'",NULL);
+#endif
+ {
+  self->setHSL(hue,saturation,luminance,alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHSL'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour__add00
+static int tolua_CEGUI_CEGUI_colour__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* c = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  self->operator+(*c);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour__sub00
+static int tolua_CEGUI_CEGUI_colour__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* c = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  self->operator-(*c);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour__eq00
+static int tolua_CEGUI_CEGUI_colour__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* c = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*c);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new00
+static int tolua_CEGUI_CEGUI_colour_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new00_local
+static int tolua_CEGUI_CEGUI_colour_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new01
+static int tolua_CEGUI_CEGUI_colour_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+  float a = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour(r,g,b,a);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_colour_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new01_local
+static int tolua_CEGUI_CEGUI_colour_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+  float a = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour(r,g,b,a);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_colour_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_top_left
+static int tolua_get_CEGUI__ColourRect_top_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_left'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_top_left,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_top_left
+static int tolua_set_CEGUI__ColourRect_top_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_left'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top_left = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_top_right
+static int tolua_get_CEGUI__ColourRect_top_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_right'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_top_right,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_top_right
+static int tolua_set_CEGUI__ColourRect_top_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_right'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top_right = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_bottom_left
+static int tolua_get_CEGUI__ColourRect_bottom_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_left'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_bottom_left,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_bottom_left
+static int tolua_set_CEGUI__ColourRect_bottom_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_left'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom_left = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_bottom_right
+static int tolua_get_CEGUI__ColourRect_bottom_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_right'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_bottom_right,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_bottom_right
+static int tolua_set_CEGUI__ColourRect_bottom_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_right'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom_right = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlpha'",NULL);
+#endif
+ {
+  self->setAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTopAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setTopAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setTopAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTopAlpha'",NULL);
+#endif
+ {
+  self->setTopAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTopAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBottomAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setBottomAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setBottomAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBottomAlpha'",NULL);
+#endif
+ {
+  self->setBottomAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBottomAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setLeftAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setLeftAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setLeftAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setLeftAlpha'",NULL);
+#endif
+ {
+  self->setLeftAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setLeftAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRightAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setRightAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setRightAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRightAlpha'",NULL);
+#endif
+ {
+  self->setRightAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRightAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: modulateAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_modulateAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_modulateAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'modulateAlpha'",NULL);
+#endif
+ {
+  self->modulateAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'modulateAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColours of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setColours00
+static int tolua_CEGUI_CEGUI_ColourRect_setColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* col = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColours'",NULL);
+#endif
+ {
+  self->setColours(*col);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMonochromatic of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_isMonochromatic00
+static int tolua_CEGUI_CEGUI_ColourRect_isMonochromatic00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* self = (const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMonochromatic'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMonochromatic();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMonochromatic'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSubRectangle of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_getSubRectangle00
+static int tolua_CEGUI_CEGUI_ColourRect_getSubRectangle00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* self = (const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float left = ((float)  tolua_tonumber(tolua_S,2,0));
+  float right = ((float)  tolua_tonumber(tolua_S,3,0));
+  float top = ((float)  tolua_tonumber(tolua_S,4,0));
+  float bottom = ((float)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSubRectangle'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getSubRectangle(left,right,top,bottom);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSubRectangle'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColourAtPoint of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_getColourAtPoint00
+static int tolua_CEGUI_CEGUI_ColourRect_getColourAtPoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* self = (const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColourAtPoint'",NULL);
+#endif
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  self->getColourAtPoint(x,y);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColourAtPoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new00
+static int tolua_CEGUI_CEGUI_ColourRect_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new00_local
+static int tolua_CEGUI_CEGUI_ColourRect_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new01
+static int tolua_CEGUI_CEGUI_ColourRect_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* col = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*col);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new01_local
+static int tolua_CEGUI_CEGUI_ColourRect_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* col = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*col);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new02
+static int tolua_CEGUI_CEGUI_ColourRect_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* top_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::colour* top_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::colour* bottom_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::colour* bottom_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*top_left,*top_right,*bottom_left,*bottom_right);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new02_local
+static int tolua_CEGUI_CEGUI_ColourRect_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* top_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::colour* top_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::colour* bottom_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::colour* bottom_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*top_left,*top_right,*bottom_left,*bottom_right);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: npos of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__String_unsigned_npos
+static int tolua_get_CEGUI__String_unsigned_npos(lua_State* tolua_S)
+{
+ tolua_pushnumber(tolua_S,(lua_Number)CEGUI::String::npos);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: size of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_size00
+static int tolua_CEGUI_CEGUI_String_size00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'size'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->size();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'size'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: length of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_length00
+static int tolua_CEGUI_CEGUI_String_length00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'length'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->length();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'length'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: empty of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_empty00
+static int tolua_CEGUI_CEGUI_String_empty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'empty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->empty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'empty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: capacity of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_capacity00
+static int tolua_CEGUI_CEGUI_String_capacity00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'capacity'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->capacity();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'capacity'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator&[] of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String__seti00
+static int tolua_CEGUI_CEGUI_String__seti00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long i = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long tolua_value = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator&[]'",NULL);
+#endif
+ self->operator[](i) =  tolua_value;
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.seti'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator[] of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String__geti00
+static int tolua_CEGUI_CEGUI_String__geti00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long i = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator[]'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->operator[](i);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.geti'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: at of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_at00
+static int tolua_CEGUI_CEGUI_String_at00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long i = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'at'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->at(i);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'at'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: c_str of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_c_str00
+static int tolua_CEGUI_CEGUI_String_c_str00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'c_str'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->c_str();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'c_str'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: reserve of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_reserve00
+static int tolua_CEGUI_CEGUI_String_reserve00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'reserve'",NULL);
+#endif
+ {
+  self->reserve(num);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'reserve'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resize of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_resize00
+static int tolua_CEGUI_CEGUI_String_resize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resize'",NULL);
+#endif
+ {
+  self->resize(num);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resize of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_resize01
+static int tolua_CEGUI_CEGUI_String_resize01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resize'",NULL);
+#endif
+ {
+  self->resize(num,codepoint);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_resize00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clear of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_clear00
+static int tolua_CEGUI_CEGUI_String_clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clear'",NULL);
+#endif
+ {
+  self->clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: erase of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_erase00
+static int tolua_CEGUI_CEGUI_String_erase00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'erase'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->erase();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'erase'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: erase of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_erase01
+static int tolua_CEGUI_CEGUI_String_erase01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long len = ((unsigned long)  tolua_tonumber(tolua_S,3,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'erase'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->erase(idx,len);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_erase00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: replace of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_replace00
+static int tolua_CEGUI_CEGUI_String_replace00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long begin = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long len = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'replace'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->replace(begin,len,*s);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'replace'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: swap of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_swap00
+static int tolua_CEGUI_CEGUI_String_swap00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::String* s = ((CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'swap'",NULL);
+#endif
+ {
+  self->swap(*s);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'swap'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insert of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_insert00
+static int tolua_CEGUI_CEGUI_String_insert00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insert'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->insert(pos,*s);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insert'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: find of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_find00
+static int tolua_CEGUI_CEGUI_String_find00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'find'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->find(codepoint,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'find'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rfind of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_rfind00
+static int tolua_CEGUI_CEGUI_String_rfind00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,-1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'rfind'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->rfind(codepoint,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'rfind'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: find of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_find01
+static int tolua_CEGUI_CEGUI_String_find01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::String* sub = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'find'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->find(*sub,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_find00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rfind of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_rfind01
+static int tolua_CEGUI_CEGUI_String_rfind01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::String* sub = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,-1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'rfind'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->rfind(*sub,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_rfind00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: substr of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_substr00
+static int tolua_CEGUI_CEGUI_String_substr00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long len = ((unsigned long)  tolua_tonumber(tolua_S,3,-1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'substr'",NULL);
+#endif
+ {
+  CEGUI::String tolua_ret = (CEGUI::String)  self->substr(idx,len);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::String(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::String));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'substr'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: push_back of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_push_back00
+static int tolua_CEGUI_CEGUI_String_push_back00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'push_back'",NULL);
+#endif
+ {
+  self->push_back(codepoint);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'push_back'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new00
+static int tolua_CEGUI_CEGUI_String_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new00_local
+static int tolua_CEGUI_CEGUI_String_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new01
+static int tolua_CEGUI_CEGUI_String_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(num,codepoint);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new01_local
+static int tolua_CEGUI_CEGUI_String_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(num,codepoint);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new02
+static int tolua_CEGUI_CEGUI_String_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string s = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(s);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new02_local
+static int tolua_CEGUI_CEGUI_String_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string s = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(s);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new03
+static int tolua_CEGUI_CEGUI_String_new03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(*s);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new03_local
+static int tolua_CEGUI_CEGUI_String_new03_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(*s);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new02_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_scale of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UDim_scale
+static int tolua_get_CEGUI__UDim_scale(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_scale'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_scale);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_scale of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UDim_scale
+static int tolua_set_CEGUI__UDim_scale(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_scale'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_scale = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_offset of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UDim_offset
+static int tolua_get_CEGUI__UDim_offset(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_offset'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_offset);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_offset of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UDim_offset
+static int tolua_set_CEGUI__UDim_offset(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_offset'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_offset = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asAbsolute of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_asAbsolute00
+static int tolua_CEGUI_CEGUI_UDim_asAbsolute00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  float base = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asAbsolute'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->asAbsolute(base);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asAbsolute'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asRelative of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_asRelative00
+static int tolua_CEGUI_CEGUI_UDim_asRelative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  float base = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asRelative'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->asRelative(base);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asRelative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__add00
+static int tolua_CEGUI_CEGUI_UDim__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator+(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__sub00
+static int tolua_CEGUI_CEGUI_UDim__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator-(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator/ of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__div00
+static int tolua_CEGUI_CEGUI_UDim__div00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator/(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__mul00
+static int tolua_CEGUI_CEGUI_UDim__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator*(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__eq00
+static int tolua_CEGUI_CEGUI_UDim__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*other);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new00
+static int tolua_CEGUI_CEGUI_UDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new00_local
+static int tolua_CEGUI_CEGUI_UDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new01
+static int tolua_CEGUI_CEGUI_UDim_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float scale = ((float)  tolua_tonumber(tolua_S,2,0));
+  float offset = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim(scale,offset);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UDim_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new01_local
+static int tolua_CEGUI_CEGUI_UDim_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float scale = ((float)  tolua_tonumber(tolua_S,2,0));
+  float offset = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim(scale,offset);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UDim_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_x of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UVector2_x
+static int tolua_get_CEGUI__UVector2_x(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_x,"CEGUI::UDim");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_x of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UVector2_x
+static int tolua_set_CEGUI__UVector2_x(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_x = *((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_y of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UVector2_y
+static int tolua_get_CEGUI__UVector2_y(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_y,"CEGUI::UDim");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_y of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UVector2_y
+static int tolua_set_CEGUI__UVector2_y(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_y = *((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asAbsolute of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_asAbsolute00
+static int tolua_CEGUI_CEGUI_UVector2_asAbsolute00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asAbsolute'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->asAbsolute(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asAbsolute'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asRelative of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_asRelative00
+static int tolua_CEGUI_CEGUI_UVector2_asRelative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asRelative'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->asRelative(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asRelative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__add00
+static int tolua_CEGUI_CEGUI_UVector2__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator+(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__sub00
+static int tolua_CEGUI_CEGUI_UVector2__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator-(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator/ of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__div00
+static int tolua_CEGUI_CEGUI_UVector2__div00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator/(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__mul00
+static int tolua_CEGUI_CEGUI_UVector2__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator*(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__eq00
+static int tolua_CEGUI_CEGUI_UVector2__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*other);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new00
+static int tolua_CEGUI_CEGUI_UVector2_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new00_local
+static int tolua_CEGUI_CEGUI_UVector2_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new01
+static int tolua_CEGUI_CEGUI_UVector2_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::UDim* scale = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::UDim* offset = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2(*scale,*offset);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UVector2_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new01_local
+static int tolua_CEGUI_CEGUI_UVector2_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::UDim* scale = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::UDim* offset = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2(*scale,*offset);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UVector2_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_min of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__URect_min
+static int tolua_get_CEGUI__URect_min(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_min'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_min,"CEGUI::UVector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_min of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__URect_min
+static int tolua_set_CEGUI__URect_min(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_min'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UVector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_min = *((CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_max of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__URect_max
+static int tolua_get_CEGUI__URect_max(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_max'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_max,"CEGUI::UVector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_max of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__URect_max
+static int tolua_set_CEGUI__URect_max(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_max'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UVector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_max = *((CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asAbsolute of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_asAbsolute00
+static int tolua_CEGUI_CEGUI_URect_asAbsolute00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asAbsolute'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->asAbsolute(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asAbsolute'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asRelative of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_asRelative00
+static int tolua_CEGUI_CEGUI_URect_asRelative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asRelative'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->asRelative(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asRelative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getPosition00
+static int tolua_CEGUI_CEGUI_URect_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getSize00
+static int tolua_CEGUI_CEGUI_URect_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getWidth00
+static int tolua_CEGUI_CEGUI_URect_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getWidth();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getHeight00
+static int tolua_CEGUI_CEGUI_URect_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getHeight();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setPosition00
+static int tolua_CEGUI_CEGUI_URect_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* pos = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSize of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setSize00
+static int tolua_CEGUI_CEGUI_URect_setSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* sz = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSize'",NULL);
+#endif
+ {
+  self->setSize(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidth of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setWidth00
+static int tolua_CEGUI_CEGUI_URect_setWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* w = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidth'",NULL);
+#endif
+ {
+  self->setWidth(*w);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHeight of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setHeight00
+static int tolua_CEGUI_CEGUI_URect_setHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* h = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHeight'",NULL);
+#endif
+ {
+  self->setHeight(*h);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offset of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_offset00
+static int tolua_CEGUI_CEGUI_URect_offset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* sz = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offset'",NULL);
+#endif
+ {
+  self->offset(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new00
+static int tolua_CEGUI_CEGUI_URect_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new00_local
+static int tolua_CEGUI_CEGUI_URect_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new01
+static int tolua_CEGUI_CEGUI_URect_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UVector2* min = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* max = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*min,*max);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new01_local
+static int tolua_CEGUI_CEGUI_URect_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UVector2* min = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* max = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*min,*max);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new02
+static int tolua_CEGUI_CEGUI_URect_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UDim* left = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* top = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::UDim* right = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::UDim* bottom = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*left,*top,*right,*bottom);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new02_local
+static int tolua_CEGUI_CEGUI_URect_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UDim* left = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* top = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::UDim* right = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::UDim* bottom = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*left,*top,*right,*bottom);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_getSingleton00
+static int tolua_CEGUI_CEGUI_Logger_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Logger",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Logger& tolua_ret = (CEGUI::Logger&)  CEGUI::Logger::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Logger");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setLoggingLevel of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_setLoggingLevel00
+static int tolua_CEGUI_CEGUI_Logger_setLoggingLevel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Logger",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Logger* self = (CEGUI::Logger*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::LoggingLevel level = ((CEGUI::LoggingLevel) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setLoggingLevel'",NULL);
+#endif
+ {
+  self->setLoggingLevel(level);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setLoggingLevel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLoggingLevel of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_getLoggingLevel00
+static int tolua_CEGUI_CEGUI_Logger_getLoggingLevel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Logger",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Logger* self = (const CEGUI::Logger*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLoggingLevel'",NULL);
+#endif
+ {
+  CEGUI::LoggingLevel tolua_ret = (CEGUI::LoggingLevel)  self->getLoggingLevel();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLoggingLevel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: logEvent of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_logEvent00
+static int tolua_CEGUI_CEGUI_Logger_logEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Logger",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Logger* self = (CEGUI::Logger*)  tolua_tousertype(tolua_S,1,0);
+  string message = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::LoggingLevel level = ((CEGUI::LoggingLevel) (int)  tolua_tonumber(tolua_S,3,CEGUI::Standard));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'logEvent'",NULL);
+#endif
+ {
+  self->logEvent(message,level);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'logEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setProperty of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_setProperty00
+static int tolua_CEGUI_CEGUI_Font_setProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setProperty'",NULL);
+#endif
+ {
+  self->setProperty(name,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getProperty of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getProperty00
+static int tolua_CEGUI_CEGUI_Font_getProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getProperty'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getProperty(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyDefault of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getPropertyDefault00
+static int tolua_CEGUI_CEGUI_Font_getPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyDefault'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyDefault(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyHelp of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getPropertyHelp00
+static int tolua_CEGUI_CEGUI_Font_getPropertyHelp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyHelp'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyHelp(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyHelp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyPresent of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_isPropertyPresent00
+static int tolua_CEGUI_CEGUI_Font_isPropertyPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyDefault of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_isPropertyDefault00
+static int tolua_CEGUI_CEGUI_Font_isPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyDefault'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyDefault(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getPropertyIterator of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getPropertyIterator00
+static int tolua_CEGUI_CEGUI_Font_getPropertyIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getPropertyIterator'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator tolua_ret = (CEGUI::PropertyIterator)  ceguiLua_getPropertyIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::PropertyIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::PropertyIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Font_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Font::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Font_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::Font::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: load of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_load00
+static int tolua_CEGUI_CEGUI_Font_load00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'load'",NULL);
+#endif
+ {
+  self->load();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'load'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCodepointAvailable of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_isCodepointAvailable00
+static int tolua_CEGUI_CEGUI_Font_isCodepointAvailable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long cp = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCodepointAvailable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCodepointAvailable(cp);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCodepointAvailable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNativeResolution of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_setNativeResolution00
+static int tolua_CEGUI_CEGUI_Font_setNativeResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNativeResolution'",NULL);
+#endif
+ {
+  self->setNativeResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNativeResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_Font_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextExtent of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getTextExtent00
+static int tolua_CEGUI_CEGUI_Font_getTextExtent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,3,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextExtent'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTextExtent(text,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextExtent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLineSpacing of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getLineSpacing00
+static int tolua_CEGUI_CEGUI_Font_getLineSpacing00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  float yscale = ((float)  tolua_tonumber(tolua_S,2,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLineSpacing'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getLineSpacing(yscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLineSpacing'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFontHeight of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getFontHeight00
+static int tolua_CEGUI_CEGUI_Font_getFontHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  float yscale = ((float)  tolua_tonumber(tolua_S,2,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFontHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFontHeight(yscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFontHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCharAtPixel of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getCharAtPixel00
+static int tolua_CEGUI_CEGUI_Font_getCharAtPixel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned long start_char = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+  float pixel = ((float)  tolua_tonumber(tolua_S,4,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCharAtPixel'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCharAtPixel(text,start_char,pixel,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCharAtPixel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCharAtPixel of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getCharAtPixel01
+static int tolua_CEGUI_CEGUI_Font_getCharAtPixel01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  float pixel = ((float)  tolua_tonumber(tolua_S,3,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,4,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCharAtPixel'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCharAtPixel(text,pixel,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Font_getCharAtPixel00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFormattedLineCount of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getFormattedLineCount00
+static int tolua_CEGUI_CEGUI_Font_getFormattedLineCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Rect* format_area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::TextFormatting fmt = ((CEGUI::TextFormatting) (int)  tolua_tonumber(tolua_S,4,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFormattedLineCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getFormattedLineCount(text,*format_area,fmt,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFormattedLineCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFormattedTextExtent of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getFormattedTextExtent00
+static int tolua_CEGUI_CEGUI_Font_getFormattedTextExtent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Rect* format_area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::TextFormatting fmt = ((CEGUI::TextFormatting) (int)  tolua_tonumber(tolua_S,4,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFormattedTextExtent'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFormattedTextExtent(text,*format_area,fmt,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFormattedTextExtent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_getSingleton00
+static int tolua_CEGUI_CEGUI_FontManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FontManager& tolua_ret = (CEGUI::FontManager&)  CEGUI::FontManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FontManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_createFont00
+static int tolua_CEGUI_CEGUI_FontManager_createFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string name = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string fontname = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,5,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createFont'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->createFont(type,name,fontname,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+catch(CEGUI::AlreadyExistsException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::AlreadyExistsException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_createFont01
+static int tolua_CEGUI_CEGUI_FontManager_createFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createFont'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->createFont(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+catch(CEGUI::AlreadyExistsException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::AlreadyExistsException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FontManager_createFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_destroyFont00
+static int tolua_CEGUI_CEGUI_FontManager_destroyFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyFont'",NULL);
+#endif
+ {
+  self->destroyFont(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_destroyFont01
+static int tolua_CEGUI_CEGUI_FontManager_destroyFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyFont'",NULL);
+#endif
+ {
+  self->destroyFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FontManager_destroyFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllFonts of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_destroyAllFonts00
+static int tolua_CEGUI_CEGUI_FontManager_destroyAllFonts00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllFonts'",NULL);
+#endif
+ {
+  self->destroyAllFonts();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllFonts'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFontPresent of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_isFontPresent00
+static int tolua_CEGUI_CEGUI_FontManager_isFontPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontManager* self = (const CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFontPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFontPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFontPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_getFont00
+static int tolua_CEGUI_CEGUI_FontManager_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontManager* self = (const CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getFont(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_FontManager_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_getIterator00
+static int tolua_CEGUI_CEGUI_FontManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontManager* self = (const CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::FontIterator tolua_ret = (CEGUI::FontIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::FontIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FontIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::FontIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FontIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getSize00
+static int tolua_CEGUI_CEGUI_Image_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getWidth00
+static int tolua_CEGUI_CEGUI_Image_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getHeight00
+static int tolua_CEGUI_CEGUI_Image_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOffsets of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getOffsets00
+static int tolua_CEGUI_CEGUI_Image_getOffsets00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOffsets'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getOffsets();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOffsets'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOffsetX of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getOffsetX00
+static int tolua_CEGUI_CEGUI_Image_getOffsetX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOffsetX'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getOffsetX();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOffsetX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOffsetY of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getOffsetY00
+static int tolua_CEGUI_CEGUI_Image_getOffsetY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOffsetY'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getOffsetY();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOffsetY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getName00
+static int tolua_CEGUI_CEGUI_Image_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImagesetName of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getImagesetName00
+static int tolua_CEGUI_CEGUI_Image_getImagesetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImagesetName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getImagesetName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImagesetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSourceTextureArea of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getSourceTextureArea00
+static int tolua_CEGUI_CEGUI_Image_getSourceTextureArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSourceTextureArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getSourceTextureArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSourceTextureArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_getWidth00
+static int tolua_CEGUI_CEGUI_Texture_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Texture* self = (const CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  unsigned short tolua_ret = (unsigned short)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_getHeight00
+static int tolua_CEGUI_CEGUI_Texture_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Texture* self = (const CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  unsigned short tolua_ret = (unsigned short)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadFromFile of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_loadFromFile00
+static int tolua_CEGUI_CEGUI_Texture_loadFromFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Texture",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Texture* self = (CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadFromFile'",NULL);
+#endif
+ {
+  self->loadFromFile(filename,resourcegroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadFromFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRenderer of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_getRenderer00
+static int tolua_CEGUI_CEGUI_Texture_getRenderer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Texture* self = (const CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRenderer'",NULL);
+#endif
+ {
+  CEGUI::Renderer* tolua_ret = (CEGUI::Renderer*)  self->getRenderer();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Renderer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRenderer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTexture of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getTexture00
+static int tolua_CEGUI_CEGUI_Imageset_getTexture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->getTexture();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTexture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getName00
+static int tolua_CEGUI_CEGUI_Imageset_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageCount of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageCount00
+static int tolua_CEGUI_CEGUI_Imageset_getImageCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getImageCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isImageDefined of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_isImageDefined00
+static int tolua_CEGUI_CEGUI_Imageset_isImageDefined00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isImageDefined'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isImageDefined(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isImageDefined'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImage00
+static int tolua_CEGUI_CEGUI_Imageset_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image& tolua_ret = (const CEGUI::Image&)  self->getImage(name);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: undefineImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_undefineImage00
+static int tolua_CEGUI_CEGUI_Imageset_undefineImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'undefineImage'",NULL);
+#endif
+ {
+  self->undefineImage(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'undefineImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: undefineAllImages of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_undefineAllImages00
+static int tolua_CEGUI_CEGUI_Imageset_undefineAllImages00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'undefineAllImages'",NULL);
+#endif
+ {
+  self->undefineAllImages();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'undefineAllImages'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageSize of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageSize00
+static int tolua_CEGUI_CEGUI_Imageset_getImageSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getImageSize(name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageWidth of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageWidth00
+static int tolua_CEGUI_CEGUI_Imageset_getImageWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageWidth(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageHeight of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageHeight00
+static int tolua_CEGUI_CEGUI_Imageset_getImageHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageHeight(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageOffset of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageOffset00
+static int tolua_CEGUI_CEGUI_Imageset_getImageOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageOffset'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getImageOffset(name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageOffsetX of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageOffsetX00
+static int tolua_CEGUI_CEGUI_Imageset_getImageOffsetX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageOffsetX'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageOffsetX(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageOffsetX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageOffsetY of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageOffsetY00
+static int tolua_CEGUI_CEGUI_Imageset_getImageOffsetY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageOffsetY'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageOffsetY(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageOffsetY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: defineImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_defineImage00
+static int tolua_CEGUI_CEGUI_Imageset_defineImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::Size* size = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Vector2* render_offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'defineImage'",NULL);
+#endif
+ {
+  self->defineImage(name,*pos,*size,*render_offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'defineImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: defineImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_defineImage01
+static int tolua_CEGUI_CEGUI_Imageset_defineImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::Vector2* render_offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'defineImage'",NULL);
+#endif
+ {
+  self->defineImage(name,*rect,*render_offset);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Imageset_defineImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoScaled of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_isAutoScaled00
+static int tolua_CEGUI_CEGUI_Imageset_isAutoScaled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoScaled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoScaled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoScaled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoScalingEnabled of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_setAutoScalingEnabled00
+static int tolua_CEGUI_CEGUI_Imageset_setAutoScalingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoScalingEnabled'",NULL);
+#endif
+ {
+  self->setAutoScalingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoScalingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNativeResolution of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getNativeResolution00
+static int tolua_CEGUI_CEGUI_Imageset_getNativeResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNativeResolution'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getNativeResolution();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNativeResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNativeResolution of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_setNativeResolution00
+static int tolua_CEGUI_CEGUI_Imageset_setNativeResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNativeResolution'",NULL);
+#endif
+ {
+  self->setNativeResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNativeResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_Imageset_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getIterator00
+static int tolua_CEGUI_CEGUI_Imageset_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::ImageIterator tolua_ret = (CEGUI::ImageIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ImageIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImageIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ImageIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImageIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Imageset_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Imageset::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Imageset_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::Imageset::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_getSingleton00
+static int tolua_CEGUI_CEGUI_ImagesetManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImagesetManager& tolua_ret = (CEGUI::ImagesetManager&)  CEGUI::ImagesetManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagesetManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_createImageset00
+static int tolua_CEGUI_CEGUI_ImagesetManager_createImageset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::Texture* texture = ((CEGUI::Texture*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createImageset'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->createImageset(name,texture);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'createImageset'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createImageset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_createImageset01
+static int tolua_CEGUI_CEGUI_ImagesetManager_createImageset01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createImageset'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->createImageset(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'createImageset'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagesetManager_createImageset00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createImagesetFromImageFile of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_createImagesetFromImageFile00
+static int tolua_CEGUI_CEGUI_ImagesetManager_createImagesetFromImageFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string filename = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createImagesetFromImageFile'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->createImagesetFromImageFile(name,filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'createImagesetFromImageFile'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createImagesetFromImageFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00
+static int tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Imageset* imageset = ((CEGUI::Imageset*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyImageset'",NULL);
+#endif
+ {
+  self->destroyImageset(imageset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyImageset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset01
+static int tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyImageset'",NULL);
+#endif
+ {
+  self->destroyImageset(name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllImagesets of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_destroyAllImagesets00
+static int tolua_CEGUI_CEGUI_ImagesetManager_destroyAllImagesets00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllImagesets'",NULL);
+#endif
+ {
+  self->destroyAllImagesets();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllImagesets'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_getImageset00
+static int tolua_CEGUI_CEGUI_ImagesetManager_getImageset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetManager* self = (const CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageset'",NULL);
+#endif
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->getImageset(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception&e)
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isImagesetPresent of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_isImagesetPresent00
+static int tolua_CEGUI_CEGUI_ImagesetManager_isImagesetPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetManager* self = (const CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isImagesetPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isImagesetPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isImagesetPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_ImagesetManager_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* size = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_getIterator00
+static int tolua_CEGUI_CEGUI_ImagesetManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetManager* self = (const CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::ImagesetIterator tolua_ret = (CEGUI::ImagesetIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ImagesetIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImagesetIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ImagesetIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImagesetIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHelp of class  CEGUI::Property */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Property_getHelp00
+static int tolua_CEGUI_CEGUI_Property_getHelp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Property",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Property* self = (const CEGUI::Property*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHelp'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getHelp();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHelp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Property */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Property_getName00
+static int tolua_CEGUI_CEGUI_Property_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Property",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Property* self = (const CEGUI::Property*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_key00
+static int tolua_CEGUI_CEGUI_PropertyIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_value00
+static int tolua_CEGUI_CEGUI_PropertyIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Property* tolua_ret = (CEGUI::Property*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Property");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_PropertyIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_PropertyIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_next00
+static int tolua_CEGUI_CEGUI_PropertyIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator& tolua_ret = (CEGUI::PropertyIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_previous00
+static int tolua_CEGUI_CEGUI_PropertyIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator& tolua_ret = (CEGUI::PropertyIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator__eq00
+static int tolua_CEGUI_CEGUI_PropertyIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyIterator* rhs = ((const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_toStart00
+static int tolua_CEGUI_CEGUI_PropertyIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_toEnd00
+static int tolua_CEGUI_CEGUI_PropertyIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_new00
+static int tolua_CEGUI_CEGUI_PropertyIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* org = ((const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::PropertyIterator* tolua_ret = (CEGUI::PropertyIterator*)  new CEGUI::PropertyIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_new00_local
+static int tolua_CEGUI_CEGUI_PropertyIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* org = ((const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::PropertyIterator* tolua_ret = (CEGUI::PropertyIterator*)  new CEGUI::PropertyIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_key00
+static int tolua_CEGUI_CEGUI_EventIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_value00
+static int tolua_CEGUI_CEGUI_EventIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Event* tolua_ret = (CEGUI::Event*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Event");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_EventIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_EventIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_next00
+static int tolua_CEGUI_CEGUI_EventIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::EventIterator& tolua_ret = (CEGUI::EventIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_previous00
+static int tolua_CEGUI_CEGUI_EventIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::EventIterator& tolua_ret = (CEGUI::EventIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator__eq00
+static int tolua_CEGUI_CEGUI_EventIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::EventIterator* rhs = ((const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_toStart00
+static int tolua_CEGUI_CEGUI_EventIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_toEnd00
+static int tolua_CEGUI_CEGUI_EventIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_new00
+static int tolua_CEGUI_CEGUI_EventIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* org = ((const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::EventIterator* tolua_ret = (CEGUI::EventIterator*)  new CEGUI::EventIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_new00_local
+static int tolua_CEGUI_CEGUI_EventIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* org = ((const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::EventIterator* tolua_ret = (CEGUI::EventIterator*)  new CEGUI::EventIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_key00
+static int tolua_CEGUI_CEGUI_WindowIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_value00
+static int tolua_CEGUI_CEGUI_WindowIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_WindowIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_WindowIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_next00
+static int tolua_CEGUI_CEGUI_WindowIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::WindowIterator& tolua_ret = (CEGUI::WindowIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_previous00
+static int tolua_CEGUI_CEGUI_WindowIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::WindowIterator& tolua_ret = (CEGUI::WindowIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator__eq00
+static int tolua_CEGUI_CEGUI_WindowIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::WindowIterator* rhs = ((const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_toStart00
+static int tolua_CEGUI_CEGUI_WindowIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_toEnd00
+static int tolua_CEGUI_CEGUI_WindowIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_new00
+static int tolua_CEGUI_CEGUI_WindowIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* org = ((const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowIterator* tolua_ret = (CEGUI::WindowIterator*)  new CEGUI::WindowIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_new00_local
+static int tolua_CEGUI_CEGUI_WindowIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* org = ((const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowIterator* tolua_ret = (CEGUI::WindowIterator*)  new CEGUI::WindowIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_key00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_value00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::WindowFactory* tolua_ret = (CEGUI::WindowFactory*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowFactory");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_next00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::WindowFactoryIterator& tolua_ret = (CEGUI::WindowFactoryIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_previous00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::WindowFactoryIterator& tolua_ret = (CEGUI::WindowFactoryIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator__eq00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::WindowFactoryIterator* rhs = ((const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_toStart00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_toEnd00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_new00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* org = ((const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowFactoryIterator* tolua_ret = (CEGUI::WindowFactoryIterator*)  new CEGUI::WindowFactoryIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* org = ((const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowFactoryIterator* tolua_ret = (CEGUI::WindowFactoryIterator*)  new CEGUI::WindowFactoryIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_key00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_value00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::FalagardWindowMapping tolua_ret = (CEGUI::FalagardWindowMapping)  self->getCurrentValue();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::FalagardWindowMapping(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardWindowMapping");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::FalagardWindowMapping));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardWindowMapping");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_next00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::FalagardMappingIterator& tolua_ret = (CEGUI::FalagardMappingIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_previous00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::FalagardMappingIterator& tolua_ret = (CEGUI::FalagardMappingIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator__eq00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::FalagardMappingIterator* rhs = ((const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_toStart00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_toEnd00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_new00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* org = ((const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FalagardMappingIterator* tolua_ret = (CEGUI::FalagardMappingIterator*)  new CEGUI::FalagardMappingIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* org = ((const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FalagardMappingIterator* tolua_ret = (CEGUI::FalagardMappingIterator*)  new CEGUI::FalagardMappingIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_key00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_value00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_next00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::ImagesetIterator& tolua_ret = (CEGUI::ImagesetIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_previous00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::ImagesetIterator& tolua_ret = (CEGUI::ImagesetIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator__eq00
+static int tolua_CEGUI_CEGUI_ImagesetIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImagesetIterator* rhs = ((const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_toStart00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_toEnd00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_new00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* org = ((const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImagesetIterator* tolua_ret = (CEGUI::ImagesetIterator*)  new CEGUI::ImagesetIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_new00_local
+static int tolua_CEGUI_CEGUI_ImagesetIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* org = ((const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImagesetIterator* tolua_ret = (CEGUI::ImagesetIterator*)  new CEGUI::ImagesetIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_key00
+static int tolua_CEGUI_CEGUI_ImageIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_value00
+static int tolua_CEGUI_CEGUI_ImageIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Image tolua_ret = (CEGUI::Image)  self->getCurrentValue();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Image(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Image");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Image));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Image");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_ImageIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_ImageIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_next00
+static int tolua_CEGUI_CEGUI_ImageIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::ImageIterator& tolua_ret = (CEGUI::ImageIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_previous00
+static int tolua_CEGUI_CEGUI_ImageIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::ImageIterator& tolua_ret = (CEGUI::ImageIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator__eq00
+static int tolua_CEGUI_CEGUI_ImageIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImageIterator* rhs = ((const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_toStart00
+static int tolua_CEGUI_CEGUI_ImageIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_toEnd00
+static int tolua_CEGUI_CEGUI_ImageIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_new00
+static int tolua_CEGUI_CEGUI_ImageIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* org = ((const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImageIterator* tolua_ret = (CEGUI::ImageIterator*)  new CEGUI::ImageIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_new00_local
+static int tolua_CEGUI_CEGUI_ImageIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* org = ((const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImageIterator* tolua_ret = (CEGUI::ImageIterator*)  new CEGUI::ImageIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_key00
+static int tolua_CEGUI_CEGUI_SchemeIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_value00
+static int tolua_CEGUI_CEGUI_SchemeIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Scheme* tolua_ret = (CEGUI::Scheme*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scheme");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_SchemeIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_SchemeIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_next00
+static int tolua_CEGUI_CEGUI_SchemeIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::SchemeIterator& tolua_ret = (CEGUI::SchemeIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_previous00
+static int tolua_CEGUI_CEGUI_SchemeIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::SchemeIterator& tolua_ret = (CEGUI::SchemeIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator__eq00
+static int tolua_CEGUI_CEGUI_SchemeIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::SchemeIterator* rhs = ((const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_toStart00
+static int tolua_CEGUI_CEGUI_SchemeIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_toEnd00
+static int tolua_CEGUI_CEGUI_SchemeIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_new00
+static int tolua_CEGUI_CEGUI_SchemeIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* org = ((const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::SchemeIterator* tolua_ret = (CEGUI::SchemeIterator*)  new CEGUI::SchemeIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_new00_local
+static int tolua_CEGUI_CEGUI_SchemeIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* org = ((const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::SchemeIterator* tolua_ret = (CEGUI::SchemeIterator*)  new CEGUI::SchemeIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_key00
+static int tolua_CEGUI_CEGUI_FontIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_value00
+static int tolua_CEGUI_CEGUI_FontIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_FontIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_FontIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_next00
+static int tolua_CEGUI_CEGUI_FontIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::FontIterator& tolua_ret = (CEGUI::FontIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_previous00
+static int tolua_CEGUI_CEGUI_FontIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::FontIterator& tolua_ret = (CEGUI::FontIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator__eq00
+static int tolua_CEGUI_CEGUI_FontIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::FontIterator* rhs = ((const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_toStart00
+static int tolua_CEGUI_CEGUI_FontIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_toEnd00
+static int tolua_CEGUI_CEGUI_FontIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_new00
+static int tolua_CEGUI_CEGUI_FontIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* org = ((const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FontIterator* tolua_ret = (CEGUI::FontIterator*)  new CEGUI::FontIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_new00_local
+static int tolua_CEGUI_CEGUI_FontIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* org = ((const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FontIterator* tolua_ret = (CEGUI::FontIterator*)  new CEGUI::FontIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: handled of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__EventArgs_handled
+static int tolua_get_CEGUI__EventArgs_handled(lua_State* tolua_S)
+{
+  CEGUI::EventArgs* self = (CEGUI::EventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'handled'",NULL);
+#endif
+ tolua_pushboolean(tolua_S,(bool)self->handled);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: handled of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__EventArgs_handled
+static int tolua_set_CEGUI__EventArgs_handled(lua_State* tolua_S)
+{
+  CEGUI::EventArgs* self = (CEGUI::EventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'handled'",NULL);
+ if (!tolua_isboolean(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->handled = ((bool)  tolua_toboolean(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventArgs_new00
+static int tolua_CEGUI_CEGUI_EventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::EventArgs* tolua_ret = (CEGUI::EventArgs*)  new CEGUI::EventArgs();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::EventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventArgs_new00_local
+static int tolua_CEGUI_CEGUI_EventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::EventArgs* tolua_ret = (CEGUI::EventArgs*)  new CEGUI::EventArgs();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::EventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: mouseCursor of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseCursorEventArgs_mouseCursor_ptr
+static int tolua_get_CEGUI__MouseCursorEventArgs_mouseCursor_ptr(lua_State* tolua_S)
+{
+  CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'mouseCursor'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->mouseCursor,"CEGUI::MouseCursor");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: mouseCursor of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseCursorEventArgs_mouseCursor_ptr
+static int tolua_set_CEGUI__MouseCursorEventArgs_mouseCursor_ptr(lua_State* tolua_S)
+{
+  CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'mouseCursor'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::MouseCursor",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->mouseCursor = ((CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: image of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseCursorEventArgs_image_ptr
+static int tolua_get_CEGUI__MouseCursorEventArgs_image_ptr(lua_State* tolua_S)
+{
+  CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'image'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->image,"const CEGUI::Image");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00
+static int tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseCursorEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* cursor = ((CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseCursorEventArgs* tolua_ret = (CEGUI::MouseCursorEventArgs*)  new CEGUI::MouseCursorEventArgs(cursor);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MouseCursorEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseCursorEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* cursor = ((CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseCursorEventArgs* tolua_ret = (CEGUI::MouseCursorEventArgs*)  new CEGUI::MouseCursorEventArgs(cursor);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::MouseCursorEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: window of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__WindowEventArgs_window_ptr
+static int tolua_get_CEGUI__WindowEventArgs_window_ptr(lua_State* tolua_S)
+{
+  CEGUI::WindowEventArgs* self = (CEGUI::WindowEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'window'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->window,"CEGUI::Window");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: window of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__WindowEventArgs_window_ptr
+static int tolua_set_CEGUI__WindowEventArgs_window_ptr(lua_State* tolua_S)
+{
+  CEGUI::WindowEventArgs* self = (CEGUI::WindowEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'window'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowEventArgs_new00
+static int tolua_CEGUI_CEGUI_WindowEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowEventArgs* tolua_ret = (CEGUI::WindowEventArgs*)  new CEGUI::WindowEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_WindowEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowEventArgs* tolua_ret = (CEGUI::WindowEventArgs*)  new CEGUI::WindowEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WindowEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: otherWindow of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ActivationEventArgs_otherWindow_ptr
+static int tolua_get_CEGUI__ActivationEventArgs_otherWindow_ptr(lua_State* tolua_S)
+{
+  CEGUI::ActivationEventArgs* self = (CEGUI::ActivationEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'otherWindow'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->otherWindow,"CEGUI::Window");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: otherWindow of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ActivationEventArgs_otherWindow_ptr
+static int tolua_set_CEGUI__ActivationEventArgs_otherWindow_ptr(lua_State* tolua_S)
+{
+  CEGUI::ActivationEventArgs* self = (CEGUI::ActivationEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'otherWindow'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->otherWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ActivationEventArgs_new00
+static int tolua_CEGUI_CEGUI_ActivationEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ActivationEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ActivationEventArgs* tolua_ret = (CEGUI::ActivationEventArgs*)  new CEGUI::ActivationEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ActivationEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ActivationEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ActivationEventArgs* tolua_ret = (CEGUI::ActivationEventArgs*)  new CEGUI::ActivationEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ActivationEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_oldIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx
+static int tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_oldIdx'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_oldIdx);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_oldIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx
+static int tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_oldIdx'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_oldIdx = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_newIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx
+static int tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_newIdx'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_newIdx);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_newIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx
+static int tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_newIdx'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_newIdx = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00
+static int tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::HeaderSequenceEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int old_index = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int new_index = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::HeaderSequenceEventArgs* tolua_ret = (CEGUI::HeaderSequenceEventArgs*)  new CEGUI::HeaderSequenceEventArgs(wnd,old_index,new_index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::HeaderSequenceEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::HeaderSequenceEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int old_index = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int new_index = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::HeaderSequenceEventArgs* tolua_ret = (CEGUI::HeaderSequenceEventArgs*)  new CEGUI::HeaderSequenceEventArgs(wnd,old_index,new_index);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::HeaderSequenceEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: position of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_position
+static int tolua_get_CEGUI__MouseEventArgs_position(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'position'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->position,"CEGUI::Vector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: position of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_position
+static int tolua_set_CEGUI__MouseEventArgs_position(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'position'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Vector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->position = *((CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: moveDelta of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_moveDelta
+static int tolua_get_CEGUI__MouseEventArgs_moveDelta(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'moveDelta'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->moveDelta,"CEGUI::Vector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: moveDelta of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_moveDelta
+static int tolua_set_CEGUI__MouseEventArgs_moveDelta(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'moveDelta'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Vector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->moveDelta = *((CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: button of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_button
+static int tolua_get_CEGUI__MouseEventArgs_button(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'button'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->button);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: button of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_button
+static int tolua_set_CEGUI__MouseEventArgs_button(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'button'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->button = ((CEGUI::MouseButton) (int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: sysKeys of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_unsigned_sysKeys
+static int tolua_get_CEGUI__MouseEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->sysKeys);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: sysKeys of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_unsigned_sysKeys
+static int tolua_set_CEGUI__MouseEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->sysKeys = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: wheelChange of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_wheelChange
+static int tolua_get_CEGUI__MouseEventArgs_wheelChange(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'wheelChange'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->wheelChange);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: wheelChange of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_wheelChange
+static int tolua_set_CEGUI__MouseEventArgs_wheelChange(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'wheelChange'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->wheelChange = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseEventArgs_new00
+static int tolua_CEGUI_CEGUI_MouseEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseEventArgs* tolua_ret = (CEGUI::MouseEventArgs*)  new CEGUI::MouseEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MouseEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_MouseEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseEventArgs* tolua_ret = (CEGUI::MouseEventArgs*)  new CEGUI::MouseEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::MouseEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: codepoint of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__KeyEventArgs_unsigned_codepoint
+static int tolua_get_CEGUI__KeyEventArgs_unsigned_codepoint(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'codepoint'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->codepoint);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: codepoint of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__KeyEventArgs_unsigned_codepoint
+static int tolua_set_CEGUI__KeyEventArgs_unsigned_codepoint(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'codepoint'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: scancode of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__KeyEventArgs_scancode
+static int tolua_get_CEGUI__KeyEventArgs_scancode(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'scancode'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->scancode);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: scancode of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__KeyEventArgs_scancode
+static int tolua_set_CEGUI__KeyEventArgs_scancode(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'scancode'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->scancode = ((CEGUI::Key::Scan) (int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: sysKeys of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__KeyEventArgs_unsigned_sysKeys
+static int tolua_get_CEGUI__KeyEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->sysKeys);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: sysKeys of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__KeyEventArgs_unsigned_sysKeys
+static int tolua_set_CEGUI__KeyEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->sysKeys = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_KeyEventArgs_new00
+static int tolua_CEGUI_CEGUI_KeyEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::KeyEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::KeyEventArgs* tolua_ret = (CEGUI::KeyEventArgs*)  new CEGUI::KeyEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::KeyEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_KeyEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_KeyEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::KeyEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::KeyEventArgs* tolua_ret = (CEGUI::KeyEventArgs*)  new CEGUI::KeyEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::KeyEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: dragDropItem of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__DragDropEventArgs_dragDropItem_ptr
+static int tolua_get_CEGUI__DragDropEventArgs_dragDropItem_ptr(lua_State* tolua_S)
+{
+  CEGUI::DragDropEventArgs* self = (CEGUI::DragDropEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'dragDropItem'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->dragDropItem,"CEGUI::DragContainer");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: dragDropItem of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__DragDropEventArgs_dragDropItem_ptr
+static int tolua_set_CEGUI__DragDropEventArgs_dragDropItem_ptr(lua_State* tolua_S)
+{
+  CEGUI::DragDropEventArgs* self = (CEGUI::DragDropEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'dragDropItem'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->dragDropItem = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragDropEventArgs_new00
+static int tolua_CEGUI_CEGUI_DragDropEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::DragDropEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::DragDropEventArgs* tolua_ret = (CEGUI::DragDropEventArgs*)  new CEGUI::DragDropEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::DragDropEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::DragDropEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::DragDropEventArgs* tolua_ret = (CEGUI::DragDropEventArgs*)  new CEGUI::DragDropEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::DragDropEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Event */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Event_getName00
+static int tolua_CEGUI_CEGUI_Event_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Event",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Event* self = (const CEGUI::Event*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_addEvent00
+static int tolua_CEGUI_CEGUI_EventSet_addEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addEvent'",NULL);
+#endif
+ {
+  self->addEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_removeEvent00
+static int tolua_CEGUI_CEGUI_EventSet_removeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeEvent'",NULL);
+#endif
+ {
+  self->removeEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeAllEvents of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_removeAllEvents00
+static int tolua_CEGUI_CEGUI_EventSet_removeAllEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllEvents'",NULL);
+#endif
+ {
+  self->removeAllEvents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeAllEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isEventPresent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_isEventPresent00
+static int tolua_CEGUI_CEGUI_EventSet_isEventPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEventPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isEventPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isEventPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: LuaFunctorSubscribeEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_subscribeEvent00
+static int tolua_CEGUI_CEGUI_EventSet_subscribeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  lua_Object funcIndex = ((lua_Object)  tolua_tovalue(tolua_S,3,0));
+  lua_Object selfIndex = ((lua_Object)  tolua_tovalue(tolua_S,4,LUA_NOREF));
+  lua_State* tolua_var_1 =  tolua_S;
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'LuaFunctorSubscribeEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+   CEGUI::EventConnection tolua_ret = (  CEGUI::EventConnection)  LuaFunctorSubscribeEvent(self,name,funcIndex,selfIndex,tolua_var_1);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'LuaFunctorSubscribeEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'subscribeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: subscribeScriptedEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_subscribeEvent01
+static int tolua_CEGUI_CEGUI_EventSet_subscribeEvent01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string callback_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'subscribeScriptedEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::EventConnection tolua_ret = (CEGUI::EventConnection)  self->subscribeScriptedEvent(name,callback_name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'subscribeScriptedEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_EventSet_subscribeEvent00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: fireEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_fireEvent00
+static int tolua_CEGUI_CEGUI_EventSet_fireEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::EventArgs* args = ((CEGUI::EventArgs*)  tolua_tousertype(tolua_S,3,0));
+  string eventnamespace = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fireEvent'",NULL);
+#endif
+ {
+  self->fireEvent(name,*args,eventnamespace);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'fireEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMuted of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_isMuted00
+static int tolua_CEGUI_CEGUI_EventSet_isMuted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventSet* self = (const CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMuted'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMuted();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMuted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMutedState of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_setMutedState00
+static int tolua_CEGUI_CEGUI_EventSet_setMutedState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMutedState'",NULL);
+#endif
+ {
+  self->setMutedState(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMutedState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_getEventIterator00
+static int tolua_CEGUI_CEGUI_EventSet_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventSet* self = (const CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::GlobalEventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_GlobalEventSet_getSingleton00
+static int tolua_CEGUI_CEGUI_GlobalEventSet_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::GlobalEventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::GlobalEventSet& tolua_ret = (CEGUI::GlobalEventSet&)  CEGUI::GlobalEventSet::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::GlobalEventSet");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getSingleton00
+static int tolua_CEGUI_CEGUI_MouseCursor_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::MouseCursor& tolua_ret = (CEGUI::MouseCursor&)  CEGUI::MouseCursor::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::MouseCursor");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setImage00
+static int tolua_CEGUI_CEGUI_MouseCursor_setImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setImage01
+static int tolua_CEGUI_CEGUI_MouseCursor_setImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MouseCursor_setImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getImage00
+static int tolua_CEGUI_CEGUI_MouseCursor_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offsetPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_offsetPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_offsetPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offsetPosition'",NULL);
+#endif
+ {
+  self->offsetPosition(*offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offsetPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_setConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setConstraintArea'",NULL);
+#endif
+ {
+  self->setConstraintArea(area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getPosition();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_getConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getConstraintArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getConstraintArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDisplayIndependantPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getDisplayIndependantPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_getDisplayIndependantPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDisplayIndependantPosition'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getDisplayIndependantPosition();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDisplayIndependantPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUnifiedConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setUnifiedConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_setUnifiedConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::URect* area = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUnifiedConstraintArea'",NULL);
+#endif
+ {
+  self->setUnifiedConstraintArea(area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUnifiedConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUnifiedConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getUnifiedConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_getUnifiedConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUnifiedConstraintArea'",NULL);
+#endif
+ {
+  const CEGUI::URect& tolua_ret = (const CEGUI::URect&)  self->getUnifiedConstraintArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUnifiedConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hide of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_hide00
+static int tolua_CEGUI_CEGUI_MouseCursor_hide00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hide'",NULL);
+#endif
+ {
+  self->hide();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hide'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: show of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_show00
+static int tolua_CEGUI_CEGUI_MouseCursor_show00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'show'",NULL);
+#endif
+ {
+  self->show();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'show'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVisible of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setVisible00
+static int tolua_CEGUI_CEGUI_MouseCursor_setVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  bool visible = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVisible'",NULL);
+#endif
+ {
+  self->setVisible(visible);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVisible of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_isVisible00
+static int tolua_CEGUI_CEGUI_MouseCursor_isVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVisible'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVisible();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getEventIterator00
+static int tolua_CEGUI_CEGUI_MouseCursor_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getType of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getType00
+static int tolua_CEGUI_CEGUI_Window_getType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getName00
+static int tolua_CEGUI_CEGUI_Window_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDestroyedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isDestroyedByParent00
+static int tolua_CEGUI_CEGUI_Window_isDestroyedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDestroyedByParent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDestroyedByParent();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDestroyedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAlwaysOnTop of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAlwaysOnTop00
+static int tolua_CEGUI_CEGUI_Window_isAlwaysOnTop00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAlwaysOnTop'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAlwaysOnTop();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAlwaysOnTop'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDisabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isDisabled00
+static int tolua_CEGUI_CEGUI_Window_isDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool localOnly = ((bool)  tolua_toboolean(tolua_S,2,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDisabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDisabled(localOnly);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVisible of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isVisible00
+static int tolua_CEGUI_CEGUI_Window_isVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool localOnly = ((bool)  tolua_toboolean(tolua_S,2,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVisible'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVisible(localOnly);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isActive of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isActive00
+static int tolua_CEGUI_CEGUI_Window_isActive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isActive'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isActive();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isActive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isClippedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isClippedByParent00
+static int tolua_CEGUI_CEGUI_Window_isClippedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isClippedByParent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isClippedByParent();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isClippedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDestroyedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setDestroyedByParent00
+static int tolua_CEGUI_CEGUI_Window_setDestroyedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDestroyedByParent'",NULL);
+#endif
+ {
+  self->setDestroyedByParent(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDestroyedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlwaysOnTop of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAlwaysOnTop00
+static int tolua_CEGUI_CEGUI_Window_setAlwaysOnTop00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlwaysOnTop'",NULL);
+#endif
+ {
+  self->setAlwaysOnTop(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlwaysOnTop'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setEnabled00
+static int tolua_CEGUI_CEGUI_Window_setEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setEnabled'",NULL);
+#endif
+ {
+  self->setEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: enable of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_enable00
+static int tolua_CEGUI_CEGUI_Window_enable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'enable'",NULL);
+#endif
+ {
+  self->enable();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'enable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: disable of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_disable00
+static int tolua_CEGUI_CEGUI_Window_disable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'disable'",NULL);
+#endif
+ {
+  self->disable();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'disable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVisible of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setVisible00
+static int tolua_CEGUI_CEGUI_Window_setVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVisible'",NULL);
+#endif
+ {
+  self->setVisible(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: show of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_show00
+static int tolua_CEGUI_CEGUI_Window_show00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'show'",NULL);
+#endif
+ {
+  self->show();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'show'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hide of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_hide00
+static int tolua_CEGUI_CEGUI_Window_hide00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hide'",NULL);
+#endif
+ {
+  self->hide();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hide'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: activate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_activate00
+static int tolua_CEGUI_CEGUI_Window_activate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'activate'",NULL);
+#endif
+ {
+  self->activate();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'activate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: deactivate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_deactivate00
+static int tolua_CEGUI_CEGUI_Window_deactivate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'deactivate'",NULL);
+#endif
+ {
+  self->deactivate();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'deactivate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClippedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setClippedByParent00
+static int tolua_CEGUI_CEGUI_Window_setClippedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClippedByParent'",NULL);
+#endif
+ {
+  self->setClippedByParent(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClippedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getID of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getID00
+static int tolua_CEGUI_CEGUI_Window_getID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setID of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setID00
+static int tolua_CEGUI_CEGUI_Window_setID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setID'",NULL);
+#endif
+ {
+  self->setID(ID);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildCount of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildCount00
+static int tolua_CEGUI_CEGUI_Window_getChildCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getChildCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChild00
+static int tolua_CEGUI_CEGUI_Window_isChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChild(ID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChild01
+static int tolua_CEGUI_CEGUI_Window_isChild01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChild(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isChild00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChild02
+static int tolua_CEGUI_CEGUI_Window_isChild02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChild(window);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isChild01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChildRecursive of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChildRecursive00
+static int tolua_CEGUI_CEGUI_Window_isChildRecursive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChildRecursive'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChildRecursive(ID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isChildRecursive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_addChildWindow00
+static int tolua_CEGUI_CEGUI_Window_addChildWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addChildWindow'",NULL);
+#endif
+ {
+  self->addChildWindow(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addChildWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_addChildWindow01
+static int tolua_CEGUI_CEGUI_Window_addChildWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addChildWindow'",NULL);
+#endif
+ {
+  self->addChildWindow(window);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_addChildWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeChildWindow00
+static int tolua_CEGUI_CEGUI_Window_removeChildWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeChildWindow'",NULL);
+#endif
+ {
+  self->removeChildWindow(ID);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeChildWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeChildWindow01
+static int tolua_CEGUI_CEGUI_Window_removeChildWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeChildWindow'",NULL);
+#endif
+ {
+  self->removeChildWindow(name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_removeChildWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeChildWindow02
+static int tolua_CEGUI_CEGUI_Window_removeChildWindow02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeChildWindow'",NULL);
+#endif
+ {
+  self->removeChildWindow(window);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_removeChildWindow01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChild00
+static int tolua_CEGUI_CEGUI_Window_getChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChild'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChild(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChild01
+static int tolua_CEGUI_CEGUI_Window_getChild01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChild'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChild(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ return 0;
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_getChild00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildAtIdx of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildAtIdx00
+static int tolua_CEGUI_CEGUI_Window_getChildAtIdx00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildAtIdx'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChildAtIdx(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildAtIdx'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getActiveChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getActiveChild00
+static int tolua_CEGUI_CEGUI_Window_getActiveChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getActiveChild'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getActiveChild();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getActiveChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildAtPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildAtPosition00
+static int tolua_CEGUI_CEGUI_Window_getChildAtPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildAtPosition'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChildAtPosition(*pos);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildAtPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTargetChildAtPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTargetChildAtPosition00
+static int tolua_CEGUI_CEGUI_Window_getTargetChildAtPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTargetChildAtPosition'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTargetChildAtPosition(*pos);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTargetChildAtPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildRecursive of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildRecursive00
+static int tolua_CEGUI_CEGUI_Window_getChildRecursive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildRecursive'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChildRecursive(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildRecursive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParent00
+static int tolua_CEGUI_CEGUI_Window_getParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParent'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getParent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAncestor00
+static int tolua_CEGUI_CEGUI_Window_isAncestor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAncestor(ID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAncestor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAncestor01
+static int tolua_CEGUI_CEGUI_Window_isAncestor01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAncestor(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isAncestor00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAncestor02
+static int tolua_CEGUI_CEGUI_Window_isAncestor02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAncestor(window);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isAncestor01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setFont00
+static int tolua_CEGUI_CEGUI_Window_setFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setFont01
+static int tolua_CEGUI_CEGUI_Window_setFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getFont00
+static int tolua_CEGUI_CEGUI_Window_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getFont();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setText00
+static int tolua_CEGUI_CEGUI_Window_setText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setText'",NULL);
+#endif
+ {
+  self->setText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getText00
+static int tolua_CEGUI_CEGUI_Window_getText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: inheritsAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_inheritsAlpha00
+static int tolua_CEGUI_CEGUI_Window_inheritsAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'inheritsAlpha'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->inheritsAlpha();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'inheritsAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getAlpha00
+static int tolua_CEGUI_CEGUI_Window_getAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getEffectiveAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getEffectiveAlpha00
+static int tolua_CEGUI_CEGUI_Window_getEffectiveAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getEffectiveAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getEffectiveAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEffectiveAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAlpha00
+static int tolua_CEGUI_CEGUI_Window_setAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  float a = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlpha'",NULL);
+#endif
+ {
+  self->setAlpha(a);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setInheritsAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setInheritsAlpha00
+static int tolua_CEGUI_CEGUI_Window_setInheritsAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setInheritsAlpha'",NULL);
+#endif
+ {
+  self->setInheritsAlpha(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setInheritsAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: requestRedraw of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_requestRedraw00
+static int tolua_CEGUI_CEGUI_Window_requestRedraw00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'requestRedraw'",NULL);
+#endif
+ {
+  self->requestRedraw();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'requestRedraw'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isZOrderingEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isZOrderingEnabled00
+static int tolua_CEGUI_CEGUI_Window_isZOrderingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isZOrderingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isZOrderingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isZOrderingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setZOrderingEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setZOrderingEnabled00
+static int tolua_CEGUI_CEGUI_Window_setZOrderingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setZOrderingEnabled'",NULL);
+#endif
+ {
+  self->setZOrderingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setZOrderingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPixelRect00
+static int tolua_CEGUI_CEGUI_Window_getPixelRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getPixelRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getInnerRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getInnerRect00
+static int tolua_CEGUI_CEGUI_Window_getInnerRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getInnerRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getInnerRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getInnerRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUnclippedPixelRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getUnclippedPixelRect00
+static int tolua_CEGUI_CEGUI_Window_getUnclippedPixelRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUnclippedPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getUnclippedPixelRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUnclippedPixelRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUnclippedInnerRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getUnclippedInnerRect00
+static int tolua_CEGUI_CEGUI_Window_getUnclippedInnerRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUnclippedInnerRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getUnclippedInnerRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUnclippedInnerRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParentPixelSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParentPixelSize00
+static int tolua_CEGUI_CEGUI_Window_getParentPixelSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParentPixelSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getParentPixelSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParentPixelSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParentPixelWidth of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParentPixelWidth00
+static int tolua_CEGUI_CEGUI_Window_getParentPixelWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParentPixelWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getParentPixelWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParentPixelWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParentPixelHeight of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParentPixelHeight00
+static int tolua_CEGUI_CEGUI_Window_getParentPixelHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParentPixelHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getParentPixelHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParentPixelHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaptureWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getCaptureWindow00
+static int tolua_CEGUI_CEGUI_Window_getCaptureWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  CEGUI::Window::getCaptureWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaptureWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRestoreCapture of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setRestoreCapture00
+static int tolua_CEGUI_CEGUI_Window_setRestoreCapture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRestoreCapture'",NULL);
+#endif
+ {
+  self->setRestoreCapture(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRestoreCapture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: restoresOldCapture of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_restoresOldCapture00
+static int tolua_CEGUI_CEGUI_Window_restoresOldCapture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'restoresOldCapture'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->restoresOldCapture();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'restoresOldCapture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: distributesCapturedInputs of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_distributesCapturedInputs00
+static int tolua_CEGUI_CEGUI_Window_distributesCapturedInputs00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'distributesCapturedInputs'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->distributesCapturedInputs();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'distributesCapturedInputs'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDistributesCapturedInputs of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setDistributesCapturedInputs00
+static int tolua_CEGUI_CEGUI_Window_setDistributesCapturedInputs00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDistributesCapturedInputs'",NULL);
+#endif
+ {
+  self->setDistributesCapturedInputs(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDistributesCapturedInputs'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: captureInput of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_captureInput00
+static int tolua_CEGUI_CEGUI_Window_captureInput00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'captureInput'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->captureInput();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'captureInput'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: releaseInput of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_releaseInput00
+static int tolua_CEGUI_CEGUI_Window_releaseInput00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'releaseInput'",NULL);
+#endif
+ {
+  self->releaseInput();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'releaseInput'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCapturedByThis of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isCapturedByThis00
+static int tolua_CEGUI_CEGUI_Window_isCapturedByThis00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCapturedByThis'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCapturedByThis();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCapturedByThis'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCapturedByAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isCapturedByAncestor00
+static int tolua_CEGUI_CEGUI_Window_isCapturedByAncestor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCapturedByAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCapturedByAncestor();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCapturedByAncestor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCapturedByChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isCapturedByChild00
+static int tolua_CEGUI_CEGUI_Window_isCapturedByChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCapturedByChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCapturedByChild();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCapturedByChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHit of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isHit00
+static int tolua_CEGUI_CEGUI_Window_isHit00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHit'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHit(*pos);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHit'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRiseOnClickEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isRiseOnClickEnabled00
+static int tolua_CEGUI_CEGUI_Window_isRiseOnClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRiseOnClickEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRiseOnClickEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRiseOnClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRiseOnClickEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setRiseOnClickEnabled00
+static int tolua_CEGUI_CEGUI_Window_setRiseOnClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRiseOnClickEnabled'",NULL);
+#endif
+ {
+  self->setRiseOnClickEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRiseOnClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getMouseCursor00
+static int tolua_CEGUI_CEGUI_Window_getMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMouseCursor'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getMouseCursor();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseCursor00
+static int tolua_CEGUI_CEGUI_Window_setMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseCursorImage cursor = ((CEGUI::MouseCursorImage) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseCursor'",NULL);
+#endif
+ {
+  self->setMouseCursor(cursor);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseCursor01
+static int tolua_CEGUI_CEGUI_Window_setMouseCursor01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseCursor'",NULL);
+#endif
+ {
+  self->setMouseCursor(image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setMouseCursor00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseCursor02
+static int tolua_CEGUI_CEGUI_Window_setMouseCursor02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseCursor'",NULL);
+#endif
+ {
+  self->setMouseCursor(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setMouseCursor01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveToFront of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_moveToFront00
+static int tolua_CEGUI_CEGUI_Window_moveToFront00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveToFront'",NULL);
+#endif
+ {
+  self->moveToFront();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveToFront'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveToBack of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_moveToBack00
+static int tolua_CEGUI_CEGUI_Window_moveToBack00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveToBack'",NULL);
+#endif
+ {
+  self->moveToBack();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveToBack'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: wantsMultiClickEvents of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_wantsMultiClickEvents00
+static int tolua_CEGUI_CEGUI_Window_wantsMultiClickEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'wantsMultiClickEvents'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->wantsMultiClickEvents();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'wantsMultiClickEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMouseAutoRepeatEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isMouseAutoRepeatEnabled00
+static int tolua_CEGUI_CEGUI_Window_isMouseAutoRepeatEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMouseAutoRepeatEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMouseAutoRepeatEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMouseAutoRepeatEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAutoRepeatDelay of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getAutoRepeatDelay00
+static int tolua_CEGUI_CEGUI_Window_getAutoRepeatDelay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAutoRepeatDelay'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAutoRepeatDelay();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAutoRepeatDelay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAutoRepeatRate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getAutoRepeatRate00
+static int tolua_CEGUI_CEGUI_Window_getAutoRepeatRate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAutoRepeatRate'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAutoRepeatRate();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAutoRepeatRate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWantsMultiClickEvents of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setWantsMultiClickEvents00
+static int tolua_CEGUI_CEGUI_Window_setWantsMultiClickEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWantsMultiClickEvents'",NULL);
+#endif
+ {
+  self->setWantsMultiClickEvents(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWantsMultiClickEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseAutoRepeatEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseAutoRepeatEnabled00
+static int tolua_CEGUI_CEGUI_Window_setMouseAutoRepeatEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseAutoRepeatEnabled'",NULL);
+#endif
+ {
+  self->setMouseAutoRepeatEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMouseAutoRepeatEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoRepeatDelay of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAutoRepeatDelay00
+static int tolua_CEGUI_CEGUI_Window_setAutoRepeatDelay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  float delay = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoRepeatDelay'",NULL);
+#endif
+ {
+  self->setAutoRepeatDelay(delay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoRepeatDelay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoRepeatRate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAutoRepeatRate00
+static int tolua_CEGUI_CEGUI_Window_setAutoRepeatRate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  float rate = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoRepeatRate'",NULL);
+#endif
+ {
+  self->setAutoRepeatRate(rate);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoRepeatRate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUsingDefaultTooltip of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isUsingDefaultTooltip00
+static int tolua_CEGUI_CEGUI_Window_isUsingDefaultTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUsingDefaultTooltip'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUsingDefaultTooltip();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUsingDefaultTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTooltip of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTooltip00
+static int tolua_CEGUI_CEGUI_Window_getTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTooltip'",NULL);
+#endif
+ {
+  CEGUI::Tooltip* tolua_ret = (CEGUI::Tooltip*)  self->getTooltip();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Tooltip");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTooltipType of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTooltipType00
+static int tolua_CEGUI_CEGUI_Window_getTooltipType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTooltipType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTooltipType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTooltipType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTooltipText00
+static int tolua_CEGUI_CEGUI_Window_getTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTooltipText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTooltipText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: inheritsTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_inheritsTooltipText00
+static int tolua_CEGUI_CEGUI_Window_inheritsTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'inheritsTooltipText'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->inheritsTooltipText();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'inheritsTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTooltip of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setTooltip00
+static int tolua_CEGUI_CEGUI_Window_setTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Tooltip* tooltip = ((CEGUI::Tooltip*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTooltip'",NULL);
+#endif
+ {
+  self->setTooltip(tooltip);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTooltipType of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setTooltipType00
+static int tolua_CEGUI_CEGUI_Window_setTooltipType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string tooltipType = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTooltipType'",NULL);
+#endif
+ {
+  self->setTooltipType(tooltipType);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTooltipType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setTooltipText00
+static int tolua_CEGUI_CEGUI_Window_setTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string tip = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTooltipText'",NULL);
+#endif
+ {
+  self->setTooltipText(tip);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setInheritsTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setInheritsTooltipText00
+static int tolua_CEGUI_CEGUI_Window_setInheritsTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setInheritsTooltipText'",NULL);
+#endif
+ {
+  self->setInheritsTooltipText(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setInheritsTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: testClassName of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_testClassName00
+static int tolua_CEGUI_CEGUI_Window_testClassName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string class_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'testClassName'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->testClassName(class_name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'testClassName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyDragDropItemEnters of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_notifyDragDropItemEnters00
+static int tolua_CEGUI_CEGUI_Window_notifyDragDropItemEnters00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DragContainer* item = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyDragDropItemEnters'",NULL);
+#endif
+ {
+  self->notifyDragDropItemEnters(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyDragDropItemEnters'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyDragDropItemLeaves of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_notifyDragDropItemLeaves00
+static int tolua_CEGUI_CEGUI_Window_notifyDragDropItemLeaves00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DragContainer* item = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyDragDropItemLeaves'",NULL);
+#endif
+ {
+  self->notifyDragDropItemLeaves(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyDragDropItemLeaves'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyDragDropItemDropped of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_notifyDragDropItemDropped00
+static int tolua_CEGUI_CEGUI_Window_notifyDragDropItemDropped00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DragContainer* item = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyDragDropItemDropped'",NULL);
+#endif
+ {
+  self->notifyDragDropItemDropped(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyDragDropItemDropped'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getVerticalAlignment00
+static int tolua_CEGUI_CEGUI_Window_getVerticalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalAlignment'",NULL);
+#endif
+ {
+  CEGUI::VerticalAlignment tolua_ret = (CEGUI::VerticalAlignment)  self->getVerticalAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getHorizontalAlignment00
+static int tolua_CEGUI_CEGUI_Window_getHorizontalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalAlignment'",NULL);
+#endif
+ {
+  CEGUI::HorizontalAlignment tolua_ret = (CEGUI::HorizontalAlignment)  self->getHorizontalAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setVerticalAlignment00
+static int tolua_CEGUI_CEGUI_Window_setVerticalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalAlignment alignment = ((CEGUI::VerticalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalAlignment'",NULL);
+#endif
+ {
+  self->setVerticalAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setHorizontalAlignment00
+static int tolua_CEGUI_CEGUI_Window_setHorizontalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalAlignment alignment = ((CEGUI::HorizontalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalAlignment'",NULL);
+#endif
+ {
+  self->setHorizontalAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLookNFeel of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getLookNFeel00
+static int tolua_CEGUI_CEGUI_Window_getLookNFeel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLookNFeel'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getLookNFeel();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLookNFeel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setLookNFeel of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setLookNFeel00
+static int tolua_CEGUI_CEGUI_Window_setLookNFeel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string lnf = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setLookNFeel'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->setLookNFeel(lnf);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'setLookNFeel'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setLookNFeel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWindowRenderer of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setWindowRenderer00
+static int tolua_CEGUI_CEGUI_Window_setWindowRenderer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWindowRenderer'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->setWindowRenderer(name);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'setWindowRenderer'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWindowRenderer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindowRendererName of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getWindowRendererName00
+static int tolua_CEGUI_CEGUI_Window_getWindowRendererName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindowRendererName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWindowRendererName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindowRendererName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getModalState of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getModalState00
+static int tolua_CEGUI_CEGUI_Window_getModalState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getModalState'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->getModalState();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getModalState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setModalState of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setModalState00
+static int tolua_CEGUI_CEGUI_Window_setModalState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool state = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setModalState'",NULL);
+#endif
+ {
+  self->setModalState(state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setModalState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUserString of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getUserString00
+static int tolua_CEGUI_CEGUI_Window_getUserString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUserString'",NULL);
+#endif
+ try
+ {
+  string tolua_ret = (string)  self->getUserString(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUserString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserStringDefined of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isUserStringDefined00
+static int tolua_CEGUI_CEGUI_Window_isUserStringDefined00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserStringDefined'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserStringDefined(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserStringDefined'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserString of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setUserString00
+static int tolua_CEGUI_CEGUI_Window_setUserString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserString'",NULL);
+#endif
+ {
+  self->setUserString(name,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: beginInitialisation of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_beginInitialisation00
+static int tolua_CEGUI_CEGUI_Window_beginInitialisation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'beginInitialisation'",NULL);
+#endif
+ {
+  self->beginInitialisation();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'beginInitialisation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: endInitialisation of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_endInitialisation00
+static int tolua_CEGUI_CEGUI_Window_endInitialisation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'endInitialisation'",NULL);
+#endif
+ {
+  self->endInitialisation();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'endInitialisation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setArea00
+static int tolua_CEGUI_CEGUI_Window_setArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* xpos = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* ypos = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::UDim* height = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(*xpos,*ypos,*width,*height);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setArea01
+static int tolua_CEGUI_CEGUI_Window_setArea01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* pos = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(*pos,*size);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setArea00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setArea02
+static int tolua_CEGUI_CEGUI_Window_setArea02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::URect* area = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(*area);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setArea01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setPosition00
+static int tolua_CEGUI_CEGUI_Window_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* pos = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setXPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setXPosition00
+static int tolua_CEGUI_CEGUI_Window_setXPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* x = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setXPosition'",NULL);
+#endif
+ {
+  self->setXPosition(*x);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setXPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setYPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setYPosition00
+static int tolua_CEGUI_CEGUI_Window_setYPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* y = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setYPosition'",NULL);
+#endif
+ {
+  self->setYPosition(*y);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setYPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setSize00
+static int tolua_CEGUI_CEGUI_Window_setSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSize'",NULL);
+#endif
+ {
+  self->setSize(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidth of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setWidth00
+static int tolua_CEGUI_CEGUI_Window_setWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidth'",NULL);
+#endif
+ {
+  self->setWidth(*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHeight of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setHeight00
+static int tolua_CEGUI_CEGUI_Window_setHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* height = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHeight'",NULL);
+#endif
+ {
+  self->setHeight(*height);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMaxSize00
+static int tolua_CEGUI_CEGUI_Window_setMaxSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxSize'",NULL);
+#endif
+ {
+  self->setMaxSize(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMinSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMinSize00
+static int tolua_CEGUI_CEGUI_Window_setMinSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMinSize'",NULL);
+#endif
+ {
+  self->setMinSize(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMinSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getArea00
+static int tolua_CEGUI_CEGUI_Window_getArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getArea'",NULL);
+#endif
+ {
+  const CEGUI::URect& tolua_ret = (const CEGUI::URect&)  self->getArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPosition00
+static int tolua_CEGUI_CEGUI_Window_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getXPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getXPosition00
+static int tolua_CEGUI_CEGUI_Window_getXPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getXPosition'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getXPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getXPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getYPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getYPosition00
+static int tolua_CEGUI_CEGUI_Window_getYPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getYPosition'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getYPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getYPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getSize00
+static int tolua_CEGUI_CEGUI_Window_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getWidth00
+static int tolua_CEGUI_CEGUI_Window_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getWidth();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getHeight00
+static int tolua_CEGUI_CEGUI_Window_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getHeight();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getMaxSize00
+static int tolua_CEGUI_CEGUI_Window_getMaxSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxSize'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getMaxSize();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMinSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getMinSize00
+static int tolua_CEGUI_CEGUI_Window_getMinSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMinSize'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getMinSize();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMinSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMousePassThroughEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isMousePassThroughEnabled00
+static int tolua_CEGUI_CEGUI_Window_isMousePassThroughEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMousePassThroughEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMousePassThroughEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMousePassThroughEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMousePassThroughEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMousePassThroughEnabled00
+static int tolua_CEGUI_CEGUI_Window_setMousePassThroughEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMousePassThroughEnabled'",NULL);
+#endif
+ {
+  self->setMousePassThroughEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMousePassThroughEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rename of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_rename00
+static int tolua_CEGUI_CEGUI_Window_rename00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string new_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'rename'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->rename(new_name);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'rename'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'rename'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setProperty of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setProperty00
+static int tolua_CEGUI_CEGUI_Window_setProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setProperty'",NULL);
+#endif
+ {
+  self->setProperty(name,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getProperty of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getProperty00
+static int tolua_CEGUI_CEGUI_Window_getProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getProperty'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getProperty(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyDefault of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPropertyDefault00
+static int tolua_CEGUI_CEGUI_Window_getPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyDefault'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyDefault(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyHelp of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPropertyHelp00
+static int tolua_CEGUI_CEGUI_Window_getPropertyHelp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyHelp'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyHelp(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyHelp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyPresent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isPropertyPresent00
+static int tolua_CEGUI_CEGUI_Window_isPropertyPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyDefault of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isPropertyDefault00
+static int tolua_CEGUI_CEGUI_Window_isPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyDefault'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyDefault(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getPropertyIterator of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPropertyIterator00
+static int tolua_CEGUI_CEGUI_Window_getPropertyIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getPropertyIterator'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator tolua_ret = (CEGUI::PropertyIterator)  ceguiLua_getPropertyIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::PropertyIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::PropertyIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_addEvent00
+static int tolua_CEGUI_CEGUI_Window_addEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addEvent'",NULL);
+#endif
+ {
+  self->addEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeEvent00
+static int tolua_CEGUI_CEGUI_Window_removeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeEvent'",NULL);
+#endif
+ {
+  self->removeEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeAllEvents of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeAllEvents00
+static int tolua_CEGUI_CEGUI_Window_removeAllEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllEvents'",NULL);
+#endif
+ {
+  self->removeAllEvents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeAllEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isEventPresent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isEventPresent00
+static int tolua_CEGUI_CEGUI_Window_isEventPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEventPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isEventPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isEventPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: LuaFunctorSubscribeEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_subscribeEvent00
+static int tolua_CEGUI_CEGUI_Window_subscribeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  lua_Object funcIndex = ((lua_Object)  tolua_tovalue(tolua_S,3,0));
+  lua_Object selfIndex = ((lua_Object)  tolua_tovalue(tolua_S,4,LUA_NOREF));
+  lua_State* tolua_var_2 =  tolua_S;
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'LuaFunctorSubscribeEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+   CEGUI::EventConnection tolua_ret = (  CEGUI::EventConnection)  LuaFunctorSubscribeEvent(self,name,funcIndex,selfIndex,tolua_var_2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'LuaFunctorSubscribeEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'subscribeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: subscribeScriptedEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_subscribeEvent01
+static int tolua_CEGUI_CEGUI_Window_subscribeEvent01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string callback_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'subscribeScriptedEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::EventConnection tolua_ret = (CEGUI::EventConnection)  self->subscribeScriptedEvent(name,callback_name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'subscribeScriptedEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_subscribeEvent00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: fireEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_fireEvent00
+static int tolua_CEGUI_CEGUI_Window_fireEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::EventArgs* args = ((CEGUI::EventArgs*)  tolua_tousertype(tolua_S,3,0));
+  string eventnamespace = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fireEvent'",NULL);
+#endif
+ {
+  self->fireEvent(name,*args,eventnamespace);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'fireEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMuted of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isMuted00
+static int tolua_CEGUI_CEGUI_Window_isMuted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMuted'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMuted();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMuted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMutedState of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMutedState00
+static int tolua_CEGUI_CEGUI_Window_setMutedState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMutedState'",NULL);
+#endif
+ {
+  self->setMutedState(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMutedState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getEventIterator00
+static int tolua_CEGUI_CEGUI_Window_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* x = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenX(*window,*x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'windowToScreenX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX01
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float x = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenX(*window,x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* y = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenY(*window,*y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'windowToScreenY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY01
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float y = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenY(*window,y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* vec = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::windowToScreen(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'windowToScreen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::windowToScreen(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::URect* rect = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::windowToScreen(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen03
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::windowToScreen(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* x = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowX(*window,*x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'screenToWindowX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX01
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float x = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowX(*window,x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* y = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowY(*window,*y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'screenToWindowY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY01
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float y = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowY(*window,y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* vec = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::screenToWindow(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'screenToWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::screenToWindow(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::URect* rect = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::screenToWindow(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow03
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::screenToWindow(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentZ of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getCurrentZ00
+static int tolua_CEGUI_CEGUI_Renderer_getCurrentZ00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentZ'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getCurrentZ();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentZ'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getZLayer of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getZLayer00
+static int tolua_CEGUI_CEGUI_Renderer_getZLayer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int layer = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getZLayer'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getZLayer(layer);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getZLayer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isQueueingEnabled of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_isQueueingEnabled00
+static int tolua_CEGUI_CEGUI_Renderer_isQueueingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isQueueingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isQueueingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isQueueingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_createTexture00
+static int tolua_CEGUI_CEGUI_Renderer_createTexture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->createTexture();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createTexture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_createTexture01
+static int tolua_CEGUI_CEGUI_Renderer_createTexture01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  float size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->createTexture(size);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Renderer_createTexture00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_createTexture02
+static int tolua_CEGUI_CEGUI_Renderer_createTexture02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->createTexture(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Renderer_createTexture01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_destroyTexture00
+static int tolua_CEGUI_CEGUI_Renderer_destroyTexture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Texture* tex = ((CEGUI::Texture*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyTexture'",NULL);
+#endif
+ {
+  self->destroyTexture(tex);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyTexture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllTextures of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_destroyAllTextures00
+static int tolua_CEGUI_CEGUI_Renderer_destroyAllTextures00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllTextures'",NULL);
+#endif
+ {
+  self->destroyAllTextures();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllTextures'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getWidth00
+static int tolua_CEGUI_CEGUI_Renderer_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getHeight00
+static int tolua_CEGUI_CEGUI_Renderer_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getSize00
+static int tolua_CEGUI_CEGUI_Renderer_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRect of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getRect00
+static int tolua_CEGUI_CEGUI_Renderer_getRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextureSize of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getMaxTextureSize00
+static int tolua_CEGUI_CEGUI_Renderer_getMaxTextureSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextureSize'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getMaxTextureSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextureSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScreenDPI of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getHorzScreenDPI00
+static int tolua_CEGUI_CEGUI_Renderer_getHorzScreenDPI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScreenDPI'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getHorzScreenDPI();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScreenDPI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScreenDPI of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getVertScreenDPI00
+static int tolua_CEGUI_CEGUI_Renderer_getVertScreenDPI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScreenDPI'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getVertScreenDPI();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScreenDPI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getEventIterator00
+static int tolua_CEGUI_CEGUI_Renderer_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getSingleton00
+static int tolua_CEGUI_CEGUI_System_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::System& tolua_ret = (CEGUI::System&)  CEGUI::System::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::System");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRenderer of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getRenderer00
+static int tolua_CEGUI_CEGUI_System_getRenderer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRenderer'",NULL);
+#endif
+ {
+  CEGUI::Renderer* tolua_ret = (CEGUI::Renderer*)  self->getRenderer();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Renderer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRenderer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultFont of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultFont00
+static int tolua_CEGUI_CEGUI_System_setDefaultFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultFont'",NULL);
+#endif
+ {
+  self->setDefaultFont(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultFont of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultFont01
+static int tolua_CEGUI_CEGUI_System_setDefaultFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultFont'",NULL);
+#endif
+ {
+  self->setDefaultFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultFont of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getDefaultFont00
+static int tolua_CEGUI_CEGUI_System_getDefaultFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDefaultFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getDefaultFont();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: signalRedraw of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_signalRedraw00
+static int tolua_CEGUI_CEGUI_System_signalRedraw00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'signalRedraw'",NULL);
+#endif
+ {
+  self->signalRedraw();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'signalRedraw'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRedrawRequested of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_isRedrawRequested00
+static int tolua_CEGUI_CEGUI_System_isRedrawRequested00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRedrawRequested'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRedrawRequested();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRedrawRequested'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renderGUI of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_renderGUI00
+static int tolua_CEGUI_CEGUI_System_renderGUI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renderGUI'",NULL);
+#endif
+ {
+  self->renderGUI();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'renderGUI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setGUISheet of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setGUISheet00
+static int tolua_CEGUI_CEGUI_System_setGUISheet00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* sheet = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setGUISheet'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->setGUISheet(sheet);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setGUISheet'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getGUISheet of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getGUISheet00
+static int tolua_CEGUI_CEGUI_System_getGUISheet00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getGUISheet'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getGUISheet();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getGUISheet'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSingleClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setSingleClickTimeout00
+static int tolua_CEGUI_CEGUI_System_setSingleClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  double timeout = ((double)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSingleClickTimeout'",NULL);
+#endif
+ {
+  self->setSingleClickTimeout(timeout);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSingleClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setMultiClickTimeout00
+static int tolua_CEGUI_CEGUI_System_setMultiClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  double timeout = ((double)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiClickTimeout'",NULL);
+#endif
+ {
+  self->setMultiClickTimeout(timeout);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiClickToleranceAreaSize of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setMultiClickToleranceAreaSize00
+static int tolua_CEGUI_CEGUI_System_setMultiClickToleranceAreaSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiClickToleranceAreaSize'",NULL);
+#endif
+ {
+  self->setMultiClickToleranceAreaSize(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiClickToleranceAreaSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getSingleClickTimeout00
+static int tolua_CEGUI_CEGUI_System_getSingleClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSingleClickTimeout'",NULL);
+#endif
+ {
+  double tolua_ret = (double)  self->getSingleClickTimeout();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMultiClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getMultiClickTimeout00
+static int tolua_CEGUI_CEGUI_System_getMultiClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMultiClickTimeout'",NULL);
+#endif
+ {
+  double tolua_ret = (double)  self->getMultiClickTimeout();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMultiClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMultiClickToleranceAreaSize of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getMultiClickToleranceAreaSize00
+static int tolua_CEGUI_CEGUI_System_getMultiClickToleranceAreaSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMultiClickToleranceAreaSize'",NULL);
+#endif
+ {
+  const CEGUI::Size& tolua_ret = (const CEGUI::Size&)  self->getMultiClickToleranceAreaSize();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Size");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMultiClickToleranceAreaSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00
+static int tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseCursorImage image = ((CEGUI::MouseCursorImage) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultMouseCursor'",NULL);
+#endif
+ {
+  self->setDefaultMouseCursor(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01
+static int tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultMouseCursor'",NULL);
+#endif
+ {
+  self->setDefaultMouseCursor(image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultMouseCursor02
+static int tolua_CEGUI_CEGUI_System_setDefaultMouseCursor02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string imageset_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultMouseCursor'",NULL);
+#endif
+ {
+  self->setDefaultMouseCursor(imageset_name,image_name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getDefaultMouseCursor00
+static int tolua_CEGUI_CEGUI_System_getDefaultMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDefaultMouseCursor'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getDefaultMouseCursor();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindowContainingMouse of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getWindowContainingMouse00
+static int tolua_CEGUI_CEGUI_System_getWindowContainingMouse00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindowContainingMouse'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getWindowContainingMouse();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindowContainingMouse'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: executeScriptFile of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_executeScriptFile00
+static int tolua_CEGUI_CEGUI_System_executeScriptFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'executeScriptFile'",NULL);
+#endif
+ {
+  self->executeScriptFile(filename);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'executeScriptFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: executeScriptGlobal of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_executeScriptGlobal00
+static int tolua_CEGUI_CEGUI_System_executeScriptGlobal00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string global_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'executeScriptGlobal'",NULL);
+#endif
+ {
+  int tolua_ret = (int)  self->executeScriptGlobal(global_name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'executeScriptGlobal'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: executeScriptString of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_executeScriptString00
+static int tolua_CEGUI_CEGUI_System_executeScriptString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string lua_string = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'executeScriptString'",NULL);
+#endif
+ {
+  self->executeScriptString(lua_string);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'executeScriptString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMouseMoveScaling of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getMouseMoveScaling00
+static int tolua_CEGUI_CEGUI_System_getMouseMoveScaling00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMouseMoveScaling'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMouseMoveScaling();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMouseMoveScaling'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseMoveScaling of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setMouseMoveScaling00
+static int tolua_CEGUI_CEGUI_System_setMouseMoveScaling00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float scaling = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseMoveScaling'",NULL);
+#endif
+ {
+  self->setMouseMoveScaling(scaling);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMouseMoveScaling'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyWindowDestroyed of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_notifyWindowDestroyed00
+static int tolua_CEGUI_CEGUI_System_notifyWindowDestroyed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyWindowDestroyed'",NULL);
+#endif
+ {
+  self->notifyWindowDestroyed(window);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyWindowDestroyed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_System_isSystemKeyDown of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_isSystemKeyDown00
+static int tolua_CEGUI_CEGUI_System_isSystemKeyDown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::SystemKey k = ((CEGUI::SystemKey) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_System_isSystemKeyDown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  ceguiLua_System_isSystemKeyDown(self,k);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSystemKeyDown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultTooltip of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultTooltip00
+static int tolua_CEGUI_CEGUI_System_setDefaultTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Tooltip* tooltip = ((CEGUI::Tooltip*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultTooltip'",NULL);
+#endif
+ {
+  self->setDefaultTooltip(tooltip);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultTooltip of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultTooltip01
+static int tolua_CEGUI_CEGUI_System_setDefaultTooltip01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string tooltipType = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultTooltip'",NULL);
+#endif
+ {
+  self->setDefaultTooltip(tooltipType);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultTooltip00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultTooltip of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getDefaultTooltip00
+static int tolua_CEGUI_CEGUI_System_getDefaultTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDefaultTooltip'",NULL);
+#endif
+ {
+  CEGUI::Tooltip* tolua_ret = (CEGUI::Tooltip*)  self->getDefaultTooltip();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Tooltip");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseMove of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseMove00
+static int tolua_CEGUI_CEGUI_System_injectMouseMove00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float dx = ((float)  tolua_tonumber(tolua_S,2,0));
+  float dy = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseMove'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseMove(dx,dy);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseMove'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseLeaves of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseLeaves00
+static int tolua_CEGUI_CEGUI_System_injectMouseLeaves00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseLeaves'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseLeaves();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseLeaves'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseButtonDown of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseButtonDown00
+static int tolua_CEGUI_CEGUI_System_injectMouseButtonDown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseButton btn = ((CEGUI::MouseButton) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseButtonDown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseButtonDown(btn);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseButtonDown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseButtonUp of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseButtonUp00
+static int tolua_CEGUI_CEGUI_System_injectMouseButtonUp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseButton btn = ((CEGUI::MouseButton) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseButtonUp'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseButtonUp(btn);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseButtonUp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectKeyDown of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectKeyDown00
+static int tolua_CEGUI_CEGUI_System_injectKeyDown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int keycode = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectKeyDown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectKeyDown(keycode);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectKeyDown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectKeyUp of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectKeyUp00
+static int tolua_CEGUI_CEGUI_System_injectKeyUp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int keycode = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectKeyUp'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectKeyUp(keycode);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectKeyUp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectChar of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectChar00
+static int tolua_CEGUI_CEGUI_System_injectChar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long code_point = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectChar'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectChar(code_point);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectChar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseWheelChange of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseWheelChange00
+static int tolua_CEGUI_CEGUI_System_injectMouseWheelChange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float delta = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseWheelChange'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseWheelChange(delta);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseWheelChange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMousePosition of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMousePosition00
+static int tolua_CEGUI_CEGUI_System_injectMousePosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMousePosition'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMousePosition(x,y);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMousePosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectTimePulse of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectTimePulse00
+static int tolua_CEGUI_CEGUI_System_injectTimePulse00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float timeElapsed = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectTimePulse'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectTimePulse(timeElapsed);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectTimePulse'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getEventIterator00
+static int tolua_CEGUI_CEGUI_System_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getSingleton00
+static int tolua_CEGUI_CEGUI_WindowManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WindowManager& tolua_ret = (CEGUI::WindowManager&)  CEGUI::WindowManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_createWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_createWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string name = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createWindow'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->createWindow(type,name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::AlreadyExistsException&e)
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadWindowLayout of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout00
+static int tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string name_prefix = ((string)  tolua_tocppstring(tolua_S,3,""));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadWindowLayout'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->loadWindowLayout(filename,name_prefix,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'loadWindowLayout'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'loadWindowLayout'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'loadWindowLayout'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadWindowLayout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWindowLayoutToStream of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00
+static int tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string window = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::OutStream* out = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+  bool writeParent = ((bool)  tolua_toboolean(tolua_S,4,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWindowLayoutToStream'",NULL);
+#endif
+ {
+  self->writeWindowLayoutToStream(window,*out,writeParent);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'writeWindowLayoutToStream'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWindowLayoutToStream of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream01
+static int tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::OutStream* out = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+  bool writeParent = ((bool)  tolua_toboolean(tolua_S,4,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWindowLayoutToStream'",NULL);
+#endif
+ {
+  self->writeWindowLayoutToStream(*window,*out,writeParent);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_destroyWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_destroyWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyWindow'",NULL);
+#endif
+ {
+  self->destroyWindow(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_destroyWindow01
+static int tolua_CEGUI_CEGUI_WindowManager_destroyWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyWindow'",NULL);
+#endif
+ {
+  self->destroyWindow(window);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WindowManager_destroyWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllWindows of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_destroyAllWindows00
+static int tolua_CEGUI_CEGUI_WindowManager_destroyAllWindows00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllWindows'",NULL);
+#endif
+ {
+  self->destroyAllWindows();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllWindows'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_getWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindow'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getWindow(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isWindowPresent of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_isWindowPresent00
+static int tolua_CEGUI_CEGUI_WindowManager_isWindowPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isWindowPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isWindowPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isWindowPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDeadPoolEmpty of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_isDeadPoolEmpty00
+static int tolua_CEGUI_CEGUI_WindowManager_isDeadPoolEmpty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDeadPoolEmpty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDeadPoolEmpty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDeadPoolEmpty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cleanDeadPool of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_cleanDeadPool00
+static int tolua_CEGUI_CEGUI_WindowManager_cleanDeadPool00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cleanDeadPool'",NULL);
+#endif
+ {
+  self->cleanDeadPool();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cleanDeadPool'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renameWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_renameWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_renameWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string new_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renameWindow'",NULL);
+#endif
+ {
+  self->renameWindow(window,new_name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'renameWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renameWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_renameWindow01
+static int tolua_CEGUI_CEGUI_WindowManager_renameWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string window = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string new_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renameWindow'",NULL);
+#endif
+ {
+  self->renameWindow(window,new_name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WindowManager_renameWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getIterator00
+static int tolua_CEGUI_CEGUI_WindowManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::WindowIterator tolua_ret = (CEGUI::WindowIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::WindowIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::WindowIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WindowManager_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WindowManager::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WindowManager_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::WindowManager::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_windowType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_windowType
+static int tolua_get_CEGUI__FalagardWindowMapping_windowType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_windowType'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_windowType);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_windowType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_windowType
+static int tolua_set_CEGUI__FalagardWindowMapping_windowType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_windowType'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_windowType = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_lookName of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_lookName
+static int tolua_get_CEGUI__FalagardWindowMapping_lookName(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_lookName'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_lookName);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_lookName of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_lookName
+static int tolua_set_CEGUI__FalagardWindowMapping_lookName(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_lookName'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_lookName = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_baseType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_baseType
+static int tolua_get_CEGUI__FalagardWindowMapping_baseType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_baseType'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_baseType);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_baseType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_baseType
+static int tolua_set_CEGUI__FalagardWindowMapping_baseType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_baseType'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_baseType = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_rendererType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_rendererType
+static int tolua_get_CEGUI__FalagardWindowMapping_rendererType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_rendererType'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_rendererType);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_rendererType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_rendererType
+static int tolua_set_CEGUI__FalagardWindowMapping_rendererType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_rendererType'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_rendererType = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTypeName of class  CEGUI::WindowFactory */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactory_getTypeName00
+static int tolua_CEGUI_CEGUI_WindowFactory_getTypeName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactory",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactory* self = (const CEGUI::WindowFactory*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTypeName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTypeName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTypeName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getSingleton00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WindowFactoryManager& tolua_ret = (CEGUI::WindowFactoryManager&)  CEGUI::WindowFactoryManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowFactoryManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFactoryPresent of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_isFactoryPresent00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_isFactoryPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFactoryPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFactoryPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFactoryPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addWindowTypeAlias of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_addWindowTypeAlias00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_addWindowTypeAlias00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string aliasName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string targetType = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addWindowTypeAlias'",NULL);
+#endif
+ {
+  self->addWindowTypeAlias(aliasName,targetType);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addWindowTypeAlias'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeWindowTypeAlias of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_removeWindowTypeAlias00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_removeWindowTypeAlias00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string aliasName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string targetType = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeWindowTypeAlias'",NULL);
+#endif
+ {
+  self->removeWindowTypeAlias(aliasName,targetType);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeWindowTypeAlias'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addFalagardWindowMapping of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_addFalagardWindowMapping00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_addFalagardWindowMapping00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string newType = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string targetType = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string lookName = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string renderer = ((string)  tolua_tocppstring(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addFalagardWindowMapping'",NULL);
+#endif
+ {
+  self->addFalagardWindowMapping(newType,targetType,lookName,renderer);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addFalagardWindowMapping'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeFalagardWindowMapping of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_removeFalagardWindowMapping00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_removeFalagardWindowMapping00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeFalagardWindowMapping'",NULL);
+#endif
+ {
+  self->removeFalagardWindowMapping(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeFalagardWindowMapping'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFalagardMappedType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_isFalagardMappedType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_isFalagardMappedType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFalagardMappedType'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFalagardMappedType(type);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFalagardMappedType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMappedLookForType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedLookForType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedLookForType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMappedLookForType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getMappedLookForType(type);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMappedLookForType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMappedRendererForType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedRendererForType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedRendererForType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMappedRendererForType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getMappedRendererForType(type);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMappedRendererForType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDereferencedAliasType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getDereferencedAliasType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getDereferencedAliasType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDereferencedAliasType'",NULL);
+#endif
+ {
+  CEGUI::String tolua_ret = (CEGUI::String)  self->getDereferencedAliasType(type);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::String(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::String));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDereferencedAliasType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFalagardMappingForType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingForType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingForType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFalagardMappingForType'",NULL);
+#endif
+ {
+  const CEGUI::FalagardWindowMapping& tolua_ret = (const CEGUI::FalagardWindowMapping&)  self->getFalagardMappingForType(type);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::FalagardWindowMapping");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFalagardMappingForType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getIterator00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::WindowFactoryIterator tolua_ret = (CEGUI::WindowFactoryIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::WindowFactoryIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowFactoryIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::WindowFactoryIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowFactoryIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFalagardMappingIterator of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingIterator00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFalagardMappingIterator'",NULL);
+#endif
+ {
+  CEGUI::FalagardMappingIterator tolua_ret = (CEGUI::FalagardMappingIterator)  self->getFalagardMappingIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::FalagardMappingIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardMappingIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::FalagardMappingIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardMappingIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFalagardMappingIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadResources of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_loadResources00
+static int tolua_CEGUI_CEGUI_Scheme_loadResources00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scheme* self = (CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadResources'",NULL);
+#endif
+ {
+  self->loadResources();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadResources'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: unloadResources of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_unloadResources00
+static int tolua_CEGUI_CEGUI_Scheme_unloadResources00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scheme* self = (CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadResources'",NULL);
+#endif
+ {
+  self->unloadResources();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'unloadResources'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resourcesLoaded of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_resourcesLoaded00
+static int tolua_CEGUI_CEGUI_Scheme_resourcesLoaded00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scheme* self = (const CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resourcesLoaded'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->resourcesLoaded();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resourcesLoaded'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_getName00
+static int tolua_CEGUI_CEGUI_Scheme_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scheme* self = (const CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Scheme_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Scheme::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Scheme_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::Scheme::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_getSingleton00
+static int tolua_CEGUI_CEGUI_SchemeManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::SchemeManager& tolua_ret = (CEGUI::SchemeManager&)  CEGUI::SchemeManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::SchemeManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadScheme of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_loadScheme00
+static int tolua_CEGUI_CEGUI_SchemeManager_loadScheme00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeManager* self = (CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadScheme'",NULL);
+#endif
+ {
+  CEGUI::Scheme* tolua_ret = (CEGUI::Scheme*)  self->loadScheme(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scheme");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadScheme'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: unloadScheme of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_unloadScheme00
+static int tolua_CEGUI_CEGUI_SchemeManager_unloadScheme00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeManager* self = (CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadScheme'",NULL);
+#endif
+ {
+  self->unloadScheme(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'unloadScheme'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSchemePresent of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_isSchemePresent00
+static int tolua_CEGUI_CEGUI_SchemeManager_isSchemePresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeManager* self = (const CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSchemePresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSchemePresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSchemePresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getScheme of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_getScheme00
+static int tolua_CEGUI_CEGUI_SchemeManager_getScheme00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeManager* self = (const CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getScheme'",NULL);
+#endif
+ {
+  CEGUI::Scheme* tolua_ret = (CEGUI::Scheme*)  self->getScheme(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scheme");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getScheme'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: unloadAllSchemes of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_unloadAllSchemes00
+static int tolua_CEGUI_CEGUI_SchemeManager_unloadAllSchemes00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeManager* self = (CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadAllSchemes'",NULL);
+#endif
+ {
+  self->unloadAllSchemes();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'unloadAllSchemes'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_getIterator00
+static int tolua_CEGUI_CEGUI_SchemeManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeManager* self = (const CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::SchemeIterator tolua_ret = (CEGUI::SchemeIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::SchemeIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::SchemeIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::SchemeIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::SchemeIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToFloat of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToFloat00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToFloat00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  float tolua_ret = (float)  CEGUI::PropertyHelper::stringToFloat(str);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToFloat'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToUint of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToUint00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToUint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  unsigned int tolua_ret = (unsigned int)  CEGUI::PropertyHelper::stringToUint(str);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToUint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToBool of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToBool00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToBool00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  bool tolua_ret = (bool)  CEGUI::PropertyHelper::stringToBool(str);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToBool'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToSize of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToSize00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  CEGUI::PropertyHelper::stringToSize(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToPoint of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToPoint00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToPoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::PropertyHelper::stringToPoint(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToPoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToRect of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToRect00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::PropertyHelper::stringToRect(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToImage of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToImage00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  CEGUI::PropertyHelper::stringToImage(str);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToColour of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToColour00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToColour00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  CEGUI::PropertyHelper::stringToColour(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToColour'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToColourRect of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToColourRect00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  CEGUI::PropertyHelper::stringToColourRect(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToUDim of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToUDim00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToUDim00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  CEGUI::PropertyHelper::stringToUDim(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToUDim'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToUVector2 of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToUVector200
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToUVector200(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  CEGUI::PropertyHelper::stringToUVector2(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToUVector2'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToURect of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToURect00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToURect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::URect tolua_ret = (CEGUI::URect)  CEGUI::PropertyHelper::stringToURect(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::URect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::URect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::URect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::URect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToURect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: floatToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_floatToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_floatToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::floatToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'floatToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: uintToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_uintToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_uintToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int val = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::uintToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'uintToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: boolToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_boolToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_boolToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  bool val = ((bool)  tolua_toboolean(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::boolToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'boolToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: sizeToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_sizeToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_sizeToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Size* val = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::sizeToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'sizeToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: pointToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_pointToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_pointToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* val = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::pointToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'pointToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rectToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_rectToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_rectToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* val = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::rectToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'rectToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: imageToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_imageToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_imageToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* val = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::imageToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'imageToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: colourToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_colourToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_colourToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* val = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::colourToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'colourToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: colourRectToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_colourRectToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_colourRectToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* val = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::colourRectToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'colourRectToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: udimToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_udimToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_udimToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* val = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::udimToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'udimToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: uvector2ToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_uvector2ToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_uvector2ToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* val = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::uvector2ToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'uvector2ToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: urectToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_urectToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_urectToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* val = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::urectToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'urectToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHovering of class  CEGUI::ButtonBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ButtonBase_isHovering00
+static int tolua_CEGUI_CEGUI_ButtonBase_isHovering00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ButtonBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ButtonBase* self = (const CEGUI::ButtonBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHovering'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHovering();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHovering'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPushed of class  CEGUI::ButtonBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ButtonBase_isPushed00
+static int tolua_CEGUI_CEGUI_ButtonBase_isPushed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ButtonBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ButtonBase* self = (const CEGUI::ButtonBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPushed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPushed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPushed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::Checkbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Checkbox_isSelected00
+static int tolua_CEGUI_CEGUI_Checkbox_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Checkbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Checkbox* self = (const CEGUI::Checkbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::Checkbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Checkbox_setSelected00
+static int tolua_CEGUI_CEGUI_Checkbox_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Checkbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Checkbox* self = (CEGUI::Checkbox*)  tolua_tousertype(tolua_S,1,0);
+  bool select = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(select);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHotTracked of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_isHotTracked00
+static int tolua_CEGUI_CEGUI_Thumb_isHotTracked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Thumb* self = (const CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHotTracked'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHotTracked();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHotTracked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_isVertFree00
+static int tolua_CEGUI_CEGUI_Thumb_isVertFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Thumb* self = (const CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertFree'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertFree();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_isHorzFree00
+static int tolua_CEGUI_CEGUI_Thumb_isHorzFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Thumb* self = (const CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzFree'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzFree();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHotTracked of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setHotTracked00
+static int tolua_CEGUI_CEGUI_Thumb_setHotTracked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHotTracked'",NULL);
+#endif
+ {
+  self->setHotTracked(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHotTracked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVertFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setVertFree00
+static int tolua_CEGUI_CEGUI_Thumb_setVertFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVertFree'",NULL);
+#endif
+ {
+  self->setVertFree(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVertFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorzFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setHorzFree00
+static int tolua_CEGUI_CEGUI_Thumb_setHorzFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorzFree'",NULL);
+#endif
+ {
+  self->setHorzFree(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorzFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_Thumb_getVertRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_getVertRange00
+static int tolua_CEGUI_CEGUI_Thumb_getVertRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_Thumb_getVertRange'",NULL);
+#endif
+ {
+  ceguiLua_Thumb_getVertRange(self,&min,&max);
+ tolua_pushnumber(tolua_S,(lua_Number)min);
+ tolua_pushnumber(tolua_S,(lua_Number)max);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_Thumb_getHorzRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_getHorzRange00
+static int tolua_CEGUI_CEGUI_Thumb_getHorzRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_Thumb_getHorzRange'",NULL);
+#endif
+ {
+  ceguiLua_Thumb_getHorzRange(self,&min,&max);
+ tolua_pushnumber(tolua_S,(lua_Number)min);
+ tolua_pushnumber(tolua_S,(lua_Number)max);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVertRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setVertRange00
+static int tolua_CEGUI_CEGUI_Thumb_setVertRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVertRange'",NULL);
+#endif
+ {
+  self->setVertRange(min,max);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVertRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorzRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setHorzRange00
+static int tolua_CEGUI_CEGUI_Thumb_setHorzRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorzRange'",NULL);
+#endif
+ {
+  self->setHorzRange(min,max);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorzRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_isSelected00
+static int tolua_CEGUI_CEGUI_RadioButton_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::RadioButton* self = (const CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_setSelected00
+static int tolua_CEGUI_CEGUI_RadioButton_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::RadioButton* self = (CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+  bool select = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(select);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getGroupID of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_getGroupID00
+static int tolua_CEGUI_CEGUI_RadioButton_getGroupID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::RadioButton* self = (const CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getGroupID'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getGroupID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getGroupID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setGroupID of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_setGroupID00
+static int tolua_CEGUI_CEGUI_RadioButton_setGroupID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::RadioButton* self = (CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long group = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setGroupID'",NULL);
+#endif
+ {
+  self->setGroupID(group);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setGroupID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedButtonInGroup of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_getSelectedButtonInGroup00
+static int tolua_CEGUI_CEGUI_RadioButton_getSelectedButtonInGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::RadioButton* self = (const CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedButtonInGroup'",NULL);
+#endif
+ {
+  CEGUI::RadioButton* tolua_ret = (CEGUI::RadioButton*)  self->getSelectedButtonInGroup();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::RadioButton");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedButtonInGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_isSelected00
+static int tolua_CEGUI_CEGUI_TabButton_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabButton* self = (const CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_setSelected00
+static int tolua_CEGUI_CEGUI_TabButton_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabButton* self = (CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+  bool select = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(select);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTargetWindow of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_setTargetWindow00
+static int tolua_CEGUI_CEGUI_TabButton_setTargetWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabButton* self = (CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTargetWindow'",NULL);
+#endif
+ {
+  self->setTargetWindow(wnd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTargetWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTargetWindow of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_getTargetWindow00
+static int tolua_CEGUI_CEGUI_TabButton_getTargetWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabButton* self = (CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTargetWindow'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTargetWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTargetWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabCount of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabCount00
+static int tolua_CEGUI_CEGUI_TabControl_getTabCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getTabCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectedTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setSelectedTab00
+static int tolua_CEGUI_CEGUI_TabControl_setSelectedTab00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectedTab'",NULL);
+#endif
+ {
+  self->setSelectedTab(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectedTab'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectedTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setSelectedTab01
+static int tolua_CEGUI_CEGUI_TabControl_setSelectedTab01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectedTab'",NULL);
+#endif
+ {
+  self->setSelectedTab(ID);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TabControl_setSelectedTab00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectedTabAtIndex of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setSelectedTabAtIndex00
+static int tolua_CEGUI_CEGUI_TabControl_setSelectedTabAtIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int index = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectedTabAtIndex'",NULL);
+#endif
+ {
+  self->setSelectedTabAtIndex(index);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectedTabAtIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabContentsAtIndex of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabContentsAtIndex00
+static int tolua_CEGUI_CEGUI_TabControl_getTabContentsAtIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int index = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabContentsAtIndex'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTabContentsAtIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabContentsAtIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabContents of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabContents00
+static int tolua_CEGUI_CEGUI_TabControl_getTabContents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabContents'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTabContents(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabContents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabContents of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabContents01
+static int tolua_CEGUI_CEGUI_TabControl_getTabContents01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabContents'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTabContents(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TabControl_getTabContents00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTabContentsSelected of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_isTabContentsSelected00
+static int tolua_CEGUI_CEGUI_TabControl_isTabContentsSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTabContentsSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTabContentsSelected(wnd);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTabContentsSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedTabIndex of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getSelectedTabIndex00
+static int tolua_CEGUI_CEGUI_TabControl_getSelectedTabIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedTabIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSelectedTabIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedTabIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabHeight of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabHeight00
+static int tolua_CEGUI_CEGUI_TabControl_getTabHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabHeight'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getTabHeight();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabTextPadding of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabTextPadding00
+static int tolua_CEGUI_CEGUI_TabControl_getTabTextPadding00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabTextPadding'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getTabTextPadding();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabTextPadding'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTabHeight of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setTabHeight00
+static int tolua_CEGUI_CEGUI_TabControl_setTabHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* height = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTabHeight'",NULL);
+#endif
+ {
+  self->setTabHeight(*height);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTabHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTabTextPadding of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setTabTextPadding00
+static int tolua_CEGUI_CEGUI_TabControl_setTabTextPadding00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* pad = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTabTextPadding'",NULL);
+#endif
+ {
+  self->setTabTextPadding(*pad);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTabTextPadding'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_addTab00
+static int tolua_CEGUI_CEGUI_TabControl_addTab00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addTab'",NULL);
+#endif
+ {
+  self->addTab(wnd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addTab'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_removeTab00
+static int tolua_CEGUI_CEGUI_TabControl_removeTab00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeTab'",NULL);
+#endif
+ {
+  self->removeTab(ID);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeTab'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_removeTab01
+static int tolua_CEGUI_CEGUI_TabControl_removeTab01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeTab'",NULL);
+#endif
+ {
+  self->removeTab(name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TabControl_removeTab00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDraggingEnabled of class  CEGUI::Titlebar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Titlebar_isDraggingEnabled00
+static int tolua_CEGUI_CEGUI_Titlebar_isDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Titlebar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Titlebar* self = (const CEGUI::Titlebar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDraggingEnabled of class  CEGUI::Titlebar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Titlebar_setDraggingEnabled00
+static int tolua_CEGUI_CEGUI_Titlebar_setDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Titlebar",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Titlebar* self = (CEGUI::Titlebar*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDraggingEnabled'",NULL);
+#endif
+ {
+  self->setDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSizingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isSizingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFrameEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isFrameEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isFrameEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFrameEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFrameEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFrameEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTitleBarEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isTitleBarEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isTitleBarEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTitleBarEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTitleBarEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTitleBarEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCloseButtonEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isCloseButtonEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isCloseButtonEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCloseButtonEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCloseButtonEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCloseButtonEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRollupEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isRollupEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isRollupEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRollupEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRollupEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRollupEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRolledup of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isRolledup00
+static int tolua_CEGUI_CEGUI_FrameWindow_isRolledup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRolledup'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRolledup();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRolledup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDragMovingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDragMovingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDragMovingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSizingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setSizingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSizingEnabled'",NULL);
+#endif
+ {
+  self->setSizingEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFrameEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setFrameEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setFrameEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFrameEnabled'",NULL);
+#endif
+ {
+  self->setFrameEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFrameEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTitleBarEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setTitleBarEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setTitleBarEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTitleBarEnabled'",NULL);
+#endif
+ {
+  self->setTitleBarEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTitleBarEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCloseButtonEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setCloseButtonEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setCloseButtonEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCloseButtonEnabled'",NULL);
+#endif
+ {
+  self->setCloseButtonEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCloseButtonEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRollupEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setRollupEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setRollupEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRollupEnabled'",NULL);
+#endif
+ {
+  self->setRollupEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRollupEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragMovingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragMovingEnabled'",NULL);
+#endif
+ {
+  self->setDragMovingEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSizingBorderThickness of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_getSizingBorderThickness00
+static int tolua_CEGUI_CEGUI_FrameWindow_getSizingBorderThickness00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSizingBorderThickness'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getSizingBorderThickness();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSizingBorderThickness'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSizingBorderThickness of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setSizingBorderThickness00
+static int tolua_CEGUI_CEGUI_FrameWindow_setSizingBorderThickness00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  float pixels = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSizingBorderThickness'",NULL);
+#endif
+ {
+  self->setSizingBorderThickness(pixels);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSizingBorderThickness'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toggleRollup of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_toggleRollup00
+static int tolua_CEGUI_CEGUI_FrameWindow_toggleRollup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toggleRollup'",NULL);
+#endif
+ {
+  self->toggleRollup();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toggleRollup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offsetPixelPosition of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_offsetPixelPosition00
+static int tolua_CEGUI_CEGUI_FrameWindow_offsetPixelPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offsetPixelPosition'",NULL);
+#endif
+ {
+  self->offsetPixelPosition(*offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offsetPixelPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTargetWindow of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setTargetWindow00
+static int tolua_CEGUI_CEGUI_Tooltip_setTargetWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTargetWindow'",NULL);
+#endif
+ {
+  self->setTargetWindow(wnd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTargetWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetTimer of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_resetTimer00
+static int tolua_CEGUI_CEGUI_Tooltip_resetTimer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetTimer'",NULL);
+#endif
+ {
+  self->resetTimer();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetTimer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHoverTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_getHoverTime00
+static int tolua_CEGUI_CEGUI_Tooltip_getHoverTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tooltip* self = (const CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHoverTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHoverTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHoverTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDisplayTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setDisplayTime00
+static int tolua_CEGUI_CEGUI_Tooltip_setDisplayTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  float seconds = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDisplayTime'",NULL);
+#endif
+ {
+  self->setDisplayTime(seconds);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDisplayTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFadeTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_getFadeTime00
+static int tolua_CEGUI_CEGUI_Tooltip_getFadeTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tooltip* self = (const CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFadeTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFadeTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFadeTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHoverTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setHoverTime00
+static int tolua_CEGUI_CEGUI_Tooltip_setHoverTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  float seconds = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHoverTime'",NULL);
+#endif
+ {
+  self->setHoverTime(seconds);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHoverTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDisplayTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_getDisplayTime00
+static int tolua_CEGUI_CEGUI_Tooltip_getDisplayTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tooltip* self = (const CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDisplayTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getDisplayTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDisplayTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFadeTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setFadeTime00
+static int tolua_CEGUI_CEGUI_Tooltip_setFadeTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  float seconds = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFadeTime'",NULL);
+#endif
+ {
+  self->setFadeTime(seconds);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFadeTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDraggingEnabled of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_isDraggingEnabled00
+static int tolua_CEGUI_CEGUI_DragContainer_isDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDraggingEnabled of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDraggingEnabled00
+static int tolua_CEGUI_CEGUI_DragContainer_setDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDraggingEnabled'",NULL);
+#endif
+ {
+  self->setDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isBeingDragged of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_isBeingDragged00
+static int tolua_CEGUI_CEGUI_DragContainer_isBeingDragged00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isBeingDragged'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isBeingDragged();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isBeingDragged'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelDragThreshold of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getPixelDragThreshold00
+static int tolua_CEGUI_CEGUI_DragContainer_getPixelDragThreshold00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelDragThreshold'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPixelDragThreshold();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelDragThreshold'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPixelDragThreshold of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setPixelDragThreshold00
+static int tolua_CEGUI_CEGUI_DragContainer_setPixelDragThreshold00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  float pixels = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPixelDragThreshold'",NULL);
+#endif
+ {
+  self->setPixelDragThreshold(pixels);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPixelDragThreshold'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDragAlpha of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getDragAlpha00
+static int tolua_CEGUI_CEGUI_DragContainer_getDragAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDragAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getDragAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDragAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragAlpha of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragAlpha00
+static int tolua_CEGUI_CEGUI_DragContainer_setDragAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragAlpha'",NULL);
+#endif
+ {
+  self->setDragAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getDragCursorImage00
+static int tolua_CEGUI_CEGUI_DragContainer_getDragCursorImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDragCursorImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getDragCursorImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDragCursorImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00
+static int tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseCursorImage image = ((CEGUI::MouseCursorImage) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragCursorImage'",NULL);
+#endif
+ {
+  self->setDragCursorImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragCursorImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01
+static int tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragCursorImage'",NULL);
+#endif
+ {
+  self->setDragCursorImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage02
+static int tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragCursorImage'",NULL);
+#endif
+ {
+  self->setDragCursorImage(image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentDropTarget of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getCurrentDropTarget00
+static int tolua_CEGUI_CEGUI_DragContainer_getCurrentDropTarget00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentDropTarget'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getCurrentDropTarget();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentDropTarget'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDocumentSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getDocumentSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getDocumentSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDocumentSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getDocumentSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDocumentSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPageSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getPageSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getPageSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPageSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPageSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPageSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStepSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getStepSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOverlapSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getOverlapSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOverlapSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getOverlapSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getScrollPosition of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getScrollPosition00
+static int tolua_CEGUI_CEGUI_Scrollbar_getScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getScrollPosition'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getScrollPosition();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDocumentSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setDocumentSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setDocumentSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float document_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDocumentSize'",NULL);
+#endif
+ {
+  self->setDocumentSize(document_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDocumentSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPageSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setPageSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setPageSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float page_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPageSize'",NULL);
+#endif
+ {
+  self->setPageSize(page_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPageSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setStepSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setStepSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float step_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setStepSize'",NULL);
+#endif
+ {
+  self->setStepSize(step_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverlapSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setOverlapSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float overlap_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverlapSize'",NULL);
+#endif
+ {
+  self->setOverlapSize(overlap_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setScrollPosition of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setScrollPosition00
+static int tolua_CEGUI_CEGUI_Scrollbar_setScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float position = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setScrollPosition'",NULL);
+#endif
+ {
+  self->setScrollPosition(position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isContentPaneAutoSized of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_isContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_isContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledContainer* self = (const CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isContentPaneAutoSized'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isContentPaneAutoSized();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentPaneAutoSized of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_setContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_setContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledContainer* self = (CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentPaneAutoSized'",NULL);
+#endif
+ {
+  self->setContentPaneAutoSized(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentArea of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_getContentArea00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_getContentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledContainer* self = (const CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentArea'",NULL);
+#endif
+ {
+  const CEGUI::Rect& tolua_ret = (const CEGUI::Rect&)  self->getContentArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentArea of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_setContentArea00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_setContentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledContainer* self = (CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentArea'",NULL);
+#endif
+ {
+  self->setContentArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildExtentsArea of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_getChildExtentsArea00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_getChildExtentsArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledContainer* self = (const CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildExtentsArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getChildExtentsArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildExtentsArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentPane of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getContentPane00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getContentPane00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentPane'",NULL);
+#endif
+ {
+  const CEGUI::ScrolledContainer* tolua_ret = (const CEGUI::ScrolledContainer*)  self->getContentPane();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::ScrolledContainer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentPane'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrollablePane_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrollablePane_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isContentPaneAutoSized of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_isContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrollablePane_isContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isContentPaneAutoSized'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isContentPaneAutoSized();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentPaneAutoSized of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentPaneAutoSized'",NULL);
+#endif
+ {
+  self->setContentPaneAutoSized(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentPaneArea of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getContentPaneArea00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getContentPaneArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentPaneArea'",NULL);
+#endif
+ {
+  const CEGUI::Rect& tolua_ret = (const CEGUI::Rect&)  self->getContentPaneArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentPaneArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentPaneArea of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneArea00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentPaneArea'",NULL);
+#endif
+ {
+  self->setContentPaneArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentPaneArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHorizontalStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalStepSize'",NULL);
+#endif
+ {
+  self->setHorizontalStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalOverlapSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHorizontalOverlapSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float overlap = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalOverlapSize'",NULL);
+#endif
+ {
+  self->setHorizontalOverlapSize(overlap);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalScrollPosition'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHorizontalScrollPosition();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float position = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalScrollPosition'",NULL);
+#endif
+ {
+  self->setHorizontalScrollPosition(position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVerticalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVerticalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getVerticalStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setVerticalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setVerticalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalStepSize'",NULL);
+#endif
+ {
+  self->setVerticalStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVerticalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVerticalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalOverlapSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getVerticalOverlapSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setVerticalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setVerticalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float overlap = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalOverlapSize'",NULL);
+#endif
+ {
+  self->setVerticalOverlapSize(overlap);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVerticalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVerticalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalScrollPosition'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getVerticalScrollPosition();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setVerticalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setVerticalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float position = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalScrollPosition'",NULL);
+#endif
+ {
+  self->setVerticalScrollPosition(position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getViewableArea of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getViewableArea00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getViewableArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getViewableArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getViewableArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getViewableArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_getCurrentValue00
+static int tolua_CEGUI_CEGUI_Slider_getCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Slider* self = (const CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getCurrentValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_getMaxValue00
+static int tolua_CEGUI_CEGUI_Slider_getMaxValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Slider* self = (const CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMaxValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getClickStep of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_getClickStep00
+static int tolua_CEGUI_CEGUI_Slider_getClickStep00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Slider* self = (const CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getClickStep'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getClickStep();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getClickStep'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_setMaxValue00
+static int tolua_CEGUI_CEGUI_Slider_setMaxValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Slider* self = (CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+  float maxVal = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxValue'",NULL);
+#endif
+ {
+  self->setMaxValue(maxVal);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCurrentValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_setCurrentValue00
+static int tolua_CEGUI_CEGUI_Slider_setCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Slider* self = (CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+  float value = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCurrentValue'",NULL);
+#endif
+ {
+  self->setCurrentValue(value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClickStep of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_setClickStep00
+static int tolua_CEGUI_CEGUI_Slider_setClickStep00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Slider* self = (CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClickStep'",NULL);
+#endif
+ {
+  self->setClickStep(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClickStep'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getCurrentValue00
+static int tolua_CEGUI_CEGUI_Spinner_getCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getCurrentValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStepSize of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getStepSize00
+static int tolua_CEGUI_CEGUI_Spinner_getStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaximumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getMaximumValue00
+static int tolua_CEGUI_CEGUI_Spinner_getMaximumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaximumValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMaximumValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaximumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMinimumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getMinimumValue00
+static int tolua_CEGUI_CEGUI_Spinner_getMinimumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMinimumValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMinimumValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMinimumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextInputMode of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getTextInputMode00
+static int tolua_CEGUI_CEGUI_Spinner_getTextInputMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextInputMode'",NULL);
+#endif
+ {
+  CEGUI::Spinner::TextInputMode tolua_ret = (CEGUI::Spinner::TextInputMode)  self->getTextInputMode();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextInputMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCurrentValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setCurrentValue00
+static int tolua_CEGUI_CEGUI_Spinner_setCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float value = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCurrentValue'",NULL);
+#endif
+ {
+  self->setCurrentValue(value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setStepSize of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setStepSize00
+static int tolua_CEGUI_CEGUI_Spinner_setStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setStepSize'",NULL);
+#endif
+ {
+  self->setStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaximumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setMaximumValue00
+static int tolua_CEGUI_CEGUI_Spinner_setMaximumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float maxValue = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaximumValue'",NULL);
+#endif
+ {
+  self->setMaximumValue(maxValue);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaximumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMinimumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setMinimumValue00
+static int tolua_CEGUI_CEGUI_Spinner_setMinimumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float minVaue = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMinimumValue'",NULL);
+#endif
+ {
+  self->setMinimumValue(minVaue);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMinimumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextInputMode of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setTextInputMode00
+static int tolua_CEGUI_CEGUI_Spinner_setTextInputMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Spinner::TextInputMode mode = ((CEGUI::Spinner::TextInputMode) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextInputMode'",NULL);
+#endif
+ {
+  self->setTextInputMode(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextInputMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getProgress of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_getProgress00
+static int tolua_CEGUI_CEGUI_ProgressBar_getProgress00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ProgressBar* self = (const CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getProgress'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getProgress();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getProgress'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStep of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_getStep00
+static int tolua_CEGUI_CEGUI_ProgressBar_getStep00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ProgressBar* self = (const CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStep'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getStep();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStep'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setProgress of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_setProgress00
+static int tolua_CEGUI_CEGUI_ProgressBar_setProgress00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+  float progress = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setProgress'",NULL);
+#endif
+ {
+  self->setProgress(progress);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setProgress'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setStepSize of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_setStepSize00
+static int tolua_CEGUI_CEGUI_ProgressBar_setStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setStepSize'",NULL);
+#endif
+ {
+  self->setStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: step of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_step00
+static int tolua_CEGUI_CEGUI_ProgressBar_step00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'step'",NULL);
+#endif
+ {
+  self->step();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'step'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: adjustProgress of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_adjustProgress00
+static int tolua_CEGUI_CEGUI_ProgressBar_adjustProgress00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+  float delta = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'adjustProgress'",NULL);
+#endif
+ {
+  self->adjustProgress(delta);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'adjustProgress'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hasInputFocus of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_hasInputFocus00
+static int tolua_CEGUI_CEGUI_Editbox_hasInputFocus00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hasInputFocus'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->hasInputFocus();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hasInputFocus'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isReadOnly of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_isReadOnly00
+static int tolua_CEGUI_CEGUI_Editbox_isReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isReadOnly'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isReadOnly();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextMasked of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_isTextMasked00
+static int tolua_CEGUI_CEGUI_Editbox_isTextMasked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextMasked'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextMasked();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextMasked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextValid of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_isTextValid00
+static int tolua_CEGUI_CEGUI_Editbox_isTextValid00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextValid'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextValid();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextValid'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValidationString of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getValidationString00
+static int tolua_CEGUI_CEGUI_Editbox_getValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValidationString'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getValidationString();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaratIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getCaratIndex00
+static int tolua_CEGUI_CEGUI_Editbox_getCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCaratIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCaratIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionStartIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getSelectionStartIndex00
+static int tolua_CEGUI_CEGUI_Editbox_getSelectionStartIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionStartIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionStartIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionStartIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionEndIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getSelectionEndIndex00
+static int tolua_CEGUI_CEGUI_Editbox_getSelectionEndIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionEndIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionEndIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionEndIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionLength of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getSelectionLength00
+static int tolua_CEGUI_CEGUI_Editbox_getSelectionLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaskCodePoint of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getMaskCodePoint00
+static int tolua_CEGUI_CEGUI_Editbox_getMaskCodePoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaskCodePoint'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaskCodePoint();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaskCodePoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextLength of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getMaxTextLength00
+static int tolua_CEGUI_CEGUI_Editbox_getMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaxTextLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setReadOnly of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setReadOnly00
+static int tolua_CEGUI_CEGUI_Editbox_setReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setReadOnly'",NULL);
+#endif
+ {
+  self->setReadOnly(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextMasked of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setTextMasked00
+static int tolua_CEGUI_CEGUI_Editbox_setTextMasked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextMasked'",NULL);
+#endif
+ {
+  self->setTextMasked(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextMasked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setValidationString of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setValidationString00
+static int tolua_CEGUI_CEGUI_Editbox_setValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  string validation_string = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setValidationString'",NULL);
+#endif
+ {
+  self->setValidationString(validation_string);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCaratIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setCaratIndex00
+static int tolua_CEGUI_CEGUI_Editbox_setCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long carat_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCaratIndex'",NULL);
+#endif
+ {
+  self->setCaratIndex(carat_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelection of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setSelection00
+static int tolua_CEGUI_CEGUI_Editbox_setSelection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long end_pos = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelection'",NULL);
+#endif
+ {
+  self->setSelection(start_pos,end_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaskCodePoint of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setMaskCodePoint00
+static int tolua_CEGUI_CEGUI_Editbox_setMaskCodePoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long code_point = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaskCodePoint'",NULL);
+#endif
+ {
+  self->setMaskCodePoint(code_point);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaskCodePoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxTextLength of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setMaxTextLength00
+static int tolua_CEGUI_CEGUI_Editbox_setMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long max_len = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxTextLength'",NULL);
+#endif
+ {
+  self->setMaxTextLength(max_len);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hasInputFocus of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_hasInputFocus00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_hasInputFocus00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hasInputFocus'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->hasInputFocus();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hasInputFocus'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isReadOnly of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_isReadOnly00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_isReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isReadOnly'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isReadOnly();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaratIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getCaratIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCaratIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCaratIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionStartIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionStartIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionStartIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionStartIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionStartIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionStartIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionEndIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionEndIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionEndIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionEndIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionEndIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionEndIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionLength of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionLength00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextLength of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getMaxTextLength00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaxTextLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isWordWrapped of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_isWordWrapped00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_isWordWrapped00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isWordWrapped'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isWordWrapped();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isWordWrapped'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextRenderArea of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getTextRenderArea00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getTextRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getTextRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLineNumberFromIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getLineNumberFromIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getLineNumberFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLineNumberFromIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getLineNumberFromIndex(index);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLineNumberFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setReadOnly of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setReadOnly00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setReadOnly'",NULL);
+#endif
+ {
+  self->setReadOnly(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCaratIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setCaratIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long carat_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCaratIndex'",NULL);
+#endif
+ {
+  self->setCaratIndex(carat_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelection of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setSelection00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setSelection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long end_pos = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelection'",NULL);
+#endif
+ {
+  self->setSelection(start_pos,end_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxTextLength of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setMaxTextLength00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long max_len = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxTextLength'",NULL);
+#endif
+ {
+  self->setMaxTextLength(max_len);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ensureCaratIsVisible of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_ensureCaratIsVisible00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_ensureCaratIsVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ensureCaratIsVisible'",NULL);
+#endif
+ {
+  self->ensureCaratIsVisible();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ensureCaratIsVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWordWrapping of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setWordWrapping00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setWordWrapping00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWordWrapping'",NULL);
+#endif
+ {
+  self->setWordWrapping(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWordWrapping'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionBrushImage of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionBrushImage'",NULL);
+#endif
+ {
+  self->setSelectionBrushImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionBrushImage of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionBrushImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getSelectionBrushImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getText of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getText00
+static int tolua_CEGUI_CEGUI_ListboxItem_getText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getID of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getID00
+static int tolua_CEGUI_CEGUI_ListboxItem_getID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUserData of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getUserData00
+static int tolua_CEGUI_CEGUI_ListboxItem_getUserData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUserData'",NULL);
+#endif
+ {
+  void* tolua_ret = (void*)  self->getUserData();
+ tolua_pushuserdata(tolua_S,(void*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUserData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_isSelected00
+static int tolua_CEGUI_CEGUI_ListboxItem_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDisabled of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_isDisabled00
+static int tolua_CEGUI_CEGUI_ListboxItem_isDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDisabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDisabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoDeleted of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_isAutoDeleted00
+static int tolua_CEGUI_CEGUI_ListboxItem_isAutoDeleted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoDeleted'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoDeleted();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoDeleted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOwnerWindow of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getOwnerWindow00
+static int tolua_CEGUI_CEGUI_ListboxItem_getOwnerWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOwnerWindow'",NULL);
+#endif
+ {
+  const CEGUI::Window* tolua_ret = (const CEGUI::Window*)  self->getOwnerWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOwnerWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getSelectionColours00
+static int tolua_CEGUI_CEGUI_ListboxItem_getSelectionColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionColours'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getSelectionColours();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionBrushImage of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_ListboxItem_getSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionBrushImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getSelectionBrushImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setText of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setText00
+static int tolua_CEGUI_CEGUI_ListboxItem_setText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setText'",NULL);
+#endif
+ {
+  self->setText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setID of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setID00
+static int tolua_CEGUI_CEGUI_ListboxItem_setID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int item_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setID'",NULL);
+#endif
+ {
+  self->setID(item_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserData of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setUserData00
+static int tolua_CEGUI_CEGUI_ListboxItem_setUserData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isuserdata(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  void* item_data = ((void*)  tolua_touserdata(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserData'",NULL);
+#endif
+ {
+  self->setUserData(item_data);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelected00
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDisabled of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setDisabled00
+static int tolua_CEGUI_CEGUI_ListboxItem_setDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDisabled'",NULL);
+#endif
+ {
+  self->setDisabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoDeleted of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setAutoDeleted00
+static int tolua_CEGUI_CEGUI_ListboxItem_setAutoDeleted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoDeleted'",NULL);
+#endif
+ {
+  self->setAutoDeleted(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoDeleted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOwnerWindow of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setOwnerWindow00
+static int tolua_CEGUI_CEGUI_ListboxItem_setOwnerWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* owner = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOwnerWindow'",NULL);
+#endif
+ {
+  self->setOwnerWindow(owner);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOwnerWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour top_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::colour top_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::colour bottom_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  CEGUI::colour bottom_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(top_left_colour,top_right_colour,bottom_left_colour,bottom_right_colour);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours02
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour col = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(col);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionBrushImage of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionBrushImage'",NULL);
+#endif
+ {
+  self->setSelectionBrushImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionBrushImage of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage01
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionBrushImage'",NULL);
+#endif
+ {
+  self->setSelectionBrushImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelSize of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getPixelSize00
+static int tolua_CEGUI_CEGUI_ListboxItem_getPixelSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getPixelSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_getFont00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxTextItem* self = (const CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getFont();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_getTextColours00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_getTextColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxTextItem* self = (const CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextColours'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getTextColours();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setFont00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  string font_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font_name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setFont01
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxTextItem_setFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour top_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::colour top_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::colour bottom_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  CEGUI::colour bottom_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(top_left_colour,top_right_colour,bottom_left_colour,bottom_right_colour);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(*cols);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours02
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour col = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(col);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleClickEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSingleClickEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_getSingleClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSingleClickEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->getSingleClickEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDropDownListVisible of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isDropDownListVisible00
+static int tolua_CEGUI_CEGUI_Combobox_isDropDownListVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDropDownListVisible'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDropDownListVisible();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDropDownListVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getEditbox of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getEditbox00
+static int tolua_CEGUI_CEGUI_Combobox_getEditbox00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getEditbox'",NULL);
+#endif
+ {
+  CEGUI::Editbox* tolua_ret = (CEGUI::Editbox*)  self->getEditbox();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Editbox");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEditbox'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPushButton of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getPushButton00
+static int tolua_CEGUI_CEGUI_Combobox_getPushButton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPushButton'",NULL);
+#endif
+ {
+  CEGUI::PushButton* tolua_ret = (CEGUI::PushButton*)  self->getPushButton();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PushButton");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPushButton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDropList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getDropList00
+static int tolua_CEGUI_CEGUI_Combobox_getDropList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDropList'",NULL);
+#endif
+ {
+  CEGUI::ComboDropList* tolua_ret = (CEGUI::ComboDropList*)  self->getDropList();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ComboDropList");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDropList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hasInputFocus of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_hasInputFocus00
+static int tolua_CEGUI_CEGUI_Combobox_hasInputFocus00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hasInputFocus'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->hasInputFocus();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hasInputFocus'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isReadOnly of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isReadOnly00
+static int tolua_CEGUI_CEGUI_Combobox_isReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isReadOnly'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isReadOnly();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextValid of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isTextValid00
+static int tolua_CEGUI_CEGUI_Combobox_isTextValid00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextValid'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextValid();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextValid'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValidationString of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getValidationString00
+static int tolua_CEGUI_CEGUI_Combobox_getValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValidationString'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getValidationString();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaratIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getCaratIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCaratIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCaratIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionStartIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectionStartIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectionStartIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionStartIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionStartIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionStartIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionEndIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectionEndIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectionEndIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionEndIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionEndIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionEndIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionLength of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectionLength00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectionLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextLength of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getMaxTextLength00
+static int tolua_CEGUI_CEGUI_Combobox_getMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaxTextLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: activateEditbox of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_activateEditbox00
+static int tolua_CEGUI_CEGUI_Combobox_activateEditbox00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'activateEditbox'",NULL);
+#endif
+ {
+  self->activateEditbox();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'activateEditbox'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getItemCount00
+static int tolua_CEGUI_CEGUI_Combobox_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectedItem00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListboxItemFromIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getListboxItemFromIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getListboxItemFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListboxItemFromIndex'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getListboxItemFromIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListboxItemFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getItemIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getItemIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isItemSelected00
+static int tolua_CEGUI_CEGUI_Combobox_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(index);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findItemWithText of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_findItemWithText00
+static int tolua_CEGUI_CEGUI_Combobox_findItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isListboxItemInList00
+static int tolua_CEGUI_CEGUI_Combobox_isListboxItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_resetList00
+static int tolua_CEGUI_CEGUI_Combobox_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_addItem00
+static int tolua_CEGUI_CEGUI_Combobox_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_insertItem00
+static int tolua_CEGUI_CEGUI_Combobox_insertItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ListboxItem* position = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertItem'",NULL);
+#endif
+ {
+  self->insertItem(item,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_removeItem00
+static int tolua_CEGUI_CEGUI_Combobox_removeItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeItem'",NULL);
+#endif
+ {
+  self->removeItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_clearAllSelections00
+static int tolua_CEGUI_CEGUI_Combobox_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortingEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setSortingEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_setSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortingEnabled'",NULL);
+#endif
+ {
+  self->setSortingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_Combobox_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_Combobox_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setItemSelectState00
+static int tolua_CEGUI_CEGUI_Combobox_setItemSelectState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item,state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSelectState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setItemSelectState01
+static int tolua_CEGUI_CEGUI_Combobox_setItemSelectState01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long item_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item_index,state);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Combobox_setItemSelectState00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedListItemData of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_handleUpdatedListItemData00
+static int tolua_CEGUI_CEGUI_Combobox_handleUpdatedListItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedListItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedListItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedListItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isSortEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_isSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Combobox_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Combobox_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: showDropList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_showDropList00
+static int tolua_CEGUI_CEGUI_Combobox_showDropList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'showDropList'",NULL);
+#endif
+ {
+  self->showDropList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'showDropList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hideDropList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_hideDropList00
+static int tolua_CEGUI_CEGUI_Combobox_hideDropList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hideDropList'",NULL);
+#endif
+ {
+  self->hideDropList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hideDropList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSingleClickEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setSingleClickEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_setSingleClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSingleClickEnabled'",NULL);
+#endif
+ {
+  self->setSingleClickEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSingleClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setReadOnly of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setReadOnly00
+static int tolua_CEGUI_CEGUI_Combobox_setReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setReadOnly'",NULL);
+#endif
+ {
+  self->setReadOnly(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setValidationString of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setValidationString00
+static int tolua_CEGUI_CEGUI_Combobox_setValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  string validation_string = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setValidationString'",NULL);
+#endif
+ {
+  self->setValidationString(validation_string);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCaratIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setCaratIndex00
+static int tolua_CEGUI_CEGUI_Combobox_setCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long carat_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCaratIndex'",NULL);
+#endif
+ {
+  self->setCaratIndex(carat_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelection of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setSelection00
+static int tolua_CEGUI_CEGUI_Combobox_setSelection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long end_pos = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelection'",NULL);
+#endif
+ {
+  self->setSelection(start_pos,end_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxTextLength of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setMaxTextLength00
+static int tolua_CEGUI_CEGUI_Combobox_setMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long max_len = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxTextLength'",NULL);
+#endif
+ {
+  self->setMaxTextLength(max_len);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getItemCount00
+static int tolua_CEGUI_CEGUI_Listbox_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedCount of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getSelectedCount00
+static int tolua_CEGUI_CEGUI_Listbox_getSelectedCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectedCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFirstSelectedItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getFirstSelectedItem00
+static int tolua_CEGUI_CEGUI_Listbox_getFirstSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFirstSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getFirstSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFirstSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelected of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getNextSelected00
+static int tolua_CEGUI_CEGUI_Listbox_getNextSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelected'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getNextSelected(start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListboxItemFromIndex of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getListboxItemFromIndex00
+static int tolua_CEGUI_CEGUI_Listbox_getListboxItemFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListboxItemFromIndex'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getListboxItemFromIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListboxItemFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemIndex of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getItemIndex00
+static int tolua_CEGUI_CEGUI_Listbox_getItemIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findItemWithText of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_findItemWithText00
+static int tolua_CEGUI_CEGUI_Listbox_findItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isSortEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_isSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMultiselectEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isMultiselectEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_isMultiselectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMultiselectEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMultiselectEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMultiselectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isItemSelected00
+static int tolua_CEGUI_CEGUI_Listbox_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(index);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInList of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isListboxItemInList00
+static int tolua_CEGUI_CEGUI_Listbox_isListboxItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Listbox_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Listbox_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_resetList00
+static int tolua_CEGUI_CEGUI_Listbox_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_addItem00
+static int tolua_CEGUI_CEGUI_Listbox_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_insertItem00
+static int tolua_CEGUI_CEGUI_Listbox_insertItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ListboxItem* position = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertItem'",NULL);
+#endif
+ {
+  self->insertItem(item,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_removeItem00
+static int tolua_CEGUI_CEGUI_Listbox_removeItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeItem'",NULL);
+#endif
+ {
+  self->removeItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_clearAllSelections00
+static int tolua_CEGUI_CEGUI_Listbox_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortingEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setSortingEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_setSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortingEnabled'",NULL);
+#endif
+ {
+  self->setSortingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiselectEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setMultiselectEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_setMultiselectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiselectEnabled'",NULL);
+#endif
+ {
+  self->setMultiselectEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiselectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setItemSelectState00
+static int tolua_CEGUI_CEGUI_Listbox_setItemSelectState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item,state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSelectState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setItemSelectState01
+static int tolua_CEGUI_CEGUI_Listbox_setItemSelectState01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long item_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item_index,state);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Listbox_setItemSelectState00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedItemData of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_handleUpdatedItemData00
+static int tolua_CEGUI_CEGUI_Listbox_handleUpdatedItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ensureItemIsVisible of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00
+static int tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long item_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ensureItemIsVisible'",NULL);
+#endif
+ {
+  self->ensureItemIsVisible(item_index);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ensureItemIsVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ensureItemIsVisible of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible01
+static int tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ensureItemIsVisible'",NULL);
+#endif
+ {
+  self->ensureItemIsVisible(item);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListRenderArea of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getListRenderArea00
+static int tolua_CEGUI_CEGUI_Listbox_getListRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getListRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidestItemWidth of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getWidestItemWidth00
+static int tolua_CEGUI_CEGUI_Listbox_getWidestItemWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidestItemWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidestItemWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidestItemWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalItemsHeight of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getTotalItemsHeight00
+static int tolua_CEGUI_CEGUI_Listbox_getTotalItemsHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalItemsHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTotalItemsHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalItemsHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArmed of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_setArmed00
+static int tolua_CEGUI_CEGUI_ComboDropList_setArmed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ComboDropList* self = (CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArmed'",NULL);
+#endif
+ {
+  self->setArmed(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setArmed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isArmed of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_isArmed00
+static int tolua_CEGUI_CEGUI_ComboDropList_isArmed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComboDropList* self = (const CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isArmed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isArmed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isArmed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoArmEnabled of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_setAutoArmEnabled00
+static int tolua_CEGUI_CEGUI_ComboDropList_setAutoArmEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ComboDropList* self = (CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoArmEnabled'",NULL);
+#endif
+ {
+  self->setAutoArmEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoArmEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoArmEnabled of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_isAutoArmEnabled00
+static int tolua_CEGUI_CEGUI_ComboDropList_isAutoArmEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComboDropList* self = (const CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoArmEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoArmEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoArmEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSizingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_isSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_isSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortDirection of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_getSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_getSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortDirection'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment::SortDirection tolua_ret = (CEGUI::ListHeaderSegment::SortDirection)  self->getSortDirection();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDragMovingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_isDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_isDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDragMovingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDragMovingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDragMoveOffset of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_getDragMoveOffset00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_getDragMoveOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDragMoveOffset'",NULL);
+#endif
+ {
+  const CEGUI::Vector2& tolua_ret = (const CEGUI::Vector2&)  self->getDragMoveOffset();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Vector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDragMoveOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isClickable of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_isClickable00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_isClickable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isClickable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isClickable();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isClickable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSizingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSizingEnabled'",NULL);
+#endif
+ {
+  self->setSizingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortDirection of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListHeaderSegment::SortDirection sort_dir = ((CEGUI::ListHeaderSegment::SortDirection) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortDirection'",NULL);
+#endif
+ {
+  self->setSortDirection(sort_dir);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragMovingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragMovingEnabled'",NULL);
+#endif
+ {
+  self->setDragMovingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClickable of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setClickable00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setClickable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClickable'",NULL);
+#endif
+ {
+  self->setClickable(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClickable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnCount of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnCount00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSegmentFromColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSegmentFromColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_getSegmentFromColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSegmentFromColumn'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getSegmentFromColumn(column);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSegmentFromColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSegmentFromID of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSegmentFromID00
+static int tolua_CEGUI_CEGUI_ListHeader_getSegmentFromID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSegmentFromID'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getSegmentFromID(id);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSegmentFromID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSortSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_getSortSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortSegment'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getSortSegment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnFromSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnFromSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnFromSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnFromSegment'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnFromSegment(*segment);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnFromSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnFromID of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnFromID00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnFromID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnFromID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnFromID(id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnFromID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSortColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_getSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortColumn'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSortColumn();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWithText of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnWithText00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWithText'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnWithText(text);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelOffsetToSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelOffsetToSegment'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPixelOffsetToSegment(*segment);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelOffsetToSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelOffsetToColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelOffsetToColumn'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPixelOffsetToColumn(column);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelOffsetToColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalSegmentsPixelExtent of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getTotalSegmentsPixelExtent00
+static int tolua_CEGUI_CEGUI_ListHeader_getTotalSegmentsPixelExtent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalSegmentsPixelExtent'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTotalSegmentsPixelExtent();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalSegmentsPixelExtent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWidth of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnWidth00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getColumnWidth(column);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortDirection of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeader_getSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortDirection'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment::SortDirection tolua_ret = (CEGUI::ListHeaderSegment::SortDirection)  self->getSortDirection();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_isSortingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_isSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isColumnSizingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_isColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_isColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isColumnSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isColumnSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isColumnDraggingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_isColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_isColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isColumnDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isColumnDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSegmentOffset of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSegmentOffset00
+static int tolua_CEGUI_CEGUI_ListHeader_getSegmentOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSegmentOffset'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getSegmentOffset();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSegmentOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortingEnabled'",NULL);
+#endif
+ {
+  self->setSortingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortDirection of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListHeaderSegment::SortDirection direction = ((CEGUI::ListHeaderSegment::SortDirection) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortDirection'",NULL);
+#endif
+ {
+  self->setSortDirection(direction);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortSegment'",NULL);
+#endif
+ {
+  self->setSortSegment(*segment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumn'",NULL);
+#endif
+ {
+  self->setSortColumn(column);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumnFromID of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortColumnFromID00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortColumnFromID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumnFromID'",NULL);
+#endif
+ {
+  self->setSortColumnFromID(id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumnFromID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnSizingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_setColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnSizingEnabled'",NULL);
+#endif
+ {
+  self->setColumnSizingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnDraggingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_setColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnDraggingEnabled'",NULL);
+#endif
+ {
+  self->setColumnDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_addColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_addColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addColumn'",NULL);
+#endif
+ {
+  self->addColumn(text,id,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_insertColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_insertColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertColumn'",NULL);
+#endif
+ {
+  self->insertColumn(text,id,*width,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_insertColumn01
+static int tolua_CEGUI_CEGUI_ListHeader_insertColumn01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::ListHeaderSegment* position = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertColumn'",NULL);
+#endif
+ {
+  self->insertColumn(text,id,*width,*position);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListHeader_insertColumn00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_removeColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_removeColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeColumn'",NULL);
+#endif
+ {
+  self->removeColumn(column);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_removeSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_removeSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeSegment'",NULL);
+#endif
+ {
+  self->removeSegment(*segment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_moveColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumn'",NULL);
+#endif
+ {
+  self->moveColumn(column,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveColumn01
+static int tolua_CEGUI_CEGUI_ListHeader_moveColumn01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::ListHeaderSegment* position = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumn'",NULL);
+#endif
+ {
+  self->moveColumn(column,*position);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListHeader_moveColumn00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_moveSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveSegment'",NULL);
+#endif
+ {
+  self->moveSegment(*segment,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveSegment01
+static int tolua_CEGUI_CEGUI_ListHeader_moveSegment01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ListHeaderSegment* position = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveSegment'",NULL);
+#endif
+ {
+  self->moveSegment(*segment,*position);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListHeader_moveSegment00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSegmentOffset of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSegmentOffset00
+static int tolua_CEGUI_CEGUI_ListHeader_setSegmentOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  float offset = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSegmentOffset'",NULL);
+#endif
+ {
+  self->setSegmentOffset(offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSegmentOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnWidth of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setColumnWidth00
+static int tolua_CEGUI_CEGUI_ListHeader_setColumnWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnWidth'",NULL);
+#endif
+ {
+  self->setColumnWidth(column,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: row of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MCLGridRef_unsigned_row
+static int tolua_get_CEGUI__MCLGridRef_unsigned_row(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'row'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->row);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: row of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MCLGridRef_unsigned_row
+static int tolua_set_CEGUI__MCLGridRef_unsigned_row(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'row'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->row = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: column of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MCLGridRef_unsigned_column
+static int tolua_get_CEGUI__MCLGridRef_unsigned_column(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'column'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->column);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: column of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MCLGridRef_unsigned_column
+static int tolua_set_CEGUI__MCLGridRef_unsigned_column(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'column'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->column = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MCLGridRef__eq00
+static int tolua_CEGUI_CEGUI_MCLGridRef__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MCLGridRef* self = (const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* rhs = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MCLGridRef_new00
+static int tolua_CEGUI_CEGUI_MCLGridRef_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int r = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int c = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::MCLGridRef* tolua_ret = (CEGUI::MCLGridRef*)  new CEGUI::MCLGridRef(r,c);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MCLGridRef");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MCLGridRef_new00_local
+static int tolua_CEGUI_CEGUI_MCLGridRef_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int r = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int c = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::MCLGridRef* tolua_ret = (CEGUI::MCLGridRef*)  new CEGUI::MCLGridRef(r,c);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::MCLGridRef");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserSortControlEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isUserSortControlEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isUserSortControlEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserSortControlEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserSortControlEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserSortControlEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserColumnSizingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserColumnSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserColumnSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserColumnDraggingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserColumnDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserColumnDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnCount of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnCount00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRowCount of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getRowCount00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getRowCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRowCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getRowCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRowCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSortColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortColumn'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSortColumn();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWithID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnWithID(col_id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWithHeaderText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithHeaderText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithHeaderText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWithHeaderText'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnWithHeaderText(text);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWithHeaderText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalColumnHeadersWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getTotalColumnHeadersWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getTotalColumnHeadersWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalColumnHeadersWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getTotalColumnHeadersWidth();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalColumnHeadersWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnHeaderWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnHeaderWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnHeaderWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnHeaderWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getColumnHeaderWidth(col_idx);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnHeaderWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortDirection of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSortDirection00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortDirection'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment::SortDirection tolua_ret = (CEGUI::ListHeaderSegment::SortDirection)  self->getSortDirection();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeaderSegmentForColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getHeaderSegmentForColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getHeaderSegmentForColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeaderSegmentForColumn'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getHeaderSegmentForColumn(col_idx);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeaderSegmentForColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemRowIndex of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemRowIndex00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemRowIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemRowIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemRowIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemRowIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemColumnIndex of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemColumnIndex00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemColumnIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemColumnIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemColumnIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemColumnIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemGridReference of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemGridReference00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemGridReference00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemGridReference'",NULL);
+#endif
+ {
+  CEGUI::MCLGridRef tolua_ret = (CEGUI::MCLGridRef)  self->getItemGridReference(item);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::MCLGridRef(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::MCLGridRef");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::MCLGridRef));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::MCLGridRef");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemGridReference'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemAtGridReference of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemAtGridReference00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemAtGridReference00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* grid_ref = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemAtGridReference'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getItemAtGridReference(*grid_ref);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemAtGridReference'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInColumn'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInColumn(item,col_idx);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInRow'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInRow(item,row_idx);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInList of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInList00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findColumnItemWithText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_findColumnItemWithText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_findColumnItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findColumnItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findColumnItemWithText(text,col_idx,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findColumnItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findRowItemWithText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_findRowItemWithText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_findRowItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findRowItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findRowItemWithText(text,row_idx,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findRowItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findListItemWithText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_findListItemWithText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_findListItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findListItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findListItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findListItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFirstSelectedItem of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getFirstSelectedItem00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getFirstSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFirstSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getFirstSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFirstSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelected of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNextSelected00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNextSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelected'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getNextSelected(start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedCount of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSelectedCount00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSelectedCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSelectedCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isItemSelected00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* grid_ref = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(*grid_ref);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNominatedSelectionColumnID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumnID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumnID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNominatedSelectionColumnID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getNominatedSelectionColumnID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNominatedSelectionColumnID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNominatedSelectionColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNominatedSelectionColumn'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getNominatedSelectionColumn();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNominatedSelectionColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNominatedSelectionRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNominatedSelectionRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getNominatedSelectionRow();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNominatedSelectionRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionMode of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSelectionMode00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSelectionMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionMode'",NULL);
+#endif
+ {
+  CEGUI::MultiColumnList::SelectionMode tolua_ret = (CEGUI::MultiColumnList::SelectionMode)  self->getSelectionMode();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnID(col_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRowID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getRowID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getRowID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRowID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getRowID(row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRowID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRowWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getRowWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getRowWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRowWithID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getRowWithID(row_id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRowWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListRenderArea of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getListRenderArea00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getListRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getListRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListHeader of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getListHeader00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getListHeader00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListHeader'",NULL);
+#endif
+ {
+  CEGUI::ListHeader* tolua_ret = (CEGUI::ListHeader*)  self->getListHeader();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListHeader");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListHeader'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalRowsHeight of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getTotalRowsHeight00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getTotalRowsHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalRowsHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTotalRowsHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalRowsHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidestColumnItemWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getWidestColumnItemWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getWidestColumnItemWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidestColumnItemWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidestColumnItemWidth(col_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidestColumnItemWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHighestRowItemHeight of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getHighestRowItemHeight00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getHighestRowItemHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHighestRowItemHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHighestRowItemHeight(row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHighestRowItemHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_resetList00
+static int tolua_CEGUI_CEGUI_MultiColumnList_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_addColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_addColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addColumn'",NULL);
+#endif
+ {
+  self->addColumn(text,col_id,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_insertColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_insertColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertColumn'",NULL);
+#endif
+ {
+  self->insertColumn(text,col_id,*width,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_removeColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_removeColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeColumn'",NULL);
+#endif
+ {
+  self->removeColumn(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeColumnWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_removeColumnWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_removeColumnWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeColumnWithID'",NULL);
+#endif
+ {
+  self->removeColumnWithID(col_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeColumnWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_moveColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_moveColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumn'",NULL);
+#endif
+ {
+  self->moveColumn(col_idx,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumnWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_moveColumnWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_moveColumnWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumnWithID'",NULL);
+#endif
+ {
+  self->moveColumnWithID(col_id,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveColumnWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_addRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_addRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->addRow();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_addRow01
+static int tolua_CEGUI_CEGUI_MultiColumnList_addRow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->addRow(item,col_id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_addRow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_insertRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_insertRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->insertRow(row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_insertRow01
+static int tolua_CEGUI_CEGUI_MultiColumnList_insertRow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->insertRow(item,col_id,row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_insertRow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_removeRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_removeRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeRow'",NULL);
+#endif
+ {
+  self->removeRow(row_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItem of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItem00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::MCLGridRef* position = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItem'",NULL);
+#endif
+ {
+  self->setItem(item,*position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItem of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItem01
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItem01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItem'",NULL);
+#endif
+ {
+  self->setItem(item,col_id,row_idx);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_setItem00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionMode of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSelectionMode00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSelectionMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MultiColumnList::SelectionMode sel_mode = ((CEGUI::MultiColumnList::SelectionMode) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionMode'",NULL);
+#endif
+ {
+  self->setSelectionMode(sel_mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNominatedSelectionColumnID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumnID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumnID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNominatedSelectionColumnID'",NULL);
+#endif
+ {
+  self->setNominatedSelectionColumnID(col_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNominatedSelectionColumnID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNominatedSelectionColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNominatedSelectionColumn'",NULL);
+#endif
+ {
+  self->setNominatedSelectionColumn(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNominatedSelectionColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNominatedSelectionRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNominatedSelectionRow'",NULL);
+#endif
+ {
+  self->setNominatedSelectionRow(row_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNominatedSelectionRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortDirection of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSortDirection00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListHeaderSegment::SortDirection direction = ((CEGUI::ListHeaderSegment::SortDirection) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortDirection'",NULL);
+#endif
+ {
+  self->setSortDirection(direction);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSortColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumn'",NULL);
+#endif
+ {
+  self->setSortColumn(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumnByID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSortColumnByID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSortColumnByID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumnByID'",NULL);
+#endif
+ {
+  self->setSortColumnByID(col_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumnByID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_clearAllSelections00
+static int tolua_CEGUI_CEGUI_MultiColumnList_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item,state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSelectState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState01
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* grid_ref = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(*grid_ref,state);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedItemData of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_handleUpdatedItemData00
+static int tolua_CEGUI_CEGUI_MultiColumnList_handleUpdatedItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnHeaderWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setColumnHeaderWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setColumnHeaderWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnHeaderWidth'",NULL);
+#endif
+ {
+  self->setColumnHeaderWidth(col_idx,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnHeaderWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserSortControlEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setUserSortControlEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setUserSortControlEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserSortControlEnabled'",NULL);
+#endif
+ {
+  self->setUserSortControlEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserSortControlEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserColumnSizingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserColumnSizingEnabled'",NULL);
+#endif
+ {
+  self->setUserColumnSizingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserColumnDraggingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserColumnDraggingEnabled'",NULL);
+#endif
+ {
+  self->setUserColumnDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: autoSizeColumnHeader of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_autoSizeColumnHeader00
+static int tolua_CEGUI_CEGUI_MultiColumnList_autoSizeColumnHeader00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'autoSizeColumnHeader'",NULL);
+#endif
+ {
+  self->autoSizeColumnHeader(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'autoSizeColumnHeader'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRowID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setRowID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setRowID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int row_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRowID'",NULL);
+#endif
+ {
+  self->setRowID(row_idx,row_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRowID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemPixelSize of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_getItemPixelSize00
+static int tolua_CEGUI_CEGUI_ItemEntry_getItemPixelSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemPixelSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getItemPixelSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemPixelSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOwnerList of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_getOwnerList00
+static int tolua_CEGUI_CEGUI_ItemEntry_getOwnerList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemEntry* self = (const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOwnerList'",NULL);
+#endif
+ {
+  CEGUI::ItemListBase* tolua_ret = (CEGUI::ItemListBase*)  self->getOwnerList();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemListBase");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOwnerList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_isSelected00
+static int tolua_CEGUI_CEGUI_ItemEntry_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemEntry* self = (const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelectable of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_isSelectable00
+static int tolua_CEGUI_CEGUI_ItemEntry_isSelectable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemEntry* self = (const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelectable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelectable();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelectable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_setSelected00
+static int tolua_CEGUI_CEGUI_ItemEntry_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: select of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_select00
+static int tolua_CEGUI_CEGUI_ItemEntry_select00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'select'",NULL);
+#endif
+ {
+  self->select();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'select'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: deselect of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_deselect00
+static int tolua_CEGUI_CEGUI_ItemEntry_deselect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'deselect'",NULL);
+#endif
+ {
+  self->deselect();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'deselect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectable of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_setSelectable00
+static int tolua_CEGUI_CEGUI_ItemEntry_setSelectable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectable'",NULL);
+#endif
+ {
+  self->setSelectable(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemCount00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemFromIndex of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemFromIndex00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int index = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemFromIndex'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getItemFromIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemIndex of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemIndex00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ItemEntry* item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findItemWithText of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_findItemWithText00
+static int tolua_CEGUI_CEGUI_ItemListBase_findItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ItemEntry* start_item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->findItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemInList of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_isItemInList00
+static int tolua_CEGUI_CEGUI_ItemListBase_isItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ItemEntry* item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoResizeEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_isAutoResizeEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_isAutoResizeEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoResizeEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoResizeEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoResizeEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_isSortEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_isSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortMode of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getSortMode00
+static int tolua_CEGUI_CEGUI_ItemListBase_getSortMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortMode'",NULL);
+#endif
+ {
+  CEGUI::ItemListBase::SortMode tolua_ret = (CEGUI::ItemListBase::SortMode)  self->getSortMode();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemRenderArea of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemRenderArea00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getItemRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentPane of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getContentPane00
+static int tolua_CEGUI_CEGUI_ItemListBase_getContentPane00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentPane'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getContentPane();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentPane'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_resetList00
+static int tolua_CEGUI_CEGUI_ItemListBase_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_addItem00
+static int tolua_CEGUI_CEGUI_ItemListBase_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemEntry* item = ((CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertItem of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_insertItem00
+static int tolua_CEGUI_CEGUI_ItemListBase_insertItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemEntry* item = ((CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ItemEntry* position = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertItem'",NULL);
+#endif
+ {
+  self->insertItem(item,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeItem of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_removeItem00
+static int tolua_CEGUI_CEGUI_ItemListBase_removeItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemEntry* item = ((CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeItem'",NULL);
+#endif
+ {
+  self->removeItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedItemData of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_handleUpdatedItemData00
+static int tolua_CEGUI_CEGUI_ItemListBase_handleUpdatedItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoResizeEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_setAutoResizeEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_setAutoResizeEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoResizeEnabled'",NULL);
+#endif
+ {
+  self->setAutoResizeEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoResizeEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: sizeToContent of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_sizeToContent00
+static int tolua_CEGUI_CEGUI_ItemListBase_sizeToContent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'sizeToContent'",NULL);
+#endif
+ {
+  self->sizeToContent();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'sizeToContent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_setSortEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_setSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortEnabled'",NULL);
+#endif
+ {
+  self->setSortEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortMode of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_setSortMode00
+static int tolua_CEGUI_CEGUI_ItemListBase_setSortMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemListBase::SortMode mode = ((CEGUI::ItemListBase::SortMode) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortMode'",NULL);
+#endif
+ {
+  self->setSortMode(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: sortList of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_sortList00
+static int tolua_CEGUI_CEGUI_ItemListBase_sortList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'sortList'",NULL);
+#endif
+ {
+  self->sortList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'sortList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemSpacing of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_getItemSpacing00
+static int tolua_CEGUI_CEGUI_MenuBase_getItemSpacing00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuBase* self = (const CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemSpacing'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getItemSpacing();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemSpacing'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMultiplePopupsAllowed of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_isMultiplePopupsAllowed00
+static int tolua_CEGUI_CEGUI_MenuBase_isMultiplePopupsAllowed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuBase* self = (const CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMultiplePopupsAllowed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMultiplePopupsAllowed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMultiplePopupsAllowed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPopupMenuItem of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_getPopupMenuItem00
+static int tolua_CEGUI_CEGUI_MenuBase_getPopupMenuItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuBase* self = (const CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPopupMenuItem'",NULL);
+#endif
+ {
+  CEGUI::MenuItem* tolua_ret = (CEGUI::MenuItem*)  self->getPopupMenuItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MenuItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPopupMenuItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSpacing of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_setItemSpacing00
+static int tolua_CEGUI_CEGUI_MenuBase_setItemSpacing00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuBase* self = (CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+  float spacing = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSpacing'",NULL);
+#endif
+ {
+  self->setItemSpacing(spacing);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSpacing'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: changePopupMenuItem of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_changePopupMenuItem00
+static int tolua_CEGUI_CEGUI_MenuBase_changePopupMenuItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuBase* self = (CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MenuItem* item = ((CEGUI::MenuItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'changePopupMenuItem'",NULL);
+#endif
+ {
+  self->changePopupMenuItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'changePopupMenuItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAllowMultiplePopups of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_setAllowMultiplePopups00
+static int tolua_CEGUI_CEGUI_MenuBase_setAllowMultiplePopups00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuBase* self = (CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAllowMultiplePopups'",NULL);
+#endif
+ {
+  self->setAllowMultiplePopups(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAllowMultiplePopups'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFadeInTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_getFadeInTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_getFadeInTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PopupMenu* self = (const CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFadeInTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFadeInTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFadeInTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFadeOutTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_getFadeOutTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_getFadeOutTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PopupMenu* self = (const CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFadeOutTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFadeOutTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFadeOutTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFadeInTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_setFadeInTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_setFadeInTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+  float fadetime = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFadeInTime'",NULL);
+#endif
+ {
+  self->setFadeInTime(fadetime);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFadeInTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFadeOutTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_setFadeOutTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_setFadeOutTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+  float fadetime = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFadeOutTime'",NULL);
+#endif
+ {
+  self->setFadeOutTime(fadetime);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFadeOutTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: openPopupMenu of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_openPopupMenu00
+static int tolua_CEGUI_CEGUI_PopupMenu_openPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'openPopupMenu'",NULL);
+#endif
+ {
+  self->openPopupMenu();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'openPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: closePopupMenu of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_closePopupMenu00
+static int tolua_CEGUI_CEGUI_PopupMenu_closePopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'closePopupMenu'",NULL);
+#endif
+ {
+  self->closePopupMenu();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'closePopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHovering of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_isHovering00
+static int tolua_CEGUI_CEGUI_MenuItem_isHovering00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuItem* self = (const CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHovering'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHovering();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHovering'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPushed of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_isPushed00
+static int tolua_CEGUI_CEGUI_MenuItem_isPushed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuItem* self = (const CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPushed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPushed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPushed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_getPopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_getPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuItem* self = (const CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPopupMenu'",NULL);
+#endif
+ {
+  CEGUI::PopupMenu* tolua_ret = (CEGUI::PopupMenu*)  self->getPopupMenu();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PopupMenu");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_setPopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_setPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::PopupMenu* popup = ((CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPopupMenu'",NULL);
+#endif
+ {
+  self->setPopupMenu(popup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: openPopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_openPopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_openPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'openPopupMenu'",NULL);
+#endif
+ {
+  self->openPopupMenu();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'openPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: closePopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_closePopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_closePopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+  bool notify = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'closePopupMenu'",NULL);
+#endif
+ {
+  self->closePopupMenu(notify);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'closePopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: togglePopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_togglePopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_togglePopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'togglePopupMenu'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->togglePopupMenu();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'togglePopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledItemListBase* self = (CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool mode = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledItemListBase* self = (CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool mode = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedCount of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getSelectedCount00
+static int tolua_CEGUI_CEGUI_ItemListbox_getSelectedCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectedCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLastSelectedItem of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getLastSelectedItem00
+static int tolua_CEGUI_CEGUI_ItemListbox_getLastSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLastSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getLastSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLastSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFirstSelectedItem of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getFirstSelectedItem00
+static int tolua_CEGUI_CEGUI_ItemListbox_getFirstSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFirstSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getFirstSelectedItem(start_index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFirstSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelectedItem of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItem00
+static int tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getNextSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelectedItemAfter of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItemAfter00
+static int tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItemAfter00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ItemEntry* start_item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelectedItemAfter'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getNextSelectedItemAfter(start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelectedItemAfter'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMultiSelectEnabled of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_isMultiSelectEnabled00
+static int tolua_CEGUI_CEGUI_ItemListbox_isMultiSelectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMultiSelectEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMultiSelectEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMultiSelectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_isItemSelected00
+static int tolua_CEGUI_CEGUI_ItemListbox_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(index);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiSelectEnabled of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_setMultiSelectEnabled00
+static int tolua_CEGUI_CEGUI_ItemListbox_setMultiSelectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  bool state = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiSelectEnabled'",NULL);
+#endif
+ {
+  self->setMultiSelectEnabled(state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiSelectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_clearAllSelections00
+static int tolua_CEGUI_CEGUI_ItemListbox_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: selectRange of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_selectRange00
+static int tolua_CEGUI_CEGUI_ItemListbox_selectRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long a = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long z = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'selectRange'",NULL);
+#endif
+ {
+  self->selectRange(a,z);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'selectRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: selectAllItems of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_selectAllItems00
+static int tolua_CEGUI_CEGUI_ItemListbox_selectAllItems00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'selectAllItems'",NULL);
+#endif
+ {
+  self->selectAllItems();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'selectAllItems'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValue of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getValue00
+static int tolua_CEGUI_CEGUI_BaseDim_getValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValue'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  float tolua_ret = (float)  self->getValue(*wnd);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'getValue'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValue of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getValue01
+static int tolua_CEGUI_CEGUI_BaseDim_getValue01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* container = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValue'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  float tolua_ret = (float)  self->getValue(*wnd,*container);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'getValue'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_BaseDim_getValue00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clone of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_clone00
+static int tolua_CEGUI_CEGUI_BaseDim_clone00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clone'",NULL);
+#endif
+ {
+  CEGUI::BaseDim* tolua_ret = (CEGUI::BaseDim*)  self->clone();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::BaseDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clone'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDimensionOperator of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getDimensionOperator00
+static int tolua_CEGUI_CEGUI_BaseDim_getDimensionOperator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDimensionOperator'",NULL);
+#endif
+ {
+  CEGUI::DimensionOperator tolua_ret = (CEGUI::DimensionOperator)  self->getDimensionOperator();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDimensionOperator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDimensionOperator of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_setDimensionOperator00
+static int tolua_CEGUI_CEGUI_BaseDim_setDimensionOperator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::BaseDim* self = (CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionOperator op = ((CEGUI::DimensionOperator) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDimensionOperator'",NULL);
+#endif
+ {
+  self->setDimensionOperator(op);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDimensionOperator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOperand of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getOperand00
+static int tolua_CEGUI_CEGUI_BaseDim_getOperand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOperand'",NULL);
+#endif
+ {
+  const CEGUI::BaseDim* tolua_ret = (const CEGUI::BaseDim*)  self->getOperand();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::BaseDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOperand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOperand of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_setOperand00
+static int tolua_CEGUI_CEGUI_BaseDim_setOperand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::BaseDim* self = (CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::BaseDim* operand = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOperand'",NULL);
+#endif
+ {
+  self->setOperand(*operand);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOperand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setValue of class  CEGUI::AbsoluteDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_AbsoluteDim_setValue00
+static int tolua_CEGUI_CEGUI_AbsoluteDim_setValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::AbsoluteDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::AbsoluteDim* self = (CEGUI::AbsoluteDim*)  tolua_tousertype(tolua_S,1,0);
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setValue'",NULL);
+#endif
+ {
+  self->setValue(val);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::AbsoluteDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_AbsoluteDim_new00
+static int tolua_CEGUI_CEGUI_AbsoluteDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::AbsoluteDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::AbsoluteDim* tolua_ret = (CEGUI::AbsoluteDim*)  new CEGUI::AbsoluteDim(val);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::AbsoluteDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::AbsoluteDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_AbsoluteDim_new00_local
+static int tolua_CEGUI_CEGUI_AbsoluteDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::AbsoluteDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::AbsoluteDim* tolua_ret = (CEGUI::AbsoluteDim*)  new CEGUI::AbsoluteDim(val);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::AbsoluteDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSourceImage of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_setSourceImage00
+static int tolua_CEGUI_CEGUI_ImageDim_setSourceImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageDim* self = (CEGUI::ImageDim*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSourceImage'",NULL);
+#endif
+ {
+  self->setSourceImage(imageset,image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSourceImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSourceDimension of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_setSourceDimension00
+static int tolua_CEGUI_CEGUI_ImageDim_setSourceDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageDim* self = (CEGUI::ImageDim*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSourceDimension'",NULL);
+#endif
+ {
+  self->setSourceDimension(dim);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSourceDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_new00
+static int tolua_CEGUI_CEGUI_ImageDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::ImageDim* tolua_ret = (CEGUI::ImageDim*)  new CEGUI::ImageDim(imageset,image,dim);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImageDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_new00_local
+static int tolua_CEGUI_CEGUI_ImageDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::ImageDim* tolua_ret = (CEGUI::ImageDim*)  new CEGUI::ImageDim(imageset,image,dim);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImageDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidgetName of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_setWidgetName00
+static int tolua_CEGUI_CEGUI_WidgetDim_setWidgetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetDim* self = (CEGUI::WidgetDim*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidgetName'",NULL);
+#endif
+ {
+  self->setWidgetName(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidgetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSourceDimension of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_setSourceDimension00
+static int tolua_CEGUI_CEGUI_WidgetDim_setSourceDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetDim* self = (CEGUI::WidgetDim*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSourceDimension'",NULL);
+#endif
+ {
+  self->setSourceDimension(dim);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSourceDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_new00
+static int tolua_CEGUI_CEGUI_WidgetDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::WidgetDim* tolua_ret = (CEGUI::WidgetDim*)  new CEGUI::WidgetDim(name,dim);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_new00_local
+static int tolua_CEGUI_CEGUI_WidgetDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::WidgetDim* tolua_ret = (CEGUI::WidgetDim*)  new CEGUI::WidgetDim(name,dim);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UnifiedDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UnifiedDim_new00
+static int tolua_CEGUI_CEGUI_UnifiedDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UnifiedDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* value = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UnifiedDim* tolua_ret = (CEGUI::UnifiedDim*)  new CEGUI::UnifiedDim(*value,dim);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UnifiedDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UnifiedDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UnifiedDim_new00_local
+static int tolua_CEGUI_CEGUI_UnifiedDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UnifiedDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* value = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UnifiedDim* tolua_ret = (CEGUI::UnifiedDim*)  new CEGUI::UnifiedDim(*value,dim);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UnifiedDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FontDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontDim_new00
+static int tolua_CEGUI_CEGUI_FontDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string font = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string text = ((string)  tolua_tocppstring(tolua_S,4,0));
+  CEGUI::FontMetricType metric = ((CEGUI::FontMetricType) (int)  tolua_tonumber(tolua_S,5,0));
+  float padding = ((float)  tolua_tonumber(tolua_S,6,0));
+ {
+  CEGUI::FontDim* tolua_ret = (CEGUI::FontDim*)  new CEGUI::FontDim(name,font,text,metric,padding);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FontDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FontDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontDim_new00_local
+static int tolua_CEGUI_CEGUI_FontDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string font = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string text = ((string)  tolua_tocppstring(tolua_S,4,0));
+  CEGUI::FontMetricType metric = ((CEGUI::FontMetricType) (int)  tolua_tonumber(tolua_S,5,0));
+  float padding = ((float)  tolua_tonumber(tolua_S,6,0));
+ {
+  CEGUI::FontDim* tolua_ret = (CEGUI::FontDim*)  new CEGUI::FontDim(name,font,text,metric,padding);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FontDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDim_new00
+static int tolua_CEGUI_CEGUI_PropertyDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string property = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::PropertyDim* tolua_ret = (CEGUI::PropertyDim*)  new CEGUI::PropertyDim(name,property,type);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDim_new00_local
+static int tolua_CEGUI_CEGUI_PropertyDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string property = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::PropertyDim* tolua_ret = (CEGUI::PropertyDim*)  new CEGUI::PropertyDim(name,property,type);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBaseDimension of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_getBaseDimension00
+static int tolua_CEGUI_CEGUI_Dimension_getBaseDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Dimension* self = (const CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBaseDimension'",NULL);
+#endif
+ {
+  const CEGUI::BaseDim& tolua_ret = (const CEGUI::BaseDim&)  self->getBaseDimension();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::BaseDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBaseDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBaseDimension of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_setBaseDimension00
+static int tolua_CEGUI_CEGUI_Dimension_setBaseDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Dimension* self = (CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::BaseDim* dim = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBaseDimension'",NULL);
+#endif
+ {
+  self->setBaseDimension(*dim);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBaseDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDimensionType of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_getDimensionType00
+static int tolua_CEGUI_CEGUI_Dimension_getDimensionType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Dimension* self = (const CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDimensionType'",NULL);
+#endif
+ {
+  CEGUI::DimensionType tolua_ret = (CEGUI::DimensionType)  self->getDimensionType();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDimensionType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDimensionType of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_setDimensionType00
+static int tolua_CEGUI_CEGUI_Dimension_setDimensionType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Dimension* self = (CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDimensionType'",NULL);
+#endif
+ {
+  self->setDimensionType(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDimensionType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new00
+static int tolua_CEGUI_CEGUI_Dimension_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* dim = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*dim,type);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new00_local
+static int tolua_CEGUI_CEGUI_Dimension_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* dim = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*dim,type);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new01
+static int tolua_CEGUI_CEGUI_Dimension_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Dimension* other = ((const CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*other);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new01_local
+static int tolua_CEGUI_CEGUI_Dimension_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Dimension* other = ((const CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*other);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new02
+static int tolua_CEGUI_CEGUI_Dimension_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new02_local
+static int tolua_CEGUI_CEGUI_Dimension_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelRect of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00
+static int tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getPixelRect(*wnd);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelRect of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_getPixelRect01
+static int tolua_CEGUI_CEGUI_ComponentArea_getPixelRect01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* container = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getPixelRect(*wnd,*container);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAreaFetchedFromProperty of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_isAreaFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_ComponentArea_isAreaFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAreaFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAreaFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAreaFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAreaPropertySource of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_getAreaPropertySource00
+static int tolua_CEGUI_CEGUI_ComponentArea_getAreaPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAreaPropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getAreaPropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAreaPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAreaPropertySource of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_setAreaPropertySource00
+static int tolua_CEGUI_CEGUI_ComponentArea_setAreaPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAreaPropertySource'",NULL);
+#endif
+ {
+  self->setAreaPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAreaPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_left of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_left
+static int tolua_get_CEGUI__ComponentArea_d_left(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_left,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_left of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_left
+static int tolua_set_CEGUI__ComponentArea_d_left(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_left = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_top
+static int tolua_get_CEGUI__ComponentArea_d_top(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_top,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_top
+static int tolua_set_CEGUI__ComponentArea_d_top(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_right_or_width of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_right_or_width
+static int tolua_get_CEGUI__ComponentArea_d_right_or_width(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right_or_width'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_right_or_width,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_right_or_width of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_right_or_width
+static int tolua_set_CEGUI__ComponentArea_d_right_or_width(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right_or_width'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_right_or_width = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom_or_height of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_bottom_or_height
+static int tolua_get_CEGUI__ComponentArea_d_bottom_or_height(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_or_height'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_bottom_or_height,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom_or_height of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_bottom_or_height
+static int tolua_set_CEGUI__ComponentArea_d_bottom_or_height(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_or_height'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom_or_height = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_new00
+static int tolua_CEGUI_CEGUI_ComponentArea_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ComponentArea* tolua_ret = (CEGUI::ComponentArea*)  new CEGUI::ComponentArea();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_new00_local
+static int tolua_CEGUI_CEGUI_ComponentArea_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ComponentArea* tolua_ret = (CEGUI::ComponentArea*)  new CEGUI::ComponentArea();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_getName00
+static int tolua_CEGUI_CEGUI_NamedArea_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::NamedArea* self = (const CEGUI::NamedArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getArea of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_getArea00
+static int tolua_CEGUI_CEGUI_NamedArea_getArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::NamedArea* self = (const CEGUI::NamedArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getArea'",NULL);
+#endif
+ {
+  const CEGUI::ComponentArea& tolua_ret = (const CEGUI::ComponentArea&)  self->getArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_setArea00
+static int tolua_CEGUI_CEGUI_NamedArea_setArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::NamedArea* self = (CEGUI::NamedArea*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ComponentArea area = *((CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new00
+static int tolua_CEGUI_CEGUI_NamedArea_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new00_local
+static int tolua_CEGUI_CEGUI_NamedArea_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new01
+static int tolua_CEGUI_CEGUI_NamedArea_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_NamedArea_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new01_local
+static int tolua_CEGUI_CEGUI_NamedArea_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_NamedArea_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::PropertyDefinitionBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinitionBase_set00
+static int tolua_CEGUI_CEGUI_PropertyDefinitionBase_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyDefinitionBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyDefinitionBase* self = (CEGUI::PropertyDefinitionBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* receiver = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(receiver,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: get of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_get00
+static int tolua_CEGUI_CEGUI_PropertyDefinition_get00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyDefinition* self = (const CEGUI::PropertyDefinition*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* receiver = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->get(receiver);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'get'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_set00
+static int tolua_CEGUI_CEGUI_PropertyDefinition_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyDefinition* self = (CEGUI::PropertyDefinition*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* receiver = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(receiver,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_new00
+static int tolua_CEGUI_CEGUI_PropertyDefinition_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,3,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,4,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,5,0));
+ {
+  CEGUI::PropertyDefinition* tolua_ret = (CEGUI::PropertyDefinition*)  new CEGUI::PropertyDefinition(name,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_new00_local
+static int tolua_CEGUI_CEGUI_PropertyDefinition_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,3,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,4,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,5,0));
+ {
+  CEGUI::PropertyDefinition* tolua_ret = (CEGUI::PropertyDefinition*)  new CEGUI::PropertyDefinition(name,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: apply of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_apply00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_apply00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyInitialiser* self = (const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* target = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'apply'",NULL);
+#endif
+ {
+  self->apply(*target);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'apply'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTargetPropertyName of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_getTargetPropertyName00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_getTargetPropertyName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyInitialiser* self = (const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTargetPropertyName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTargetPropertyName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTargetPropertyName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getInitialiserValue of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_getInitialiserValue00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_getInitialiserValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyInitialiser* self = (const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getInitialiserValue'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getInitialiserValue();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getInitialiserValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_new00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+ {
+  CEGUI::PropertyInitialiser* tolua_ret = (CEGUI::PropertyInitialiser*)  new CEGUI::PropertyInitialiser(property,value);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+ {
+  CEGUI::PropertyInitialiser* tolua_ret = (CEGUI::PropertyInitialiser*)  new CEGUI::PropertyInitialiser(property,value);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: get of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_get00
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_get00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyLinkDefinition* self = (const CEGUI::PropertyLinkDefinition*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* receiver = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->get(receiver);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'get'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_set00
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyLinkDefinition* self = (CEGUI::PropertyLinkDefinition*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* receiver = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(receiver,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string widgetNameSuffix = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string targetProperty = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,5,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,6,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,7,0));
+ {
+  CEGUI::PropertyLinkDefinition* tolua_ret = (CEGUI::PropertyLinkDefinition*)  new CEGUI::PropertyLinkDefinition(propertyName,widgetNameSuffix,targetProperty,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyLinkDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string widgetNameSuffix = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string targetProperty = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,5,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,6,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,7,0));
+ {
+  CEGUI::PropertyLinkDefinition* tolua_ret = (CEGUI::PropertyLinkDefinition*)  new CEGUI::PropertyLinkDefinition(propertyName,widgetNameSuffix,targetProperty,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyLinkDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_render00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_render01
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FalagardComponentBase_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getComponentArea of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_getComponentArea00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_getComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getComponentArea'",NULL);
+#endif
+ {
+  const CEGUI::ComponentArea& tolua_ret = (const CEGUI::ComponentArea&)  self->getComponentArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setComponentArea of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setComponentArea00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ComponentArea* area = ((const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setComponentArea'",NULL);
+#endif
+ {
+  self->setComponentArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColours of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_getColours00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_getColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColours'",NULL);
+#endif
+ {
+  const CEGUI::ColourRect& tolua_ret = (const CEGUI::ColourRect&)  self->getColours();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColours of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setColours00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColours'",NULL);
+#endif
+ {
+  self->setColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColoursPropertySource of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertySource00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColoursPropertySource'",NULL);
+#endif
+ {
+  self->setColoursPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColoursPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColoursPropertyIsColourRect of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertyIsColourRect00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertyIsColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColoursPropertyIsColourRect'",NULL);
+#endif
+ {
+  self->setColoursPropertyIsColourRect(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColoursPropertyIsColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVertFormattingPropertySource of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setVertFormattingPropertySource00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setVertFormattingPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVertFormattingPropertySource'",NULL);
+#endif
+ {
+  self->setVertFormattingPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVertFormattingPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorzFormattingPropertySource of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setHorzFormattingPropertySource00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setHorzFormattingPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorzFormattingPropertySource'",NULL);
+#endif
+ {
+  self->setHorzFormattingPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorzFormattingPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBackgroundVerticalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_getBackgroundVerticalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_getBackgroundVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameComponent* self = (const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBackgroundVerticalFormatting'",NULL);
+#endif
+ {
+  CEGUI::VerticalFormatting tolua_ret = (CEGUI::VerticalFormatting)  self->getBackgroundVerticalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBackgroundVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBackgroundVerticalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setBackgroundVerticalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_setBackgroundVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalFormatting fmt = ((CEGUI::VerticalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBackgroundVerticalFormatting'",NULL);
+#endif
+ {
+  self->setBackgroundVerticalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBackgroundVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBackgroundHorizontalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_getBackgroundHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_getBackgroundHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameComponent* self = (const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBackgroundHorizontalFormatting'",NULL);
+#endif
+ {
+  CEGUI::HorizontalFormatting tolua_ret = (CEGUI::HorizontalFormatting)  self->getBackgroundHorizontalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBackgroundHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBackgroundHorizontalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setBackgroundHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_setBackgroundHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalFormatting fmt = ((CEGUI::HorizontalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBackgroundHorizontalFormatting'",NULL);
+#endif
+ {
+  self->setBackgroundHorizontalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBackgroundHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_getImage00
+static int tolua_CEGUI_CEGUI_FrameComponent_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameComponent* self = (const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::FrameImageComponent part = ((CEGUI::FrameImageComponent) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getImage(part);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setImage00
+static int tolua_CEGUI_CEGUI_FrameComponent_setImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::FrameImageComponent part = ((CEGUI::FrameImageComponent) (int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(part,image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setImage01
+static int tolua_CEGUI_CEGUI_FrameComponent_setImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::FrameImageComponent part = ((CEGUI::FrameImageComponent) (int)  tolua_tonumber(tolua_S,2,0));
+  string imageset = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(part,imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FrameComponent_setImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_new00
+static int tolua_CEGUI_CEGUI_FrameComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FrameComponent* tolua_ret = (CEGUI::FrameComponent*)  new CEGUI::FrameComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FrameComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_new00_local
+static int tolua_CEGUI_CEGUI_FrameComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FrameComponent* tolua_ret = (CEGUI::FrameComponent*)  new CEGUI::FrameComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FrameComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getImage00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setImage00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setImage01
+static int tolua_CEGUI_CEGUI_ImageryComponent_setImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImageryComponent_setImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getVerticalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalFormatting'",NULL);
+#endif
+ {
+  CEGUI::VerticalFormatting tolua_ret = (CEGUI::VerticalFormatting)  self->getVerticalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setVerticalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalFormatting fmt = ((CEGUI::VerticalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalFormatting'",NULL);
+#endif
+ {
+  self->setVerticalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalFormatting'",NULL);
+#endif
+ {
+  CEGUI::HorizontalFormatting tolua_ret = (CEGUI::HorizontalFormatting)  self->getHorizontalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalFormatting fmt = ((CEGUI::HorizontalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalFormatting'",NULL);
+#endif
+ {
+  self->setHorizontalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isImageFetchedFromProperty of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_isImageFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_ImageryComponent_isImageFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isImageFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isImageFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isImageFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImagePropertySource of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getImagePropertySource00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getImagePropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImagePropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getImagePropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImagePropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImagePropertySource of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setImagePropertySource00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setImagePropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImagePropertySource'",NULL);
+#endif
+ {
+  self->setImagePropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImagePropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_new00
+static int tolua_CEGUI_CEGUI_ImageryComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImageryComponent* tolua_ret = (CEGUI::ImageryComponent*)  new CEGUI::ImageryComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImageryComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_new00_local
+static int tolua_CEGUI_CEGUI_ImageryComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImageryComponent* tolua_ret = (CEGUI::ImageryComponent*)  new CEGUI::ImageryComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImageryComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getText of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getText00
+static int tolua_CEGUI_CEGUI_TextComponent_getText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setText of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setText00
+static int tolua_CEGUI_CEGUI_TextComponent_setText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setText'",NULL);
+#endif
+ {
+  self->setText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getFont00
+static int tolua_CEGUI_CEGUI_TextComponent_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getFont();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setFont00
+static int tolua_CEGUI_CEGUI_TextComponent_setFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string font = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getVerticalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_getVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalFormatting'",NULL);
+#endif
+ {
+  CEGUI::VerticalTextFormatting tolua_ret = (CEGUI::VerticalTextFormatting)  self->getVerticalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setVerticalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_setVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalTextFormatting fmt = ((CEGUI::VerticalTextFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalFormatting'",NULL);
+#endif
+ {
+  self->setVerticalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_getHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalFormatting'",NULL);
+#endif
+ {
+  CEGUI::HorizontalTextFormatting tolua_ret = (CEGUI::HorizontalTextFormatting)  self->getHorizontalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_setHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalTextFormatting fmt = ((CEGUI::HorizontalTextFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalFormatting'",NULL);
+#endif
+ {
+  self->setHorizontalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextFetchedFromProperty of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_isTextFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_TextComponent_isTextFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getTextPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_getTextPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextPropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTextPropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setTextPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_setTextPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextPropertySource'",NULL);
+#endif
+ {
+  self->setTextPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFontFetchedFromProperty of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_isFontFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_TextComponent_isFontFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFontFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFontFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFontFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFontPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getFontPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_getFontPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFontPropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getFontPropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFontPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFontPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setFontPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_setFontPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFontPropertySource'",NULL);
+#endif
+ {
+  self->setFontPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFontPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_new00
+static int tolua_CEGUI_CEGUI_TextComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::TextComponent* tolua_ret = (CEGUI::TextComponent*)  new CEGUI::TextComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TextComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_new00_local
+static int tolua_CEGUI_CEGUI_TextComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::TextComponent* tolua_ret = (CEGUI::TextComponent*)  new CEGUI::TextComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::TextComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_render00
+static int tolua_CEGUI_CEGUI_ImagerySection_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_render01
+static int tolua_CEGUI_CEGUI_ImagerySection_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addImageryComponent of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_addImageryComponent00
+static int tolua_CEGUI_CEGUI_ImagerySection_addImageryComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImageryComponent* img = ((const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addImageryComponent'",NULL);
+#endif
+ {
+  self->addImageryComponent(*img);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addImageryComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearImageryComponents of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_clearImageryComponents00
+static int tolua_CEGUI_CEGUI_ImagerySection_clearImageryComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearImageryComponents'",NULL);
+#endif
+ {
+  self->clearImageryComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearImageryComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addTextComponent of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_addTextComponent00
+static int tolua_CEGUI_CEGUI_ImagerySection_addTextComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::TextComponent* text = ((const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addTextComponent'",NULL);
+#endif
+ {
+  self->addTextComponent(*text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addTextComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearTextComponents of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_clearTextComponents00
+static int tolua_CEGUI_CEGUI_ImagerySection_clearTextComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearTextComponents'",NULL);
+#endif
+ {
+  self->clearTextComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearTextComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearFrameComponents of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_clearFrameComponents00
+static int tolua_CEGUI_CEGUI_ImagerySection_clearFrameComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearFrameComponents'",NULL);
+#endif
+ {
+  self->clearFrameComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearFrameComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addFrameComponent of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_addFrameComponent00
+static int tolua_CEGUI_CEGUI_ImagerySection_addFrameComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::FrameComponent* frame = ((const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addFrameComponent'",NULL);
+#endif
+ {
+  self->addFrameComponent(*frame);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addFrameComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMasterColours of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getMasterColours00
+static int tolua_CEGUI_CEGUI_ImagerySection_getMasterColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMasterColours'",NULL);
+#endif
+ {
+  const CEGUI::ColourRect& tolua_ret = (const CEGUI::ColourRect&)  self->getMasterColours();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMasterColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMasterColours of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_setMasterColours00
+static int tolua_CEGUI_CEGUI_ImagerySection_setMasterColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMasterColours'",NULL);
+#endif
+ {
+  self->setMasterColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMasterColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getName00
+static int tolua_CEGUI_CEGUI_ImagerySection_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMasterColoursPropertySource of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertySource00
+static int tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMasterColoursPropertySource'",NULL);
+#endif
+ {
+  self->setMasterColoursPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMasterColoursPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMasterColoursPropertyIsColourRect of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertyIsColourRect00
+static int tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertyIsColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMasterColoursPropertyIsColourRect'",NULL);
+#endif
+ {
+  self->setMasterColoursPropertyIsColourRect(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMasterColoursPropertyIsColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBoundingRect of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00
+static int tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBoundingRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getBoundingRect(*wnd);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBoundingRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBoundingRect of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect01
+static int tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBoundingRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getBoundingRect(*wnd,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new00
+static int tolua_CEGUI_CEGUI_ImagerySection_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new00_local
+static int tolua_CEGUI_CEGUI_ImagerySection_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new01
+static int tolua_CEGUI_CEGUI_ImagerySection_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new01_local
+static int tolua_CEGUI_CEGUI_ImagerySection_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_render00
+static int tolua_CEGUI_CEGUI_SectionSpecification_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_render01
+static int tolua_CEGUI_CEGUI_SectionSpecification_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_SectionSpecification_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOwnerWidgetLookFeel of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_getOwnerWidgetLookFeel00
+static int tolua_CEGUI_CEGUI_SectionSpecification_getOwnerWidgetLookFeel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOwnerWidgetLookFeel'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getOwnerWidgetLookFeel();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOwnerWidgetLookFeel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSectionName of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_getSectionName00
+static int tolua_CEGUI_CEGUI_SectionSpecification_getSectionName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSectionName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getSectionName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSectionName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_getOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_getOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOverrideColours'",NULL);
+#endif
+ {
+  const CEGUI::ColourRect& tolua_ret = (const CEGUI::ColourRect&)  self->getOverrideColours();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverrideColours'",NULL);
+#endif
+ {
+  self->setOverrideColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUsingOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_isUsingOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_isUsingOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUsingOverrideColours'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUsingOverrideColours();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUsingOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUsingOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setUsingOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setUsingOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUsingOverrideColours'",NULL);
+#endif
+ {
+  self->setUsingOverrideColours(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUsingOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverrideColoursPropertySource of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertySource00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverrideColoursPropertySource'",NULL);
+#endif
+ {
+  self->setOverrideColoursPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverrideColoursPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverrideColoursPropertyIsColourRect of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertyIsColourRect00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertyIsColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverrideColoursPropertyIsColourRect'",NULL);
+#endif
+ {
+  self->setOverrideColoursPropertyIsColourRect(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverrideColoursPropertyIsColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRenderControlPropertySource of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setRenderControlPropertySource00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setRenderControlPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRenderControlPropertySource'",NULL);
+#endif
+ {
+  self->setRenderControlPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRenderControlPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new00
+static int tolua_CEGUI_CEGUI_SectionSpecification_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  const string controlPropertySource = ((const string)  tolua_tocppstring(tolua_S,4,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new00_local
+static int tolua_CEGUI_CEGUI_SectionSpecification_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  const string controlPropertySource = ((const string)  tolua_tocppstring(tolua_S,4,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new01
+static int tolua_CEGUI_CEGUI_SectionSpecification_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string controlPropertySource = ((string)  tolua_tocppstring(tolua_S,4,0));
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource,*cols);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_SectionSpecification_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new01_local
+static int tolua_CEGUI_CEGUI_SectionSpecification_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string controlPropertySource = ((string)  tolua_tocppstring(tolua_S,4,0));
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource,*cols);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_SectionSpecification_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_render00
+static int tolua_CEGUI_CEGUI_LayerSpecification_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_render01
+static int tolua_CEGUI_CEGUI_LayerSpecification_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_LayerSpecification_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addSectionSpecification of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_addSectionSpecification00
+static int tolua_CEGUI_CEGUI_LayerSpecification_addSectionSpecification00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::LayerSpecification* self = (CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::SectionSpecification* section = ((const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addSectionSpecification'",NULL);
+#endif
+ {
+  self->addSectionSpecification(*section);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addSectionSpecification'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearSectionSpecifications of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_clearSectionSpecifications00
+static int tolua_CEGUI_CEGUI_LayerSpecification_clearSectionSpecifications00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::LayerSpecification* self = (CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearSectionSpecifications'",NULL);
+#endif
+ {
+  self->clearSectionSpecifications();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearSectionSpecifications'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLayerPriority of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_getLayerPriority00
+static int tolua_CEGUI_CEGUI_LayerSpecification_getLayerPriority00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLayerPriority'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getLayerPriority();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLayerPriority'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator< of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification__lt00
+static int tolua_CEGUI_CEGUI_LayerSpecification__lt00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::LayerSpecification* other = ((const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator<'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator<(*other);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.lt'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_new00
+static int tolua_CEGUI_CEGUI_LayerSpecification_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int priority = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::LayerSpecification* tolua_ret = (CEGUI::LayerSpecification*)  new CEGUI::LayerSpecification(priority);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::LayerSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_new00_local
+static int tolua_CEGUI_CEGUI_LayerSpecification_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int priority = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::LayerSpecification* tolua_ret = (CEGUI::LayerSpecification*)  new CEGUI::LayerSpecification(priority);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::LayerSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_render00
+static int tolua_CEGUI_CEGUI_StateImagery_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,modcols,clipper);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_render01
+static int tolua_CEGUI_CEGUI_StateImagery_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,modcols,clipper);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_StateImagery_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addLayer of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_addLayer00
+static int tolua_CEGUI_CEGUI_StateImagery_addLayer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::StateImagery* self = (CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::LayerSpecification* layer = ((const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addLayer'",NULL);
+#endif
+ {
+  self->addLayer(*layer);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addLayer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearLayers of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_clearLayers00
+static int tolua_CEGUI_CEGUI_StateImagery_clearLayers00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::StateImagery* self = (CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearLayers'",NULL);
+#endif
+ {
+  self->clearLayers();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearLayers'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_getName00
+static int tolua_CEGUI_CEGUI_StateImagery_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isClippedToDisplay of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_isClippedToDisplay00
+static int tolua_CEGUI_CEGUI_StateImagery_isClippedToDisplay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isClippedToDisplay'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isClippedToDisplay();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isClippedToDisplay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClippedToDisplay of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_setClippedToDisplay00
+static int tolua_CEGUI_CEGUI_StateImagery_setClippedToDisplay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::StateImagery* self = (CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClippedToDisplay'",NULL);
+#endif
+ {
+  self->setClippedToDisplay(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClippedToDisplay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new00
+static int tolua_CEGUI_CEGUI_StateImagery_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new00_local
+static int tolua_CEGUI_CEGUI_StateImagery_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new01
+static int tolua_CEGUI_CEGUI_StateImagery_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_StateImagery_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new01_local
+static int tolua_CEGUI_CEGUI_StateImagery_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_StateImagery_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: create of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_create00
+static int tolua_CEGUI_CEGUI_WidgetComponent_create00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* parent = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'create'",NULL);
+#endif
+ {
+  self->create(*parent);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getComponentArea of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getComponentArea00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getComponentArea'",NULL);
+#endif
+ {
+  const CEGUI::ComponentArea& tolua_ret = (const CEGUI::ComponentArea&)  self->getComponentArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setComponentArea of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setComponentArea00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ComponentArea* area = ((const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setComponentArea'",NULL);
+#endif
+ {
+  self->setComponentArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBaseWidgetType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getBaseWidgetType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getBaseWidgetType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBaseWidgetType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getBaseWidgetType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBaseWidgetType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBaseWidgetType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setBaseWidgetType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setBaseWidgetType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBaseWidgetType'",NULL);
+#endif
+ {
+  self->setBaseWidgetType(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBaseWidgetType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidgetLookName of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getWidgetLookName00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getWidgetLookName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidgetLookName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWidgetLookName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidgetLookName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidgetLookName of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setWidgetLookName00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setWidgetLookName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string look = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidgetLookName'",NULL);
+#endif
+ {
+  self->setWidgetLookName(look);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidgetLookName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidgetNameSuffix of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getWidgetNameSuffix00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getWidgetNameSuffix00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidgetNameSuffix'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWidgetNameSuffix();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidgetNameSuffix'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidgetNameSuffix of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setWidgetNameSuffix00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setWidgetNameSuffix00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string suffix = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidgetNameSuffix'",NULL);
+#endif
+ {
+  self->setWidgetNameSuffix(suffix);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidgetNameSuffix'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindowRendererType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getWindowRendererType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getWindowRendererType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindowRendererType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWindowRendererType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindowRendererType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWindowRendererType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setWindowRendererType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setWindowRendererType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWindowRendererType'",NULL);
+#endif
+ {
+  self->setWindowRendererType(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWindowRendererType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getVerticalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getVerticalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalWidgetAlignment'",NULL);
+#endif
+ {
+  CEGUI::VerticalAlignment tolua_ret = (CEGUI::VerticalAlignment)  self->getVerticalWidgetAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setVerticalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setVerticalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalAlignment alignment = ((CEGUI::VerticalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalWidgetAlignment'",NULL);
+#endif
+ {
+  self->setVerticalWidgetAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getHorizontalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getHorizontalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalWidgetAlignment'",NULL);
+#endif
+ {
+  CEGUI::HorizontalAlignment tolua_ret = (CEGUI::HorizontalAlignment)  self->getHorizontalWidgetAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setHorizontalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setHorizontalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalAlignment alignment = ((CEGUI::HorizontalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalWidgetAlignment'",NULL);
+#endif
+ {
+  self->setHorizontalWidgetAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyInitialiser of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_addPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetComponent_addPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyInitialiser* initialiser = ((const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyInitialiser'",NULL);
+#endif
+ {
+  self->addPropertyInitialiser(*initialiser);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyInitialisers of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_clearPropertyInitialisers00
+static int tolua_CEGUI_CEGUI_WidgetComponent_clearPropertyInitialisers00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyInitialisers'",NULL);
+#endif
+ {
+  self->clearPropertyInitialisers();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyInitialisers'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: layout of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_layout00
+static int tolua_CEGUI_CEGUI_WidgetComponent_layout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* owner = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'layout'",NULL);
+#endif
+ {
+  self->layout(*owner);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'layout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findPropertyInitialiser of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_findPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetComponent_findPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findPropertyInitialiser'",NULL);
+#endif
+ {
+  const CEGUI::PropertyInitialiser* tolua_ret = (const CEGUI::PropertyInitialiser*)  self->findPropertyInitialiser(propertyName);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new00
+static int tolua_CEGUI_CEGUI_WidgetComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new00_local
+static int tolua_CEGUI_CEGUI_WidgetComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new01
+static int tolua_CEGUI_CEGUI_WidgetComponent_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string look = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string suffix = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string renderer = ((string)  tolua_tocppstring(tolua_S,5,0));
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent(type,look,suffix,renderer);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetComponent_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new01_local
+static int tolua_CEGUI_CEGUI_WidgetComponent_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string look = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string suffix = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string renderer = ((string)  tolua_tocppstring(tolua_S,5,0));
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent(type,look,suffix,renderer);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetComponent_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStateImagery of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getStateImagery00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getStateImagery00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string state = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStateImagery'",NULL);
+#endif
+ {
+  CEGUI::StateImagery& tolua_ret = (CEGUI::StateImagery&)  self->getStateImagery(state);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStateImagery'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImagerySection of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getImagerySection00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getImagerySection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string section = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImagerySection'",NULL);
+#endif
+ {
+  CEGUI::ImagerySection& tolua_ret = (CEGUI::ImagerySection&)  self->getImagerySection(section);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImagerySection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getName00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addImagerySection of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addImagerySection00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addImagerySection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImagerySection* section = ((const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addImagerySection'",NULL);
+#endif
+ {
+  self->addImagerySection(*section);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addImagerySection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addWidgetComponent of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addWidgetComponent00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addWidgetComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::WidgetComponent* widget = ((const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addWidgetComponent'",NULL);
+#endif
+ {
+  self->addWidgetComponent(*widget);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addWidgetComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addStateSpecification of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addStateSpecification00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addStateSpecification00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::StateImagery* state = ((const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addStateSpecification'",NULL);
+#endif
+ {
+  self->addStateSpecification(*state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addStateSpecification'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyInitialiser of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyInitialiser* initialiser = ((const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyInitialiser'",NULL);
+#endif
+ {
+  self->addPropertyInitialiser(*initialiser);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearImagerySections of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearImagerySections00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearImagerySections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearImagerySections'",NULL);
+#endif
+ {
+  self->clearImagerySections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearImagerySections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearWidgetComponents of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearWidgetComponents00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearWidgetComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearWidgetComponents'",NULL);
+#endif
+ {
+  self->clearWidgetComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearWidgetComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearStateSpecifications of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearStateSpecifications00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearStateSpecifications00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearStateSpecifications'",NULL);
+#endif
+ {
+  self->clearStateSpecifications();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearStateSpecifications'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyInitialisers of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyInitialisers00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyInitialisers00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyInitialisers'",NULL);
+#endif
+ {
+  self->clearPropertyInitialisers();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyInitialisers'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: initialiseWidget of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_initialiseWidget00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_initialiseWidget00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* widget = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'initialiseWidget'",NULL);
+#endif
+ {
+  self->initialiseWidget(*widget);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'initialiseWidget'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isStateImageryPresent of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_isStateImageryPresent00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_isStateImageryPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string state = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isStateImageryPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isStateImageryPresent(state);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isStateImageryPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addNamedArea of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addNamedArea00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addNamedArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::NamedArea* area = ((const CEGUI::NamedArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addNamedArea'",NULL);
+#endif
+ {
+  self->addNamedArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addNamedArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearNamedAreas of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearNamedAreas00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearNamedAreas00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearNamedAreas'",NULL);
+#endif
+ {
+  self->clearNamedAreas();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearNamedAreas'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNamedArea of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getNamedArea00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getNamedArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNamedArea'",NULL);
+#endif
+ {
+  const CEGUI::NamedArea& tolua_ret = (const CEGUI::NamedArea&)  self->getNamedArea(name);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::NamedArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNamedArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isNamedAreaDefined of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_isNamedAreaDefined00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_isNamedAreaDefined00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isNamedAreaDefined'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isNamedAreaDefined(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isNamedAreaDefined'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: layoutChildWidgets of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_layoutChildWidgets00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_layoutChildWidgets00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* owner = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'layoutChildWidgets'",NULL);
+#endif
+ {
+  self->layoutChildWidgets(*owner);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'layoutChildWidgets'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyDefinition of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyDefinition00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyDefinition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyDefinition* propdef = ((const CEGUI::PropertyDefinition*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyDefinition'",NULL);
+#endif
+ {
+  self->addPropertyDefinition(*propdef);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyDefinition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyLinkDefinition of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyLinkDefinition00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyLinkDefinition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyLinkDefinition* propdef = ((const CEGUI::PropertyLinkDefinition*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyLinkDefinition'",NULL);
+#endif
+ {
+  self->addPropertyLinkDefinition(*propdef);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyLinkDefinition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyDefinitions of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyDefinitions00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyDefinitions00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyDefinitions'",NULL);
+#endif
+ {
+  self->clearPropertyDefinitions();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyDefinitions'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyLinkDefinitions of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyLinkDefinitions00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyLinkDefinitions00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyLinkDefinitions'",NULL);
+#endif
+ {
+  self->clearPropertyLinkDefinitions();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyLinkDefinitions'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renameChildren of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_renameChildren00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_renameChildren00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* widget = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string newBaseName = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renameChildren'",NULL);
+#endif
+ {
+  self->renameChildren(*widget,newBaseName);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'renameChildren'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findPropertyInitialiser of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_findPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_findPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findPropertyInitialiser'",NULL);
+#endif
+ {
+  const CEGUI::PropertyInitialiser* tolua_ret = (const CEGUI::PropertyInitialiser*)  self->findPropertyInitialiser(propertyName);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findWidgetComponent of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_findWidgetComponent00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_findWidgetComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string nameSuffix = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findWidgetComponent'",NULL);
+#endif
+ {
+  const CEGUI::WidgetComponent* tolua_ret = (const CEGUI::WidgetComponent*)  self->findWidgetComponent(nameSuffix);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findWidgetComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new01
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetLookFeel_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_getSingleton00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetLookManager& tolua_ret = (CEGUI::WidgetLookManager&)  CEGUI::WidgetLookManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WidgetLookManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: parseLookNFeelSpecification of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_parseLookNFeelSpecification00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_parseLookNFeelSpecification00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'parseLookNFeelSpecification'",NULL);
+#endif
+ {
+  self->parseLookNFeelSpecification(filename,resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'parseLookNFeelSpecification'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isWidgetLookAvailable of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_isWidgetLookAvailable00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_isWidgetLookAvailable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string widget = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isWidgetLookAvailable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isWidgetLookAvailable(widget);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isWidgetLookAvailable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidgetLook of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_getWidgetLook00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_getWidgetLook00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string widget = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidgetLook'",NULL);
+#endif
+ {
+  const CEGUI::WidgetLookFeel& tolua_ret = (const CEGUI::WidgetLookFeel&)  self->getWidgetLook(widget);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidgetLook'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: eraseWidgetLook of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_eraseWidgetLook00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_eraseWidgetLook00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string widget = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'eraseWidgetLook'",NULL);
+#endif
+ {
+  self->eraseWidgetLook(widget);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'eraseWidgetLook'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addWidgetLook of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_addWidgetLook00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_addWidgetLook00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::WidgetLookFeel* look = ((CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addWidgetLook'",NULL);
+#endif
+ {
+  self->addWidgetLook(*look);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addWidgetLook'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWidgetLookToStream of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookToStream00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookToStream00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::OutStream* out_stream = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWidgetLookToStream'",NULL);
+#endif
+ {
+  self->writeWidgetLookToStream(name,*out_stream);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'writeWidgetLookToStream'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWidgetLookSeriesToStream of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookSeriesToStream00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookSeriesToStream00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string prefix = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::OutStream* out_stream = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWidgetLookSeriesToStream'",NULL);
+#endif
+ {
+  self->writeWidgetLookSeriesToStream(prefix,*out_stream);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'writeWidgetLookSeriesToStream'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_new00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetLookManager* tolua_ret = (CEGUI::WidgetLookManager*)  new CEGUI::WidgetLookManager();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetLookManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_new00_local
+static int tolua_CEGUI_CEGUI_WidgetLookManager_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetLookManager* tolua_ret = (CEGUI::WidgetLookManager*)  new CEGUI::WidgetLookManager();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetLookManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WidgetLookManager::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::WidgetLookManager::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: CEGUI::ceguiLua_createListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_createListboxTextItem00
+static int tolua_CEGUI_CEGUI_createListboxTextItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_iscppstring(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isuserdata(tolua_S,3,1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string text = ((string)  tolua_tocppstring(tolua_S,1,0));
+  unsigned int item_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  void* item_data = ((void*)  tolua_touserdata(tolua_S,3,0));
+  bool disabled = ((bool)  tolua_toboolean(tolua_S,4,false));
+  bool auto_delete = ((bool)  tolua_toboolean(tolua_S,5,true));
+ {
+  CEGUI::ListboxTextItem* tolua_ret = (CEGUI::ListboxTextItem*)  CEGUI::ceguiLua_createListboxTextItem(text,item_id,item_data,disabled,auto_delete);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxTextItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createListboxTextItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_new00
+static int tolua_CEGUI_CEGUI_FileStream_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FileStream* tolua_ret = (CEGUI::FileStream*)  new CEGUI::FileStream();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FileStream");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_new00_local
+static int tolua_CEGUI_CEGUI_FileStream_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FileStream* tolua_ret = (CEGUI::FileStream*)  new CEGUI::FileStream();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FileStream");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: is_open of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_is_open00
+static int tolua_CEGUI_CEGUI_FileStream_is_open00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FileStream* self = (CEGUI::FileStream*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'is_open'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->is_open();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'is_open'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: CEGUI::ceguiLua_FileStream_open of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_open00
+static int tolua_CEGUI_CEGUI_FileStream_open00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FileStream* self = (CEGUI::FileStream*)  tolua_tousertype(tolua_S,1,0);
+  const char* filename = ((const char*)  tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CEGUI::ceguiLua_FileStream_open'",NULL);
+#endif
+ {
+  CEGUI::ceguiLua_FileStream_open(self,filename);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'open'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: close of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_close00
+static int tolua_CEGUI_CEGUI_FileStream_close00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FileStream* self = (CEGUI::FileStream*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'close'",NULL);
+#endif
+ {
+  self->close();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'close'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* Open function */
+int tolua_CEGUI_open (lua_State* tolua_S)
+{
+ tolua_open(tolua_S);
+ tolua_reg_types(tolua_S);
+ tolua_module(tolua_S,NULL,0);
+ tolua_beginmodule(tolua_S,NULL);
+ tolua_module(tolua_S,"CEGUI",0);
+ tolua_beginmodule(tolua_S,"CEGUI");
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Vector2","CEGUI::Vector2","",tolua_collect_CEGUI__Vector2);
+  #else
+  tolua_cclass(tolua_S,"Vector2","CEGUI::Vector2","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Vector2");
+   tolua_variable(tolua_S,"x",tolua_get_CEGUI__Vector2_x,tolua_set_CEGUI__Vector2_x);
+   tolua_variable(tolua_S,"y",tolua_get_CEGUI__Vector2_y,tolua_set_CEGUI__Vector2_y);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_Vector2__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_Vector2__sub00);
+   tolua_function(tolua_S,".mul",tolua_CEGUI_CEGUI_Vector2__mul00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_Vector2__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Vector2_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Vector2_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Vector2_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Vector2_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Vector2_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Vector2_new01_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 80,111,105,110,116, 32, 61, 32,
+    67, 69, 71, 85, 73, 46, 86,101, 99,116,111,114, 50,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 1");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Size","CEGUI::Size","",tolua_collect_CEGUI__Size);
+  #else
+  tolua_cclass(tolua_S,"Size","CEGUI::Size","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Size");
+   tolua_variable(tolua_S,"width",tolua_get_CEGUI__Size_width,tolua_set_CEGUI__Size_width);
+   tolua_variable(tolua_S,"height",tolua_get_CEGUI__Size_height,tolua_set_CEGUI__Size_height);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_Size__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Size_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Size_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Size_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Size_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Size_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Size_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Rect","CEGUI::Rect","",tolua_collect_CEGUI__Rect);
+  #else
+  tolua_cclass(tolua_S,"Rect","CEGUI::Rect","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Rect");
+   tolua_variable(tolua_S,"top",tolua_get_CEGUI__Rect_top,tolua_set_CEGUI__Rect_top);
+   tolua_variable(tolua_S,"bottom",tolua_get_CEGUI__Rect_bottom,tolua_set_CEGUI__Rect_bottom);
+   tolua_variable(tolua_S,"left",tolua_get_CEGUI__Rect_left,tolua_set_CEGUI__Rect_left);
+   tolua_variable(tolua_S,"right",tolua_get_CEGUI__Rect_right,tolua_set_CEGUI__Rect_right);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_Rect_getPosition00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Rect_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Rect_getHeight00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Rect_getSize00);
+   tolua_function(tolua_S,"getIntersection",tolua_CEGUI_CEGUI_Rect_getIntersection00);
+   tolua_function(tolua_S,"isPointInRect",tolua_CEGUI_CEGUI_Rect_isPointInRect00);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_Rect_setPosition00);
+   tolua_function(tolua_S,"setWidth",tolua_CEGUI_CEGUI_Rect_setWidth00);
+   tolua_function(tolua_S,"setHeight",tolua_CEGUI_CEGUI_Rect_setHeight00);
+   tolua_function(tolua_S,"setSize",tolua_CEGUI_CEGUI_Rect_setSize00);
+   tolua_function(tolua_S,"offset",tolua_CEGUI_CEGUI_Rect_offset00);
+   tolua_function(tolua_S,"constrainSizeMax",tolua_CEGUI_CEGUI_Rect_constrainSizeMax00);
+   tolua_function(tolua_S,"constrainSizeMin",tolua_CEGUI_CEGUI_Rect_constrainSizeMin00);
+   tolua_function(tolua_S,"constrainSize",tolua_CEGUI_CEGUI_Rect_constrainSize00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_Rect__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Rect_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Rect_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Rect_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Rect_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Rect_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Rect_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"colour","CEGUI::colour","",tolua_collect_CEGUI__colour);
+  #else
+  tolua_cclass(tolua_S,"colour","CEGUI::colour","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"colour");
+   tolua_function(tolua_S,"getAlpha",tolua_CEGUI_CEGUI_colour_getAlpha00);
+   tolua_function(tolua_S,"getRed",tolua_CEGUI_CEGUI_colour_getRed00);
+   tolua_function(tolua_S,"getGreen",tolua_CEGUI_CEGUI_colour_getGreen00);
+   tolua_function(tolua_S,"getBlue",tolua_CEGUI_CEGUI_colour_getBlue00);
+   tolua_function(tolua_S,"getHue",tolua_CEGUI_CEGUI_colour_getHue00);
+   tolua_function(tolua_S,"getSaturation",tolua_CEGUI_CEGUI_colour_getSaturation00);
+   tolua_function(tolua_S,"getLumination",tolua_CEGUI_CEGUI_colour_getLumination00);
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_colour_set00);
+   tolua_function(tolua_S,"setAlpha",tolua_CEGUI_CEGUI_colour_setAlpha00);
+   tolua_function(tolua_S,"setRed",tolua_CEGUI_CEGUI_colour_setRed00);
+   tolua_function(tolua_S,"setGreen",tolua_CEGUI_CEGUI_colour_setGreen00);
+   tolua_function(tolua_S,"setBlue",tolua_CEGUI_CEGUI_colour_setBlue00);
+   tolua_function(tolua_S,"setRGB",tolua_CEGUI_CEGUI_colour_setRGB00);
+   tolua_function(tolua_S,"setHSL",tolua_CEGUI_CEGUI_colour_setHSL00);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_colour__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_colour__sub00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_colour__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_colour_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_colour_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_colour_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_colour_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_colour_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_colour_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ColourRect","CEGUI::ColourRect","",tolua_collect_CEGUI__ColourRect);
+  #else
+  tolua_cclass(tolua_S,"ColourRect","CEGUI::ColourRect","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ColourRect");
+   tolua_variable(tolua_S,"top_left",tolua_get_CEGUI__ColourRect_top_left,tolua_set_CEGUI__ColourRect_top_left);
+   tolua_variable(tolua_S,"top_right",tolua_get_CEGUI__ColourRect_top_right,tolua_set_CEGUI__ColourRect_top_right);
+   tolua_variable(tolua_S,"bottom_left",tolua_get_CEGUI__ColourRect_bottom_left,tolua_set_CEGUI__ColourRect_bottom_left);
+   tolua_variable(tolua_S,"bottom_right",tolua_get_CEGUI__ColourRect_bottom_right,tolua_set_CEGUI__ColourRect_bottom_right);
+   tolua_function(tolua_S,"setAlpha",tolua_CEGUI_CEGUI_ColourRect_setAlpha00);
+   tolua_function(tolua_S,"setTopAlpha",tolua_CEGUI_CEGUI_ColourRect_setTopAlpha00);
+   tolua_function(tolua_S,"setBottomAlpha",tolua_CEGUI_CEGUI_ColourRect_setBottomAlpha00);
+   tolua_function(tolua_S,"setLeftAlpha",tolua_CEGUI_CEGUI_ColourRect_setLeftAlpha00);
+   tolua_function(tolua_S,"setRightAlpha",tolua_CEGUI_CEGUI_ColourRect_setRightAlpha00);
+   tolua_function(tolua_S,"modulateAlpha",tolua_CEGUI_CEGUI_ColourRect_modulateAlpha00);
+   tolua_function(tolua_S,"setColours",tolua_CEGUI_CEGUI_ColourRect_setColours00);
+   tolua_function(tolua_S,"isMonochromatic",tolua_CEGUI_CEGUI_ColourRect_isMonochromatic00);
+   tolua_function(tolua_S,"getSubRectangle",tolua_CEGUI_CEGUI_ColourRect_getSubRectangle00);
+   tolua_function(tolua_S,"getColourAtPoint",tolua_CEGUI_CEGUI_ColourRect_getColourAtPoint00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ColourRect_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ColourRect_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ColourRect_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ColourRect_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ColourRect_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ColourRect_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ColourRect_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ColourRect_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ColourRect_new02_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"String","CEGUI::String","",tolua_collect_CEGUI__String);
+  #else
+  tolua_cclass(tolua_S,"String","CEGUI::String","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"String");
+   tolua_variable(tolua_S,"npos",tolua_get_CEGUI__String_unsigned_npos,NULL);
+   tolua_function(tolua_S,"size",tolua_CEGUI_CEGUI_String_size00);
+   tolua_function(tolua_S,"length",tolua_CEGUI_CEGUI_String_length00);
+   tolua_function(tolua_S,"empty",tolua_CEGUI_CEGUI_String_empty00);
+   tolua_function(tolua_S,"capacity",tolua_CEGUI_CEGUI_String_capacity00);
+   tolua_function(tolua_S,".seti",tolua_CEGUI_CEGUI_String__seti00);
+   tolua_function(tolua_S,".geti",tolua_CEGUI_CEGUI_String__geti00);
+   tolua_function(tolua_S,"at",tolua_CEGUI_CEGUI_String_at00);
+   tolua_function(tolua_S,"c_str",tolua_CEGUI_CEGUI_String_c_str00);
+   tolua_function(tolua_S,"reserve",tolua_CEGUI_CEGUI_String_reserve00);
+   tolua_function(tolua_S,"resize",tolua_CEGUI_CEGUI_String_resize00);
+   tolua_function(tolua_S,"resize",tolua_CEGUI_CEGUI_String_resize01);
+   tolua_function(tolua_S,"clear",tolua_CEGUI_CEGUI_String_clear00);
+   tolua_function(tolua_S,"erase",tolua_CEGUI_CEGUI_String_erase00);
+   tolua_function(tolua_S,"erase",tolua_CEGUI_CEGUI_String_erase01);
+   tolua_function(tolua_S,"replace",tolua_CEGUI_CEGUI_String_replace00);
+   tolua_function(tolua_S,"swap",tolua_CEGUI_CEGUI_String_swap00);
+   tolua_function(tolua_S,"insert",tolua_CEGUI_CEGUI_String_insert00);
+   tolua_function(tolua_S,"find",tolua_CEGUI_CEGUI_String_find00);
+   tolua_function(tolua_S,"rfind",tolua_CEGUI_CEGUI_String_rfind00);
+   tolua_function(tolua_S,"find",tolua_CEGUI_CEGUI_String_find01);
+   tolua_function(tolua_S,"rfind",tolua_CEGUI_CEGUI_String_rfind01);
+   tolua_function(tolua_S,"substr",tolua_CEGUI_CEGUI_String_substr00);
+   tolua_function(tolua_S,"push_back",tolua_CEGUI_CEGUI_String_push_back00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new02_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new03);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new03_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new03_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"UDim","CEGUI::UDim","",tolua_collect_CEGUI__UDim);
+  #else
+  tolua_cclass(tolua_S,"UDim","CEGUI::UDim","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"UDim");
+   tolua_variable(tolua_S,"scale",tolua_get_CEGUI__UDim_scale,tolua_set_CEGUI__UDim_scale);
+   tolua_variable(tolua_S,"offset",tolua_get_CEGUI__UDim_offset,tolua_set_CEGUI__UDim_offset);
+   tolua_function(tolua_S,"asAbsolute",tolua_CEGUI_CEGUI_UDim_asAbsolute00);
+   tolua_function(tolua_S,"asRelative",tolua_CEGUI_CEGUI_UDim_asRelative00);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_UDim__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_UDim__sub00);
+   tolua_function(tolua_S,".div",tolua_CEGUI_CEGUI_UDim__div00);
+   tolua_function(tolua_S,".mul",tolua_CEGUI_CEGUI_UDim__mul00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_UDim__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UDim_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UDim_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UDim_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UDim_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"UVector2","CEGUI::UVector2","",tolua_collect_CEGUI__UVector2);
+  #else
+  tolua_cclass(tolua_S,"UVector2","CEGUI::UVector2","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"UVector2");
+   tolua_variable(tolua_S,"x",tolua_get_CEGUI__UVector2_x,tolua_set_CEGUI__UVector2_x);
+   tolua_variable(tolua_S,"y",tolua_get_CEGUI__UVector2_y,tolua_set_CEGUI__UVector2_y);
+   tolua_function(tolua_S,"asAbsolute",tolua_CEGUI_CEGUI_UVector2_asAbsolute00);
+   tolua_function(tolua_S,"asRelative",tolua_CEGUI_CEGUI_UVector2_asRelative00);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_UVector2__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_UVector2__sub00);
+   tolua_function(tolua_S,".div",tolua_CEGUI_CEGUI_UVector2__div00);
+   tolua_function(tolua_S,".mul",tolua_CEGUI_CEGUI_UVector2__mul00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_UVector2__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UVector2_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UVector2_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UVector2_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UVector2_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UVector2_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UVector2_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"URect","CEGUI::URect","",tolua_collect_CEGUI__URect);
+  #else
+  tolua_cclass(tolua_S,"URect","CEGUI::URect","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"URect");
+   tolua_variable(tolua_S,"min",tolua_get_CEGUI__URect_min,tolua_set_CEGUI__URect_min);
+   tolua_variable(tolua_S,"max",tolua_get_CEGUI__URect_max,tolua_set_CEGUI__URect_max);
+   tolua_function(tolua_S,"asAbsolute",tolua_CEGUI_CEGUI_URect_asAbsolute00);
+   tolua_function(tolua_S,"asRelative",tolua_CEGUI_CEGUI_URect_asRelative00);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_URect_getPosition00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_URect_getSize00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_URect_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_URect_getHeight00);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_URect_setPosition00);
+   tolua_function(tolua_S,"setSize",tolua_CEGUI_CEGUI_URect_setSize00);
+   tolua_function(tolua_S,"setWidth",tolua_CEGUI_CEGUI_URect_setWidth00);
+   tolua_function(tolua_S,"setHeight",tolua_CEGUI_CEGUI_URect_setHeight00);
+   tolua_function(tolua_S,"offset",tolua_CEGUI_CEGUI_URect_offset00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_URect_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_URect_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_URect_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_URect_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_URect_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_URect_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_URect_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_URect_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_URect_new02_local);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"Errors",CEGUI::Errors);
+  tolua_constant(tolua_S,"Standard",CEGUI::Standard);
+  tolua_constant(tolua_S,"Informative",CEGUI::Informative);
+  tolua_constant(tolua_S,"Insane",CEGUI::Insane);
+  tolua_cclass(tolua_S,"Logger","CEGUI::Logger","",NULL);
+  tolua_beginmodule(tolua_S,"Logger");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_Logger_getSingleton00);
+   tolua_function(tolua_S,"setLoggingLevel",tolua_CEGUI_CEGUI_Logger_setLoggingLevel00);
+   tolua_function(tolua_S,"getLoggingLevel",tolua_CEGUI_CEGUI_Logger_getLoggingLevel00);
+   tolua_function(tolua_S,"logEvent",tolua_CEGUI_CEGUI_Logger_logEvent00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"LeftAligned",CEGUI::LeftAligned);
+  tolua_constant(tolua_S,"RightAligned",CEGUI::RightAligned);
+  tolua_constant(tolua_S,"Centred",CEGUI::Centred);
+  tolua_constant(tolua_S,"Justified",CEGUI::Justified);
+  tolua_constant(tolua_S,"WordWrapLeftAligned",CEGUI::WordWrapLeftAligned);
+  tolua_constant(tolua_S,"WordWrapRightAligned",CEGUI::WordWrapRightAligned);
+  tolua_constant(tolua_S,"WordWrapCentred",CEGUI::WordWrapCentred);
+  tolua_constant(tolua_S,"WordWrapJustified",CEGUI::WordWrapJustified);
+  tolua_cclass(tolua_S,"Font","CEGUI::Font","",NULL);
+  tolua_beginmodule(tolua_S,"Font");
+   tolua_function(tolua_S,"setProperty",tolua_CEGUI_CEGUI_Font_setProperty00);
+   tolua_function(tolua_S,"getProperty",tolua_CEGUI_CEGUI_Font_getProperty00);
+   tolua_function(tolua_S,"getPropertyDefault",tolua_CEGUI_CEGUI_Font_getPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyHelp",tolua_CEGUI_CEGUI_Font_getPropertyHelp00);
+   tolua_function(tolua_S,"isPropertyPresent",tolua_CEGUI_CEGUI_Font_isPropertyPresent00);
+   tolua_function(tolua_S,"isPropertyDefault",tolua_CEGUI_CEGUI_Font_isPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyIterator",tolua_CEGUI_CEGUI_Font_getPropertyIterator00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_Font_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_Font_getDefaultResourceGroup00);
+   tolua_function(tolua_S,"load",tolua_CEGUI_CEGUI_Font_load00);
+   tolua_function(tolua_S,"isCodepointAvailable",tolua_CEGUI_CEGUI_Font_isCodepointAvailable00);
+   tolua_function(tolua_S,"setNativeResolution",tolua_CEGUI_CEGUI_Font_setNativeResolution00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_Font_notifyScreenResolution00);
+   tolua_function(tolua_S,"getTextExtent",tolua_CEGUI_CEGUI_Font_getTextExtent00);
+   tolua_function(tolua_S,"getLineSpacing",tolua_CEGUI_CEGUI_Font_getLineSpacing00);
+   tolua_function(tolua_S,"getFontHeight",tolua_CEGUI_CEGUI_Font_getFontHeight00);
+   tolua_function(tolua_S,"getCharAtPixel",tolua_CEGUI_CEGUI_Font_getCharAtPixel00);
+   tolua_function(tolua_S,"getCharAtPixel",tolua_CEGUI_CEGUI_Font_getCharAtPixel01);
+   tolua_function(tolua_S,"getFormattedLineCount",tolua_CEGUI_CEGUI_Font_getFormattedLineCount00);
+   tolua_function(tolua_S,"getFormattedTextExtent",tolua_CEGUI_CEGUI_Font_getFormattedTextExtent00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"FontManager","CEGUI::FontManager","",NULL);
+  tolua_beginmodule(tolua_S,"FontManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_FontManager_getSingleton00);
+   tolua_function(tolua_S,"createFont",tolua_CEGUI_CEGUI_FontManager_createFont00);
+   tolua_function(tolua_S,"createFont",tolua_CEGUI_CEGUI_FontManager_createFont01);
+   tolua_function(tolua_S,"destroyFont",tolua_CEGUI_CEGUI_FontManager_destroyFont00);
+   tolua_function(tolua_S,"destroyFont",tolua_CEGUI_CEGUI_FontManager_destroyFont01);
+   tolua_function(tolua_S,"destroyAllFonts",tolua_CEGUI_CEGUI_FontManager_destroyAllFonts00);
+   tolua_function(tolua_S,"isFontPresent",tolua_CEGUI_CEGUI_FontManager_isFontPresent00);
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_FontManager_getFont00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_FontManager_notifyScreenResolution00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_FontManager_getIterator00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Image","CEGUI::Image","",tolua_collect_CEGUI__Image);
+  #else
+  tolua_cclass(tolua_S,"Image","CEGUI::Image","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Image");
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Image_getSize00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Image_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Image_getHeight00);
+   tolua_function(tolua_S,"getOffsets",tolua_CEGUI_CEGUI_Image_getOffsets00);
+   tolua_function(tolua_S,"getOffsetX",tolua_CEGUI_CEGUI_Image_getOffsetX00);
+   tolua_function(tolua_S,"getOffsetY",tolua_CEGUI_CEGUI_Image_getOffsetY00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Image_getName00);
+   tolua_function(tolua_S,"getImagesetName",tolua_CEGUI_CEGUI_Image_getImagesetName00);
+   tolua_function(tolua_S,"getSourceTextureArea",tolua_CEGUI_CEGUI_Image_getSourceTextureArea00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Texture","CEGUI::Texture","",NULL);
+  tolua_beginmodule(tolua_S,"Texture");
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Texture_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Texture_getHeight00);
+   tolua_function(tolua_S,"loadFromFile",tolua_CEGUI_CEGUI_Texture_loadFromFile00);
+   tolua_function(tolua_S,"getRenderer",tolua_CEGUI_CEGUI_Texture_getRenderer00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Imageset","CEGUI::Imageset","",NULL);
+  tolua_beginmodule(tolua_S,"Imageset");
+   tolua_function(tolua_S,"getTexture",tolua_CEGUI_CEGUI_Imageset_getTexture00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Imageset_getName00);
+   tolua_function(tolua_S,"getImageCount",tolua_CEGUI_CEGUI_Imageset_getImageCount00);
+   tolua_function(tolua_S,"isImageDefined",tolua_CEGUI_CEGUI_Imageset_isImageDefined00);
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_Imageset_getImage00);
+   tolua_function(tolua_S,"undefineImage",tolua_CEGUI_CEGUI_Imageset_undefineImage00);
+   tolua_function(tolua_S,"undefineAllImages",tolua_CEGUI_CEGUI_Imageset_undefineAllImages00);
+   tolua_function(tolua_S,"getImageSize",tolua_CEGUI_CEGUI_Imageset_getImageSize00);
+   tolua_function(tolua_S,"getImageWidth",tolua_CEGUI_CEGUI_Imageset_getImageWidth00);
+   tolua_function(tolua_S,"getImageHeight",tolua_CEGUI_CEGUI_Imageset_getImageHeight00);
+   tolua_function(tolua_S,"getImageOffset",tolua_CEGUI_CEGUI_Imageset_getImageOffset00);
+   tolua_function(tolua_S,"getImageOffsetX",tolua_CEGUI_CEGUI_Imageset_getImageOffsetX00);
+   tolua_function(tolua_S,"getImageOffsetY",tolua_CEGUI_CEGUI_Imageset_getImageOffsetY00);
+   tolua_function(tolua_S,"defineImage",tolua_CEGUI_CEGUI_Imageset_defineImage00);
+   tolua_function(tolua_S,"defineImage",tolua_CEGUI_CEGUI_Imageset_defineImage01);
+   tolua_function(tolua_S,"isAutoScaled",tolua_CEGUI_CEGUI_Imageset_isAutoScaled00);
+   tolua_function(tolua_S,"setAutoScalingEnabled",tolua_CEGUI_CEGUI_Imageset_setAutoScalingEnabled00);
+   tolua_function(tolua_S,"getNativeResolution",tolua_CEGUI_CEGUI_Imageset_getNativeResolution00);
+   tolua_function(tolua_S,"setNativeResolution",tolua_CEGUI_CEGUI_Imageset_setNativeResolution00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_Imageset_notifyScreenResolution00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_Imageset_getIterator00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_Imageset_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_Imageset_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ImagesetManager","CEGUI::ImagesetManager","",NULL);
+  tolua_beginmodule(tolua_S,"ImagesetManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_ImagesetManager_getSingleton00);
+   tolua_function(tolua_S,"createImageset",tolua_CEGUI_CEGUI_ImagesetManager_createImageset00);
+   tolua_function(tolua_S,"createImageset",tolua_CEGUI_CEGUI_ImagesetManager_createImageset01);
+   tolua_function(tolua_S,"createImagesetFromImageFile",tolua_CEGUI_CEGUI_ImagesetManager_createImagesetFromImageFile00);
+   tolua_function(tolua_S,"destroyImageset",tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00);
+   tolua_function(tolua_S,"destroyImageset",tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset01);
+   tolua_function(tolua_S,"destroyAllImagesets",tolua_CEGUI_CEGUI_ImagesetManager_destroyAllImagesets00);
+   tolua_function(tolua_S,"getImageset",tolua_CEGUI_CEGUI_ImagesetManager_getImageset00);
+   tolua_function(tolua_S,"isImagesetPresent",tolua_CEGUI_CEGUI_ImagesetManager_isImagesetPresent00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_ImagesetManager_notifyScreenResolution00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_ImagesetManager_getIterator00);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73,
+    46,105,116,101,114, 97,116,111,114, 95,105,109,112,108, 95,
+   110,101,120,116, 40,112, 41, 10,105,102, 32,112, 58,105,115,
+    65,116, 69,110,100, 40, 41, 32,116,104,101,110, 10,114,101,
+   116,117,114,110, 32,110,105,108, 59, 10,101,110,100, 10,108,
+   111, 99, 97,108, 32,107, 44,118, 32, 61, 32,112, 58,107,101,
+   121, 40, 41, 44, 32,112, 58,118, 97,108,117,101, 40, 41, 59,
+    10,112, 58,110,101,120,116, 40, 41, 59, 10,114,101,116,117,
+   114,110, 32,107, 44,118, 59, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,105,116,101,
+   114, 97,116,111,114, 95,105,109,112,108, 40,115,101,108,102,
+    41, 10,114,101,116,117,114,110, 32, 67, 69, 71, 85, 73, 46,
+   105,116,101,114, 97,116,111,114, 95,105,109,112,108, 95,110,
+   101,120,116, 44, 32,115,101,108,102, 59, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 2");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  tolua_cclass(tolua_S,"Property","CEGUI::Property","",NULL);
+  tolua_beginmodule(tolua_S,"Property");
+   tolua_function(tolua_S,"getHelp",tolua_CEGUI_CEGUI_Property_getHelp00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Property_getName00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyIterator","CEGUI::PropertyIterator","",tolua_collect_CEGUI__PropertyIterator);
+  #else
+  tolua_cclass(tolua_S,"PropertyIterator","CEGUI::PropertyIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_PropertyIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_PropertyIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_PropertyIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_PropertyIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_PropertyIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_PropertyIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_PropertyIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_PropertyIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_PropertyIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 80,114,111,112,101,114,116,121,
+    73,116,101,114, 97,116,111,114, 46,105,116,101,114, 97,116,
+   111,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114,
+    97,116,111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 3");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"EventIterator","CEGUI::EventIterator","",tolua_collect_CEGUI__EventIterator);
+  #else
+  tolua_cclass(tolua_S,"EventIterator","CEGUI::EventIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"EventIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_EventIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_EventIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_EventIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_EventIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_EventIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_EventIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_EventIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_EventIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_EventIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_EventIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_EventIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_EventIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116, 73,116,101,
+   114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,111,
+   114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 4");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WindowIterator","CEGUI::WindowIterator","",tolua_collect_CEGUI__WindowIterator);
+  #else
+  tolua_cclass(tolua_S,"WindowIterator","CEGUI::WindowIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WindowIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_WindowIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_WindowIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_WindowIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_WindowIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_WindowIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_WindowIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_WindowIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_WindowIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_WindowIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WindowIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WindowIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WindowIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 73,116,
+   101,114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114,
+    32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,
+   111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 5");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WindowFactoryIterator","CEGUI::WindowFactoryIterator","",tolua_collect_CEGUI__WindowFactoryIterator);
+  #else
+  tolua_cclass(tolua_S,"WindowFactoryIterator","CEGUI::WindowFactoryIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WindowFactoryIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_WindowFactoryIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_WindowFactoryIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_WindowFactoryIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_WindowFactoryIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_WindowFactoryIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_WindowFactoryIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_WindowFactoryIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WindowFactoryIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 70, 97,
+    99,116,111,114,121, 73,116,101,114, 97,116,111,114, 46,105,
+   116,101,114, 97,116,111,114, 32, 61, 32, 67, 69, 71, 85, 73,
+    46,105,116,101,114, 97,116,111,114, 95,105,109,112,108, 59,
+   32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 6");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FalagardMappingIterator","CEGUI::FalagardMappingIterator","",tolua_collect_CEGUI__FalagardMappingIterator);
+  #else
+  tolua_cclass(tolua_S,"FalagardMappingIterator","CEGUI::FalagardMappingIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FalagardMappingIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_FalagardMappingIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_FalagardMappingIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_FalagardMappingIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_FalagardMappingIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_FalagardMappingIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_FalagardMappingIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_FalagardMappingIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FalagardMappingIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 70, 97,108, 97,103, 97,114,100,
+    77, 97,112,112,105,110,103, 73,116,101,114, 97,116,111,114,
+    46,105,116,101,114, 97,116,111,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,105,116,101,114, 97,116,111,114, 95,105,109,112,
+   108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 7");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImagesetIterator","CEGUI::ImagesetIterator","",tolua_collect_CEGUI__ImagesetIterator);
+  #else
+  tolua_cclass(tolua_S,"ImagesetIterator","CEGUI::ImagesetIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImagesetIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_ImagesetIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_ImagesetIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_ImagesetIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_ImagesetIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_ImagesetIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_ImagesetIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_ImagesetIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_ImagesetIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_ImagesetIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImagesetIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImagesetIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImagesetIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 73,109, 97,103,101,115,101,116,
+    73,116,101,114, 97,116,111,114, 46,105,116,101,114, 97,116,
+   111,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114,
+    97,116,111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 8");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImageIterator","CEGUI::ImageIterator","",tolua_collect_CEGUI__ImageIterator);
+  #else
+  tolua_cclass(tolua_S,"ImageIterator","CEGUI::ImageIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImageIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_ImageIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_ImageIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_ImageIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_ImageIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_ImageIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_ImageIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_ImageIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_ImageIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_ImageIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImageIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImageIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImageIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 73,109, 97,103,101, 73,116,101,
+   114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,111,
+   114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 9");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"SchemeIterator","CEGUI::SchemeIterator","",tolua_collect_CEGUI__SchemeIterator);
+  #else
+  tolua_cclass(tolua_S,"SchemeIterator","CEGUI::SchemeIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"SchemeIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_SchemeIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_SchemeIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_SchemeIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_SchemeIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_SchemeIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_SchemeIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_SchemeIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_SchemeIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_SchemeIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_SchemeIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_SchemeIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_SchemeIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 83, 99,104,101,109,101, 73,116,
+   101,114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114,
+    32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,
+   111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 10");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FontIterator","CEGUI::FontIterator","",tolua_collect_CEGUI__FontIterator);
+  #else
+  tolua_cclass(tolua_S,"FontIterator","CEGUI::FontIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FontIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_FontIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_FontIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_FontIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_FontIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_FontIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_FontIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_FontIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_FontIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_FontIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FontIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FontIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FontIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 70,111,110,116, 73,116,101,114,
+    97,116,111,114, 46,105,116,101,114, 97,116,111,114, 32, 61,
+    32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,111,114,
+    95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 11");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  tolua_module(tolua_S,"Key",0);
+  tolua_beginmodule(tolua_S,"Key");
+   tolua_constant(tolua_S,"Escape",CEGUI::Key::Escape);
+   tolua_constant(tolua_S,"One",CEGUI::Key::One);
+   tolua_constant(tolua_S,"Two",CEGUI::Key::Two);
+   tolua_constant(tolua_S,"Three",CEGUI::Key::Three);
+   tolua_constant(tolua_S,"Four",CEGUI::Key::Four);
+   tolua_constant(tolua_S,"Five",CEGUI::Key::Five);
+   tolua_constant(tolua_S,"Six",CEGUI::Key::Six);
+   tolua_constant(tolua_S,"Seven",CEGUI::Key::Seven);
+   tolua_constant(tolua_S,"Eight",CEGUI::Key::Eight);
+   tolua_constant(tolua_S,"Nine",CEGUI::Key::Nine);
+   tolua_constant(tolua_S,"Zero",CEGUI::Key::Zero);
+   tolua_constant(tolua_S,"Minus",CEGUI::Key::Minus);
+   tolua_constant(tolua_S,"Equals",CEGUI::Key::Equals);
+   tolua_constant(tolua_S,"Backspace",CEGUI::Key::Backspace);
+   tolua_constant(tolua_S,"Tab",CEGUI::Key::Tab);
+   tolua_constant(tolua_S,"Q",CEGUI::Key::Q);
+   tolua_constant(tolua_S,"W",CEGUI::Key::W);
+   tolua_constant(tolua_S,"E",CEGUI::Key::E);
+   tolua_constant(tolua_S,"R",CEGUI::Key::R);
+   tolua_constant(tolua_S,"T",CEGUI::Key::T);
+   tolua_constant(tolua_S,"Y",CEGUI::Key::Y);
+   tolua_constant(tolua_S,"U",CEGUI::Key::U);
+   tolua_constant(tolua_S,"I",CEGUI::Key::I);
+   tolua_constant(tolua_S,"O",CEGUI::Key::O);
+   tolua_constant(tolua_S,"P",CEGUI::Key::P);
+   tolua_constant(tolua_S,"LeftBracket",CEGUI::Key::LeftBracket);
+   tolua_constant(tolua_S,"RightBracket",CEGUI::Key::RightBracket);
+   tolua_constant(tolua_S,"Return",CEGUI::Key::Return);
+   tolua_constant(tolua_S,"LeftControl",CEGUI::Key::LeftControl);
+   tolua_constant(tolua_S,"A",CEGUI::Key::A);
+   tolua_constant(tolua_S,"S",CEGUI::Key::S);
+   tolua_constant(tolua_S,"D",CEGUI::Key::D);
+   tolua_constant(tolua_S,"F",CEGUI::Key::F);
+   tolua_constant(tolua_S,"G",CEGUI::Key::G);
+   tolua_constant(tolua_S,"H",CEGUI::Key::H);
+   tolua_constant(tolua_S,"J",CEGUI::Key::J);
+   tolua_constant(tolua_S,"K",CEGUI::Key::K);
+   tolua_constant(tolua_S,"L",CEGUI::Key::L);
+   tolua_constant(tolua_S,"Semicolon",CEGUI::Key::Semicolon);
+   tolua_constant(tolua_S,"Apostrophe",CEGUI::Key::Apostrophe);
+   tolua_constant(tolua_S,"Grave",CEGUI::Key::Grave);
+   tolua_constant(tolua_S,"LeftShift",CEGUI::Key::LeftShift);
+   tolua_constant(tolua_S,"Backslash",CEGUI::Key::Backslash);
+   tolua_constant(tolua_S,"Z",CEGUI::Key::Z);
+   tolua_constant(tolua_S,"X",CEGUI::Key::X);
+   tolua_constant(tolua_S,"C",CEGUI::Key::C);
+   tolua_constant(tolua_S,"V",CEGUI::Key::V);
+   tolua_constant(tolua_S,"B",CEGUI::Key::B);
+   tolua_constant(tolua_S,"N",CEGUI::Key::N);
+   tolua_constant(tolua_S,"M",CEGUI::Key::M);
+   tolua_constant(tolua_S,"Comma",CEGUI::Key::Comma);
+   tolua_constant(tolua_S,"Period",CEGUI::Key::Period);
+   tolua_constant(tolua_S,"Slash",CEGUI::Key::Slash);
+   tolua_constant(tolua_S,"RightShift",CEGUI::Key::RightShift);
+   tolua_constant(tolua_S,"Multiply",CEGUI::Key::Multiply);
+   tolua_constant(tolua_S,"LeftAlt",CEGUI::Key::LeftAlt);
+   tolua_constant(tolua_S,"Space",CEGUI::Key::Space);
+   tolua_constant(tolua_S,"Capital",CEGUI::Key::Capital);
+   tolua_constant(tolua_S,"F1",CEGUI::Key::F1);
+   tolua_constant(tolua_S,"F2",CEGUI::Key::F2);
+   tolua_constant(tolua_S,"F3",CEGUI::Key::F3);
+   tolua_constant(tolua_S,"F4",CEGUI::Key::F4);
+   tolua_constant(tolua_S,"F5",CEGUI::Key::F5);
+   tolua_constant(tolua_S,"F6",CEGUI::Key::F6);
+   tolua_constant(tolua_S,"F7",CEGUI::Key::F7);
+   tolua_constant(tolua_S,"F8",CEGUI::Key::F8);
+   tolua_constant(tolua_S,"F9",CEGUI::Key::F9);
+   tolua_constant(tolua_S,"F10",CEGUI::Key::F10);
+   tolua_constant(tolua_S,"NumLock",CEGUI::Key::NumLock);
+   tolua_constant(tolua_S,"ScrollLock",CEGUI::Key::ScrollLock);
+   tolua_constant(tolua_S,"Numpad7",CEGUI::Key::Numpad7);
+   tolua_constant(tolua_S,"Numpad8",CEGUI::Key::Numpad8);
+   tolua_constant(tolua_S,"Numpad9",CEGUI::Key::Numpad9);
+   tolua_constant(tolua_S,"Subtract",CEGUI::Key::Subtract);
+   tolua_constant(tolua_S,"Numpad4",CEGUI::Key::Numpad4);
+   tolua_constant(tolua_S,"Numpad5",CEGUI::Key::Numpad5);
+   tolua_constant(tolua_S,"Numpad6",CEGUI::Key::Numpad6);
+   tolua_constant(tolua_S,"Add",CEGUI::Key::Add);
+   tolua_constant(tolua_S,"Numpad1",CEGUI::Key::Numpad1);
+   tolua_constant(tolua_S,"Numpad2",CEGUI::Key::Numpad2);
+   tolua_constant(tolua_S,"Numpad3",CEGUI::Key::Numpad3);
+   tolua_constant(tolua_S,"Numpad0",CEGUI::Key::Numpad0);
+   tolua_constant(tolua_S,"Decimal",CEGUI::Key::Decimal);
+   tolua_constant(tolua_S,"OEM_102",CEGUI::Key::OEM_102);
+   tolua_constant(tolua_S,"F11",CEGUI::Key::F11);
+   tolua_constant(tolua_S,"F12",CEGUI::Key::F12);
+   tolua_constant(tolua_S,"F13",CEGUI::Key::F13);
+   tolua_constant(tolua_S,"F14",CEGUI::Key::F14);
+   tolua_constant(tolua_S,"F15",CEGUI::Key::F15);
+   tolua_constant(tolua_S,"Kana",CEGUI::Key::Kana);
+   tolua_constant(tolua_S,"ABNT_C1",CEGUI::Key::ABNT_C1);
+   tolua_constant(tolua_S,"Convert",CEGUI::Key::Convert);
+   tolua_constant(tolua_S,"NoConvert",CEGUI::Key::NoConvert);
+   tolua_constant(tolua_S,"Yen",CEGUI::Key::Yen);
+   tolua_constant(tolua_S,"ABNT_C2",CEGUI::Key::ABNT_C2);
+   tolua_constant(tolua_S,"NumpadEquals",CEGUI::Key::NumpadEquals);
+   tolua_constant(tolua_S,"PrevTrack",CEGUI::Key::PrevTrack);
+   tolua_constant(tolua_S,"At",CEGUI::Key::At);
+   tolua_constant(tolua_S,"Colon",CEGUI::Key::Colon);
+   tolua_constant(tolua_S,"Underline",CEGUI::Key::Underline);
+   tolua_constant(tolua_S,"Kanji",CEGUI::Key::Kanji);
+   tolua_constant(tolua_S,"Stop",CEGUI::Key::Stop);
+   tolua_constant(tolua_S,"AX",CEGUI::Key::AX);
+   tolua_constant(tolua_S,"Unlabeled",CEGUI::Key::Unlabeled);
+   tolua_constant(tolua_S,"NextTrack",CEGUI::Key::NextTrack);
+   tolua_constant(tolua_S,"NumpadEnter",CEGUI::Key::NumpadEnter);
+   tolua_constant(tolua_S,"RightControl",CEGUI::Key::RightControl);
+   tolua_constant(tolua_S,"Mute",CEGUI::Key::Mute);
+   tolua_constant(tolua_S,"Calculator",CEGUI::Key::Calculator);
+   tolua_constant(tolua_S,"PlayPause",CEGUI::Key::PlayPause);
+   tolua_constant(tolua_S,"MediaStop",CEGUI::Key::MediaStop);
+   tolua_constant(tolua_S,"VolumeDown",CEGUI::Key::VolumeDown);
+   tolua_constant(tolua_S,"VolumeUp",CEGUI::Key::VolumeUp);
+   tolua_constant(tolua_S,"WebHome",CEGUI::Key::WebHome);
+   tolua_constant(tolua_S,"NumpadComma",CEGUI::Key::NumpadComma);
+   tolua_constant(tolua_S,"Divide",CEGUI::Key::Divide);
+   tolua_constant(tolua_S,"SysRq",CEGUI::Key::SysRq);
+   tolua_constant(tolua_S,"RightAlt",CEGUI::Key::RightAlt);
+   tolua_constant(tolua_S,"Pause",CEGUI::Key::Pause);
+   tolua_constant(tolua_S,"Home",CEGUI::Key::Home);
+   tolua_constant(tolua_S,"ArrowUp",CEGUI::Key::ArrowUp);
+   tolua_constant(tolua_S,"PageUp",CEGUI::Key::PageUp);
+   tolua_constant(tolua_S,"ArrowLeft",CEGUI::Key::ArrowLeft);
+   tolua_constant(tolua_S,"ArrowRight",CEGUI::Key::ArrowRight);
+   tolua_constant(tolua_S,"End",CEGUI::Key::End);
+   tolua_constant(tolua_S,"ArrowDown",CEGUI::Key::ArrowDown);
+   tolua_constant(tolua_S,"PageDown",CEGUI::Key::PageDown);
+   tolua_constant(tolua_S,"Insert",CEGUI::Key::Insert);
+   tolua_constant(tolua_S,"Delete",CEGUI::Key::Delete);
+   tolua_constant(tolua_S,"LeftWindows",CEGUI::Key::LeftWindows);
+   tolua_constant(tolua_S,"RightWindow",CEGUI::Key::RightWindow);
+   tolua_constant(tolua_S,"AppMenu",CEGUI::Key::AppMenu);
+   tolua_constant(tolua_S,"Power",CEGUI::Key::Power);
+   tolua_constant(tolua_S,"Sleep",CEGUI::Key::Sleep);
+   tolua_constant(tolua_S,"Wake",CEGUI::Key::Wake);
+   tolua_constant(tolua_S,"WebSearch",CEGUI::Key::WebSearch);
+   tolua_constant(tolua_S,"WebFavorites",CEGUI::Key::WebFavorites);
+   tolua_constant(tolua_S,"WebRefresh",CEGUI::Key::WebRefresh);
+   tolua_constant(tolua_S,"WebStop",CEGUI::Key::WebStop);
+   tolua_constant(tolua_S,"WebForward",CEGUI::Key::WebForward);
+   tolua_constant(tolua_S,"WebBack",CEGUI::Key::WebBack);
+   tolua_constant(tolua_S,"MyComputer",CEGUI::Key::MyComputer);
+   tolua_constant(tolua_S,"Mail",CEGUI::Key::Mail);
+   tolua_constant(tolua_S,"MediaSelect",CEGUI::Key::MediaSelect);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"LeftMouse",CEGUI::LeftMouse);
+  tolua_constant(tolua_S,"RightMouse",CEGUI::RightMouse);
+  tolua_constant(tolua_S,"Shift",CEGUI::Shift);
+  tolua_constant(tolua_S,"Control",CEGUI::Control);
+  tolua_constant(tolua_S,"MiddleMouse",CEGUI::MiddleMouse);
+  tolua_constant(tolua_S,"X1Mouse",CEGUI::X1Mouse);
+  tolua_constant(tolua_S,"X2Mouse",CEGUI::X2Mouse);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"EventArgs","CEGUI::EventArgs","",tolua_collect_CEGUI__EventArgs);
+  #else
+  tolua_cclass(tolua_S,"EventArgs","CEGUI::EventArgs","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"EventArgs");
+   tolua_variable(tolua_S,"handled",tolua_get_CEGUI__EventArgs_handled,tolua_set_CEGUI__EventArgs_handled);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_EventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_EventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_EventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"MouseCursorEventArgs","CEGUI::MouseCursorEventArgs","CEGUI::EventArgs",tolua_collect_CEGUI__MouseCursorEventArgs);
+  #else
+  tolua_cclass(tolua_S,"MouseCursorEventArgs","CEGUI::MouseCursorEventArgs","CEGUI::EventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"MouseCursorEventArgs");
+   tolua_variable(tolua_S,"mouseCursor",tolua_get_CEGUI__MouseCursorEventArgs_mouseCursor_ptr,tolua_set_CEGUI__MouseCursorEventArgs_mouseCursor_ptr);
+   tolua_variable(tolua_S,"image",tolua_get_CEGUI__MouseCursorEventArgs_image_ptr,NULL);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WindowEventArgs","CEGUI::WindowEventArgs","CEGUI::EventArgs",tolua_collect_CEGUI__WindowEventArgs);
+  #else
+  tolua_cclass(tolua_S,"WindowEventArgs","CEGUI::WindowEventArgs","CEGUI::EventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WindowEventArgs");
+   tolua_variable(tolua_S,"window",tolua_get_CEGUI__WindowEventArgs_window_ptr,tolua_set_CEGUI__WindowEventArgs_window_ptr);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WindowEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WindowEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WindowEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ActivationEventArgs","CEGUI::ActivationEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__ActivationEventArgs);
+  #else
+  tolua_cclass(tolua_S,"ActivationEventArgs","CEGUI::ActivationEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ActivationEventArgs");
+   tolua_variable(tolua_S,"otherWindow",tolua_get_CEGUI__ActivationEventArgs_otherWindow_ptr,tolua_set_CEGUI__ActivationEventArgs_otherWindow_ptr);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ActivationEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"HeaderSequenceEventArgs","CEGUI::HeaderSequenceEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__HeaderSequenceEventArgs);
+  #else
+  tolua_cclass(tolua_S,"HeaderSequenceEventArgs","CEGUI::HeaderSequenceEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"HeaderSequenceEventArgs");
+   tolua_variable(tolua_S,"oldIdx",tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx,tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx);
+   tolua_variable(tolua_S,"newIdx",tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx,tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"LeftButton",CEGUI::LeftButton);
+  tolua_constant(tolua_S,"RightButton",CEGUI::RightButton);
+  tolua_constant(tolua_S,"MiddleButton",CEGUI::MiddleButton);
+  tolua_constant(tolua_S,"X1Button",CEGUI::X1Button);
+  tolua_constant(tolua_S,"X2Button",CEGUI::X2Button);
+  tolua_constant(tolua_S,"MouseButtonCount",CEGUI::MouseButtonCount);
+  tolua_constant(tolua_S,"NoButton",CEGUI::NoButton);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"MouseEventArgs","CEGUI::MouseEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__MouseEventArgs);
+  #else
+  tolua_cclass(tolua_S,"MouseEventArgs","CEGUI::MouseEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"MouseEventArgs");
+   tolua_variable(tolua_S,"position",tolua_get_CEGUI__MouseEventArgs_position,tolua_set_CEGUI__MouseEventArgs_position);
+   tolua_variable(tolua_S,"moveDelta",tolua_get_CEGUI__MouseEventArgs_moveDelta,tolua_set_CEGUI__MouseEventArgs_moveDelta);
+   tolua_variable(tolua_S,"button",tolua_get_CEGUI__MouseEventArgs_button,tolua_set_CEGUI__MouseEventArgs_button);
+   tolua_variable(tolua_S,"sysKeys",tolua_get_CEGUI__MouseEventArgs_unsigned_sysKeys,tolua_set_CEGUI__MouseEventArgs_unsigned_sysKeys);
+   tolua_variable(tolua_S,"wheelChange",tolua_get_CEGUI__MouseEventArgs_wheelChange,tolua_set_CEGUI__MouseEventArgs_wheelChange);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_MouseEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_MouseEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_MouseEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"KeyEventArgs","CEGUI::KeyEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__KeyEventArgs);
+  #else
+  tolua_cclass(tolua_S,"KeyEventArgs","CEGUI::KeyEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"KeyEventArgs");
+   tolua_variable(tolua_S,"codepoint",tolua_get_CEGUI__KeyEventArgs_unsigned_codepoint,tolua_set_CEGUI__KeyEventArgs_unsigned_codepoint);
+   tolua_variable(tolua_S,"scancode",tolua_get_CEGUI__KeyEventArgs_scancode,tolua_set_CEGUI__KeyEventArgs_scancode);
+   tolua_variable(tolua_S,"sysKeys",tolua_get_CEGUI__KeyEventArgs_unsigned_sysKeys,tolua_set_CEGUI__KeyEventArgs_unsigned_sysKeys);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_KeyEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_KeyEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_KeyEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"DragDropEventArgs","CEGUI::DragDropEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__DragDropEventArgs);
+  #else
+  tolua_cclass(tolua_S,"DragDropEventArgs","CEGUI::DragDropEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"DragDropEventArgs");
+   tolua_variable(tolua_S,"dragDropItem",tolua_get_CEGUI__DragDropEventArgs_dragDropItem_ptr,tolua_set_CEGUI__DragDropEventArgs_dragDropItem_ptr);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_DragDropEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Event","CEGUI::Event","",NULL);
+  tolua_beginmodule(tolua_S,"Event");
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Event_getName00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"EventConnection","CEGUI::EventConnection","",tolua_collect_CEGUI__EventConnection);
+  #else
+  tolua_cclass(tolua_S,"EventConnection","CEGUI::EventConnection","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"EventConnection");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"EventSet","CEGUI::EventSet","",NULL);
+  tolua_beginmodule(tolua_S,"EventSet");
+   tolua_function(tolua_S,"addEvent",tolua_CEGUI_CEGUI_EventSet_addEvent00);
+   tolua_function(tolua_S,"removeEvent",tolua_CEGUI_CEGUI_EventSet_removeEvent00);
+   tolua_function(tolua_S,"removeAllEvents",tolua_CEGUI_CEGUI_EventSet_removeAllEvents00);
+   tolua_function(tolua_S,"isEventPresent",tolua_CEGUI_CEGUI_EventSet_isEventPresent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_EventSet_subscribeEvent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_EventSet_subscribeEvent01);
+   tolua_function(tolua_S,"fireEvent",tolua_CEGUI_CEGUI_EventSet_fireEvent00);
+   tolua_function(tolua_S,"isMuted",tolua_CEGUI_CEGUI_EventSet_isMuted00);
+   tolua_function(tolua_S,"setMutedState",tolua_CEGUI_CEGUI_EventSet_setMutedState00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_EventSet_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"GlobalEventSet","CEGUI::GlobalEventSet","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"GlobalEventSet");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_GlobalEventSet_getSingleton00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"BlankMouseCursor",CEGUI::BlankMouseCursor);
+  tolua_constant(tolua_S,"DefaultMouseCursor",CEGUI::DefaultMouseCursor);
+  tolua_cclass(tolua_S,"MouseCursor","CEGUI::MouseCursor","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"MouseCursor");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_MouseCursor_getSingleton00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_MouseCursor_setImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_MouseCursor_setImage01);
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_MouseCursor_getImage00);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_MouseCursor_setPosition00);
+   tolua_function(tolua_S,"offsetPosition",tolua_CEGUI_CEGUI_MouseCursor_offsetPosition00);
+   tolua_function(tolua_S,"setConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_setConstraintArea00);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_MouseCursor_getPosition00);
+   tolua_function(tolua_S,"getConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_getConstraintArea00);
+   tolua_function(tolua_S,"getDisplayIndependantPosition",tolua_CEGUI_CEGUI_MouseCursor_getDisplayIndependantPosition00);
+   tolua_function(tolua_S,"setUnifiedConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_setUnifiedConstraintArea00);
+   tolua_function(tolua_S,"getUnifiedConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_getUnifiedConstraintArea00);
+   tolua_function(tolua_S,"hide",tolua_CEGUI_CEGUI_MouseCursor_hide00);
+   tolua_function(tolua_S,"show",tolua_CEGUI_CEGUI_MouseCursor_show00);
+   tolua_function(tolua_S,"setVisible",tolua_CEGUI_CEGUI_MouseCursor_setVisible00);
+   tolua_function(tolua_S,"isVisible",tolua_CEGUI_CEGUI_MouseCursor_isVisible00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_MouseCursor_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"VA_TOP",CEGUI::VA_TOP);
+  tolua_constant(tolua_S,"VA_CENTRE",CEGUI::VA_CENTRE);
+  tolua_constant(tolua_S,"VA_BOTTOM",CEGUI::VA_BOTTOM);
+  tolua_constant(tolua_S,"HA_LEFT",CEGUI::HA_LEFT);
+  tolua_constant(tolua_S,"HA_CENTRE",CEGUI::HA_CENTRE);
+  tolua_constant(tolua_S,"HA_RIGHT",CEGUI::HA_RIGHT);
+  tolua_cclass(tolua_S,"Window","CEGUI::Window","",NULL);
+  tolua_beginmodule(tolua_S,"Window");
+   tolua_function(tolua_S,"getType",tolua_CEGUI_CEGUI_Window_getType00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Window_getName00);
+   tolua_function(tolua_S,"isDestroyedByParent",tolua_CEGUI_CEGUI_Window_isDestroyedByParent00);
+   tolua_function(tolua_S,"isAlwaysOnTop",tolua_CEGUI_CEGUI_Window_isAlwaysOnTop00);
+   tolua_function(tolua_S,"isDisabled",tolua_CEGUI_CEGUI_Window_isDisabled00);
+   tolua_function(tolua_S,"isVisible",tolua_CEGUI_CEGUI_Window_isVisible00);
+   tolua_function(tolua_S,"isActive",tolua_CEGUI_CEGUI_Window_isActive00);
+   tolua_function(tolua_S,"isClippedByParent",tolua_CEGUI_CEGUI_Window_isClippedByParent00);
+   tolua_function(tolua_S,"setDestroyedByParent",tolua_CEGUI_CEGUI_Window_setDestroyedByParent00);
+   tolua_function(tolua_S,"setAlwaysOnTop",tolua_CEGUI_CEGUI_Window_setAlwaysOnTop00);
+   tolua_function(tolua_S,"setEnabled",tolua_CEGUI_CEGUI_Window_setEnabled00);
+   tolua_function(tolua_S,"enable",tolua_CEGUI_CEGUI_Window_enable00);
+   tolua_function(tolua_S,"disable",tolua_CEGUI_CEGUI_Window_disable00);
+   tolua_function(tolua_S,"setVisible",tolua_CEGUI_CEGUI_Window_setVisible00);
+   tolua_function(tolua_S,"show",tolua_CEGUI_CEGUI_Window_show00);
+   tolua_function(tolua_S,"hide",tolua_CEGUI_CEGUI_Window_hide00);
+   tolua_function(tolua_S,"activate",tolua_CEGUI_CEGUI_Window_activate00);
+   tolua_function(tolua_S,"deactivate",tolua_CEGUI_CEGUI_Window_deactivate00);
+   tolua_function(tolua_S,"setClippedByParent",tolua_CEGUI_CEGUI_Window_setClippedByParent00);
+   tolua_function(tolua_S,"getID",tolua_CEGUI_CEGUI_Window_getID00);
+   tolua_function(tolua_S,"setID",tolua_CEGUI_CEGUI_Window_setID00);
+   tolua_function(tolua_S,"getChildCount",tolua_CEGUI_CEGUI_Window_getChildCount00);
+   tolua_function(tolua_S,"isChild",tolua_CEGUI_CEGUI_Window_isChild00);
+   tolua_function(tolua_S,"isChild",tolua_CEGUI_CEGUI_Window_isChild01);
+   tolua_function(tolua_S,"isChild",tolua_CEGUI_CEGUI_Window_isChild02);
+   tolua_function(tolua_S,"isChildRecursive",tolua_CEGUI_CEGUI_Window_isChildRecursive00);
+   tolua_function(tolua_S,"addChildWindow",tolua_CEGUI_CEGUI_Window_addChildWindow00);
+   tolua_function(tolua_S,"addChildWindow",tolua_CEGUI_CEGUI_Window_addChildWindow01);
+   tolua_function(tolua_S,"removeChildWindow",tolua_CEGUI_CEGUI_Window_removeChildWindow00);
+   tolua_function(tolua_S,"removeChildWindow",tolua_CEGUI_CEGUI_Window_removeChildWindow01);
+   tolua_function(tolua_S,"removeChildWindow",tolua_CEGUI_CEGUI_Window_removeChildWindow02);
+   tolua_function(tolua_S,"getChild",tolua_CEGUI_CEGUI_Window_getChild00);
+   tolua_function(tolua_S,"getChild",tolua_CEGUI_CEGUI_Window_getChild01);
+   tolua_function(tolua_S,"getChildAtIdx",tolua_CEGUI_CEGUI_Window_getChildAtIdx00);
+   tolua_function(tolua_S,"getActiveChild",tolua_CEGUI_CEGUI_Window_getActiveChild00);
+   tolua_function(tolua_S,"getChildAtPosition",tolua_CEGUI_CEGUI_Window_getChildAtPosition00);
+   tolua_function(tolua_S,"getTargetChildAtPosition",tolua_CEGUI_CEGUI_Window_getTargetChildAtPosition00);
+   tolua_function(tolua_S,"getChildRecursive",tolua_CEGUI_CEGUI_Window_getChildRecursive00);
+   tolua_function(tolua_S,"getParent",tolua_CEGUI_CEGUI_Window_getParent00);
+   tolua_function(tolua_S,"isAncestor",tolua_CEGUI_CEGUI_Window_isAncestor00);
+   tolua_function(tolua_S,"isAncestor",tolua_CEGUI_CEGUI_Window_isAncestor01);
+   tolua_function(tolua_S,"isAncestor",tolua_CEGUI_CEGUI_Window_isAncestor02);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_Window_setFont00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_Window_setFont01);
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_Window_getFont00);
+   tolua_function(tolua_S,"setText",tolua_CEGUI_CEGUI_Window_setText00);
+   tolua_function(tolua_S,"getText",tolua_CEGUI_CEGUI_Window_getText00);
+   tolua_function(tolua_S,"inheritsAlpha",tolua_CEGUI_CEGUI_Window_inheritsAlpha00);
+   tolua_function(tolua_S,"getAlpha",tolua_CEGUI_CEGUI_Window_getAlpha00);
+   tolua_function(tolua_S,"getEffectiveAlpha",tolua_CEGUI_CEGUI_Window_getEffectiveAlpha00);
+   tolua_function(tolua_S,"setAlpha",tolua_CEGUI_CEGUI_Window_setAlpha00);
+   tolua_function(tolua_S,"setInheritsAlpha",tolua_CEGUI_CEGUI_Window_setInheritsAlpha00);
+   tolua_function(tolua_S,"requestRedraw",tolua_CEGUI_CEGUI_Window_requestRedraw00);
+   tolua_function(tolua_S,"isZOrderingEnabled",tolua_CEGUI_CEGUI_Window_isZOrderingEnabled00);
+   tolua_function(tolua_S,"setZOrderingEnabled",tolua_CEGUI_CEGUI_Window_setZOrderingEnabled00);
+   tolua_function(tolua_S,"getPixelRect",tolua_CEGUI_CEGUI_Window_getPixelRect00);
+   tolua_function(tolua_S,"getInnerRect",tolua_CEGUI_CEGUI_Window_getInnerRect00);
+   tolua_function(tolua_S,"getUnclippedPixelRect",tolua_CEGUI_CEGUI_Window_getUnclippedPixelRect00);
+   tolua_function(tolua_S,"getUnclippedInnerRect",tolua_CEGUI_CEGUI_Window_getUnclippedInnerRect00);
+   tolua_function(tolua_S,"getParentPixelSize",tolua_CEGUI_CEGUI_Window_getParentPixelSize00);
+   tolua_function(tolua_S,"getParentPixelWidth",tolua_CEGUI_CEGUI_Window_getParentPixelWidth00);
+   tolua_function(tolua_S,"getParentPixelHeight",tolua_CEGUI_CEGUI_Window_getParentPixelHeight00);
+   tolua_function(tolua_S,"getCaptureWindow",tolua_CEGUI_CEGUI_Window_getCaptureWindow00);
+   tolua_function(tolua_S,"setRestoreCapture",tolua_CEGUI_CEGUI_Window_setRestoreCapture00);
+   tolua_function(tolua_S,"restoresOldCapture",tolua_CEGUI_CEGUI_Window_restoresOldCapture00);
+   tolua_function(tolua_S,"distributesCapturedInputs",tolua_CEGUI_CEGUI_Window_distributesCapturedInputs00);
+   tolua_function(tolua_S,"setDistributesCapturedInputs",tolua_CEGUI_CEGUI_Window_setDistributesCapturedInputs00);
+   tolua_function(tolua_S,"captureInput",tolua_CEGUI_CEGUI_Window_captureInput00);
+   tolua_function(tolua_S,"releaseInput",tolua_CEGUI_CEGUI_Window_releaseInput00);
+   tolua_function(tolua_S,"isCapturedByThis",tolua_CEGUI_CEGUI_Window_isCapturedByThis00);
+   tolua_function(tolua_S,"isCapturedByAncestor",tolua_CEGUI_CEGUI_Window_isCapturedByAncestor00);
+   tolua_function(tolua_S,"isCapturedByChild",tolua_CEGUI_CEGUI_Window_isCapturedByChild00);
+   tolua_function(tolua_S,"isHit",tolua_CEGUI_CEGUI_Window_isHit00);
+   tolua_function(tolua_S,"isRiseOnClickEnabled",tolua_CEGUI_CEGUI_Window_isRiseOnClickEnabled00);
+   tolua_function(tolua_S,"setRiseOnClickEnabled",tolua_CEGUI_CEGUI_Window_setRiseOnClickEnabled00);
+   tolua_function(tolua_S,"getMouseCursor",tolua_CEGUI_CEGUI_Window_getMouseCursor00);
+   tolua_function(tolua_S,"setMouseCursor",tolua_CEGUI_CEGUI_Window_setMouseCursor00);
+   tolua_function(tolua_S,"setMouseCursor",tolua_CEGUI_CEGUI_Window_setMouseCursor01);
+   tolua_function(tolua_S,"setMouseCursor",tolua_CEGUI_CEGUI_Window_setMouseCursor02);
+   tolua_function(tolua_S,"moveToFront",tolua_CEGUI_CEGUI_Window_moveToFront00);
+   tolua_function(tolua_S,"moveToBack",tolua_CEGUI_CEGUI_Window_moveToBack00);
+   tolua_function(tolua_S,"wantsMultiClickEvents",tolua_CEGUI_CEGUI_Window_wantsMultiClickEvents00);
+   tolua_function(tolua_S,"isMouseAutoRepeatEnabled",tolua_CEGUI_CEGUI_Window_isMouseAutoRepeatEnabled00);
+   tolua_function(tolua_S,"getAutoRepeatDelay",tolua_CEGUI_CEGUI_Window_getAutoRepeatDelay00);
+   tolua_function(tolua_S,"getAutoRepeatRate",tolua_CEGUI_CEGUI_Window_getAutoRepeatRate00);
+   tolua_function(tolua_S,"setWantsMultiClickEvents",tolua_CEGUI_CEGUI_Window_setWantsMultiClickEvents00);
+   tolua_function(tolua_S,"setMouseAutoRepeatEnabled",tolua_CEGUI_CEGUI_Window_setMouseAutoRepeatEnabled00);
+   tolua_function(tolua_S,"setAutoRepeatDelay",tolua_CEGUI_CEGUI_Window_setAutoRepeatDelay00);
+   tolua_function(tolua_S,"setAutoRepeatRate",tolua_CEGUI_CEGUI_Window_setAutoRepeatRate00);
+   tolua_function(tolua_S,"isUsingDefaultTooltip",tolua_CEGUI_CEGUI_Window_isUsingDefaultTooltip00);
+   tolua_function(tolua_S,"getTooltip",tolua_CEGUI_CEGUI_Window_getTooltip00);
+   tolua_function(tolua_S,"getTooltipType",tolua_CEGUI_CEGUI_Window_getTooltipType00);
+   tolua_function(tolua_S,"getTooltipText",tolua_CEGUI_CEGUI_Window_getTooltipText00);
+   tolua_function(tolua_S,"inheritsTooltipText",tolua_CEGUI_CEGUI_Window_inheritsTooltipText00);
+   tolua_function(tolua_S,"setTooltip",tolua_CEGUI_CEGUI_Window_setTooltip00);
+   tolua_function(tolua_S,"setTooltipType",tolua_CEGUI_CEGUI_Window_setTooltipType00);
+   tolua_function(tolua_S,"setTooltipText",tolua_CEGUI_CEGUI_Window_setTooltipText00);
+   tolua_function(tolua_S,"setInheritsTooltipText",tolua_CEGUI_CEGUI_Window_setInheritsTooltipText00);
+   tolua_function(tolua_S,"testClassName",tolua_CEGUI_CEGUI_Window_testClassName00);
+   tolua_function(tolua_S,"notifyDragDropItemEnters",tolua_CEGUI_CEGUI_Window_notifyDragDropItemEnters00);
+   tolua_function(tolua_S,"notifyDragDropItemLeaves",tolua_CEGUI_CEGUI_Window_notifyDragDropItemLeaves00);
+   tolua_function(tolua_S,"notifyDragDropItemDropped",tolua_CEGUI_CEGUI_Window_notifyDragDropItemDropped00);
+   tolua_function(tolua_S,"getVerticalAlignment",tolua_CEGUI_CEGUI_Window_getVerticalAlignment00);
+   tolua_function(tolua_S,"getHorizontalAlignment",tolua_CEGUI_CEGUI_Window_getHorizontalAlignment00);
+   tolua_function(tolua_S,"setVerticalAlignment",tolua_CEGUI_CEGUI_Window_setVerticalAlignment00);
+   tolua_function(tolua_S,"setHorizontalAlignment",tolua_CEGUI_CEGUI_Window_setHorizontalAlignment00);
+   tolua_function(tolua_S,"getLookNFeel",tolua_CEGUI_CEGUI_Window_getLookNFeel00);
+   tolua_function(tolua_S,"setLookNFeel",tolua_CEGUI_CEGUI_Window_setLookNFeel00);
+   tolua_function(tolua_S,"setWindowRenderer",tolua_CEGUI_CEGUI_Window_setWindowRenderer00);
+   tolua_function(tolua_S,"getWindowRendererName",tolua_CEGUI_CEGUI_Window_getWindowRendererName00);
+   tolua_function(tolua_S,"getModalState",tolua_CEGUI_CEGUI_Window_getModalState00);
+   tolua_function(tolua_S,"setModalState",tolua_CEGUI_CEGUI_Window_setModalState00);
+   tolua_function(tolua_S,"getUserString",tolua_CEGUI_CEGUI_Window_getUserString00);
+   tolua_function(tolua_S,"isUserStringDefined",tolua_CEGUI_CEGUI_Window_isUserStringDefined00);
+   tolua_function(tolua_S,"setUserString",tolua_CEGUI_CEGUI_Window_setUserString00);
+   tolua_function(tolua_S,"beginInitialisation",tolua_CEGUI_CEGUI_Window_beginInitialisation00);
+   tolua_function(tolua_S,"endInitialisation",tolua_CEGUI_CEGUI_Window_endInitialisation00);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_Window_setArea00);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_Window_setArea01);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_Window_setArea02);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_Window_setPosition00);
+   tolua_function(tolua_S,"setXPosition",tolua_CEGUI_CEGUI_Window_setXPosition00);
+   tolua_function(tolua_S,"setYPosition",tolua_CEGUI_CEGUI_Window_setYPosition00);
+   tolua_function(tolua_S,"setSize",tolua_CEGUI_CEGUI_Window_setSize00);
+   tolua_function(tolua_S,"setWidth",tolua_CEGUI_CEGUI_Window_setWidth00);
+   tolua_function(tolua_S,"setHeight",tolua_CEGUI_CEGUI_Window_setHeight00);
+   tolua_function(tolua_S,"setMaxSize",tolua_CEGUI_CEGUI_Window_setMaxSize00);
+   tolua_function(tolua_S,"setMinSize",tolua_CEGUI_CEGUI_Window_setMinSize00);
+   tolua_function(tolua_S,"getArea",tolua_CEGUI_CEGUI_Window_getArea00);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_Window_getPosition00);
+   tolua_function(tolua_S,"getXPosition",tolua_CEGUI_CEGUI_Window_getXPosition00);
+   tolua_function(tolua_S,"getYPosition",tolua_CEGUI_CEGUI_Window_getYPosition00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Window_getSize00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Window_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Window_getHeight00);
+   tolua_function(tolua_S,"getMaxSize",tolua_CEGUI_CEGUI_Window_getMaxSize00);
+   tolua_function(tolua_S,"getMinSize",tolua_CEGUI_CEGUI_Window_getMinSize00);
+   tolua_function(tolua_S,"isMousePassThroughEnabled",tolua_CEGUI_CEGUI_Window_isMousePassThroughEnabled00);
+   tolua_function(tolua_S,"setMousePassThroughEnabled",tolua_CEGUI_CEGUI_Window_setMousePassThroughEnabled00);
+   tolua_function(tolua_S,"rename",tolua_CEGUI_CEGUI_Window_rename00);
+   tolua_function(tolua_S,"setProperty",tolua_CEGUI_CEGUI_Window_setProperty00);
+   tolua_function(tolua_S,"getProperty",tolua_CEGUI_CEGUI_Window_getProperty00);
+   tolua_function(tolua_S,"getPropertyDefault",tolua_CEGUI_CEGUI_Window_getPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyHelp",tolua_CEGUI_CEGUI_Window_getPropertyHelp00);
+   tolua_function(tolua_S,"isPropertyPresent",tolua_CEGUI_CEGUI_Window_isPropertyPresent00);
+   tolua_function(tolua_S,"isPropertyDefault",tolua_CEGUI_CEGUI_Window_isPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyIterator",tolua_CEGUI_CEGUI_Window_getPropertyIterator00);
+   tolua_function(tolua_S,"addEvent",tolua_CEGUI_CEGUI_Window_addEvent00);
+   tolua_function(tolua_S,"removeEvent",tolua_CEGUI_CEGUI_Window_removeEvent00);
+   tolua_function(tolua_S,"removeAllEvents",tolua_CEGUI_CEGUI_Window_removeAllEvents00);
+   tolua_function(tolua_S,"isEventPresent",tolua_CEGUI_CEGUI_Window_isEventPresent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_Window_subscribeEvent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_Window_subscribeEvent01);
+   tolua_function(tolua_S,"fireEvent",tolua_CEGUI_CEGUI_Window_fireEvent00);
+   tolua_function(tolua_S,"isMuted",tolua_CEGUI_CEGUI_Window_isMuted00);
+   tolua_function(tolua_S,"setMutedState",tolua_CEGUI_CEGUI_Window_setMutedState00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_Window_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"CoordConverter","CEGUI::CoordConverter","",NULL);
+  tolua_beginmodule(tolua_S,"CoordConverter");
+   tolua_function(tolua_S,"windowToScreenX",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00);
+   tolua_function(tolua_S,"windowToScreenX",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX01);
+   tolua_function(tolua_S,"windowToScreenY",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00);
+   tolua_function(tolua_S,"windowToScreenY",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY01);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen03);
+   tolua_function(tolua_S,"screenToWindowX",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00);
+   tolua_function(tolua_S,"screenToWindowX",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX01);
+   tolua_function(tolua_S,"screenToWindowY",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00);
+   tolua_function(tolua_S,"screenToWindowY",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY01);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow03);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Renderer","CEGUI::Renderer","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"Renderer");
+   tolua_function(tolua_S,"getCurrentZ",tolua_CEGUI_CEGUI_Renderer_getCurrentZ00);
+   tolua_function(tolua_S,"getZLayer",tolua_CEGUI_CEGUI_Renderer_getZLayer00);
+   tolua_function(tolua_S,"isQueueingEnabled",tolua_CEGUI_CEGUI_Renderer_isQueueingEnabled00);
+   tolua_function(tolua_S,"createTexture",tolua_CEGUI_CEGUI_Renderer_createTexture00);
+   tolua_function(tolua_S,"createTexture",tolua_CEGUI_CEGUI_Renderer_createTexture01);
+   tolua_function(tolua_S,"createTexture",tolua_CEGUI_CEGUI_Renderer_createTexture02);
+   tolua_function(tolua_S,"destroyTexture",tolua_CEGUI_CEGUI_Renderer_destroyTexture00);
+   tolua_function(tolua_S,"destroyAllTextures",tolua_CEGUI_CEGUI_Renderer_destroyAllTextures00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Renderer_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Renderer_getHeight00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Renderer_getSize00);
+   tolua_function(tolua_S,"getRect",tolua_CEGUI_CEGUI_Renderer_getRect00);
+   tolua_function(tolua_S,"getMaxTextureSize",tolua_CEGUI_CEGUI_Renderer_getMaxTextureSize00);
+   tolua_function(tolua_S,"getHorzScreenDPI",tolua_CEGUI_CEGUI_Renderer_getHorzScreenDPI00);
+   tolua_function(tolua_S,"getVertScreenDPI",tolua_CEGUI_CEGUI_Renderer_getVertScreenDPI00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_Renderer_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"System","CEGUI::System","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"System");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_System_getSingleton00);
+   tolua_function(tolua_S,"getRenderer",tolua_CEGUI_CEGUI_System_getRenderer00);
+   tolua_function(tolua_S,"setDefaultFont",tolua_CEGUI_CEGUI_System_setDefaultFont00);
+   tolua_function(tolua_S,"setDefaultFont",tolua_CEGUI_CEGUI_System_setDefaultFont01);
+   tolua_function(tolua_S,"getDefaultFont",tolua_CEGUI_CEGUI_System_getDefaultFont00);
+   tolua_function(tolua_S,"signalRedraw",tolua_CEGUI_CEGUI_System_signalRedraw00);
+   tolua_function(tolua_S,"isRedrawRequested",tolua_CEGUI_CEGUI_System_isRedrawRequested00);
+   tolua_function(tolua_S,"renderGUI",tolua_CEGUI_CEGUI_System_renderGUI00);
+   tolua_function(tolua_S,"setGUISheet",tolua_CEGUI_CEGUI_System_setGUISheet00);
+   tolua_function(tolua_S,"getGUISheet",tolua_CEGUI_CEGUI_System_getGUISheet00);
+   tolua_function(tolua_S,"setSingleClickTimeout",tolua_CEGUI_CEGUI_System_setSingleClickTimeout00);
+   tolua_function(tolua_S,"setMultiClickTimeout",tolua_CEGUI_CEGUI_System_setMultiClickTimeout00);
+   tolua_function(tolua_S,"setMultiClickToleranceAreaSize",tolua_CEGUI_CEGUI_System_setMultiClickToleranceAreaSize00);
+   tolua_function(tolua_S,"getSingleClickTimeout",tolua_CEGUI_CEGUI_System_getSingleClickTimeout00);
+   tolua_function(tolua_S,"getMultiClickTimeout",tolua_CEGUI_CEGUI_System_getMultiClickTimeout00);
+   tolua_function(tolua_S,"getMultiClickToleranceAreaSize",tolua_CEGUI_CEGUI_System_getMultiClickToleranceAreaSize00);
+   tolua_function(tolua_S,"setDefaultMouseCursor",tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00);
+   tolua_function(tolua_S,"setDefaultMouseCursor",tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01);
+   tolua_function(tolua_S,"setDefaultMouseCursor",tolua_CEGUI_CEGUI_System_setDefaultMouseCursor02);
+   tolua_function(tolua_S,"getDefaultMouseCursor",tolua_CEGUI_CEGUI_System_getDefaultMouseCursor00);
+   tolua_function(tolua_S,"getWindowContainingMouse",tolua_CEGUI_CEGUI_System_getWindowContainingMouse00);
+   tolua_function(tolua_S,"executeScriptFile",tolua_CEGUI_CEGUI_System_executeScriptFile00);
+   tolua_function(tolua_S,"executeScriptGlobal",tolua_CEGUI_CEGUI_System_executeScriptGlobal00);
+   tolua_function(tolua_S,"executeScriptString",tolua_CEGUI_CEGUI_System_executeScriptString00);
+   tolua_function(tolua_S,"getMouseMoveScaling",tolua_CEGUI_CEGUI_System_getMouseMoveScaling00);
+   tolua_function(tolua_S,"setMouseMoveScaling",tolua_CEGUI_CEGUI_System_setMouseMoveScaling00);
+   tolua_function(tolua_S,"notifyWindowDestroyed",tolua_CEGUI_CEGUI_System_notifyWindowDestroyed00);
+   tolua_function(tolua_S,"isSystemKeyDown",tolua_CEGUI_CEGUI_System_isSystemKeyDown00);
+   tolua_function(tolua_S,"setDefaultTooltip",tolua_CEGUI_CEGUI_System_setDefaultTooltip00);
+   tolua_function(tolua_S,"setDefaultTooltip",tolua_CEGUI_CEGUI_System_setDefaultTooltip01);
+   tolua_function(tolua_S,"getDefaultTooltip",tolua_CEGUI_CEGUI_System_getDefaultTooltip00);
+   tolua_function(tolua_S,"injectMouseMove",tolua_CEGUI_CEGUI_System_injectMouseMove00);
+   tolua_function(tolua_S,"injectMouseLeaves",tolua_CEGUI_CEGUI_System_injectMouseLeaves00);
+   tolua_function(tolua_S,"injectMouseButtonDown",tolua_CEGUI_CEGUI_System_injectMouseButtonDown00);
+   tolua_function(tolua_S,"injectMouseButtonUp",tolua_CEGUI_CEGUI_System_injectMouseButtonUp00);
+   tolua_function(tolua_S,"injectKeyDown",tolua_CEGUI_CEGUI_System_injectKeyDown00);
+   tolua_function(tolua_S,"injectKeyUp",tolua_CEGUI_CEGUI_System_injectKeyUp00);
+   tolua_function(tolua_S,"injectChar",tolua_CEGUI_CEGUI_System_injectChar00);
+   tolua_function(tolua_S,"injectMouseWheelChange",tolua_CEGUI_CEGUI_System_injectMouseWheelChange00);
+   tolua_function(tolua_S,"injectMousePosition",tolua_CEGUI_CEGUI_System_injectMousePosition00);
+   tolua_function(tolua_S,"injectTimePulse",tolua_CEGUI_CEGUI_System_injectTimePulse00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_System_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"WindowManager","CEGUI::WindowManager","",NULL);
+  tolua_beginmodule(tolua_S,"WindowManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_WindowManager_getSingleton00);
+   tolua_function(tolua_S,"createWindow",tolua_CEGUI_CEGUI_WindowManager_createWindow00);
+   tolua_function(tolua_S,"loadWindowLayout",tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout00);
+   tolua_function(tolua_S,"writeWindowLayoutToStream",tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00);
+   tolua_function(tolua_S,"writeWindowLayoutToStream",tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream01);
+   tolua_function(tolua_S,"destroyWindow",tolua_CEGUI_CEGUI_WindowManager_destroyWindow00);
+   tolua_function(tolua_S,"destroyWindow",tolua_CEGUI_CEGUI_WindowManager_destroyWindow01);
+   tolua_function(tolua_S,"destroyAllWindows",tolua_CEGUI_CEGUI_WindowManager_destroyAllWindows00);
+   tolua_function(tolua_S,"getWindow",tolua_CEGUI_CEGUI_WindowManager_getWindow00);
+   tolua_function(tolua_S,"isWindowPresent",tolua_CEGUI_CEGUI_WindowManager_isWindowPresent00);
+   tolua_function(tolua_S,"isDeadPoolEmpty",tolua_CEGUI_CEGUI_WindowManager_isDeadPoolEmpty00);
+   tolua_function(tolua_S,"cleanDeadPool",tolua_CEGUI_CEGUI_WindowManager_cleanDeadPool00);
+   tolua_function(tolua_S,"renameWindow",tolua_CEGUI_CEGUI_WindowManager_renameWindow00);
+   tolua_function(tolua_S,"renameWindow",tolua_CEGUI_CEGUI_WindowManager_renameWindow01);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_WindowManager_getIterator00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_WindowManager_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_WindowManager_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FalagardWindowMapping","CEGUI::FalagardWindowMapping","",tolua_collect_CEGUI__FalagardWindowMapping);
+  #else
+  tolua_cclass(tolua_S,"FalagardWindowMapping","CEGUI::FalagardWindowMapping","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FalagardWindowMapping");
+   tolua_variable(tolua_S,"windowType",tolua_get_CEGUI__FalagardWindowMapping_windowType,tolua_set_CEGUI__FalagardWindowMapping_windowType);
+   tolua_variable(tolua_S,"lookName",tolua_get_CEGUI__FalagardWindowMapping_lookName,tolua_set_CEGUI__FalagardWindowMapping_lookName);
+   tolua_variable(tolua_S,"baseType",tolua_get_CEGUI__FalagardWindowMapping_baseType,tolua_set_CEGUI__FalagardWindowMapping_baseType);
+   tolua_variable(tolua_S,"rendererType",tolua_get_CEGUI__FalagardWindowMapping_rendererType,tolua_set_CEGUI__FalagardWindowMapping_rendererType);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"WindowFactory","CEGUI::WindowFactory","",NULL);
+  tolua_beginmodule(tolua_S,"WindowFactory");
+   tolua_function(tolua_S,"getTypeName",tolua_CEGUI_CEGUI_WindowFactory_getTypeName00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"WindowFactoryManager","CEGUI::WindowFactoryManager","",NULL);
+  tolua_beginmodule(tolua_S,"WindowFactoryManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_WindowFactoryManager_getSingleton00);
+   tolua_function(tolua_S,"isFactoryPresent",tolua_CEGUI_CEGUI_WindowFactoryManager_isFactoryPresent00);
+   tolua_function(tolua_S,"addWindowTypeAlias",tolua_CEGUI_CEGUI_WindowFactoryManager_addWindowTypeAlias00);
+   tolua_function(tolua_S,"removeWindowTypeAlias",tolua_CEGUI_CEGUI_WindowFactoryManager_removeWindowTypeAlias00);
+   tolua_function(tolua_S,"addFalagardWindowMapping",tolua_CEGUI_CEGUI_WindowFactoryManager_addFalagardWindowMapping00);
+   tolua_function(tolua_S,"removeFalagardWindowMapping",tolua_CEGUI_CEGUI_WindowFactoryManager_removeFalagardWindowMapping00);
+   tolua_function(tolua_S,"isFalagardMappedType",tolua_CEGUI_CEGUI_WindowFactoryManager_isFalagardMappedType00);
+   tolua_function(tolua_S,"getMappedLookForType",tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedLookForType00);
+   tolua_function(tolua_S,"getMappedRendererForType",tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedRendererForType00);
+   tolua_function(tolua_S,"getDereferencedAliasType",tolua_CEGUI_CEGUI_WindowFactoryManager_getDereferencedAliasType00);
+   tolua_function(tolua_S,"getFalagardMappingForType",tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingForType00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_WindowFactoryManager_getIterator00);
+   tolua_function(tolua_S,"getFalagardMappingIterator",tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Scheme","CEGUI::Scheme","",NULL);
+  tolua_beginmodule(tolua_S,"Scheme");
+   tolua_function(tolua_S,"loadResources",tolua_CEGUI_CEGUI_Scheme_loadResources00);
+   tolua_function(tolua_S,"unloadResources",tolua_CEGUI_CEGUI_Scheme_unloadResources00);
+   tolua_function(tolua_S,"resourcesLoaded",tolua_CEGUI_CEGUI_Scheme_resourcesLoaded00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Scheme_getName00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_Scheme_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_Scheme_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"SchemeManager","CEGUI::SchemeManager","",NULL);
+  tolua_beginmodule(tolua_S,"SchemeManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_SchemeManager_getSingleton00);
+   tolua_function(tolua_S,"loadScheme",tolua_CEGUI_CEGUI_SchemeManager_loadScheme00);
+   tolua_function(tolua_S,"unloadScheme",tolua_CEGUI_CEGUI_SchemeManager_unloadScheme00);
+   tolua_function(tolua_S,"isSchemePresent",tolua_CEGUI_CEGUI_SchemeManager_isSchemePresent00);
+   tolua_function(tolua_S,"getScheme",tolua_CEGUI_CEGUI_SchemeManager_getScheme00);
+   tolua_function(tolua_S,"unloadAllSchemes",tolua_CEGUI_CEGUI_SchemeManager_unloadAllSchemes00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_SchemeManager_getIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PropertyHelper","CEGUI::PropertyHelper","",NULL);
+  tolua_beginmodule(tolua_S,"PropertyHelper");
+   tolua_function(tolua_S,"stringToFloat",tolua_CEGUI_CEGUI_PropertyHelper_stringToFloat00);
+   tolua_function(tolua_S,"stringToUint",tolua_CEGUI_CEGUI_PropertyHelper_stringToUint00);
+   tolua_function(tolua_S,"stringToBool",tolua_CEGUI_CEGUI_PropertyHelper_stringToBool00);
+   tolua_function(tolua_S,"stringToSize",tolua_CEGUI_CEGUI_PropertyHelper_stringToSize00);
+   tolua_function(tolua_S,"stringToPoint",tolua_CEGUI_CEGUI_PropertyHelper_stringToPoint00);
+   tolua_function(tolua_S,"stringToRect",tolua_CEGUI_CEGUI_PropertyHelper_stringToRect00);
+   tolua_function(tolua_S,"stringToImage",tolua_CEGUI_CEGUI_PropertyHelper_stringToImage00);
+   tolua_function(tolua_S,"stringToColour",tolua_CEGUI_CEGUI_PropertyHelper_stringToColour00);
+   tolua_function(tolua_S,"stringToColourRect",tolua_CEGUI_CEGUI_PropertyHelper_stringToColourRect00);
+   tolua_function(tolua_S,"stringToUDim",tolua_CEGUI_CEGUI_PropertyHelper_stringToUDim00);
+   tolua_function(tolua_S,"stringToUVector2",tolua_CEGUI_CEGUI_PropertyHelper_stringToUVector200);
+   tolua_function(tolua_S,"stringToURect",tolua_CEGUI_CEGUI_PropertyHelper_stringToURect00);
+   tolua_function(tolua_S,"floatToString",tolua_CEGUI_CEGUI_PropertyHelper_floatToString00);
+   tolua_function(tolua_S,"uintToString",tolua_CEGUI_CEGUI_PropertyHelper_uintToString00);
+   tolua_function(tolua_S,"boolToString",tolua_CEGUI_CEGUI_PropertyHelper_boolToString00);
+   tolua_function(tolua_S,"sizeToString",tolua_CEGUI_CEGUI_PropertyHelper_sizeToString00);
+   tolua_function(tolua_S,"pointToString",tolua_CEGUI_CEGUI_PropertyHelper_pointToString00);
+   tolua_function(tolua_S,"rectToString",tolua_CEGUI_CEGUI_PropertyHelper_rectToString00);
+   tolua_function(tolua_S,"imageToString",tolua_CEGUI_CEGUI_PropertyHelper_imageToString00);
+   tolua_function(tolua_S,"colourToString",tolua_CEGUI_CEGUI_PropertyHelper_colourToString00);
+   tolua_function(tolua_S,"colourRectToString",tolua_CEGUI_CEGUI_PropertyHelper_colourRectToString00);
+   tolua_function(tolua_S,"udimToString",tolua_CEGUI_CEGUI_PropertyHelper_udimToString00);
+   tolua_function(tolua_S,"uvector2ToString",tolua_CEGUI_CEGUI_PropertyHelper_uvector2ToString00);
+   tolua_function(tolua_S,"urectToString",tolua_CEGUI_CEGUI_PropertyHelper_urectToString00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"GUISheet","CEGUI::GUISheet","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"GUISheet");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ButtonBase","CEGUI::ButtonBase","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ButtonBase");
+   tolua_function(tolua_S,"isHovering",tolua_CEGUI_CEGUI_ButtonBase_isHovering00);
+   tolua_function(tolua_S,"isPushed",tolua_CEGUI_CEGUI_ButtonBase_isPushed00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Checkbox","CEGUI::Checkbox","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"Checkbox");
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_Checkbox_isSelected00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_Checkbox_setSelected00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PushButton","CEGUI::PushButton","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"PushButton");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Thumb","CEGUI::Thumb","CEGUI::PushButton",NULL);
+  tolua_beginmodule(tolua_S,"Thumb");
+   tolua_function(tolua_S,"isHotTracked",tolua_CEGUI_CEGUI_Thumb_isHotTracked00);
+   tolua_function(tolua_S,"isVertFree",tolua_CEGUI_CEGUI_Thumb_isVertFree00);
+   tolua_function(tolua_S,"isHorzFree",tolua_CEGUI_CEGUI_Thumb_isHorzFree00);
+   tolua_function(tolua_S,"setHotTracked",tolua_CEGUI_CEGUI_Thumb_setHotTracked00);
+   tolua_function(tolua_S,"setVertFree",tolua_CEGUI_CEGUI_Thumb_setVertFree00);
+   tolua_function(tolua_S,"setHorzFree",tolua_CEGUI_CEGUI_Thumb_setHorzFree00);
+   tolua_function(tolua_S,"getVertRange",tolua_CEGUI_CEGUI_Thumb_getVertRange00);
+   tolua_function(tolua_S,"getHorzRange",tolua_CEGUI_CEGUI_Thumb_getHorzRange00);
+   tolua_function(tolua_S,"setVertRange",tolua_CEGUI_CEGUI_Thumb_setVertRange00);
+   tolua_function(tolua_S,"setHorzRange",tolua_CEGUI_CEGUI_Thumb_setHorzRange00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"RadioButton","CEGUI::RadioButton","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"RadioButton");
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_RadioButton_isSelected00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_RadioButton_setSelected00);
+   tolua_function(tolua_S,"getGroupID",tolua_CEGUI_CEGUI_RadioButton_getGroupID00);
+   tolua_function(tolua_S,"setGroupID",tolua_CEGUI_CEGUI_RadioButton_setGroupID00);
+   tolua_function(tolua_S,"getSelectedButtonInGroup",tolua_CEGUI_CEGUI_RadioButton_getSelectedButtonInGroup00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"TabButton","CEGUI::TabButton","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"TabButton");
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_TabButton_isSelected00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_TabButton_setSelected00);
+   tolua_function(tolua_S,"setTargetWindow",tolua_CEGUI_CEGUI_TabButton_setTargetWindow00);
+   tolua_function(tolua_S,"getTargetWindow",tolua_CEGUI_CEGUI_TabButton_getTargetWindow00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"TabControl","CEGUI::TabControl","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"TabControl");
+   tolua_function(tolua_S,"getTabCount",tolua_CEGUI_CEGUI_TabControl_getTabCount00);
+   tolua_function(tolua_S,"setSelectedTab",tolua_CEGUI_CEGUI_TabControl_setSelectedTab00);
+   tolua_function(tolua_S,"setSelectedTab",tolua_CEGUI_CEGUI_TabControl_setSelectedTab01);
+   tolua_function(tolua_S,"setSelectedTabAtIndex",tolua_CEGUI_CEGUI_TabControl_setSelectedTabAtIndex00);
+   tolua_function(tolua_S,"getTabContentsAtIndex",tolua_CEGUI_CEGUI_TabControl_getTabContentsAtIndex00);
+   tolua_function(tolua_S,"getTabContents",tolua_CEGUI_CEGUI_TabControl_getTabContents00);
+   tolua_function(tolua_S,"getTabContents",tolua_CEGUI_CEGUI_TabControl_getTabContents01);
+   tolua_function(tolua_S,"isTabContentsSelected",tolua_CEGUI_CEGUI_TabControl_isTabContentsSelected00);
+   tolua_function(tolua_S,"getSelectedTabIndex",tolua_CEGUI_CEGUI_TabControl_getSelectedTabIndex00);
+   tolua_function(tolua_S,"getTabHeight",tolua_CEGUI_CEGUI_TabControl_getTabHeight00);
+   tolua_function(tolua_S,"getTabTextPadding",tolua_CEGUI_CEGUI_TabControl_getTabTextPadding00);
+   tolua_function(tolua_S,"setTabHeight",tolua_CEGUI_CEGUI_TabControl_setTabHeight00);
+   tolua_function(tolua_S,"setTabTextPadding",tolua_CEGUI_CEGUI_TabControl_setTabTextPadding00);
+   tolua_function(tolua_S,"addTab",tolua_CEGUI_CEGUI_TabControl_addTab00);
+   tolua_function(tolua_S,"removeTab",tolua_CEGUI_CEGUI_TabControl_removeTab00);
+   tolua_function(tolua_S,"removeTab",tolua_CEGUI_CEGUI_TabControl_removeTab01);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Titlebar","CEGUI::Titlebar","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Titlebar");
+   tolua_function(tolua_S,"isDraggingEnabled",tolua_CEGUI_CEGUI_Titlebar_isDraggingEnabled00);
+   tolua_function(tolua_S,"setDraggingEnabled",tolua_CEGUI_CEGUI_Titlebar_setDraggingEnabled00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"FrameWindow","CEGUI::FrameWindow","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"FrameWindow");
+   tolua_function(tolua_S,"isSizingEnabled",tolua_CEGUI_CEGUI_FrameWindow_isSizingEnabled00);
+   tolua_function(tolua_S,"isFrameEnabled",tolua_CEGUI_CEGUI_FrameWindow_isFrameEnabled00);
+   tolua_function(tolua_S,"isTitleBarEnabled",tolua_CEGUI_CEGUI_FrameWindow_isTitleBarEnabled00);
+   tolua_function(tolua_S,"isCloseButtonEnabled",tolua_CEGUI_CEGUI_FrameWindow_isCloseButtonEnabled00);
+   tolua_function(tolua_S,"isRollupEnabled",tolua_CEGUI_CEGUI_FrameWindow_isRollupEnabled00);
+   tolua_function(tolua_S,"isRolledup",tolua_CEGUI_CEGUI_FrameWindow_isRolledup00);
+   tolua_function(tolua_S,"isDragMovingEnabled",tolua_CEGUI_CEGUI_FrameWindow_isDragMovingEnabled00);
+   tolua_function(tolua_S,"setSizingEnabled",tolua_CEGUI_CEGUI_FrameWindow_setSizingEnabled00);
+   tolua_function(tolua_S,"setFrameEnabled",tolua_CEGUI_CEGUI_FrameWindow_setFrameEnabled00);
+   tolua_function(tolua_S,"setTitleBarEnabled",tolua_CEGUI_CEGUI_FrameWindow_setTitleBarEnabled00);
+   tolua_function(tolua_S,"setCloseButtonEnabled",tolua_CEGUI_CEGUI_FrameWindow_setCloseButtonEnabled00);
+   tolua_function(tolua_S,"setRollupEnabled",tolua_CEGUI_CEGUI_FrameWindow_setRollupEnabled00);
+   tolua_function(tolua_S,"setDragMovingEnabled",tolua_CEGUI_CEGUI_FrameWindow_setDragMovingEnabled00);
+   tolua_function(tolua_S,"getSizingBorderThickness",tolua_CEGUI_CEGUI_FrameWindow_getSizingBorderThickness00);
+   tolua_function(tolua_S,"setSizingBorderThickness",tolua_CEGUI_CEGUI_FrameWindow_setSizingBorderThickness00);
+   tolua_function(tolua_S,"toggleRollup",tolua_CEGUI_CEGUI_FrameWindow_toggleRollup00);
+   tolua_function(tolua_S,"offsetPixelPosition",tolua_CEGUI_CEGUI_FrameWindow_offsetPixelPosition00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Tooltip","CEGUI::Tooltip","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Tooltip");
+   tolua_function(tolua_S,"setTargetWindow",tolua_CEGUI_CEGUI_Tooltip_setTargetWindow00);
+   tolua_function(tolua_S,"resetTimer",tolua_CEGUI_CEGUI_Tooltip_resetTimer00);
+   tolua_function(tolua_S,"getHoverTime",tolua_CEGUI_CEGUI_Tooltip_getHoverTime00);
+   tolua_function(tolua_S,"setDisplayTime",tolua_CEGUI_CEGUI_Tooltip_setDisplayTime00);
+   tolua_function(tolua_S,"getFadeTime",tolua_CEGUI_CEGUI_Tooltip_getFadeTime00);
+   tolua_function(tolua_S,"setHoverTime",tolua_CEGUI_CEGUI_Tooltip_setHoverTime00);
+   tolua_function(tolua_S,"getDisplayTime",tolua_CEGUI_CEGUI_Tooltip_getDisplayTime00);
+   tolua_function(tolua_S,"setFadeTime",tolua_CEGUI_CEGUI_Tooltip_setFadeTime00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"DragContainer","CEGUI::DragContainer","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"DragContainer");
+   tolua_function(tolua_S,"isDraggingEnabled",tolua_CEGUI_CEGUI_DragContainer_isDraggingEnabled00);
+   tolua_function(tolua_S,"setDraggingEnabled",tolua_CEGUI_CEGUI_DragContainer_setDraggingEnabled00);
+   tolua_function(tolua_S,"isBeingDragged",tolua_CEGUI_CEGUI_DragContainer_isBeingDragged00);
+   tolua_function(tolua_S,"getPixelDragThreshold",tolua_CEGUI_CEGUI_DragContainer_getPixelDragThreshold00);
+   tolua_function(tolua_S,"setPixelDragThreshold",tolua_CEGUI_CEGUI_DragContainer_setPixelDragThreshold00);
+   tolua_function(tolua_S,"getDragAlpha",tolua_CEGUI_CEGUI_DragContainer_getDragAlpha00);
+   tolua_function(tolua_S,"setDragAlpha",tolua_CEGUI_CEGUI_DragContainer_setDragAlpha00);
+   tolua_function(tolua_S,"getDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_getDragCursorImage00);
+   tolua_function(tolua_S,"setDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00);
+   tolua_function(tolua_S,"setDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01);
+   tolua_function(tolua_S,"setDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage02);
+   tolua_function(tolua_S,"getCurrentDropTarget",tolua_CEGUI_CEGUI_DragContainer_getCurrentDropTarget00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Scrollbar","CEGUI::Scrollbar","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Scrollbar");
+   tolua_function(tolua_S,"getDocumentSize",tolua_CEGUI_CEGUI_Scrollbar_getDocumentSize00);
+   tolua_function(tolua_S,"getPageSize",tolua_CEGUI_CEGUI_Scrollbar_getPageSize00);
+   tolua_function(tolua_S,"getStepSize",tolua_CEGUI_CEGUI_Scrollbar_getStepSize00);
+   tolua_function(tolua_S,"getOverlapSize",tolua_CEGUI_CEGUI_Scrollbar_getOverlapSize00);
+   tolua_function(tolua_S,"getScrollPosition",tolua_CEGUI_CEGUI_Scrollbar_getScrollPosition00);
+   tolua_function(tolua_S,"setDocumentSize",tolua_CEGUI_CEGUI_Scrollbar_setDocumentSize00);
+   tolua_function(tolua_S,"setPageSize",tolua_CEGUI_CEGUI_Scrollbar_setPageSize00);
+   tolua_function(tolua_S,"setStepSize",tolua_CEGUI_CEGUI_Scrollbar_setStepSize00);
+   tolua_function(tolua_S,"setOverlapSize",tolua_CEGUI_CEGUI_Scrollbar_setOverlapSize00);
+   tolua_function(tolua_S,"setScrollPosition",tolua_CEGUI_CEGUI_Scrollbar_setScrollPosition00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ScrolledContainer","CEGUI::ScrolledContainer","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ScrolledContainer");
+   tolua_function(tolua_S,"isContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrolledContainer_isContentPaneAutoSized00);
+   tolua_function(tolua_S,"setContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrolledContainer_setContentPaneAutoSized00);
+   tolua_function(tolua_S,"getContentArea",tolua_CEGUI_CEGUI_ScrolledContainer_getContentArea00);
+   tolua_function(tolua_S,"setContentArea",tolua_CEGUI_CEGUI_ScrolledContainer_setContentArea00);
+   tolua_function(tolua_S,"getChildExtentsArea",tolua_CEGUI_CEGUI_ScrolledContainer_getChildExtentsArea00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ScrollablePane","CEGUI::ScrollablePane","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ScrollablePane");
+   tolua_function(tolua_S,"getContentPane",tolua_CEGUI_CEGUI_ScrollablePane_getContentPane00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrollablePane_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_setShowVertScrollbar00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrollablePane_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"isContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrollablePane_isContentPaneAutoSized00);
+   tolua_function(tolua_S,"setContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneAutoSized00);
+   tolua_function(tolua_S,"getContentPaneArea",tolua_CEGUI_CEGUI_ScrollablePane_getContentPaneArea00);
+   tolua_function(tolua_S,"setContentPaneArea",tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneArea00);
+   tolua_function(tolua_S,"getHorizontalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalStepSize00);
+   tolua_function(tolua_S,"setHorizontalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalStepSize00);
+   tolua_function(tolua_S,"getHorizontalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalOverlapSize00);
+   tolua_function(tolua_S,"setHorizontalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalOverlapSize00);
+   tolua_function(tolua_S,"getHorizontalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalScrollPosition00);
+   tolua_function(tolua_S,"setHorizontalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalScrollPosition00);
+   tolua_function(tolua_S,"getVerticalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_getVerticalStepSize00);
+   tolua_function(tolua_S,"setVerticalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_setVerticalStepSize00);
+   tolua_function(tolua_S,"getVerticalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_getVerticalOverlapSize00);
+   tolua_function(tolua_S,"setVerticalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_setVerticalOverlapSize00);
+   tolua_function(tolua_S,"getVerticalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_getVerticalScrollPosition00);
+   tolua_function(tolua_S,"setVerticalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_setVerticalScrollPosition00);
+   tolua_function(tolua_S,"getViewableArea",tolua_CEGUI_CEGUI_ScrollablePane_getViewableArea00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_getHorzScrollbar00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Slider","CEGUI::Slider","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Slider");
+   tolua_function(tolua_S,"getCurrentValue",tolua_CEGUI_CEGUI_Slider_getCurrentValue00);
+   tolua_function(tolua_S,"getMaxValue",tolua_CEGUI_CEGUI_Slider_getMaxValue00);
+   tolua_function(tolua_S,"getClickStep",tolua_CEGUI_CEGUI_Slider_getClickStep00);
+   tolua_function(tolua_S,"setMaxValue",tolua_CEGUI_CEGUI_Slider_setMaxValue00);
+   tolua_function(tolua_S,"setCurrentValue",tolua_CEGUI_CEGUI_Slider_setCurrentValue00);
+   tolua_function(tolua_S,"setClickStep",tolua_CEGUI_CEGUI_Slider_setClickStep00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Spinner","CEGUI::Spinner","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Spinner");
+   tolua_constant(tolua_S,"FloatingPoint",CEGUI::Spinner::FloatingPoint);
+   tolua_constant(tolua_S,"Integer",CEGUI::Spinner::Integer);
+   tolua_constant(tolua_S,"Hexadecimal",CEGUI::Spinner::Hexadecimal);
+   tolua_constant(tolua_S,"Octal",CEGUI::Spinner::Octal);
+   tolua_function(tolua_S,"getCurrentValue",tolua_CEGUI_CEGUI_Spinner_getCurrentValue00);
+   tolua_function(tolua_S,"getStepSize",tolua_CEGUI_CEGUI_Spinner_getStepSize00);
+   tolua_function(tolua_S,"getMaximumValue",tolua_CEGUI_CEGUI_Spinner_getMaximumValue00);
+   tolua_function(tolua_S,"getMinimumValue",tolua_CEGUI_CEGUI_Spinner_getMinimumValue00);
+   tolua_function(tolua_S,"getTextInputMode",tolua_CEGUI_CEGUI_Spinner_getTextInputMode00);
+   tolua_function(tolua_S,"setCurrentValue",tolua_CEGUI_CEGUI_Spinner_setCurrentValue00);
+   tolua_function(tolua_S,"setStepSize",tolua_CEGUI_CEGUI_Spinner_setStepSize00);
+   tolua_function(tolua_S,"setMaximumValue",tolua_CEGUI_CEGUI_Spinner_setMaximumValue00);
+   tolua_function(tolua_S,"setMinimumValue",tolua_CEGUI_CEGUI_Spinner_setMinimumValue00);
+   tolua_function(tolua_S,"setTextInputMode",tolua_CEGUI_CEGUI_Spinner_setTextInputMode00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ProgressBar","CEGUI::ProgressBar","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ProgressBar");
+   tolua_function(tolua_S,"getProgress",tolua_CEGUI_CEGUI_ProgressBar_getProgress00);
+   tolua_function(tolua_S,"getStep",tolua_CEGUI_CEGUI_ProgressBar_getStep00);
+   tolua_function(tolua_S,"setProgress",tolua_CEGUI_CEGUI_ProgressBar_setProgress00);
+   tolua_function(tolua_S,"setStepSize",tolua_CEGUI_CEGUI_ProgressBar_setStepSize00);
+   tolua_function(tolua_S,"step",tolua_CEGUI_CEGUI_ProgressBar_step00);
+   tolua_function(tolua_S,"adjustProgress",tolua_CEGUI_CEGUI_ProgressBar_adjustProgress00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Editbox","CEGUI::Editbox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Editbox");
+   tolua_function(tolua_S,"hasInputFocus",tolua_CEGUI_CEGUI_Editbox_hasInputFocus00);
+   tolua_function(tolua_S,"isReadOnly",tolua_CEGUI_CEGUI_Editbox_isReadOnly00);
+   tolua_function(tolua_S,"isTextMasked",tolua_CEGUI_CEGUI_Editbox_isTextMasked00);
+   tolua_function(tolua_S,"isTextValid",tolua_CEGUI_CEGUI_Editbox_isTextValid00);
+   tolua_function(tolua_S,"getValidationString",tolua_CEGUI_CEGUI_Editbox_getValidationString00);
+   tolua_function(tolua_S,"getCaratIndex",tolua_CEGUI_CEGUI_Editbox_getCaratIndex00);
+   tolua_function(tolua_S,"getSelectionStartIndex",tolua_CEGUI_CEGUI_Editbox_getSelectionStartIndex00);
+   tolua_function(tolua_S,"getSelectionEndIndex",tolua_CEGUI_CEGUI_Editbox_getSelectionEndIndex00);
+   tolua_function(tolua_S,"getSelectionLength",tolua_CEGUI_CEGUI_Editbox_getSelectionLength00);
+   tolua_function(tolua_S,"getMaskCodePoint",tolua_CEGUI_CEGUI_Editbox_getMaskCodePoint00);
+   tolua_function(tolua_S,"getMaxTextLength",tolua_CEGUI_CEGUI_Editbox_getMaxTextLength00);
+   tolua_function(tolua_S,"setReadOnly",tolua_CEGUI_CEGUI_Editbox_setReadOnly00);
+   tolua_function(tolua_S,"setTextMasked",tolua_CEGUI_CEGUI_Editbox_setTextMasked00);
+   tolua_function(tolua_S,"setValidationString",tolua_CEGUI_CEGUI_Editbox_setValidationString00);
+   tolua_function(tolua_S,"setCaratIndex",tolua_CEGUI_CEGUI_Editbox_setCaratIndex00);
+   tolua_function(tolua_S,"setSelection",tolua_CEGUI_CEGUI_Editbox_setSelection00);
+   tolua_function(tolua_S,"setMaskCodePoint",tolua_CEGUI_CEGUI_Editbox_setMaskCodePoint00);
+   tolua_function(tolua_S,"setMaxTextLength",tolua_CEGUI_CEGUI_Editbox_setMaxTextLength00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MultiLineEditbox","CEGUI::MultiLineEditbox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"MultiLineEditbox");
+   tolua_function(tolua_S,"hasInputFocus",tolua_CEGUI_CEGUI_MultiLineEditbox_hasInputFocus00);
+   tolua_function(tolua_S,"isReadOnly",tolua_CEGUI_CEGUI_MultiLineEditbox_isReadOnly00);
+   tolua_function(tolua_S,"getCaratIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getCaratIndex00);
+   tolua_function(tolua_S,"getSelectionStartIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionStartIndex00);
+   tolua_function(tolua_S,"getSelectionEndIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionEndIndex00);
+   tolua_function(tolua_S,"getSelectionLength",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionLength00);
+   tolua_function(tolua_S,"getMaxTextLength",tolua_CEGUI_CEGUI_MultiLineEditbox_getMaxTextLength00);
+   tolua_function(tolua_S,"isWordWrapped",tolua_CEGUI_CEGUI_MultiLineEditbox_isWordWrapped00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_MultiLineEditbox_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_MultiLineEditbox_getHorzScrollbar00);
+   tolua_function(tolua_S,"getTextRenderArea",tolua_CEGUI_CEGUI_MultiLineEditbox_getTextRenderArea00);
+   tolua_function(tolua_S,"getLineNumberFromIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getLineNumberFromIndex00);
+   tolua_function(tolua_S,"setReadOnly",tolua_CEGUI_CEGUI_MultiLineEditbox_setReadOnly00);
+   tolua_function(tolua_S,"setCaratIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_setCaratIndex00);
+   tolua_function(tolua_S,"setSelection",tolua_CEGUI_CEGUI_MultiLineEditbox_setSelection00);
+   tolua_function(tolua_S,"setMaxTextLength",tolua_CEGUI_CEGUI_MultiLineEditbox_setMaxTextLength00);
+   tolua_function(tolua_S,"ensureCaratIsVisible",tolua_CEGUI_CEGUI_MultiLineEditbox_ensureCaratIsVisible00);
+   tolua_function(tolua_S,"setWordWrapping",tolua_CEGUI_CEGUI_MultiLineEditbox_setWordWrapping00);
+   tolua_function(tolua_S,"setSelectionBrushImage",tolua_CEGUI_CEGUI_MultiLineEditbox_setSelectionBrushImage00);
+   tolua_function(tolua_S,"getSelectionBrushImage",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionBrushImage00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListboxItem","CEGUI::ListboxItem","",NULL);
+  tolua_beginmodule(tolua_S,"ListboxItem");
+   tolua_function(tolua_S,"getText",tolua_CEGUI_CEGUI_ListboxItem_getText00);
+   tolua_function(tolua_S,"getID",tolua_CEGUI_CEGUI_ListboxItem_getID00);
+   tolua_function(tolua_S,"getUserData",tolua_CEGUI_CEGUI_ListboxItem_getUserData00);
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_ListboxItem_isSelected00);
+   tolua_function(tolua_S,"isDisabled",tolua_CEGUI_CEGUI_ListboxItem_isDisabled00);
+   tolua_function(tolua_S,"isAutoDeleted",tolua_CEGUI_CEGUI_ListboxItem_isAutoDeleted00);
+   tolua_function(tolua_S,"getOwnerWindow",tolua_CEGUI_CEGUI_ListboxItem_getOwnerWindow00);
+   tolua_function(tolua_S,"getSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_getSelectionColours00);
+   tolua_function(tolua_S,"getSelectionBrushImage",tolua_CEGUI_CEGUI_ListboxItem_getSelectionBrushImage00);
+   tolua_function(tolua_S,"setText",tolua_CEGUI_CEGUI_ListboxItem_setText00);
+   tolua_function(tolua_S,"setID",tolua_CEGUI_CEGUI_ListboxItem_setID00);
+   tolua_function(tolua_S,"setUserData",tolua_CEGUI_CEGUI_ListboxItem_setUserData00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_ListboxItem_setSelected00);
+   tolua_function(tolua_S,"setDisabled",tolua_CEGUI_CEGUI_ListboxItem_setDisabled00);
+   tolua_function(tolua_S,"setAutoDeleted",tolua_CEGUI_CEGUI_ListboxItem_setAutoDeleted00);
+   tolua_function(tolua_S,"setOwnerWindow",tolua_CEGUI_CEGUI_ListboxItem_setOwnerWindow00);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours02);
+   tolua_function(tolua_S,"setSelectionBrushImage",tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00);
+   tolua_function(tolua_S,"setSelectionBrushImage",tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage01);
+   tolua_function(tolua_S,"getPixelSize",tolua_CEGUI_CEGUI_ListboxItem_getPixelSize00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListboxTextItem","CEGUI::ListboxTextItem","CEGUI::ListboxItem",NULL);
+  tolua_beginmodule(tolua_S,"ListboxTextItem");
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_ListboxTextItem_getFont00);
+   tolua_function(tolua_S,"getTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_getTextColours00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_ListboxTextItem_setFont00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_ListboxTextItem_setFont01);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours02);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Combobox","CEGUI::Combobox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Combobox");
+   tolua_function(tolua_S,"getSingleClickEnabled",tolua_CEGUI_CEGUI_Combobox_getSingleClickEnabled00);
+   tolua_function(tolua_S,"isDropDownListVisible",tolua_CEGUI_CEGUI_Combobox_isDropDownListVisible00);
+   tolua_function(tolua_S,"getEditbox",tolua_CEGUI_CEGUI_Combobox_getEditbox00);
+   tolua_function(tolua_S,"getPushButton",tolua_CEGUI_CEGUI_Combobox_getPushButton00);
+   tolua_function(tolua_S,"getDropList",tolua_CEGUI_CEGUI_Combobox_getDropList00);
+   tolua_function(tolua_S,"hasInputFocus",tolua_CEGUI_CEGUI_Combobox_hasInputFocus00);
+   tolua_function(tolua_S,"isReadOnly",tolua_CEGUI_CEGUI_Combobox_isReadOnly00);
+   tolua_function(tolua_S,"isTextValid",tolua_CEGUI_CEGUI_Combobox_isTextValid00);
+   tolua_function(tolua_S,"getValidationString",tolua_CEGUI_CEGUI_Combobox_getValidationString00);
+   tolua_function(tolua_S,"getCaratIndex",tolua_CEGUI_CEGUI_Combobox_getCaratIndex00);
+   tolua_function(tolua_S,"getSelectionStartIndex",tolua_CEGUI_CEGUI_Combobox_getSelectionStartIndex00);
+   tolua_function(tolua_S,"getSelectionEndIndex",tolua_CEGUI_CEGUI_Combobox_getSelectionEndIndex00);
+   tolua_function(tolua_S,"getSelectionLength",tolua_CEGUI_CEGUI_Combobox_getSelectionLength00);
+   tolua_function(tolua_S,"getMaxTextLength",tolua_CEGUI_CEGUI_Combobox_getMaxTextLength00);
+   tolua_function(tolua_S,"activateEditbox",tolua_CEGUI_CEGUI_Combobox_activateEditbox00);
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_Combobox_getItemCount00);
+   tolua_function(tolua_S,"getSelectedItem",tolua_CEGUI_CEGUI_Combobox_getSelectedItem00);
+   tolua_function(tolua_S,"getListboxItemFromIndex",tolua_CEGUI_CEGUI_Combobox_getListboxItemFromIndex00);
+   tolua_function(tolua_S,"getItemIndex",tolua_CEGUI_CEGUI_Combobox_getItemIndex00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_Combobox_isItemSelected00);
+   tolua_function(tolua_S,"findItemWithText",tolua_CEGUI_CEGUI_Combobox_findItemWithText00);
+   tolua_function(tolua_S,"isListboxItemInList",tolua_CEGUI_CEGUI_Combobox_isListboxItemInList00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_Combobox_resetList00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_Combobox_addItem00);
+   tolua_function(tolua_S,"insertItem",tolua_CEGUI_CEGUI_Combobox_insertItem00);
+   tolua_function(tolua_S,"removeItem",tolua_CEGUI_CEGUI_Combobox_removeItem00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_Combobox_clearAllSelections00);
+   tolua_function(tolua_S,"setSortingEnabled",tolua_CEGUI_CEGUI_Combobox_setSortingEnabled00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_Combobox_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_Combobox_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Combobox_setItemSelectState00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Combobox_setItemSelectState01);
+   tolua_function(tolua_S,"handleUpdatedListItemData",tolua_CEGUI_CEGUI_Combobox_handleUpdatedListItemData00);
+   tolua_function(tolua_S,"isSortEnabled",tolua_CEGUI_CEGUI_Combobox_isSortEnabled00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Combobox_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Combobox_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"showDropList",tolua_CEGUI_CEGUI_Combobox_showDropList00);
+   tolua_function(tolua_S,"hideDropList",tolua_CEGUI_CEGUI_Combobox_hideDropList00);
+   tolua_function(tolua_S,"setSingleClickEnabled",tolua_CEGUI_CEGUI_Combobox_setSingleClickEnabled00);
+   tolua_function(tolua_S,"setReadOnly",tolua_CEGUI_CEGUI_Combobox_setReadOnly00);
+   tolua_function(tolua_S,"setValidationString",tolua_CEGUI_CEGUI_Combobox_setValidationString00);
+   tolua_function(tolua_S,"setCaratIndex",tolua_CEGUI_CEGUI_Combobox_setCaratIndex00);
+   tolua_function(tolua_S,"setSelection",tolua_CEGUI_CEGUI_Combobox_setSelection00);
+   tolua_function(tolua_S,"setMaxTextLength",tolua_CEGUI_CEGUI_Combobox_setMaxTextLength00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Listbox","CEGUI::Listbox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Listbox");
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_Listbox_getItemCount00);
+   tolua_function(tolua_S,"getSelectedCount",tolua_CEGUI_CEGUI_Listbox_getSelectedCount00);
+   tolua_function(tolua_S,"getFirstSelectedItem",tolua_CEGUI_CEGUI_Listbox_getFirstSelectedItem00);
+   tolua_function(tolua_S,"getNextSelected",tolua_CEGUI_CEGUI_Listbox_getNextSelected00);
+   tolua_function(tolua_S,"getListboxItemFromIndex",tolua_CEGUI_CEGUI_Listbox_getListboxItemFromIndex00);
+   tolua_function(tolua_S,"getItemIndex",tolua_CEGUI_CEGUI_Listbox_getItemIndex00);
+   tolua_function(tolua_S,"findItemWithText",tolua_CEGUI_CEGUI_Listbox_findItemWithText00);
+   tolua_function(tolua_S,"isSortEnabled",tolua_CEGUI_CEGUI_Listbox_isSortEnabled00);
+   tolua_function(tolua_S,"isMultiselectEnabled",tolua_CEGUI_CEGUI_Listbox_isMultiselectEnabled00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_Listbox_isItemSelected00);
+   tolua_function(tolua_S,"isListboxItemInList",tolua_CEGUI_CEGUI_Listbox_isListboxItemInList00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Listbox_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Listbox_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_Listbox_resetList00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_Listbox_addItem00);
+   tolua_function(tolua_S,"insertItem",tolua_CEGUI_CEGUI_Listbox_insertItem00);
+   tolua_function(tolua_S,"removeItem",tolua_CEGUI_CEGUI_Listbox_removeItem00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_Listbox_clearAllSelections00);
+   tolua_function(tolua_S,"setSortingEnabled",tolua_CEGUI_CEGUI_Listbox_setSortingEnabled00);
+   tolua_function(tolua_S,"setMultiselectEnabled",tolua_CEGUI_CEGUI_Listbox_setMultiselectEnabled00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_Listbox_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_Listbox_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Listbox_setItemSelectState00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Listbox_setItemSelectState01);
+   tolua_function(tolua_S,"handleUpdatedItemData",tolua_CEGUI_CEGUI_Listbox_handleUpdatedItemData00);
+   tolua_function(tolua_S,"ensureItemIsVisible",tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00);
+   tolua_function(tolua_S,"ensureItemIsVisible",tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible01);
+   tolua_function(tolua_S,"getListRenderArea",tolua_CEGUI_CEGUI_Listbox_getListRenderArea00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_Listbox_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_Listbox_getHorzScrollbar00);
+   tolua_function(tolua_S,"getWidestItemWidth",tolua_CEGUI_CEGUI_Listbox_getWidestItemWidth00);
+   tolua_function(tolua_S,"getTotalItemsHeight",tolua_CEGUI_CEGUI_Listbox_getTotalItemsHeight00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ComboDropList","CEGUI::ComboDropList","CEGUI::Listbox",NULL);
+  tolua_beginmodule(tolua_S,"ComboDropList");
+   tolua_function(tolua_S,"setArmed",tolua_CEGUI_CEGUI_ComboDropList_setArmed00);
+   tolua_function(tolua_S,"isArmed",tolua_CEGUI_CEGUI_ComboDropList_isArmed00);
+   tolua_function(tolua_S,"setAutoArmEnabled",tolua_CEGUI_CEGUI_ComboDropList_setAutoArmEnabled00);
+   tolua_function(tolua_S,"isAutoArmEnabled",tolua_CEGUI_CEGUI_ComboDropList_isAutoArmEnabled00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListHeaderSegment","CEGUI::ListHeaderSegment","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ListHeaderSegment");
+   tolua_constant(tolua_S,"None",CEGUI::ListHeaderSegment::None);
+   tolua_constant(tolua_S,"Ascending",CEGUI::ListHeaderSegment::Ascending);
+   tolua_constant(tolua_S,"Descending",CEGUI::ListHeaderSegment::Descending);
+   tolua_function(tolua_S,"isSizingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_isSizingEnabled00);
+   tolua_function(tolua_S,"getSortDirection",tolua_CEGUI_CEGUI_ListHeaderSegment_getSortDirection00);
+   tolua_function(tolua_S,"isDragMovingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_isDragMovingEnabled00);
+   tolua_function(tolua_S,"getDragMoveOffset",tolua_CEGUI_CEGUI_ListHeaderSegment_getDragMoveOffset00);
+   tolua_function(tolua_S,"isClickable",tolua_CEGUI_CEGUI_ListHeaderSegment_isClickable00);
+   tolua_function(tolua_S,"setSizingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_setSizingEnabled00);
+   tolua_function(tolua_S,"setSortDirection",tolua_CEGUI_CEGUI_ListHeaderSegment_setSortDirection00);
+   tolua_function(tolua_S,"setDragMovingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_setDragMovingEnabled00);
+   tolua_function(tolua_S,"setClickable",tolua_CEGUI_CEGUI_ListHeaderSegment_setClickable00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListHeader","CEGUI::ListHeader","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ListHeader");
+   tolua_function(tolua_S,"getColumnCount",tolua_CEGUI_CEGUI_ListHeader_getColumnCount00);
+   tolua_function(tolua_S,"getSegmentFromColumn",tolua_CEGUI_CEGUI_ListHeader_getSegmentFromColumn00);
+   tolua_function(tolua_S,"getSegmentFromID",tolua_CEGUI_CEGUI_ListHeader_getSegmentFromID00);
+   tolua_function(tolua_S,"getSortSegment",tolua_CEGUI_CEGUI_ListHeader_getSortSegment00);
+   tolua_function(tolua_S,"getColumnFromSegment",tolua_CEGUI_CEGUI_ListHeader_getColumnFromSegment00);
+   tolua_function(tolua_S,"getColumnFromID",tolua_CEGUI_CEGUI_ListHeader_getColumnFromID00);
+   tolua_function(tolua_S,"getSortColumn",tolua_CEGUI_CEGUI_ListHeader_getSortColumn00);
+   tolua_function(tolua_S,"getColumnWithText",tolua_CEGUI_CEGUI_ListHeader_getColumnWithText00);
+   tolua_function(tolua_S,"getPixelOffsetToSegment",tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToSegment00);
+   tolua_function(tolua_S,"getPixelOffsetToColumn",tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToColumn00);
+   tolua_function(tolua_S,"getTotalSegmentsPixelExtent",tolua_CEGUI_CEGUI_ListHeader_getTotalSegmentsPixelExtent00);
+   tolua_function(tolua_S,"getColumnWidth",tolua_CEGUI_CEGUI_ListHeader_getColumnWidth00);
+   tolua_function(tolua_S,"getSortDirection",tolua_CEGUI_CEGUI_ListHeader_getSortDirection00);
+   tolua_function(tolua_S,"isSortingEnabled",tolua_CEGUI_CEGUI_ListHeader_isSortingEnabled00);
+   tolua_function(tolua_S,"isColumnSizingEnabled",tolua_CEGUI_CEGUI_ListHeader_isColumnSizingEnabled00);
+   tolua_function(tolua_S,"isColumnDraggingEnabled",tolua_CEGUI_CEGUI_ListHeader_isColumnDraggingEnabled00);
+   tolua_function(tolua_S,"getSegmentOffset",tolua_CEGUI_CEGUI_ListHeader_getSegmentOffset00);
+   tolua_function(tolua_S,"setSortingEnabled",tolua_CEGUI_CEGUI_ListHeader_setSortingEnabled00);
+   tolua_function(tolua_S,"setSortDirection",tolua_CEGUI_CEGUI_ListHeader_setSortDirection00);
+   tolua_function(tolua_S,"setSortSegment",tolua_CEGUI_CEGUI_ListHeader_setSortSegment00);
+   tolua_function(tolua_S,"setSortColumn",tolua_CEGUI_CEGUI_ListHeader_setSortColumn00);
+   tolua_function(tolua_S,"setSortColumnFromID",tolua_CEGUI_CEGUI_ListHeader_setSortColumnFromID00);
+   tolua_function(tolua_S,"setColumnSizingEnabled",tolua_CEGUI_CEGUI_ListHeader_setColumnSizingEnabled00);
+   tolua_function(tolua_S,"setColumnDraggingEnabled",tolua_CEGUI_CEGUI_ListHeader_setColumnDraggingEnabled00);
+   tolua_function(tolua_S,"addColumn",tolua_CEGUI_CEGUI_ListHeader_addColumn00);
+   tolua_function(tolua_S,"insertColumn",tolua_CEGUI_CEGUI_ListHeader_insertColumn00);
+   tolua_function(tolua_S,"insertColumn",tolua_CEGUI_CEGUI_ListHeader_insertColumn01);
+   tolua_function(tolua_S,"removeColumn",tolua_CEGUI_CEGUI_ListHeader_removeColumn00);
+   tolua_function(tolua_S,"removeSegment",tolua_CEGUI_CEGUI_ListHeader_removeSegment00);
+   tolua_function(tolua_S,"moveColumn",tolua_CEGUI_CEGUI_ListHeader_moveColumn00);
+   tolua_function(tolua_S,"moveColumn",tolua_CEGUI_CEGUI_ListHeader_moveColumn01);
+   tolua_function(tolua_S,"moveSegment",tolua_CEGUI_CEGUI_ListHeader_moveSegment00);
+   tolua_function(tolua_S,"moveSegment",tolua_CEGUI_CEGUI_ListHeader_moveSegment01);
+   tolua_function(tolua_S,"setSegmentOffset",tolua_CEGUI_CEGUI_ListHeader_setSegmentOffset00);
+   tolua_function(tolua_S,"setColumnWidth",tolua_CEGUI_CEGUI_ListHeader_setColumnWidth00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"MCLGridRef","CEGUI::MCLGridRef","",tolua_collect_CEGUI__MCLGridRef);
+  #else
+  tolua_cclass(tolua_S,"MCLGridRef","CEGUI::MCLGridRef","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"MCLGridRef");
+   tolua_variable(tolua_S,"row",tolua_get_CEGUI__MCLGridRef_unsigned_row,tolua_set_CEGUI__MCLGridRef_unsigned_row);
+   tolua_variable(tolua_S,"column",tolua_get_CEGUI__MCLGridRef_unsigned_column,tolua_set_CEGUI__MCLGridRef_unsigned_column);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_MCLGridRef__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_MCLGridRef_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_MCLGridRef_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_MCLGridRef_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MultiColumnList","CEGUI::MultiColumnList","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"MultiColumnList");
+   tolua_constant(tolua_S,"RowSingle",CEGUI::MultiColumnList::RowSingle);
+   tolua_constant(tolua_S,"RowMultiple",CEGUI::MultiColumnList::RowMultiple);
+   tolua_constant(tolua_S,"CellSingle",CEGUI::MultiColumnList::CellSingle);
+   tolua_constant(tolua_S,"CellMultiple",CEGUI::MultiColumnList::CellMultiple);
+   tolua_constant(tolua_S,"NominatedColumnSingle",CEGUI::MultiColumnList::NominatedColumnSingle);
+   tolua_constant(tolua_S,"NominatedColumnMultiple",CEGUI::MultiColumnList::NominatedColumnMultiple);
+   tolua_constant(tolua_S,"ColumnSingle",CEGUI::MultiColumnList::ColumnSingle);
+   tolua_constant(tolua_S,"ColumnMultiple",CEGUI::MultiColumnList::ColumnMultiple);
+   tolua_constant(tolua_S,"NominatedRowSingle",CEGUI::MultiColumnList::NominatedRowSingle);
+   tolua_constant(tolua_S,"NominatedRowMultiple",CEGUI::MultiColumnList::NominatedRowMultiple);
+   tolua_function(tolua_S,"isUserSortControlEnabled",tolua_CEGUI_CEGUI_MultiColumnList_isUserSortControlEnabled00);
+   tolua_function(tolua_S,"isUserColumnSizingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnSizingEnabled00);
+   tolua_function(tolua_S,"isUserColumnDraggingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnDraggingEnabled00);
+   tolua_function(tolua_S,"getColumnCount",tolua_CEGUI_CEGUI_MultiColumnList_getColumnCount00);
+   tolua_function(tolua_S,"getRowCount",tolua_CEGUI_CEGUI_MultiColumnList_getRowCount00);
+   tolua_function(tolua_S,"getSortColumn",tolua_CEGUI_CEGUI_MultiColumnList_getSortColumn00);
+   tolua_function(tolua_S,"getColumnWithID",tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithID00);
+   tolua_function(tolua_S,"getColumnWithHeaderText",tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithHeaderText00);
+   tolua_function(tolua_S,"getTotalColumnHeadersWidth",tolua_CEGUI_CEGUI_MultiColumnList_getTotalColumnHeadersWidth00);
+   tolua_function(tolua_S,"getColumnHeaderWidth",tolua_CEGUI_CEGUI_MultiColumnList_getColumnHeaderWidth00);
+   tolua_function(tolua_S,"getSortDirection",tolua_CEGUI_CEGUI_MultiColumnList_getSortDirection00);
+   tolua_function(tolua_S,"getHeaderSegmentForColumn",tolua_CEGUI_CEGUI_MultiColumnList_getHeaderSegmentForColumn00);
+   tolua_function(tolua_S,"getItemRowIndex",tolua_CEGUI_CEGUI_MultiColumnList_getItemRowIndex00);
+   tolua_function(tolua_S,"getItemColumnIndex",tolua_CEGUI_CEGUI_MultiColumnList_getItemColumnIndex00);
+   tolua_function(tolua_S,"getItemGridReference",tolua_CEGUI_CEGUI_MultiColumnList_getItemGridReference00);
+   tolua_function(tolua_S,"getItemAtGridReference",tolua_CEGUI_CEGUI_MultiColumnList_getItemAtGridReference00);
+   tolua_function(tolua_S,"isListboxItemInColumn",tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInColumn00);
+   tolua_function(tolua_S,"isListboxItemInRow",tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInRow00);
+   tolua_function(tolua_S,"isListboxItemInList",tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInList00);
+   tolua_function(tolua_S,"findColumnItemWithText",tolua_CEGUI_CEGUI_MultiColumnList_findColumnItemWithText00);
+   tolua_function(tolua_S,"findRowItemWithText",tolua_CEGUI_CEGUI_MultiColumnList_findRowItemWithText00);
+   tolua_function(tolua_S,"findListItemWithText",tolua_CEGUI_CEGUI_MultiColumnList_findListItemWithText00);
+   tolua_function(tolua_S,"getFirstSelectedItem",tolua_CEGUI_CEGUI_MultiColumnList_getFirstSelectedItem00);
+   tolua_function(tolua_S,"getNextSelected",tolua_CEGUI_CEGUI_MultiColumnList_getNextSelected00);
+   tolua_function(tolua_S,"getSelectedCount",tolua_CEGUI_CEGUI_MultiColumnList_getSelectedCount00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_MultiColumnList_isItemSelected00);
+   tolua_function(tolua_S,"getNominatedSelectionColumnID",tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumnID00);
+   tolua_function(tolua_S,"getNominatedSelectionColumn",tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumn00);
+   tolua_function(tolua_S,"getNominatedSelectionRow",tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionRow00);
+   tolua_function(tolua_S,"getSelectionMode",tolua_CEGUI_CEGUI_MultiColumnList_getSelectionMode00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_MultiColumnList_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_MultiColumnList_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"getColumnID",tolua_CEGUI_CEGUI_MultiColumnList_getColumnID00);
+   tolua_function(tolua_S,"getRowID",tolua_CEGUI_CEGUI_MultiColumnList_getRowID00);
+   tolua_function(tolua_S,"getRowWithID",tolua_CEGUI_CEGUI_MultiColumnList_getRowWithID00);
+   tolua_function(tolua_S,"getListRenderArea",tolua_CEGUI_CEGUI_MultiColumnList_getListRenderArea00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_getHorzScrollbar00);
+   tolua_function(tolua_S,"getListHeader",tolua_CEGUI_CEGUI_MultiColumnList_getListHeader00);
+   tolua_function(tolua_S,"getTotalRowsHeight",tolua_CEGUI_CEGUI_MultiColumnList_getTotalRowsHeight00);
+   tolua_function(tolua_S,"getWidestColumnItemWidth",tolua_CEGUI_CEGUI_MultiColumnList_getWidestColumnItemWidth00);
+   tolua_function(tolua_S,"getHighestRowItemHeight",tolua_CEGUI_CEGUI_MultiColumnList_getHighestRowItemHeight00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_MultiColumnList_resetList00);
+   tolua_function(tolua_S,"addColumn",tolua_CEGUI_CEGUI_MultiColumnList_addColumn00);
+   tolua_function(tolua_S,"insertColumn",tolua_CEGUI_CEGUI_MultiColumnList_insertColumn00);
+   tolua_function(tolua_S,"removeColumn",tolua_CEGUI_CEGUI_MultiColumnList_removeColumn00);
+   tolua_function(tolua_S,"removeColumnWithID",tolua_CEGUI_CEGUI_MultiColumnList_removeColumnWithID00);
+   tolua_function(tolua_S,"moveColumn",tolua_CEGUI_CEGUI_MultiColumnList_moveColumn00);
+   tolua_function(tolua_S,"moveColumnWithID",tolua_CEGUI_CEGUI_MultiColumnList_moveColumnWithID00);
+   tolua_function(tolua_S,"addRow",tolua_CEGUI_CEGUI_MultiColumnList_addRow00);
+   tolua_function(tolua_S,"addRow",tolua_CEGUI_CEGUI_MultiColumnList_addRow01);
+   tolua_function(tolua_S,"insertRow",tolua_CEGUI_CEGUI_MultiColumnList_insertRow00);
+   tolua_function(tolua_S,"insertRow",tolua_CEGUI_CEGUI_MultiColumnList_insertRow01);
+   tolua_function(tolua_S,"removeRow",tolua_CEGUI_CEGUI_MultiColumnList_removeRow00);
+   tolua_function(tolua_S,"setItem",tolua_CEGUI_CEGUI_MultiColumnList_setItem00);
+   tolua_function(tolua_S,"setItem",tolua_CEGUI_CEGUI_MultiColumnList_setItem01);
+   tolua_function(tolua_S,"setSelectionMode",tolua_CEGUI_CEGUI_MultiColumnList_setSelectionMode00);
+   tolua_function(tolua_S,"setNominatedSelectionColumnID",tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumnID00);
+   tolua_function(tolua_S,"setNominatedSelectionColumn",tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumn00);
+   tolua_function(tolua_S,"setNominatedSelectionRow",tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionRow00);
+   tolua_function(tolua_S,"setSortDirection",tolua_CEGUI_CEGUI_MultiColumnList_setSortDirection00);
+   tolua_function(tolua_S,"setSortColumn",tolua_CEGUI_CEGUI_MultiColumnList_setSortColumn00);
+   tolua_function(tolua_S,"setSortColumnByID",tolua_CEGUI_CEGUI_MultiColumnList_setSortColumnByID00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_MultiColumnList_clearAllSelections00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState01);
+   tolua_function(tolua_S,"handleUpdatedItemData",tolua_CEGUI_CEGUI_MultiColumnList_handleUpdatedItemData00);
+   tolua_function(tolua_S,"setColumnHeaderWidth",tolua_CEGUI_CEGUI_MultiColumnList_setColumnHeaderWidth00);
+   tolua_function(tolua_S,"setUserSortControlEnabled",tolua_CEGUI_CEGUI_MultiColumnList_setUserSortControlEnabled00);
+   tolua_function(tolua_S,"setUserColumnSizingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnSizingEnabled00);
+   tolua_function(tolua_S,"setUserColumnDraggingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnDraggingEnabled00);
+   tolua_function(tolua_S,"autoSizeColumnHeader",tolua_CEGUI_CEGUI_MultiColumnList_autoSizeColumnHeader00);
+   tolua_function(tolua_S,"setRowID",tolua_CEGUI_CEGUI_MultiColumnList_setRowID00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ItemEntry","CEGUI::ItemEntry","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ItemEntry");
+   tolua_function(tolua_S,"getItemPixelSize",tolua_CEGUI_CEGUI_ItemEntry_getItemPixelSize00);
+   tolua_function(tolua_S,"getOwnerList",tolua_CEGUI_CEGUI_ItemEntry_getOwnerList00);
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_ItemEntry_isSelected00);
+   tolua_function(tolua_S,"isSelectable",tolua_CEGUI_CEGUI_ItemEntry_isSelectable00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_ItemEntry_setSelected00);
+   tolua_function(tolua_S,"select",tolua_CEGUI_CEGUI_ItemEntry_select00);
+   tolua_function(tolua_S,"deselect",tolua_CEGUI_CEGUI_ItemEntry_deselect00);
+   tolua_function(tolua_S,"setSelectable",tolua_CEGUI_CEGUI_ItemEntry_setSelectable00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ItemListBase","CEGUI::ItemListBase","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ItemListBase");
+   tolua_constant(tolua_S,"Ascending",CEGUI::ItemListBase::Ascending);
+   tolua_constant(tolua_S,"Descending",CEGUI::ItemListBase::Descending);
+   tolua_constant(tolua_S,"UserSort",CEGUI::ItemListBase::UserSort);
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_ItemListBase_getItemCount00);
+   tolua_function(tolua_S,"getItemFromIndex",tolua_CEGUI_CEGUI_ItemListBase_getItemFromIndex00);
+   tolua_function(tolua_S,"getItemIndex",tolua_CEGUI_CEGUI_ItemListBase_getItemIndex00);
+   tolua_function(tolua_S,"findItemWithText",tolua_CEGUI_CEGUI_ItemListBase_findItemWithText00);
+   tolua_function(tolua_S,"isItemInList",tolua_CEGUI_CEGUI_ItemListBase_isItemInList00);
+   tolua_function(tolua_S,"isAutoResizeEnabled",tolua_CEGUI_CEGUI_ItemListBase_isAutoResizeEnabled00);
+   tolua_function(tolua_S,"isSortEnabled",tolua_CEGUI_CEGUI_ItemListBase_isSortEnabled00);
+   tolua_function(tolua_S,"getSortMode",tolua_CEGUI_CEGUI_ItemListBase_getSortMode00);
+   tolua_function(tolua_S,"getItemRenderArea",tolua_CEGUI_CEGUI_ItemListBase_getItemRenderArea00);
+   tolua_function(tolua_S,"getContentPane",tolua_CEGUI_CEGUI_ItemListBase_getContentPane00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_ItemListBase_resetList00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_ItemListBase_addItem00);
+   tolua_function(tolua_S,"insertItem",tolua_CEGUI_CEGUI_ItemListBase_insertItem00);
+   tolua_function(tolua_S,"removeItem",tolua_CEGUI_CEGUI_ItemListBase_removeItem00);
+   tolua_function(tolua_S,"handleUpdatedItemData",tolua_CEGUI_CEGUI_ItemListBase_handleUpdatedItemData00);
+   tolua_function(tolua_S,"setAutoResizeEnabled",tolua_CEGUI_CEGUI_ItemListBase_setAutoResizeEnabled00);
+   tolua_function(tolua_S,"sizeToContent",tolua_CEGUI_CEGUI_ItemListBase_sizeToContent00);
+   tolua_function(tolua_S,"setSortEnabled",tolua_CEGUI_CEGUI_ItemListBase_setSortEnabled00);
+   tolua_function(tolua_S,"setSortMode",tolua_CEGUI_CEGUI_ItemListBase_setSortMode00);
+   tolua_function(tolua_S,"sortList",tolua_CEGUI_CEGUI_ItemListBase_sortList00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MenuBase","CEGUI::MenuBase","CEGUI::ItemListBase",NULL);
+  tolua_beginmodule(tolua_S,"MenuBase");
+   tolua_function(tolua_S,"getItemSpacing",tolua_CEGUI_CEGUI_MenuBase_getItemSpacing00);
+   tolua_function(tolua_S,"isMultiplePopupsAllowed",tolua_CEGUI_CEGUI_MenuBase_isMultiplePopupsAllowed00);
+   tolua_function(tolua_S,"getPopupMenuItem",tolua_CEGUI_CEGUI_MenuBase_getPopupMenuItem00);
+   tolua_function(tolua_S,"setItemSpacing",tolua_CEGUI_CEGUI_MenuBase_setItemSpacing00);
+   tolua_function(tolua_S,"changePopupMenuItem",tolua_CEGUI_CEGUI_MenuBase_changePopupMenuItem00);
+   tolua_function(tolua_S,"setAllowMultiplePopups",tolua_CEGUI_CEGUI_MenuBase_setAllowMultiplePopups00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Menubar","CEGUI::Menubar","CEGUI::MenuBase",NULL);
+  tolua_beginmodule(tolua_S,"Menubar");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PopupMenu","CEGUI::PopupMenu","CEGUI::MenuBase",NULL);
+  tolua_beginmodule(tolua_S,"PopupMenu");
+   tolua_function(tolua_S,"getFadeInTime",tolua_CEGUI_CEGUI_PopupMenu_getFadeInTime00);
+   tolua_function(tolua_S,"getFadeOutTime",tolua_CEGUI_CEGUI_PopupMenu_getFadeOutTime00);
+   tolua_function(tolua_S,"setFadeInTime",tolua_CEGUI_CEGUI_PopupMenu_setFadeInTime00);
+   tolua_function(tolua_S,"setFadeOutTime",tolua_CEGUI_CEGUI_PopupMenu_setFadeOutTime00);
+   tolua_function(tolua_S,"openPopupMenu",tolua_CEGUI_CEGUI_PopupMenu_openPopupMenu00);
+   tolua_function(tolua_S,"closePopupMenu",tolua_CEGUI_CEGUI_PopupMenu_closePopupMenu00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MenuItem","CEGUI::MenuItem","CEGUI::ItemEntry",NULL);
+  tolua_beginmodule(tolua_S,"MenuItem");
+   tolua_function(tolua_S,"isHovering",tolua_CEGUI_CEGUI_MenuItem_isHovering00);
+   tolua_function(tolua_S,"isPushed",tolua_CEGUI_CEGUI_MenuItem_isPushed00);
+   tolua_function(tolua_S,"getPopupMenu",tolua_CEGUI_CEGUI_MenuItem_getPopupMenu00);
+   tolua_function(tolua_S,"setPopupMenu",tolua_CEGUI_CEGUI_MenuItem_setPopupMenu00);
+   tolua_function(tolua_S,"openPopupMenu",tolua_CEGUI_CEGUI_MenuItem_openPopupMenu00);
+   tolua_function(tolua_S,"closePopupMenu",tolua_CEGUI_CEGUI_MenuItem_closePopupMenu00);
+   tolua_function(tolua_S,"togglePopupMenu",tolua_CEGUI_CEGUI_MenuItem_togglePopupMenu00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ScrolledItemListBase","CEGUI::ScrolledItemListBase","CEGUI::ItemListBase",NULL);
+  tolua_beginmodule(tolua_S,"ScrolledItemListBase");
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrolledItemListBase_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrolledItemListBase_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_getHorzScrollbar00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowHorzScrollbar00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ItemListbox","CEGUI::ItemListbox","CEGUI::ScrolledItemListBase",NULL);
+  tolua_beginmodule(tolua_S,"ItemListbox");
+   tolua_function(tolua_S,"getSelectedCount",tolua_CEGUI_CEGUI_ItemListbox_getSelectedCount00);
+   tolua_function(tolua_S,"getLastSelectedItem",tolua_CEGUI_CEGUI_ItemListbox_getLastSelectedItem00);
+   tolua_function(tolua_S,"getFirstSelectedItem",tolua_CEGUI_CEGUI_ItemListbox_getFirstSelectedItem00);
+   tolua_function(tolua_S,"getNextSelectedItem",tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItem00);
+   tolua_function(tolua_S,"getNextSelectedItemAfter",tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItemAfter00);
+   tolua_function(tolua_S,"isMultiSelectEnabled",tolua_CEGUI_CEGUI_ItemListbox_isMultiSelectEnabled00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_ItemListbox_isItemSelected00);
+   tolua_function(tolua_S,"setMultiSelectEnabled",tolua_CEGUI_CEGUI_ItemListbox_setMultiSelectEnabled00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_ItemListbox_clearAllSelections00);
+   tolua_function(tolua_S,"selectRange",tolua_CEGUI_CEGUI_ItemListbox_selectRange00);
+   tolua_function(tolua_S,"selectAllItems",tolua_CEGUI_CEGUI_ItemListbox_selectAllItems00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"DT_LEFT_EDGE",CEGUI::DT_LEFT_EDGE);
+  tolua_constant(tolua_S,"DT_X_POSITION",CEGUI::DT_X_POSITION);
+  tolua_constant(tolua_S,"DT_TOP_EDGE",CEGUI::DT_TOP_EDGE);
+  tolua_constant(tolua_S,"DT_Y_POSITION",CEGUI::DT_Y_POSITION);
+  tolua_constant(tolua_S,"DT_RIGHT_EDGE",CEGUI::DT_RIGHT_EDGE);
+  tolua_constant(tolua_S,"DT_BOTTOM_EDGE",CEGUI::DT_BOTTOM_EDGE);
+  tolua_constant(tolua_S,"DT_WIDTH",CEGUI::DT_WIDTH);
+  tolua_constant(tolua_S,"DT_HEIGHT",CEGUI::DT_HEIGHT);
+  tolua_constant(tolua_S,"DT_X_OFFSET",CEGUI::DT_X_OFFSET);
+  tolua_constant(tolua_S,"DT_Y_OFFSET",CEGUI::DT_Y_OFFSET);
+  tolua_constant(tolua_S,"DT_INVALID",CEGUI::DT_INVALID);
+  tolua_constant(tolua_S,"VF_TOP_ALIGNED",CEGUI::VF_TOP_ALIGNED);
+  tolua_constant(tolua_S,"VF_CENTRE_ALIGNED",CEGUI::VF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"VF_BOTTOM_ALIGNED",CEGUI::VF_BOTTOM_ALIGNED);
+  tolua_constant(tolua_S,"VF_STRETCHED",CEGUI::VF_STRETCHED);
+  tolua_constant(tolua_S,"VF_TILED",CEGUI::VF_TILED);
+  tolua_constant(tolua_S,"HF_LEFT_ALIGNED",CEGUI::HF_LEFT_ALIGNED);
+  tolua_constant(tolua_S,"HF_CENTRE_ALIGNED",CEGUI::HF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"HF_RIGHT_ALIGNED",CEGUI::HF_RIGHT_ALIGNED);
+  tolua_constant(tolua_S,"HF_STRETCHED",CEGUI::HF_STRETCHED);
+  tolua_constant(tolua_S,"HF_TILED",CEGUI::HF_TILED);
+  tolua_constant(tolua_S,"VTF_TOP_ALIGNED",CEGUI::VTF_TOP_ALIGNED);
+  tolua_constant(tolua_S,"VTF_CENTRE_ALIGNED",CEGUI::VTF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"VTF_BOTTOM_ALIGNED",CEGUI::VTF_BOTTOM_ALIGNED);
+  tolua_constant(tolua_S,"HTF_LEFT_ALIGNED",CEGUI::HTF_LEFT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_RIGHT_ALIGNED",CEGUI::HTF_RIGHT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_CENTRE_ALIGNED",CEGUI::HTF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"HTF_JUSTIFIED",CEGUI::HTF_JUSTIFIED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_LEFT_ALIGNED",CEGUI::HTF_WORDWRAP_LEFT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_RIGHT_ALIGNED",CEGUI::HTF_WORDWRAP_RIGHT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_CENTRE_ALIGNED",CEGUI::HTF_WORDWRAP_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_JUSTIFIED",CEGUI::HTF_WORDWRAP_JUSTIFIED);
+  tolua_constant(tolua_S,"FMT_LINE_SPACING",CEGUI::FMT_LINE_SPACING);
+  tolua_constant(tolua_S,"FMT_BASELINE",CEGUI::FMT_BASELINE);
+  tolua_constant(tolua_S,"FMT_HORZ_EXTENT",CEGUI::FMT_HORZ_EXTENT);
+  tolua_constant(tolua_S,"DOP_NOOP",CEGUI::DOP_NOOP);
+  tolua_constant(tolua_S,"DOP_ADD",CEGUI::DOP_ADD);
+  tolua_constant(tolua_S,"DOP_SUBTRACT",CEGUI::DOP_SUBTRACT);
+  tolua_constant(tolua_S,"DOP_MULTIPLY",CEGUI::DOP_MULTIPLY);
+  tolua_constant(tolua_S,"DOP_DIVIDE",CEGUI::DOP_DIVIDE);
+  tolua_constant(tolua_S,"FIC_BACKGROUND",CEGUI::FIC_BACKGROUND);
+  tolua_constant(tolua_S,"FIC_TOP_LEFT_CORNER",CEGUI::FIC_TOP_LEFT_CORNER);
+  tolua_constant(tolua_S,"FIC_TOP_RIGHT_CORNER",CEGUI::FIC_TOP_RIGHT_CORNER);
+  tolua_constant(tolua_S,"FIC_BOTTOM_LEFT_CORNER",CEGUI::FIC_BOTTOM_LEFT_CORNER);
+  tolua_constant(tolua_S,"FIC_BOTTOM_RIGHT_CORNER",CEGUI::FIC_BOTTOM_RIGHT_CORNER);
+  tolua_constant(tolua_S,"FIC_LEFT_EDGE",CEGUI::FIC_LEFT_EDGE);
+  tolua_constant(tolua_S,"FIC_RIGHT_EDGE",CEGUI::FIC_RIGHT_EDGE);
+  tolua_constant(tolua_S,"FIC_TOP_EDGE",CEGUI::FIC_TOP_EDGE);
+  tolua_constant(tolua_S,"FIC_BOTTOM_EDGE",CEGUI::FIC_BOTTOM_EDGE);
+  tolua_constant(tolua_S,"FIC_FRAME_IMAGE_COUNT",CEGUI::FIC_FRAME_IMAGE_COUNT);
+  tolua_cclass(tolua_S,"BaseDim","CEGUI::BaseDim","",NULL);
+  tolua_beginmodule(tolua_S,"BaseDim");
+   tolua_function(tolua_S,"getValue",tolua_CEGUI_CEGUI_BaseDim_getValue00);
+   tolua_function(tolua_S,"getValue",tolua_CEGUI_CEGUI_BaseDim_getValue01);
+   tolua_function(tolua_S,"clone",tolua_CEGUI_CEGUI_BaseDim_clone00);
+   tolua_function(tolua_S,"getDimensionOperator",tolua_CEGUI_CEGUI_BaseDim_getDimensionOperator00);
+   tolua_function(tolua_S,"setDimensionOperator",tolua_CEGUI_CEGUI_BaseDim_setDimensionOperator00);
+   tolua_function(tolua_S,"getOperand",tolua_CEGUI_CEGUI_BaseDim_getOperand00);
+   tolua_function(tolua_S,"setOperand",tolua_CEGUI_CEGUI_BaseDim_setOperand00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"AbsoluteDim","CEGUI::AbsoluteDim","CEGUI::BaseDim",tolua_collect_CEGUI__AbsoluteDim);
+  #else
+  tolua_cclass(tolua_S,"AbsoluteDim","CEGUI::AbsoluteDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"AbsoluteDim");
+   tolua_function(tolua_S,"setValue",tolua_CEGUI_CEGUI_AbsoluteDim_setValue00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_AbsoluteDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_AbsoluteDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_AbsoluteDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImageDim","CEGUI::ImageDim","CEGUI::BaseDim",tolua_collect_CEGUI__ImageDim);
+  #else
+  tolua_cclass(tolua_S,"ImageDim","CEGUI::ImageDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImageDim");
+   tolua_function(tolua_S,"setSourceImage",tolua_CEGUI_CEGUI_ImageDim_setSourceImage00);
+   tolua_function(tolua_S,"setSourceDimension",tolua_CEGUI_CEGUI_ImageDim_setSourceDimension00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImageDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImageDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImageDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetDim","CEGUI::WidgetDim","CEGUI::BaseDim",tolua_collect_CEGUI__WidgetDim);
+  #else
+  tolua_cclass(tolua_S,"WidgetDim","CEGUI::WidgetDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetDim");
+   tolua_function(tolua_S,"setWidgetName",tolua_CEGUI_CEGUI_WidgetDim_setWidgetName00);
+   tolua_function(tolua_S,"setSourceDimension",tolua_CEGUI_CEGUI_WidgetDim_setSourceDimension00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"UnifiedDim","CEGUI::UnifiedDim","CEGUI::BaseDim",tolua_collect_CEGUI__UnifiedDim);
+  #else
+  tolua_cclass(tolua_S,"UnifiedDim","CEGUI::UnifiedDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"UnifiedDim");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UnifiedDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UnifiedDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UnifiedDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FontDim","CEGUI::FontDim","CEGUI::BaseDim",tolua_collect_CEGUI__FontDim);
+  #else
+  tolua_cclass(tolua_S,"FontDim","CEGUI::FontDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FontDim");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FontDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FontDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FontDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyDim","CEGUI::PropertyDim","CEGUI::BaseDim",tolua_collect_CEGUI__PropertyDim);
+  #else
+  tolua_cclass(tolua_S,"PropertyDim","CEGUI::PropertyDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyDim");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Dimension","CEGUI::Dimension","",tolua_collect_CEGUI__Dimension);
+  #else
+  tolua_cclass(tolua_S,"Dimension","CEGUI::Dimension","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Dimension");
+   tolua_function(tolua_S,"getBaseDimension",tolua_CEGUI_CEGUI_Dimension_getBaseDimension00);
+   tolua_function(tolua_S,"setBaseDimension",tolua_CEGUI_CEGUI_Dimension_setBaseDimension00);
+   tolua_function(tolua_S,"getDimensionType",tolua_CEGUI_CEGUI_Dimension_getDimensionType00);
+   tolua_function(tolua_S,"setDimensionType",tolua_CEGUI_CEGUI_Dimension_setDimensionType00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Dimension_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Dimension_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Dimension_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Dimension_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Dimension_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Dimension_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Dimension_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Dimension_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Dimension_new02_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ComponentArea","CEGUI::ComponentArea","",tolua_collect_CEGUI__ComponentArea);
+  #else
+  tolua_cclass(tolua_S,"ComponentArea","CEGUI::ComponentArea","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ComponentArea");
+   tolua_function(tolua_S,"getPixelRect",tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00);
+   tolua_function(tolua_S,"getPixelRect",tolua_CEGUI_CEGUI_ComponentArea_getPixelRect01);
+   tolua_function(tolua_S,"isAreaFetchedFromProperty",tolua_CEGUI_CEGUI_ComponentArea_isAreaFetchedFromProperty00);
+   tolua_function(tolua_S,"getAreaPropertySource",tolua_CEGUI_CEGUI_ComponentArea_getAreaPropertySource00);
+   tolua_function(tolua_S,"setAreaPropertySource",tolua_CEGUI_CEGUI_ComponentArea_setAreaPropertySource00);
+   tolua_variable(tolua_S,"d_left",tolua_get_CEGUI__ComponentArea_d_left,tolua_set_CEGUI__ComponentArea_d_left);
+   tolua_variable(tolua_S,"d_top",tolua_get_CEGUI__ComponentArea_d_top,tolua_set_CEGUI__ComponentArea_d_top);
+   tolua_variable(tolua_S,"d_right_or_width",tolua_get_CEGUI__ComponentArea_d_right_or_width,tolua_set_CEGUI__ComponentArea_d_right_or_width);
+   tolua_variable(tolua_S,"d_bottom_or_height",tolua_get_CEGUI__ComponentArea_d_bottom_or_height,tolua_set_CEGUI__ComponentArea_d_bottom_or_height);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ComponentArea_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ComponentArea_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ComponentArea_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"NamedArea","CEGUI::NamedArea","",tolua_collect_CEGUI__NamedArea);
+  #else
+  tolua_cclass(tolua_S,"NamedArea","CEGUI::NamedArea","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"NamedArea");
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_NamedArea_getName00);
+   tolua_function(tolua_S,"getArea",tolua_CEGUI_CEGUI_NamedArea_getArea00);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_NamedArea_setArea00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_NamedArea_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_NamedArea_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_NamedArea_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_NamedArea_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_NamedArea_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_NamedArea_new01_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PropertyDefinitionBase","CEGUI::PropertyDefinitionBase","CEGUI::Property",NULL);
+  tolua_beginmodule(tolua_S,"PropertyDefinitionBase");
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_PropertyDefinitionBase_set00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyDefinition","CEGUI::PropertyDefinition","CEGUI::PropertyDefinitionBase",tolua_collect_CEGUI__PropertyDefinition);
+  #else
+  tolua_cclass(tolua_S,"PropertyDefinition","CEGUI::PropertyDefinition","CEGUI::PropertyDefinitionBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyDefinition");
+   tolua_function(tolua_S,"get",tolua_CEGUI_CEGUI_PropertyDefinition_get00);
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_PropertyDefinition_set00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyDefinition_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyDefinition_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyDefinition_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyInitialiser","CEGUI::PropertyInitialiser","",tolua_collect_CEGUI__PropertyInitialiser);
+  #else
+  tolua_cclass(tolua_S,"PropertyInitialiser","CEGUI::PropertyInitialiser","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyInitialiser");
+   tolua_function(tolua_S,"apply",tolua_CEGUI_CEGUI_PropertyInitialiser_apply00);
+   tolua_function(tolua_S,"getTargetPropertyName",tolua_CEGUI_CEGUI_PropertyInitialiser_getTargetPropertyName00);
+   tolua_function(tolua_S,"getInitialiserValue",tolua_CEGUI_CEGUI_PropertyInitialiser_getInitialiserValue00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyInitialiser_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyLinkDefinition","CEGUI::PropertyLinkDefinition","CEGUI::PropertyDefinitionBase",tolua_collect_CEGUI__PropertyLinkDefinition);
+  #else
+  tolua_cclass(tolua_S,"PropertyLinkDefinition","CEGUI::PropertyLinkDefinition","CEGUI::PropertyDefinitionBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyLinkDefinition");
+   tolua_function(tolua_S,"get",tolua_CEGUI_CEGUI_PropertyLinkDefinition_get00);
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_PropertyLinkDefinition_set00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"FalagardComponentBase","CEGUI::FalagardComponentBase","",NULL);
+  tolua_beginmodule(tolua_S,"FalagardComponentBase");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_FalagardComponentBase_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_FalagardComponentBase_render01);
+   tolua_function(tolua_S,"getComponentArea",tolua_CEGUI_CEGUI_FalagardComponentBase_getComponentArea00);
+   tolua_function(tolua_S,"setComponentArea",tolua_CEGUI_CEGUI_FalagardComponentBase_setComponentArea00);
+   tolua_function(tolua_S,"getColours",tolua_CEGUI_CEGUI_FalagardComponentBase_getColours00);
+   tolua_function(tolua_S,"setColours",tolua_CEGUI_CEGUI_FalagardComponentBase_setColours00);
+   tolua_function(tolua_S,"setColoursPropertySource",tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertySource00);
+   tolua_function(tolua_S,"setColoursPropertyIsColourRect",tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertyIsColourRect00);
+   tolua_function(tolua_S,"setVertFormattingPropertySource",tolua_CEGUI_CEGUI_FalagardComponentBase_setVertFormattingPropertySource00);
+   tolua_function(tolua_S,"setHorzFormattingPropertySource",tolua_CEGUI_CEGUI_FalagardComponentBase_setHorzFormattingPropertySource00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FrameComponent","CEGUI::FrameComponent","CEGUI::FalagardComponentBase",tolua_collect_CEGUI__FrameComponent);
+  #else
+  tolua_cclass(tolua_S,"FrameComponent","CEGUI::FrameComponent","CEGUI::FalagardComponentBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FrameComponent");
+   tolua_function(tolua_S,"getBackgroundVerticalFormatting",tolua_CEGUI_CEGUI_FrameComponent_getBackgroundVerticalFormatting00);
+   tolua_function(tolua_S,"setBackgroundVerticalFormatting",tolua_CEGUI_CEGUI_FrameComponent_setBackgroundVerticalFormatting00);
+   tolua_function(tolua_S,"getBackgroundHorizontalFormatting",tolua_CEGUI_CEGUI_FrameComponent_getBackgroundHorizontalFormatting00);
+   tolua_function(tolua_S,"setBackgroundHorizontalFormatting",tolua_CEGUI_CEGUI_FrameComponent_setBackgroundHorizontalFormatting00);
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_FrameComponent_getImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_FrameComponent_setImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_FrameComponent_setImage01);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FrameComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FrameComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FrameComponent_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImageryComponent","CEGUI::ImageryComponent","CEGUI::FalagardComponentBase",tolua_collect_CEGUI__ImageryComponent);
+  #else
+  tolua_cclass(tolua_S,"ImageryComponent","CEGUI::ImageryComponent","CEGUI::FalagardComponentBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImageryComponent");
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_ImageryComponent_getImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_ImageryComponent_setImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_ImageryComponent_setImage01);
+   tolua_function(tolua_S,"getVerticalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_getVerticalFormatting00);
+   tolua_function(tolua_S,"setVerticalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_setVerticalFormatting00);
+   tolua_function(tolua_S,"getHorizontalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_getHorizontalFormatting00);
+   tolua_function(tolua_S,"setHorizontalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_setHorizontalFormatting00);
+   tolua_function(tolua_S,"isImageFetchedFromProperty",tolua_CEGUI_CEGUI_ImageryComponent_isImageFetchedFromProperty00);
+   tolua_function(tolua_S,"getImagePropertySource",tolua_CEGUI_CEGUI_ImageryComponent_getImagePropertySource00);
+   tolua_function(tolua_S,"setImagePropertySource",tolua_CEGUI_CEGUI_ImageryComponent_setImagePropertySource00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImageryComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImageryComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImageryComponent_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"TextComponent","CEGUI::TextComponent","CEGUI::FalagardComponentBase",tolua_collect_CEGUI__TextComponent);
+  #else
+  tolua_cclass(tolua_S,"TextComponent","CEGUI::TextComponent","CEGUI::FalagardComponentBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"TextComponent");
+   tolua_function(tolua_S,"getText",tolua_CEGUI_CEGUI_TextComponent_getText00);
+   tolua_function(tolua_S,"setText",tolua_CEGUI_CEGUI_TextComponent_setText00);
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_TextComponent_getFont00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_TextComponent_setFont00);
+   tolua_function(tolua_S,"getVerticalFormatting",tolua_CEGUI_CEGUI_TextComponent_getVerticalFormatting00);
+   tolua_function(tolua_S,"setVerticalFormatting",tolua_CEGUI_CEGUI_TextComponent_setVerticalFormatting00);
+   tolua_function(tolua_S,"getHorizontalFormatting",tolua_CEGUI_CEGUI_TextComponent_getHorizontalFormatting00);
+   tolua_function(tolua_S,"setHorizontalFormatting",tolua_CEGUI_CEGUI_TextComponent_setHorizontalFormatting00);
+   tolua_function(tolua_S,"isTextFetchedFromProperty",tolua_CEGUI_CEGUI_TextComponent_isTextFetchedFromProperty00);
+   tolua_function(tolua_S,"getTextPropertySource",tolua_CEGUI_CEGUI_TextComponent_getTextPropertySource00);
+   tolua_function(tolua_S,"setTextPropertySource",tolua_CEGUI_CEGUI_TextComponent_setTextPropertySource00);
+   tolua_function(tolua_S,"isFontFetchedFromProperty",tolua_CEGUI_CEGUI_TextComponent_isFontFetchedFromProperty00);
+   tolua_function(tolua_S,"getFontPropertySource",tolua_CEGUI_CEGUI_TextComponent_getFontPropertySource00);
+   tolua_function(tolua_S,"setFontPropertySource",tolua_CEGUI_CEGUI_TextComponent_setFontPropertySource00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_TextComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_TextComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_TextComponent_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImagerySection","CEGUI::ImagerySection","",tolua_collect_CEGUI__ImagerySection);
+  #else
+  tolua_cclass(tolua_S,"ImagerySection","CEGUI::ImagerySection","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImagerySection");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_ImagerySection_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_ImagerySection_render01);
+   tolua_function(tolua_S,"addImageryComponent",tolua_CEGUI_CEGUI_ImagerySection_addImageryComponent00);
+   tolua_function(tolua_S,"clearImageryComponents",tolua_CEGUI_CEGUI_ImagerySection_clearImageryComponents00);
+   tolua_function(tolua_S,"addTextComponent",tolua_CEGUI_CEGUI_ImagerySection_addTextComponent00);
+   tolua_function(tolua_S,"clearTextComponents",tolua_CEGUI_CEGUI_ImagerySection_clearTextComponents00);
+   tolua_function(tolua_S,"clearFrameComponents",tolua_CEGUI_CEGUI_ImagerySection_clearFrameComponents00);
+   tolua_function(tolua_S,"addFrameComponent",tolua_CEGUI_CEGUI_ImagerySection_addFrameComponent00);
+   tolua_function(tolua_S,"getMasterColours",tolua_CEGUI_CEGUI_ImagerySection_getMasterColours00);
+   tolua_function(tolua_S,"setMasterColours",tolua_CEGUI_CEGUI_ImagerySection_setMasterColours00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_ImagerySection_getName00);
+   tolua_function(tolua_S,"setMasterColoursPropertySource",tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertySource00);
+   tolua_function(tolua_S,"setMasterColoursPropertyIsColourRect",tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertyIsColourRect00);
+   tolua_function(tolua_S,"getBoundingRect",tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00);
+   tolua_function(tolua_S,"getBoundingRect",tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect01);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImagerySection_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImagerySection_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImagerySection_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImagerySection_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImagerySection_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImagerySection_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"SectionSpecification","CEGUI::SectionSpecification","",tolua_collect_CEGUI__SectionSpecification);
+  #else
+  tolua_cclass(tolua_S,"SectionSpecification","CEGUI::SectionSpecification","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"SectionSpecification");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_SectionSpecification_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_SectionSpecification_render01);
+   tolua_function(tolua_S,"getOwnerWidgetLookFeel",tolua_CEGUI_CEGUI_SectionSpecification_getOwnerWidgetLookFeel00);
+   tolua_function(tolua_S,"getSectionName",tolua_CEGUI_CEGUI_SectionSpecification_getSectionName00);
+   tolua_function(tolua_S,"getOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_getOverrideColours00);
+   tolua_function(tolua_S,"setOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColours00);
+   tolua_function(tolua_S,"isUsingOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_isUsingOverrideColours00);
+   tolua_function(tolua_S,"setUsingOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_setUsingOverrideColours00);
+   tolua_function(tolua_S,"setOverrideColoursPropertySource",tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertySource00);
+   tolua_function(tolua_S,"setOverrideColoursPropertyIsColourRect",tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertyIsColourRect00);
+   tolua_function(tolua_S,"setRenderControlPropertySource",tolua_CEGUI_CEGUI_SectionSpecification_setRenderControlPropertySource00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_SectionSpecification_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_SectionSpecification_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_SectionSpecification_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_SectionSpecification_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_SectionSpecification_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_SectionSpecification_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"LayerSpecification","CEGUI::LayerSpecification","",tolua_collect_CEGUI__LayerSpecification);
+  #else
+  tolua_cclass(tolua_S,"LayerSpecification","CEGUI::LayerSpecification","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"LayerSpecification");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_LayerSpecification_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_LayerSpecification_render01);
+   tolua_function(tolua_S,"addSectionSpecification",tolua_CEGUI_CEGUI_LayerSpecification_addSectionSpecification00);
+   tolua_function(tolua_S,"clearSectionSpecifications",tolua_CEGUI_CEGUI_LayerSpecification_clearSectionSpecifications00);
+   tolua_function(tolua_S,"getLayerPriority",tolua_CEGUI_CEGUI_LayerSpecification_getLayerPriority00);
+   tolua_function(tolua_S,".lt",tolua_CEGUI_CEGUI_LayerSpecification__lt00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_LayerSpecification_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_LayerSpecification_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_LayerSpecification_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"StateImagery","CEGUI::StateImagery","",tolua_collect_CEGUI__StateImagery);
+  #else
+  tolua_cclass(tolua_S,"StateImagery","CEGUI::StateImagery","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"StateImagery");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_StateImagery_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_StateImagery_render01);
+   tolua_function(tolua_S,"addLayer",tolua_CEGUI_CEGUI_StateImagery_addLayer00);
+   tolua_function(tolua_S,"clearLayers",tolua_CEGUI_CEGUI_StateImagery_clearLayers00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_StateImagery_getName00);
+   tolua_function(tolua_S,"isClippedToDisplay",tolua_CEGUI_CEGUI_StateImagery_isClippedToDisplay00);
+   tolua_function(tolua_S,"setClippedToDisplay",tolua_CEGUI_CEGUI_StateImagery_setClippedToDisplay00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_StateImagery_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_StateImagery_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_StateImagery_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_StateImagery_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_StateImagery_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_StateImagery_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetComponent","CEGUI::WidgetComponent","",tolua_collect_CEGUI__WidgetComponent);
+  #else
+  tolua_cclass(tolua_S,"WidgetComponent","CEGUI::WidgetComponent","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetComponent");
+   tolua_function(tolua_S,"create",tolua_CEGUI_CEGUI_WidgetComponent_create00);
+   tolua_function(tolua_S,"getComponentArea",tolua_CEGUI_CEGUI_WidgetComponent_getComponentArea00);
+   tolua_function(tolua_S,"setComponentArea",tolua_CEGUI_CEGUI_WidgetComponent_setComponentArea00);
+   tolua_function(tolua_S,"getBaseWidgetType",tolua_CEGUI_CEGUI_WidgetComponent_getBaseWidgetType00);
+   tolua_function(tolua_S,"setBaseWidgetType",tolua_CEGUI_CEGUI_WidgetComponent_setBaseWidgetType00);
+   tolua_function(tolua_S,"getWidgetLookName",tolua_CEGUI_CEGUI_WidgetComponent_getWidgetLookName00);
+   tolua_function(tolua_S,"setWidgetLookName",tolua_CEGUI_CEGUI_WidgetComponent_setWidgetLookName00);
+   tolua_function(tolua_S,"getWidgetNameSuffix",tolua_CEGUI_CEGUI_WidgetComponent_getWidgetNameSuffix00);
+   tolua_function(tolua_S,"setWidgetNameSuffix",tolua_CEGUI_CEGUI_WidgetComponent_setWidgetNameSuffix00);
+   tolua_function(tolua_S,"getWindowRendererType",tolua_CEGUI_CEGUI_WidgetComponent_getWindowRendererType00);
+   tolua_function(tolua_S,"setWindowRendererType",tolua_CEGUI_CEGUI_WidgetComponent_setWindowRendererType00);
+   tolua_function(tolua_S,"getVerticalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_getVerticalWidgetAlignment00);
+   tolua_function(tolua_S,"setVerticalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_setVerticalWidgetAlignment00);
+   tolua_function(tolua_S,"getHorizontalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_getHorizontalWidgetAlignment00);
+   tolua_function(tolua_S,"setHorizontalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_setHorizontalWidgetAlignment00);
+   tolua_function(tolua_S,"addPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetComponent_addPropertyInitialiser00);
+   tolua_function(tolua_S,"clearPropertyInitialisers",tolua_CEGUI_CEGUI_WidgetComponent_clearPropertyInitialisers00);
+   tolua_function(tolua_S,"layout",tolua_CEGUI_CEGUI_WidgetComponent_layout00);
+   tolua_function(tolua_S,"findPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetComponent_findPropertyInitialiser00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetComponent_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetComponent_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetComponent_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetComponent_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetLookFeel","CEGUI::WidgetLookFeel","",tolua_collect_CEGUI__WidgetLookFeel);
+  #else
+  tolua_cclass(tolua_S,"WidgetLookFeel","CEGUI::WidgetLookFeel","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetLookFeel");
+   tolua_function(tolua_S,"getStateImagery",tolua_CEGUI_CEGUI_WidgetLookFeel_getStateImagery00);
+   tolua_function(tolua_S,"getImagerySection",tolua_CEGUI_CEGUI_WidgetLookFeel_getImagerySection00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_WidgetLookFeel_getName00);
+   tolua_function(tolua_S,"addImagerySection",tolua_CEGUI_CEGUI_WidgetLookFeel_addImagerySection00);
+   tolua_function(tolua_S,"addWidgetComponent",tolua_CEGUI_CEGUI_WidgetLookFeel_addWidgetComponent00);
+   tolua_function(tolua_S,"addStateSpecification",tolua_CEGUI_CEGUI_WidgetLookFeel_addStateSpecification00);
+   tolua_function(tolua_S,"addPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyInitialiser00);
+   tolua_function(tolua_S,"clearImagerySections",tolua_CEGUI_CEGUI_WidgetLookFeel_clearImagerySections00);
+   tolua_function(tolua_S,"clearWidgetComponents",tolua_CEGUI_CEGUI_WidgetLookFeel_clearWidgetComponents00);
+   tolua_function(tolua_S,"clearStateSpecifications",tolua_CEGUI_CEGUI_WidgetLookFeel_clearStateSpecifications00);
+   tolua_function(tolua_S,"clearPropertyInitialisers",tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyInitialisers00);
+   tolua_function(tolua_S,"initialiseWidget",tolua_CEGUI_CEGUI_WidgetLookFeel_initialiseWidget00);
+   tolua_function(tolua_S,"isStateImageryPresent",tolua_CEGUI_CEGUI_WidgetLookFeel_isStateImageryPresent00);
+   tolua_function(tolua_S,"addNamedArea",tolua_CEGUI_CEGUI_WidgetLookFeel_addNamedArea00);
+   tolua_function(tolua_S,"clearNamedAreas",tolua_CEGUI_CEGUI_WidgetLookFeel_clearNamedAreas00);
+   tolua_function(tolua_S,"getNamedArea",tolua_CEGUI_CEGUI_WidgetLookFeel_getNamedArea00);
+   tolua_function(tolua_S,"isNamedAreaDefined",tolua_CEGUI_CEGUI_WidgetLookFeel_isNamedAreaDefined00);
+   tolua_function(tolua_S,"layoutChildWidgets",tolua_CEGUI_CEGUI_WidgetLookFeel_layoutChildWidgets00);
+   tolua_function(tolua_S,"addPropertyDefinition",tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyDefinition00);
+   tolua_function(tolua_S,"addPropertyLinkDefinition",tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyLinkDefinition00);
+   tolua_function(tolua_S,"clearPropertyDefinitions",tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyDefinitions00);
+   tolua_function(tolua_S,"clearPropertyLinkDefinitions",tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyLinkDefinitions00);
+   tolua_function(tolua_S,"renameChildren",tolua_CEGUI_CEGUI_WidgetLookFeel_renameChildren00);
+   tolua_function(tolua_S,"findPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetLookFeel_findPropertyInitialiser00);
+   tolua_function(tolua_S,"findWidgetComponent",tolua_CEGUI_CEGUI_WidgetLookFeel_findWidgetComponent00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetLookFeel_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetLookFeel_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetLookManager","CEGUI::WidgetLookManager","",tolua_collect_CEGUI__WidgetLookManager);
+  #else
+  tolua_cclass(tolua_S,"WidgetLookManager","CEGUI::WidgetLookManager","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetLookManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_WidgetLookManager_getSingleton00);
+   tolua_function(tolua_S,"parseLookNFeelSpecification",tolua_CEGUI_CEGUI_WidgetLookManager_parseLookNFeelSpecification00);
+   tolua_function(tolua_S,"isWidgetLookAvailable",tolua_CEGUI_CEGUI_WidgetLookManager_isWidgetLookAvailable00);
+   tolua_function(tolua_S,"getWidgetLook",tolua_CEGUI_CEGUI_WidgetLookManager_getWidgetLook00);
+   tolua_function(tolua_S,"eraseWidgetLook",tolua_CEGUI_CEGUI_WidgetLookManager_eraseWidgetLook00);
+   tolua_function(tolua_S,"addWidgetLook",tolua_CEGUI_CEGUI_WidgetLookManager_addWidgetLook00);
+   tolua_function(tolua_S,"writeWidgetLookToStream",tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookToStream00);
+   tolua_function(tolua_S,"writeWidgetLookSeriesToStream",tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookSeriesToStream00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetLookManager_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetLookManager_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetLookManager_new00_local);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_WidgetLookManager_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_WidgetLookManager_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73,
+    46,116,111, 77,111,117,115,101, 67,117,114,115,111,114, 69,
+   118,101,110,116, 65,114,103,115, 40,101, 41, 10,114,101,116,
+   117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,
+   101, 44, 34, 99,111,110,115,116, 32, 67, 69, 71, 85, 73, 58,
+    58, 77,111,117,115,101, 67,117,114,115,111,114, 69,118,101,
+   110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    87,105,110,100,111,119, 69,118,101,110,116, 65,114,103,115,
+    40,101, 41, 10,114,101,116,117,114,110, 32,116,111,108,117,
+    97, 46, 99, 97,115,116, 40,101, 44, 34, 99,111,110,115,116,
+    32, 67, 69, 71, 85, 73, 58, 58, 87,105,110,100,111,119, 69,
+   118,101,110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,
+   102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 65, 99,116,105,118, 97,116,105,111,110, 69,118,101,
+   110,116, 65,114,103,115, 40,101, 41, 10,114,101,116,117,114,
+   110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,101, 44,
+    34, 99,111,110,115,116, 32, 67, 69, 71, 85, 73, 58, 58, 65,
+    99,116,105,118, 97,116,105,111,110, 69,118,101,110,116, 65,
+   114,103,115, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,
+   105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 72,101, 97,
+   100,101,114, 83,101,113,117,101,110, 99,101, 69,118,101,110,
+   116, 65,114,103,115, 40,101, 41, 10,114,101,116,117,114,110,
+    32,116,111,108,117, 97, 46, 99, 97,115,116, 40,101, 44, 34,
+    99,111,110,115,116, 32, 67, 69, 71, 85, 73, 58, 58, 72,101,
+    97,100,101,114, 83,101,113,117,101,110, 99,101, 69,118,101,
+   110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    77,111,117,115,101, 69,118,101,110,116, 65,114,103,115, 40,
+   101, 41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97,
+    46, 99, 97,115,116, 40,101, 44, 34, 99,111,110,115,116, 32,
+    67, 69, 71, 85, 73, 58, 58, 77,111,117,115,101, 69,118,101,
+   110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    75,101,121, 69,118,101,110,116, 65,114,103,115, 40,101, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,101, 44, 34, 99,111,110,115,116, 32, 67, 69,
+    71, 85, 73, 58, 58, 75,101,121, 69,118,101,110,116, 65,114,
+   103,115, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 68,114, 97,103,
+    68,114,111,112, 69,118,101,110,116, 65,114,103,115, 40,101,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,101, 44, 34, 99,111,110,115,116, 32, 67,
+    69, 71, 85, 73, 58, 58, 68,114, 97,103, 68,114,111,112, 69,
+   118,101,110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,
+    67, 69, 71, 85, 73, 46, 69,118,101,110,116, 65,114,103,115,
+    46,116,111, 77,111,117,115,101, 67,117,114,115,111,114, 69,
+   118,101,110,116, 65,114,103,115, 32, 61, 32, 67, 69, 71, 85,
+    73, 46,116,111, 77,111,117,115,101, 67,117,114,115,111,114,
+    69,118,101,110,116, 65,114,103,115, 10, 67, 69, 71, 85, 73,
+    46, 69,118,101,110,116, 65,114,103,115, 46,116,111, 87,105,
+   110,100,111,119, 69,118,101,110,116, 65,114,103,115, 32, 61,
+    32, 67, 69, 71, 85, 73, 46,116,111, 87,105,110,100,111,119,
+    69,118,101,110,116, 65,114,103,115, 10, 67, 69, 71, 85, 73,
+    46, 69,118,101,110,116, 65,114,103,115, 46,116,111, 65, 99,
+   116,105,118, 97,116,105,111,110, 69,118,101,110,116, 65,114,
+   103,115, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 65, 99,
+   116,105,118, 97,116,105,111,110, 69,118,101,110,116, 65,114,
+   103,115, 10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116, 65,
+   114,103,115, 46,116,111, 72,101, 97,100,101,114, 83,101,113,
+   117,101,110, 99,101, 69,118,101,110,116, 65,114,103,115, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 72,101, 97,100,101,
+   114, 83,101,113,117,101,110, 99,101, 69,118,101,110,116, 65,
+   114,103,115, 10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116,
+    65,114,103,115, 46,116,111, 77,111,117,115,101, 69,118,101,
+   110,116, 65,114,103,115, 32, 61, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 77,111,117,115,101, 69,118,101,110,116, 65,114,103,
+   115, 10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116, 65,114,
+   103,115, 46,116,111, 75,101,121, 69,118,101,110,116, 65,114,
+   103,115, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 75,101,
+   121, 69,118,101,110,116, 65,114,103,115, 10, 67, 69, 71, 85,
+    73, 46, 69,118,101,110,116, 65,114,103,115, 46,116,111, 68,
+   114, 97,103, 68,114,111,112, 69,118,101,110,116, 65,114,103,
+   115, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 68,114, 97,
+   103, 68,114,111,112, 69,118,101,110,116, 65,114,103,115,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 12");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73,
+    46,116,111, 66,117,116,116,111,110, 66, 97,115,101, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    66,117,116,116,111,110, 66, 97,115,101, 34, 41, 10,101,110,
+   100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85,
+    73, 46,116,111, 67,104,101, 99,107, 98,111,120, 40,119, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 67,
+   104,101, 99,107, 98,111,120, 34, 41, 10,101,110,100, 10,102,
+   117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 67,111,109, 98,111, 98,111,120, 40,119, 41, 10,114,101,
+   116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116,
+    40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 67,111,109, 98,
+   111, 98,111,120, 34, 41, 10,101,110,100, 10,102,117,110, 99,
+   116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 67,111,
+   109, 98,111, 68,114,111,112, 76,105,115,116, 40,119, 41, 10,
+   114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,
+   115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 67,111,
+   109, 98,111, 68,114,111,112, 76,105,115,116, 34, 41, 10,101,
+   110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71,
+    85, 73, 46,116,111, 68,114, 97,103, 67,111,110,116, 97,105,
+   110,101,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 68,114, 97,103, 67,111,110,116, 97,105,
+   110,101,114, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,
+   105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 69,100,105,
+   116, 98,111,120, 40,119, 41, 10,114,101,116,117,114,110, 32,
+   116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67,
+    69, 71, 85, 73, 58, 58, 69,100,105,116, 98,111,120, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 70,114, 97,109,101, 87,105,110,
+   100,111,119, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 70,114, 97,109,101, 87,105,110,100,111,
+   119, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 71, 85, 73, 83,104,
+   101,101,116, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 71, 85, 73, 83,104,101,101,116, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 73,116,101,109, 69,110,116,114,
+   121, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,108,
+   117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85,
+    73, 58, 58, 73,116,101,109, 69,110,116,114,121, 34, 41, 10,
+   101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69,
+    71, 85, 73, 46,116,111, 73,116,101,109, 76,105,115,116, 66,
+    97,115,101, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 73,116,101,109, 76,105,115,116, 66, 97,
+   115,101, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 73,116,101,109,
+    76,105,115,116, 98,111,120, 40,119, 41, 10,114,101,116,117,
+   114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119,
+    44, 34, 67, 69, 71, 85, 73, 58, 58, 73,116,101,109, 76,105,
+   115,116, 98,111,120, 34, 41, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 76,
+   105,115,116, 98,111,120, 40,119, 41, 10,114,101,116,117,114,
+   110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44,
+    34, 67, 69, 71, 85, 73, 58, 58, 76,105,115,116, 98,111,120,
+    34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+    32, 67, 69, 71, 85, 73, 46,116,111, 76,105,115,116, 72,101,
+    97,100,101,114, 40,119, 41, 10,114,101,116,117,114,110, 32,
+   116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67,
+    69, 71, 85, 73, 58, 58, 76,105,115,116, 72,101, 97,100,101,
+   114, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 76,105,115,116, 72,
+   101, 97,100,101,114, 83,101,103,109,101,110,116, 40,119, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 76,
+   105,115,116, 72,101, 97,100,101,114, 83,101,103,109,101,110,
+   116, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 77,101,110,117, 98,
+    97,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,
+   108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71,
+    85, 73, 58, 58, 77,101,110,117, 98, 97,114, 34, 41, 10,101,
+   110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71,
+    85, 73, 46,116,111, 77,101,110,117, 66, 97,115,101, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    77,101,110,117, 66, 97,115,101, 34, 41, 10,101,110,100, 10,
+   102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 77,101,110,117, 73,116,101,109, 40,119, 41, 10,114,
+   101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,
+   116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 77,101,110,
+   117, 73,116,101,109, 34, 41, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 77,
+   117,108,116,105, 67,111,108,117,109,110, 76,105,115,116, 40,
+   119, 41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97,
+    46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58,
+    58, 77,117,108,116,105, 67,111,108,117,109,110, 76,105,115,
+   116, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 77,117,108,116,105,
+    76,105,110,101, 69,100,105,116, 98,111,120, 40,119, 41, 10,
+   114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,
+   115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 77,117,
+   108,116,105, 76,105,110,101, 69,100,105,116, 98,111,120, 34,
+    41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+    67, 69, 71, 85, 73, 46,116,111, 80,111,112,117,112, 77,101,
+   110,117, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,
+   108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71,
+    85, 73, 58, 58, 80,111,112,117,112, 77,101,110,117, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 80,114,111,103,114,101,115,115,
+    66, 97,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 80,114,111,103,114,101,115,115, 66, 97,
+   114, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 80,117,115,104, 66,
+   117,116,116,111,110, 40,119, 41, 10,114,101,116,117,114,110,
+    32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34,
+    67, 69, 71, 85, 73, 58, 58, 80,117,115,104, 66,117,116,116,
+   111,110, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 82, 97,100,105,
+   111, 66,117,116,116,111,110, 40,119, 41, 10,114,101,116,117,
+   114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119,
+    44, 34, 67, 69, 71, 85, 73, 58, 58, 82, 97,100,105,111, 66,
+   117,116,116,111,110, 34, 41, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 83,
+    99,114,111,108,108, 97, 98,108,101, 80, 97,110,101, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    83, 99,114,111,108,108, 97, 98,108,101, 80, 97,110,101, 34,
+    41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+    67, 69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108, 98,
+    97,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,
+   108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71,
+    85, 73, 58, 58, 83, 99,114,111,108,108, 98, 97,114, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108,101,100,
+    67,111,110,116, 97,105,110,101,114, 40,119, 41, 10,114,101,
+   116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116,
+    40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 83, 99,114,111,
+   108,108,101,100, 67,111,110,116, 97,105,110,101,114, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108,101,100,
+    73,116,101,109, 76,105,115,116, 66, 97,115,101, 40,119, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 83,
+    99,114,111,108,108,101,100, 73,116,101,109, 76,105,115,116,
+    66, 97,115,101, 34, 41, 10,101,110,100, 10,102,117,110, 99,
+   116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 83,108,
+   105,100,101,114, 40,119, 41, 10,114,101,116,117,114,110, 32,
+   116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67,
+    69, 71, 85, 73, 58, 58, 83,108,105,100,101,114, 34, 41, 10,
+   101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69,
+    71, 85, 73, 46,116,111, 83,112,105,110,110,101,114, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    83,112,105,110,110,101,114, 34, 41, 10,101,110,100, 10,102,
+   117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 84, 97, 98, 66,117,116,116,111,110, 40,119, 41, 10,114,
+   101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,
+   116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84, 97, 98,
+    66,117,116,116,111,110, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    84, 97, 98, 67,111,110,116,114,111,108, 40,119, 41, 10,114,
+   101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,
+   116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84, 97, 98,
+    67,111,110,116,114,111,108, 34, 41, 10,101,110,100, 10,102,
+   117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 84, 97, 98, 80, 97,110,101, 40,119, 41, 10,114,101,116,
+   117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,
+   119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84, 97, 98, 80, 97,
+   110,101, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 84,104,117,109,
+    98, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,108,
+   117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85,
+    73, 58, 58, 84,104,117,109, 98, 34, 41, 10,101,110,100, 10,
+   102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 84,111,111,108,116,105,112, 40,119, 41, 10,114,101,
+   116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116,
+    40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84,111,111,108,
+   116,105,112, 34, 41, 10,101,110,100, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 66,117,116,116,111,
+   110, 66, 97,115,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 66,117,116,116,111,110, 66, 97,115,101, 10, 67, 69, 71,
+    85, 73, 46, 87,105,110,100,111,119, 46,116,111, 67,104,101,
+    99,107, 98,111,120, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 67,104,101, 99,107, 98,111,120, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 67,111,109, 98,111,
+    98,111,120, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 67,
+   111,109, 98,111, 98,111,120, 10, 67, 69, 71, 85, 73, 46, 87,
+   105,110,100,111,119, 46,116,111, 67,111,109, 98,111, 68,114,
+   111,112, 76,105,115,116, 32, 61, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 67,111,109, 98,111, 68,114,111,112, 76,105,115,116,
+    10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,
+   111, 68,114, 97,103, 67,111,110,116, 97,105,110,101,114, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 68,114, 97,103, 67,
+   111,110,116, 97,105,110,101,114, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 69,100,105,116, 98,111,
+   120, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 69,100,105,
+   116, 98,111,120, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,
+   111,119, 46,116,111, 70,114, 97,109,101, 87,105,110,100,111,
+   119, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 70,114, 97,
+   109,101, 87,105,110,100,111,119, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 71, 85, 73, 83,104,101,
+   101,116, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 71, 85,
+    73, 83,104,101,101,116, 10, 67, 69, 71, 85, 73, 46, 87,105,
+   110,100,111,119, 46,116,111, 73,116,101,109, 69,110,116,114,
+   121, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 73,116,101,
+   109, 69,110,116,114,121, 10, 67, 69, 71, 85, 73, 46, 87,105,
+   110,100,111,119, 46,116,111, 73,116,101,109, 76,105,115,116,
+    66, 97,115,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    73,116,101,109, 76,105,115,116, 66, 97,115,101, 10, 67, 69,
+    71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 73,116,
+   101,109, 76,105,115,116, 98,111,120, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 73,116,101,109, 76,105,115,116, 66, 97,
+   115,101, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119,
+    46,116,111, 76,105,115,116, 98,111,120, 32, 61, 32, 67, 69,
+    71, 85, 73, 46,116,111, 76,105,115,116, 98,111,120, 10, 67,
+    69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 76,
+   105,115,116, 72,101, 97,100,101,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 76,105,115,116, 72,101, 97,100,101,114,
+    10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,
+   111, 76,105,115,116, 72,101, 97,100,101,114, 83,101,103,109,
+   101,110,116, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 76,
+   105,115,116, 72,101, 97,100,101,114, 83,101,103,109,101,110,
+   116, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,
+   116,111, 77,101,110,117, 98, 97,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 77,101,110,117, 98, 97,114, 10, 67, 69,
+    71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 77,101,
+   110,117, 66, 97,115,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 77,101,110,117, 66, 97,115,101, 10, 67, 69, 71, 85,
+    73, 46, 87,105,110,100,111,119, 46,116,111, 77,101,110,117,
+    73,116,101,109, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    77,101,110,117, 73,116,101,109, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 77,117,108,116,105, 67,
+   111,108,117,109,110, 76,105,115,116, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 77,117,108,116,105, 67,111,108,117,109,
+   110, 76,105,115,116, 10, 67, 69, 71, 85, 73, 46, 87,105,110,
+   100,111,119, 46,116,111, 77,117,108,116,105, 76,105,110,101,
+    69,100,105,116, 98,111,120, 32, 61, 32, 67, 69, 71, 85, 73,
+    46,116,111, 77,117,108,116,105, 76,105,110,101, 69,100,105,
+   116, 98,111,120, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,
+   111,119, 46,116,111, 80,111,112,117,112, 77,101,110,117, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 80,111,112,117,112,
+    77,101,110,117, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,
+   111,119, 46,116,111, 80,114,111,103,114,101,115,115, 66, 97,
+   114, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 80,114,111,
+   103,114,101,115,115, 66, 97,114, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 80,117,115,104, 66,117,
+   116,116,111,110, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    80,117,115,104, 66,117,116,116,111,110, 10, 67, 69, 71, 85,
+    73, 46, 87,105,110,100,111,119, 46,116,111, 82, 97,100,105,
+   111, 66,117,116,116,111,110, 32, 61, 32, 67, 69, 71, 85, 73,
+    46,116,111, 82, 97,100,105,111, 66,117,116,116,111,110, 10,
+    67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111,
+    83, 99,114,111,108,108, 97, 98,108,101, 80, 97,110,101, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,
+   108, 97, 98,108,101, 80, 97,110,101, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 83, 99,114,111,108,
+   108, 98, 97,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    83, 99,114,111,108,108, 98, 97,114, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 83, 99,114,111,108,
+   108,101,100, 67,111,110,116, 97,105,110,101,114, 32, 61, 32,
+    67, 69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108,101,
+   100, 67,111,110,116, 97,105,110,101,114, 10, 67, 69, 71, 85,
+    73, 46, 87,105,110,100,111,119, 46,116,111, 83, 99,114,111,
+   108,108,101,100, 73,116,101,109, 76,105,115,116, 66, 97,115,
+   101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 83, 99,114,
+   111,108,108,101,100, 73,116,101,109, 76,105,115,116, 66, 97,
+   115,101, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119,
+    46,116,111, 83,108,105,100,101,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 83,108,105,100,101,114, 10, 67, 69, 71,
+    85, 73, 46, 87,105,110,100,111,119, 46,116,111, 83,112,105,
+   110,110,101,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    83,112,105,110,110,101,114, 10, 67, 69, 71, 85, 73, 46, 87,
+   105,110,100,111,119, 46,116,111, 84, 97, 98, 66,117,116,116,
+   111,110, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 84, 97,
+    98, 66,117,116,116,111,110, 10, 67, 69, 71, 85, 73, 46, 87,
+   105,110,100,111,119, 46,116,111, 84, 97, 98, 67,111,110,116,
+   114,111,108, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 84,
+    97, 98, 67,111,110,116,114,111,108, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 84, 97, 98, 80, 97,
+   110,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 84, 97,
+    98, 80, 97,110,101, 10, 67, 69, 71, 85, 73, 46, 87,105,110,
+   100,111,119, 46,116,111, 84,104,117,109, 98, 32, 61, 32, 67,
+    69, 71, 85, 73, 46,116,111, 84,104,117,109, 98, 10, 67, 69,
+    71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 84,111,
+   111,108,116,105,112, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 84,111,111,108,116,105,112,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 13");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  tolua_function(tolua_S,"createListboxTextItem",tolua_CEGUI_CEGUI_createListboxTextItem00);
+  tolua_cclass(tolua_S,"OutStream","CEGUI::OutStream","",NULL);
+  tolua_beginmodule(tolua_S,"OutStream");
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FileStream","CEGUI::FileStream","CEGUI::OutStream",tolua_collect_CEGUI__FileStream);
+  #else
+  tolua_cclass(tolua_S,"FileStream","CEGUI::FileStream","CEGUI::OutStream",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FileStream");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FileStream_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FileStream_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FileStream_new00_local);
+   tolua_function(tolua_S,"is_open",tolua_CEGUI_CEGUI_FileStream_is_open00);
+   tolua_function(tolua_S,"open",tolua_CEGUI_CEGUI_FileStream_open00);
+   tolua_function(tolua_S,"close",tolua_CEGUI_CEGUI_FileStream_close00);
+  tolua_endmodule(tolua_S);
+ tolua_endmodule(tolua_S);
+ tolua_endmodule(tolua_S);
+ return 1;
+}
+
+
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
+ int luaopen_CEGUI (lua_State* tolua_S) {
+ return tolua_CEGUI_open(tolua_S);
+};
+#endif
+
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/required.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/required.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/required.cpp	(revision 2122)
@@ -0,0 +1,88 @@
+/***********************************************************************
+	filename: required.cpp
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+	
+	purpose:  Implementation of helper functions
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#include "CEGUI.h"
+#include "required.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*************************************************************************
+	Functions for getting Thumb range pairs as two return values
+*************************************************************************/
+
+// returns horizontal range as two values for lua
+void ceguiLua_Thumb_getHorzRange(Thumb* wnd, float* min, float* max)
+{
+	std::pair<float,float> range_pair = wnd->getHorzRange();
+	*min = range_pair.first;
+	*max = range_pair.second;
+}
+
+
+// returns vertical range as two values for lua
+void ceguiLua_Thumb_getVertRange(Thumb* wnd, float* min, float* max)
+{
+	std::pair<float,float> range_pair = wnd->getVertRange();
+	*min = range_pair.first;
+	*max = range_pair.second;
+}
+
+
+/*************************************************************************
+	Functions for creating list box items
+*************************************************************************/
+
+// allocates and returns a new ListboxTextItem
+ListboxTextItem* ceguiLua_createListboxTextItem(const String& text, uint item_id, void* item_data, bool disabled, bool auto_delete)
+{
+	return new ListboxTextItem(text,item_id,item_data,disabled,auto_delete);
+}
+
+
+/************************************************************************
+    OutStream
+*************************************************************************/
+void ceguiLua_FileStream_open(FileStream* os, const char* filename)
+{
+    os->open(filename, std::ios::binary);
+}
+
+
+/************************************************************************
+    CEGUI::System::getSystemKeys alternative
+*************************************************************************/
+bool ceguiLua_System_isSystemKeyDown(const System* sys, SystemKey k)
+{
+    return (k & sys->getSystemKeys()) != 0;
+}
+
+
+} // namespace CEGUI
Index: /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/required.h
===================================================================
--- /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/required.h	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.5.0b/ceguilua/required.h	(revision 2122)
@@ -0,0 +1,110 @@
+/***********************************************************************
+	filename: required.h
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+	
+	purpose:  Header that includes the necessary stuff needed for the Lua bindings
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#include "CEGUI.h"
+#include "CEGUILua.h"
+#include "CEGUILuaFunctor.h"
+#include <fstream>
+
+#define __operator_increment    operator++
+#define __operator_decrement    operator--
+#define __operator_dereference  operator*
+
+#define LuaFunctorSubscribeEvent CEGUI::LuaFunctor::SubscribeEvent
+
+#if defined(_MSC_VER) && !defined(snprintf)
+#   define snprintf   _snprintf
+#endif
+
+typedef CEGUI::String string;
+
+namespace CEGUI
+{
+
+typedef Event::Connection EventConnection;
+
+/*************************************************************************
+	Functions for getting Thumb range pairs as two return values
+*************************************************************************/
+void ceguiLua_Thumb_getHorzRange(Thumb* wnd, float* min, float* max);
+void ceguiLua_Thumb_getVertRange(Thumb* wnd, float* min, float* max);
+
+
+/*************************************************************************
+	Functions for creating list box items
+*************************************************************************/
+ListboxTextItem* ceguiLua_createListboxTextItem(const String& text, uint item_id, void* item_data, bool disabled, bool auto_delete);
+
+
+/************************************************************************
+    Stuff needed to make the iterators work
+*************************************************************************/
+typedef PropertySet::Iterator PropertyIterator;
+typedef EventSet::Iterator EventIterator;
+typedef WindowManager::WindowIterator WindowIterator;
+typedef WindowFactoryManager::WindowFactoryIterator WindowFactoryIterator;
+typedef WindowFactoryManager::FalagardMappingIterator FalagardMappingIterator;
+typedef WindowFactoryManager::FalagardWindowMapping FalagardWindowMapping;
+typedef ImagesetManager::ImagesetIterator ImagesetIterator;
+typedef Imageset::ImageIterator ImageIterator;
+typedef SchemeManager::SchemeIterator SchemeIterator;
+typedef FontManager::FontIterator FontIterator;
+
+template <typename T>
+inline PropertyIterator ceguiLua_getPropertyIterator(const T* self)
+{
+    return static_cast<const PropertySet*>(self)->getIterator();
+}
+
+template <typename T>
+inline EventIterator ceguiLua_getEventIterator(const T* self)
+{
+    return static_cast<const EventSet*>(self)->getIterator();
+}
+
+
+/************************************************************************
+    OutStream
+*************************************************************************/
+typedef std::ofstream FileStream;
+void ceguiLua_FileStream_open(FileStream*, const char* filename);
+
+
+/************************************************************************
+    CEGUI::System::getSystemKeys alternative
+*************************************************************************/
+bool ceguiLua_System_isSystemKeyDown(const System* sys, SystemKey k);
+
+}
+
+// the binding file generates alot of
+// warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
+#if defined(_MSC_VER)
+#   pragma warning(disable : 4800)
+#endif
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILua.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILua.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILua.cpp	(revision 2122)
@@ -0,0 +1,320 @@
+/***********************************************************************
+	filename: CEGUILua.cpp
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+
+	purpose:  Implementation for LuaScriptModule class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+
+#include "CEGUI.h"
+#include "CEGUIConfig.h"
+#include "CEGUIPropertyHelper.h"
+#include "CEGUILua.h"
+#include "CEGUILuaFunctor.h"
+#include <vector>
+
+// include Lua libs and tolua++
+#include "lua/lua.hpp"
+#include "tolua/tolua++.h"
+
+// prototype for bindings initialisation function
+int tolua_CEGUI_open(lua_State* tolua_S);
+
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*************************************************************************
+	Constructor (creates Lua state)
+*************************************************************************/
+LuaScriptModule::LuaScriptModule()
+{
+    static const luaL_Reg lualibs[] = {
+        {"", luaopen_base},
+        {LUA_LOADLIBNAME, luaopen_package},
+        {LUA_TABLIBNAME, luaopen_table},
+        {LUA_IOLIBNAME, luaopen_io},
+        {LUA_OSLIBNAME, luaopen_os},
+        {LUA_STRLIBNAME, luaopen_string},
+        {LUA_MATHLIBNAME, luaopen_math},
+    #if defined(DEBUG) || defined (_DEBUG)
+        {LUA_DBLIBNAME, luaopen_debug},
+    #endif
+        {0, 0}
+    };
+
+    // create a lua state
+    d_ownsState = true;
+    d_state = lua_open();
+
+    // init all standard libraries
+    const luaL_Reg *lib = lualibs;
+    for (; lib->func; lib++)
+    {
+        lua_pushcfunction(d_state, lib->func);
+        lua_pushstring(d_state, lib->name);
+        lua_call(d_state, 1, 0);
+    }
+
+    setModuleIdentifierString();
+}
+
+
+/*************************************************************************
+	Constructor (uses given Lua state)
+*************************************************************************/
+LuaScriptModule::LuaScriptModule(lua_State* state)
+{
+	// just use the given state
+	d_ownsState = false;
+	d_state = state;
+
+	setModuleIdentifierString();
+}
+
+
+/*************************************************************************
+	Destructor
+*************************************************************************/
+LuaScriptModule::~LuaScriptModule()
+{
+	if ( d_ownsState && d_state )
+	{
+		lua_close( d_state );
+	}
+}
+
+
+/*************************************************************************
+	Execute script file
+*************************************************************************/
+void LuaScriptModule::executeScriptFile(const String& filename, const String& resourceGroup)
+{
+	// load file
+	RawDataContainer raw;
+	System::getSingleton().getResourceProvider()->loadRawDataContainer(filename,
+        raw, resourceGroup.empty() ? d_defaultResourceGroup : resourceGroup);
+
+	// load code into lua
+	int top = lua_gettop(d_state);
+	int loaderr = luaL_loadbuffer(d_state, (char*)raw.getDataPtr(), raw.getSize(), filename.c_str());
+	System::getSingleton().getResourceProvider()->unloadRawDataContainer( raw );
+	if (loaderr)
+	{
+	    String errMsg = lua_tostring(d_state,-1);
+		lua_settop(d_state,top);
+		throw ScriptException("Unable to execute Lua script file: '"+filename+"'\n\n"+errMsg+"\n");
+	}
+
+    // call it
+	if (lua_pcall(d_state,0,0,0))
+	{
+	    String errMsg = lua_tostring(d_state,-1);
+		lua_settop(d_state,top);
+		throw ScriptException("Unable to execute Lua script file: '"+filename+"'\n\n"+errMsg+"\n");
+	}
+
+	lua_settop(d_state,top); // just in case :P
+}
+
+
+/*************************************************************************
+	Execute global script function
+*************************************************************************/
+int	LuaScriptModule::executeScriptGlobal(const String& function_name)
+{
+    int top = lua_gettop(d_state);
+
+    // get the function from lua
+    lua_getglobal(d_state, function_name.c_str());
+
+    // is it a function
+    if (!lua_isfunction(d_state,-1))
+    {
+        lua_settop(d_state,top);
+        throw ScriptException("Unable to get Lua global: '"+function_name+"' as name not represent a global Lua function" );
+    }
+
+    // call it
+    int error = lua_pcall(d_state,0,1,0);
+
+    // handle errors
+    if (error)
+    {
+        String errMsg = lua_tostring(d_state,-1);
+        lua_pop(d_state,1);
+        throw ScriptException("Unable to evaluate Lua global: '"+function_name+"\n\n"+errMsg+"\n");
+    }
+
+    // get return value
+    if (!lua_isnumber(d_state,-1))
+    {
+        // log that return value is invalid. return -1 and move on.
+        lua_settop(d_state,top);
+        ScriptException("Unable to get Lua global : '"+function_name+"' return value as it's not a number" );
+        return -1;
+    }
+
+    int ret = (int)lua_tonumber(d_state,-1);
+    lua_pop(d_state,1);
+
+    // return it
+    return ret;
+}
+
+
+/*************************************************************************
+	Execute scripted event handler
+*************************************************************************/
+bool LuaScriptModule::executeScriptedEventHandler(const String& handler_name, const EventArgs& e)
+{
+
+	LuaFunctor::pushNamedFunction(d_state, handler_name);
+
+	ScriptWindowHelper* helper = 0;
+	//If this is an event that was triggered by a window then make a "this" pointer to the window for the script.
+	if(e.d_hasWindow)
+	{
+		WindowEventArgs& we = (WindowEventArgs&)e;
+		helper = new ScriptWindowHelper(we.window);
+		lua_pushlightuserdata(d_state,(void*)helper);
+		lua_setglobal(d_state,"this");
+	} // if(e.d_hasWindow)
+
+    // push EventArgs as the first parameter
+    tolua_pushusertype(d_state,(void*)&e,"const CEGUI::EventArgs");
+
+    // call it
+    int error = lua_pcall(d_state,1,0,0);
+
+    // handle errors
+    if (error)
+    {
+        String errStr(lua_tostring(d_state,-1));
+        lua_pop(d_state,1);
+		//cleanup the helper object if any
+		if(helper)
+		{
+			delete helper;
+			helper = 0;
+		}
+        throw ScriptException("Unable to evaluate the Lua event handler: '"+handler_name+"'\n\n"+errStr+"\n");
+    } // if (error)
+
+	if(helper)
+	{
+		delete helper;
+		helper = 0;
+	}
+
+    return true;
+}
+
+
+/*************************************************************************
+	Execute script code string
+*************************************************************************/
+void LuaScriptModule::executeString(const String& str)
+{
+    int top = lua_gettop(d_state);
+
+    // load code into lua and call it
+    int error =	luaL_loadbuffer(d_state, str.c_str(), str.length(), str.c_str()) || lua_pcall(d_state,0,0,0);
+
+    // handle errors
+    if (error)
+    {
+        String errMsg = lua_tostring(d_state,-1);
+        lua_settop(d_state,top);
+        throw ScriptException("Unable to execute Lua script string: '"+str+"'\n\n"+errMsg+"\n");
+    }
+}
+
+
+/*************************************************************************
+	Create Lua bindings
+*************************************************************************/
+void LuaScriptModule::createBindings(void)
+{
+	CEGUI::Logger::getSingleton().logEvent( "---- Creating Lua bindings ----" );
+	// init CEGUI module
+	tolua_CEGUI_open(d_state);
+}
+
+
+/*************************************************************************
+	Destroy Lua bindings
+*************************************************************************/
+void LuaScriptModule::destroyBindings(void)
+{
+	CEGUI::Logger::getSingleton().logEvent( "---- Destroying Lua bindings ----" );
+	// is this ok ?
+	lua_pushnil(d_state);
+	lua_setglobal(d_state,"CEGUI");
+}
+
+
+/*************************************************************************
+	Set the ID string for the module
+*************************************************************************/
+void LuaScriptModule::setModuleIdentifierString()
+{
+    // set ID string
+    d_identifierString = "CEGUI::LuaScriptModule - Official Lua based scripting module for CEGUI";
+	d_language = "Lua";
+}
+
+
+/*************************************************************************
+	Subscribe to a scripted event handler
+*************************************************************************/
+Event::Connection LuaScriptModule::subscribeEvent(EventSet* target, const String& event_name, const String& subscriber_name)
+{
+    // do the real subscription
+    LuaFunctor functor(d_state,subscriber_name,LUA_NOREF);
+    Event::Connection con = target->subscribeEvent(event_name, Event::Subscriber(functor));
+    // make sure we don't release the reference we just made when this call returns
+    functor.index = LUA_NOREF;
+
+    // return the event connection
+    return con;
+}
+
+
+/*************************************************************************
+	Subscribe to a scripted event handler
+*************************************************************************/
+Event::Connection LuaScriptModule::subscribeEvent(EventSet* target, const String& event_name, Event::Group group, const String& subscriber_name)
+{
+    // do the real subscription
+    LuaFunctor functor(d_state,subscriber_name,LUA_NOREF);
+    Event::Connection con = target->subscribeEvent(event_name, group, Event::Subscriber(functor));
+
+    // return the event connection
+    return con;
+}
+
+} // namespace CEGUI
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILua.h
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILua.h	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILua.h	(revision 2122)
@@ -0,0 +1,253 @@
+/***********************************************************************
+	filename: CEGUILua.h
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+	
+	purpose:  Defines interface for LuaScriptModule class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#ifndef _CEGUILua_h_
+#define _CEGUILua_h_
+
+/*** CHANGES BY ORXONOX TEAM FOR MINGW32 ***/
+/*************************************************************************
+	Import / Export control macros
+*************************************************************************/
+#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
+#   ifdef CEGUILUA_EXPORTS
+#       define CEGUILUA_API __declspec(dllexport)
+#   else
+#      if defined( __MINGW32__ )
+#          define CEGUILUA_API
+#      else
+#          define CEGUILUA_API __declspec(dllimport)
+#      endif
+#   endif
+#else
+#   define CEGUILUA_API
+#endif
+
+
+#include "CEGUIScriptModule.h"
+
+struct lua_State;
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*!
+\brief
+	Interface for the LuaScriptModule class
+*/
+class CEGUILUA_API LuaScriptModule : public CEGUI::ScriptModule
+{
+public:
+	/*************************************************************************
+		Construction and Destruction
+	*************************************************************************/
+	/*!
+	\brief
+		Constructor for LuaScriptModule class which create a lua_State
+	*/
+	LuaScriptModule();
+
+
+	/*!
+	\brief
+		Constructor for LuaScriptModule class which takes a lua_State
+
+	\param state
+		Pointer to the lua_State that the script module should attach to.
+	*/
+	LuaScriptModule(lua_State* state);
+
+
+	/*!
+	\brief
+		Destructor for LuaScriptModule class.
+	*/
+	~LuaScriptModule();
+
+
+	/*************************************************************************
+		Script Execution Functions
+	*************************************************************************/
+	/*!
+	\brief
+		Execute a script file.
+
+	\param filename
+		String object holding the filename of the script file that is to be executed
+		
+	\param resourceGroup
+		Resource group idendifier to be passed to the ResourceProvider when loading the script file.
+	*/
+	void executeScriptFile(const String& filename, const String& resourceGroup);
+
+
+	/*!
+	\brief
+		Execute a scripted global function.  The function should not take any parameters and should return an integer.
+
+	\param function_name
+		String object holding the name of the function, in the global script environment, that
+		is to be executed.
+
+	\return
+		The integer value returned from the script function.
+	*/
+	int executeScriptGlobal(const String& function_name);
+
+
+    /*!
+    \brief
+        Execute a scripted global 'event handler' function by looking it up by name.
+
+    \param handler_name
+        String object holding the name of the scripted handler function.
+        If this string contains dots '.' it will be parsed as tables containing a function field.
+        For example: 'mytable.subtable.func'
+
+    \param e
+        EventArgs based object that should be passed, by any appropriate means, to the scripted function.
+
+    \return
+        - true if the event was handled.
+        - false if the event was not handled.
+    */
+    bool executeScriptedEventHandler(const String& handler_name, const EventArgs& e);
+
+
+    /*!
+    \brief
+        Execute script code contained in the given CEGUI::String object.
+
+    \param str
+        String object holding the valid script code that should be executed.
+
+    \return
+        Nothing.
+    */
+    void executeString(const String& str);
+
+    /*************************************************************************
+        Event subscription
+    *************************************************************************/
+    /*!
+    \brief
+            Subscribes the named Event to a scripted funtion
+
+    \param target
+            The target EventSet for the subscription.
+
+    \param name
+            String object containing the name of the Event to subscribe to.
+
+    \param subscriber_name
+            String object containing the name of the script funtion that is to be subscribed to the Event.
+
+    \return
+            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
+
+    \exception UnknownObjectException	Thrown if an Event named \a name is not in the EventSet
+    */
+    Event::Connection	subscribeEvent(EventSet* target, const String& name, const String& subscriber_name);
+
+    /*!
+    \brief
+            Subscribes the specified group of the named Event to a scripted funtion.
+
+    \param target
+            The target EventSet for the subscription.
+
+    \param name
+            String object containing the name of the Event to subscribe to.
+
+    \param group
+            Group which is to be subscribed to.  Subscription groups are called in ascending order.
+
+    \param subscriber_name
+            String object containing the name of the script funtion that is to be subscribed to the Event.
+
+    \return
+            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
+
+    \exception UnknownObjectException	Thrown if an Event named \a name is not in the EventSet
+    */
+    Event::Connection	subscribeEvent(EventSet* target, const String& name, Event::Group group, const String& subscriber_name);
+
+    /*************************************************************************
+        Bindings creation / destruction
+    *************************************************************************/
+    /*!
+    \brief
+        Method called during system initialisation, prior to running any scripts via the ScriptModule, to enable the ScriptModule
+        to perform any operations required to complete initialisation or binding of the script language to the gui system objects.
+
+    \return
+        Nothing.
+    */
+    void createBindings(void);
+
+
+    /*!
+    \brief
+        Method called during system destruction, after all scripts have been run via the ScriptModule, to enable the ScriptModule
+        to perform any operations required to cleanup bindings of the script language to the gui system objects, as set-up in the
+        earlier createBindings call.
+
+    \return
+        Nothing.
+    */
+    void destroyBindings(void);
+
+    /*************************************************************************
+        Accessor type functions
+    *************************************************************************/
+    /*!
+    \brief
+        Method used to get a pointer to the lua_State that the script module is attached to.
+
+    \return
+        A pointer to the lua_State that the script module is attached to.
+    */
+    lua_State* getLuaState(void) const {return d_state;}
+
+private:
+    /*************************************************************************
+        Implementation Functions
+    *************************************************************************/
+    void setModuleIdentifierString();
+
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    bool d_ownsState;      //!< true when the attached lua_State was created by this script module
+    lua_State* d_state;    //!< The lua_State that this script module uses.
+};
+
+} // namespace CEGUI
+
+#endif // end of guard _CEGUILua_h_
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILuaFunctor.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILuaFunctor.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILuaFunctor.cpp	(revision 2122)
@@ -0,0 +1,275 @@
+/***********************************************************************
+    filename: CEGUILuaFunctor.cpp
+    created:  Thu Jan 26 2006
+    author:   Tomas Lindquist Olsen <tomas@famolsen.dk>
+
+    purpose:  Implementation for LuaFunctor class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#include "CEGUILuaFunctor.h"
+#include "CEGUILogger.h"
+#include "CEGUIExceptions.h"
+#include "CEGUIPropertyHelper.h"
+
+// include Lua libs and tolua++
+#include "lua/lua.hpp"
+#include "tolua/tolua++.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+LuaFunctor::LuaFunctor(lua_State* state, int func, int selfIndex) :
+    L(state),
+    index(func),
+    self(selfIndex),
+    needs_lookup(false)
+{
+}
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+LuaFunctor::LuaFunctor(lua_State* state, const String& func, int selfIndex) :
+    L(state),
+    index(LUA_NOREF),
+    self(selfIndex),
+    needs_lookup(true),
+    function_name(func)
+{
+}
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+LuaFunctor::LuaFunctor(const LuaFunctor& cp) :
+    L(cp.L),
+    index(cp.index),
+    self(cp.self),
+    needs_lookup(cp.needs_lookup),
+    function_name(cp.function_name)
+{
+}
+
+/*************************************************************************
+    Destructor
+*************************************************************************/
+LuaFunctor::~LuaFunctor()
+{
+    if (self!=LUA_NOREF)
+    {
+        luaL_unref(L, LUA_REGISTRYINDEX, self);
+    }
+    if (index!=LUA_NOREF)
+    {
+        luaL_unref(L, LUA_REGISTRYINDEX, index);
+    }
+}
+
+/*************************************************************************
+    Call operator
+*************************************************************************/
+bool LuaFunctor::operator()(const EventArgs& args) const
+{
+    // is this a late binding?
+    if (needs_lookup)
+    {
+        pushNamedFunction(L, function_name);
+        // reference function
+        index = luaL_ref(L, LUA_REGISTRYINDEX);
+        needs_lookup = false;
+        CEGUI_LOGINSANE("Late binding of callback '"+function_name+"' performed");
+        function_name.clear();
+    } // if (needs_lookup)
+
+	ScriptWindowHelper* helper = 0;
+	//Set a global for this window
+	if(args.d_hasWindow)
+	{
+		WindowEventArgs& we = (WindowEventArgs&)args;
+		helper = new ScriptWindowHelper(we.window);
+		tolua_pushusertype(L,(void*)helper,"CEGUI::ScriptWindowHelper");
+		lua_setglobal(L,"this");
+	}
+
+    // retrieve function
+    lua_rawgeti(L, LUA_REGISTRYINDEX, index);
+
+    // possibly self as well?
+    int nargs = 1;
+    if (self != LUA_NOREF)
+    {
+        lua_rawgeti(L, LUA_REGISTRYINDEX, self);
+        ++nargs;
+    }
+
+    // push EventArgs  parameter
+    tolua_pushusertype(L, (void*)&args, "const CEGUI::EventArgs");
+
+    // call it
+    int error = lua_pcall(L, nargs, 0, 0);
+
+    // handle errors
+    if (error)
+    {
+        String errStr(lua_tostring(L, -1));
+        lua_pop(L, 1);
+		if(helper)
+		{
+			delete helper;
+			helper = 0;
+		}
+        throw ScriptException("Unable to call Lua event handler:\n\n"+errStr+"\n");
+    } // if (error)
+
+	if(helper)
+	{
+		delete helper;
+		helper = 0;
+	}
+
+    return true;
+}
+
+/*************************************************************************
+    do event subscription by reference instead of by name
+*************************************************************************/
+Event::Connection LuaFunctor::SubscribeEvent(EventSet* self, const String& event_name, int funcIndex, int selfIndex, lua_State* L)
+{
+    // should we pass a self to the callback?
+    int thisIndex = LUA_NOREF;
+    if (selfIndex != LUA_NOREF)
+    {
+        // reference self
+        thisIndex = luaL_ref(L, LUA_REGISTRYINDEX);
+    }
+
+    // do the real subscription
+    int type = lua_type(L,-1);
+    Event::Connection con;
+    if (type == LUA_TFUNCTION)
+    {
+        // reference function
+        int index = luaL_ref(L, LUA_REGISTRYINDEX);
+        LuaFunctor functor(L,index,thisIndex);
+        con = self->subscribeEvent(String(event_name), Event::Subscriber(functor));
+        // make sure we don't release the reference(s) we just made when this call returns
+        functor.index = LUA_NOREF;
+        functor.self = LUA_NOREF;
+    }
+    else if (type == LUA_TSTRING)
+    {
+        const char* str = lua_tostring(L, -1);
+        LuaFunctor functor(L,String(str),thisIndex);
+        con = self->subscribeEvent(String(event_name), Event::Subscriber(functor));
+        // make sure we don't release the reference we just (maybe) made when this call returns
+        functor.self = LUA_NOREF;
+    }
+    else
+    {
+        luaL_error(L,"bad function passed to subscribe function. must be a real function, or a string for late binding");
+    }
+
+    // return the event connection
+    return con;
+}
+
+/*************************************************************************
+    Pushes a named function on the stack
+*************************************************************************/
+void LuaFunctor::pushNamedFunction(lua_State* L, const String& handler_name)
+{
+    int top = lua_gettop(L);
+
+    // do we have any dots in the handler name? if so we grab the function as a table field
+    String::size_type i = handler_name.find_first_of((utf32)'.');
+    if (i!=String::npos)
+    {
+        // split the rest of the string up in parts seperated by '.'
+        // TODO: count the dots and size the vector accordingly from the beginning.
+        std::vector<String> parts;
+        String::size_type start = 0;
+        do
+        {
+            parts.push_back(handler_name.substr(start,i-start));
+            start = i+1;
+            i = handler_name.find_first_of((utf32)'.',start);
+        } while(i!=String::npos);
+
+        // add last part
+        parts.push_back(handler_name.substr(start));
+
+        // first part is the global
+        lua_getglobal(L, parts[0].c_str());
+        if (!lua_istable(L,-1))
+        {
+            lua_settop(L,top);
+            throw ScriptException("Unable to get the Lua event handler: '"+handler_name+"' as first part is not a table");
+        }
+
+        // if there is more than two parts, we have more tables to go through
+        std::vector<String>::size_type visz = parts.size();
+        if (visz-- > 2) // avoid subtracting one later on
+        {
+            // go through all the remaining parts to (hopefully) have a valid Lua function in the end
+            std::vector<String>::size_type vi = 1;
+            while (vi<visz)
+            {
+                // push key, and get the next table
+                lua_pushstring(L,parts[vi].c_str());
+                lua_gettable(L,-2);
+                if (!lua_istable(L,-1))
+                {
+                    lua_settop(L,top);
+                    throw ScriptException("Unable to get the Lua event handler: '"+handler_name+"' as part #"+PropertyHelper::uintToString(uint(vi+1))+" ("+parts[vi]+") is not a table");
+                }
+                // get rid of the last table and move on
+                lua_remove(L,-2);
+                vi++;
+            }
+        }
+
+        // now we are ready to get the function to call ... phew :)
+        lua_pushstring(L,parts[visz].c_str());
+        lua_gettable(L,-2);
+        lua_remove(L,-2); // get rid of the table
+    }
+    // just a regular global function
+    else
+    {
+        lua_getglobal(L, handler_name.c_str());
+    }
+
+    // is it a function
+    if (!lua_isfunction(L,-1))
+    {
+        lua_settop(L,top);
+        throw ScriptException("The Lua event handler: '"+handler_name+"' does not represent a Lua function");
+    }
+}
+
+} // namespace CEGUI
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILuaFunctor.h
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILuaFunctor.h	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CEGUILuaFunctor.h	(revision 2122)
@@ -0,0 +1,86 @@
+/***********************************************************************
+    filename: CEGUILuaFunctor.h
+    created:  Thu Jan 26 2006
+    author:   Tomas Lindquist Olsen <tomas@famolsen.dk>
+
+    purpose:  Defines interface for LuaFunctor class
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#ifndef _CEGUILuaFunctor_h_
+#define _CEGUILuaFunctor_h_
+
+#include "CEGUIEventSet.h"
+#include "CEGUIScriptWindowHelper.h"
+
+struct lua_State;
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+// forward declaration
+class LuaScriptModule;
+
+/*!
+\brief
+    Functor class used for subscribing Lua functions to CEGUI events
+*/
+class LuaFunctor
+{
+public:
+    LuaFunctor(lua_State* state, int func, int selfIndex);
+    LuaFunctor(lua_State* state, const String& func, int selfIndex);
+    LuaFunctor(const LuaFunctor& cp);
+    ~LuaFunctor();
+
+    bool operator()(const EventArgs& args) const;
+
+    /*!
+    \brief
+        function used to subscribe any Lua function as event handler.
+        References using the Lua registry.
+        To be called from Lua only.
+    */
+    static Event::Connection SubscribeEvent(EventSet* self, const String& eventName, int funcIndex, int selfIndex, lua_State* L);
+
+    /*!
+    \brief
+        Pushes the Lua function named \param name on top of the Lua stack.
+        The name may contain '.' (dots) character for (nested) table values.
+    */
+    static void pushNamedFunction(lua_State* L, const String& name);
+
+private:
+    lua_State* L;
+    mutable int index;
+    int self;
+    mutable bool needs_lookup;
+    mutable String function_name;
+
+    friend class LuaScriptModule;
+};
+
+} // namespace CEGUI
+
+#endif // end of guard _CEGUILuaFunctor_h_
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,16 @@
+INCLUDE_DIRECTORIES(.)
+
+SET( CEGUILUA_SRC_FILES
+  CEGUILua.cpp
+  CEGUILuaFunctor.cpp
+  lua_CEGUI.cpp
+  required.cpp
+)
+
+ADD_LIBRARY( ceguilua_orxonox SHARED ${CEGUILUA_SRC_FILES} )
+
+TARGET_LINK_LIBRARIES(ceguilua_orxonox
+  lua_orxonox
+  tolualib_orxonox
+  ${CEGUI_LIBRARIES}
+)
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/lua_CEGUI.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/lua_CEGUI.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/lua_CEGUI.cpp	(revision 2122)
@@ -0,0 +1,51921 @@
+/*
+** Lua binding: CEGUI
+** Generated automatically by tolua++-1.0.92 on Mon Jun 23 14:42:20 2008.
+*/
+
+#ifndef __cplusplus
+#include "stdlib.h"
+#endif
+#include "string.h"
+
+#include "tolua/tolua++.h"
+
+/* Exported function */
+int tolua_CEGUI_open (lua_State* tolua_S);
+
+#include "required.h"
+#include "CEGUIPropertyHelper.h"
+
+/* function to release collected object via destructor */
+#ifdef __cplusplus
+
+static int tolua_collect_CEGUI__Image (lua_State* tolua_S)
+{
+ CEGUI::Image* self = (CEGUI::Image*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__SchemeIterator (lua_State* tolua_S)
+{
+ CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetDim (lua_State* tolua_S)
+{
+ CEGUI::WidgetDim* self = (CEGUI::WidgetDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FalagardWindowMapping (lua_State* tolua_S)
+{
+ CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__MouseEventArgs (lua_State* tolua_S)
+{
+ CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImageIterator (lua_State* tolua_S)
+{
+ CEGUI::ImageIterator* self = (CEGUI::ImageIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImagesetIterator (lua_State* tolua_S)
+{
+ CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Dimension (lua_State* tolua_S)
+{
+ CEGUI::Dimension* self = (CEGUI::Dimension*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetLookFeel (lua_State* tolua_S)
+{
+ CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__DragDropEventArgs (lua_State* tolua_S)
+{
+ CEGUI::DragDropEventArgs* self = (CEGUI::DragDropEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetLookManager (lua_State* tolua_S)
+{
+ CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FileStream (lua_State* tolua_S)
+{
+ CEGUI::FileStream* self = (CEGUI::FileStream*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__MCLGridRef (lua_State* tolua_S)
+{
+ CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_size_t (lua_State* tolua_S)
+{
+ size_t* self = (size_t*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ColourRect (lua_State* tolua_S)
+{
+ CEGUI::ColourRect* self = (CEGUI::ColourRect*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__SectionSpecification (lua_State* tolua_S)
+{
+ CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__LayerSpecification (lua_State* tolua_S)
+{
+ CEGUI::LayerSpecification* self = (CEGUI::LayerSpecification*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__StateImagery (lua_State* tolua_S)
+{
+ CEGUI::StateImagery* self = (CEGUI::StateImagery*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__EventConnection (lua_State* tolua_S)
+{
+ CEGUI::EventConnection* self = (CEGUI::EventConnection*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImagerySection (lua_State* tolua_S)
+{
+ CEGUI::ImagerySection* self = (CEGUI::ImagerySection*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__TextComponent (lua_State* tolua_S)
+{
+ CEGUI::TextComponent* self = (CEGUI::TextComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Vector2 (lua_State* tolua_S)
+{
+ CEGUI::Vector2* self = (CEGUI::Vector2*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__String (lua_State* tolua_S)
+{
+ CEGUI::String* self = (CEGUI::String*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__NamedArea (lua_State* tolua_S)
+{
+ CEGUI::NamedArea* self = (CEGUI::NamedArea*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImageDim (lua_State* tolua_S)
+{
+ CEGUI::ImageDim* self = (CEGUI::ImageDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FrameComponent (lua_State* tolua_S)
+{
+ CEGUI::FrameComponent* self = (CEGUI::FrameComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WindowEventArgs (lua_State* tolua_S)
+{
+ CEGUI::WindowEventArgs* self = (CEGUI::WindowEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WindowIterator (lua_State* tolua_S)
+{
+ CEGUI::WindowIterator* self = (CEGUI::WindowIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WindowFactoryIterator (lua_State* tolua_S)
+{
+ CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Size (lua_State* tolua_S)
+{
+ CEGUI::Size* self = (CEGUI::Size*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FontIterator (lua_State* tolua_S)
+{
+ CEGUI::FontIterator* self = (CEGUI::FontIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ActivationEventArgs (lua_State* tolua_S)
+{
+ CEGUI::ActivationEventArgs* self = (CEGUI::ActivationEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyLinkDefinition (lua_State* tolua_S)
+{
+ CEGUI::PropertyLinkDefinition* self = (CEGUI::PropertyLinkDefinition*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyInitialiser (lua_State* tolua_S)
+{
+ CEGUI::PropertyInitialiser* self = (CEGUI::PropertyInitialiser*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FalagardMappingIterator (lua_State* tolua_S)
+{
+ CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__EventArgs (lua_State* tolua_S)
+{
+ CEGUI::EventArgs* self = (CEGUI::EventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyDefinition (lua_State* tolua_S)
+{
+ CEGUI::PropertyDefinition* self = (CEGUI::PropertyDefinition*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__UVector2 (lua_State* tolua_S)
+{
+ CEGUI::UVector2* self = (CEGUI::UVector2*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ComponentArea (lua_State* tolua_S)
+{
+ CEGUI::ComponentArea* self = (CEGUI::ComponentArea*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyIterator (lua_State* tolua_S)
+{
+ CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__AbsoluteDim (lua_State* tolua_S)
+{
+ CEGUI::AbsoluteDim* self = (CEGUI::AbsoluteDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__HeaderSequenceEventArgs (lua_State* tolua_S)
+{
+ CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__PropertyDim (lua_State* tolua_S)
+{
+ CEGUI::PropertyDim* self = (CEGUI::PropertyDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__FontDim (lua_State* tolua_S)
+{
+ CEGUI::FontDim* self = (CEGUI::FontDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__URect (lua_State* tolua_S)
+{
+ CEGUI::URect* self = (CEGUI::URect*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__UnifiedDim (lua_State* tolua_S)
+{
+ CEGUI::UnifiedDim* self = (CEGUI::UnifiedDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__ImageryComponent (lua_State* tolua_S)
+{
+ CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__WidgetComponent (lua_State* tolua_S)
+{
+ CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__KeyEventArgs (lua_State* tolua_S)
+{
+ CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__UDim (lua_State* tolua_S)
+{
+ CEGUI::UDim* self = (CEGUI::UDim*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__EventIterator (lua_State* tolua_S)
+{
+ CEGUI::EventIterator* self = (CEGUI::EventIterator*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__colour (lua_State* tolua_S)
+{
+ CEGUI::colour* self = (CEGUI::colour*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__MouseCursorEventArgs (lua_State* tolua_S)
+{
+ CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+
+static int tolua_collect_CEGUI__Rect (lua_State* tolua_S)
+{
+ CEGUI::Rect* self = (CEGUI::Rect*) tolua_tousertype(tolua_S,1,0);
+ delete self;
+ return 0;
+}
+#endif
+
+
+/* function to register type */
+static void tolua_reg_types (lua_State* tolua_S)
+{
+ tolua_usertype(tolua_S,"CEGUI::Logger");
+ tolua_usertype(tolua_S,"CEGUI::Image");
+ tolua_usertype(tolua_S,"CEGUI::MenuBase");
+ tolua_usertype(tolua_S,"CEGUI::Renderer");
+ tolua_usertype(tolua_S,"CEGUI::SchemeIterator");
+ tolua_usertype(tolua_S,"CEGUI::FalagardComponentBase");
+ tolua_usertype(tolua_S,"CEGUI::Scrollbar");
+ tolua_usertype(tolua_S,"CEGUI::MouseEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::ImageIterator");
+ tolua_usertype(tolua_S,"CEGUI::ImagesetIterator");
+ tolua_usertype(tolua_S,"CEGUI::ItemListBase");
+ tolua_usertype(tolua_S,"CEGUI::Dimension");
+ tolua_usertype(tolua_S,"CEGUI::WindowFactory");
+ tolua_usertype(tolua_S,"CEGUI::MouseCursor");
+ tolua_usertype(tolua_S,"CEGUI::ItemListbox");
+ tolua_usertype(tolua_S,"CEGUI::ComboDropList");
+ tolua_usertype(tolua_S,"CEGUI::FrameWindow");
+ tolua_usertype(tolua_S,"size_t");
+ tolua_usertype(tolua_S,"CEGUI::ButtonBase");
+ tolua_usertype(tolua_S,"CEGUI::EventConnection");
+ tolua_usertype(tolua_S,"CEGUI::ListboxItem");
+ tolua_usertype(tolua_S,"CEGUI::Imageset");
+ tolua_usertype(tolua_S,"CEGUI::Property");
+ tolua_usertype(tolua_S,"CEGUI::WidgetLookFeel");
+ tolua_usertype(tolua_S,"CEGUI::OutStream");
+ tolua_usertype(tolua_S,"CEGUI::WidgetLookManager");
+ tolua_usertype(tolua_S,"CEGUI::GroupBox");
+ tolua_usertype(tolua_S,"CEGUI::EventIterator");
+ tolua_usertype(tolua_S,"CEGUI::FileStream");
+ tolua_usertype(tolua_S,"CEGUI::WindowFactoryIterator");
+ tolua_usertype(tolua_S,"CEGUI::PropertyDim");
+ tolua_usertype(tolua_S,"CEGUI::PropertyHelper");
+ tolua_usertype(tolua_S,"CEGUI::RadioButton");
+ tolua_usertype(tolua_S,"CEGUI::LayerSpecification");
+ tolua_usertype(tolua_S,"CEGUI::SectionSpecification");
+ tolua_usertype(tolua_S,"CEGUI::ProgressBar");
+ tolua_usertype(tolua_S,"CEGUI::ImagerySection");
+ tolua_usertype(tolua_S,"CEGUI::TextComponent");
+ tolua_usertype(tolua_S,"CEGUI::UVector2");
+ tolua_usertype(tolua_S,"CEGUI::ComponentArea");
+ tolua_usertype(tolua_S,"CEGUI::FrameComponent");
+ tolua_usertype(tolua_S,"CEGUI::Spinner");
+ tolua_usertype(tolua_S,"CEGUI::PropertyLinkDefinition");
+ tolua_usertype(tolua_S,"CEGUI::PropertyInitialiser");
+ tolua_usertype(tolua_S,"CEGUI::PropertyDefinition");
+ tolua_usertype(tolua_S,"CEGUI::PropertyDefinitionBase");
+ tolua_usertype(tolua_S,"CEGUI::TreeItem");
+ tolua_usertype(tolua_S,"CEGUI::ImageryComponent");
+ tolua_usertype(tolua_S,"CEGUI::WidgetComponent");
+ tolua_usertype(tolua_S,"CEGUI::KeyEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::FontManager");
+ tolua_usertype(tolua_S,"CEGUI::ScriptWindowHelper");
+ tolua_usertype(tolua_S,"CEGUI::ImagesetManager");
+ tolua_usertype(tolua_S,"CEGUI::FontDim");
+ tolua_usertype(tolua_S,"CEGUI::GlobalEventSet");
+ tolua_usertype(tolua_S,"CEGUI::UnifiedDim");
+ tolua_usertype(tolua_S,"CEGUI::WidgetDim");
+ tolua_usertype(tolua_S,"CEGUI::ImageDim");
+ tolua_usertype(tolua_S,"CEGUI::Thumb");
+ tolua_usertype(tolua_S,"CEGUI::BaseDim");
+ tolua_usertype(tolua_S,"CEGUI::MultiLineEditbox");
+ tolua_usertype(tolua_S,"CEGUI::ScrolledItemListBase");
+ tolua_usertype(tolua_S,"CEGUI::MenuItem");
+ tolua_usertype(tolua_S,"CEGUI::FalagardWindowMapping");
+ tolua_usertype(tolua_S,"CEGUI::WindowManager");
+ tolua_usertype(tolua_S,"CEGUI::PopupMenu");
+ tolua_usertype(tolua_S,"CEGUI::Checkbox");
+ tolua_usertype(tolua_S,"CEGUI::ListHeader");
+ tolua_usertype(tolua_S,"CEGUI::Tooltip");
+ tolua_usertype(tolua_S,"CEGUI::ScrolledContainer");
+ tolua_usertype(tolua_S,"CEGUI::PushButton");
+ tolua_usertype(tolua_S,"CEGUI::ItemEntry");
+ tolua_usertype(tolua_S,"CEGUI::MultiColumnList");
+ tolua_usertype(tolua_S,"CEGUI::MCLGridRef");
+ tolua_usertype(tolua_S,"CEGUI::ListHeaderSegment");
+ tolua_usertype(tolua_S,"CEGUI::Listbox");
+ tolua_usertype(tolua_S,"CEGUI::Combobox");
+ tolua_usertype(tolua_S,"CEGUI::DragContainer");
+ tolua_usertype(tolua_S,"CEGUI::Editbox");
+ tolua_usertype(tolua_S,"CEGUI::ColourRect");
+ tolua_usertype(tolua_S,"CEGUI::Slider");
+ tolua_usertype(tolua_S,"CEGUI::System");
+ tolua_usertype(tolua_S,"CEGUI::StateImagery");
+ tolua_usertype(tolua_S,"CEGUI::ListboxTextItem");
+ tolua_usertype(tolua_S,"CEGUI::Menubar");
+ tolua_usertype(tolua_S,"CEGUI::SchemeManager");
+ tolua_usertype(tolua_S,"CEGUI::Vector2");
+ tolua_usertype(tolua_S,"CEGUI::String");
+ tolua_usertype(tolua_S,"CEGUI::NamedArea");
+ tolua_usertype(tolua_S,"CEGUI::Titlebar");
+ tolua_usertype(tolua_S,"CEGUI::TabControl");
+ tolua_usertype(tolua_S,"CEGUI::WindowEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::WindowIterator");
+ tolua_usertype(tolua_S,"CEGUI::colour");
+ tolua_usertype(tolua_S,"CEGUI::Font");
+ tolua_usertype(tolua_S,"CEGUI::FontIterator");
+ tolua_usertype(tolua_S,"CEGUI::Texture");
+ tolua_usertype(tolua_S,"CEGUI::MouseCursorEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::TabButton");
+ tolua_usertype(tolua_S,"CEGUI::FalagardMappingIterator");
+ tolua_usertype(tolua_S,"CEGUI::EventArgs");
+ tolua_usertype(tolua_S,"CEGUI::ScrollablePane");
+ tolua_usertype(tolua_S,"CEGUI::EventSet");
+ tolua_usertype(tolua_S,"CEGUI::DragDropEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::PropertyIterator");
+ tolua_usertype(tolua_S,"CEGUI::AbsoluteDim");
+ tolua_usertype(tolua_S,"CEGUI::HeaderSequenceEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::Event");
+ tolua_usertype(tolua_S,"CEGUI::GUISheet");
+ tolua_usertype(tolua_S,"CEGUI::URect");
+ tolua_usertype(tolua_S,"CEGUI::CoordConverter");
+ tolua_usertype(tolua_S,"CEGUI::Tree");
+ tolua_usertype(tolua_S,"CEGUI::Scheme");
+ tolua_usertype(tolua_S,"CEGUI::WindowFactoryManager");
+ tolua_usertype(tolua_S,"CEGUI::UDim");
+ tolua_usertype(tolua_S,"CEGUI::Size");
+ tolua_usertype(tolua_S,"CEGUI::ActivationEventArgs");
+ tolua_usertype(tolua_S,"CEGUI::Window");
+ tolua_usertype(tolua_S,"CEGUI::Rect");
+}
+
+/* get function: d_x of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Vector2_x
+static int tolua_get_CEGUI__Vector2_x(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_x);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_x of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Vector2_x
+static int tolua_set_CEGUI__Vector2_x(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_x = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_y of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Vector2_y
+static int tolua_get_CEGUI__Vector2_y(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_y);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_y of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Vector2_y
+static int tolua_set_CEGUI__Vector2_y(lua_State* tolua_S)
+{
+  CEGUI::Vector2* self = (CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_y = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__add00
+static int tolua_CEGUI_CEGUI_Vector2__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->operator+(*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__sub00
+static int tolua_CEGUI_CEGUI_Vector2__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->operator-(*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__mul00
+static int tolua_CEGUI_CEGUI_Vector2__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->operator*(*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2__eq00
+static int tolua_CEGUI_CEGUI_Vector2__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* self = (const CEGUI::Vector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*vec);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new00
+static int tolua_CEGUI_CEGUI_Vector2_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new00_local
+static int tolua_CEGUI_CEGUI_Vector2_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new01
+static int tolua_CEGUI_CEGUI_Vector2_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2(x,y);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Vector2_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Vector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Vector2_new01_local
+static int tolua_CEGUI_CEGUI_Vector2_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Vector2* tolua_ret = (CEGUI::Vector2*)  new CEGUI::Vector2(x,y);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Vector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Vector2_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_width of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Size_width
+static int tolua_get_CEGUI__Size_width(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_width'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_width);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_width of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Size_width
+static int tolua_set_CEGUI__Size_width(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_width'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_width = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_height of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Size_height
+static int tolua_get_CEGUI__Size_height(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_height'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_height);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_height of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Size_height
+static int tolua_set_CEGUI__Size_height(lua_State* tolua_S)
+{
+  CEGUI::Size* self = (CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_height'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_height = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size__eq00
+static int tolua_CEGUI_CEGUI_Size__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Size* self = (const CEGUI::Size*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*sz);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new00
+static int tolua_CEGUI_CEGUI_Size_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new00_local
+static int tolua_CEGUI_CEGUI_Size_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new01
+static int tolua_CEGUI_CEGUI_Size_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float w = ((float)  tolua_tonumber(tolua_S,2,0));
+  float h = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size(w,h);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Size_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Size */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Size_new01_local
+static int tolua_CEGUI_CEGUI_Size_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float w = ((float)  tolua_tonumber(tolua_S,2,0));
+  float h = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Size* tolua_ret = (CEGUI::Size*)  new CEGUI::Size(w,h);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Size");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Size_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_top
+static int tolua_get_CEGUI__Rect_top(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_top);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_top
+static int tolua_set_CEGUI__Rect_top(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_bottom
+static int tolua_get_CEGUI__Rect_bottom(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_bottom);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_bottom
+static int tolua_set_CEGUI__Rect_bottom(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_left of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_left
+static int tolua_get_CEGUI__Rect_left(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_left);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_left of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_left
+static int tolua_set_CEGUI__Rect_left(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_left = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_right of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__Rect_right
+static int tolua_get_CEGUI__Rect_right(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_right);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_right of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__Rect_right
+static int tolua_set_CEGUI__Rect_right(lua_State* tolua_S)
+{
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_right = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getPosition00
+static int tolua_CEGUI_CEGUI_Rect_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getPosition();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getWidth00
+static int tolua_CEGUI_CEGUI_Rect_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getHeight00
+static int tolua_CEGUI_CEGUI_Rect_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getSize00
+static int tolua_CEGUI_CEGUI_Rect_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIntersection of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_getIntersection00
+static int tolua_CEGUI_CEGUI_Rect_getIntersection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIntersection'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getIntersection(*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIntersection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPointInRect of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_isPointInRect00
+static int tolua_CEGUI_CEGUI_Rect_isPointInRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* p = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPointInRect'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPointInRect(*p);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPointInRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setPosition00
+static int tolua_CEGUI_CEGUI_Rect_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* p = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*p);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidth of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setWidth00
+static int tolua_CEGUI_CEGUI_Rect_setWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  float w = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidth'",NULL);
+#endif
+ {
+  self->setWidth(w);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHeight of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setHeight00
+static int tolua_CEGUI_CEGUI_Rect_setHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  float h = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHeight'",NULL);
+#endif
+ {
+  self->setHeight(h);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSize of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_setSize00
+static int tolua_CEGUI_CEGUI_Rect_setSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSize'",NULL);
+#endif
+ {
+  self->setSize(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offset of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_offset00
+static int tolua_CEGUI_CEGUI_Rect_offset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* p = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offset'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->offset(*p);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: constrainSizeMax of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_constrainSizeMax00
+static int tolua_CEGUI_CEGUI_Rect_constrainSizeMax00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'constrainSizeMax'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->constrainSizeMax(*sz);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'constrainSizeMax'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: constrainSizeMin of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_constrainSizeMin00
+static int tolua_CEGUI_CEGUI_Rect_constrainSizeMin00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'constrainSizeMin'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->constrainSizeMin(*sz);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'constrainSizeMin'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: constrainSize of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_constrainSize00
+static int tolua_CEGUI_CEGUI_Rect_constrainSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Rect* self = (CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* min = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Size* max = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'constrainSize'",NULL);
+#endif
+ {
+  CEGUI::Rect& tolua_ret = (CEGUI::Rect&)  self->constrainSize(*min,*max);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'constrainSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect__eq00
+static int tolua_CEGUI_CEGUI_Rect__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* self = (const CEGUI::Rect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* r = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*r);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new00
+static int tolua_CEGUI_CEGUI_Rect_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new00_local
+static int tolua_CEGUI_CEGUI_Rect_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new01
+static int tolua_CEGUI_CEGUI_Rect_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float l = ((float)  tolua_tonumber(tolua_S,2,0));
+  float t = ((float)  tolua_tonumber(tolua_S,3,0));
+  float r = ((float)  tolua_tonumber(tolua_S,4,0));
+  float b = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect(l,t,r,b);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Rect_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Rect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Rect_new01_local
+static int tolua_CEGUI_CEGUI_Rect_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float l = ((float)  tolua_tonumber(tolua_S,2,0));
+  float t = ((float)  tolua_tonumber(tolua_S,3,0));
+  float r = ((float)  tolua_tonumber(tolua_S,4,0));
+  float b = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::Rect* tolua_ret = (CEGUI::Rect*)  new CEGUI::Rect(l,t,r,b);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Rect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Rect_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAlpha of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getAlpha00
+static int tolua_CEGUI_CEGUI_colour_getAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRed of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getRed00
+static int tolua_CEGUI_CEGUI_colour_getRed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRed'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getRed();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getGreen of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getGreen00
+static int tolua_CEGUI_CEGUI_colour_getGreen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getGreen'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getGreen();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getGreen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBlue of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getBlue00
+static int tolua_CEGUI_CEGUI_colour_getBlue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBlue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getBlue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBlue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHue of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getHue00
+static int tolua_CEGUI_CEGUI_colour_getHue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSaturation of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getSaturation00
+static int tolua_CEGUI_CEGUI_colour_getSaturation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSaturation'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getSaturation();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSaturation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLumination of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_getLumination00
+static int tolua_CEGUI_CEGUI_colour_getLumination00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLumination'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getLumination();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLumination'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_set00
+static int tolua_CEGUI_CEGUI_colour_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+  float a = ((float)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(r,g,b,a);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlpha of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setAlpha00
+static int tolua_CEGUI_CEGUI_colour_setAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float a = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlpha'",NULL);
+#endif
+ {
+  self->setAlpha(a);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRed of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setRed00
+static int tolua_CEGUI_CEGUI_colour_setRed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRed'",NULL);
+#endif
+ {
+  self->setRed(r);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setGreen of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setGreen00
+static int tolua_CEGUI_CEGUI_colour_setGreen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float g = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setGreen'",NULL);
+#endif
+ {
+  self->setGreen(g);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setGreen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBlue of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setBlue00
+static int tolua_CEGUI_CEGUI_colour_setBlue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float b = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBlue'",NULL);
+#endif
+ {
+  self->setBlue(b);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBlue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRGB of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setRGB00
+static int tolua_CEGUI_CEGUI_colour_setRGB00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRGB'",NULL);
+#endif
+ {
+  self->setRGB(r,g,b);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRGB'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHSL of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_setHSL00
+static int tolua_CEGUI_CEGUI_colour_setHSL00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::colour* self = (CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  float hue = ((float)  tolua_tonumber(tolua_S,2,0));
+  float saturation = ((float)  tolua_tonumber(tolua_S,3,0));
+  float luminance = ((float)  tolua_tonumber(tolua_S,4,0));
+  float alpha = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHSL'",NULL);
+#endif
+ {
+  self->setHSL(hue,saturation,luminance,alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHSL'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour__add00
+static int tolua_CEGUI_CEGUI_colour__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* c = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  self->operator+(*c);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour__sub00
+static int tolua_CEGUI_CEGUI_colour__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* c = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  self->operator-(*c);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour__eq00
+static int tolua_CEGUI_CEGUI_colour__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* self = (const CEGUI::colour*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* c = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*c);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new00
+static int tolua_CEGUI_CEGUI_colour_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new00_local
+static int tolua_CEGUI_CEGUI_colour_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new01
+static int tolua_CEGUI_CEGUI_colour_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+  float a = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour(r,g,b,a);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_colour_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::colour */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_colour_new01_local
+static int tolua_CEGUI_CEGUI_colour_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float r = ((float)  tolua_tonumber(tolua_S,2,0));
+  float g = ((float)  tolua_tonumber(tolua_S,3,0));
+  float b = ((float)  tolua_tonumber(tolua_S,4,0));
+  float a = ((float)  tolua_tonumber(tolua_S,5,0));
+ {
+  CEGUI::colour* tolua_ret = (CEGUI::colour*)  new CEGUI::colour(r,g,b,a);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::colour");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_colour_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_top_left
+static int tolua_get_CEGUI__ColourRect_top_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_left'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_top_left,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_top_left
+static int tolua_set_CEGUI__ColourRect_top_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_left'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top_left = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_top_right
+static int tolua_get_CEGUI__ColourRect_top_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_right'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_top_right,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_top_right
+static int tolua_set_CEGUI__ColourRect_top_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top_right'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top_right = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_bottom_left
+static int tolua_get_CEGUI__ColourRect_bottom_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_left'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_bottom_left,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom_left of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_bottom_left
+static int tolua_set_CEGUI__ColourRect_bottom_left(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_left'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom_left = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ColourRect_bottom_right
+static int tolua_get_CEGUI__ColourRect_bottom_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_right'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_bottom_right,"CEGUI::colour");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom_right of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ColourRect_bottom_right
+static int tolua_set_CEGUI__ColourRect_bottom_right(lua_State* tolua_S)
+{
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_right'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom_right = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlpha'",NULL);
+#endif
+ {
+  self->setAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTopAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setTopAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setTopAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTopAlpha'",NULL);
+#endif
+ {
+  self->setTopAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTopAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBottomAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setBottomAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setBottomAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBottomAlpha'",NULL);
+#endif
+ {
+  self->setBottomAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBottomAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setLeftAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setLeftAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setLeftAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setLeftAlpha'",NULL);
+#endif
+ {
+  self->setLeftAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setLeftAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRightAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setRightAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_setRightAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRightAlpha'",NULL);
+#endif
+ {
+  self->setRightAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRightAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: modulateAlpha of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_modulateAlpha00
+static int tolua_CEGUI_CEGUI_ColourRect_modulateAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'modulateAlpha'",NULL);
+#endif
+ {
+  self->modulateAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'modulateAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColours of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_setColours00
+static int tolua_CEGUI_CEGUI_ColourRect_setColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ColourRect* self = (CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::colour* col = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColours'",NULL);
+#endif
+ {
+  self->setColours(*col);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMonochromatic of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_isMonochromatic00
+static int tolua_CEGUI_CEGUI_ColourRect_isMonochromatic00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* self = (const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMonochromatic'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMonochromatic();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMonochromatic'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSubRectangle of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_getSubRectangle00
+static int tolua_CEGUI_CEGUI_ColourRect_getSubRectangle00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* self = (const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float left = ((float)  tolua_tonumber(tolua_S,2,0));
+  float right = ((float)  tolua_tonumber(tolua_S,3,0));
+  float top = ((float)  tolua_tonumber(tolua_S,4,0));
+  float bottom = ((float)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSubRectangle'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getSubRectangle(left,right,top,bottom);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSubRectangle'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColourAtPoint of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_getColourAtPoint00
+static int tolua_CEGUI_CEGUI_ColourRect_getColourAtPoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* self = (const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,1,0);
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColourAtPoint'",NULL);
+#endif
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  self->getColourAtPoint(x,y);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColourAtPoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new00
+static int tolua_CEGUI_CEGUI_ColourRect_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new00_local
+static int tolua_CEGUI_CEGUI_ColourRect_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new01
+static int tolua_CEGUI_CEGUI_ColourRect_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* col = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*col);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new01_local
+static int tolua_CEGUI_CEGUI_ColourRect_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* col = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*col);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new02
+static int tolua_CEGUI_CEGUI_ColourRect_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* top_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::colour* top_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::colour* bottom_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::colour* bottom_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*top_left,*top_right,*bottom_left,*bottom_right);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ColourRect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ColourRect_new02_local
+static int tolua_CEGUI_CEGUI_ColourRect_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::colour* top_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::colour* top_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::colour* bottom_left = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::colour* bottom_right = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::ColourRect* tolua_ret = (CEGUI::ColourRect*)  new CEGUI::ColourRect(*top_left,*top_right,*bottom_left,*bottom_right);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ColourRect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ColourRect_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: npos of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__String_unsigned_npos
+static int tolua_get_CEGUI__String_unsigned_npos(lua_State* tolua_S)
+{
+ tolua_pushnumber(tolua_S,(lua_Number)CEGUI::String::npos);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: size of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_size00
+static int tolua_CEGUI_CEGUI_String_size00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'size'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->size();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'size'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: length of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_length00
+static int tolua_CEGUI_CEGUI_String_length00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'length'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->length();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'length'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: empty of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_empty00
+static int tolua_CEGUI_CEGUI_String_empty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'empty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->empty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'empty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: capacity of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_capacity00
+static int tolua_CEGUI_CEGUI_String_capacity00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'capacity'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->capacity();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'capacity'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator&[] of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String__seti00
+static int tolua_CEGUI_CEGUI_String__seti00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long i = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long tolua_value = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator&[]'",NULL);
+#endif
+ self->operator[](i) =  tolua_value;
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.seti'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator[] of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String__geti00
+static int tolua_CEGUI_CEGUI_String__geti00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long i = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator[]'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->operator[](i);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.geti'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: at of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_at00
+static int tolua_CEGUI_CEGUI_String_at00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long i = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'at'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->at(i);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'at'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: c_str of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_c_str00
+static int tolua_CEGUI_CEGUI_String_c_str00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'c_str'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->c_str();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'c_str'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: reserve of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_reserve00
+static int tolua_CEGUI_CEGUI_String_reserve00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'reserve'",NULL);
+#endif
+ {
+  self->reserve(num);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'reserve'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resize of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_resize00
+static int tolua_CEGUI_CEGUI_String_resize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resize'",NULL);
+#endif
+ {
+  self->resize(num);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resize of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_resize01
+static int tolua_CEGUI_CEGUI_String_resize01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resize'",NULL);
+#endif
+ {
+  self->resize(num,codepoint);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_resize00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clear of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_clear00
+static int tolua_CEGUI_CEGUI_String_clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clear'",NULL);
+#endif
+ {
+  self->clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: erase of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_erase00
+static int tolua_CEGUI_CEGUI_String_erase00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'erase'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->erase();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'erase'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: erase of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_erase01
+static int tolua_CEGUI_CEGUI_String_erase01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long len = ((unsigned long)  tolua_tonumber(tolua_S,3,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'erase'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->erase(idx,len);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_erase00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: replace of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_replace00
+static int tolua_CEGUI_CEGUI_String_replace00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long begin = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long len = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'replace'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->replace(begin,len,*s);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'replace'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: swap of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_swap00
+static int tolua_CEGUI_CEGUI_String_swap00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::String* s = ((CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'swap'",NULL);
+#endif
+ {
+  self->swap(*s);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'swap'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insert of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_insert00
+static int tolua_CEGUI_CEGUI_String_insert00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insert'",NULL);
+#endif
+ {
+  CEGUI::String& tolua_ret = (CEGUI::String&)  self->insert(pos,*s);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insert'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: find of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_find00
+static int tolua_CEGUI_CEGUI_String_find00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'find'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->find(codepoint,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'find'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rfind of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_rfind00
+static int tolua_CEGUI_CEGUI_String_rfind00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,-1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'rfind'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->rfind(codepoint,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'rfind'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: find of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_find01
+static int tolua_CEGUI_CEGUI_String_find01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::String* sub = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'find'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->find(*sub,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_find00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rfind of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_rfind01
+static int tolua_CEGUI_CEGUI_String_rfind01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::String* sub = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,3,-1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'rfind'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->rfind(*sub,idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_rfind00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: substr of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_substr00
+static int tolua_CEGUI_CEGUI_String_substr00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::String* self = (const CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long idx = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long len = ((unsigned long)  tolua_tonumber(tolua_S,3,-1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'substr'",NULL);
+#endif
+ {
+  CEGUI::String tolua_ret = (CEGUI::String)  self->substr(idx,len);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::String(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::String));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'substr'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: push_back of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_push_back00
+static int tolua_CEGUI_CEGUI_String_push_back00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::String* self = (CEGUI::String*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'push_back'",NULL);
+#endif
+ {
+  self->push_back(codepoint);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'push_back'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new00
+static int tolua_CEGUI_CEGUI_String_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new00_local
+static int tolua_CEGUI_CEGUI_String_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new01
+static int tolua_CEGUI_CEGUI_String_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(num,codepoint);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new01_local
+static int tolua_CEGUI_CEGUI_String_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  unsigned long num = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long codepoint = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(num,codepoint);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new02
+static int tolua_CEGUI_CEGUI_String_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string s = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(s);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new02_local
+static int tolua_CEGUI_CEGUI_String_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string s = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(s);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new03
+static int tolua_CEGUI_CEGUI_String_new03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(*s);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::String */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_String_new03_local
+static int tolua_CEGUI_CEGUI_String_new03_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::String",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::String",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::String* s = ((const CEGUI::String*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::String* tolua_ret = (CEGUI::String*)  new CEGUI::String(*s);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::String");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_String_new02_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_scale of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UDim_scale
+static int tolua_get_CEGUI__UDim_scale(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_scale'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_scale);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_scale of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UDim_scale
+static int tolua_set_CEGUI__UDim_scale(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_scale'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_scale = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_offset of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UDim_offset
+static int tolua_get_CEGUI__UDim_offset(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_offset'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_offset);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_offset of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UDim_offset
+static int tolua_set_CEGUI__UDim_offset(lua_State* tolua_S)
+{
+  CEGUI::UDim* self = (CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_offset'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_offset = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asAbsolute of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_asAbsolute00
+static int tolua_CEGUI_CEGUI_UDim_asAbsolute00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  float base = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asAbsolute'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->asAbsolute(base);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asAbsolute'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asRelative of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_asRelative00
+static int tolua_CEGUI_CEGUI_UDim_asRelative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  float base = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asRelative'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->asRelative(base);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asRelative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__add00
+static int tolua_CEGUI_CEGUI_UDim__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator+(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__sub00
+static int tolua_CEGUI_CEGUI_UDim__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator-(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator/ of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__div00
+static int tolua_CEGUI_CEGUI_UDim__div00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator/(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__mul00
+static int tolua_CEGUI_CEGUI_UDim__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->operator*(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim__eq00
+static int tolua_CEGUI_CEGUI_UDim__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* self = (const CEGUI::UDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* other = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*other);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new00
+static int tolua_CEGUI_CEGUI_UDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new00_local
+static int tolua_CEGUI_CEGUI_UDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new01
+static int tolua_CEGUI_CEGUI_UDim_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float scale = ((float)  tolua_tonumber(tolua_S,2,0));
+  float offset = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim(scale,offset);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UDim_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UDim_new01_local
+static int tolua_CEGUI_CEGUI_UDim_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  float scale = ((float)  tolua_tonumber(tolua_S,2,0));
+  float offset = ((float)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UDim* tolua_ret = (CEGUI::UDim*)  new CEGUI::UDim(scale,offset);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UDim");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UDim_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_x of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UVector2_x
+static int tolua_get_CEGUI__UVector2_x(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_x,"CEGUI::UDim");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_x of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UVector2_x
+static int tolua_set_CEGUI__UVector2_x(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_x'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_x = *((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_y of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__UVector2_y
+static int tolua_get_CEGUI__UVector2_y(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_y,"CEGUI::UDim");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_y of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__UVector2_y
+static int tolua_set_CEGUI__UVector2_y(lua_State* tolua_S)
+{
+  CEGUI::UVector2* self = (CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_y'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_y = *((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asAbsolute of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_asAbsolute00
+static int tolua_CEGUI_CEGUI_UVector2_asAbsolute00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asAbsolute'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->asAbsolute(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asAbsolute'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asRelative of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_asRelative00
+static int tolua_CEGUI_CEGUI_UVector2_asRelative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asRelative'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->asRelative(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asRelative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator+ of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__add00
+static int tolua_CEGUI_CEGUI_UVector2__add00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator+(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator- of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__sub00
+static int tolua_CEGUI_CEGUI_UVector2__sub00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator-(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator/ of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__div00
+static int tolua_CEGUI_CEGUI_UVector2__div00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator/(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator* of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__mul00
+static int tolua_CEGUI_CEGUI_UVector2__mul00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->operator*(*other);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2__eq00
+static int tolua_CEGUI_CEGUI_UVector2__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* self = (const CEGUI::UVector2*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* other = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*other);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new00
+static int tolua_CEGUI_CEGUI_UVector2_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new00_local
+static int tolua_CEGUI_CEGUI_UVector2_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new01
+static int tolua_CEGUI_CEGUI_UVector2_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::UDim* scale = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::UDim* offset = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2(*scale,*offset);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UVector2_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UVector2 */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UVector2_new01_local
+static int tolua_CEGUI_CEGUI_UVector2_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::UDim* scale = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::UDim* offset = ((CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::UVector2* tolua_ret = (CEGUI::UVector2*)  new CEGUI::UVector2(*scale,*offset);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UVector2");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_UVector2_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_min of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__URect_min
+static int tolua_get_CEGUI__URect_min(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_min'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_min,"CEGUI::UVector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_min of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__URect_min
+static int tolua_set_CEGUI__URect_min(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_min'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UVector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_min = *((CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_max of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__URect_max
+static int tolua_get_CEGUI__URect_max(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_max'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_max,"CEGUI::UVector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_max of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__URect_max
+static int tolua_set_CEGUI__URect_max(lua_State* tolua_S)
+{
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_max'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::UVector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_max = *((CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asAbsolute of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_asAbsolute00
+static int tolua_CEGUI_CEGUI_URect_asAbsolute00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asAbsolute'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->asAbsolute(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asAbsolute'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: asRelative of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_asRelative00
+static int tolua_CEGUI_CEGUI_URect_asRelative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* base = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'asRelative'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->asRelative(*base);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'asRelative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getPosition00
+static int tolua_CEGUI_CEGUI_URect_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getSize00
+static int tolua_CEGUI_CEGUI_URect_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getWidth00
+static int tolua_CEGUI_CEGUI_URect_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getWidth();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_getHeight00
+static int tolua_CEGUI_CEGUI_URect_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* self = (const CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getHeight();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setPosition00
+static int tolua_CEGUI_CEGUI_URect_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* pos = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSize of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setSize00
+static int tolua_CEGUI_CEGUI_URect_setSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* sz = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSize'",NULL);
+#endif
+ {
+  self->setSize(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidth of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setWidth00
+static int tolua_CEGUI_CEGUI_URect_setWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* w = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidth'",NULL);
+#endif
+ {
+  self->setWidth(*w);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHeight of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_setHeight00
+static int tolua_CEGUI_CEGUI_URect_setHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* h = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHeight'",NULL);
+#endif
+ {
+  self->setHeight(*h);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offset of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_offset00
+static int tolua_CEGUI_CEGUI_URect_offset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::URect* self = (CEGUI::URect*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* sz = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offset'",NULL);
+#endif
+ {
+  self->offset(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new00
+static int tolua_CEGUI_CEGUI_URect_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new00_local
+static int tolua_CEGUI_CEGUI_URect_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new01
+static int tolua_CEGUI_CEGUI_URect_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UVector2* min = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* max = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*min,*max);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new01_local
+static int tolua_CEGUI_CEGUI_URect_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UVector2* min = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* max = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*min,*max);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new02
+static int tolua_CEGUI_CEGUI_URect_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UDim* left = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* top = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::UDim* right = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::UDim* bottom = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*left,*top,*right,*bottom);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::URect */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_URect_new02_local
+static int tolua_CEGUI_CEGUI_URect_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::URect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::UDim* left = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* top = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::UDim* right = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::UDim* bottom = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::URect* tolua_ret = (CEGUI::URect*)  new CEGUI::URect(*left,*top,*right,*bottom);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::URect");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_URect_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_getSingleton00
+static int tolua_CEGUI_CEGUI_Logger_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Logger",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Logger& tolua_ret = (CEGUI::Logger&)  CEGUI::Logger::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::Logger");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setLoggingLevel of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_setLoggingLevel00
+static int tolua_CEGUI_CEGUI_Logger_setLoggingLevel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Logger",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Logger* self = (CEGUI::Logger*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::LoggingLevel level = ((CEGUI::LoggingLevel) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setLoggingLevel'",NULL);
+#endif
+ {
+  self->setLoggingLevel(level);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setLoggingLevel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLoggingLevel of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_getLoggingLevel00
+static int tolua_CEGUI_CEGUI_Logger_getLoggingLevel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Logger",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Logger* self = (const CEGUI::Logger*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLoggingLevel'",NULL);
+#endif
+ {
+  CEGUI::LoggingLevel tolua_ret = (CEGUI::LoggingLevel)  self->getLoggingLevel();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLoggingLevel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: logEvent of class  CEGUI::Logger */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Logger_logEvent00
+static int tolua_CEGUI_CEGUI_Logger_logEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Logger",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Logger* self = (CEGUI::Logger*)  tolua_tousertype(tolua_S,1,0);
+  string message = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::LoggingLevel level = ((CEGUI::LoggingLevel) (int)  tolua_tonumber(tolua_S,3,CEGUI::Standard));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'logEvent'",NULL);
+#endif
+ {
+  self->logEvent(message,level);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'logEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setProperty of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_setProperty00
+static int tolua_CEGUI_CEGUI_Font_setProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setProperty'",NULL);
+#endif
+ {
+  self->setProperty(name,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getProperty of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getProperty00
+static int tolua_CEGUI_CEGUI_Font_getProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getProperty'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getProperty(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyDefault of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getPropertyDefault00
+static int tolua_CEGUI_CEGUI_Font_getPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyDefault'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyDefault(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyHelp of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getPropertyHelp00
+static int tolua_CEGUI_CEGUI_Font_getPropertyHelp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyHelp'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyHelp(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyHelp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyPresent of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_isPropertyPresent00
+static int tolua_CEGUI_CEGUI_Font_isPropertyPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyDefault of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_isPropertyDefault00
+static int tolua_CEGUI_CEGUI_Font_isPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyDefault'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyDefault(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getPropertyIterator of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getPropertyIterator00
+static int tolua_CEGUI_CEGUI_Font_getPropertyIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getPropertyIterator'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator tolua_ret = (CEGUI::PropertyIterator)  ceguiLua_getPropertyIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::PropertyIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::PropertyIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Font_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Font::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Font_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::Font::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: load of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_load00
+static int tolua_CEGUI_CEGUI_Font_load00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'load'",NULL);
+#endif
+ {
+  self->load();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'load'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCodepointAvailable of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_isCodepointAvailable00
+static int tolua_CEGUI_CEGUI_Font_isCodepointAvailable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long cp = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCodepointAvailable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCodepointAvailable(cp);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCodepointAvailable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNativeResolution of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_setNativeResolution00
+static int tolua_CEGUI_CEGUI_Font_setNativeResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNativeResolution'",NULL);
+#endif
+ {
+  self->setNativeResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNativeResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_Font_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextExtent of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getTextExtent00
+static int tolua_CEGUI_CEGUI_Font_getTextExtent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,3,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextExtent'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTextExtent(text,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextExtent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLineSpacing of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getLineSpacing00
+static int tolua_CEGUI_CEGUI_Font_getLineSpacing00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  float yscale = ((float)  tolua_tonumber(tolua_S,2,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLineSpacing'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getLineSpacing(yscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLineSpacing'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFontHeight of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getFontHeight00
+static int tolua_CEGUI_CEGUI_Font_getFontHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Font* self = (const CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  float yscale = ((float)  tolua_tonumber(tolua_S,2,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFontHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFontHeight(yscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFontHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCharAtPixel of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getCharAtPixel00
+static int tolua_CEGUI_CEGUI_Font_getCharAtPixel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned long start_char = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+  float pixel = ((float)  tolua_tonumber(tolua_S,4,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCharAtPixel'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCharAtPixel(text,start_char,pixel,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCharAtPixel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCharAtPixel of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getCharAtPixel01
+static int tolua_CEGUI_CEGUI_Font_getCharAtPixel01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  float pixel = ((float)  tolua_tonumber(tolua_S,3,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,4,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCharAtPixel'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCharAtPixel(text,pixel,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Font_getCharAtPixel00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFormattedLineCount of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getFormattedLineCount00
+static int tolua_CEGUI_CEGUI_Font_getFormattedLineCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Rect* format_area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::TextFormatting fmt = ((CEGUI::TextFormatting) (int)  tolua_tonumber(tolua_S,4,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFormattedLineCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getFormattedLineCount(text,*format_area,fmt,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFormattedLineCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFormattedTextExtent of class  CEGUI::Font */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Font_getFormattedTextExtent00
+static int tolua_CEGUI_CEGUI_Font_getFormattedTextExtent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Font* self = (CEGUI::Font*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Rect* format_area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::TextFormatting fmt = ((CEGUI::TextFormatting) (int)  tolua_tonumber(tolua_S,4,0));
+  float xscale = ((float)  tolua_tonumber(tolua_S,5,1));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFormattedTextExtent'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFormattedTextExtent(text,*format_area,fmt,xscale);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFormattedTextExtent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_getSingleton00
+static int tolua_CEGUI_CEGUI_FontManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FontManager& tolua_ret = (CEGUI::FontManager&)  CEGUI::FontManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FontManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_createFont00
+static int tolua_CEGUI_CEGUI_FontManager_createFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string name = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string fontname = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,5,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createFont'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->createFont(type,name,fontname,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+catch(CEGUI::AlreadyExistsException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::AlreadyExistsException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_createFont01
+static int tolua_CEGUI_CEGUI_FontManager_createFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createFont'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->createFont(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+catch(CEGUI::AlreadyExistsException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::AlreadyExistsException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'createFont'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FontManager_createFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_destroyFont00
+static int tolua_CEGUI_CEGUI_FontManager_destroyFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyFont'",NULL);
+#endif
+ {
+  self->destroyFont(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_destroyFont01
+static int tolua_CEGUI_CEGUI_FontManager_destroyFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyFont'",NULL);
+#endif
+ {
+  self->destroyFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FontManager_destroyFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllFonts of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_destroyAllFonts00
+static int tolua_CEGUI_CEGUI_FontManager_destroyAllFonts00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllFonts'",NULL);
+#endif
+ {
+  self->destroyAllFonts();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllFonts'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFontPresent of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_isFontPresent00
+static int tolua_CEGUI_CEGUI_FontManager_isFontPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontManager* self = (const CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFontPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFontPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFontPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_getFont00
+static int tolua_CEGUI_CEGUI_FontManager_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontManager* self = (const CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getFont(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_FontManager_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontManager* self = (CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::FontManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontManager_getIterator00
+static int tolua_CEGUI_CEGUI_FontManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontManager* self = (const CEGUI::FontManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::FontIterator tolua_ret = (CEGUI::FontIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::FontIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FontIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::FontIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FontIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getSize00
+static int tolua_CEGUI_CEGUI_Image_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getWidth00
+static int tolua_CEGUI_CEGUI_Image_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getHeight00
+static int tolua_CEGUI_CEGUI_Image_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOffsets of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getOffsets00
+static int tolua_CEGUI_CEGUI_Image_getOffsets00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOffsets'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getOffsets();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOffsets'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOffsetX of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getOffsetX00
+static int tolua_CEGUI_CEGUI_Image_getOffsetX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOffsetX'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getOffsetX();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOffsetX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOffsetY of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getOffsetY00
+static int tolua_CEGUI_CEGUI_Image_getOffsetY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOffsetY'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getOffsetY();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOffsetY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getName00
+static int tolua_CEGUI_CEGUI_Image_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImagesetName of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getImagesetName00
+static int tolua_CEGUI_CEGUI_Image_getImagesetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImagesetName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getImagesetName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImagesetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSourceTextureArea of class  CEGUI::Image */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Image_getSourceTextureArea00
+static int tolua_CEGUI_CEGUI_Image_getSourceTextureArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* self = (const CEGUI::Image*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSourceTextureArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getSourceTextureArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSourceTextureArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_getWidth00
+static int tolua_CEGUI_CEGUI_Texture_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Texture* self = (const CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  unsigned short tolua_ret = (unsigned short)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_getHeight00
+static int tolua_CEGUI_CEGUI_Texture_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Texture* self = (const CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  unsigned short tolua_ret = (unsigned short)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadFromFile of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_loadFromFile00
+static int tolua_CEGUI_CEGUI_Texture_loadFromFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Texture",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Texture* self = (CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadFromFile'",NULL);
+#endif
+ {
+  self->loadFromFile(filename,resourcegroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadFromFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRenderer of class  CEGUI::Texture */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Texture_getRenderer00
+static int tolua_CEGUI_CEGUI_Texture_getRenderer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Texture* self = (const CEGUI::Texture*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRenderer'",NULL);
+#endif
+ {
+  CEGUI::Renderer* tolua_ret = (CEGUI::Renderer*)  self->getRenderer();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Renderer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRenderer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTexture of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getTexture00
+static int tolua_CEGUI_CEGUI_Imageset_getTexture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->getTexture();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTexture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getName00
+static int tolua_CEGUI_CEGUI_Imageset_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageCount of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageCount00
+static int tolua_CEGUI_CEGUI_Imageset_getImageCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getImageCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isImageDefined of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_isImageDefined00
+static int tolua_CEGUI_CEGUI_Imageset_isImageDefined00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isImageDefined'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isImageDefined(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isImageDefined'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImage00
+static int tolua_CEGUI_CEGUI_Imageset_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image& tolua_ret = (const CEGUI::Image&)  self->getImage(name);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: undefineImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_undefineImage00
+static int tolua_CEGUI_CEGUI_Imageset_undefineImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'undefineImage'",NULL);
+#endif
+ {
+  self->undefineImage(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'undefineImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: undefineAllImages of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_undefineAllImages00
+static int tolua_CEGUI_CEGUI_Imageset_undefineAllImages00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'undefineAllImages'",NULL);
+#endif
+ {
+  self->undefineAllImages();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'undefineAllImages'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageSize of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageSize00
+static int tolua_CEGUI_CEGUI_Imageset_getImageSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getImageSize(name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageWidth of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageWidth00
+static int tolua_CEGUI_CEGUI_Imageset_getImageWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageWidth(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageHeight of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageHeight00
+static int tolua_CEGUI_CEGUI_Imageset_getImageHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageHeight(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageOffset of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageOffset00
+static int tolua_CEGUI_CEGUI_Imageset_getImageOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageOffset'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getImageOffset(name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageOffsetX of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageOffsetX00
+static int tolua_CEGUI_CEGUI_Imageset_getImageOffsetX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageOffsetX'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageOffsetX(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageOffsetX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageOffsetY of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getImageOffsetY00
+static int tolua_CEGUI_CEGUI_Imageset_getImageOffsetY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageOffsetY'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getImageOffsetY(name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageOffsetY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: defineImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_defineImage00
+static int tolua_CEGUI_CEGUI_Imageset_defineImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::Size* size = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Vector2* render_offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'defineImage'",NULL);
+#endif
+ {
+  self->defineImage(name,*pos,*size,*render_offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'defineImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: defineImage of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_defineImage01
+static int tolua_CEGUI_CEGUI_Imageset_defineImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::Vector2* render_offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'defineImage'",NULL);
+#endif
+ {
+  self->defineImage(name,*rect,*render_offset);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Imageset_defineImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoScaled of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_isAutoScaled00
+static int tolua_CEGUI_CEGUI_Imageset_isAutoScaled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoScaled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoScaled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoScaled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoScalingEnabled of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_setAutoScalingEnabled00
+static int tolua_CEGUI_CEGUI_Imageset_setAutoScalingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoScalingEnabled'",NULL);
+#endif
+ {
+  self->setAutoScalingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoScalingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNativeResolution of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getNativeResolution00
+static int tolua_CEGUI_CEGUI_Imageset_getNativeResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNativeResolution'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getNativeResolution();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNativeResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNativeResolution of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_setNativeResolution00
+static int tolua_CEGUI_CEGUI_Imageset_setNativeResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNativeResolution'",NULL);
+#endif
+ {
+  self->setNativeResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNativeResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_Imageset_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Imageset* self = (CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getIterator00
+static int tolua_CEGUI_CEGUI_Imageset_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Imageset* self = (const CEGUI::Imageset*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::ImageIterator tolua_ret = (CEGUI::ImageIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ImageIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImageIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ImageIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImageIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Imageset_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Imageset::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::Imageset */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Imageset_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Imageset_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::Imageset::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_getSingleton00
+static int tolua_CEGUI_CEGUI_ImagesetManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImagesetManager& tolua_ret = (CEGUI::ImagesetManager&)  CEGUI::ImagesetManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagesetManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_createImageset00
+static int tolua_CEGUI_CEGUI_ImagesetManager_createImageset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::Texture* texture = ((CEGUI::Texture*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createImageset'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->createImageset(name,texture);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'createImageset'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createImageset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_createImageset01
+static int tolua_CEGUI_CEGUI_ImagesetManager_createImageset01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createImageset'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->createImageset(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'createImageset'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagesetManager_createImageset00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createImagesetFromImageFile of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_createImagesetFromImageFile00
+static int tolua_CEGUI_CEGUI_ImagesetManager_createImagesetFromImageFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string filename = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createImagesetFromImageFile'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->createImagesetFromImageFile(name,filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'createImagesetFromImageFile'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createImagesetFromImageFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00
+static int tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Imageset",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Imageset* imageset = ((CEGUI::Imageset*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyImageset'",NULL);
+#endif
+ {
+  self->destroyImageset(imageset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyImageset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset01
+static int tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyImageset'",NULL);
+#endif
+ {
+  self->destroyImageset(name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllImagesets of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_destroyAllImagesets00
+static int tolua_CEGUI_CEGUI_ImagesetManager_destroyAllImagesets00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllImagesets'",NULL);
+#endif
+ {
+  self->destroyAllImagesets();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllImagesets'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImageset of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_getImageset00
+static int tolua_CEGUI_CEGUI_ImagesetManager_getImageset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetManager* self = (const CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageset'",NULL);
+#endif
+ try
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->getImageset(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+catch(CEGUI::Exception CEGUIDeadException(&e))
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImageset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isImagesetPresent of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_isImagesetPresent00
+static int tolua_CEGUI_CEGUI_ImagesetManager_isImagesetPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetManager* self = (const CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isImagesetPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isImagesetPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isImagesetPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyScreenResolution of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_notifyScreenResolution00
+static int tolua_CEGUI_CEGUI_ImagesetManager_notifyScreenResolution00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetManager* self = (CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* size = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyScreenResolution'",NULL);
+#endif
+ {
+  self->notifyScreenResolution(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyScreenResolution'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::ImagesetManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetManager_getIterator00
+static int tolua_CEGUI_CEGUI_ImagesetManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetManager* self = (const CEGUI::ImagesetManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::ImagesetIterator tolua_ret = (CEGUI::ImagesetIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ImagesetIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImagesetIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ImagesetIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ImagesetIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHelp of class  CEGUI::Property */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Property_getHelp00
+static int tolua_CEGUI_CEGUI_Property_getHelp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Property",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Property* self = (const CEGUI::Property*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHelp'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getHelp();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHelp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Property */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Property_getName00
+static int tolua_CEGUI_CEGUI_Property_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Property",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Property* self = (const CEGUI::Property*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_key00
+static int tolua_CEGUI_CEGUI_PropertyIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_value00
+static int tolua_CEGUI_CEGUI_PropertyIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Property* tolua_ret = (CEGUI::Property*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Property");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_PropertyIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_PropertyIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_next00
+static int tolua_CEGUI_CEGUI_PropertyIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator& tolua_ret = (CEGUI::PropertyIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_previous00
+static int tolua_CEGUI_CEGUI_PropertyIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator& tolua_ret = (CEGUI::PropertyIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator__eq00
+static int tolua_CEGUI_CEGUI_PropertyIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* self = (const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyIterator* rhs = ((const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_toStart00
+static int tolua_CEGUI_CEGUI_PropertyIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_toEnd00
+static int tolua_CEGUI_CEGUI_PropertyIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyIterator* self = (CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_new00
+static int tolua_CEGUI_CEGUI_PropertyIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* org = ((const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::PropertyIterator* tolua_ret = (CEGUI::PropertyIterator*)  new CEGUI::PropertyIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyIterator_new00_local
+static int tolua_CEGUI_CEGUI_PropertyIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyIterator* org = ((const CEGUI::PropertyIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::PropertyIterator* tolua_ret = (CEGUI::PropertyIterator*)  new CEGUI::PropertyIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_key00
+static int tolua_CEGUI_CEGUI_EventIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_value00
+static int tolua_CEGUI_CEGUI_EventIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Event* tolua_ret = (CEGUI::Event*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Event");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_EventIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_EventIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_next00
+static int tolua_CEGUI_CEGUI_EventIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::EventIterator& tolua_ret = (CEGUI::EventIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_previous00
+static int tolua_CEGUI_CEGUI_EventIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::EventIterator& tolua_ret = (CEGUI::EventIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator__eq00
+static int tolua_CEGUI_CEGUI_EventIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* self = (const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::EventIterator* rhs = ((const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_toStart00
+static int tolua_CEGUI_CEGUI_EventIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_toEnd00
+static int tolua_CEGUI_CEGUI_EventIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventIterator* self = (CEGUI::EventIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_new00
+static int tolua_CEGUI_CEGUI_EventIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* org = ((const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::EventIterator* tolua_ret = (CEGUI::EventIterator*)  new CEGUI::EventIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::EventIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventIterator_new00_local
+static int tolua_CEGUI_CEGUI_EventIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::EventIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventIterator* org = ((const CEGUI::EventIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::EventIterator* tolua_ret = (CEGUI::EventIterator*)  new CEGUI::EventIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::EventIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_key00
+static int tolua_CEGUI_CEGUI_WindowIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_value00
+static int tolua_CEGUI_CEGUI_WindowIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_WindowIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_WindowIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_next00
+static int tolua_CEGUI_CEGUI_WindowIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::WindowIterator& tolua_ret = (CEGUI::WindowIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_previous00
+static int tolua_CEGUI_CEGUI_WindowIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::WindowIterator& tolua_ret = (CEGUI::WindowIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator__eq00
+static int tolua_CEGUI_CEGUI_WindowIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* self = (const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::WindowIterator* rhs = ((const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_toStart00
+static int tolua_CEGUI_CEGUI_WindowIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_toEnd00
+static int tolua_CEGUI_CEGUI_WindowIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowIterator* self = (CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_new00
+static int tolua_CEGUI_CEGUI_WindowIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* org = ((const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowIterator* tolua_ret = (CEGUI::WindowIterator*)  new CEGUI::WindowIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WindowIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowIterator_new00_local
+static int tolua_CEGUI_CEGUI_WindowIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowIterator* org = ((const CEGUI::WindowIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowIterator* tolua_ret = (CEGUI::WindowIterator*)  new CEGUI::WindowIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WindowIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_key00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_value00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::WindowFactory* tolua_ret = (CEGUI::WindowFactory*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowFactory");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_next00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::WindowFactoryIterator& tolua_ret = (CEGUI::WindowFactoryIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_previous00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::WindowFactoryIterator& tolua_ret = (CEGUI::WindowFactoryIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator__eq00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* self = (const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::WindowFactoryIterator* rhs = ((const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_toStart00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_toEnd00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryIterator* self = (CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_new00
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* org = ((const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowFactoryIterator* tolua_ret = (CEGUI::WindowFactoryIterator*)  new CEGUI::WindowFactoryIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WindowFactoryIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local
+static int tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WindowFactoryIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryIterator* org = ((const CEGUI::WindowFactoryIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowFactoryIterator* tolua_ret = (CEGUI::WindowFactoryIterator*)  new CEGUI::WindowFactoryIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WindowFactoryIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_key00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_value00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::FalagardWindowMapping tolua_ret = (CEGUI::FalagardWindowMapping)  self->getCurrentValue();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::FalagardWindowMapping(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardWindowMapping");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::FalagardWindowMapping));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardWindowMapping");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_next00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::FalagardMappingIterator& tolua_ret = (CEGUI::FalagardMappingIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_previous00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::FalagardMappingIterator& tolua_ret = (CEGUI::FalagardMappingIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator__eq00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* self = (const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::FalagardMappingIterator* rhs = ((const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_toStart00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_toEnd00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardMappingIterator* self = (CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_new00
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* org = ((const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FalagardMappingIterator* tolua_ret = (CEGUI::FalagardMappingIterator*)  new CEGUI::FalagardMappingIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FalagardMappingIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local
+static int tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FalagardMappingIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardMappingIterator* org = ((const CEGUI::FalagardMappingIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FalagardMappingIterator* tolua_ret = (CEGUI::FalagardMappingIterator*)  new CEGUI::FalagardMappingIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FalagardMappingIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_key00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_value00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Imageset* tolua_ret = (CEGUI::Imageset*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Imageset");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_next00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::ImagesetIterator& tolua_ret = (CEGUI::ImagesetIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_previous00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::ImagesetIterator& tolua_ret = (CEGUI::ImagesetIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator__eq00
+static int tolua_CEGUI_CEGUI_ImagesetIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* self = (const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImagesetIterator* rhs = ((const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_toStart00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_toEnd00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagesetIterator* self = (CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_new00
+static int tolua_CEGUI_CEGUI_ImagesetIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* org = ((const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImagesetIterator* tolua_ret = (CEGUI::ImagesetIterator*)  new CEGUI::ImagesetIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImagesetIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagesetIterator_new00_local
+static int tolua_CEGUI_CEGUI_ImagesetIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagesetIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagesetIterator* org = ((const CEGUI::ImagesetIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImagesetIterator* tolua_ret = (CEGUI::ImagesetIterator*)  new CEGUI::ImagesetIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImagesetIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_key00
+static int tolua_CEGUI_CEGUI_ImageIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_value00
+static int tolua_CEGUI_CEGUI_ImageIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Image tolua_ret = (CEGUI::Image)  self->getCurrentValue();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Image(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Image");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Image));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Image");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_ImageIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_ImageIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_next00
+static int tolua_CEGUI_CEGUI_ImageIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::ImageIterator& tolua_ret = (CEGUI::ImageIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_previous00
+static int tolua_CEGUI_CEGUI_ImageIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::ImageIterator& tolua_ret = (CEGUI::ImageIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator__eq00
+static int tolua_CEGUI_CEGUI_ImageIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* self = (const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImageIterator* rhs = ((const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_toStart00
+static int tolua_CEGUI_CEGUI_ImageIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_toEnd00
+static int tolua_CEGUI_CEGUI_ImageIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageIterator* self = (CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_new00
+static int tolua_CEGUI_CEGUI_ImageIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* org = ((const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImageIterator* tolua_ret = (CEGUI::ImageIterator*)  new CEGUI::ImageIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImageIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageIterator_new00_local
+static int tolua_CEGUI_CEGUI_ImageIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageIterator* org = ((const CEGUI::ImageIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ImageIterator* tolua_ret = (CEGUI::ImageIterator*)  new CEGUI::ImageIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImageIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_key00
+static int tolua_CEGUI_CEGUI_SchemeIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_value00
+static int tolua_CEGUI_CEGUI_SchemeIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Scheme* tolua_ret = (CEGUI::Scheme*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scheme");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_SchemeIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_SchemeIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_next00
+static int tolua_CEGUI_CEGUI_SchemeIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::SchemeIterator& tolua_ret = (CEGUI::SchemeIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_previous00
+static int tolua_CEGUI_CEGUI_SchemeIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::SchemeIterator& tolua_ret = (CEGUI::SchemeIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator__eq00
+static int tolua_CEGUI_CEGUI_SchemeIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* self = (const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::SchemeIterator* rhs = ((const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_toStart00
+static int tolua_CEGUI_CEGUI_SchemeIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_toEnd00
+static int tolua_CEGUI_CEGUI_SchemeIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeIterator* self = (CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_new00
+static int tolua_CEGUI_CEGUI_SchemeIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* org = ((const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::SchemeIterator* tolua_ret = (CEGUI::SchemeIterator*)  new CEGUI::SchemeIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::SchemeIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeIterator_new00_local
+static int tolua_CEGUI_CEGUI_SchemeIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SchemeIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeIterator* org = ((const CEGUI::SchemeIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::SchemeIterator* tolua_ret = (CEGUI::SchemeIterator*)  new CEGUI::SchemeIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::SchemeIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentKey of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_key00
+static int tolua_CEGUI_CEGUI_FontIterator_key00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentKey'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getCurrentKey();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'key'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_value00
+static int tolua_CEGUI_CEGUI_FontIterator_value00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getCurrentValue();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'value'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtEnd of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_isAtEnd00
+static int tolua_CEGUI_CEGUI_FontIterator_isAtEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtEnd'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtEnd();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAtStart of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_isAtStart00
+static int tolua_CEGUI_CEGUI_FontIterator_isAtStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAtStart'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAtStart();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAtStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_increment of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_next00
+static int tolua_CEGUI_CEGUI_FontIterator_next00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_increment'",NULL);
+#endif
+ {
+  CEGUI::FontIterator& tolua_ret = (CEGUI::FontIterator&)  self->__operator_increment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'next'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: __operator_decrement of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_previous00
+static int tolua_CEGUI_CEGUI_FontIterator_previous00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function '__operator_decrement'",NULL);
+#endif
+ {
+  CEGUI::FontIterator& tolua_ret = (CEGUI::FontIterator&)  self->__operator_decrement();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'previous'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator__eq00
+static int tolua_CEGUI_CEGUI_FontIterator__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* self = (const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::FontIterator* rhs = ((const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toStart of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_toStart00
+static int tolua_CEGUI_CEGUI_FontIterator_toStart00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toStart'",NULL);
+#endif
+ {
+  self->toStart();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toStart'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toEnd of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_toEnd00
+static int tolua_CEGUI_CEGUI_FontIterator_toEnd00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FontIterator* self = (CEGUI::FontIterator*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toEnd'",NULL);
+#endif
+ {
+  self->toEnd();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toEnd'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_new00
+static int tolua_CEGUI_CEGUI_FontIterator_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* org = ((const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FontIterator* tolua_ret = (CEGUI::FontIterator*)  new CEGUI::FontIterator(*org);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FontIterator */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontIterator_new00_local
+static int tolua_CEGUI_CEGUI_FontIterator_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FontIterator",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FontIterator* org = ((const CEGUI::FontIterator*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::FontIterator* tolua_ret = (CEGUI::FontIterator*)  new CEGUI::FontIterator(*org);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FontIterator");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: handled of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__EventArgs_handled
+static int tolua_get_CEGUI__EventArgs_handled(lua_State* tolua_S)
+{
+  CEGUI::EventArgs* self = (CEGUI::EventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'handled'",NULL);
+#endif
+ tolua_pushboolean(tolua_S,(bool)self->handled);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: handled of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__EventArgs_handled
+static int tolua_set_CEGUI__EventArgs_handled(lua_State* tolua_S)
+{
+  CEGUI::EventArgs* self = (CEGUI::EventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'handled'",NULL);
+ if (!tolua_isboolean(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->handled = ((bool)  tolua_toboolean(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventArgs_new00
+static int tolua_CEGUI_CEGUI_EventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::EventArgs* tolua_ret = (CEGUI::EventArgs*)  new CEGUI::EventArgs();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::EventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::EventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventArgs_new00_local
+static int tolua_CEGUI_CEGUI_EventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::EventArgs* tolua_ret = (CEGUI::EventArgs*)  new CEGUI::EventArgs();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::EventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: mouseCursor of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseCursorEventArgs_mouseCursor_ptr
+static int tolua_get_CEGUI__MouseCursorEventArgs_mouseCursor_ptr(lua_State* tolua_S)
+{
+  CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'mouseCursor'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->mouseCursor,"CEGUI::MouseCursor");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: mouseCursor of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseCursorEventArgs_mouseCursor_ptr
+static int tolua_set_CEGUI__MouseCursorEventArgs_mouseCursor_ptr(lua_State* tolua_S)
+{
+  CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'mouseCursor'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::MouseCursor",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->mouseCursor = ((CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: image of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseCursorEventArgs_image_ptr
+static int tolua_get_CEGUI__MouseCursorEventArgs_image_ptr(lua_State* tolua_S)
+{
+  CEGUI::MouseCursorEventArgs* self = (CEGUI::MouseCursorEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'image'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->image,"const CEGUI::Image");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00
+static int tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseCursorEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* cursor = ((CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseCursorEventArgs* tolua_ret = (CEGUI::MouseCursorEventArgs*)  new CEGUI::MouseCursorEventArgs(cursor);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MouseCursorEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::MouseCursorEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseCursorEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* cursor = ((CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseCursorEventArgs* tolua_ret = (CEGUI::MouseCursorEventArgs*)  new CEGUI::MouseCursorEventArgs(cursor);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::MouseCursorEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: window of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__WindowEventArgs_window_ptr
+static int tolua_get_CEGUI__WindowEventArgs_window_ptr(lua_State* tolua_S)
+{
+  CEGUI::WindowEventArgs* self = (CEGUI::WindowEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'window'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->window,"CEGUI::Window");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: window of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__WindowEventArgs_window_ptr
+static int tolua_set_CEGUI__WindowEventArgs_window_ptr(lua_State* tolua_S)
+{
+  CEGUI::WindowEventArgs* self = (CEGUI::WindowEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'window'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowEventArgs_new00
+static int tolua_CEGUI_CEGUI_WindowEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowEventArgs* tolua_ret = (CEGUI::WindowEventArgs*)  new CEGUI::WindowEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WindowEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WindowEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_WindowEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::WindowEventArgs* tolua_ret = (CEGUI::WindowEventArgs*)  new CEGUI::WindowEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WindowEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: otherWindow of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ActivationEventArgs_otherWindow_ptr
+static int tolua_get_CEGUI__ActivationEventArgs_otherWindow_ptr(lua_State* tolua_S)
+{
+  CEGUI::ActivationEventArgs* self = (CEGUI::ActivationEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'otherWindow'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->otherWindow,"CEGUI::Window");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: otherWindow of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ActivationEventArgs_otherWindow_ptr
+static int tolua_set_CEGUI__ActivationEventArgs_otherWindow_ptr(lua_State* tolua_S)
+{
+  CEGUI::ActivationEventArgs* self = (CEGUI::ActivationEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'otherWindow'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->otherWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ActivationEventArgs_new00
+static int tolua_CEGUI_CEGUI_ActivationEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ActivationEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ActivationEventArgs* tolua_ret = (CEGUI::ActivationEventArgs*)  new CEGUI::ActivationEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ActivationEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ActivationEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ActivationEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::ActivationEventArgs* tolua_ret = (CEGUI::ActivationEventArgs*)  new CEGUI::ActivationEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ActivationEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_oldIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx
+static int tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_oldIdx'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_oldIdx);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_oldIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx
+static int tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_oldIdx'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_oldIdx = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_newIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx
+static int tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_newIdx'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->d_newIdx);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_newIdx of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx
+static int tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx(lua_State* tolua_S)
+{
+  CEGUI::HeaderSequenceEventArgs* self = (CEGUI::HeaderSequenceEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_newIdx'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_newIdx = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00
+static int tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::HeaderSequenceEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int old_index = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int new_index = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::HeaderSequenceEventArgs* tolua_ret = (CEGUI::HeaderSequenceEventArgs*)  new CEGUI::HeaderSequenceEventArgs(wnd,old_index,new_index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::HeaderSequenceEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::HeaderSequenceEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::HeaderSequenceEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int old_index = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int new_index = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::HeaderSequenceEventArgs* tolua_ret = (CEGUI::HeaderSequenceEventArgs*)  new CEGUI::HeaderSequenceEventArgs(wnd,old_index,new_index);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::HeaderSequenceEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: position of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_position
+static int tolua_get_CEGUI__MouseEventArgs_position(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'position'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->position,"CEGUI::Vector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: position of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_position
+static int tolua_set_CEGUI__MouseEventArgs_position(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'position'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Vector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->position = *((CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: moveDelta of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_moveDelta
+static int tolua_get_CEGUI__MouseEventArgs_moveDelta(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'moveDelta'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->moveDelta,"CEGUI::Vector2");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: moveDelta of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_moveDelta
+static int tolua_set_CEGUI__MouseEventArgs_moveDelta(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'moveDelta'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Vector2",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->moveDelta = *((CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: button of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_button
+static int tolua_get_CEGUI__MouseEventArgs_button(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'button'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->button);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: button of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_button
+static int tolua_set_CEGUI__MouseEventArgs_button(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'button'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->button = ((CEGUI::MouseButton) (int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: sysKeys of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_unsigned_sysKeys
+static int tolua_get_CEGUI__MouseEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->sysKeys);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: sysKeys of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_unsigned_sysKeys
+static int tolua_set_CEGUI__MouseEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->sysKeys = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: wheelChange of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MouseEventArgs_wheelChange
+static int tolua_get_CEGUI__MouseEventArgs_wheelChange(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'wheelChange'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->wheelChange);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: wheelChange of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MouseEventArgs_wheelChange
+static int tolua_set_CEGUI__MouseEventArgs_wheelChange(lua_State* tolua_S)
+{
+  CEGUI::MouseEventArgs* self = (CEGUI::MouseEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'wheelChange'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->wheelChange = ((float)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseEventArgs_new00
+static int tolua_CEGUI_CEGUI_MouseEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseEventArgs* tolua_ret = (CEGUI::MouseEventArgs*)  new CEGUI::MouseEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MouseEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::MouseEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_MouseEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::MouseEventArgs* tolua_ret = (CEGUI::MouseEventArgs*)  new CEGUI::MouseEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::MouseEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: codepoint of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__KeyEventArgs_unsigned_codepoint
+static int tolua_get_CEGUI__KeyEventArgs_unsigned_codepoint(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'codepoint'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->codepoint);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: codepoint of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__KeyEventArgs_unsigned_codepoint
+static int tolua_set_CEGUI__KeyEventArgs_unsigned_codepoint(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'codepoint'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->codepoint = ((unsigned long)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: scancode of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__KeyEventArgs_scancode
+static int tolua_get_CEGUI__KeyEventArgs_scancode(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'scancode'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->scancode);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: scancode of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__KeyEventArgs_scancode
+static int tolua_set_CEGUI__KeyEventArgs_scancode(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'scancode'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->scancode = ((CEGUI::Key::Scan) (int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: sysKeys of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__KeyEventArgs_unsigned_sysKeys
+static int tolua_get_CEGUI__KeyEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->sysKeys);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: sysKeys of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__KeyEventArgs_unsigned_sysKeys
+static int tolua_set_CEGUI__KeyEventArgs_unsigned_sysKeys(lua_State* tolua_S)
+{
+  CEGUI::KeyEventArgs* self = (CEGUI::KeyEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'sysKeys'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->sysKeys = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_KeyEventArgs_new00
+static int tolua_CEGUI_CEGUI_KeyEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::KeyEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::KeyEventArgs* tolua_ret = (CEGUI::KeyEventArgs*)  new CEGUI::KeyEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::KeyEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::KeyEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_KeyEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_KeyEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::KeyEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::KeyEventArgs* tolua_ret = (CEGUI::KeyEventArgs*)  new CEGUI::KeyEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::KeyEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: dragDropItem of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__DragDropEventArgs_dragDropItem_ptr
+static int tolua_get_CEGUI__DragDropEventArgs_dragDropItem_ptr(lua_State* tolua_S)
+{
+  CEGUI::DragDropEventArgs* self = (CEGUI::DragDropEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'dragDropItem'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)self->dragDropItem,"CEGUI::DragContainer");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: dragDropItem of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__DragDropEventArgs_dragDropItem_ptr
+static int tolua_set_CEGUI__DragDropEventArgs_dragDropItem_ptr(lua_State* tolua_S)
+{
+  CEGUI::DragDropEventArgs* self = (CEGUI::DragDropEventArgs*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'dragDropItem'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->dragDropItem = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragDropEventArgs_new00
+static int tolua_CEGUI_CEGUI_DragDropEventArgs_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::DragDropEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::DragDropEventArgs* tolua_ret = (CEGUI::DragDropEventArgs*)  new CEGUI::DragDropEventArgs(wnd);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::DragDropEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::DragDropEventArgs */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local
+static int tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::DragDropEventArgs",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::DragDropEventArgs* tolua_ret = (CEGUI::DragDropEventArgs*)  new CEGUI::DragDropEventArgs(wnd);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::DragDropEventArgs");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Event */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Event_getName00
+static int tolua_CEGUI_CEGUI_Event_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Event",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Event* self = (const CEGUI::Event*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_addEvent00
+static int tolua_CEGUI_CEGUI_EventSet_addEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addEvent'",NULL);
+#endif
+ {
+  self->addEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_removeEvent00
+static int tolua_CEGUI_CEGUI_EventSet_removeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeEvent'",NULL);
+#endif
+ {
+  self->removeEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeAllEvents of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_removeAllEvents00
+static int tolua_CEGUI_CEGUI_EventSet_removeAllEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllEvents'",NULL);
+#endif
+ {
+  self->removeAllEvents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeAllEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isEventPresent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_isEventPresent00
+static int tolua_CEGUI_CEGUI_EventSet_isEventPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEventPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isEventPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isEventPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: LuaFunctorSubscribeEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_subscribeEvent00
+static int tolua_CEGUI_CEGUI_EventSet_subscribeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  lua_Object funcIndex = ((lua_Object)  tolua_tovalue(tolua_S,3,0));
+  lua_Object selfIndex = ((lua_Object)  tolua_tovalue(tolua_S,4,LUA_NOREF));
+  lua_State* tolua_var_1 =  tolua_S;
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'LuaFunctorSubscribeEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+   CEGUI::EventConnection tolua_ret = (  CEGUI::EventConnection)  LuaFunctorSubscribeEvent(self,name,funcIndex,selfIndex,tolua_var_1);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'LuaFunctorSubscribeEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'subscribeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: subscribeScriptedEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_subscribeEvent01
+static int tolua_CEGUI_CEGUI_EventSet_subscribeEvent01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string callback_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'subscribeScriptedEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::EventConnection tolua_ret = (CEGUI::EventConnection)  self->subscribeScriptedEvent(name,callback_name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'subscribeScriptedEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_EventSet_subscribeEvent00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: fireEvent of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_fireEvent00
+static int tolua_CEGUI_CEGUI_EventSet_fireEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::EventArgs* args = ((CEGUI::EventArgs*)  tolua_tousertype(tolua_S,3,0));
+  string eventnamespace = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fireEvent'",NULL);
+#endif
+ {
+  self->fireEvent(name,*args,eventnamespace);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'fireEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMuted of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_isMuted00
+static int tolua_CEGUI_CEGUI_EventSet_isMuted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventSet* self = (const CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMuted'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMuted();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMuted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMutedState of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_setMutedState00
+static int tolua_CEGUI_CEGUI_EventSet_setMutedState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::EventSet* self = (CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMutedState'",NULL);
+#endif
+ {
+  self->setMutedState(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMutedState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::EventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_EventSet_getEventIterator00
+static int tolua_CEGUI_CEGUI_EventSet_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::EventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::EventSet* self = (const CEGUI::EventSet*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::GlobalEventSet */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_GlobalEventSet_getSingleton00
+static int tolua_CEGUI_CEGUI_GlobalEventSet_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::GlobalEventSet",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::GlobalEventSet& tolua_ret = (CEGUI::GlobalEventSet&)  CEGUI::GlobalEventSet::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::GlobalEventSet");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getSingleton00
+static int tolua_CEGUI_CEGUI_MouseCursor_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::MouseCursor& tolua_ret = (CEGUI::MouseCursor&)  CEGUI::MouseCursor::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::MouseCursor");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setImage00
+static int tolua_CEGUI_CEGUI_MouseCursor_setImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setImage01
+static int tolua_CEGUI_CEGUI_MouseCursor_setImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MouseCursor_setImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getImage00
+static int tolua_CEGUI_CEGUI_MouseCursor_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offsetPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_offsetPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_offsetPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offsetPosition'",NULL);
+#endif
+ {
+  self->offsetPosition(*offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offsetPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_setConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setConstraintArea'",NULL);
+#endif
+ {
+  self->setConstraintArea(area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getPosition();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_getConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getConstraintArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getConstraintArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDisplayIndependantPosition of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getDisplayIndependantPosition00
+static int tolua_CEGUI_CEGUI_MouseCursor_getDisplayIndependantPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDisplayIndependantPosition'",NULL);
+#endif
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  self->getDisplayIndependantPosition();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDisplayIndependantPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUnifiedConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setUnifiedConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_setUnifiedConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::URect* area = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUnifiedConstraintArea'",NULL);
+#endif
+ {
+  self->setUnifiedConstraintArea(area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUnifiedConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUnifiedConstraintArea of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getUnifiedConstraintArea00
+static int tolua_CEGUI_CEGUI_MouseCursor_getUnifiedConstraintArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUnifiedConstraintArea'",NULL);
+#endif
+ {
+  const CEGUI::URect& tolua_ret = (const CEGUI::URect&)  self->getUnifiedConstraintArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUnifiedConstraintArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hide of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_hide00
+static int tolua_CEGUI_CEGUI_MouseCursor_hide00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hide'",NULL);
+#endif
+ {
+  self->hide();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hide'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: show of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_show00
+static int tolua_CEGUI_CEGUI_MouseCursor_show00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'show'",NULL);
+#endif
+ {
+  self->show();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'show'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVisible of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_setVisible00
+static int tolua_CEGUI_CEGUI_MouseCursor_setVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MouseCursor* self = (CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+  bool visible = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVisible'",NULL);
+#endif
+ {
+  self->setVisible(visible);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVisible of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_isVisible00
+static int tolua_CEGUI_CEGUI_MouseCursor_isVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVisible'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVisible();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::MouseCursor */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MouseCursor_getEventIterator00
+static int tolua_CEGUI_CEGUI_MouseCursor_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MouseCursor",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MouseCursor* self = (const CEGUI::MouseCursor*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getType of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getType00
+static int tolua_CEGUI_CEGUI_Window_getType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getName00
+static int tolua_CEGUI_CEGUI_Window_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDestroyedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isDestroyedByParent00
+static int tolua_CEGUI_CEGUI_Window_isDestroyedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDestroyedByParent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDestroyedByParent();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDestroyedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAlwaysOnTop of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAlwaysOnTop00
+static int tolua_CEGUI_CEGUI_Window_isAlwaysOnTop00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAlwaysOnTop'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAlwaysOnTop();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAlwaysOnTop'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDisabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isDisabled00
+static int tolua_CEGUI_CEGUI_Window_isDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool localOnly = ((bool)  tolua_toboolean(tolua_S,2,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDisabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDisabled(localOnly);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVisible of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isVisible00
+static int tolua_CEGUI_CEGUI_Window_isVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool localOnly = ((bool)  tolua_toboolean(tolua_S,2,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVisible'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVisible(localOnly);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isActive of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isActive00
+static int tolua_CEGUI_CEGUI_Window_isActive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isActive'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isActive();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isActive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isClippedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isClippedByParent00
+static int tolua_CEGUI_CEGUI_Window_isClippedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isClippedByParent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isClippedByParent();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isClippedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDestroyedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setDestroyedByParent00
+static int tolua_CEGUI_CEGUI_Window_setDestroyedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDestroyedByParent'",NULL);
+#endif
+ {
+  self->setDestroyedByParent(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDestroyedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlwaysOnTop of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAlwaysOnTop00
+static int tolua_CEGUI_CEGUI_Window_setAlwaysOnTop00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlwaysOnTop'",NULL);
+#endif
+ {
+  self->setAlwaysOnTop(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlwaysOnTop'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setEnabled00
+static int tolua_CEGUI_CEGUI_Window_setEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setEnabled'",NULL);
+#endif
+ {
+  self->setEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: enable of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_enable00
+static int tolua_CEGUI_CEGUI_Window_enable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'enable'",NULL);
+#endif
+ {
+  self->enable();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'enable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: disable of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_disable00
+static int tolua_CEGUI_CEGUI_Window_disable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'disable'",NULL);
+#endif
+ {
+  self->disable();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'disable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVisible of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setVisible00
+static int tolua_CEGUI_CEGUI_Window_setVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVisible'",NULL);
+#endif
+ {
+  self->setVisible(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: show of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_show00
+static int tolua_CEGUI_CEGUI_Window_show00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'show'",NULL);
+#endif
+ {
+  self->show();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'show'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hide of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_hide00
+static int tolua_CEGUI_CEGUI_Window_hide00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hide'",NULL);
+#endif
+ {
+  self->hide();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hide'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: activate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_activate00
+static int tolua_CEGUI_CEGUI_Window_activate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'activate'",NULL);
+#endif
+ {
+  self->activate();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'activate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: deactivate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_deactivate00
+static int tolua_CEGUI_CEGUI_Window_deactivate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'deactivate'",NULL);
+#endif
+ {
+  self->deactivate();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'deactivate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClippedByParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setClippedByParent00
+static int tolua_CEGUI_CEGUI_Window_setClippedByParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClippedByParent'",NULL);
+#endif
+ {
+  self->setClippedByParent(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClippedByParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getID of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getID00
+static int tolua_CEGUI_CEGUI_Window_getID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setID of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setID00
+static int tolua_CEGUI_CEGUI_Window_setID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setID'",NULL);
+#endif
+ {
+  self->setID(ID);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildCount of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildCount00
+static int tolua_CEGUI_CEGUI_Window_getChildCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getChildCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChild00
+static int tolua_CEGUI_CEGUI_Window_isChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChild(ID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChild01
+static int tolua_CEGUI_CEGUI_Window_isChild01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChild(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isChild00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChild02
+static int tolua_CEGUI_CEGUI_Window_isChild02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChild(window);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isChild01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isChildRecursive of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isChildRecursive00
+static int tolua_CEGUI_CEGUI_Window_isChildRecursive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isChildRecursive'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isChildRecursive(ID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isChildRecursive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_addChildWindow00
+static int tolua_CEGUI_CEGUI_Window_addChildWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addChildWindow'",NULL);
+#endif
+ {
+  self->addChildWindow(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addChildWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_addChildWindow01
+static int tolua_CEGUI_CEGUI_Window_addChildWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addChildWindow'",NULL);
+#endif
+ {
+  self->addChildWindow(window);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_addChildWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeChildWindow00
+static int tolua_CEGUI_CEGUI_Window_removeChildWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeChildWindow'",NULL);
+#endif
+ {
+  self->removeChildWindow(ID);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeChildWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeChildWindow01
+static int tolua_CEGUI_CEGUI_Window_removeChildWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeChildWindow'",NULL);
+#endif
+ {
+  self->removeChildWindow(name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_removeChildWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeChildWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeChildWindow02
+static int tolua_CEGUI_CEGUI_Window_removeChildWindow02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeChildWindow'",NULL);
+#endif
+ {
+  self->removeChildWindow(window);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_removeChildWindow01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChild00
+static int tolua_CEGUI_CEGUI_Window_getChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChild'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChild(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::UnknownObjectException CEGUIDeadException(&e))
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChild01
+static int tolua_CEGUI_CEGUI_Window_getChild01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChild'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChild(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::UnknownObjectException CEGUIDeadException(&e))
+{
+ return 0;
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_getChild00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildAtIdx of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildAtIdx00
+static int tolua_CEGUI_CEGUI_Window_getChildAtIdx00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildAtIdx'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChildAtIdx(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildAtIdx'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getActiveChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getActiveChild00
+static int tolua_CEGUI_CEGUI_Window_getActiveChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getActiveChild'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getActiveChild();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getActiveChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildAtPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildAtPosition00
+static int tolua_CEGUI_CEGUI_Window_getChildAtPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildAtPosition'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChildAtPosition(*pos);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildAtPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTargetChildAtPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTargetChildAtPosition00
+static int tolua_CEGUI_CEGUI_Window_getTargetChildAtPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTargetChildAtPosition'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTargetChildAtPosition(*pos);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTargetChildAtPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildRecursive of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getChildRecursive00
+static int tolua_CEGUI_CEGUI_Window_getChildRecursive00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildRecursive'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getChildRecursive(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildRecursive'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParent00
+static int tolua_CEGUI_CEGUI_Window_getParent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParent'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getParent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAncestor00
+static int tolua_CEGUI_CEGUI_Window_isAncestor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAncestor(ID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAncestor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAncestor01
+static int tolua_CEGUI_CEGUI_Window_isAncestor01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAncestor(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isAncestor00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isAncestor02
+static int tolua_CEGUI_CEGUI_Window_isAncestor02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAncestor(window);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_isAncestor01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setFont00
+static int tolua_CEGUI_CEGUI_Window_setFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setFont01
+static int tolua_CEGUI_CEGUI_Window_setFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getFont00
+static int tolua_CEGUI_CEGUI_Window_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getFont();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setText00
+static int tolua_CEGUI_CEGUI_Window_setText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setText'",NULL);
+#endif
+ {
+  self->setText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_insertText00
+static int tolua_CEGUI_CEGUI_Window_insertText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned long position = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertText'",NULL);
+#endif
+ {
+  self->insertText(text,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: appendText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_appendText00
+static int tolua_CEGUI_CEGUI_Window_appendText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'appendText'",NULL);
+#endif
+ {
+  self->appendText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'appendText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getText00
+static int tolua_CEGUI_CEGUI_Window_getText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: inheritsAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_inheritsAlpha00
+static int tolua_CEGUI_CEGUI_Window_inheritsAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'inheritsAlpha'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->inheritsAlpha();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'inheritsAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getAlpha00
+static int tolua_CEGUI_CEGUI_Window_getAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getEffectiveAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getEffectiveAlpha00
+static int tolua_CEGUI_CEGUI_Window_getEffectiveAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getEffectiveAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getEffectiveAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEffectiveAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAlpha00
+static int tolua_CEGUI_CEGUI_Window_setAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  float a = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAlpha'",NULL);
+#endif
+ {
+  self->setAlpha(a);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setInheritsAlpha of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setInheritsAlpha00
+static int tolua_CEGUI_CEGUI_Window_setInheritsAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setInheritsAlpha'",NULL);
+#endif
+ {
+  self->setInheritsAlpha(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setInheritsAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: requestRedraw of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_requestRedraw00
+static int tolua_CEGUI_CEGUI_Window_requestRedraw00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'requestRedraw'",NULL);
+#endif
+ {
+  self->requestRedraw();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'requestRedraw'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isZOrderingEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isZOrderingEnabled00
+static int tolua_CEGUI_CEGUI_Window_isZOrderingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isZOrderingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isZOrderingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isZOrderingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setZOrderingEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setZOrderingEnabled00
+static int tolua_CEGUI_CEGUI_Window_setZOrderingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setZOrderingEnabled'",NULL);
+#endif
+ {
+  self->setZOrderingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setZOrderingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPixelRect00
+static int tolua_CEGUI_CEGUI_Window_getPixelRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getPixelRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getInnerRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getInnerRect00
+static int tolua_CEGUI_CEGUI_Window_getInnerRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getInnerRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getInnerRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getInnerRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUnclippedPixelRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getUnclippedPixelRect00
+static int tolua_CEGUI_CEGUI_Window_getUnclippedPixelRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUnclippedPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getUnclippedPixelRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUnclippedPixelRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUnclippedInnerRect of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getUnclippedInnerRect00
+static int tolua_CEGUI_CEGUI_Window_getUnclippedInnerRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUnclippedInnerRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getUnclippedInnerRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUnclippedInnerRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParentPixelSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParentPixelSize00
+static int tolua_CEGUI_CEGUI_Window_getParentPixelSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParentPixelSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getParentPixelSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParentPixelSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParentPixelWidth of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParentPixelWidth00
+static int tolua_CEGUI_CEGUI_Window_getParentPixelWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParentPixelWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getParentPixelWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParentPixelWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getParentPixelHeight of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getParentPixelHeight00
+static int tolua_CEGUI_CEGUI_Window_getParentPixelHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getParentPixelHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getParentPixelHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getParentPixelHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaptureWindow of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getCaptureWindow00
+static int tolua_CEGUI_CEGUI_Window_getCaptureWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  CEGUI::Window::getCaptureWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaptureWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRestoreCapture of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setRestoreCapture00
+static int tolua_CEGUI_CEGUI_Window_setRestoreCapture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRestoreCapture'",NULL);
+#endif
+ {
+  self->setRestoreCapture(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRestoreCapture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: restoresOldCapture of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_restoresOldCapture00
+static int tolua_CEGUI_CEGUI_Window_restoresOldCapture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'restoresOldCapture'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->restoresOldCapture();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'restoresOldCapture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: distributesCapturedInputs of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_distributesCapturedInputs00
+static int tolua_CEGUI_CEGUI_Window_distributesCapturedInputs00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'distributesCapturedInputs'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->distributesCapturedInputs();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'distributesCapturedInputs'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDistributesCapturedInputs of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setDistributesCapturedInputs00
+static int tolua_CEGUI_CEGUI_Window_setDistributesCapturedInputs00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDistributesCapturedInputs'",NULL);
+#endif
+ {
+  self->setDistributesCapturedInputs(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDistributesCapturedInputs'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: captureInput of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_captureInput00
+static int tolua_CEGUI_CEGUI_Window_captureInput00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'captureInput'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->captureInput();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'captureInput'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: releaseInput of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_releaseInput00
+static int tolua_CEGUI_CEGUI_Window_releaseInput00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'releaseInput'",NULL);
+#endif
+ {
+  self->releaseInput();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'releaseInput'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCapturedByThis of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isCapturedByThis00
+static int tolua_CEGUI_CEGUI_Window_isCapturedByThis00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCapturedByThis'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCapturedByThis();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCapturedByThis'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCapturedByAncestor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isCapturedByAncestor00
+static int tolua_CEGUI_CEGUI_Window_isCapturedByAncestor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCapturedByAncestor'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCapturedByAncestor();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCapturedByAncestor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCapturedByChild of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isCapturedByChild00
+static int tolua_CEGUI_CEGUI_Window_isCapturedByChild00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCapturedByChild'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCapturedByChild();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCapturedByChild'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHit of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isHit00
+static int tolua_CEGUI_CEGUI_Window_isHit00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* pos = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHit'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHit(*pos);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHit'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRiseOnClickEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isRiseOnClickEnabled00
+static int tolua_CEGUI_CEGUI_Window_isRiseOnClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRiseOnClickEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRiseOnClickEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRiseOnClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRiseOnClickEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setRiseOnClickEnabled00
+static int tolua_CEGUI_CEGUI_Window_setRiseOnClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRiseOnClickEnabled'",NULL);
+#endif
+ {
+  self->setRiseOnClickEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRiseOnClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getMouseCursor00
+static int tolua_CEGUI_CEGUI_Window_getMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMouseCursor'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getMouseCursor();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseCursor00
+static int tolua_CEGUI_CEGUI_Window_setMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseCursorImage cursor = ((CEGUI::MouseCursorImage) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseCursor'",NULL);
+#endif
+ {
+  self->setMouseCursor(cursor);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseCursor01
+static int tolua_CEGUI_CEGUI_Window_setMouseCursor01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseCursor'",NULL);
+#endif
+ {
+  self->setMouseCursor(image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setMouseCursor00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseCursor of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseCursor02
+static int tolua_CEGUI_CEGUI_Window_setMouseCursor02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseCursor'",NULL);
+#endif
+ {
+  self->setMouseCursor(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setMouseCursor01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveToFront of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_moveToFront00
+static int tolua_CEGUI_CEGUI_Window_moveToFront00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveToFront'",NULL);
+#endif
+ {
+  self->moveToFront();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveToFront'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveToBack of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_moveToBack00
+static int tolua_CEGUI_CEGUI_Window_moveToBack00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveToBack'",NULL);
+#endif
+ {
+  self->moveToBack();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveToBack'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: wantsMultiClickEvents of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_wantsMultiClickEvents00
+static int tolua_CEGUI_CEGUI_Window_wantsMultiClickEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'wantsMultiClickEvents'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->wantsMultiClickEvents();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'wantsMultiClickEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMouseAutoRepeatEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isMouseAutoRepeatEnabled00
+static int tolua_CEGUI_CEGUI_Window_isMouseAutoRepeatEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMouseAutoRepeatEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMouseAutoRepeatEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMouseAutoRepeatEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAutoRepeatDelay of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getAutoRepeatDelay00
+static int tolua_CEGUI_CEGUI_Window_getAutoRepeatDelay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAutoRepeatDelay'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAutoRepeatDelay();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAutoRepeatDelay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAutoRepeatRate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getAutoRepeatRate00
+static int tolua_CEGUI_CEGUI_Window_getAutoRepeatRate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAutoRepeatRate'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getAutoRepeatRate();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAutoRepeatRate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWantsMultiClickEvents of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setWantsMultiClickEvents00
+static int tolua_CEGUI_CEGUI_Window_setWantsMultiClickEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWantsMultiClickEvents'",NULL);
+#endif
+ {
+  self->setWantsMultiClickEvents(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWantsMultiClickEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseAutoRepeatEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMouseAutoRepeatEnabled00
+static int tolua_CEGUI_CEGUI_Window_setMouseAutoRepeatEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseAutoRepeatEnabled'",NULL);
+#endif
+ {
+  self->setMouseAutoRepeatEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMouseAutoRepeatEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoRepeatDelay of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAutoRepeatDelay00
+static int tolua_CEGUI_CEGUI_Window_setAutoRepeatDelay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  float delay = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoRepeatDelay'",NULL);
+#endif
+ {
+  self->setAutoRepeatDelay(delay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoRepeatDelay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoRepeatRate of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setAutoRepeatRate00
+static int tolua_CEGUI_CEGUI_Window_setAutoRepeatRate00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  float rate = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoRepeatRate'",NULL);
+#endif
+ {
+  self->setAutoRepeatRate(rate);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoRepeatRate'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUsingDefaultTooltip of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isUsingDefaultTooltip00
+static int tolua_CEGUI_CEGUI_Window_isUsingDefaultTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUsingDefaultTooltip'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUsingDefaultTooltip();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUsingDefaultTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTooltip of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTooltip00
+static int tolua_CEGUI_CEGUI_Window_getTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTooltip'",NULL);
+#endif
+ {
+  CEGUI::Tooltip* tolua_ret = (CEGUI::Tooltip*)  self->getTooltip();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Tooltip");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTooltipType of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTooltipType00
+static int tolua_CEGUI_CEGUI_Window_getTooltipType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTooltipType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTooltipType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTooltipType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getTooltipText00
+static int tolua_CEGUI_CEGUI_Window_getTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTooltipText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTooltipText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: inheritsTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_inheritsTooltipText00
+static int tolua_CEGUI_CEGUI_Window_inheritsTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'inheritsTooltipText'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->inheritsTooltipText();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'inheritsTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTooltip of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setTooltip00
+static int tolua_CEGUI_CEGUI_Window_setTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Tooltip* tooltip = ((CEGUI::Tooltip*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTooltip'",NULL);
+#endif
+ {
+  self->setTooltip(tooltip);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTooltipType of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setTooltipType00
+static int tolua_CEGUI_CEGUI_Window_setTooltipType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string tooltipType = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTooltipType'",NULL);
+#endif
+ {
+  self->setTooltipType(tooltipType);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTooltipType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setTooltipText00
+static int tolua_CEGUI_CEGUI_Window_setTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string tip = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTooltipText'",NULL);
+#endif
+ {
+  self->setTooltipText(tip);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setInheritsTooltipText of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setInheritsTooltipText00
+static int tolua_CEGUI_CEGUI_Window_setInheritsTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setInheritsTooltipText'",NULL);
+#endif
+ {
+  self->setInheritsTooltipText(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setInheritsTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: testClassName of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_testClassName00
+static int tolua_CEGUI_CEGUI_Window_testClassName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string class_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'testClassName'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->testClassName(class_name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'testClassName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyDragDropItemEnters of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_notifyDragDropItemEnters00
+static int tolua_CEGUI_CEGUI_Window_notifyDragDropItemEnters00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DragContainer* item = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyDragDropItemEnters'",NULL);
+#endif
+ {
+  self->notifyDragDropItemEnters(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyDragDropItemEnters'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyDragDropItemLeaves of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_notifyDragDropItemLeaves00
+static int tolua_CEGUI_CEGUI_Window_notifyDragDropItemLeaves00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DragContainer* item = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyDragDropItemLeaves'",NULL);
+#endif
+ {
+  self->notifyDragDropItemLeaves(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyDragDropItemLeaves'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyDragDropItemDropped of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_notifyDragDropItemDropped00
+static int tolua_CEGUI_CEGUI_Window_notifyDragDropItemDropped00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DragContainer* item = ((CEGUI::DragContainer*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyDragDropItemDropped'",NULL);
+#endif
+ {
+  self->notifyDragDropItemDropped(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyDragDropItemDropped'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getVerticalAlignment00
+static int tolua_CEGUI_CEGUI_Window_getVerticalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalAlignment'",NULL);
+#endif
+ {
+  CEGUI::VerticalAlignment tolua_ret = (CEGUI::VerticalAlignment)  self->getVerticalAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getHorizontalAlignment00
+static int tolua_CEGUI_CEGUI_Window_getHorizontalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalAlignment'",NULL);
+#endif
+ {
+  CEGUI::HorizontalAlignment tolua_ret = (CEGUI::HorizontalAlignment)  self->getHorizontalAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setVerticalAlignment00
+static int tolua_CEGUI_CEGUI_Window_setVerticalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalAlignment alignment = ((CEGUI::VerticalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalAlignment'",NULL);
+#endif
+ {
+  self->setVerticalAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalAlignment of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setHorizontalAlignment00
+static int tolua_CEGUI_CEGUI_Window_setHorizontalAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalAlignment alignment = ((CEGUI::HorizontalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalAlignment'",NULL);
+#endif
+ {
+  self->setHorizontalAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLookNFeel of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getLookNFeel00
+static int tolua_CEGUI_CEGUI_Window_getLookNFeel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLookNFeel'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getLookNFeel();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLookNFeel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setLookNFeel of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setLookNFeel00
+static int tolua_CEGUI_CEGUI_Window_setLookNFeel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string lnf = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setLookNFeel'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->setLookNFeel(lnf);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'setLookNFeel'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setLookNFeel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWindowRenderer of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setWindowRenderer00
+static int tolua_CEGUI_CEGUI_Window_setWindowRenderer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWindowRenderer'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->setWindowRenderer(name);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'setWindowRenderer'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWindowRenderer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindowRendererName of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getWindowRendererName00
+static int tolua_CEGUI_CEGUI_Window_getWindowRendererName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindowRendererName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWindowRendererName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindowRendererName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getModalState of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getModalState00
+static int tolua_CEGUI_CEGUI_Window_getModalState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getModalState'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->getModalState();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getModalState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setModalState of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setModalState00
+static int tolua_CEGUI_CEGUI_Window_setModalState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool state = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setModalState'",NULL);
+#endif
+ {
+  self->setModalState(state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setModalState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUserString of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getUserString00
+static int tolua_CEGUI_CEGUI_Window_getUserString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUserString'",NULL);
+#endif
+ try
+ {
+  string tolua_ret = (string)  self->getUserString(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+catch(CEGUI::UnknownObjectException CEGUIDeadException(&e))
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUserString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserStringDefined of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isUserStringDefined00
+static int tolua_CEGUI_CEGUI_Window_isUserStringDefined00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserStringDefined'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserStringDefined(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserStringDefined'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserString of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setUserString00
+static int tolua_CEGUI_CEGUI_Window_setUserString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserString'",NULL);
+#endif
+ {
+  self->setUserString(name,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: beginInitialisation of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_beginInitialisation00
+static int tolua_CEGUI_CEGUI_Window_beginInitialisation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'beginInitialisation'",NULL);
+#endif
+ {
+  self->beginInitialisation();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'beginInitialisation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: endInitialisation of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_endInitialisation00
+static int tolua_CEGUI_CEGUI_Window_endInitialisation00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'endInitialisation'",NULL);
+#endif
+ {
+  self->endInitialisation();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'endInitialisation'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setArea00
+static int tolua_CEGUI_CEGUI_Window_setArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* xpos = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* ypos = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::UDim* height = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(*xpos,*ypos,*width,*height);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setArea01
+static int tolua_CEGUI_CEGUI_Window_setArea01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* pos = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(*pos,*size);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setArea00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setArea02
+static int tolua_CEGUI_CEGUI_Window_setArea02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::URect* area = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(*area);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_setArea01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setPosition00
+static int tolua_CEGUI_CEGUI_Window_setPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* pos = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPosition'",NULL);
+#endif
+ {
+  self->setPosition(*pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setXPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setXPosition00
+static int tolua_CEGUI_CEGUI_Window_setXPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* x = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setXPosition'",NULL);
+#endif
+ {
+  self->setXPosition(*x);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setXPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setYPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setYPosition00
+static int tolua_CEGUI_CEGUI_Window_setYPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* y = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setYPosition'",NULL);
+#endif
+ {
+  self->setYPosition(*y);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setYPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setSize00
+static int tolua_CEGUI_CEGUI_Window_setSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSize'",NULL);
+#endif
+ {
+  self->setSize(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidth of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setWidth00
+static int tolua_CEGUI_CEGUI_Window_setWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidth'",NULL);
+#endif
+ {
+  self->setWidth(*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHeight of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setHeight00
+static int tolua_CEGUI_CEGUI_Window_setHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* height = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHeight'",NULL);
+#endif
+ {
+  self->setHeight(*height);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMaxSize00
+static int tolua_CEGUI_CEGUI_Window_setMaxSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxSize'",NULL);
+#endif
+ {
+  self->setMaxSize(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMinSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMinSize00
+static int tolua_CEGUI_CEGUI_Window_setMinSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UVector2* size = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMinSize'",NULL);
+#endif
+ {
+  self->setMinSize(*size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMinSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getArea of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getArea00
+static int tolua_CEGUI_CEGUI_Window_getArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getArea'",NULL);
+#endif
+ {
+  const CEGUI::URect& tolua_ret = (const CEGUI::URect&)  self->getArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::URect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPosition00
+static int tolua_CEGUI_CEGUI_Window_getPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPosition'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getXPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getXPosition00
+static int tolua_CEGUI_CEGUI_Window_getXPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getXPosition'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getXPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getXPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getYPosition of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getYPosition00
+static int tolua_CEGUI_CEGUI_Window_getYPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getYPosition'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getYPosition();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getYPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getSize00
+static int tolua_CEGUI_CEGUI_Window_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getWidth00
+static int tolua_CEGUI_CEGUI_Window_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getWidth();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getHeight00
+static int tolua_CEGUI_CEGUI_Window_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getHeight();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getMaxSize00
+static int tolua_CEGUI_CEGUI_Window_getMaxSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxSize'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getMaxSize();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMinSize of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getMinSize00
+static int tolua_CEGUI_CEGUI_Window_getMinSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMinSize'",NULL);
+#endif
+ {
+  const CEGUI::UVector2& tolua_ret = (const CEGUI::UVector2&)  self->getMinSize();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UVector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMinSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMousePassThroughEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isMousePassThroughEnabled00
+static int tolua_CEGUI_CEGUI_Window_isMousePassThroughEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMousePassThroughEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMousePassThroughEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMousePassThroughEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMousePassThroughEnabled of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMousePassThroughEnabled00
+static int tolua_CEGUI_CEGUI_Window_setMousePassThroughEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMousePassThroughEnabled'",NULL);
+#endif
+ {
+  self->setMousePassThroughEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMousePassThroughEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rename of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_rename00
+static int tolua_CEGUI_CEGUI_Window_rename00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string new_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'rename'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->rename(new_name);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'rename'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'rename'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setProperty of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setProperty00
+static int tolua_CEGUI_CEGUI_Window_setProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setProperty'",NULL);
+#endif
+ {
+  self->setProperty(name,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getProperty of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getProperty00
+static int tolua_CEGUI_CEGUI_Window_getProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getProperty'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getProperty(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyDefault of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPropertyDefault00
+static int tolua_CEGUI_CEGUI_Window_getPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyDefault'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyDefault(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPropertyHelp of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPropertyHelp00
+static int tolua_CEGUI_CEGUI_Window_getPropertyHelp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPropertyHelp'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getPropertyHelp(name);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyHelp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyPresent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isPropertyPresent00
+static int tolua_CEGUI_CEGUI_Window_isPropertyPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPropertyDefault of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isPropertyDefault00
+static int tolua_CEGUI_CEGUI_Window_isPropertyDefault00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPropertyDefault'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPropertyDefault(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPropertyDefault'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getPropertyIterator of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getPropertyIterator00
+static int tolua_CEGUI_CEGUI_Window_getPropertyIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getPropertyIterator'",NULL);
+#endif
+ {
+  CEGUI::PropertyIterator tolua_ret = (CEGUI::PropertyIterator)  ceguiLua_getPropertyIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::PropertyIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::PropertyIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::PropertyIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPropertyIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_addEvent00
+static int tolua_CEGUI_CEGUI_Window_addEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addEvent'",NULL);
+#endif
+ {
+  self->addEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeEvent00
+static int tolua_CEGUI_CEGUI_Window_removeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeEvent'",NULL);
+#endif
+ {
+  self->removeEvent(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeAllEvents of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_removeAllEvents00
+static int tolua_CEGUI_CEGUI_Window_removeAllEvents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllEvents'",NULL);
+#endif
+ {
+  self->removeAllEvents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeAllEvents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isEventPresent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isEventPresent00
+static int tolua_CEGUI_CEGUI_Window_isEventPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEventPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isEventPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isEventPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: LuaFunctorSubscribeEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_subscribeEvent00
+static int tolua_CEGUI_CEGUI_Window_subscribeEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  lua_Object funcIndex = ((lua_Object)  tolua_tovalue(tolua_S,3,0));
+  lua_Object selfIndex = ((lua_Object)  tolua_tovalue(tolua_S,4,LUA_NOREF));
+  lua_State* tolua_var_2 =  tolua_S;
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'LuaFunctorSubscribeEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+   CEGUI::EventConnection tolua_ret = (  CEGUI::EventConnection)  LuaFunctorSubscribeEvent(self,name,funcIndex,selfIndex,tolua_var_2);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'LuaFunctorSubscribeEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'subscribeEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: subscribeScriptedEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_subscribeEvent01
+static int tolua_CEGUI_CEGUI_Window_subscribeEvent01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string callback_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'subscribeScriptedEvent'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::EventConnection tolua_ret = (CEGUI::EventConnection)  self->subscribeScriptedEvent(name,callback_name);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventConnection(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventConnection));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventConnection");
+#endif
+ }
+ }
+catch(CEGUI::UnknownObjectException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::UnknownObjectException' was thrown by function 'subscribeScriptedEvent'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Window_subscribeEvent00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: fireEvent of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_fireEvent00
+static int tolua_CEGUI_CEGUI_Window_fireEvent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::EventArgs",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::EventArgs* args = ((CEGUI::EventArgs*)  tolua_tousertype(tolua_S,3,0));
+  string eventnamespace = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fireEvent'",NULL);
+#endif
+ {
+  self->fireEvent(name,*args,eventnamespace);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'fireEvent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMuted of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_isMuted00
+static int tolua_CEGUI_CEGUI_Window_isMuted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMuted'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMuted();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMuted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMutedState of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_setMutedState00
+static int tolua_CEGUI_CEGUI_Window_setMutedState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Window* self = (CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMutedState'",NULL);
+#endif
+ {
+  self->setMutedState(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMutedState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::Window */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Window_getEventIterator00
+static int tolua_CEGUI_CEGUI_Window_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* self = (const CEGUI::Window*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* x = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenX(*window,*x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'windowToScreenX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX01
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float x = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenX(*window,x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* y = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenY(*window,*y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'windowToScreenY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreenY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY01
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float y = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::windowToScreenY(*window,y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* vec = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::windowToScreen(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'windowToScreen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::windowToScreen(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::URect* rect = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::windowToScreen(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: windowToScreen of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_windowToScreen03
+static int tolua_CEGUI_CEGUI_CoordConverter_windowToScreen03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::windowToScreen(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* x = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowX(*window,*x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'screenToWindowX'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowX of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX01
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float x = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowX(*window,x);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UDim* y = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowY(*window,*y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'screenToWindowY'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindowY of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY01
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const float y = ((const float)  tolua_tonumber(tolua_S,3,0));
+ {
+  float tolua_ret = (float)  CEGUI::CoordConverter::screenToWindowY(*window,y);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::UVector2* vec = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::screenToWindow(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'screenToWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Vector2* vec = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::CoordConverter::screenToWindow(*window,*vec);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::URect* rect = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::screenToWindow(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: screenToWindow of class  CEGUI::CoordConverter */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_CoordConverter_screenToWindow03
+static int tolua_CEGUI_CEGUI_CoordConverter_screenToWindow03(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::CoordConverter",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::CoordConverter::screenToWindow(*window,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentZ of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getCurrentZ00
+static int tolua_CEGUI_CEGUI_Renderer_getCurrentZ00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentZ'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getCurrentZ();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentZ'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getZLayer of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getZLayer00
+static int tolua_CEGUI_CEGUI_Renderer_getZLayer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int layer = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getZLayer'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getZLayer(layer);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getZLayer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isQueueingEnabled of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_isQueueingEnabled00
+static int tolua_CEGUI_CEGUI_Renderer_isQueueingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isQueueingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isQueueingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isQueueingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_createTexture00
+static int tolua_CEGUI_CEGUI_Renderer_createTexture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->createTexture();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createTexture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_createTexture01
+static int tolua_CEGUI_CEGUI_Renderer_createTexture01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  float size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->createTexture(size);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Renderer_createTexture00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_createTexture02
+static int tolua_CEGUI_CEGUI_Renderer_createTexture02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createTexture'",NULL);
+#endif
+ {
+  CEGUI::Texture* tolua_ret = (CEGUI::Texture*)  self->createTexture(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Texture");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Renderer_createTexture01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyTexture of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_destroyTexture00
+static int tolua_CEGUI_CEGUI_Renderer_destroyTexture00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Texture",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Texture* tex = ((CEGUI::Texture*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyTexture'",NULL);
+#endif
+ {
+  self->destroyTexture(tex);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyTexture'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllTextures of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_destroyAllTextures00
+static int tolua_CEGUI_CEGUI_Renderer_destroyAllTextures00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Renderer* self = (CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllTextures'",NULL);
+#endif
+ {
+  self->destroyAllTextures();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllTextures'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidth of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getWidth00
+static int tolua_CEGUI_CEGUI_Renderer_getWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeight of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getHeight00
+static int tolua_CEGUI_CEGUI_Renderer_getHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSize of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getSize00
+static int tolua_CEGUI_CEGUI_Renderer_getSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRect of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getRect00
+static int tolua_CEGUI_CEGUI_Renderer_getRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getRect();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextureSize of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getMaxTextureSize00
+static int tolua_CEGUI_CEGUI_Renderer_getMaxTextureSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextureSize'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getMaxTextureSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextureSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScreenDPI of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getHorzScreenDPI00
+static int tolua_CEGUI_CEGUI_Renderer_getHorzScreenDPI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScreenDPI'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getHorzScreenDPI();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScreenDPI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScreenDPI of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getVertScreenDPI00
+static int tolua_CEGUI_CEGUI_Renderer_getVertScreenDPI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScreenDPI'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getVertScreenDPI();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScreenDPI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::Renderer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Renderer_getEventIterator00
+static int tolua_CEGUI_CEGUI_Renderer_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Renderer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Renderer* self = (const CEGUI::Renderer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindow of class  CEGUI::ScriptWindowHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScriptWindowHelper_getWindow00
+static int tolua_CEGUI_CEGUI_ScriptWindowHelper_getWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScriptWindowHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScriptWindowHelper* self = (CEGUI::ScriptWindowHelper*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindow'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getWindow(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindow of class  CEGUI::ScriptWindowHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScriptWindowHelper_getWindow01
+static int tolua_CEGUI_CEGUI_ScriptWindowHelper_getWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScriptWindowHelper",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ScriptWindowHelper* self = (CEGUI::ScriptWindowHelper*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindow'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ScriptWindowHelper_getWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getSingleton00
+static int tolua_CEGUI_CEGUI_System_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::System& tolua_ret = (CEGUI::System&)  CEGUI::System::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::System");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRenderer of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getRenderer00
+static int tolua_CEGUI_CEGUI_System_getRenderer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRenderer'",NULL);
+#endif
+ {
+  CEGUI::Renderer* tolua_ret = (CEGUI::Renderer*)  self->getRenderer();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Renderer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRenderer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultFont of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultFont00
+static int tolua_CEGUI_CEGUI_System_setDefaultFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultFont'",NULL);
+#endif
+ {
+  self->setDefaultFont(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultFont of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultFont01
+static int tolua_CEGUI_CEGUI_System_setDefaultFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultFont'",NULL);
+#endif
+ {
+  self->setDefaultFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultFont of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getDefaultFont00
+static int tolua_CEGUI_CEGUI_System_getDefaultFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDefaultFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getDefaultFont();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: signalRedraw of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_signalRedraw00
+static int tolua_CEGUI_CEGUI_System_signalRedraw00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'signalRedraw'",NULL);
+#endif
+ {
+  self->signalRedraw();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'signalRedraw'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRedrawRequested of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_isRedrawRequested00
+static int tolua_CEGUI_CEGUI_System_isRedrawRequested00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRedrawRequested'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRedrawRequested();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRedrawRequested'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renderGUI of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_renderGUI00
+static int tolua_CEGUI_CEGUI_System_renderGUI00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renderGUI'",NULL);
+#endif
+ {
+  self->renderGUI();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'renderGUI'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setGUISheet of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setGUISheet00
+static int tolua_CEGUI_CEGUI_System_setGUISheet00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* sheet = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setGUISheet'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->setGUISheet(sheet);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setGUISheet'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getGUISheet of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getGUISheet00
+static int tolua_CEGUI_CEGUI_System_getGUISheet00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getGUISheet'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getGUISheet();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getGUISheet'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSingleClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setSingleClickTimeout00
+static int tolua_CEGUI_CEGUI_System_setSingleClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  double timeout = ((double)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSingleClickTimeout'",NULL);
+#endif
+ {
+  self->setSingleClickTimeout(timeout);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSingleClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setMultiClickTimeout00
+static int tolua_CEGUI_CEGUI_System_setMultiClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  double timeout = ((double)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiClickTimeout'",NULL);
+#endif
+ {
+  self->setMultiClickTimeout(timeout);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiClickToleranceAreaSize of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setMultiClickToleranceAreaSize00
+static int tolua_CEGUI_CEGUI_System_setMultiClickToleranceAreaSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Size* sz = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiClickToleranceAreaSize'",NULL);
+#endif
+ {
+  self->setMultiClickToleranceAreaSize(*sz);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiClickToleranceAreaSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getSingleClickTimeout00
+static int tolua_CEGUI_CEGUI_System_getSingleClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSingleClickTimeout'",NULL);
+#endif
+ {
+  double tolua_ret = (double)  self->getSingleClickTimeout();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMultiClickTimeout of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getMultiClickTimeout00
+static int tolua_CEGUI_CEGUI_System_getMultiClickTimeout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMultiClickTimeout'",NULL);
+#endif
+ {
+  double tolua_ret = (double)  self->getMultiClickTimeout();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMultiClickTimeout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMultiClickToleranceAreaSize of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getMultiClickToleranceAreaSize00
+static int tolua_CEGUI_CEGUI_System_getMultiClickToleranceAreaSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMultiClickToleranceAreaSize'",NULL);
+#endif
+ {
+  const CEGUI::Size& tolua_ret = (const CEGUI::Size&)  self->getMultiClickToleranceAreaSize();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Size");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMultiClickToleranceAreaSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00
+static int tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseCursorImage image = ((CEGUI::MouseCursorImage) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultMouseCursor'",NULL);
+#endif
+ {
+  self->setDefaultMouseCursor(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01
+static int tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultMouseCursor'",NULL);
+#endif
+ {
+  self->setDefaultMouseCursor(image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultMouseCursor02
+static int tolua_CEGUI_CEGUI_System_setDefaultMouseCursor02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string imageset_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultMouseCursor'",NULL);
+#endif
+ {
+  self->setDefaultMouseCursor(imageset_name,image_name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultMouseCursor of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getDefaultMouseCursor00
+static int tolua_CEGUI_CEGUI_System_getDefaultMouseCursor00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDefaultMouseCursor'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getDefaultMouseCursor();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultMouseCursor'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindowContainingMouse of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getWindowContainingMouse00
+static int tolua_CEGUI_CEGUI_System_getWindowContainingMouse00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindowContainingMouse'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getWindowContainingMouse();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindowContainingMouse'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: executeScriptFile of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_executeScriptFile00
+static int tolua_CEGUI_CEGUI_System_executeScriptFile00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'executeScriptFile'",NULL);
+#endif
+ {
+  self->executeScriptFile(filename);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'executeScriptFile'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: executeScriptGlobal of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_executeScriptGlobal00
+static int tolua_CEGUI_CEGUI_System_executeScriptGlobal00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string global_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'executeScriptGlobal'",NULL);
+#endif
+ {
+  int tolua_ret = (int)  self->executeScriptGlobal(global_name);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'executeScriptGlobal'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: executeScriptString of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_executeScriptString00
+static int tolua_CEGUI_CEGUI_System_executeScriptString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string lua_string = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'executeScriptString'",NULL);
+#endif
+ {
+  self->executeScriptString(lua_string);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'executeScriptString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMouseMoveScaling of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getMouseMoveScaling00
+static int tolua_CEGUI_CEGUI_System_getMouseMoveScaling00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMouseMoveScaling'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMouseMoveScaling();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMouseMoveScaling'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMouseMoveScaling of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setMouseMoveScaling00
+static int tolua_CEGUI_CEGUI_System_setMouseMoveScaling00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float scaling = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMouseMoveScaling'",NULL);
+#endif
+ {
+  self->setMouseMoveScaling(scaling);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMouseMoveScaling'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: notifyWindowDestroyed of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_notifyWindowDestroyed00
+static int tolua_CEGUI_CEGUI_System_notifyWindowDestroyed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'notifyWindowDestroyed'",NULL);
+#endif
+ {
+  self->notifyWindowDestroyed(window);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'notifyWindowDestroyed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_System_isSystemKeyDown of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_isSystemKeyDown00
+static int tolua_CEGUI_CEGUI_System_isSystemKeyDown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::SystemKey k = ((CEGUI::SystemKey) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_System_isSystemKeyDown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  ceguiLua_System_isSystemKeyDown(self,k);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSystemKeyDown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultTooltip of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultTooltip00
+static int tolua_CEGUI_CEGUI_System_setDefaultTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Tooltip* tooltip = ((CEGUI::Tooltip*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultTooltip'",NULL);
+#endif
+ {
+  self->setDefaultTooltip(tooltip);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultTooltip of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_setDefaultTooltip01
+static int tolua_CEGUI_CEGUI_System_setDefaultTooltip01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  string tooltipType = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDefaultTooltip'",NULL);
+#endif
+ {
+  self->setDefaultTooltip(tooltipType);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_System_setDefaultTooltip00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultTooltip of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getDefaultTooltip00
+static int tolua_CEGUI_CEGUI_System_getDefaultTooltip00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDefaultTooltip'",NULL);
+#endif
+ {
+  CEGUI::Tooltip* tolua_ret = (CEGUI::Tooltip*)  self->getDefaultTooltip();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Tooltip");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultTooltip'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseMove of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseMove00
+static int tolua_CEGUI_CEGUI_System_injectMouseMove00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float dx = ((float)  tolua_tonumber(tolua_S,2,0));
+  float dy = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseMove'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseMove(dx,dy);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseMove'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseLeaves of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseLeaves00
+static int tolua_CEGUI_CEGUI_System_injectMouseLeaves00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseLeaves'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseLeaves();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseLeaves'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseButtonDown of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseButtonDown00
+static int tolua_CEGUI_CEGUI_System_injectMouseButtonDown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseButton btn = ((CEGUI::MouseButton) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseButtonDown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseButtonDown(btn);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseButtonDown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseButtonUp of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseButtonUp00
+static int tolua_CEGUI_CEGUI_System_injectMouseButtonUp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseButton btn = ((CEGUI::MouseButton) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseButtonUp'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseButtonUp(btn);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseButtonUp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectKeyDown of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectKeyDown00
+static int tolua_CEGUI_CEGUI_System_injectKeyDown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int keycode = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectKeyDown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectKeyDown(keycode);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectKeyDown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectKeyUp of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectKeyUp00
+static int tolua_CEGUI_CEGUI_System_injectKeyUp00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int keycode = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectKeyUp'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectKeyUp(keycode);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectKeyUp'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectChar of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectChar00
+static int tolua_CEGUI_CEGUI_System_injectChar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long code_point = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectChar'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectChar(code_point);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectChar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMouseWheelChange of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMouseWheelChange00
+static int tolua_CEGUI_CEGUI_System_injectMouseWheelChange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float delta = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMouseWheelChange'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMouseWheelChange(delta);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMouseWheelChange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectMousePosition of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectMousePosition00
+static int tolua_CEGUI_CEGUI_System_injectMousePosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float x = ((float)  tolua_tonumber(tolua_S,2,0));
+  float y = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectMousePosition'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectMousePosition(x,y);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectMousePosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: injectTimePulse of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_injectTimePulse00
+static int tolua_CEGUI_CEGUI_System_injectTimePulse00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::System",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::System* self = (CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+  float timeElapsed = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'injectTimePulse'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->injectTimePulse(timeElapsed);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'injectTimePulse'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_getEventIterator of class  CEGUI::System */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_System_getEventIterator00
+static int tolua_CEGUI_CEGUI_System_getEventIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::System",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::System* self = (const CEGUI::System*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_getEventIterator'",NULL);
+#endif
+ {
+  CEGUI::EventIterator tolua_ret = (CEGUI::EventIterator)  ceguiLua_getEventIterator(self);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::EventIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::EventIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::EventIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEventIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getSingleton00
+static int tolua_CEGUI_CEGUI_WindowManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WindowManager& tolua_ret = (CEGUI::WindowManager&)  CEGUI::WindowManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: createWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_createWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_createWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string name = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createWindow'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->createWindow(type,name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::AlreadyExistsException CEGUIDeadException(&e))
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadWindowLayout of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout00
+static int tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string name_prefix = ((string)  tolua_tocppstring(tolua_S,3,""));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,4,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadWindowLayout'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->loadWindowLayout(filename,name_prefix,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'loadWindowLayout'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'loadWindowLayout'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'loadWindowLayout'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadWindowLayout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadWindowLayout of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout01
+static int tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  bool generateRandomPrefix = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadWindowLayout'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->loadWindowLayout(filename,generateRandomPrefix);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'loadWindowLayout'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'loadWindowLayout'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'loadWindowLayout'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWindowLayoutToStream of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00
+static int tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string window = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::OutStream* out = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+  bool writeParent = ((bool)  tolua_toboolean(tolua_S,4,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWindowLayoutToStream'",NULL);
+#endif
+ {
+  self->writeWindowLayoutToStream(window,*out,writeParent);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'writeWindowLayoutToStream'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWindowLayoutToStream of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream01
+static int tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* window = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::OutStream* out = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+  bool writeParent = ((bool)  tolua_toboolean(tolua_S,4,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWindowLayoutToStream'",NULL);
+#endif
+ {
+  self->writeWindowLayoutToStream(*window,*out,writeParent);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_destroyWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_destroyWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyWindow'",NULL);
+#endif
+ {
+  self->destroyWindow(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_destroyWindow01
+static int tolua_CEGUI_CEGUI_WindowManager_destroyWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyWindow'",NULL);
+#endif
+ {
+  self->destroyWindow(window);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WindowManager_destroyWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: destroyAllWindows of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_destroyAllWindows00
+static int tolua_CEGUI_CEGUI_WindowManager_destroyAllWindows00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'destroyAllWindows'",NULL);
+#endif
+ {
+  self->destroyAllWindows();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'destroyAllWindows'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_getWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindow'",NULL);
+#endif
+ try
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getWindow(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+catch(CEGUI::UnknownObjectException CEGUIDeadException(&e))
+{
+ return 0;
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isWindowPresent of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_isWindowPresent00
+static int tolua_CEGUI_CEGUI_WindowManager_isWindowPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isWindowPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isWindowPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isWindowPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDeadPoolEmpty of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_isDeadPoolEmpty00
+static int tolua_CEGUI_CEGUI_WindowManager_isDeadPoolEmpty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDeadPoolEmpty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDeadPoolEmpty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDeadPoolEmpty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: cleanDeadPool of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_cleanDeadPool00
+static int tolua_CEGUI_CEGUI_WindowManager_cleanDeadPool00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cleanDeadPool'",NULL);
+#endif
+ {
+  self->cleanDeadPool();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cleanDeadPool'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renameWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_renameWindow00
+static int tolua_CEGUI_CEGUI_WindowManager_renameWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* window = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string new_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renameWindow'",NULL);
+#endif
+ {
+  self->renameWindow(window,new_name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'renameWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renameWindow of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_renameWindow01
+static int tolua_CEGUI_CEGUI_WindowManager_renameWindow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::WindowManager* self = (CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+  string window = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string new_name = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renameWindow'",NULL);
+#endif
+ {
+  self->renameWindow(window,new_name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WindowManager_renameWindow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getIterator00
+static int tolua_CEGUI_CEGUI_WindowManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowManager* self = (const CEGUI::WindowManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::WindowIterator tolua_ret = (CEGUI::WindowIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::WindowIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::WindowIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WindowManager_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WindowManager::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::WindowManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowManager_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WindowManager_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::WindowManager::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_windowType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_windowType
+static int tolua_get_CEGUI__FalagardWindowMapping_windowType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_windowType'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_windowType);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_windowType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_windowType
+static int tolua_set_CEGUI__FalagardWindowMapping_windowType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_windowType'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_windowType = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_lookName of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_lookName
+static int tolua_get_CEGUI__FalagardWindowMapping_lookName(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_lookName'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_lookName);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_lookName of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_lookName
+static int tolua_set_CEGUI__FalagardWindowMapping_lookName(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_lookName'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_lookName = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_baseType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_baseType
+static int tolua_get_CEGUI__FalagardWindowMapping_baseType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_baseType'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_baseType);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_baseType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_baseType
+static int tolua_set_CEGUI__FalagardWindowMapping_baseType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_baseType'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_baseType = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_rendererType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__FalagardWindowMapping_rendererType
+static int tolua_get_CEGUI__FalagardWindowMapping_rendererType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_rendererType'",NULL);
+#endif
+ tolua_pushcppstring(tolua_S,(const char*)self->d_rendererType);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_rendererType of class  CEGUI::FalagardWindowMapping */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__FalagardWindowMapping_rendererType
+static int tolua_set_CEGUI__FalagardWindowMapping_rendererType(lua_State* tolua_S)
+{
+  CEGUI::FalagardWindowMapping* self = (CEGUI::FalagardWindowMapping*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_rendererType'",NULL);
+ if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_rendererType = ((string)  tolua_tocppstring(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTypeName of class  CEGUI::WindowFactory */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactory_getTypeName00
+static int tolua_CEGUI_CEGUI_WindowFactory_getTypeName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactory",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactory* self = (const CEGUI::WindowFactory*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTypeName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTypeName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTypeName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getSingleton00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WindowFactoryManager& tolua_ret = (CEGUI::WindowFactoryManager&)  CEGUI::WindowFactoryManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WindowFactoryManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFactoryPresent of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_isFactoryPresent00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_isFactoryPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFactoryPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFactoryPresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFactoryPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addWindowTypeAlias of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_addWindowTypeAlias00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_addWindowTypeAlias00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string aliasName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string targetType = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addWindowTypeAlias'",NULL);
+#endif
+ {
+  self->addWindowTypeAlias(aliasName,targetType);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addWindowTypeAlias'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeWindowTypeAlias of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_removeWindowTypeAlias00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_removeWindowTypeAlias00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string aliasName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string targetType = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeWindowTypeAlias'",NULL);
+#endif
+ {
+  self->removeWindowTypeAlias(aliasName,targetType);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeWindowTypeAlias'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addFalagardWindowMapping of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_addFalagardWindowMapping00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_addFalagardWindowMapping00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string newType = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string targetType = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string lookName = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string renderer = ((string)  tolua_tocppstring(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addFalagardWindowMapping'",NULL);
+#endif
+ {
+  self->addFalagardWindowMapping(newType,targetType,lookName,renderer);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addFalagardWindowMapping'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeFalagardWindowMapping of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_removeFalagardWindowMapping00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_removeFalagardWindowMapping00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WindowFactoryManager* self = (CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeFalagardWindowMapping'",NULL);
+#endif
+ {
+  self->removeFalagardWindowMapping(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeFalagardWindowMapping'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFalagardMappedType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_isFalagardMappedType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_isFalagardMappedType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFalagardMappedType'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFalagardMappedType(type);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFalagardMappedType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMappedLookForType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedLookForType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedLookForType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMappedLookForType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getMappedLookForType(type);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMappedLookForType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMappedRendererForType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedRendererForType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedRendererForType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMappedRendererForType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getMappedRendererForType(type);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMappedRendererForType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDereferencedAliasType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getDereferencedAliasType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getDereferencedAliasType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDereferencedAliasType'",NULL);
+#endif
+ {
+  CEGUI::String tolua_ret = (CEGUI::String)  self->getDereferencedAliasType(type);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::String(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::String));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::String");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDereferencedAliasType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFalagardMappingForType of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingForType00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingForType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFalagardMappingForType'",NULL);
+#endif
+ {
+  const CEGUI::FalagardWindowMapping& tolua_ret = (const CEGUI::FalagardWindowMapping&)  self->getFalagardMappingForType(type);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::FalagardWindowMapping");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFalagardMappingForType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getIterator00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::WindowFactoryIterator tolua_ret = (CEGUI::WindowFactoryIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::WindowFactoryIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowFactoryIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::WindowFactoryIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::WindowFactoryIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFalagardMappingIterator of class  CEGUI::WindowFactoryManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingIterator00
+static int tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WindowFactoryManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WindowFactoryManager* self = (const CEGUI::WindowFactoryManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFalagardMappingIterator'",NULL);
+#endif
+ {
+  CEGUI::FalagardMappingIterator tolua_ret = (CEGUI::FalagardMappingIterator)  self->getFalagardMappingIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::FalagardMappingIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardMappingIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::FalagardMappingIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::FalagardMappingIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFalagardMappingIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadResources of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_loadResources00
+static int tolua_CEGUI_CEGUI_Scheme_loadResources00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scheme* self = (CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadResources'",NULL);
+#endif
+ {
+  self->loadResources();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadResources'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: unloadResources of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_unloadResources00
+static int tolua_CEGUI_CEGUI_Scheme_unloadResources00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scheme* self = (CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadResources'",NULL);
+#endif
+ {
+  self->unloadResources();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'unloadResources'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resourcesLoaded of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_resourcesLoaded00
+static int tolua_CEGUI_CEGUI_Scheme_resourcesLoaded00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scheme* self = (const CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resourcesLoaded'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->resourcesLoaded();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resourcesLoaded'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_getName00
+static int tolua_CEGUI_CEGUI_Scheme_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scheme* self = (const CEGUI::Scheme*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Scheme_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Scheme::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::Scheme */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scheme_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_Scheme_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Scheme",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::Scheme::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_getSingleton00
+static int tolua_CEGUI_CEGUI_SchemeManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::SchemeManager& tolua_ret = (CEGUI::SchemeManager&)  CEGUI::SchemeManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::SchemeManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: loadScheme of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_loadScheme00
+static int tolua_CEGUI_CEGUI_SchemeManager_loadScheme00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeManager* self = (CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourcegroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'loadScheme'",NULL);
+#endif
+ {
+  CEGUI::Scheme* tolua_ret = (CEGUI::Scheme*)  self->loadScheme(filename,resourcegroup);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scheme");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'loadScheme'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: unloadScheme of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_unloadScheme00
+static int tolua_CEGUI_CEGUI_SchemeManager_unloadScheme00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeManager* self = (CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadScheme'",NULL);
+#endif
+ {
+  self->unloadScheme(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'unloadScheme'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSchemePresent of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_isSchemePresent00
+static int tolua_CEGUI_CEGUI_SchemeManager_isSchemePresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeManager* self = (const CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSchemePresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSchemePresent(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSchemePresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getScheme of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_getScheme00
+static int tolua_CEGUI_CEGUI_SchemeManager_getScheme00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeManager* self = (const CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getScheme'",NULL);
+#endif
+ {
+  CEGUI::Scheme* tolua_ret = (CEGUI::Scheme*)  self->getScheme(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scheme");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getScheme'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: unloadAllSchemes of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_unloadAllSchemes00
+static int tolua_CEGUI_CEGUI_SchemeManager_unloadAllSchemes00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SchemeManager* self = (CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unloadAllSchemes'",NULL);
+#endif
+ {
+  self->unloadAllSchemes();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'unloadAllSchemes'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIterator of class  CEGUI::SchemeManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SchemeManager_getIterator00
+static int tolua_CEGUI_CEGUI_SchemeManager_getIterator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SchemeManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SchemeManager* self = (const CEGUI::SchemeManager*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIterator'",NULL);
+#endif
+ {
+  CEGUI::SchemeIterator tolua_ret = (CEGUI::SchemeIterator)  self->getIterator();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::SchemeIterator(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::SchemeIterator");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::SchemeIterator));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::SchemeIterator");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIterator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToFloat of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToFloat00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToFloat00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  float tolua_ret = (float)  CEGUI::PropertyHelper::stringToFloat(str);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToFloat'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToUint of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToUint00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToUint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  unsigned int tolua_ret = (unsigned int)  CEGUI::PropertyHelper::stringToUint(str);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToUint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToBool of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToBool00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToBool00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  bool tolua_ret = (bool)  CEGUI::PropertyHelper::stringToBool(str);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToBool'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToSize of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToSize00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  CEGUI::PropertyHelper::stringToSize(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToPoint of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToPoint00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToPoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Vector2 tolua_ret = (CEGUI::Vector2)  CEGUI::PropertyHelper::stringToPoint(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Vector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Vector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Vector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToPoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToRect of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToRect00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  CEGUI::PropertyHelper::stringToRect(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToImage of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToImage00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  CEGUI::PropertyHelper::stringToImage(str);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToColour of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToColour00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToColour00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::colour tolua_ret = (CEGUI::colour)  CEGUI::PropertyHelper::stringToColour(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::colour(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::colour));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::colour");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToColour'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToColourRect of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToColourRect00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  CEGUI::PropertyHelper::stringToColourRect(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToUDim of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToUDim00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToUDim00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  CEGUI::PropertyHelper::stringToUDim(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToUDim'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToUVector2 of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToUVector200
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToUVector200(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::UVector2 tolua_ret = (CEGUI::UVector2)  CEGUI::PropertyHelper::stringToUVector2(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UVector2(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UVector2));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UVector2");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToUVector2'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: stringToURect of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_stringToURect00
+static int tolua_CEGUI_CEGUI_PropertyHelper_stringToURect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string str = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::URect tolua_ret = (CEGUI::URect)  CEGUI::PropertyHelper::stringToURect(str);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::URect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::URect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::URect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::URect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'stringToURect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: floatToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_floatToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_floatToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::floatToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'floatToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: uintToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_uintToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_uintToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int val = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::uintToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'uintToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: boolToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_boolToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_boolToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  bool val = ((bool)  tolua_toboolean(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::boolToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'boolToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: sizeToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_sizeToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_sizeToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Size",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Size* val = ((const CEGUI::Size*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::sizeToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'sizeToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: pointToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_pointToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_pointToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Vector2* val = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::pointToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'pointToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: rectToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_rectToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_rectToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Rect* val = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::rectToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'rectToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: imageToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_imageToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_imageToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Image* val = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::imageToString(val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'imageToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: colourToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_colourToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_colourToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::colour* val = ((const CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::colourToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'colourToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: colourRectToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_colourRectToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_colourRectToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ColourRect* val = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::colourRectToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'colourRectToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: udimToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_udimToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_udimToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* val = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::udimToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'udimToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: uvector2ToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_uvector2ToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_uvector2ToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UVector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UVector2* val = ((const CEGUI::UVector2*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::uvector2ToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'uvector2ToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: urectToString of class  CEGUI::PropertyHelper */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyHelper_urectToString00
+static int tolua_CEGUI_CEGUI_PropertyHelper_urectToString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyHelper",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::URect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::URect* val = ((const CEGUI::URect*)  tolua_tousertype(tolua_S,2,0));
+ {
+  string tolua_ret = (string)  CEGUI::PropertyHelper::urectToString(*val);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'urectToString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_getItemCount00
+static int tolua_CEGUI_CEGUI_Tree_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  size_t tolua_ret = (size_t)  self->getItemCount();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new size_t(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"size_t");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(size_t));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"size_t");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedCount of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_getSelectedCount00
+static int tolua_CEGUI_CEGUI_Tree_getSelectedCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedCount'",NULL);
+#endif
+ {
+  size_t tolua_ret = (size_t)  self->getSelectedCount();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new size_t(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"size_t");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(size_t));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"size_t");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFirstSelectedItem of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_getFirstSelectedItem00
+static int tolua_CEGUI_CEGUI_Tree_getFirstSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFirstSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::TreeItem* tolua_ret = (CEGUI::TreeItem*)  self->getFirstSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TreeItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFirstSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLastSelectedItem of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_getLastSelectedItem00
+static int tolua_CEGUI_CEGUI_Tree_getLastSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLastSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::TreeItem* tolua_ret = (CEGUI::TreeItem*)  self->getLastSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TreeItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLastSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortEnabled of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_isSortEnabled00
+static int tolua_CEGUI_CEGUI_Tree_isSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMultiselectEnabled of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_isMultiselectEnabled00
+static int tolua_CEGUI_CEGUI_Tree_isMultiselectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMultiselectEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMultiselectEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMultiselectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemTooltipsEnabled of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_isItemTooltipsEnabled00
+static int tolua_CEGUI_CEGUI_Tree_isItemTooltipsEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemTooltipsEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemTooltipsEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemTooltipsEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findFirstItemWithText of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_findFirstItemWithText00
+static int tolua_CEGUI_CEGUI_Tree_findFirstItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findFirstItemWithText'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::TreeItem* tolua_ret = (CEGUI::TreeItem*)  self->findFirstItemWithText(text);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TreeItem");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'findFirstItemWithText'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'findFirstItemWithText'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'findFirstItemWithText'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findFirstItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findNextItemWithText of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_findNextItemWithText00
+static int tolua_CEGUI_CEGUI_Tree_findNextItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::TreeItem* start_item = ((const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findNextItemWithText'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::TreeItem* tolua_ret = (CEGUI::TreeItem*)  self->findNextItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TreeItem");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'findNextItemWithText'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'findNextItemWithText'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'findNextItemWithText'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findNextItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findFirstItemWithID of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_findFirstItemWithID00
+static int tolua_CEGUI_CEGUI_Tree_findFirstItemWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int searchID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findFirstItemWithID'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::TreeItem* tolua_ret = (CEGUI::TreeItem*)  self->findFirstItemWithID(searchID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TreeItem");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'findFirstItemWithID'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'findFirstItemWithID'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'findFirstItemWithID'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findFirstItemWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findNextItemWithID of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_findNextItemWithID00
+static int tolua_CEGUI_CEGUI_Tree_findNextItemWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int searchID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::TreeItem* start_item = ((const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findNextItemWithID'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  CEGUI::TreeItem* tolua_ret = (CEGUI::TreeItem*)  self->findNextItemWithID(searchID,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TreeItem");
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'findNextItemWithID'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'findNextItemWithID'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'findNextItemWithID'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findNextItemWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTreeItemInList of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_isTreeItemInList00
+static int tolua_CEGUI_CEGUI_Tree_isTreeItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tree* self = (const CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::TreeItem* item = ((const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTreeItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTreeItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTreeItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_resetList00
+static int tolua_CEGUI_CEGUI_Tree_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_addItem00
+static int tolua_CEGUI_CEGUI_Tree_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::TreeItem* item = ((CEGUI::TreeItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertItem of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_insertItem00
+static int tolua_CEGUI_CEGUI_Tree_insertItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::TreeItem* item = ((CEGUI::TreeItem*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::TreeItem* position = ((const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertItem'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->insertItem(item,position);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'insertItem'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'insertItem'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'insertItem'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeItem of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_removeItem00
+static int tolua_CEGUI_CEGUI_Tree_removeItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::TreeItem* item = ((const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeItem'",NULL);
+#endif
+ {
+  self->removeItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_clearAllSelections00
+static int tolua_CEGUI_CEGUI_Tree_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortingEnabled of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_setSortingEnabled00
+static int tolua_CEGUI_CEGUI_Tree_setSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortingEnabled'",NULL);
+#endif
+ {
+  self->setSortingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiselectEnabled of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_setMultiselectEnabled00
+static int tolua_CEGUI_CEGUI_Tree_setMultiselectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiselectEnabled'",NULL);
+#endif
+ {
+  self->setMultiselectEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiselectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_setItemSelectState00
+static int tolua_CEGUI_CEGUI_Tree_setItemSelectState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::TreeItem* item = ((CEGUI::TreeItem*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item,state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSelectState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_setItemSelectState01
+static int tolua_CEGUI_CEGUI_Tree_setItemSelectState01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"size_t",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  size_t item_index = *((size_t*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->setItemSelectState(item_index,state);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'setItemSelectState'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'setItemSelectState'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'setItemSelectState'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Tree_setItemSelectState00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ensureItemIsVisible of class  CEGUI::Tree */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tree_ensureItemIsVisible00
+static int tolua_CEGUI_CEGUI_Tree_ensureItemIsVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tree",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tree* self = (CEGUI::Tree*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::TreeItem* item = ((const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ensureItemIsVisible'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  self->ensureItemIsVisible(item);
+ }
+catch(CEGUI::Exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::Exception' was thrown by function 'ensureItemIsVisible'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ catch(std::exception&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'std::exception' was thrown by function 'ensureItemIsVisible'\nMessage: %s",e.what());
+ errorDoIt = true;
+}
+ catch(...)
+{
+ snprintf(errorBuffer,512,"Unknown exception thrown by function 'ensureItemIsVisible'");
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ensureItemIsVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHovering of class  CEGUI::ButtonBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ButtonBase_isHovering00
+static int tolua_CEGUI_CEGUI_ButtonBase_isHovering00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ButtonBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ButtonBase* self = (const CEGUI::ButtonBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHovering'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHovering();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHovering'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPushed of class  CEGUI::ButtonBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ButtonBase_isPushed00
+static int tolua_CEGUI_CEGUI_ButtonBase_isPushed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ButtonBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ButtonBase* self = (const CEGUI::ButtonBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPushed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPushed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPushed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::Checkbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Checkbox_isSelected00
+static int tolua_CEGUI_CEGUI_Checkbox_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Checkbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Checkbox* self = (const CEGUI::Checkbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::Checkbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Checkbox_setSelected00
+static int tolua_CEGUI_CEGUI_Checkbox_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Checkbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Checkbox* self = (CEGUI::Checkbox*)  tolua_tousertype(tolua_S,1,0);
+  bool select = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(select);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHotTracked of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_isHotTracked00
+static int tolua_CEGUI_CEGUI_Thumb_isHotTracked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Thumb* self = (const CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHotTracked'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHotTracked();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHotTracked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_isVertFree00
+static int tolua_CEGUI_CEGUI_Thumb_isVertFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Thumb* self = (const CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertFree'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertFree();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_isHorzFree00
+static int tolua_CEGUI_CEGUI_Thumb_isHorzFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Thumb* self = (const CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzFree'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzFree();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHotTracked of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setHotTracked00
+static int tolua_CEGUI_CEGUI_Thumb_setHotTracked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHotTracked'",NULL);
+#endif
+ {
+  self->setHotTracked(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHotTracked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVertFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setVertFree00
+static int tolua_CEGUI_CEGUI_Thumb_setVertFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVertFree'",NULL);
+#endif
+ {
+  self->setVertFree(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVertFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorzFree of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setHorzFree00
+static int tolua_CEGUI_CEGUI_Thumb_setHorzFree00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorzFree'",NULL);
+#endif
+ {
+  self->setHorzFree(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorzFree'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_Thumb_getVertRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_getVertRange00
+static int tolua_CEGUI_CEGUI_Thumb_getVertRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_Thumb_getVertRange'",NULL);
+#endif
+ {
+  ceguiLua_Thumb_getVertRange(self,&min,&max);
+ tolua_pushnumber(tolua_S,(lua_Number)min);
+ tolua_pushnumber(tolua_S,(lua_Number)max);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ceguiLua_Thumb_getHorzRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_getHorzRange00
+static int tolua_CEGUI_CEGUI_Thumb_getHorzRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ceguiLua_Thumb_getHorzRange'",NULL);
+#endif
+ {
+  ceguiLua_Thumb_getHorzRange(self,&min,&max);
+ tolua_pushnumber(tolua_S,(lua_Number)min);
+ tolua_pushnumber(tolua_S,(lua_Number)max);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVertRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setVertRange00
+static int tolua_CEGUI_CEGUI_Thumb_setVertRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVertRange'",NULL);
+#endif
+ {
+  self->setVertRange(min,max);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVertRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorzRange of class  CEGUI::Thumb */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Thumb_setHorzRange00
+static int tolua_CEGUI_CEGUI_Thumb_setHorzRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Thumb",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Thumb* self = (CEGUI::Thumb*)  tolua_tousertype(tolua_S,1,0);
+  float min = ((float)  tolua_tonumber(tolua_S,2,0));
+  float max = ((float)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorzRange'",NULL);
+#endif
+ {
+  self->setHorzRange(min,max);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorzRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_isSelected00
+static int tolua_CEGUI_CEGUI_RadioButton_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::RadioButton* self = (const CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_setSelected00
+static int tolua_CEGUI_CEGUI_RadioButton_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::RadioButton* self = (CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+  bool select = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(select);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getGroupID of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_getGroupID00
+static int tolua_CEGUI_CEGUI_RadioButton_getGroupID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::RadioButton* self = (const CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getGroupID'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getGroupID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getGroupID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setGroupID of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_setGroupID00
+static int tolua_CEGUI_CEGUI_RadioButton_setGroupID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::RadioButton* self = (CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long group = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setGroupID'",NULL);
+#endif
+ {
+  self->setGroupID(group);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setGroupID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedButtonInGroup of class  CEGUI::RadioButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_RadioButton_getSelectedButtonInGroup00
+static int tolua_CEGUI_CEGUI_RadioButton_getSelectedButtonInGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::RadioButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::RadioButton* self = (const CEGUI::RadioButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedButtonInGroup'",NULL);
+#endif
+ {
+  CEGUI::RadioButton* tolua_ret = (CEGUI::RadioButton*)  self->getSelectedButtonInGroup();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::RadioButton");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedButtonInGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_isSelected00
+static int tolua_CEGUI_CEGUI_TabButton_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabButton* self = (const CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_setSelected00
+static int tolua_CEGUI_CEGUI_TabButton_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabButton* self = (CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+  bool select = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(select);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTargetWindow of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_setTargetWindow00
+static int tolua_CEGUI_CEGUI_TabButton_setTargetWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabButton* self = (CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTargetWindow'",NULL);
+#endif
+ {
+  self->setTargetWindow(wnd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTargetWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTargetWindow of class  CEGUI::TabButton */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabButton_getTargetWindow00
+static int tolua_CEGUI_CEGUI_TabButton_getTargetWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabButton",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabButton* self = (CEGUI::TabButton*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTargetWindow'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTargetWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTargetWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabCount of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabCount00
+static int tolua_CEGUI_CEGUI_TabControl_getTabCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getTabCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectedTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setSelectedTab00
+static int tolua_CEGUI_CEGUI_TabControl_setSelectedTab00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectedTab'",NULL);
+#endif
+ {
+  self->setSelectedTab(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectedTab'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectedTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setSelectedTab01
+static int tolua_CEGUI_CEGUI_TabControl_setSelectedTab01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectedTab'",NULL);
+#endif
+ {
+  self->setSelectedTab(ID);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TabControl_setSelectedTab00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectedTabAtIndex of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setSelectedTabAtIndex00
+static int tolua_CEGUI_CEGUI_TabControl_setSelectedTabAtIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int index = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectedTabAtIndex'",NULL);
+#endif
+ {
+  self->setSelectedTabAtIndex(index);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectedTabAtIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabContentsAtIndex of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabContentsAtIndex00
+static int tolua_CEGUI_CEGUI_TabControl_getTabContentsAtIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int index = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabContentsAtIndex'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTabContentsAtIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabContentsAtIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabContents of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabContents00
+static int tolua_CEGUI_CEGUI_TabControl_getTabContents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabContents'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTabContents(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabContents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabContents of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabContents01
+static int tolua_CEGUI_CEGUI_TabControl_getTabContents01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabContents'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getTabContents(ID);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TabControl_getTabContents00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTabContentsSelected of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_isTabContentsSelected00
+static int tolua_CEGUI_CEGUI_TabControl_isTabContentsSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTabContentsSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTabContentsSelected(wnd);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTabContentsSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedTabIndex of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getSelectedTabIndex00
+static int tolua_CEGUI_CEGUI_TabControl_getSelectedTabIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedTabIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSelectedTabIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedTabIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabHeight of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabHeight00
+static int tolua_CEGUI_CEGUI_TabControl_getTabHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabHeight'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getTabHeight();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTabTextPadding of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_getTabTextPadding00
+static int tolua_CEGUI_CEGUI_TabControl_getTabTextPadding00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TabControl* self = (const CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTabTextPadding'",NULL);
+#endif
+ {
+  const CEGUI::UDim& tolua_ret = (const CEGUI::UDim&)  self->getTabTextPadding();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::UDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTabTextPadding'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTabHeight of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setTabHeight00
+static int tolua_CEGUI_CEGUI_TabControl_setTabHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* height = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTabHeight'",NULL);
+#endif
+ {
+  self->setTabHeight(*height);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTabHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTabTextPadding of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_setTabTextPadding00
+static int tolua_CEGUI_CEGUI_TabControl_setTabTextPadding00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::UDim* pad = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTabTextPadding'",NULL);
+#endif
+ {
+  self->setTabTextPadding(*pad);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTabTextPadding'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_addTab00
+static int tolua_CEGUI_CEGUI_TabControl_addTab00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addTab'",NULL);
+#endif
+ {
+  self->addTab(wnd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addTab'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_removeTab00
+static int tolua_CEGUI_CEGUI_TabControl_removeTab00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int ID = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeTab'",NULL);
+#endif
+ {
+  self->removeTab(ID);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeTab'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeTab of class  CEGUI::TabControl */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TabControl_removeTab01
+static int tolua_CEGUI_CEGUI_TabControl_removeTab01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TabControl",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TabControl* self = (CEGUI::TabControl*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeTab'",NULL);
+#endif
+ {
+  self->removeTab(name);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TabControl_removeTab00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDraggingEnabled of class  CEGUI::Titlebar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Titlebar_isDraggingEnabled00
+static int tolua_CEGUI_CEGUI_Titlebar_isDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Titlebar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Titlebar* self = (const CEGUI::Titlebar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDraggingEnabled of class  CEGUI::Titlebar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Titlebar_setDraggingEnabled00
+static int tolua_CEGUI_CEGUI_Titlebar_setDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Titlebar",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Titlebar* self = (CEGUI::Titlebar*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDraggingEnabled'",NULL);
+#endif
+ {
+  self->setDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getTextColours00
+static int tolua_CEGUI_CEGUI_TreeItem_getTextColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextColours'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getTextColours();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setTextColours00
+static int tolua_CEGUI_CEGUI_TreeItem_setTextColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ColourRect* cols = ((CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setTextColours01
+static int tolua_CEGUI_CEGUI_TreeItem_setTextColours01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour top_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::colour top_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::colour bottom_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  CEGUI::colour bottom_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(top_left_colour,top_right_colour,bottom_left_colour,bottom_right_colour);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TreeItem_setTextColours00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setTextColours02
+static int tolua_CEGUI_CEGUI_TreeItem_setTextColours02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour col = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(col);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TreeItem_setTextColours01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getText of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getText00
+static int tolua_CEGUI_CEGUI_TreeItem_getText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTooltipText of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getTooltipText00
+static int tolua_CEGUI_CEGUI_TreeItem_getTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTooltipText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTooltipText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getID of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getID00
+static int tolua_CEGUI_CEGUI_TreeItem_getID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUserData of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getUserData00
+static int tolua_CEGUI_CEGUI_TreeItem_getUserData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUserData'",NULL);
+#endif
+ {
+  void* tolua_ret = (void*)  self->getUserData();
+ tolua_pushuserdata(tolua_S,(void*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUserData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_isSelected00
+static int tolua_CEGUI_CEGUI_TreeItem_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDisabled of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_isDisabled00
+static int tolua_CEGUI_CEGUI_TreeItem_isDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDisabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDisabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoDeleted of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_isAutoDeleted00
+static int tolua_CEGUI_CEGUI_TreeItem_isAutoDeleted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoDeleted'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoDeleted();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoDeleted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOwnerWindow of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getOwnerWindow00
+static int tolua_CEGUI_CEGUI_TreeItem_getOwnerWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOwnerWindow'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getOwnerWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOwnerWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getSelectionColours00
+static int tolua_CEGUI_CEGUI_TreeItem_getSelectionColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TreeItem* self = (const CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionColours'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getSelectionColours();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setText of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setText00
+static int tolua_CEGUI_CEGUI_TreeItem_setText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setText'",NULL);
+#endif
+ {
+  self->setText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTooltipText of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setTooltipText00
+static int tolua_CEGUI_CEGUI_TreeItem_setTooltipText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTooltipText'",NULL);
+#endif
+ {
+  self->setTooltipText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTooltipText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserData of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setUserData00
+static int tolua_CEGUI_CEGUI_TreeItem_setUserData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isuserdata(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  void* item_data = ((void*)  tolua_touserdata(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserData'",NULL);
+#endif
+ {
+  self->setUserData(item_data);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setSelected00
+static int tolua_CEGUI_CEGUI_TreeItem_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDisabled of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setDisabled00
+static int tolua_CEGUI_CEGUI_TreeItem_setDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDisabled'",NULL);
+#endif
+ {
+  self->setDisabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoDeleted of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setAutoDeleted00
+static int tolua_CEGUI_CEGUI_TreeItem_setAutoDeleted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoDeleted'",NULL);
+#endif
+ {
+  self->setAutoDeleted(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoDeleted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setSelectionColours00
+static int tolua_CEGUI_CEGUI_TreeItem_setSelectionColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ColourRect* cols = ((CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setSelectionColours01
+static int tolua_CEGUI_CEGUI_TreeItem_setSelectionColours01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour top_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::colour top_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::colour bottom_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  CEGUI::colour bottom_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(top_left_colour,top_right_colour,bottom_left_colour,bottom_right_colour);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TreeItem_setSelectionColours00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setSelectionColours02
+static int tolua_CEGUI_CEGUI_TreeItem_setSelectionColours02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour col = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(col);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_TreeItem_setSelectionColours01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getIsOpen of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getIsOpen00
+static int tolua_CEGUI_CEGUI_TreeItem_getIsOpen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getIsOpen'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->getIsOpen();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getIsOpen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toggleIsOpen of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_toggleIsOpen00
+static int tolua_CEGUI_CEGUI_TreeItem_toggleIsOpen00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toggleIsOpen'",NULL);
+#endif
+ {
+  self->toggleIsOpen();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toggleIsOpen'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_getItemCount00
+static int tolua_CEGUI_CEGUI_TreeItem_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  size_t tolua_ret = (size_t)  self->getItemCount();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new size_t(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"size_t");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(size_t));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"size_t");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_addItem00
+static int tolua_CEGUI_CEGUI_TreeItem_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::TreeItem* item = ((CEGUI::TreeItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setIcon of class  CEGUI::TreeItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TreeItem_setIcon00
+static int tolua_CEGUI_CEGUI_TreeItem_setIcon00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TreeItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TreeItem* self = (CEGUI::TreeItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Image* icon = ((CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setIcon'",NULL);
+#endif
+ {
+  self->setIcon(*icon);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setIcon'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSizingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isSizingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFrameEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isFrameEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isFrameEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFrameEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFrameEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFrameEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTitleBarEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isTitleBarEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isTitleBarEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTitleBarEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTitleBarEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTitleBarEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isCloseButtonEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isCloseButtonEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isCloseButtonEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isCloseButtonEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isCloseButtonEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isCloseButtonEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRollupEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isRollupEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isRollupEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRollupEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRollupEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRollupEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isRolledup of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isRolledup00
+static int tolua_CEGUI_CEGUI_FrameWindow_isRolledup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isRolledup'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isRolledup();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isRolledup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDragMovingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_isDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_isDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDragMovingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDragMovingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSizingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setSizingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSizingEnabled'",NULL);
+#endif
+ {
+  self->setSizingEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFrameEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setFrameEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setFrameEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFrameEnabled'",NULL);
+#endif
+ {
+  self->setFrameEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFrameEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTitleBarEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setTitleBarEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setTitleBarEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTitleBarEnabled'",NULL);
+#endif
+ {
+  self->setTitleBarEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTitleBarEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCloseButtonEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setCloseButtonEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setCloseButtonEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCloseButtonEnabled'",NULL);
+#endif
+ {
+  self->setCloseButtonEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCloseButtonEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRollupEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setRollupEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setRollupEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRollupEnabled'",NULL);
+#endif
+ {
+  self->setRollupEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRollupEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragMovingEnabled of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_FrameWindow_setDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  bool enabled = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragMovingEnabled'",NULL);
+#endif
+ {
+  self->setDragMovingEnabled(enabled);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSizingBorderThickness of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_getSizingBorderThickness00
+static int tolua_CEGUI_CEGUI_FrameWindow_getSizingBorderThickness00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameWindow* self = (const CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSizingBorderThickness'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getSizingBorderThickness();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSizingBorderThickness'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSizingBorderThickness of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_setSizingBorderThickness00
+static int tolua_CEGUI_CEGUI_FrameWindow_setSizingBorderThickness00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  float pixels = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSizingBorderThickness'",NULL);
+#endif
+ {
+  self->setSizingBorderThickness(pixels);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSizingBorderThickness'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: toggleRollup of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_toggleRollup00
+static int tolua_CEGUI_CEGUI_FrameWindow_toggleRollup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'toggleRollup'",NULL);
+#endif
+ {
+  self->toggleRollup();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'toggleRollup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: offsetPixelPosition of class  CEGUI::FrameWindow */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameWindow_offsetPixelPosition00
+static int tolua_CEGUI_CEGUI_FrameWindow_offsetPixelPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameWindow",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Vector2",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameWindow* self = (CEGUI::FrameWindow*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Vector2* offset = ((const CEGUI::Vector2*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'offsetPixelPosition'",NULL);
+#endif
+ {
+  self->offsetPixelPosition(*offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offsetPixelPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTargetWindow of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setTargetWindow00
+static int tolua_CEGUI_CEGUI_Tooltip_setTargetWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* wnd = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTargetWindow'",NULL);
+#endif
+ {
+  self->setTargetWindow(wnd);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTargetWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetTimer of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_resetTimer00
+static int tolua_CEGUI_CEGUI_Tooltip_resetTimer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetTimer'",NULL);
+#endif
+ {
+  self->resetTimer();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetTimer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHoverTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_getHoverTime00
+static int tolua_CEGUI_CEGUI_Tooltip_getHoverTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tooltip* self = (const CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHoverTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHoverTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHoverTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDisplayTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setDisplayTime00
+static int tolua_CEGUI_CEGUI_Tooltip_setDisplayTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  float seconds = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDisplayTime'",NULL);
+#endif
+ {
+  self->setDisplayTime(seconds);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDisplayTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFadeTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_getFadeTime00
+static int tolua_CEGUI_CEGUI_Tooltip_getFadeTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tooltip* self = (const CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFadeTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFadeTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFadeTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHoverTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setHoverTime00
+static int tolua_CEGUI_CEGUI_Tooltip_setHoverTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  float seconds = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHoverTime'",NULL);
+#endif
+ {
+  self->setHoverTime(seconds);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHoverTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDisplayTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_getDisplayTime00
+static int tolua_CEGUI_CEGUI_Tooltip_getDisplayTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Tooltip* self = (const CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDisplayTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getDisplayTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDisplayTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFadeTime of class  CEGUI::Tooltip */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Tooltip_setFadeTime00
+static int tolua_CEGUI_CEGUI_Tooltip_setFadeTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Tooltip",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Tooltip* self = (CEGUI::Tooltip*)  tolua_tousertype(tolua_S,1,0);
+  float seconds = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFadeTime'",NULL);
+#endif
+ {
+  self->setFadeTime(seconds);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFadeTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDraggingEnabled of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_isDraggingEnabled00
+static int tolua_CEGUI_CEGUI_DragContainer_isDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDraggingEnabled of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDraggingEnabled00
+static int tolua_CEGUI_CEGUI_DragContainer_setDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDraggingEnabled'",NULL);
+#endif
+ {
+  self->setDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isBeingDragged of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_isBeingDragged00
+static int tolua_CEGUI_CEGUI_DragContainer_isBeingDragged00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isBeingDragged'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isBeingDragged();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isBeingDragged'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelDragThreshold of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getPixelDragThreshold00
+static int tolua_CEGUI_CEGUI_DragContainer_getPixelDragThreshold00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelDragThreshold'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPixelDragThreshold();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelDragThreshold'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPixelDragThreshold of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setPixelDragThreshold00
+static int tolua_CEGUI_CEGUI_DragContainer_setPixelDragThreshold00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  float pixels = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPixelDragThreshold'",NULL);
+#endif
+ {
+  self->setPixelDragThreshold(pixels);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPixelDragThreshold'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDragAlpha of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getDragAlpha00
+static int tolua_CEGUI_CEGUI_DragContainer_getDragAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDragAlpha'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getDragAlpha();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDragAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragAlpha of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragAlpha00
+static int tolua_CEGUI_CEGUI_DragContainer_setDragAlpha00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  float alpha = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragAlpha'",NULL);
+#endif
+ {
+  self->setDragAlpha(alpha);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragAlpha'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getDragCursorImage00
+static int tolua_CEGUI_CEGUI_DragContainer_getDragCursorImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDragCursorImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getDragCursorImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDragCursorImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00
+static int tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MouseCursorImage image = ((CEGUI::MouseCursorImage) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragCursorImage'",NULL);
+#endif
+ {
+  self->setDragCursorImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragCursorImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01
+static int tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragCursorImage'",NULL);
+#endif
+ {
+  self->setDragCursorImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragCursorImage of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage02
+static int tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::DragContainer* self = (CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragCursorImage'",NULL);
+#endif
+ {
+  self->setDragCursorImage(image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentDropTarget of class  CEGUI::DragContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_DragContainer_getCurrentDropTarget00
+static int tolua_CEGUI_CEGUI_DragContainer_getCurrentDropTarget00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::DragContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::DragContainer* self = (const CEGUI::DragContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentDropTarget'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getCurrentDropTarget();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentDropTarget'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDocumentSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getDocumentSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getDocumentSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDocumentSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getDocumentSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDocumentSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPageSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getPageSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getPageSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPageSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPageSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPageSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStepSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getStepSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOverlapSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getOverlapSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_getOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOverlapSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getOverlapSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getScrollPosition of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_getScrollPosition00
+static int tolua_CEGUI_CEGUI_Scrollbar_getScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Scrollbar* self = (const CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getScrollPosition'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getScrollPosition();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDocumentSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setDocumentSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setDocumentSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float document_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDocumentSize'",NULL);
+#endif
+ {
+  self->setDocumentSize(document_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDocumentSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPageSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setPageSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setPageSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float page_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPageSize'",NULL);
+#endif
+ {
+  self->setPageSize(page_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPageSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setStepSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setStepSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float step_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setStepSize'",NULL);
+#endif
+ {
+  self->setStepSize(step_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverlapSize of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setOverlapSize00
+static int tolua_CEGUI_CEGUI_Scrollbar_setOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float overlap_size = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverlapSize'",NULL);
+#endif
+ {
+  self->setOverlapSize(overlap_size);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setScrollPosition of class  CEGUI::Scrollbar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Scrollbar_setScrollPosition00
+static int tolua_CEGUI_CEGUI_Scrollbar_setScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Scrollbar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Scrollbar* self = (CEGUI::Scrollbar*)  tolua_tousertype(tolua_S,1,0);
+  float position = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setScrollPosition'",NULL);
+#endif
+ {
+  self->setScrollPosition(position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isContentPaneAutoSized of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_isContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_isContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledContainer* self = (const CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isContentPaneAutoSized'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isContentPaneAutoSized();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentPaneAutoSized of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_setContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_setContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledContainer* self = (CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentPaneAutoSized'",NULL);
+#endif
+ {
+  self->setContentPaneAutoSized(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentArea of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_getContentArea00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_getContentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledContainer* self = (const CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentArea'",NULL);
+#endif
+ {
+  const CEGUI::Rect& tolua_ret = (const CEGUI::Rect&)  self->getContentArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentArea of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_setContentArea00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_setContentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledContainer* self = (CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentArea'",NULL);
+#endif
+ {
+  self->setContentArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getChildExtentsArea of class  CEGUI::ScrolledContainer */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledContainer_getChildExtentsArea00
+static int tolua_CEGUI_CEGUI_ScrolledContainer_getChildExtentsArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledContainer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledContainer* self = (const CEGUI::ScrolledContainer*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getChildExtentsArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getChildExtentsArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getChildExtentsArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentPane of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getContentPane00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getContentPane00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentPane'",NULL);
+#endif
+ {
+  const CEGUI::ScrolledContainer* tolua_ret = (const CEGUI::ScrolledContainer*)  self->getContentPane();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::ScrolledContainer");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentPane'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrollablePane_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrollablePane_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isContentPaneAutoSized of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_isContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrollablePane_isContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isContentPaneAutoSized'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isContentPaneAutoSized();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentPaneAutoSized of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneAutoSized00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneAutoSized00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentPaneAutoSized'",NULL);
+#endif
+ {
+  self->setContentPaneAutoSized(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentPaneAutoSized'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentPaneArea of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getContentPaneArea00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getContentPaneArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentPaneArea'",NULL);
+#endif
+ {
+  const CEGUI::Rect& tolua_ret = (const CEGUI::Rect&)  self->getContentPaneArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Rect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentPaneArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setContentPaneArea of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneArea00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Rect* area = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setContentPaneArea'",NULL);
+#endif
+ {
+  self->setContentPaneArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setContentPaneArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHorizontalStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalStepSize'",NULL);
+#endif
+ {
+  self->setHorizontalStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalOverlapSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHorizontalOverlapSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float overlap = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalOverlapSize'",NULL);
+#endif
+ {
+  self->setHorizontalOverlapSize(overlap);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalScrollPosition'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHorizontalScrollPosition();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float position = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalScrollPosition'",NULL);
+#endif
+ {
+  self->setHorizontalScrollPosition(position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVerticalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVerticalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getVerticalStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalStepSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setVerticalStepSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setVerticalStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalStepSize'",NULL);
+#endif
+ {
+  self->setVerticalStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVerticalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVerticalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalOverlapSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getVerticalOverlapSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalOverlapSize of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setVerticalOverlapSize00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setVerticalOverlapSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float overlap = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalOverlapSize'",NULL);
+#endif
+ {
+  self->setVerticalOverlapSize(overlap);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalOverlapSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVerticalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVerticalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalScrollPosition'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getVerticalScrollPosition();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalScrollPosition of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_setVerticalScrollPosition00
+static int tolua_CEGUI_CEGUI_ScrollablePane_setVerticalScrollPosition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrollablePane* self = (CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+  float position = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalScrollPosition'",NULL);
+#endif
+ {
+  self->setVerticalScrollPosition(position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalScrollPosition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getViewableArea of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getViewableArea00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getViewableArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getViewableArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getViewableArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getViewableArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::ScrollablePane */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrollablePane_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrollablePane_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrollablePane",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrollablePane* self = (const CEGUI::ScrollablePane*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_getCurrentValue00
+static int tolua_CEGUI_CEGUI_Slider_getCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Slider* self = (const CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getCurrentValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_getMaxValue00
+static int tolua_CEGUI_CEGUI_Slider_getMaxValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Slider* self = (const CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMaxValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getClickStep of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_getClickStep00
+static int tolua_CEGUI_CEGUI_Slider_getClickStep00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Slider* self = (const CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getClickStep'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getClickStep();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getClickStep'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_setMaxValue00
+static int tolua_CEGUI_CEGUI_Slider_setMaxValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Slider* self = (CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+  float maxVal = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxValue'",NULL);
+#endif
+ {
+  self->setMaxValue(maxVal);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCurrentValue of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_setCurrentValue00
+static int tolua_CEGUI_CEGUI_Slider_setCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Slider* self = (CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+  float value = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCurrentValue'",NULL);
+#endif
+ {
+  self->setCurrentValue(value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClickStep of class  CEGUI::Slider */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Slider_setClickStep00
+static int tolua_CEGUI_CEGUI_Slider_setClickStep00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Slider",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Slider* self = (CEGUI::Slider*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClickStep'",NULL);
+#endif
+ {
+  self->setClickStep(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClickStep'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCurrentValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getCurrentValue00
+static int tolua_CEGUI_CEGUI_Spinner_getCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCurrentValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getCurrentValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStepSize of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getStepSize00
+static int tolua_CEGUI_CEGUI_Spinner_getStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStepSize'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getStepSize();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaximumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getMaximumValue00
+static int tolua_CEGUI_CEGUI_Spinner_getMaximumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaximumValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMaximumValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaximumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMinimumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getMinimumValue00
+static int tolua_CEGUI_CEGUI_Spinner_getMinimumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMinimumValue'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getMinimumValue();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMinimumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextInputMode of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_getTextInputMode00
+static int tolua_CEGUI_CEGUI_Spinner_getTextInputMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Spinner* self = (const CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextInputMode'",NULL);
+#endif
+ {
+  CEGUI::Spinner::TextInputMode tolua_ret = (CEGUI::Spinner::TextInputMode)  self->getTextInputMode();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextInputMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCurrentValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setCurrentValue00
+static int tolua_CEGUI_CEGUI_Spinner_setCurrentValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float value = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCurrentValue'",NULL);
+#endif
+ {
+  self->setCurrentValue(value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCurrentValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setStepSize of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setStepSize00
+static int tolua_CEGUI_CEGUI_Spinner_setStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setStepSize'",NULL);
+#endif
+ {
+  self->setStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaximumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setMaximumValue00
+static int tolua_CEGUI_CEGUI_Spinner_setMaximumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float maxValue = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaximumValue'",NULL);
+#endif
+ {
+  self->setMaximumValue(maxValue);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaximumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMinimumValue of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setMinimumValue00
+static int tolua_CEGUI_CEGUI_Spinner_setMinimumValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  float minVaue = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMinimumValue'",NULL);
+#endif
+ {
+  self->setMinimumValue(minVaue);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMinimumValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextInputMode of class  CEGUI::Spinner */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Spinner_setTextInputMode00
+static int tolua_CEGUI_CEGUI_Spinner_setTextInputMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Spinner",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Spinner* self = (CEGUI::Spinner*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Spinner::TextInputMode mode = ((CEGUI::Spinner::TextInputMode) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextInputMode'",NULL);
+#endif
+ {
+  self->setTextInputMode(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextInputMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getProgress of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_getProgress00
+static int tolua_CEGUI_CEGUI_ProgressBar_getProgress00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ProgressBar* self = (const CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getProgress'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getProgress();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getProgress'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStep of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_getStep00
+static int tolua_CEGUI_CEGUI_ProgressBar_getStep00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ProgressBar* self = (const CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStep'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getStep();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStep'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setProgress of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_setProgress00
+static int tolua_CEGUI_CEGUI_ProgressBar_setProgress00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+  float progress = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setProgress'",NULL);
+#endif
+ {
+  self->setProgress(progress);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setProgress'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setStepSize of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_setStepSize00
+static int tolua_CEGUI_CEGUI_ProgressBar_setStepSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+  float step = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setStepSize'",NULL);
+#endif
+ {
+  self->setStepSize(step);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setStepSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: step of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_step00
+static int tolua_CEGUI_CEGUI_ProgressBar_step00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'step'",NULL);
+#endif
+ {
+  self->step();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'step'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: adjustProgress of class  CEGUI::ProgressBar */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ProgressBar_adjustProgress00
+static int tolua_CEGUI_CEGUI_ProgressBar_adjustProgress00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ProgressBar",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ProgressBar* self = (CEGUI::ProgressBar*)  tolua_tousertype(tolua_S,1,0);
+  float delta = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'adjustProgress'",NULL);
+#endif
+ {
+  self->adjustProgress(delta);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'adjustProgress'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hasInputFocus of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_hasInputFocus00
+static int tolua_CEGUI_CEGUI_Editbox_hasInputFocus00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hasInputFocus'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->hasInputFocus();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hasInputFocus'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isReadOnly of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_isReadOnly00
+static int tolua_CEGUI_CEGUI_Editbox_isReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isReadOnly'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isReadOnly();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextMasked of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_isTextMasked00
+static int tolua_CEGUI_CEGUI_Editbox_isTextMasked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextMasked'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextMasked();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextMasked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextValid of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_isTextValid00
+static int tolua_CEGUI_CEGUI_Editbox_isTextValid00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextValid'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextValid();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextValid'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValidationString of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getValidationString00
+static int tolua_CEGUI_CEGUI_Editbox_getValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValidationString'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getValidationString();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaratIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getCaratIndex00
+static int tolua_CEGUI_CEGUI_Editbox_getCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCaratIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCaratIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionStartIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getSelectionStartIndex00
+static int tolua_CEGUI_CEGUI_Editbox_getSelectionStartIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionStartIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionStartIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionStartIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionEndIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getSelectionEndIndex00
+static int tolua_CEGUI_CEGUI_Editbox_getSelectionEndIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionEndIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionEndIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionEndIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionLength of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getSelectionLength00
+static int tolua_CEGUI_CEGUI_Editbox_getSelectionLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaskCodePoint of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getMaskCodePoint00
+static int tolua_CEGUI_CEGUI_Editbox_getMaskCodePoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaskCodePoint'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaskCodePoint();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaskCodePoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextLength of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_getMaxTextLength00
+static int tolua_CEGUI_CEGUI_Editbox_getMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Editbox* self = (const CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaxTextLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setReadOnly of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setReadOnly00
+static int tolua_CEGUI_CEGUI_Editbox_setReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setReadOnly'",NULL);
+#endif
+ {
+  self->setReadOnly(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextMasked of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setTextMasked00
+static int tolua_CEGUI_CEGUI_Editbox_setTextMasked00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextMasked'",NULL);
+#endif
+ {
+  self->setTextMasked(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextMasked'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setValidationString of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setValidationString00
+static int tolua_CEGUI_CEGUI_Editbox_setValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  string validation_string = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setValidationString'",NULL);
+#endif
+ {
+  self->setValidationString(validation_string);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCaratIndex of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setCaratIndex00
+static int tolua_CEGUI_CEGUI_Editbox_setCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long carat_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCaratIndex'",NULL);
+#endif
+ {
+  self->setCaratIndex(carat_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelection of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setSelection00
+static int tolua_CEGUI_CEGUI_Editbox_setSelection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long end_pos = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelection'",NULL);
+#endif
+ {
+  self->setSelection(start_pos,end_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaskCodePoint of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setMaskCodePoint00
+static int tolua_CEGUI_CEGUI_Editbox_setMaskCodePoint00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long code_point = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaskCodePoint'",NULL);
+#endif
+ {
+  self->setMaskCodePoint(code_point);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaskCodePoint'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxTextLength of class  CEGUI::Editbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Editbox_setMaxTextLength00
+static int tolua_CEGUI_CEGUI_Editbox_setMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Editbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Editbox* self = (CEGUI::Editbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long max_len = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxTextLength'",NULL);
+#endif
+ {
+  self->setMaxTextLength(max_len);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hasInputFocus of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_hasInputFocus00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_hasInputFocus00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hasInputFocus'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->hasInputFocus();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hasInputFocus'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isReadOnly of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_isReadOnly00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_isReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isReadOnly'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isReadOnly();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaratIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getCaratIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCaratIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCaratIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionStartIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionStartIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionStartIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionStartIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionStartIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionStartIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionEndIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionEndIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionEndIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionEndIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionEndIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionEndIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionLength of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionLength00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextLength of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getMaxTextLength00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaxTextLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isWordWrapped of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_isWordWrapped00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_isWordWrapped00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isWordWrapped'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isWordWrapped();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isWordWrapped'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextRenderArea of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getTextRenderArea00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getTextRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getTextRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLineNumberFromIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getLineNumberFromIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getLineNumberFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLineNumberFromIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getLineNumberFromIndex(index);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLineNumberFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setReadOnly of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setReadOnly00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setReadOnly'",NULL);
+#endif
+ {
+  self->setReadOnly(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCaratIndex of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setCaratIndex00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long carat_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCaratIndex'",NULL);
+#endif
+ {
+  self->setCaratIndex(carat_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelection of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setSelection00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setSelection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long end_pos = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelection'",NULL);
+#endif
+ {
+  self->setSelection(start_pos,end_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxTextLength of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setMaxTextLength00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long max_len = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxTextLength'",NULL);
+#endif
+ {
+  self->setMaxTextLength(max_len);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ensureCaratIsVisible of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_ensureCaratIsVisible00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_ensureCaratIsVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ensureCaratIsVisible'",NULL);
+#endif
+ {
+  self->ensureCaratIsVisible();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ensureCaratIsVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWordWrapping of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setWordWrapping00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setWordWrapping00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWordWrapping'",NULL);
+#endif
+ {
+  self->setWordWrapping(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWordWrapping'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionBrushImage of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_setSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_setSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiLineEditbox* self = (CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionBrushImage'",NULL);
+#endif
+ {
+  self->setSelectionBrushImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionBrushImage of class  CEGUI::MultiLineEditbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiLineEditbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiLineEditbox* self = (const CEGUI::MultiLineEditbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionBrushImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getSelectionBrushImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getText of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getText00
+static int tolua_CEGUI_CEGUI_ListboxItem_getText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getID of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getID00
+static int tolua_CEGUI_CEGUI_ListboxItem_getID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getUserData of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getUserData00
+static int tolua_CEGUI_CEGUI_ListboxItem_getUserData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUserData'",NULL);
+#endif
+ {
+  void* tolua_ret = (void*)  self->getUserData();
+ tolua_pushuserdata(tolua_S,(void*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getUserData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_isSelected00
+static int tolua_CEGUI_CEGUI_ListboxItem_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDisabled of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_isDisabled00
+static int tolua_CEGUI_CEGUI_ListboxItem_isDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDisabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDisabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoDeleted of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_isAutoDeleted00
+static int tolua_CEGUI_CEGUI_ListboxItem_isAutoDeleted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoDeleted'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoDeleted();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoDeleted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOwnerWindow of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getOwnerWindow00
+static int tolua_CEGUI_CEGUI_ListboxItem_getOwnerWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOwnerWindow'",NULL);
+#endif
+ {
+  const CEGUI::Window* tolua_ret = (const CEGUI::Window*)  self->getOwnerWindow();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOwnerWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getSelectionColours00
+static int tolua_CEGUI_CEGUI_ListboxItem_getSelectionColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionColours'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getSelectionColours();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionBrushImage of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_ListboxItem_getSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionBrushImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getSelectionBrushImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setText of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setText00
+static int tolua_CEGUI_CEGUI_ListboxItem_setText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setText'",NULL);
+#endif
+ {
+  self->setText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setID of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setID00
+static int tolua_CEGUI_CEGUI_ListboxItem_setID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int item_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setID'",NULL);
+#endif
+ {
+  self->setID(item_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserData of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setUserData00
+static int tolua_CEGUI_CEGUI_ListboxItem_setUserData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isuserdata(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  void* item_data = ((void*)  tolua_touserdata(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserData'",NULL);
+#endif
+ {
+  self->setUserData(item_data);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelected00
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDisabled of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setDisabled00
+static int tolua_CEGUI_CEGUI_ListboxItem_setDisabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDisabled'",NULL);
+#endif
+ {
+  self->setDisabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDisabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoDeleted of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setAutoDeleted00
+static int tolua_CEGUI_CEGUI_ListboxItem_setAutoDeleted00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoDeleted'",NULL);
+#endif
+ {
+  self->setAutoDeleted(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoDeleted'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOwnerWindow of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setOwnerWindow00
+static int tolua_CEGUI_CEGUI_ListboxItem_setOwnerWindow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* owner = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOwnerWindow'",NULL);
+#endif
+ {
+  self->setOwnerWindow(owner);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOwnerWindow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour top_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::colour top_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::colour bottom_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  CEGUI::colour bottom_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(top_left_colour,top_right_colour,bottom_left_colour,bottom_right_colour);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionColours of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours02
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour col = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionColours'",NULL);
+#endif
+ {
+  self->setSelectionColours(col);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionBrushImage of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionBrushImage'",NULL);
+#endif
+ {
+  self->setSelectionBrushImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionBrushImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionBrushImage of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage01
+static int tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxItem* self = (CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionBrushImage'",NULL);
+#endif
+ {
+  self->setSelectionBrushImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelSize of class  CEGUI::ListboxItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxItem_getPixelSize00
+static int tolua_CEGUI_CEGUI_ListboxItem_getPixelSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxItem* self = (const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getPixelSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_getFont00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxTextItem* self = (const CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  CEGUI::Font* tolua_ret = (CEGUI::Font*)  self->getFont();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Font");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_getTextColours00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_getTextColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListboxTextItem* self = (const CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextColours'",NULL);
+#endif
+ {
+  CEGUI::ColourRect tolua_ret = (CEGUI::ColourRect)  self->getTextColours();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::ColourRect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::ColourRect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::ColourRect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setFont00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  string font_name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font_name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setFont01
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setFont01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Font* font = ((CEGUI::Font*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxTextItem_setFont00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour top_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::colour top_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,3,0));
+  CEGUI::colour bottom_left_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,4,0));
+  CEGUI::colour bottom_right_colour = *((CEGUI::colour*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(top_left_colour,top_right_colour,bottom_left_colour,bottom_right_colour);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(*cols);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextColours of class  CEGUI::ListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours02
+static int tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListboxTextItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::colour",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListboxTextItem* self = (CEGUI::ListboxTextItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::colour col = *((CEGUI::colour*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextColours'",NULL);
+#endif
+ {
+  self->setTextColours(col);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleClickEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSingleClickEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_getSingleClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSingleClickEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->getSingleClickEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDropDownListVisible of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isDropDownListVisible00
+static int tolua_CEGUI_CEGUI_Combobox_isDropDownListVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDropDownListVisible'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDropDownListVisible();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDropDownListVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getEditbox of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getEditbox00
+static int tolua_CEGUI_CEGUI_Combobox_getEditbox00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getEditbox'",NULL);
+#endif
+ {
+  CEGUI::Editbox* tolua_ret = (CEGUI::Editbox*)  self->getEditbox();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Editbox");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getEditbox'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPushButton of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getPushButton00
+static int tolua_CEGUI_CEGUI_Combobox_getPushButton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPushButton'",NULL);
+#endif
+ {
+  CEGUI::PushButton* tolua_ret = (CEGUI::PushButton*)  self->getPushButton();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PushButton");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPushButton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDropList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getDropList00
+static int tolua_CEGUI_CEGUI_Combobox_getDropList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDropList'",NULL);
+#endif
+ {
+  CEGUI::ComboDropList* tolua_ret = (CEGUI::ComboDropList*)  self->getDropList();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ComboDropList");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDropList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hasInputFocus of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_hasInputFocus00
+static int tolua_CEGUI_CEGUI_Combobox_hasInputFocus00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hasInputFocus'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->hasInputFocus();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hasInputFocus'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isReadOnly of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isReadOnly00
+static int tolua_CEGUI_CEGUI_Combobox_isReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isReadOnly'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isReadOnly();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextValid of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isTextValid00
+static int tolua_CEGUI_CEGUI_Combobox_isTextValid00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextValid'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextValid();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextValid'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValidationString of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getValidationString00
+static int tolua_CEGUI_CEGUI_Combobox_getValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValidationString'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getValidationString();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getCaratIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getCaratIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCaratIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getCaratIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionStartIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectionStartIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectionStartIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionStartIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionStartIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionStartIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionEndIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectionEndIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectionEndIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionEndIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionEndIndex();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionEndIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionLength of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectionLength00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectionLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectionLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMaxTextLength of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getMaxTextLength00
+static int tolua_CEGUI_CEGUI_Combobox_getMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMaxTextLength'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getMaxTextLength();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: activateEditbox of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_activateEditbox00
+static int tolua_CEGUI_CEGUI_Combobox_activateEditbox00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'activateEditbox'",NULL);
+#endif
+ {
+  self->activateEditbox();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'activateEditbox'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getItemCount00
+static int tolua_CEGUI_CEGUI_Combobox_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getSelectedItem00
+static int tolua_CEGUI_CEGUI_Combobox_getSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListboxItemFromIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getListboxItemFromIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getListboxItemFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListboxItemFromIndex'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getListboxItemFromIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListboxItemFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_getItemIndex00
+static int tolua_CEGUI_CEGUI_Combobox_getItemIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isItemSelected00
+static int tolua_CEGUI_CEGUI_Combobox_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(index);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findItemWithText of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_findItemWithText00
+static int tolua_CEGUI_CEGUI_Combobox_findItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isListboxItemInList00
+static int tolua_CEGUI_CEGUI_Combobox_isListboxItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_resetList00
+static int tolua_CEGUI_CEGUI_Combobox_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_addItem00
+static int tolua_CEGUI_CEGUI_Combobox_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_insertItem00
+static int tolua_CEGUI_CEGUI_Combobox_insertItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ListboxItem* position = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertItem'",NULL);
+#endif
+ {
+  self->insertItem(item,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeItem of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_removeItem00
+static int tolua_CEGUI_CEGUI_Combobox_removeItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeItem'",NULL);
+#endif
+ {
+  self->removeItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_clearAllSelections00
+static int tolua_CEGUI_CEGUI_Combobox_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortingEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setSortingEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_setSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortingEnabled'",NULL);
+#endif
+ {
+  self->setSortingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_Combobox_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_Combobox_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setItemSelectState00
+static int tolua_CEGUI_CEGUI_Combobox_setItemSelectState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item,state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSelectState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setItemSelectState01
+static int tolua_CEGUI_CEGUI_Combobox_setItemSelectState01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long item_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item_index,state);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Combobox_setItemSelectState00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedListItemData of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_handleUpdatedListItemData00
+static int tolua_CEGUI_CEGUI_Combobox_handleUpdatedListItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedListItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedListItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedListItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isSortEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_isSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Combobox_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Combobox_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Combobox* self = (const CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: showDropList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_showDropList00
+static int tolua_CEGUI_CEGUI_Combobox_showDropList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'showDropList'",NULL);
+#endif
+ {
+  self->showDropList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'showDropList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: hideDropList of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_hideDropList00
+static int tolua_CEGUI_CEGUI_Combobox_hideDropList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hideDropList'",NULL);
+#endif
+ {
+  self->hideDropList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'hideDropList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSingleClickEnabled of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setSingleClickEnabled00
+static int tolua_CEGUI_CEGUI_Combobox_setSingleClickEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSingleClickEnabled'",NULL);
+#endif
+ {
+  self->setSingleClickEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSingleClickEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setReadOnly of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setReadOnly00
+static int tolua_CEGUI_CEGUI_Combobox_setReadOnly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setReadOnly'",NULL);
+#endif
+ {
+  self->setReadOnly(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setReadOnly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setValidationString of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setValidationString00
+static int tolua_CEGUI_CEGUI_Combobox_setValidationString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  string validation_string = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setValidationString'",NULL);
+#endif
+ {
+  self->setValidationString(validation_string);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setValidationString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setCaratIndex of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setCaratIndex00
+static int tolua_CEGUI_CEGUI_Combobox_setCaratIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long carat_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCaratIndex'",NULL);
+#endif
+ {
+  self->setCaratIndex(carat_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setCaratIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelection of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setSelection00
+static int tolua_CEGUI_CEGUI_Combobox_setSelection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_pos = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long end_pos = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelection'",NULL);
+#endif
+ {
+  self->setSelection(start_pos,end_pos);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMaxTextLength of class  CEGUI::Combobox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Combobox_setMaxTextLength00
+static int tolua_CEGUI_CEGUI_Combobox_setMaxTextLength00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Combobox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Combobox* self = (CEGUI::Combobox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long max_len = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMaxTextLength'",NULL);
+#endif
+ {
+  self->setMaxTextLength(max_len);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMaxTextLength'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getItemCount00
+static int tolua_CEGUI_CEGUI_Listbox_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedCount of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getSelectedCount00
+static int tolua_CEGUI_CEGUI_Listbox_getSelectedCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectedCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFirstSelectedItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getFirstSelectedItem00
+static int tolua_CEGUI_CEGUI_Listbox_getFirstSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFirstSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getFirstSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFirstSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelected of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getNextSelected00
+static int tolua_CEGUI_CEGUI_Listbox_getNextSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelected'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getNextSelected(start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListboxItemFromIndex of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getListboxItemFromIndex00
+static int tolua_CEGUI_CEGUI_Listbox_getListboxItemFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListboxItemFromIndex'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getListboxItemFromIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListboxItemFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemIndex of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getItemIndex00
+static int tolua_CEGUI_CEGUI_Listbox_getItemIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemIndex'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getItemIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findItemWithText of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_findItemWithText00
+static int tolua_CEGUI_CEGUI_Listbox_findItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isSortEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_isSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMultiselectEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isMultiselectEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_isMultiselectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMultiselectEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMultiselectEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMultiselectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isItemSelected00
+static int tolua_CEGUI_CEGUI_Listbox_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(index);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInList of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isListboxItemInList00
+static int tolua_CEGUI_CEGUI_Listbox_isListboxItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Listbox_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_Listbox_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_resetList00
+static int tolua_CEGUI_CEGUI_Listbox_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_addItem00
+static int tolua_CEGUI_CEGUI_Listbox_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_insertItem00
+static int tolua_CEGUI_CEGUI_Listbox_insertItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ListboxItem* position = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertItem'",NULL);
+#endif
+ {
+  self->insertItem(item,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeItem of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_removeItem00
+static int tolua_CEGUI_CEGUI_Listbox_removeItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeItem'",NULL);
+#endif
+ {
+  self->removeItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_clearAllSelections00
+static int tolua_CEGUI_CEGUI_Listbox_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortingEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setSortingEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_setSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortingEnabled'",NULL);
+#endif
+ {
+  self->setSortingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiselectEnabled of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setMultiselectEnabled00
+static int tolua_CEGUI_CEGUI_Listbox_setMultiselectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiselectEnabled'",NULL);
+#endif
+ {
+  self->setMultiselectEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiselectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setItemSelectState00
+static int tolua_CEGUI_CEGUI_Listbox_setItemSelectState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item,state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSelectState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_setItemSelectState01
+static int tolua_CEGUI_CEGUI_Listbox_setItemSelectState01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long item_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item_index,state);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Listbox_setItemSelectState00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedItemData of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_handleUpdatedItemData00
+static int tolua_CEGUI_CEGUI_Listbox_handleUpdatedItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ensureItemIsVisible of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00
+static int tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long item_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ensureItemIsVisible'",NULL);
+#endif
+ {
+  self->ensureItemIsVisible(item_index);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ensureItemIsVisible'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ensureItemIsVisible of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible01
+static int tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::Listbox* self = (CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ensureItemIsVisible'",NULL);
+#endif
+ {
+  self->ensureItemIsVisible(item);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListRenderArea of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getListRenderArea00
+static int tolua_CEGUI_CEGUI_Listbox_getListRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getListRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_Listbox_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidestItemWidth of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getWidestItemWidth00
+static int tolua_CEGUI_CEGUI_Listbox_getWidestItemWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidestItemWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidestItemWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidestItemWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalItemsHeight of class  CEGUI::Listbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Listbox_getTotalItemsHeight00
+static int tolua_CEGUI_CEGUI_Listbox_getTotalItemsHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Listbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Listbox* self = (const CEGUI::Listbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalItemsHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTotalItemsHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalItemsHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArmed of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_setArmed00
+static int tolua_CEGUI_CEGUI_ComboDropList_setArmed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ComboDropList* self = (CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArmed'",NULL);
+#endif
+ {
+  self->setArmed(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setArmed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isArmed of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_isArmed00
+static int tolua_CEGUI_CEGUI_ComboDropList_isArmed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComboDropList* self = (const CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isArmed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isArmed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isArmed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoArmEnabled of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_setAutoArmEnabled00
+static int tolua_CEGUI_CEGUI_ComboDropList_setAutoArmEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ComboDropList* self = (CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoArmEnabled'",NULL);
+#endif
+ {
+  self->setAutoArmEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoArmEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoArmEnabled of class  CEGUI::ComboDropList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComboDropList_isAutoArmEnabled00
+static int tolua_CEGUI_CEGUI_ComboDropList_isAutoArmEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComboDropList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComboDropList* self = (const CEGUI::ComboDropList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoArmEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoArmEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoArmEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSizingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_isSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_isSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortDirection of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_getSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_getSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortDirection'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment::SortDirection tolua_ret = (CEGUI::ListHeaderSegment::SortDirection)  self->getSortDirection();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isDragMovingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_isDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_isDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDragMovingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isDragMovingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDragMoveOffset of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_getDragMoveOffset00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_getDragMoveOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDragMoveOffset'",NULL);
+#endif
+ {
+  const CEGUI::Vector2& tolua_ret = (const CEGUI::Vector2&)  self->getDragMoveOffset();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::Vector2");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDragMoveOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isClickable of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_isClickable00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_isClickable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeaderSegment* self = (const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isClickable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isClickable();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isClickable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSizingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSizingEnabled'",NULL);
+#endif
+ {
+  self->setSizingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortDirection of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListHeaderSegment::SortDirection sort_dir = ((CEGUI::ListHeaderSegment::SortDirection) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortDirection'",NULL);
+#endif
+ {
+  self->setSortDirection(sort_dir);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDragMovingEnabled of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setDragMovingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setDragMovingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDragMovingEnabled'",NULL);
+#endif
+ {
+  self->setDragMovingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDragMovingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClickable of class  CEGUI::ListHeaderSegment */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeaderSegment_setClickable00
+static int tolua_CEGUI_CEGUI_ListHeaderSegment_setClickable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeaderSegment* self = (CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClickable'",NULL);
+#endif
+ {
+  self->setClickable(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClickable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnCount of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnCount00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSegmentFromColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSegmentFromColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_getSegmentFromColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSegmentFromColumn'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getSegmentFromColumn(column);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSegmentFromColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSegmentFromID of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSegmentFromID00
+static int tolua_CEGUI_CEGUI_ListHeader_getSegmentFromID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSegmentFromID'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getSegmentFromID(id);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSegmentFromID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSortSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_getSortSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortSegment'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getSortSegment();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnFromSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnFromSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnFromSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnFromSegment'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnFromSegment(*segment);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnFromSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnFromID of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnFromID00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnFromID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnFromID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnFromID(id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnFromID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSortColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_getSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortColumn'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSortColumn();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWithText of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnWithText00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWithText'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnWithText(text);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelOffsetToSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelOffsetToSegment'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPixelOffsetToSegment(*segment);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelOffsetToSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelOffsetToColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelOffsetToColumn'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getPixelOffsetToColumn(column);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelOffsetToColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalSegmentsPixelExtent of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getTotalSegmentsPixelExtent00
+static int tolua_CEGUI_CEGUI_ListHeader_getTotalSegmentsPixelExtent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalSegmentsPixelExtent'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTotalSegmentsPixelExtent();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalSegmentsPixelExtent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWidth of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getColumnWidth00
+static int tolua_CEGUI_CEGUI_ListHeader_getColumnWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getColumnWidth(column);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortDirection of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeader_getSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortDirection'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment::SortDirection tolua_ret = (CEGUI::ListHeaderSegment::SortDirection)  self->getSortDirection();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_isSortingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_isSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isColumnSizingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_isColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_isColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isColumnSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isColumnSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isColumnDraggingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_isColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_isColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isColumnDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isColumnDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSegmentOffset of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_getSegmentOffset00
+static int tolua_CEGUI_CEGUI_ListHeader_getSegmentOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ListHeader* self = (const CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSegmentOffset'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getSegmentOffset();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSegmentOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortingEnabled'",NULL);
+#endif
+ {
+  self->setSortingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortDirection of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortDirection00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListHeaderSegment::SortDirection direction = ((CEGUI::ListHeaderSegment::SortDirection) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortDirection'",NULL);
+#endif
+ {
+  self->setSortDirection(direction);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortSegment'",NULL);
+#endif
+ {
+  self->setSortSegment(*segment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumn'",NULL);
+#endif
+ {
+  self->setSortColumn(column);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumnFromID of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSortColumnFromID00
+static int tolua_CEGUI_CEGUI_ListHeader_setSortColumnFromID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumnFromID'",NULL);
+#endif
+ {
+  self->setSortColumnFromID(id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumnFromID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnSizingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_setColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnSizingEnabled'",NULL);
+#endif
+ {
+  self->setColumnSizingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnDraggingEnabled of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_ListHeader_setColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnDraggingEnabled'",NULL);
+#endif
+ {
+  self->setColumnDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_addColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_addColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addColumn'",NULL);
+#endif
+ {
+  self->addColumn(text,id,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_insertColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_insertColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertColumn'",NULL);
+#endif
+ {
+  self->insertColumn(text,id,*width,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_insertColumn01
+static int tolua_CEGUI_CEGUI_ListHeader_insertColumn01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::ListHeaderSegment* position = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertColumn'",NULL);
+#endif
+ {
+  self->insertColumn(text,id,*width,*position);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListHeader_insertColumn00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_removeColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_removeColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeColumn'",NULL);
+#endif
+ {
+  self->removeColumn(column);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_removeSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_removeSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeSegment'",NULL);
+#endif
+ {
+  self->removeSegment(*segment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveColumn00
+static int tolua_CEGUI_CEGUI_ListHeader_moveColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumn'",NULL);
+#endif
+ {
+  self->moveColumn(column,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumn of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveColumn01
+static int tolua_CEGUI_CEGUI_ListHeader_moveColumn01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::ListHeaderSegment* position = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumn'",NULL);
+#endif
+ {
+  self->moveColumn(column,*position);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListHeader_moveColumn00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveSegment00
+static int tolua_CEGUI_CEGUI_ListHeader_moveSegment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveSegment'",NULL);
+#endif
+ {
+  self->moveSegment(*segment,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveSegment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveSegment of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_moveSegment01
+static int tolua_CEGUI_CEGUI_ListHeader_moveSegment01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListHeaderSegment",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListHeaderSegment* segment = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ListHeaderSegment* position = ((const CEGUI::ListHeaderSegment*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveSegment'",NULL);
+#endif
+ {
+  self->moveSegment(*segment,*position);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ListHeader_moveSegment00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSegmentOffset of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setSegmentOffset00
+static int tolua_CEGUI_CEGUI_ListHeader_setSegmentOffset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  float offset = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSegmentOffset'",NULL);
+#endif
+ {
+  self->setSegmentOffset(offset);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSegmentOffset'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnWidth of class  CEGUI::ListHeader */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ListHeader_setColumnWidth00
+static int tolua_CEGUI_CEGUI_ListHeader_setColumnWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ListHeader",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ListHeader* self = (CEGUI::ListHeader*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int column = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnWidth'",NULL);
+#endif
+ {
+  self->setColumnWidth(column,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: row of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MCLGridRef_unsigned_row
+static int tolua_get_CEGUI__MCLGridRef_unsigned_row(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'row'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->row);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: row of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MCLGridRef_unsigned_row
+static int tolua_set_CEGUI__MCLGridRef_unsigned_row(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'row'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->row = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: column of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__MCLGridRef_unsigned_column
+static int tolua_get_CEGUI__MCLGridRef_unsigned_column(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'column'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->column);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: column of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__MCLGridRef_unsigned_column
+static int tolua_set_CEGUI__MCLGridRef_unsigned_column(lua_State* tolua_S)
+{
+  CEGUI::MCLGridRef* self = (CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'column'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->column = ((unsigned int)  tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator== of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MCLGridRef__eq00
+static int tolua_CEGUI_CEGUI_MCLGridRef__eq00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MCLGridRef* self = (const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* rhs = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator==(*rhs);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MCLGridRef_new00
+static int tolua_CEGUI_CEGUI_MCLGridRef_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int r = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int c = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::MCLGridRef* tolua_ret = (CEGUI::MCLGridRef*)  new CEGUI::MCLGridRef(r,c);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MCLGridRef");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::MCLGridRef */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MCLGridRef_new00_local
+static int tolua_CEGUI_CEGUI_MCLGridRef_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int r = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int c = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::MCLGridRef* tolua_ret = (CEGUI::MCLGridRef*)  new CEGUI::MCLGridRef(r,c);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::MCLGridRef");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserSortControlEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isUserSortControlEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isUserSortControlEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserSortControlEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserSortControlEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserSortControlEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserColumnSizingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserColumnSizingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserColumnSizingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUserColumnDraggingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUserColumnDraggingEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUserColumnDraggingEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUserColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnCount of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnCount00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRowCount of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getRowCount00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getRowCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRowCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getRowCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRowCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSortColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortColumn'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSortColumn();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWithID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnWithID(col_id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnWithHeaderText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithHeaderText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithHeaderText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnWithHeaderText'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnWithHeaderText(text);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnWithHeaderText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalColumnHeadersWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getTotalColumnHeadersWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getTotalColumnHeadersWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalColumnHeadersWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getTotalColumnHeadersWidth();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalColumnHeadersWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnHeaderWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnHeaderWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnHeaderWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnHeaderWidth'",NULL);
+#endif
+ {
+  CEGUI::UDim tolua_ret = (CEGUI::UDim)  self->getColumnHeaderWidth(col_idx);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::UDim(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::UDim));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::UDim");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnHeaderWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortDirection of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSortDirection00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortDirection'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment::SortDirection tolua_ret = (CEGUI::ListHeaderSegment::SortDirection)  self->getSortDirection();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHeaderSegmentForColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getHeaderSegmentForColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getHeaderSegmentForColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeaderSegmentForColumn'",NULL);
+#endif
+ {
+  CEGUI::ListHeaderSegment& tolua_ret = (CEGUI::ListHeaderSegment&)  self->getHeaderSegmentForColumn(col_idx);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ListHeaderSegment");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHeaderSegmentForColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemRowIndex of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemRowIndex00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemRowIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemRowIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemRowIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemRowIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemColumnIndex of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemColumnIndex00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemColumnIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemColumnIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemColumnIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemColumnIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemGridReference of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemGridReference00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemGridReference00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemGridReference'",NULL);
+#endif
+ {
+  CEGUI::MCLGridRef tolua_ret = (CEGUI::MCLGridRef)  self->getItemGridReference(item);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::MCLGridRef(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::MCLGridRef");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::MCLGridRef));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::MCLGridRef");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemGridReference'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemAtGridReference of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getItemAtGridReference00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getItemAtGridReference00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* grid_ref = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemAtGridReference'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getItemAtGridReference(*grid_ref);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemAtGridReference'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInColumn'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInColumn(item,col_idx);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInRow'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInRow(item,row_idx);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isListboxItemInList of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInList00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isListboxItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isListboxItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isListboxItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findColumnItemWithText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_findColumnItemWithText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_findColumnItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findColumnItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findColumnItemWithText(text,col_idx,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findColumnItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findRowItemWithText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_findRowItemWithText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_findRowItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findRowItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findRowItemWithText(text,row_idx,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findRowItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findListItemWithText of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_findListItemWithText00
+static int tolua_CEGUI_CEGUI_MultiColumnList_findListItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findListItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->findListItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findListItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFirstSelectedItem of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getFirstSelectedItem00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getFirstSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFirstSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getFirstSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFirstSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelected of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNextSelected00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNextSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ListboxItem* start_item = ((const CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelected'",NULL);
+#endif
+ {
+  CEGUI::ListboxItem* tolua_ret = (CEGUI::ListboxItem*)  self->getNextSelected(start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedCount of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSelectedCount00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSelectedCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getSelectedCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isItemSelected00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* grid_ref = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(*grid_ref);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNominatedSelectionColumnID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumnID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumnID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNominatedSelectionColumnID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getNominatedSelectionColumnID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNominatedSelectionColumnID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNominatedSelectionColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNominatedSelectionColumn'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getNominatedSelectionColumn();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNominatedSelectionColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNominatedSelectionRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNominatedSelectionRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getNominatedSelectionRow();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNominatedSelectionRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectionMode of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getSelectionMode00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getSelectionMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectionMode'",NULL);
+#endif
+ {
+  CEGUI::MultiColumnList::SelectionMode tolua_ret = (CEGUI::MultiColumnList::SelectionMode)  self->getSelectionMode();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectionMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_MultiColumnList_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColumnID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getColumnID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getColumnID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColumnID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getColumnID(col_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColumnID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRowID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getRowID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getRowID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRowID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getRowID(row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRowID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getRowWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getRowWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getRowWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getRowWithID'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getRowWithID(row_id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getRowWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListRenderArea of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getListRenderArea00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getListRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getListRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getListHeader of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getListHeader00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getListHeader00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getListHeader'",NULL);
+#endif
+ {
+  CEGUI::ListHeader* tolua_ret = (CEGUI::ListHeader*)  self->getListHeader();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListHeader");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getListHeader'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTotalRowsHeight of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getTotalRowsHeight00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getTotalRowsHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalRowsHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getTotalRowsHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTotalRowsHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidestColumnItemWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getWidestColumnItemWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getWidestColumnItemWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidestColumnItemWidth'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getWidestColumnItemWidth(col_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidestColumnItemWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHighestRowItemHeight of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_getHighestRowItemHeight00
+static int tolua_CEGUI_CEGUI_MultiColumnList_getHighestRowItemHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MultiColumnList* self = (const CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHighestRowItemHeight'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getHighestRowItemHeight(row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHighestRowItemHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_resetList00
+static int tolua_CEGUI_CEGUI_MultiColumnList_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_addColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_addColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addColumn'",NULL);
+#endif
+ {
+  self->addColumn(text,col_id,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_insertColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_insertColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,4,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertColumn'",NULL);
+#endif
+ {
+  self->insertColumn(text,col_id,*width,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_removeColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_removeColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeColumn'",NULL);
+#endif
+ {
+  self->removeColumn(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeColumnWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_removeColumnWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_removeColumnWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeColumnWithID'",NULL);
+#endif
+ {
+  self->removeColumnWithID(col_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeColumnWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_moveColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_moveColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumn'",NULL);
+#endif
+ {
+  self->moveColumn(col_idx,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: moveColumnWithID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_moveColumnWithID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_moveColumnWithID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int position = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'moveColumnWithID'",NULL);
+#endif
+ {
+  self->moveColumnWithID(col_id,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'moveColumnWithID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_addRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_addRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->addRow();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_addRow01
+static int tolua_CEGUI_CEGUI_MultiColumnList_addRow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->addRow(item,col_id);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_addRow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_insertRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_insertRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->insertRow(row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_insertRow01
+static int tolua_CEGUI_CEGUI_MultiColumnList_insertRow01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertRow'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->insertRow(item,col_id,row_idx);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_insertRow00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_removeRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_removeRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeRow'",NULL);
+#endif
+ {
+  self->removeRow(row_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItem of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItem00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::MCLGridRef* position = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItem'",NULL);
+#endif
+ {
+  self->setItem(item,*position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItem of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItem01
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItem01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItem'",NULL);
+#endif
+ {
+  self->setItem(item,col_id,row_idx);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_setItem00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectionMode of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSelectionMode00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSelectionMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MultiColumnList::SelectionMode sel_mode = ((CEGUI::MultiColumnList::SelectionMode) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectionMode'",NULL);
+#endif
+ {
+  self->setSelectionMode(sel_mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectionMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNominatedSelectionColumnID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumnID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumnID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNominatedSelectionColumnID'",NULL);
+#endif
+ {
+  self->setNominatedSelectionColumnID(col_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNominatedSelectionColumnID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNominatedSelectionColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNominatedSelectionColumn'",NULL);
+#endif
+ {
+  self->setNominatedSelectionColumn(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNominatedSelectionColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setNominatedSelectionRow of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionRow00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionRow00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setNominatedSelectionRow'",NULL);
+#endif
+ {
+  self->setNominatedSelectionRow(row_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setNominatedSelectionRow'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortDirection of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSortDirection00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSortDirection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListHeaderSegment::SortDirection direction = ((CEGUI::ListHeaderSegment::SortDirection) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortDirection'",NULL);
+#endif
+ {
+  self->setSortDirection(direction);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortDirection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumn of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSortColumn00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSortColumn00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumn'",NULL);
+#endif
+ {
+  self->setSortColumn(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumn'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortColumnByID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setSortColumnByID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setSortColumnByID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortColumnByID'",NULL);
+#endif
+ {
+  self->setSortColumnByID(col_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortColumnByID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_clearAllSelections00
+static int tolua_CEGUI_CEGUI_MultiColumnList_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ListboxItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ListboxItem* item = ((CEGUI::ListboxItem*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(item,state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSelectState'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSelectState of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState01
+static int tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::MCLGridRef",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::MCLGridRef* grid_ref = ((const CEGUI::MCLGridRef*)  tolua_tousertype(tolua_S,2,0));
+  bool state = ((bool)  tolua_toboolean(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSelectState'",NULL);
+#endif
+ {
+  self->setItemSelectState(*grid_ref,state);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedItemData of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_handleUpdatedItemData00
+static int tolua_CEGUI_CEGUI_MultiColumnList_handleUpdatedItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColumnHeaderWidth of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setColumnHeaderWidth00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setColumnHeaderWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::UDim* width = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColumnHeaderWidth'",NULL);
+#endif
+ {
+  self->setColumnHeaderWidth(col_idx,*width);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColumnHeaderWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserSortControlEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setUserSortControlEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setUserSortControlEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserSortControlEnabled'",NULL);
+#endif
+ {
+  self->setUserSortControlEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserSortControlEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserColumnSizingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnSizingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnSizingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserColumnSizingEnabled'",NULL);
+#endif
+ {
+  self->setUserColumnSizingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserColumnSizingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUserColumnDraggingEnabled of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnDraggingEnabled00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnDraggingEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUserColumnDraggingEnabled'",NULL);
+#endif
+ {
+  self->setUserColumnDraggingEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUserColumnDraggingEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: autoSizeColumnHeader of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_autoSizeColumnHeader00
+static int tolua_CEGUI_CEGUI_MultiColumnList_autoSizeColumnHeader00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int col_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'autoSizeColumnHeader'",NULL);
+#endif
+ {
+  self->autoSizeColumnHeader(col_idx);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'autoSizeColumnHeader'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRowID of class  CEGUI::MultiColumnList */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MultiColumnList_setRowID00
+static int tolua_CEGUI_CEGUI_MultiColumnList_setRowID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MultiColumnList",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MultiColumnList* self = (CEGUI::MultiColumnList*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int row_idx = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  unsigned int row_id = ((unsigned int)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRowID'",NULL);
+#endif
+ {
+  self->setRowID(row_idx,row_id);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRowID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemPixelSize of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_getItemPixelSize00
+static int tolua_CEGUI_CEGUI_ItemEntry_getItemPixelSize00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemPixelSize'",NULL);
+#endif
+ {
+  CEGUI::Size tolua_ret = (CEGUI::Size)  self->getItemPixelSize();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Size(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Size));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Size");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemPixelSize'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOwnerList of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_getOwnerList00
+static int tolua_CEGUI_CEGUI_ItemEntry_getOwnerList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemEntry* self = (const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOwnerList'",NULL);
+#endif
+ {
+  CEGUI::ItemListBase* tolua_ret = (CEGUI::ItemListBase*)  self->getOwnerList();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemListBase");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOwnerList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelected of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_isSelected00
+static int tolua_CEGUI_CEGUI_ItemEntry_isSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemEntry* self = (const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelected();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSelectable of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_isSelectable00
+static int tolua_CEGUI_CEGUI_ItemEntry_isSelectable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemEntry* self = (const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSelectable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSelectable();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSelectable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelected of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_setSelected00
+static int tolua_CEGUI_CEGUI_ItemEntry_setSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelected'",NULL);
+#endif
+ {
+  self->setSelected(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: select of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_select00
+static int tolua_CEGUI_CEGUI_ItemEntry_select00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'select'",NULL);
+#endif
+ {
+  self->select();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'select'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: deselect of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_deselect00
+static int tolua_CEGUI_CEGUI_ItemEntry_deselect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'deselect'",NULL);
+#endif
+ {
+  self->deselect();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'deselect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSelectable of class  CEGUI::ItemEntry */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemEntry_setSelectable00
+static int tolua_CEGUI_CEGUI_ItemEntry_setSelectable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemEntry* self = (CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSelectable'",NULL);
+#endif
+ {
+  self->setSelectable(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSelectable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemCount of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemCount00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemCount'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemFromIndex of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemFromIndex00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemFromIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  unsigned int index = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemFromIndex'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getItemFromIndex(index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemFromIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemIndex of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemIndex00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemIndex00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ItemEntry* item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemIndex'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getItemIndex(item);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemIndex'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findItemWithText of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_findItemWithText00
+static int tolua_CEGUI_CEGUI_ItemListBase_findItemWithText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+  const CEGUI::ItemEntry* start_item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findItemWithText'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->findItemWithText(text,start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findItemWithText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemInList of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_isItemInList00
+static int tolua_CEGUI_CEGUI_ItemListBase_isItemInList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ItemEntry* item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemInList'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemInList(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemInList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAutoResizeEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_isAutoResizeEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_isAutoResizeEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAutoResizeEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAutoResizeEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAutoResizeEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isSortEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_isSortEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_isSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isSortEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isSortEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSortMode of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getSortMode00
+static int tolua_CEGUI_CEGUI_ItemListBase_getSortMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSortMode'",NULL);
+#endif
+ {
+  CEGUI::ItemListBase::SortMode tolua_ret = (CEGUI::ItemListBase::SortMode)  self->getSortMode();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSortMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemRenderArea of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getItemRenderArea00
+static int tolua_CEGUI_CEGUI_ItemListBase_getItemRenderArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemRenderArea'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getItemRenderArea();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemRenderArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getContentPane of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_getContentPane00
+static int tolua_CEGUI_CEGUI_ItemListBase_getContentPane00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListBase* self = (const CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getContentPane'",NULL);
+#endif
+ {
+  CEGUI::Window* tolua_ret = (CEGUI::Window*)  self->getContentPane();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Window");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getContentPane'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: resetList of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_resetList00
+static int tolua_CEGUI_CEGUI_ItemListBase_resetList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resetList'",NULL);
+#endif
+ {
+  self->resetList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'resetList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addItem of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_addItem00
+static int tolua_CEGUI_CEGUI_ItemListBase_addItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemEntry* item = ((CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addItem'",NULL);
+#endif
+ {
+  self->addItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: insertItem of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_insertItem00
+static int tolua_CEGUI_CEGUI_ItemListBase_insertItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemEntry* item = ((CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ItemEntry* position = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertItem'",NULL);
+#endif
+ {
+  self->insertItem(item,position);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'insertItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: removeItem of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_removeItem00
+static int tolua_CEGUI_CEGUI_ItemListBase_removeItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemEntry* item = ((CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeItem'",NULL);
+#endif
+ {
+  self->removeItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'removeItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: handleUpdatedItemData of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_handleUpdatedItemData00
+static int tolua_CEGUI_CEGUI_ItemListBase_handleUpdatedItemData00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'handleUpdatedItemData'",NULL);
+#endif
+ {
+  self->handleUpdatedItemData();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'handleUpdatedItemData'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAutoResizeEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_setAutoResizeEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_setAutoResizeEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAutoResizeEnabled'",NULL);
+#endif
+ {
+  self->setAutoResizeEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAutoResizeEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: sizeToContent of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_sizeToContent00
+static int tolua_CEGUI_CEGUI_ItemListBase_sizeToContent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'sizeToContent'",NULL);
+#endif
+ {
+  self->sizeToContent();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'sizeToContent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortEnabled of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_setSortEnabled00
+static int tolua_CEGUI_CEGUI_ItemListBase_setSortEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortEnabled'",NULL);
+#endif
+ {
+  self->setSortEnabled(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSortMode of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_setSortMode00
+static int tolua_CEGUI_CEGUI_ItemListBase_setSortMode00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ItemListBase::SortMode mode = ((CEGUI::ItemListBase::SortMode) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSortMode'",NULL);
+#endif
+ {
+  self->setSortMode(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSortMode'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: sortList of class  CEGUI::ItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListBase_sortList00
+static int tolua_CEGUI_CEGUI_ItemListBase_sortList00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListBase* self = (CEGUI::ItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'sortList'",NULL);
+#endif
+ {
+  self->sortList();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'sortList'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getItemSpacing of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_getItemSpacing00
+static int tolua_CEGUI_CEGUI_MenuBase_getItemSpacing00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuBase* self = (const CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getItemSpacing'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getItemSpacing();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getItemSpacing'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMultiplePopupsAllowed of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_isMultiplePopupsAllowed00
+static int tolua_CEGUI_CEGUI_MenuBase_isMultiplePopupsAllowed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuBase* self = (const CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMultiplePopupsAllowed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMultiplePopupsAllowed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMultiplePopupsAllowed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPopupMenuItem of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_getPopupMenuItem00
+static int tolua_CEGUI_CEGUI_MenuBase_getPopupMenuItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuBase* self = (const CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPopupMenuItem'",NULL);
+#endif
+ {
+  CEGUI::MenuItem* tolua_ret = (CEGUI::MenuItem*)  self->getPopupMenuItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::MenuItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPopupMenuItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setItemSpacing of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_setItemSpacing00
+static int tolua_CEGUI_CEGUI_MenuBase_setItemSpacing00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuBase* self = (CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+  float spacing = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setItemSpacing'",NULL);
+#endif
+ {
+  self->setItemSpacing(spacing);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setItemSpacing'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: changePopupMenuItem of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_changePopupMenuItem00
+static int tolua_CEGUI_CEGUI_MenuBase_changePopupMenuItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuBase* self = (CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::MenuItem* item = ((CEGUI::MenuItem*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'changePopupMenuItem'",NULL);
+#endif
+ {
+  self->changePopupMenuItem(item);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'changePopupMenuItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAllowMultiplePopups of class  CEGUI::MenuBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuBase_setAllowMultiplePopups00
+static int tolua_CEGUI_CEGUI_MenuBase_setAllowMultiplePopups00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuBase* self = (CEGUI::MenuBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAllowMultiplePopups'",NULL);
+#endif
+ {
+  self->setAllowMultiplePopups(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAllowMultiplePopups'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFadeInTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_getFadeInTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_getFadeInTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PopupMenu* self = (const CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFadeInTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFadeInTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFadeInTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFadeOutTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_getFadeOutTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_getFadeOutTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PopupMenu* self = (const CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFadeOutTime'",NULL);
+#endif
+ {
+  float tolua_ret = (float)  self->getFadeOutTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFadeOutTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFadeInTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_setFadeInTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_setFadeInTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+  float fadetime = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFadeInTime'",NULL);
+#endif
+ {
+  self->setFadeInTime(fadetime);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFadeInTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFadeOutTime of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_setFadeOutTime00
+static int tolua_CEGUI_CEGUI_PopupMenu_setFadeOutTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+  float fadetime = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFadeOutTime'",NULL);
+#endif
+ {
+  self->setFadeOutTime(fadetime);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFadeOutTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: openPopupMenu of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_openPopupMenu00
+static int tolua_CEGUI_CEGUI_PopupMenu_openPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'openPopupMenu'",NULL);
+#endif
+ {
+  self->openPopupMenu();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'openPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: closePopupMenu of class  CEGUI::PopupMenu */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PopupMenu_closePopupMenu00
+static int tolua_CEGUI_CEGUI_PopupMenu_closePopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PopupMenu* self = (CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'closePopupMenu'",NULL);
+#endif
+ {
+  self->closePopupMenu();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'closePopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHovering of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_isHovering00
+static int tolua_CEGUI_CEGUI_MenuItem_isHovering00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuItem* self = (const CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHovering'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHovering();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHovering'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isPushed of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_isPushed00
+static int tolua_CEGUI_CEGUI_MenuItem_isPushed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuItem* self = (const CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isPushed'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isPushed();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isPushed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_getPopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_getPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::MenuItem* self = (const CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPopupMenu'",NULL);
+#endif
+ {
+  CEGUI::PopupMenu* tolua_ret = (CEGUI::PopupMenu*)  self->getPopupMenu();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PopupMenu");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setPopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_setPopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_setPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::PopupMenu",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::PopupMenu* popup = ((CEGUI::PopupMenu*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPopupMenu'",NULL);
+#endif
+ {
+  self->setPopupMenu(popup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: openPopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_openPopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_openPopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'openPopupMenu'",NULL);
+#endif
+ {
+  self->openPopupMenu();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'openPopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: closePopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_closePopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_closePopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+  bool notify = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'closePopupMenu'",NULL);
+#endif
+ {
+  self->closePopupMenu(notify);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'closePopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: togglePopupMenu of class  CEGUI::MenuItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_MenuItem_togglePopupMenu00
+static int tolua_CEGUI_CEGUI_MenuItem_togglePopupMenu00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::MenuItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::MenuItem* self = (CEGUI::MenuItem*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'togglePopupMenu'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->togglePopupMenu();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'togglePopupMenu'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isVertScrollbarAlwaysShown of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_isVertScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_isVertScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isVertScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isVertScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isVertScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isHorzScrollbarAlwaysShown of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_isHorzScrollbarAlwaysShown00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_isHorzScrollbarAlwaysShown00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isHorzScrollbarAlwaysShown'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isHorzScrollbarAlwaysShown();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isHorzScrollbarAlwaysShown'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVertScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_getVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_getVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVertScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getVertScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorzScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_getHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_getHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ScrolledItemListBase* self = (const CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorzScrollbar'",NULL);
+#endif
+ {
+  CEGUI::Scrollbar* tolua_ret = (CEGUI::Scrollbar*)  self->getHorzScrollbar();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Scrollbar");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowVertScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowVertScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowVertScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledItemListBase* self = (CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool mode = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowVertScrollbar'",NULL);
+#endif
+ {
+  self->setShowVertScrollbar(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowVertScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setShowHorzScrollbar of class  CEGUI::ScrolledItemListBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowHorzScrollbar00
+static int tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowHorzScrollbar00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ScrolledItemListBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ScrolledItemListBase* self = (CEGUI::ScrolledItemListBase*)  tolua_tousertype(tolua_S,1,0);
+  bool mode = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShowHorzScrollbar'",NULL);
+#endif
+ {
+  self->setShowHorzScrollbar(mode);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setShowHorzScrollbar'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSelectedCount of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getSelectedCount00
+static int tolua_CEGUI_CEGUI_ItemListbox_getSelectedCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSelectedCount'",NULL);
+#endif
+ {
+  unsigned long tolua_ret = (unsigned long)  self->getSelectedCount();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSelectedCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLastSelectedItem of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getLastSelectedItem00
+static int tolua_CEGUI_CEGUI_ItemListbox_getLastSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLastSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getLastSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLastSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFirstSelectedItem of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getFirstSelectedItem00
+static int tolua_CEGUI_CEGUI_ItemListbox_getFirstSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long start_index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFirstSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getFirstSelectedItem(start_index);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFirstSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelectedItem of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItem00
+static int tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelectedItem'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getNextSelectedItem();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelectedItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNextSelectedItemAfter of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItemAfter00
+static int tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItemAfter00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ItemEntry",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ItemEntry* start_item = ((const CEGUI::ItemEntry*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextSelectedItemAfter'",NULL);
+#endif
+ {
+  CEGUI::ItemEntry* tolua_ret = (CEGUI::ItemEntry*)  self->getNextSelectedItemAfter(start_item);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ItemEntry");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNextSelectedItemAfter'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isMultiSelectEnabled of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_isMultiSelectEnabled00
+static int tolua_CEGUI_CEGUI_ItemListbox_isMultiSelectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isMultiSelectEnabled'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isMultiSelectEnabled();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isMultiSelectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isItemSelected of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_isItemSelected00
+static int tolua_CEGUI_CEGUI_ItemListbox_isItemSelected00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ItemListbox* self = (const CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long index = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isItemSelected'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isItemSelected(index);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isItemSelected'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMultiSelectEnabled of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_setMultiSelectEnabled00
+static int tolua_CEGUI_CEGUI_ItemListbox_setMultiSelectEnabled00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  bool state = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMultiSelectEnabled'",NULL);
+#endif
+ {
+  self->setMultiSelectEnabled(state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMultiSelectEnabled'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearAllSelections of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_clearAllSelections00
+static int tolua_CEGUI_CEGUI_ItemListbox_clearAllSelections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearAllSelections'",NULL);
+#endif
+ {
+  self->clearAllSelections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearAllSelections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: selectRange of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_selectRange00
+static int tolua_CEGUI_CEGUI_ItemListbox_selectRange00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+  unsigned long a = ((unsigned long)  tolua_tonumber(tolua_S,2,0));
+  unsigned long z = ((unsigned long)  tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'selectRange'",NULL);
+#endif
+ {
+  self->selectRange(a,z);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'selectRange'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: selectAllItems of class  CEGUI::ItemListbox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ItemListbox_selectAllItems00
+static int tolua_CEGUI_CEGUI_ItemListbox_selectAllItems00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ItemListbox",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ItemListbox* self = (CEGUI::ItemListbox*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'selectAllItems'",NULL);
+#endif
+ {
+  self->selectAllItems();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'selectAllItems'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: drawAroundWidget of class  CEGUI::GroupBox */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_GroupBox_drawAroundWidget00
+static int tolua_CEGUI_CEGUI_GroupBox_drawAroundWidget00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::GroupBox",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::GroupBox* self = (CEGUI::GroupBox*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'drawAroundWidget'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->drawAroundWidget(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'drawAroundWidget'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValue of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getValue00
+static int tolua_CEGUI_CEGUI_BaseDim_getValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValue'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  float tolua_ret = (float)  self->getValue(*wnd);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'getValue'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getValue of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getValue01
+static int tolua_CEGUI_CEGUI_BaseDim_getValue01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* container = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getValue'",NULL);
+#endif
+ char errorBuffer[512];
+ bool errorDoIt = false;
+ try
+ {
+  float tolua_ret = (float)  self->getValue(*wnd,*container);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+catch(CEGUI::InvalidRequestException&e)
+{
+ snprintf(errorBuffer,512,"Exception of type 'CEGUI::InvalidRequestException' was thrown by function 'getValue'\nMessage: %s",e.getMessage().c_str());
+ errorDoIt = true;
+}
+ if (errorDoIt) {
+ luaL_error(tolua_S,errorBuffer);
+}
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_BaseDim_getValue00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clone of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_clone00
+static int tolua_CEGUI_CEGUI_BaseDim_clone00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clone'",NULL);
+#endif
+ {
+  CEGUI::BaseDim* tolua_ret = (CEGUI::BaseDim*)  self->clone();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::BaseDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clone'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDimensionOperator of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getDimensionOperator00
+static int tolua_CEGUI_CEGUI_BaseDim_getDimensionOperator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDimensionOperator'",NULL);
+#endif
+ {
+  CEGUI::DimensionOperator tolua_ret = (CEGUI::DimensionOperator)  self->getDimensionOperator();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDimensionOperator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDimensionOperator of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_setDimensionOperator00
+static int tolua_CEGUI_CEGUI_BaseDim_setDimensionOperator00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::BaseDim* self = (CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionOperator op = ((CEGUI::DimensionOperator) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDimensionOperator'",NULL);
+#endif
+ {
+  self->setDimensionOperator(op);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDimensionOperator'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOperand of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_getOperand00
+static int tolua_CEGUI_CEGUI_BaseDim_getOperand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* self = (const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOperand'",NULL);
+#endif
+ {
+  const CEGUI::BaseDim* tolua_ret = (const CEGUI::BaseDim*)  self->getOperand();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::BaseDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOperand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOperand of class  CEGUI::BaseDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_BaseDim_setOperand00
+static int tolua_CEGUI_CEGUI_BaseDim_setOperand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::BaseDim* self = (CEGUI::BaseDim*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::BaseDim* operand = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOperand'",NULL);
+#endif
+ {
+  self->setOperand(*operand);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOperand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setValue of class  CEGUI::AbsoluteDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_AbsoluteDim_setValue00
+static int tolua_CEGUI_CEGUI_AbsoluteDim_setValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::AbsoluteDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::AbsoluteDim* self = (CEGUI::AbsoluteDim*)  tolua_tousertype(tolua_S,1,0);
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setValue'",NULL);
+#endif
+ {
+  self->setValue(val);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::AbsoluteDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_AbsoluteDim_new00
+static int tolua_CEGUI_CEGUI_AbsoluteDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::AbsoluteDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::AbsoluteDim* tolua_ret = (CEGUI::AbsoluteDim*)  new CEGUI::AbsoluteDim(val);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::AbsoluteDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::AbsoluteDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_AbsoluteDim_new00_local
+static int tolua_CEGUI_CEGUI_AbsoluteDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::AbsoluteDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  float val = ((float)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::AbsoluteDim* tolua_ret = (CEGUI::AbsoluteDim*)  new CEGUI::AbsoluteDim(val);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::AbsoluteDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSourceImage of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_setSourceImage00
+static int tolua_CEGUI_CEGUI_ImageDim_setSourceImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageDim* self = (CEGUI::ImageDim*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSourceImage'",NULL);
+#endif
+ {
+  self->setSourceImage(imageset,image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSourceImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSourceDimension of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_setSourceDimension00
+static int tolua_CEGUI_CEGUI_ImageDim_setSourceDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageDim* self = (CEGUI::ImageDim*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSourceDimension'",NULL);
+#endif
+ {
+  self->setSourceDimension(dim);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSourceDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_new00
+static int tolua_CEGUI_CEGUI_ImageDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::ImageDim* tolua_ret = (CEGUI::ImageDim*)  new CEGUI::ImageDim(imageset,image,dim);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImageDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImageDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageDim_new00_local
+static int tolua_CEGUI_CEGUI_ImageDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::ImageDim* tolua_ret = (CEGUI::ImageDim*)  new CEGUI::ImageDim(imageset,image,dim);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImageDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidgetName of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_setWidgetName00
+static int tolua_CEGUI_CEGUI_WidgetDim_setWidgetName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetDim* self = (CEGUI::WidgetDim*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidgetName'",NULL);
+#endif
+ {
+  self->setWidgetName(name);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidgetName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setSourceDimension of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_setSourceDimension00
+static int tolua_CEGUI_CEGUI_WidgetDim_setSourceDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetDim* self = (CEGUI::WidgetDim*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setSourceDimension'",NULL);
+#endif
+ {
+  self->setSourceDimension(dim);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setSourceDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_new00
+static int tolua_CEGUI_CEGUI_WidgetDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::WidgetDim* tolua_ret = (CEGUI::WidgetDim*)  new CEGUI::WidgetDim(name,dim);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetDim_new00_local
+static int tolua_CEGUI_CEGUI_WidgetDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::WidgetDim* tolua_ret = (CEGUI::WidgetDim*)  new CEGUI::WidgetDim(name,dim);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::UnifiedDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UnifiedDim_new00
+static int tolua_CEGUI_CEGUI_UnifiedDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UnifiedDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* value = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UnifiedDim* tolua_ret = (CEGUI::UnifiedDim*)  new CEGUI::UnifiedDim(*value,dim);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::UnifiedDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::UnifiedDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_UnifiedDim_new00_local
+static int tolua_CEGUI_CEGUI_UnifiedDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::UnifiedDim",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::UDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::UDim* value = ((const CEGUI::UDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType dim = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::UnifiedDim* tolua_ret = (CEGUI::UnifiedDim*)  new CEGUI::UnifiedDim(*value,dim);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::UnifiedDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FontDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontDim_new00
+static int tolua_CEGUI_CEGUI_FontDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string font = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string text = ((string)  tolua_tocppstring(tolua_S,4,0));
+  CEGUI::FontMetricType metric = ((CEGUI::FontMetricType) (int)  tolua_tonumber(tolua_S,5,0));
+  float padding = ((float)  tolua_tonumber(tolua_S,6,0));
+ {
+  CEGUI::FontDim* tolua_ret = (CEGUI::FontDim*)  new CEGUI::FontDim(name,font,text,metric,padding);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FontDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FontDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FontDim_new00_local
+static int tolua_CEGUI_CEGUI_FontDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FontDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string font = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string text = ((string)  tolua_tocppstring(tolua_S,4,0));
+  CEGUI::FontMetricType metric = ((CEGUI::FontMetricType) (int)  tolua_tonumber(tolua_S,5,0));
+  float padding = ((float)  tolua_tonumber(tolua_S,6,0));
+ {
+  CEGUI::FontDim* tolua_ret = (CEGUI::FontDim*)  new CEGUI::FontDim(name,font,text,metric,padding);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FontDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDim_new00
+static int tolua_CEGUI_CEGUI_PropertyDim_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string property = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::PropertyDim* tolua_ret = (CEGUI::PropertyDim*)  new CEGUI::PropertyDim(name,property,type);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyDim */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDim_new00_local
+static int tolua_CEGUI_CEGUI_PropertyDim_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDim",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string property = ((string)  tolua_tocppstring(tolua_S,3,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,4,0));
+ {
+  CEGUI::PropertyDim* tolua_ret = (CEGUI::PropertyDim*)  new CEGUI::PropertyDim(name,property,type);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBaseDimension of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_getBaseDimension00
+static int tolua_CEGUI_CEGUI_Dimension_getBaseDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Dimension* self = (const CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBaseDimension'",NULL);
+#endif
+ {
+  const CEGUI::BaseDim& tolua_ret = (const CEGUI::BaseDim&)  self->getBaseDimension();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::BaseDim");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBaseDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBaseDimension of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_setBaseDimension00
+static int tolua_CEGUI_CEGUI_Dimension_setBaseDimension00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Dimension* self = (CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::BaseDim* dim = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBaseDimension'",NULL);
+#endif
+ {
+  self->setBaseDimension(*dim);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBaseDimension'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDimensionType of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_getDimensionType00
+static int tolua_CEGUI_CEGUI_Dimension_getDimensionType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::Dimension* self = (const CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDimensionType'",NULL);
+#endif
+ {
+  CEGUI::DimensionType tolua_ret = (CEGUI::DimensionType)  self->getDimensionType();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDimensionType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDimensionType of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_setDimensionType00
+static int tolua_CEGUI_CEGUI_Dimension_setDimensionType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::Dimension* self = (CEGUI::Dimension*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDimensionType'",NULL);
+#endif
+ {
+  self->setDimensionType(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDimensionType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new00
+static int tolua_CEGUI_CEGUI_Dimension_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* dim = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*dim,type);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new00_local
+static int tolua_CEGUI_CEGUI_Dimension_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::BaseDim",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::BaseDim* dim = ((const CEGUI::BaseDim*)  tolua_tousertype(tolua_S,2,0));
+  CEGUI::DimensionType type = ((CEGUI::DimensionType) (int)  tolua_tonumber(tolua_S,3,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*dim,type);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new01
+static int tolua_CEGUI_CEGUI_Dimension_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Dimension* other = ((const CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*other);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new01_local
+static int tolua_CEGUI_CEGUI_Dimension_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::Dimension* other = ((const CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0));
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension(*other);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new02
+static int tolua_CEGUI_CEGUI_Dimension_new02(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new01(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::Dimension */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_Dimension_new02_local
+static int tolua_CEGUI_CEGUI_Dimension_new02_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::Dimension",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::Dimension* tolua_ret = (CEGUI::Dimension*)  new CEGUI::Dimension();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::Dimension");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_Dimension_new01_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelRect of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00
+static int tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getPixelRect(*wnd);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getPixelRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getPixelRect of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_getPixelRect01
+static int tolua_CEGUI_CEGUI_ComponentArea_getPixelRect01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* container = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getPixelRect(*wnd,*container);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isAreaFetchedFromProperty of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_isAreaFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_ComponentArea_isAreaFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isAreaFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isAreaFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isAreaFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getAreaPropertySource of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_getAreaPropertySource00
+static int tolua_CEGUI_CEGUI_ComponentArea_getAreaPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ComponentArea* self = (const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAreaPropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getAreaPropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getAreaPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setAreaPropertySource of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_setAreaPropertySource00
+static int tolua_CEGUI_CEGUI_ComponentArea_setAreaPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAreaPropertySource'",NULL);
+#endif
+ {
+  self->setAreaPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setAreaPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_left of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_left
+static int tolua_get_CEGUI__ComponentArea_d_left(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_left,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_left of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_left
+static int tolua_set_CEGUI__ComponentArea_d_left(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_left'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_left = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_top of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_top
+static int tolua_get_CEGUI__ComponentArea_d_top(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_top,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_top of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_top
+static int tolua_set_CEGUI__ComponentArea_d_top(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_top'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_top = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_right_or_width of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_right_or_width
+static int tolua_get_CEGUI__ComponentArea_d_right_or_width(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right_or_width'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_right_or_width,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_right_or_width of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_right_or_width
+static int tolua_set_CEGUI__ComponentArea_d_right_or_width(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_right_or_width'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_right_or_width = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: d_bottom_or_height of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_get_CEGUI__ComponentArea_d_bottom_or_height
+static int tolua_get_CEGUI__ComponentArea_d_bottom_or_height(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_or_height'",NULL);
+#endif
+ tolua_pushusertype(tolua_S,(void*)&self->d_bottom_or_height,"CEGUI::Dimension");
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: d_bottom_or_height of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_set_CEGUI__ComponentArea_d_bottom_or_height
+static int tolua_set_CEGUI__ComponentArea_d_bottom_or_height(lua_State* tolua_S)
+{
+  CEGUI::ComponentArea* self = (CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'd_bottom_or_height'",NULL);
+ if (!tolua_isusertype(tolua_S,2,"CEGUI::Dimension",0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+  self->d_bottom_or_height = *((CEGUI::Dimension*)  tolua_tousertype(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_new00
+static int tolua_CEGUI_CEGUI_ComponentArea_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ComponentArea* tolua_ret = (CEGUI::ComponentArea*)  new CEGUI::ComponentArea();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ComponentArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ComponentArea_new00_local
+static int tolua_CEGUI_CEGUI_ComponentArea_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ComponentArea* tolua_ret = (CEGUI::ComponentArea*)  new CEGUI::ComponentArea();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_getName00
+static int tolua_CEGUI_CEGUI_NamedArea_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::NamedArea* self = (const CEGUI::NamedArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getArea of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_getArea00
+static int tolua_CEGUI_CEGUI_NamedArea_getArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::NamedArea* self = (const CEGUI::NamedArea*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getArea'",NULL);
+#endif
+ {
+  const CEGUI::ComponentArea& tolua_ret = (const CEGUI::ComponentArea&)  self->getArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setArea of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_setArea00
+static int tolua_CEGUI_CEGUI_NamedArea_setArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::NamedArea* self = (CEGUI::NamedArea*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::ComponentArea area = *((CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setArea'",NULL);
+#endif
+ {
+  self->setArea(area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new00
+static int tolua_CEGUI_CEGUI_NamedArea_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new00_local
+static int tolua_CEGUI_CEGUI_NamedArea_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new01
+static int tolua_CEGUI_CEGUI_NamedArea_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_NamedArea_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::NamedArea */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_NamedArea_new01_local
+static int tolua_CEGUI_CEGUI_NamedArea_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::NamedArea* tolua_ret = (CEGUI::NamedArea*)  new CEGUI::NamedArea(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::NamedArea");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_NamedArea_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::PropertyDefinitionBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinitionBase_set00
+static int tolua_CEGUI_CEGUI_PropertyDefinitionBase_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyDefinitionBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyDefinitionBase* self = (CEGUI::PropertyDefinitionBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* receiver = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(receiver,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: get of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_get00
+static int tolua_CEGUI_CEGUI_PropertyDefinition_get00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyDefinition* self = (const CEGUI::PropertyDefinition*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* receiver = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->get(receiver);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'get'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_set00
+static int tolua_CEGUI_CEGUI_PropertyDefinition_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyDefinition* self = (CEGUI::PropertyDefinition*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* receiver = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(receiver,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_new00
+static int tolua_CEGUI_CEGUI_PropertyDefinition_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,3,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,4,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,5,0));
+ {
+  CEGUI::PropertyDefinition* tolua_ret = (CEGUI::PropertyDefinition*)  new CEGUI::PropertyDefinition(name,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyDefinition_new00_local
+static int tolua_CEGUI_CEGUI_PropertyDefinition_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,3,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,4,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,5,0));
+ {
+  CEGUI::PropertyDefinition* tolua_ret = (CEGUI::PropertyDefinition*)  new CEGUI::PropertyDefinition(name,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: apply of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_apply00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_apply00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyInitialiser* self = (const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* target = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'apply'",NULL);
+#endif
+ {
+  self->apply(*target);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'apply'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTargetPropertyName of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_getTargetPropertyName00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_getTargetPropertyName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyInitialiser* self = (const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTargetPropertyName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTargetPropertyName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTargetPropertyName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getInitialiserValue of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_getInitialiserValue00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_getInitialiserValue00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyInitialiser* self = (const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getInitialiserValue'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getInitialiserValue();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getInitialiserValue'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_new00
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+ {
+  CEGUI::PropertyInitialiser* tolua_ret = (CEGUI::PropertyInitialiser*)  new CEGUI::PropertyInitialiser(property,value);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyInitialiser */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local
+static int tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+ {
+  CEGUI::PropertyInitialiser* tolua_ret = (CEGUI::PropertyInitialiser*)  new CEGUI::PropertyInitialiser(property,value);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: get of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_get00
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_get00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::PropertyLinkDefinition* self = (const CEGUI::PropertyLinkDefinition*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* receiver = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->get(receiver);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'get'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: set of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_set00
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_set00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::PropertyLinkDefinition* self = (CEGUI::PropertyLinkDefinition*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* receiver = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string value = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
+#endif
+ {
+  self->set(receiver,value);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string widgetNameSuffix = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string targetProperty = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,5,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,6,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,7,0));
+ {
+  CEGUI::PropertyLinkDefinition* tolua_ret = (CEGUI::PropertyLinkDefinition*)  new CEGUI::PropertyLinkDefinition(propertyName,widgetNameSuffix,targetProperty,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::PropertyLinkDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::PropertyLinkDefinition */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local
+static int tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string widgetNameSuffix = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string targetProperty = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string initialValue = ((string)  tolua_tocppstring(tolua_S,5,0));
+  bool redrawOnWrite = ((bool)  tolua_toboolean(tolua_S,6,0));
+  bool layoutOnWrite = ((bool)  tolua_toboolean(tolua_S,7,0));
+ {
+  CEGUI::PropertyLinkDefinition* tolua_ret = (CEGUI::PropertyLinkDefinition*)  new CEGUI::PropertyLinkDefinition(propertyName,widgetNameSuffix,targetProperty,initialValue,redrawOnWrite,layoutOnWrite);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::PropertyLinkDefinition");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_render00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_render01
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FalagardComponentBase_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getComponentArea of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_getComponentArea00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_getComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getComponentArea'",NULL);
+#endif
+ {
+  const CEGUI::ComponentArea& tolua_ret = (const CEGUI::ComponentArea&)  self->getComponentArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setComponentArea of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setComponentArea00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ComponentArea* area = ((const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setComponentArea'",NULL);
+#endif
+ {
+  self->setComponentArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getColours of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_getColours00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_getColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FalagardComponentBase* self = (const CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getColours'",NULL);
+#endif
+ {
+  const CEGUI::ColourRect& tolua_ret = (const CEGUI::ColourRect&)  self->getColours();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColours of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setColours00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColours'",NULL);
+#endif
+ {
+  self->setColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColoursPropertySource of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertySource00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColoursPropertySource'",NULL);
+#endif
+ {
+  self->setColoursPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColoursPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setColoursPropertyIsColourRect of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertyIsColourRect00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertyIsColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColoursPropertyIsColourRect'",NULL);
+#endif
+ {
+  self->setColoursPropertyIsColourRect(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setColoursPropertyIsColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVertFormattingPropertySource of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setVertFormattingPropertySource00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setVertFormattingPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVertFormattingPropertySource'",NULL);
+#endif
+ {
+  self->setVertFormattingPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVertFormattingPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorzFormattingPropertySource of class  CEGUI::FalagardComponentBase */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FalagardComponentBase_setHorzFormattingPropertySource00
+static int tolua_CEGUI_CEGUI_FalagardComponentBase_setHorzFormattingPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FalagardComponentBase",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FalagardComponentBase* self = (CEGUI::FalagardComponentBase*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorzFormattingPropertySource'",NULL);
+#endif
+ {
+  self->setHorzFormattingPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorzFormattingPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBackgroundVerticalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_getBackgroundVerticalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_getBackgroundVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameComponent* self = (const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBackgroundVerticalFormatting'",NULL);
+#endif
+ {
+  CEGUI::VerticalFormatting tolua_ret = (CEGUI::VerticalFormatting)  self->getBackgroundVerticalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBackgroundVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBackgroundVerticalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setBackgroundVerticalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_setBackgroundVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalFormatting fmt = ((CEGUI::VerticalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBackgroundVerticalFormatting'",NULL);
+#endif
+ {
+  self->setBackgroundVerticalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBackgroundVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBackgroundHorizontalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_getBackgroundHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_getBackgroundHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameComponent* self = (const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBackgroundHorizontalFormatting'",NULL);
+#endif
+ {
+  CEGUI::HorizontalFormatting tolua_ret = (CEGUI::HorizontalFormatting)  self->getBackgroundHorizontalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBackgroundHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBackgroundHorizontalFormatting of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setBackgroundHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_FrameComponent_setBackgroundHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalFormatting fmt = ((CEGUI::HorizontalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBackgroundHorizontalFormatting'",NULL);
+#endif
+ {
+  self->setBackgroundHorizontalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBackgroundHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_getImage00
+static int tolua_CEGUI_CEGUI_FrameComponent_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::FrameComponent* self = (const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::FrameImageComponent part = ((CEGUI::FrameImageComponent) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getImage(part);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setImage00
+static int tolua_CEGUI_CEGUI_FrameComponent_setImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::FrameImageComponent part = ((CEGUI::FrameImageComponent) (int)  tolua_tonumber(tolua_S,2,0));
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(part,image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_setImage01
+static int tolua_CEGUI_CEGUI_FrameComponent_setImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::FrameComponent* self = (CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::FrameImageComponent part = ((CEGUI::FrameImageComponent) (int)  tolua_tonumber(tolua_S,2,0));
+  string imageset = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(part,imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_FrameComponent_setImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_new00
+static int tolua_CEGUI_CEGUI_FrameComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FrameComponent* tolua_ret = (CEGUI::FrameComponent*)  new CEGUI::FrameComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FrameComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FrameComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FrameComponent_new00_local
+static int tolua_CEGUI_CEGUI_FrameComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FrameComponent* tolua_ret = (CEGUI::FrameComponent*)  new CEGUI::FrameComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FrameComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImage of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getImage00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImage'",NULL);
+#endif
+ {
+  const CEGUI::Image* tolua_ret = (const CEGUI::Image*)  self->getImage();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::Image");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setImage00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setImage00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Image",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Image* image = ((const CEGUI::Image*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(image);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImage'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImage of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setImage01
+static int tolua_CEGUI_CEGUI_ImageryComponent_setImage01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  string imageset = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string image = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImage'",NULL);
+#endif
+ {
+  self->setImage(imageset,image);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImageryComponent_setImage00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getVerticalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalFormatting'",NULL);
+#endif
+ {
+  CEGUI::VerticalFormatting tolua_ret = (CEGUI::VerticalFormatting)  self->getVerticalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setVerticalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalFormatting fmt = ((CEGUI::VerticalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalFormatting'",NULL);
+#endif
+ {
+  self->setVerticalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalFormatting'",NULL);
+#endif
+ {
+  CEGUI::HorizontalFormatting tolua_ret = (CEGUI::HorizontalFormatting)  self->getHorizontalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalFormatting of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalFormatting fmt = ((CEGUI::HorizontalFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalFormatting'",NULL);
+#endif
+ {
+  self->setHorizontalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isImageFetchedFromProperty of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_isImageFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_ImageryComponent_isImageFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isImageFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isImageFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isImageFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImagePropertySource of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_getImagePropertySource00
+static int tolua_CEGUI_CEGUI_ImageryComponent_getImagePropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImageryComponent* self = (const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImagePropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getImagePropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImagePropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setImagePropertySource of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_setImagePropertySource00
+static int tolua_CEGUI_CEGUI_ImageryComponent_setImagePropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImageryComponent* self = (CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setImagePropertySource'",NULL);
+#endif
+ {
+  self->setImagePropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setImagePropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_new00
+static int tolua_CEGUI_CEGUI_ImageryComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImageryComponent* tolua_ret = (CEGUI::ImageryComponent*)  new CEGUI::ImageryComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImageryComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImageryComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImageryComponent_new00_local
+static int tolua_CEGUI_CEGUI_ImageryComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImageryComponent* tolua_ret = (CEGUI::ImageryComponent*)  new CEGUI::ImageryComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImageryComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getText of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getText00
+static int tolua_CEGUI_CEGUI_TextComponent_getText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getText();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setText of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setText00
+static int tolua_CEGUI_CEGUI_TextComponent_setText00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string text = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setText'",NULL);
+#endif
+ {
+  self->setText(text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setText'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFont of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getFont00
+static int tolua_CEGUI_CEGUI_TextComponent_getFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFont'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getFont();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFont of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setFont00
+static int tolua_CEGUI_CEGUI_TextComponent_setFont00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string font = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFont'",NULL);
+#endif
+ {
+  self->setFont(font);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFont'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getVerticalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_getVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalFormatting'",NULL);
+#endif
+ {
+  CEGUI::VerticalTextFormatting tolua_ret = (CEGUI::VerticalTextFormatting)  self->getVerticalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setVerticalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_setVerticalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalTextFormatting fmt = ((CEGUI::VerticalTextFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalFormatting'",NULL);
+#endif
+ {
+  self->setVerticalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_getHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalFormatting'",NULL);
+#endif
+ {
+  CEGUI::HorizontalTextFormatting tolua_ret = (CEGUI::HorizontalTextFormatting)  self->getHorizontalFormatting();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalFormatting of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setHorizontalFormatting00
+static int tolua_CEGUI_CEGUI_TextComponent_setHorizontalFormatting00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalTextFormatting fmt = ((CEGUI::HorizontalTextFormatting) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalFormatting'",NULL);
+#endif
+ {
+  self->setHorizontalFormatting(fmt);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalFormatting'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isTextFetchedFromProperty of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_isTextFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_TextComponent_isTextFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isTextFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isTextFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isTextFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getTextPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getTextPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_getTextPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTextPropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getTextPropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getTextPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setTextPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setTextPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_setTextPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTextPropertySource'",NULL);
+#endif
+ {
+  self->setTextPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setTextPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isFontFetchedFromProperty of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_isFontFetchedFromProperty00
+static int tolua_CEGUI_CEGUI_TextComponent_isFontFetchedFromProperty00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFontFetchedFromProperty'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isFontFetchedFromProperty();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isFontFetchedFromProperty'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getFontPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_getFontPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_getFontPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::TextComponent* self = (const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getFontPropertySource'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getFontPropertySource();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getFontPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setFontPropertySource of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_setFontPropertySource00
+static int tolua_CEGUI_CEGUI_TextComponent_setFontPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::TextComponent* self = (CEGUI::TextComponent*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFontPropertySource'",NULL);
+#endif
+ {
+  self->setFontPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setFontPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_new00
+static int tolua_CEGUI_CEGUI_TextComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::TextComponent* tolua_ret = (CEGUI::TextComponent*)  new CEGUI::TextComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::TextComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::TextComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_TextComponent_new00_local
+static int tolua_CEGUI_CEGUI_TextComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::TextComponent* tolua_ret = (CEGUI::TextComponent*)  new CEGUI::TextComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::TextComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_render00
+static int tolua_CEGUI_CEGUI_ImagerySection_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_render01
+static int tolua_CEGUI_CEGUI_ImagerySection_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modColours = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modColours,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addImageryComponent of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_addImageryComponent00
+static int tolua_CEGUI_CEGUI_ImagerySection_addImageryComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImageryComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImageryComponent* img = ((const CEGUI::ImageryComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addImageryComponent'",NULL);
+#endif
+ {
+  self->addImageryComponent(*img);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addImageryComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearImageryComponents of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_clearImageryComponents00
+static int tolua_CEGUI_CEGUI_ImagerySection_clearImageryComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearImageryComponents'",NULL);
+#endif
+ {
+  self->clearImageryComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearImageryComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addTextComponent of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_addTextComponent00
+static int tolua_CEGUI_CEGUI_ImagerySection_addTextComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::TextComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::TextComponent* text = ((const CEGUI::TextComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addTextComponent'",NULL);
+#endif
+ {
+  self->addTextComponent(*text);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addTextComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearTextComponents of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_clearTextComponents00
+static int tolua_CEGUI_CEGUI_ImagerySection_clearTextComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearTextComponents'",NULL);
+#endif
+ {
+  self->clearTextComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearTextComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearFrameComponents of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_clearFrameComponents00
+static int tolua_CEGUI_CEGUI_ImagerySection_clearFrameComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearFrameComponents'",NULL);
+#endif
+ {
+  self->clearFrameComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearFrameComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addFrameComponent of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_addFrameComponent00
+static int tolua_CEGUI_CEGUI_ImagerySection_addFrameComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::FrameComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::FrameComponent* frame = ((const CEGUI::FrameComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addFrameComponent'",NULL);
+#endif
+ {
+  self->addFrameComponent(*frame);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addFrameComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getMasterColours of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getMasterColours00
+static int tolua_CEGUI_CEGUI_ImagerySection_getMasterColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getMasterColours'",NULL);
+#endif
+ {
+  const CEGUI::ColourRect& tolua_ret = (const CEGUI::ColourRect&)  self->getMasterColours();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getMasterColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMasterColours of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_setMasterColours00
+static int tolua_CEGUI_CEGUI_ImagerySection_setMasterColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMasterColours'",NULL);
+#endif
+ {
+  self->setMasterColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMasterColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getName00
+static int tolua_CEGUI_CEGUI_ImagerySection_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMasterColoursPropertySource of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertySource00
+static int tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMasterColoursPropertySource'",NULL);
+#endif
+ {
+  self->setMasterColoursPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMasterColoursPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setMasterColoursPropertyIsColourRect of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertyIsColourRect00
+static int tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertyIsColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::ImagerySection* self = (CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setMasterColoursPropertyIsColourRect'",NULL);
+#endif
+ {
+  self->setMasterColoursPropertyIsColourRect(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setMasterColoursPropertyIsColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBoundingRect of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00
+static int tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBoundingRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getBoundingRect(*wnd);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBoundingRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBoundingRect of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect01
+static int tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::ImagerySection* self = (const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* wnd = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* rect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBoundingRect'",NULL);
+#endif
+ {
+  CEGUI::Rect tolua_ret = (CEGUI::Rect)  self->getBoundingRect(*wnd,*rect);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = new CEGUI::Rect(tolua_ret);
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CEGUI::Rect));
+ tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CEGUI::Rect");
+#endif
+ }
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new00
+static int tolua_CEGUI_CEGUI_ImagerySection_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new00_local
+static int tolua_CEGUI_CEGUI_ImagerySection_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new01
+static int tolua_CEGUI_CEGUI_ImagerySection_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::ImagerySection */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_ImagerySection_new01_local
+static int tolua_CEGUI_CEGUI_ImagerySection_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::ImagerySection* tolua_ret = (CEGUI::ImagerySection*)  new CEGUI::ImagerySection(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_ImagerySection_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_render00
+static int tolua_CEGUI_CEGUI_SectionSpecification_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_render01
+static int tolua_CEGUI_CEGUI_SectionSpecification_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_SectionSpecification_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOwnerWidgetLookFeel of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_getOwnerWidgetLookFeel00
+static int tolua_CEGUI_CEGUI_SectionSpecification_getOwnerWidgetLookFeel00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOwnerWidgetLookFeel'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getOwnerWidgetLookFeel();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOwnerWidgetLookFeel'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSectionName of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_getSectionName00
+static int tolua_CEGUI_CEGUI_SectionSpecification_getSectionName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSectionName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getSectionName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSectionName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_getOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_getOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getOverrideColours'",NULL);
+#endif
+ {
+  const CEGUI::ColourRect& tolua_ret = (const CEGUI::ColourRect&)  self->getOverrideColours();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ColourRect");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverrideColours'",NULL);
+#endif
+ {
+  self->setOverrideColours(*cols);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isUsingOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_isUsingOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_isUsingOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::SectionSpecification* self = (const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isUsingOverrideColours'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isUsingOverrideColours();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isUsingOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setUsingOverrideColours of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setUsingOverrideColours00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setUsingOverrideColours00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUsingOverrideColours'",NULL);
+#endif
+ {
+  self->setUsingOverrideColours(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setUsingOverrideColours'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverrideColoursPropertySource of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertySource00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverrideColoursPropertySource'",NULL);
+#endif
+ {
+  self->setOverrideColoursPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverrideColoursPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setOverrideColoursPropertyIsColourRect of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertyIsColourRect00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertyIsColourRect00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,true));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setOverrideColoursPropertyIsColourRect'",NULL);
+#endif
+ {
+  self->setOverrideColoursPropertyIsColourRect(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setOverrideColoursPropertyIsColourRect'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setRenderControlPropertySource of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_setRenderControlPropertySource00
+static int tolua_CEGUI_CEGUI_SectionSpecification_setRenderControlPropertySource00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::SectionSpecification* self = (CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,1,0);
+  string property = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRenderControlPropertySource'",NULL);
+#endif
+ {
+  self->setRenderControlPropertySource(property);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setRenderControlPropertySource'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new00
+static int tolua_CEGUI_CEGUI_SectionSpecification_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  const string controlPropertySource = ((const string)  tolua_tocppstring(tolua_S,4,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new00_local
+static int tolua_CEGUI_CEGUI_SectionSpecification_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  const string controlPropertySource = ((const string)  tolua_tocppstring(tolua_S,4,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new01
+static int tolua_CEGUI_CEGUI_SectionSpecification_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string controlPropertySource = ((string)  tolua_tocppstring(tolua_S,4,0));
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource,*cols);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_SectionSpecification_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::SectionSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_SectionSpecification_new01_local
+static int tolua_CEGUI_CEGUI_SectionSpecification_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string owner = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string sectionName = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string controlPropertySource = ((string)  tolua_tocppstring(tolua_S,4,0));
+  const CEGUI::ColourRect* cols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+ {
+  CEGUI::SectionSpecification* tolua_ret = (CEGUI::SectionSpecification*)  new CEGUI::SectionSpecification(owner,sectionName,controlPropertySource,*cols);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::SectionSpecification");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_SectionSpecification_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_render00
+static int tolua_CEGUI_CEGUI_LayerSpecification_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,6,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,3,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,6,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_render01
+static int tolua_CEGUI_CEGUI_LayerSpecification_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,6,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,7,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  float base_z = ((float)  tolua_tonumber(tolua_S,4,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,5,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,6,0));
+  bool clipToDisplay = ((bool)  tolua_toboolean(tolua_S,7,false));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,base_z,modcols,clipper,clipToDisplay);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_LayerSpecification_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addSectionSpecification of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_addSectionSpecification00
+static int tolua_CEGUI_CEGUI_LayerSpecification_addSectionSpecification00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::SectionSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::LayerSpecification* self = (CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::SectionSpecification* section = ((const CEGUI::SectionSpecification*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addSectionSpecification'",NULL);
+#endif
+ {
+  self->addSectionSpecification(*section);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addSectionSpecification'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearSectionSpecifications of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_clearSectionSpecifications00
+static int tolua_CEGUI_CEGUI_LayerSpecification_clearSectionSpecifications00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::LayerSpecification* self = (CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearSectionSpecifications'",NULL);
+#endif
+ {
+  self->clearSectionSpecifications();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearSectionSpecifications'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getLayerPriority of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_getLayerPriority00
+static int tolua_CEGUI_CEGUI_LayerSpecification_getLayerPriority00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getLayerPriority'",NULL);
+#endif
+ {
+  unsigned int tolua_ret = (unsigned int)  self->getLayerPriority();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getLayerPriority'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: operator< of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification__lt00
+static int tolua_CEGUI_CEGUI_LayerSpecification__lt00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::LayerSpecification* self = (const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::LayerSpecification* other = ((const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator<'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->operator<(*other);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function '.lt'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_new00
+static int tolua_CEGUI_CEGUI_LayerSpecification_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int priority = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::LayerSpecification* tolua_ret = (CEGUI::LayerSpecification*)  new CEGUI::LayerSpecification(priority);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::LayerSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::LayerSpecification */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_LayerSpecification_new00_local
+static int tolua_CEGUI_CEGUI_LayerSpecification_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  unsigned int priority = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+ {
+  CEGUI::LayerSpecification* tolua_ret = (CEGUI::LayerSpecification*)  new CEGUI::LayerSpecification(priority);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::LayerSpecification");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_render00
+static int tolua_CEGUI_CEGUI_StateImagery_render00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,modcols,clipper);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'render'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: render of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_render01
+static int tolua_CEGUI_CEGUI_StateImagery_render01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"const CEGUI::Rect",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,4,"const CEGUI::ColourRect",1,&tolua_err) ||
+ !tolua_isusertype(tolua_S,5,"const CEGUI::Rect",1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* srcWindow = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  const CEGUI::Rect* baseRect = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,3,0));
+  const CEGUI::ColourRect* modcols = ((const CEGUI::ColourRect*)  tolua_tousertype(tolua_S,4,0));
+  const CEGUI::Rect* clipper = ((const CEGUI::Rect*)  tolua_tousertype(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'render'",NULL);
+#endif
+ {
+  self->render(*srcWindow,*baseRect,modcols,clipper);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_StateImagery_render00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addLayer of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_addLayer00
+static int tolua_CEGUI_CEGUI_StateImagery_addLayer00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::LayerSpecification",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::StateImagery* self = (CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::LayerSpecification* layer = ((const CEGUI::LayerSpecification*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addLayer'",NULL);
+#endif
+ {
+  self->addLayer(*layer);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addLayer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearLayers of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_clearLayers00
+static int tolua_CEGUI_CEGUI_StateImagery_clearLayers00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::StateImagery* self = (CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearLayers'",NULL);
+#endif
+ {
+  self->clearLayers();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearLayers'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_getName00
+static int tolua_CEGUI_CEGUI_StateImagery_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isClippedToDisplay of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_isClippedToDisplay00
+static int tolua_CEGUI_CEGUI_StateImagery_isClippedToDisplay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::StateImagery* self = (const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isClippedToDisplay'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isClippedToDisplay();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isClippedToDisplay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setClippedToDisplay of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_setClippedToDisplay00
+static int tolua_CEGUI_CEGUI_StateImagery_setClippedToDisplay00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::StateImagery* self = (CEGUI::StateImagery*)  tolua_tousertype(tolua_S,1,0);
+  bool setting = ((bool)  tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setClippedToDisplay'",NULL);
+#endif
+ {
+  self->setClippedToDisplay(setting);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setClippedToDisplay'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new00
+static int tolua_CEGUI_CEGUI_StateImagery_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new00_local
+static int tolua_CEGUI_CEGUI_StateImagery_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new01
+static int tolua_CEGUI_CEGUI_StateImagery_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_StateImagery_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::StateImagery */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_StateImagery_new01_local
+static int tolua_CEGUI_CEGUI_StateImagery_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::StateImagery* tolua_ret = (CEGUI::StateImagery*)  new CEGUI::StateImagery();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_StateImagery_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: create of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_create00
+static int tolua_CEGUI_CEGUI_WidgetComponent_create00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* parent = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'create'",NULL);
+#endif
+ {
+  self->create(*parent);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getComponentArea of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getComponentArea00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getComponentArea'",NULL);
+#endif
+ {
+  const CEGUI::ComponentArea& tolua_ret = (const CEGUI::ComponentArea&)  self->getComponentArea();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::ComponentArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setComponentArea of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setComponentArea00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setComponentArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ComponentArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ComponentArea* area = ((const CEGUI::ComponentArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setComponentArea'",NULL);
+#endif
+ {
+  self->setComponentArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setComponentArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getBaseWidgetType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getBaseWidgetType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getBaseWidgetType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getBaseWidgetType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getBaseWidgetType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getBaseWidgetType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setBaseWidgetType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setBaseWidgetType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setBaseWidgetType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setBaseWidgetType'",NULL);
+#endif
+ {
+  self->setBaseWidgetType(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setBaseWidgetType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidgetLookName of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getWidgetLookName00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getWidgetLookName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidgetLookName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWidgetLookName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidgetLookName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidgetLookName of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setWidgetLookName00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setWidgetLookName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string look = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidgetLookName'",NULL);
+#endif
+ {
+  self->setWidgetLookName(look);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidgetLookName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidgetNameSuffix of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getWidgetNameSuffix00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getWidgetNameSuffix00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidgetNameSuffix'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWidgetNameSuffix();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidgetNameSuffix'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWidgetNameSuffix of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setWidgetNameSuffix00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setWidgetNameSuffix00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string suffix = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWidgetNameSuffix'",NULL);
+#endif
+ {
+  self->setWidgetNameSuffix(suffix);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWidgetNameSuffix'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWindowRendererType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getWindowRendererType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getWindowRendererType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWindowRendererType'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getWindowRendererType();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWindowRendererType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setWindowRendererType of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setWindowRendererType00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setWindowRendererType00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setWindowRendererType'",NULL);
+#endif
+ {
+  self->setWindowRendererType(type);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setWindowRendererType'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getVerticalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getVerticalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getVerticalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVerticalWidgetAlignment'",NULL);
+#endif
+ {
+  CEGUI::VerticalAlignment tolua_ret = (CEGUI::VerticalAlignment)  self->getVerticalWidgetAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getVerticalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setVerticalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setVerticalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setVerticalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::VerticalAlignment alignment = ((CEGUI::VerticalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setVerticalWidgetAlignment'",NULL);
+#endif
+ {
+  self->setVerticalWidgetAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setVerticalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getHorizontalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_getHorizontalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_getHorizontalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHorizontalWidgetAlignment'",NULL);
+#endif
+ {
+  CEGUI::HorizontalAlignment tolua_ret = (CEGUI::HorizontalAlignment)  self->getHorizontalWidgetAlignment();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getHorizontalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setHorizontalWidgetAlignment of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_setHorizontalWidgetAlignment00
+static int tolua_CEGUI_CEGUI_WidgetComponent_setHorizontalWidgetAlignment00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::HorizontalAlignment alignment = ((CEGUI::HorizontalAlignment) (int)  tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHorizontalWidgetAlignment'",NULL);
+#endif
+ {
+  self->setHorizontalWidgetAlignment(alignment);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setHorizontalWidgetAlignment'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyInitialiser of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_addPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetComponent_addPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyInitialiser* initialiser = ((const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyInitialiser'",NULL);
+#endif
+ {
+  self->addPropertyInitialiser(*initialiser);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyInitialisers of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_clearPropertyInitialisers00
+static int tolua_CEGUI_CEGUI_WidgetComponent_clearPropertyInitialisers00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetComponent* self = (CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyInitialisers'",NULL);
+#endif
+ {
+  self->clearPropertyInitialisers();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyInitialisers'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: layout of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_layout00
+static int tolua_CEGUI_CEGUI_WidgetComponent_layout00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* owner = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'layout'",NULL);
+#endif
+ {
+  self->layout(*owner);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'layout'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findPropertyInitialiser of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_findPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetComponent_findPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetComponent* self = (const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,1,0);
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findPropertyInitialiser'",NULL);
+#endif
+ {
+  const CEGUI::PropertyInitialiser* tolua_ret = (const CEGUI::PropertyInitialiser*)  self->findPropertyInitialiser(propertyName);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new00
+static int tolua_CEGUI_CEGUI_WidgetComponent_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new00_local
+static int tolua_CEGUI_CEGUI_WidgetComponent_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new01
+static int tolua_CEGUI_CEGUI_WidgetComponent_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string look = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string suffix = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string renderer = ((string)  tolua_tocppstring(tolua_S,5,0));
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent(type,look,suffix,renderer);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetComponent_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetComponent */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetComponent_new01_local
+static int tolua_CEGUI_CEGUI_WidgetComponent_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+  string type = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string look = ((string)  tolua_tocppstring(tolua_S,3,0));
+  string suffix = ((string)  tolua_tocppstring(tolua_S,4,0));
+  string renderer = ((string)  tolua_tocppstring(tolua_S,5,0));
+ {
+  CEGUI::WidgetComponent* tolua_ret = (CEGUI::WidgetComponent*)  new CEGUI::WidgetComponent(type,look,suffix,renderer);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetComponent_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getStateImagery of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getStateImagery00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getStateImagery00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string state = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getStateImagery'",NULL);
+#endif
+ {
+  CEGUI::StateImagery& tolua_ret = (CEGUI::StateImagery&)  self->getStateImagery(state);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::StateImagery");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getStateImagery'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getImagerySection of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getImagerySection00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getImagerySection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string section = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImagerySection'",NULL);
+#endif
+ {
+  CEGUI::ImagerySection& tolua_ret = (CEGUI::ImagerySection&)  self->getImagerySection(section);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::ImagerySection");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getImagerySection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getName of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getName00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'",NULL);
+#endif
+ {
+  string tolua_ret = (string)  self->getName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addImagerySection of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addImagerySection00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addImagerySection00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::ImagerySection",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::ImagerySection* section = ((const CEGUI::ImagerySection*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addImagerySection'",NULL);
+#endif
+ {
+  self->addImagerySection(*section);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addImagerySection'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addWidgetComponent of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addWidgetComponent00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addWidgetComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::WidgetComponent",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::WidgetComponent* widget = ((const CEGUI::WidgetComponent*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addWidgetComponent'",NULL);
+#endif
+ {
+  self->addWidgetComponent(*widget);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addWidgetComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addStateSpecification of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addStateSpecification00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addStateSpecification00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::StateImagery",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::StateImagery* state = ((const CEGUI::StateImagery*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addStateSpecification'",NULL);
+#endif
+ {
+  self->addStateSpecification(*state);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addStateSpecification'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyInitialiser of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyInitialiser",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyInitialiser* initialiser = ((const CEGUI::PropertyInitialiser*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyInitialiser'",NULL);
+#endif
+ {
+  self->addPropertyInitialiser(*initialiser);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearImagerySections of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearImagerySections00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearImagerySections00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearImagerySections'",NULL);
+#endif
+ {
+  self->clearImagerySections();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearImagerySections'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearWidgetComponents of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearWidgetComponents00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearWidgetComponents00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearWidgetComponents'",NULL);
+#endif
+ {
+  self->clearWidgetComponents();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearWidgetComponents'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearStateSpecifications of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearStateSpecifications00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearStateSpecifications00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearStateSpecifications'",NULL);
+#endif
+ {
+  self->clearStateSpecifications();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearStateSpecifications'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyInitialisers of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyInitialisers00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyInitialisers00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyInitialisers'",NULL);
+#endif
+ {
+  self->clearPropertyInitialisers();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyInitialisers'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: initialiseWidget of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_initialiseWidget00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_initialiseWidget00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::Window* widget = ((CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'initialiseWidget'",NULL);
+#endif
+ {
+  self->initialiseWidget(*widget);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'initialiseWidget'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isStateImageryPresent of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_isStateImageryPresent00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_isStateImageryPresent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string state = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isStateImageryPresent'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isStateImageryPresent(state);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isStateImageryPresent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addNamedArea of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addNamedArea00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addNamedArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::NamedArea",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::NamedArea* area = ((const CEGUI::NamedArea*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addNamedArea'",NULL);
+#endif
+ {
+  self->addNamedArea(*area);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addNamedArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearNamedAreas of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearNamedAreas00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearNamedAreas00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearNamedAreas'",NULL);
+#endif
+ {
+  self->clearNamedAreas();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearNamedAreas'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getNamedArea of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_getNamedArea00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_getNamedArea00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNamedArea'",NULL);
+#endif
+ {
+  const CEGUI::NamedArea& tolua_ret = (const CEGUI::NamedArea&)  self->getNamedArea(name);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::NamedArea");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getNamedArea'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isNamedAreaDefined of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_isNamedAreaDefined00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_isNamedAreaDefined00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isNamedAreaDefined'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isNamedAreaDefined(name);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isNamedAreaDefined'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: layoutChildWidgets of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_layoutChildWidgets00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_layoutChildWidgets00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* owner = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'layoutChildWidgets'",NULL);
+#endif
+ {
+  self->layoutChildWidgets(*owner);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'layoutChildWidgets'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyDefinition of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyDefinition00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyDefinition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyDefinition",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyDefinition* propdef = ((const CEGUI::PropertyDefinition*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyDefinition'",NULL);
+#endif
+ {
+  self->addPropertyDefinition(*propdef);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyDefinition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addPropertyLinkDefinition of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyLinkDefinition00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyLinkDefinition00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::PropertyLinkDefinition",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::PropertyLinkDefinition* propdef = ((const CEGUI::PropertyLinkDefinition*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addPropertyLinkDefinition'",NULL);
+#endif
+ {
+  self->addPropertyLinkDefinition(*propdef);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addPropertyLinkDefinition'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyDefinitions of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyDefinitions00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyDefinitions00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyDefinitions'",NULL);
+#endif
+ {
+  self->clearPropertyDefinitions();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyDefinitions'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: clearPropertyLinkDefinitions of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyLinkDefinitions00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyLinkDefinitions00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookFeel* self = (CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'clearPropertyLinkDefinitions'",NULL);
+#endif
+ {
+  self->clearPropertyLinkDefinitions();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'clearPropertyLinkDefinitions'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: renameChildren of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_renameChildren00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_renameChildren00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"const CEGUI::Window",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  const CEGUI::Window* widget = ((const CEGUI::Window*)  tolua_tousertype(tolua_S,2,0));
+  string newBaseName = ((string)  tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'renameChildren'",NULL);
+#endif
+ {
+  self->renameChildren(*widget,newBaseName);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'renameChildren'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findPropertyInitialiser of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_findPropertyInitialiser00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_findPropertyInitialiser00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string propertyName = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findPropertyInitialiser'",NULL);
+#endif
+ {
+  const CEGUI::PropertyInitialiser* tolua_ret = (const CEGUI::PropertyInitialiser*)  self->findPropertyInitialiser(propertyName);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::PropertyInitialiser");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findPropertyInitialiser'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: findWidgetComponent of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_findWidgetComponent00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_findWidgetComponent00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookFeel* self = (const CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,1,0);
+  string nameSuffix = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'findWidgetComponent'",NULL);
+#endif
+ {
+  const CEGUI::WidgetComponent* tolua_ret = (const CEGUI::WidgetComponent*)  self->findWidgetComponent(nameSuffix);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"const CEGUI::WidgetComponent");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'findWidgetComponent'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new00
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel(name);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel(name);
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new01
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetLookFeel_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetLookFeel */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local
+static int tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ {
+  CEGUI::WidgetLookFeel* tolua_ret = (CEGUI::WidgetLookFeel*)  new CEGUI::WidgetLookFeel();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getSingleton of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_getSingleton00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_getSingleton00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetLookManager& tolua_ret = (CEGUI::WidgetLookManager&)  CEGUI::WidgetLookManager::getSingleton();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"CEGUI::WidgetLookManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getSingleton'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: parseLookNFeelSpecification of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_parseLookNFeelSpecification00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_parseLookNFeelSpecification00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string filename = ((string)  tolua_tocppstring(tolua_S,2,0));
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,3,""));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'parseLookNFeelSpecification'",NULL);
+#endif
+ {
+  self->parseLookNFeelSpecification(filename,resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'parseLookNFeelSpecification'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: isWidgetLookAvailable of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_isWidgetLookAvailable00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_isWidgetLookAvailable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string widget = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isWidgetLookAvailable'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->isWidgetLookAvailable(widget);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'isWidgetLookAvailable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getWidgetLook of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_getWidgetLook00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_getWidgetLook00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string widget = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidgetLook'",NULL);
+#endif
+ {
+  const CEGUI::WidgetLookFeel& tolua_ret = (const CEGUI::WidgetLookFeel&)  self->getWidgetLook(widget);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const CEGUI::WidgetLookFeel");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getWidgetLook'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: eraseWidgetLook of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_eraseWidgetLook00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_eraseWidgetLook00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string widget = ((string)  tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'eraseWidgetLook'",NULL);
+#endif
+ {
+  self->eraseWidgetLook(widget);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'eraseWidgetLook'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: addWidgetLook of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_addWidgetLook00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_addWidgetLook00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,2,"CEGUI::WidgetLookFeel",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::WidgetLookManager* self = (CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  CEGUI::WidgetLookFeel* look = ((CEGUI::WidgetLookFeel*)  tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addWidgetLook'",NULL);
+#endif
+ {
+  self->addWidgetLook(*look);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'addWidgetLook'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWidgetLookToStream of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookToStream00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookToStream00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string name = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::OutStream* out_stream = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWidgetLookToStream'",NULL);
+#endif
+ {
+  self->writeWidgetLookToStream(name,*out_stream);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'writeWidgetLookToStream'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: writeWidgetLookSeriesToStream of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookSeriesToStream00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookSeriesToStream00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,3,"CEGUI::OutStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  const CEGUI::WidgetLookManager* self = (const CEGUI::WidgetLookManager*)  tolua_tousertype(tolua_S,1,0);
+  string prefix = ((string)  tolua_tocppstring(tolua_S,2,0));
+  CEGUI::OutStream* out_stream = ((CEGUI::OutStream*)  tolua_tousertype(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'writeWidgetLookSeriesToStream'",NULL);
+#endif
+ {
+  self->writeWidgetLookSeriesToStream(prefix,*out_stream);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'writeWidgetLookSeriesToStream'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_new00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetLookManager* tolua_ret = (CEGUI::WidgetLookManager*)  new CEGUI::WidgetLookManager();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::WidgetLookManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_new00_local
+static int tolua_CEGUI_CEGUI_WidgetLookManager_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::WidgetLookManager* tolua_ret = (CEGUI::WidgetLookManager*)  new CEGUI::WidgetLookManager();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::WidgetLookManager");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: setDefaultResourceGroup of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_setDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_setDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string resourceGroup = ((string)  tolua_tocppstring(tolua_S,2,0));
+ {
+  CEGUI::WidgetLookManager::setDefaultResourceGroup(resourceGroup);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'setDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: getDefaultResourceGroup of class  CEGUI::WidgetLookManager */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_WidgetLookManager_getDefaultResourceGroup00
+static int tolua_CEGUI_CEGUI_WidgetLookManager_getDefaultResourceGroup00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::WidgetLookManager",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  string tolua_ret = (string)  CEGUI::WidgetLookManager::getDefaultResourceGroup();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'getDefaultResourceGroup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* function: CEGUI::ceguiLua_createListboxTextItem */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_createListboxTextItem00
+static int tolua_CEGUI_CEGUI_createListboxTextItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_iscppstring(tolua_S,1,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,1,&tolua_err) ||
+ !tolua_isuserdata(tolua_S,3,1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  string text = ((string)  tolua_tocppstring(tolua_S,1,0));
+  unsigned int item_id = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
+  void* item_data = ((void*)  tolua_touserdata(tolua_S,3,0));
+  bool disabled = ((bool)  tolua_toboolean(tolua_S,4,false));
+  bool auto_delete = ((bool)  tolua_toboolean(tolua_S,5,true));
+ {
+  CEGUI::ListboxTextItem* tolua_ret = (CEGUI::ListboxTextItem*)  CEGUI::ceguiLua_createListboxTextItem(text,item_id,item_data,disabled,auto_delete);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::ListboxTextItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'createListboxTextItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_new00
+static int tolua_CEGUI_CEGUI_FileStream_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FileStream* tolua_ret = (CEGUI::FileStream*)  new CEGUI::FileStream();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"CEGUI::FileStream");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_new00_local
+static int tolua_CEGUI_CEGUI_FileStream_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ {
+  CEGUI::FileStream* tolua_ret = (CEGUI::FileStream*)  new CEGUI::FileStream();
+ tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"CEGUI::FileStream");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: is_open of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_is_open00
+static int tolua_CEGUI_CEGUI_FileStream_is_open00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FileStream* self = (CEGUI::FileStream*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'is_open'",NULL);
+#endif
+ {
+  bool tolua_ret = (bool)  self->is_open();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'is_open'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: CEGUI::ceguiLua_FileStream_open of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_open00
+static int tolua_CEGUI_CEGUI_FileStream_open00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FileStream* self = (CEGUI::FileStream*)  tolua_tousertype(tolua_S,1,0);
+  const char* filename = ((const char*)  tolua_tostring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CEGUI::ceguiLua_FileStream_open'",NULL);
+#endif
+ {
+  CEGUI::ceguiLua_FileStream_open(self,filename);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'open'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: close of class  CEGUI::FileStream */
+#ifndef TOLUA_DISABLE_tolua_CEGUI_CEGUI_FileStream_close00
+static int tolua_CEGUI_CEGUI_FileStream_close00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"CEGUI::FileStream",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+  CEGUI::FileStream* self = (CEGUI::FileStream*)  tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'close'",NULL);
+#endif
+ {
+  self->close();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'close'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* Open function */
+int tolua_CEGUI_open (lua_State* tolua_S)
+{
+ tolua_open(tolua_S);
+ tolua_reg_types(tolua_S);
+ tolua_module(tolua_S,NULL,0);
+ tolua_beginmodule(tolua_S,NULL);
+ tolua_module(tolua_S,"CEGUI",0);
+ tolua_beginmodule(tolua_S,"CEGUI");
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Vector2","CEGUI::Vector2","",tolua_collect_CEGUI__Vector2);
+  #else
+  tolua_cclass(tolua_S,"Vector2","CEGUI::Vector2","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Vector2");
+   tolua_variable(tolua_S,"x",tolua_get_CEGUI__Vector2_x,tolua_set_CEGUI__Vector2_x);
+   tolua_variable(tolua_S,"y",tolua_get_CEGUI__Vector2_y,tolua_set_CEGUI__Vector2_y);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_Vector2__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_Vector2__sub00);
+   tolua_function(tolua_S,".mul",tolua_CEGUI_CEGUI_Vector2__mul00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_Vector2__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Vector2_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Vector2_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Vector2_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Vector2_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Vector2_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Vector2_new01_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 80,111,105,110,116, 32, 61, 32,
+    67, 69, 71, 85, 73, 46, 86,101, 99,116,111,114, 50,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 1");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Size","CEGUI::Size","",tolua_collect_CEGUI__Size);
+  #else
+  tolua_cclass(tolua_S,"Size","CEGUI::Size","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Size");
+   tolua_variable(tolua_S,"width",tolua_get_CEGUI__Size_width,tolua_set_CEGUI__Size_width);
+   tolua_variable(tolua_S,"height",tolua_get_CEGUI__Size_height,tolua_set_CEGUI__Size_height);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_Size__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Size_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Size_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Size_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Size_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Size_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Size_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Rect","CEGUI::Rect","",tolua_collect_CEGUI__Rect);
+  #else
+  tolua_cclass(tolua_S,"Rect","CEGUI::Rect","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Rect");
+   tolua_variable(tolua_S,"top",tolua_get_CEGUI__Rect_top,tolua_set_CEGUI__Rect_top);
+   tolua_variable(tolua_S,"bottom",tolua_get_CEGUI__Rect_bottom,tolua_set_CEGUI__Rect_bottom);
+   tolua_variable(tolua_S,"left",tolua_get_CEGUI__Rect_left,tolua_set_CEGUI__Rect_left);
+   tolua_variable(tolua_S,"right",tolua_get_CEGUI__Rect_right,tolua_set_CEGUI__Rect_right);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_Rect_getPosition00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Rect_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Rect_getHeight00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Rect_getSize00);
+   tolua_function(tolua_S,"getIntersection",tolua_CEGUI_CEGUI_Rect_getIntersection00);
+   tolua_function(tolua_S,"isPointInRect",tolua_CEGUI_CEGUI_Rect_isPointInRect00);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_Rect_setPosition00);
+   tolua_function(tolua_S,"setWidth",tolua_CEGUI_CEGUI_Rect_setWidth00);
+   tolua_function(tolua_S,"setHeight",tolua_CEGUI_CEGUI_Rect_setHeight00);
+   tolua_function(tolua_S,"setSize",tolua_CEGUI_CEGUI_Rect_setSize00);
+   tolua_function(tolua_S,"offset",tolua_CEGUI_CEGUI_Rect_offset00);
+   tolua_function(tolua_S,"constrainSizeMax",tolua_CEGUI_CEGUI_Rect_constrainSizeMax00);
+   tolua_function(tolua_S,"constrainSizeMin",tolua_CEGUI_CEGUI_Rect_constrainSizeMin00);
+   tolua_function(tolua_S,"constrainSize",tolua_CEGUI_CEGUI_Rect_constrainSize00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_Rect__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Rect_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Rect_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Rect_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Rect_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Rect_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Rect_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"colour","CEGUI::colour","",tolua_collect_CEGUI__colour);
+  #else
+  tolua_cclass(tolua_S,"colour","CEGUI::colour","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"colour");
+   tolua_function(tolua_S,"getAlpha",tolua_CEGUI_CEGUI_colour_getAlpha00);
+   tolua_function(tolua_S,"getRed",tolua_CEGUI_CEGUI_colour_getRed00);
+   tolua_function(tolua_S,"getGreen",tolua_CEGUI_CEGUI_colour_getGreen00);
+   tolua_function(tolua_S,"getBlue",tolua_CEGUI_CEGUI_colour_getBlue00);
+   tolua_function(tolua_S,"getHue",tolua_CEGUI_CEGUI_colour_getHue00);
+   tolua_function(tolua_S,"getSaturation",tolua_CEGUI_CEGUI_colour_getSaturation00);
+   tolua_function(tolua_S,"getLumination",tolua_CEGUI_CEGUI_colour_getLumination00);
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_colour_set00);
+   tolua_function(tolua_S,"setAlpha",tolua_CEGUI_CEGUI_colour_setAlpha00);
+   tolua_function(tolua_S,"setRed",tolua_CEGUI_CEGUI_colour_setRed00);
+   tolua_function(tolua_S,"setGreen",tolua_CEGUI_CEGUI_colour_setGreen00);
+   tolua_function(tolua_S,"setBlue",tolua_CEGUI_CEGUI_colour_setBlue00);
+   tolua_function(tolua_S,"setRGB",tolua_CEGUI_CEGUI_colour_setRGB00);
+   tolua_function(tolua_S,"setHSL",tolua_CEGUI_CEGUI_colour_setHSL00);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_colour__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_colour__sub00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_colour__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_colour_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_colour_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_colour_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_colour_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_colour_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_colour_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ColourRect","CEGUI::ColourRect","",tolua_collect_CEGUI__ColourRect);
+  #else
+  tolua_cclass(tolua_S,"ColourRect","CEGUI::ColourRect","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ColourRect");
+   tolua_variable(tolua_S,"top_left",tolua_get_CEGUI__ColourRect_top_left,tolua_set_CEGUI__ColourRect_top_left);
+   tolua_variable(tolua_S,"top_right",tolua_get_CEGUI__ColourRect_top_right,tolua_set_CEGUI__ColourRect_top_right);
+   tolua_variable(tolua_S,"bottom_left",tolua_get_CEGUI__ColourRect_bottom_left,tolua_set_CEGUI__ColourRect_bottom_left);
+   tolua_variable(tolua_S,"bottom_right",tolua_get_CEGUI__ColourRect_bottom_right,tolua_set_CEGUI__ColourRect_bottom_right);
+   tolua_function(tolua_S,"setAlpha",tolua_CEGUI_CEGUI_ColourRect_setAlpha00);
+   tolua_function(tolua_S,"setTopAlpha",tolua_CEGUI_CEGUI_ColourRect_setTopAlpha00);
+   tolua_function(tolua_S,"setBottomAlpha",tolua_CEGUI_CEGUI_ColourRect_setBottomAlpha00);
+   tolua_function(tolua_S,"setLeftAlpha",tolua_CEGUI_CEGUI_ColourRect_setLeftAlpha00);
+   tolua_function(tolua_S,"setRightAlpha",tolua_CEGUI_CEGUI_ColourRect_setRightAlpha00);
+   tolua_function(tolua_S,"modulateAlpha",tolua_CEGUI_CEGUI_ColourRect_modulateAlpha00);
+   tolua_function(tolua_S,"setColours",tolua_CEGUI_CEGUI_ColourRect_setColours00);
+   tolua_function(tolua_S,"isMonochromatic",tolua_CEGUI_CEGUI_ColourRect_isMonochromatic00);
+   tolua_function(tolua_S,"getSubRectangle",tolua_CEGUI_CEGUI_ColourRect_getSubRectangle00);
+   tolua_function(tolua_S,"getColourAtPoint",tolua_CEGUI_CEGUI_ColourRect_getColourAtPoint00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ColourRect_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ColourRect_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ColourRect_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ColourRect_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ColourRect_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ColourRect_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ColourRect_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ColourRect_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ColourRect_new02_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"String","CEGUI::String","",tolua_collect_CEGUI__String);
+  #else
+  tolua_cclass(tolua_S,"String","CEGUI::String","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"String");
+   tolua_variable(tolua_S,"npos",tolua_get_CEGUI__String_unsigned_npos,NULL);
+   tolua_function(tolua_S,"size",tolua_CEGUI_CEGUI_String_size00);
+   tolua_function(tolua_S,"length",tolua_CEGUI_CEGUI_String_length00);
+   tolua_function(tolua_S,"empty",tolua_CEGUI_CEGUI_String_empty00);
+   tolua_function(tolua_S,"capacity",tolua_CEGUI_CEGUI_String_capacity00);
+   tolua_function(tolua_S,".seti",tolua_CEGUI_CEGUI_String__seti00);
+   tolua_function(tolua_S,".geti",tolua_CEGUI_CEGUI_String__geti00);
+   tolua_function(tolua_S,"at",tolua_CEGUI_CEGUI_String_at00);
+   tolua_function(tolua_S,"c_str",tolua_CEGUI_CEGUI_String_c_str00);
+   tolua_function(tolua_S,"reserve",tolua_CEGUI_CEGUI_String_reserve00);
+   tolua_function(tolua_S,"resize",tolua_CEGUI_CEGUI_String_resize00);
+   tolua_function(tolua_S,"resize",tolua_CEGUI_CEGUI_String_resize01);
+   tolua_function(tolua_S,"clear",tolua_CEGUI_CEGUI_String_clear00);
+   tolua_function(tolua_S,"erase",tolua_CEGUI_CEGUI_String_erase00);
+   tolua_function(tolua_S,"erase",tolua_CEGUI_CEGUI_String_erase01);
+   tolua_function(tolua_S,"replace",tolua_CEGUI_CEGUI_String_replace00);
+   tolua_function(tolua_S,"swap",tolua_CEGUI_CEGUI_String_swap00);
+   tolua_function(tolua_S,"insert",tolua_CEGUI_CEGUI_String_insert00);
+   tolua_function(tolua_S,"find",tolua_CEGUI_CEGUI_String_find00);
+   tolua_function(tolua_S,"rfind",tolua_CEGUI_CEGUI_String_rfind00);
+   tolua_function(tolua_S,"find",tolua_CEGUI_CEGUI_String_find01);
+   tolua_function(tolua_S,"rfind",tolua_CEGUI_CEGUI_String_rfind01);
+   tolua_function(tolua_S,"substr",tolua_CEGUI_CEGUI_String_substr00);
+   tolua_function(tolua_S,"push_back",tolua_CEGUI_CEGUI_String_push_back00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new02_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_String_new03);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_String_new03_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_String_new03_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"UDim","CEGUI::UDim","",tolua_collect_CEGUI__UDim);
+  #else
+  tolua_cclass(tolua_S,"UDim","CEGUI::UDim","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"UDim");
+   tolua_variable(tolua_S,"scale",tolua_get_CEGUI__UDim_scale,tolua_set_CEGUI__UDim_scale);
+   tolua_variable(tolua_S,"offset",tolua_get_CEGUI__UDim_offset,tolua_set_CEGUI__UDim_offset);
+   tolua_function(tolua_S,"asAbsolute",tolua_CEGUI_CEGUI_UDim_asAbsolute00);
+   tolua_function(tolua_S,"asRelative",tolua_CEGUI_CEGUI_UDim_asRelative00);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_UDim__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_UDim__sub00);
+   tolua_function(tolua_S,".div",tolua_CEGUI_CEGUI_UDim__div00);
+   tolua_function(tolua_S,".mul",tolua_CEGUI_CEGUI_UDim__mul00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_UDim__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UDim_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UDim_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UDim_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UDim_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"UVector2","CEGUI::UVector2","",tolua_collect_CEGUI__UVector2);
+  #else
+  tolua_cclass(tolua_S,"UVector2","CEGUI::UVector2","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"UVector2");
+   tolua_variable(tolua_S,"x",tolua_get_CEGUI__UVector2_x,tolua_set_CEGUI__UVector2_x);
+   tolua_variable(tolua_S,"y",tolua_get_CEGUI__UVector2_y,tolua_set_CEGUI__UVector2_y);
+   tolua_function(tolua_S,"asAbsolute",tolua_CEGUI_CEGUI_UVector2_asAbsolute00);
+   tolua_function(tolua_S,"asRelative",tolua_CEGUI_CEGUI_UVector2_asRelative00);
+   tolua_function(tolua_S,".add",tolua_CEGUI_CEGUI_UVector2__add00);
+   tolua_function(tolua_S,".sub",tolua_CEGUI_CEGUI_UVector2__sub00);
+   tolua_function(tolua_S,".div",tolua_CEGUI_CEGUI_UVector2__div00);
+   tolua_function(tolua_S,".mul",tolua_CEGUI_CEGUI_UVector2__mul00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_UVector2__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UVector2_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UVector2_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UVector2_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UVector2_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UVector2_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UVector2_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"URect","CEGUI::URect","",tolua_collect_CEGUI__URect);
+  #else
+  tolua_cclass(tolua_S,"URect","CEGUI::URect","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"URect");
+   tolua_variable(tolua_S,"min",tolua_get_CEGUI__URect_min,tolua_set_CEGUI__URect_min);
+   tolua_variable(tolua_S,"max",tolua_get_CEGUI__URect_max,tolua_set_CEGUI__URect_max);
+   tolua_function(tolua_S,"asAbsolute",tolua_CEGUI_CEGUI_URect_asAbsolute00);
+   tolua_function(tolua_S,"asRelative",tolua_CEGUI_CEGUI_URect_asRelative00);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_URect_getPosition00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_URect_getSize00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_URect_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_URect_getHeight00);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_URect_setPosition00);
+   tolua_function(tolua_S,"setSize",tolua_CEGUI_CEGUI_URect_setSize00);
+   tolua_function(tolua_S,"setWidth",tolua_CEGUI_CEGUI_URect_setWidth00);
+   tolua_function(tolua_S,"setHeight",tolua_CEGUI_CEGUI_URect_setHeight00);
+   tolua_function(tolua_S,"offset",tolua_CEGUI_CEGUI_URect_offset00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_URect_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_URect_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_URect_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_URect_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_URect_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_URect_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_URect_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_URect_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_URect_new02_local);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"Errors",CEGUI::Errors);
+  tolua_constant(tolua_S,"Warnings",CEGUI::Warnings);
+  tolua_constant(tolua_S,"Standard",CEGUI::Standard);
+  tolua_constant(tolua_S,"Informative",CEGUI::Informative);
+  tolua_constant(tolua_S,"Insane",CEGUI::Insane);
+  tolua_cclass(tolua_S,"Logger","CEGUI::Logger","",NULL);
+  tolua_beginmodule(tolua_S,"Logger");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_Logger_getSingleton00);
+   tolua_function(tolua_S,"setLoggingLevel",tolua_CEGUI_CEGUI_Logger_setLoggingLevel00);
+   tolua_function(tolua_S,"getLoggingLevel",tolua_CEGUI_CEGUI_Logger_getLoggingLevel00);
+   tolua_function(tolua_S,"logEvent",tolua_CEGUI_CEGUI_Logger_logEvent00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"LeftAligned",CEGUI::LeftAligned);
+  tolua_constant(tolua_S,"RightAligned",CEGUI::RightAligned);
+  tolua_constant(tolua_S,"Centred",CEGUI::Centred);
+  tolua_constant(tolua_S,"Justified",CEGUI::Justified);
+  tolua_constant(tolua_S,"WordWrapLeftAligned",CEGUI::WordWrapLeftAligned);
+  tolua_constant(tolua_S,"WordWrapRightAligned",CEGUI::WordWrapRightAligned);
+  tolua_constant(tolua_S,"WordWrapCentred",CEGUI::WordWrapCentred);
+  tolua_constant(tolua_S,"WordWrapJustified",CEGUI::WordWrapJustified);
+  tolua_cclass(tolua_S,"Font","CEGUI::Font","",NULL);
+  tolua_beginmodule(tolua_S,"Font");
+   tolua_function(tolua_S,"setProperty",tolua_CEGUI_CEGUI_Font_setProperty00);
+   tolua_function(tolua_S,"getProperty",tolua_CEGUI_CEGUI_Font_getProperty00);
+   tolua_function(tolua_S,"getPropertyDefault",tolua_CEGUI_CEGUI_Font_getPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyHelp",tolua_CEGUI_CEGUI_Font_getPropertyHelp00);
+   tolua_function(tolua_S,"isPropertyPresent",tolua_CEGUI_CEGUI_Font_isPropertyPresent00);
+   tolua_function(tolua_S,"isPropertyDefault",tolua_CEGUI_CEGUI_Font_isPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyIterator",tolua_CEGUI_CEGUI_Font_getPropertyIterator00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_Font_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_Font_getDefaultResourceGroup00);
+   tolua_function(tolua_S,"load",tolua_CEGUI_CEGUI_Font_load00);
+   tolua_function(tolua_S,"isCodepointAvailable",tolua_CEGUI_CEGUI_Font_isCodepointAvailable00);
+   tolua_function(tolua_S,"setNativeResolution",tolua_CEGUI_CEGUI_Font_setNativeResolution00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_Font_notifyScreenResolution00);
+   tolua_function(tolua_S,"getTextExtent",tolua_CEGUI_CEGUI_Font_getTextExtent00);
+   tolua_function(tolua_S,"getLineSpacing",tolua_CEGUI_CEGUI_Font_getLineSpacing00);
+   tolua_function(tolua_S,"getFontHeight",tolua_CEGUI_CEGUI_Font_getFontHeight00);
+   tolua_function(tolua_S,"getCharAtPixel",tolua_CEGUI_CEGUI_Font_getCharAtPixel00);
+   tolua_function(tolua_S,"getCharAtPixel",tolua_CEGUI_CEGUI_Font_getCharAtPixel01);
+   tolua_function(tolua_S,"getFormattedLineCount",tolua_CEGUI_CEGUI_Font_getFormattedLineCount00);
+   tolua_function(tolua_S,"getFormattedTextExtent",tolua_CEGUI_CEGUI_Font_getFormattedTextExtent00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"FontManager","CEGUI::FontManager","",NULL);
+  tolua_beginmodule(tolua_S,"FontManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_FontManager_getSingleton00);
+   tolua_function(tolua_S,"createFont",tolua_CEGUI_CEGUI_FontManager_createFont00);
+   tolua_function(tolua_S,"createFont",tolua_CEGUI_CEGUI_FontManager_createFont01);
+   tolua_function(tolua_S,"destroyFont",tolua_CEGUI_CEGUI_FontManager_destroyFont00);
+   tolua_function(tolua_S,"destroyFont",tolua_CEGUI_CEGUI_FontManager_destroyFont01);
+   tolua_function(tolua_S,"destroyAllFonts",tolua_CEGUI_CEGUI_FontManager_destroyAllFonts00);
+   tolua_function(tolua_S,"isFontPresent",tolua_CEGUI_CEGUI_FontManager_isFontPresent00);
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_FontManager_getFont00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_FontManager_notifyScreenResolution00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_FontManager_getIterator00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Image","CEGUI::Image","",tolua_collect_CEGUI__Image);
+  #else
+  tolua_cclass(tolua_S,"Image","CEGUI::Image","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Image");
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Image_getSize00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Image_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Image_getHeight00);
+   tolua_function(tolua_S,"getOffsets",tolua_CEGUI_CEGUI_Image_getOffsets00);
+   tolua_function(tolua_S,"getOffsetX",tolua_CEGUI_CEGUI_Image_getOffsetX00);
+   tolua_function(tolua_S,"getOffsetY",tolua_CEGUI_CEGUI_Image_getOffsetY00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Image_getName00);
+   tolua_function(tolua_S,"getImagesetName",tolua_CEGUI_CEGUI_Image_getImagesetName00);
+   tolua_function(tolua_S,"getSourceTextureArea",tolua_CEGUI_CEGUI_Image_getSourceTextureArea00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Texture","CEGUI::Texture","",NULL);
+  tolua_beginmodule(tolua_S,"Texture");
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Texture_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Texture_getHeight00);
+   tolua_function(tolua_S,"loadFromFile",tolua_CEGUI_CEGUI_Texture_loadFromFile00);
+   tolua_function(tolua_S,"getRenderer",tolua_CEGUI_CEGUI_Texture_getRenderer00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Imageset","CEGUI::Imageset","",NULL);
+  tolua_beginmodule(tolua_S,"Imageset");
+   tolua_function(tolua_S,"getTexture",tolua_CEGUI_CEGUI_Imageset_getTexture00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Imageset_getName00);
+   tolua_function(tolua_S,"getImageCount",tolua_CEGUI_CEGUI_Imageset_getImageCount00);
+   tolua_function(tolua_S,"isImageDefined",tolua_CEGUI_CEGUI_Imageset_isImageDefined00);
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_Imageset_getImage00);
+   tolua_function(tolua_S,"undefineImage",tolua_CEGUI_CEGUI_Imageset_undefineImage00);
+   tolua_function(tolua_S,"undefineAllImages",tolua_CEGUI_CEGUI_Imageset_undefineAllImages00);
+   tolua_function(tolua_S,"getImageSize",tolua_CEGUI_CEGUI_Imageset_getImageSize00);
+   tolua_function(tolua_S,"getImageWidth",tolua_CEGUI_CEGUI_Imageset_getImageWidth00);
+   tolua_function(tolua_S,"getImageHeight",tolua_CEGUI_CEGUI_Imageset_getImageHeight00);
+   tolua_function(tolua_S,"getImageOffset",tolua_CEGUI_CEGUI_Imageset_getImageOffset00);
+   tolua_function(tolua_S,"getImageOffsetX",tolua_CEGUI_CEGUI_Imageset_getImageOffsetX00);
+   tolua_function(tolua_S,"getImageOffsetY",tolua_CEGUI_CEGUI_Imageset_getImageOffsetY00);
+   tolua_function(tolua_S,"defineImage",tolua_CEGUI_CEGUI_Imageset_defineImage00);
+   tolua_function(tolua_S,"defineImage",tolua_CEGUI_CEGUI_Imageset_defineImage01);
+   tolua_function(tolua_S,"isAutoScaled",tolua_CEGUI_CEGUI_Imageset_isAutoScaled00);
+   tolua_function(tolua_S,"setAutoScalingEnabled",tolua_CEGUI_CEGUI_Imageset_setAutoScalingEnabled00);
+   tolua_function(tolua_S,"getNativeResolution",tolua_CEGUI_CEGUI_Imageset_getNativeResolution00);
+   tolua_function(tolua_S,"setNativeResolution",tolua_CEGUI_CEGUI_Imageset_setNativeResolution00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_Imageset_notifyScreenResolution00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_Imageset_getIterator00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_Imageset_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_Imageset_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ImagesetManager","CEGUI::ImagesetManager","",NULL);
+  tolua_beginmodule(tolua_S,"ImagesetManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_ImagesetManager_getSingleton00);
+   tolua_function(tolua_S,"createImageset",tolua_CEGUI_CEGUI_ImagesetManager_createImageset00);
+   tolua_function(tolua_S,"createImageset",tolua_CEGUI_CEGUI_ImagesetManager_createImageset01);
+   tolua_function(tolua_S,"createImagesetFromImageFile",tolua_CEGUI_CEGUI_ImagesetManager_createImagesetFromImageFile00);
+   tolua_function(tolua_S,"destroyImageset",tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset00);
+   tolua_function(tolua_S,"destroyImageset",tolua_CEGUI_CEGUI_ImagesetManager_destroyImageset01);
+   tolua_function(tolua_S,"destroyAllImagesets",tolua_CEGUI_CEGUI_ImagesetManager_destroyAllImagesets00);
+   tolua_function(tolua_S,"getImageset",tolua_CEGUI_CEGUI_ImagesetManager_getImageset00);
+   tolua_function(tolua_S,"isImagesetPresent",tolua_CEGUI_CEGUI_ImagesetManager_isImagesetPresent00);
+   tolua_function(tolua_S,"notifyScreenResolution",tolua_CEGUI_CEGUI_ImagesetManager_notifyScreenResolution00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_ImagesetManager_getIterator00);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73,
+    46,105,116,101,114, 97,116,111,114, 95,105,109,112,108, 95,
+   110,101,120,116, 40,112, 41, 10,105,102, 32,112, 58,105,115,
+    65,116, 69,110,100, 40, 41, 32,116,104,101,110, 10,114,101,
+   116,117,114,110, 32,110,105,108, 59, 10,101,110,100, 10,108,
+   111, 99, 97,108, 32,107, 44,118, 32, 61, 32,112, 58,107,101,
+   121, 40, 41, 44, 32,112, 58,118, 97,108,117,101, 40, 41, 59,
+    10,112, 58,110,101,120,116, 40, 41, 59, 10,114,101,116,117,
+   114,110, 32,107, 44,118, 59, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,105,116,101,
+   114, 97,116,111,114, 95,105,109,112,108, 40,115,101,108,102,
+    41, 10,114,101,116,117,114,110, 32, 67, 69, 71, 85, 73, 46,
+   105,116,101,114, 97,116,111,114, 95,105,109,112,108, 95,110,
+   101,120,116, 44, 32,115,101,108,102, 59, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 2");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  tolua_cclass(tolua_S,"Property","CEGUI::Property","",NULL);
+  tolua_beginmodule(tolua_S,"Property");
+   tolua_function(tolua_S,"getHelp",tolua_CEGUI_CEGUI_Property_getHelp00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Property_getName00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyIterator","CEGUI::PropertyIterator","",tolua_collect_CEGUI__PropertyIterator);
+  #else
+  tolua_cclass(tolua_S,"PropertyIterator","CEGUI::PropertyIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_PropertyIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_PropertyIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_PropertyIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_PropertyIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_PropertyIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_PropertyIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_PropertyIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_PropertyIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_PropertyIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 80,114,111,112,101,114,116,121,
+    73,116,101,114, 97,116,111,114, 46,105,116,101,114, 97,116,
+   111,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114,
+    97,116,111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 3");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"EventIterator","CEGUI::EventIterator","",tolua_collect_CEGUI__EventIterator);
+  #else
+  tolua_cclass(tolua_S,"EventIterator","CEGUI::EventIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"EventIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_EventIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_EventIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_EventIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_EventIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_EventIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_EventIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_EventIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_EventIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_EventIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_EventIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_EventIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_EventIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116, 73,116,101,
+   114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,111,
+   114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 4");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WindowIterator","CEGUI::WindowIterator","",tolua_collect_CEGUI__WindowIterator);
+  #else
+  tolua_cclass(tolua_S,"WindowIterator","CEGUI::WindowIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WindowIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_WindowIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_WindowIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_WindowIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_WindowIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_WindowIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_WindowIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_WindowIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_WindowIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_WindowIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WindowIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WindowIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WindowIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 73,116,
+   101,114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114,
+    32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,
+   111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 5");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WindowFactoryIterator","CEGUI::WindowFactoryIterator","",tolua_collect_CEGUI__WindowFactoryIterator);
+  #else
+  tolua_cclass(tolua_S,"WindowFactoryIterator","CEGUI::WindowFactoryIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WindowFactoryIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_WindowFactoryIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_WindowFactoryIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_WindowFactoryIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_WindowFactoryIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_WindowFactoryIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_WindowFactoryIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_WindowFactoryIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_WindowFactoryIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WindowFactoryIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WindowFactoryIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 70, 97,
+    99,116,111,114,121, 73,116,101,114, 97,116,111,114, 46,105,
+   116,101,114, 97,116,111,114, 32, 61, 32, 67, 69, 71, 85, 73,
+    46,105,116,101,114, 97,116,111,114, 95,105,109,112,108, 59,
+   32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 6");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FalagardMappingIterator","CEGUI::FalagardMappingIterator","",tolua_collect_CEGUI__FalagardMappingIterator);
+  #else
+  tolua_cclass(tolua_S,"FalagardMappingIterator","CEGUI::FalagardMappingIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FalagardMappingIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_FalagardMappingIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_FalagardMappingIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_FalagardMappingIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_FalagardMappingIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_FalagardMappingIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_FalagardMappingIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_FalagardMappingIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_FalagardMappingIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FalagardMappingIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FalagardMappingIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 70, 97,108, 97,103, 97,114,100,
+    77, 97,112,112,105,110,103, 73,116,101,114, 97,116,111,114,
+    46,105,116,101,114, 97,116,111,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,105,116,101,114, 97,116,111,114, 95,105,109,112,
+   108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 7");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImagesetIterator","CEGUI::ImagesetIterator","",tolua_collect_CEGUI__ImagesetIterator);
+  #else
+  tolua_cclass(tolua_S,"ImagesetIterator","CEGUI::ImagesetIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImagesetIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_ImagesetIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_ImagesetIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_ImagesetIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_ImagesetIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_ImagesetIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_ImagesetIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_ImagesetIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_ImagesetIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_ImagesetIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImagesetIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImagesetIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImagesetIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 73,109, 97,103,101,115,101,116,
+    73,116,101,114, 97,116,111,114, 46,105,116,101,114, 97,116,
+   111,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114,
+    97,116,111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 8");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImageIterator","CEGUI::ImageIterator","",tolua_collect_CEGUI__ImageIterator);
+  #else
+  tolua_cclass(tolua_S,"ImageIterator","CEGUI::ImageIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImageIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_ImageIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_ImageIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_ImageIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_ImageIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_ImageIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_ImageIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_ImageIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_ImageIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_ImageIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImageIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImageIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImageIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 73,109, 97,103,101, 73,116,101,
+   114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,111,
+   114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 9");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"SchemeIterator","CEGUI::SchemeIterator","",tolua_collect_CEGUI__SchemeIterator);
+  #else
+  tolua_cclass(tolua_S,"SchemeIterator","CEGUI::SchemeIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"SchemeIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_SchemeIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_SchemeIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_SchemeIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_SchemeIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_SchemeIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_SchemeIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_SchemeIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_SchemeIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_SchemeIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_SchemeIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_SchemeIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_SchemeIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 83, 99,104,101,109,101, 73,116,
+   101,114, 97,116,111,114, 46,105,116,101,114, 97,116,111,114,
+    32, 61, 32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,
+   111,114, 95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 10");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FontIterator","CEGUI::FontIterator","",tolua_collect_CEGUI__FontIterator);
+  #else
+  tolua_cclass(tolua_S,"FontIterator","CEGUI::FontIterator","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FontIterator");
+   tolua_function(tolua_S,"key",tolua_CEGUI_CEGUI_FontIterator_key00);
+   tolua_function(tolua_S,"value",tolua_CEGUI_CEGUI_FontIterator_value00);
+   tolua_function(tolua_S,"isAtEnd",tolua_CEGUI_CEGUI_FontIterator_isAtEnd00);
+   tolua_function(tolua_S,"isAtStart",tolua_CEGUI_CEGUI_FontIterator_isAtStart00);
+   tolua_function(tolua_S,"next",tolua_CEGUI_CEGUI_FontIterator_next00);
+   tolua_function(tolua_S,"previous",tolua_CEGUI_CEGUI_FontIterator_previous00);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_FontIterator__eq00);
+   tolua_function(tolua_S,"toStart",tolua_CEGUI_CEGUI_FontIterator_toStart00);
+   tolua_function(tolua_S,"toEnd",tolua_CEGUI_CEGUI_FontIterator_toEnd00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FontIterator_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FontIterator_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FontIterator_new00_local);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10, 67, 69, 71, 85, 73, 46, 70,111,110,116, 73,116,101,114,
+    97,116,111,114, 46,105,116,101,114, 97,116,111,114, 32, 61,
+    32, 67, 69, 71, 85, 73, 46,105,116,101,114, 97,116,111,114,
+    95,105,109,112,108, 59,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 11");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  tolua_module(tolua_S,"Key",0);
+  tolua_beginmodule(tolua_S,"Key");
+   tolua_constant(tolua_S,"Escape",CEGUI::Key::Escape);
+   tolua_constant(tolua_S,"One",CEGUI::Key::One);
+   tolua_constant(tolua_S,"Two",CEGUI::Key::Two);
+   tolua_constant(tolua_S,"Three",CEGUI::Key::Three);
+   tolua_constant(tolua_S,"Four",CEGUI::Key::Four);
+   tolua_constant(tolua_S,"Five",CEGUI::Key::Five);
+   tolua_constant(tolua_S,"Six",CEGUI::Key::Six);
+   tolua_constant(tolua_S,"Seven",CEGUI::Key::Seven);
+   tolua_constant(tolua_S,"Eight",CEGUI::Key::Eight);
+   tolua_constant(tolua_S,"Nine",CEGUI::Key::Nine);
+   tolua_constant(tolua_S,"Zero",CEGUI::Key::Zero);
+   tolua_constant(tolua_S,"Minus",CEGUI::Key::Minus);
+   tolua_constant(tolua_S,"Equals",CEGUI::Key::Equals);
+   tolua_constant(tolua_S,"Backspace",CEGUI::Key::Backspace);
+   tolua_constant(tolua_S,"Tab",CEGUI::Key::Tab);
+   tolua_constant(tolua_S,"Q",CEGUI::Key::Q);
+   tolua_constant(tolua_S,"W",CEGUI::Key::W);
+   tolua_constant(tolua_S,"E",CEGUI::Key::E);
+   tolua_constant(tolua_S,"R",CEGUI::Key::R);
+   tolua_constant(tolua_S,"T",CEGUI::Key::T);
+   tolua_constant(tolua_S,"Y",CEGUI::Key::Y);
+   tolua_constant(tolua_S,"U",CEGUI::Key::U);
+   tolua_constant(tolua_S,"I",CEGUI::Key::I);
+   tolua_constant(tolua_S,"O",CEGUI::Key::O);
+   tolua_constant(tolua_S,"P",CEGUI::Key::P);
+   tolua_constant(tolua_S,"LeftBracket",CEGUI::Key::LeftBracket);
+   tolua_constant(tolua_S,"RightBracket",CEGUI::Key::RightBracket);
+   tolua_constant(tolua_S,"Return",CEGUI::Key::Return);
+   tolua_constant(tolua_S,"LeftControl",CEGUI::Key::LeftControl);
+   tolua_constant(tolua_S,"A",CEGUI::Key::A);
+   tolua_constant(tolua_S,"S",CEGUI::Key::S);
+   tolua_constant(tolua_S,"D",CEGUI::Key::D);
+   tolua_constant(tolua_S,"F",CEGUI::Key::F);
+   tolua_constant(tolua_S,"G",CEGUI::Key::G);
+   tolua_constant(tolua_S,"H",CEGUI::Key::H);
+   tolua_constant(tolua_S,"J",CEGUI::Key::J);
+   tolua_constant(tolua_S,"K",CEGUI::Key::K);
+   tolua_constant(tolua_S,"L",CEGUI::Key::L);
+   tolua_constant(tolua_S,"Semicolon",CEGUI::Key::Semicolon);
+   tolua_constant(tolua_S,"Apostrophe",CEGUI::Key::Apostrophe);
+   tolua_constant(tolua_S,"Grave",CEGUI::Key::Grave);
+   tolua_constant(tolua_S,"LeftShift",CEGUI::Key::LeftShift);
+   tolua_constant(tolua_S,"Backslash",CEGUI::Key::Backslash);
+   tolua_constant(tolua_S,"Z",CEGUI::Key::Z);
+   tolua_constant(tolua_S,"X",CEGUI::Key::X);
+   tolua_constant(tolua_S,"C",CEGUI::Key::C);
+   tolua_constant(tolua_S,"V",CEGUI::Key::V);
+   tolua_constant(tolua_S,"B",CEGUI::Key::B);
+   tolua_constant(tolua_S,"N",CEGUI::Key::N);
+   tolua_constant(tolua_S,"M",CEGUI::Key::M);
+   tolua_constant(tolua_S,"Comma",CEGUI::Key::Comma);
+   tolua_constant(tolua_S,"Period",CEGUI::Key::Period);
+   tolua_constant(tolua_S,"Slash",CEGUI::Key::Slash);
+   tolua_constant(tolua_S,"RightShift",CEGUI::Key::RightShift);
+   tolua_constant(tolua_S,"Multiply",CEGUI::Key::Multiply);
+   tolua_constant(tolua_S,"LeftAlt",CEGUI::Key::LeftAlt);
+   tolua_constant(tolua_S,"Space",CEGUI::Key::Space);
+   tolua_constant(tolua_S,"Capital",CEGUI::Key::Capital);
+   tolua_constant(tolua_S,"F1",CEGUI::Key::F1);
+   tolua_constant(tolua_S,"F2",CEGUI::Key::F2);
+   tolua_constant(tolua_S,"F3",CEGUI::Key::F3);
+   tolua_constant(tolua_S,"F4",CEGUI::Key::F4);
+   tolua_constant(tolua_S,"F5",CEGUI::Key::F5);
+   tolua_constant(tolua_S,"F6",CEGUI::Key::F6);
+   tolua_constant(tolua_S,"F7",CEGUI::Key::F7);
+   tolua_constant(tolua_S,"F8",CEGUI::Key::F8);
+   tolua_constant(tolua_S,"F9",CEGUI::Key::F9);
+   tolua_constant(tolua_S,"F10",CEGUI::Key::F10);
+   tolua_constant(tolua_S,"NumLock",CEGUI::Key::NumLock);
+   tolua_constant(tolua_S,"ScrollLock",CEGUI::Key::ScrollLock);
+   tolua_constant(tolua_S,"Numpad7",CEGUI::Key::Numpad7);
+   tolua_constant(tolua_S,"Numpad8",CEGUI::Key::Numpad8);
+   tolua_constant(tolua_S,"Numpad9",CEGUI::Key::Numpad9);
+   tolua_constant(tolua_S,"Subtract",CEGUI::Key::Subtract);
+   tolua_constant(tolua_S,"Numpad4",CEGUI::Key::Numpad4);
+   tolua_constant(tolua_S,"Numpad5",CEGUI::Key::Numpad5);
+   tolua_constant(tolua_S,"Numpad6",CEGUI::Key::Numpad6);
+   tolua_constant(tolua_S,"Add",CEGUI::Key::Add);
+   tolua_constant(tolua_S,"Numpad1",CEGUI::Key::Numpad1);
+   tolua_constant(tolua_S,"Numpad2",CEGUI::Key::Numpad2);
+   tolua_constant(tolua_S,"Numpad3",CEGUI::Key::Numpad3);
+   tolua_constant(tolua_S,"Numpad0",CEGUI::Key::Numpad0);
+   tolua_constant(tolua_S,"Decimal",CEGUI::Key::Decimal);
+   tolua_constant(tolua_S,"OEM_102",CEGUI::Key::OEM_102);
+   tolua_constant(tolua_S,"F11",CEGUI::Key::F11);
+   tolua_constant(tolua_S,"F12",CEGUI::Key::F12);
+   tolua_constant(tolua_S,"F13",CEGUI::Key::F13);
+   tolua_constant(tolua_S,"F14",CEGUI::Key::F14);
+   tolua_constant(tolua_S,"F15",CEGUI::Key::F15);
+   tolua_constant(tolua_S,"Kana",CEGUI::Key::Kana);
+   tolua_constant(tolua_S,"ABNT_C1",CEGUI::Key::ABNT_C1);
+   tolua_constant(tolua_S,"Convert",CEGUI::Key::Convert);
+   tolua_constant(tolua_S,"NoConvert",CEGUI::Key::NoConvert);
+   tolua_constant(tolua_S,"Yen",CEGUI::Key::Yen);
+   tolua_constant(tolua_S,"ABNT_C2",CEGUI::Key::ABNT_C2);
+   tolua_constant(tolua_S,"NumpadEquals",CEGUI::Key::NumpadEquals);
+   tolua_constant(tolua_S,"PrevTrack",CEGUI::Key::PrevTrack);
+   tolua_constant(tolua_S,"At",CEGUI::Key::At);
+   tolua_constant(tolua_S,"Colon",CEGUI::Key::Colon);
+   tolua_constant(tolua_S,"Underline",CEGUI::Key::Underline);
+   tolua_constant(tolua_S,"Kanji",CEGUI::Key::Kanji);
+   tolua_constant(tolua_S,"Stop",CEGUI::Key::Stop);
+   tolua_constant(tolua_S,"AX",CEGUI::Key::AX);
+   tolua_constant(tolua_S,"Unlabeled",CEGUI::Key::Unlabeled);
+   tolua_constant(tolua_S,"NextTrack",CEGUI::Key::NextTrack);
+   tolua_constant(tolua_S,"NumpadEnter",CEGUI::Key::NumpadEnter);
+   tolua_constant(tolua_S,"RightControl",CEGUI::Key::RightControl);
+   tolua_constant(tolua_S,"Mute",CEGUI::Key::Mute);
+   tolua_constant(tolua_S,"Calculator",CEGUI::Key::Calculator);
+   tolua_constant(tolua_S,"PlayPause",CEGUI::Key::PlayPause);
+   tolua_constant(tolua_S,"MediaStop",CEGUI::Key::MediaStop);
+   tolua_constant(tolua_S,"VolumeDown",CEGUI::Key::VolumeDown);
+   tolua_constant(tolua_S,"VolumeUp",CEGUI::Key::VolumeUp);
+   tolua_constant(tolua_S,"WebHome",CEGUI::Key::WebHome);
+   tolua_constant(tolua_S,"NumpadComma",CEGUI::Key::NumpadComma);
+   tolua_constant(tolua_S,"Divide",CEGUI::Key::Divide);
+   tolua_constant(tolua_S,"SysRq",CEGUI::Key::SysRq);
+   tolua_constant(tolua_S,"RightAlt",CEGUI::Key::RightAlt);
+   tolua_constant(tolua_S,"Pause",CEGUI::Key::Pause);
+   tolua_constant(tolua_S,"Home",CEGUI::Key::Home);
+   tolua_constant(tolua_S,"ArrowUp",CEGUI::Key::ArrowUp);
+   tolua_constant(tolua_S,"PageUp",CEGUI::Key::PageUp);
+   tolua_constant(tolua_S,"ArrowLeft",CEGUI::Key::ArrowLeft);
+   tolua_constant(tolua_S,"ArrowRight",CEGUI::Key::ArrowRight);
+   tolua_constant(tolua_S,"End",CEGUI::Key::End);
+   tolua_constant(tolua_S,"ArrowDown",CEGUI::Key::ArrowDown);
+   tolua_constant(tolua_S,"PageDown",CEGUI::Key::PageDown);
+   tolua_constant(tolua_S,"Insert",CEGUI::Key::Insert);
+   tolua_constant(tolua_S,"Delete",CEGUI::Key::Delete);
+   tolua_constant(tolua_S,"LeftWindows",CEGUI::Key::LeftWindows);
+   tolua_constant(tolua_S,"RightWindow",CEGUI::Key::RightWindow);
+   tolua_constant(tolua_S,"AppMenu",CEGUI::Key::AppMenu);
+   tolua_constant(tolua_S,"Power",CEGUI::Key::Power);
+   tolua_constant(tolua_S,"Sleep",CEGUI::Key::Sleep);
+   tolua_constant(tolua_S,"Wake",CEGUI::Key::Wake);
+   tolua_constant(tolua_S,"WebSearch",CEGUI::Key::WebSearch);
+   tolua_constant(tolua_S,"WebFavorites",CEGUI::Key::WebFavorites);
+   tolua_constant(tolua_S,"WebRefresh",CEGUI::Key::WebRefresh);
+   tolua_constant(tolua_S,"WebStop",CEGUI::Key::WebStop);
+   tolua_constant(tolua_S,"WebForward",CEGUI::Key::WebForward);
+   tolua_constant(tolua_S,"WebBack",CEGUI::Key::WebBack);
+   tolua_constant(tolua_S,"MyComputer",CEGUI::Key::MyComputer);
+   tolua_constant(tolua_S,"Mail",CEGUI::Key::Mail);
+   tolua_constant(tolua_S,"MediaSelect",CEGUI::Key::MediaSelect);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"LeftMouse",CEGUI::LeftMouse);
+  tolua_constant(tolua_S,"RightMouse",CEGUI::RightMouse);
+  tolua_constant(tolua_S,"Shift",CEGUI::Shift);
+  tolua_constant(tolua_S,"Control",CEGUI::Control);
+  tolua_constant(tolua_S,"MiddleMouse",CEGUI::MiddleMouse);
+  tolua_constant(tolua_S,"X1Mouse",CEGUI::X1Mouse);
+  tolua_constant(tolua_S,"X2Mouse",CEGUI::X2Mouse);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"EventArgs","CEGUI::EventArgs","",tolua_collect_CEGUI__EventArgs);
+  #else
+  tolua_cclass(tolua_S,"EventArgs","CEGUI::EventArgs","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"EventArgs");
+   tolua_variable(tolua_S,"handled",tolua_get_CEGUI__EventArgs_handled,tolua_set_CEGUI__EventArgs_handled);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_EventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_EventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_EventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"MouseCursorEventArgs","CEGUI::MouseCursorEventArgs","CEGUI::EventArgs",tolua_collect_CEGUI__MouseCursorEventArgs);
+  #else
+  tolua_cclass(tolua_S,"MouseCursorEventArgs","CEGUI::MouseCursorEventArgs","CEGUI::EventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"MouseCursorEventArgs");
+   tolua_variable(tolua_S,"mouseCursor",tolua_get_CEGUI__MouseCursorEventArgs_mouseCursor_ptr,tolua_set_CEGUI__MouseCursorEventArgs_mouseCursor_ptr);
+   tolua_variable(tolua_S,"image",tolua_get_CEGUI__MouseCursorEventArgs_image_ptr,NULL);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_MouseCursorEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WindowEventArgs","CEGUI::WindowEventArgs","CEGUI::EventArgs",tolua_collect_CEGUI__WindowEventArgs);
+  #else
+  tolua_cclass(tolua_S,"WindowEventArgs","CEGUI::WindowEventArgs","CEGUI::EventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WindowEventArgs");
+   tolua_variable(tolua_S,"window",tolua_get_CEGUI__WindowEventArgs_window_ptr,tolua_set_CEGUI__WindowEventArgs_window_ptr);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WindowEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WindowEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WindowEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ActivationEventArgs","CEGUI::ActivationEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__ActivationEventArgs);
+  #else
+  tolua_cclass(tolua_S,"ActivationEventArgs","CEGUI::ActivationEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ActivationEventArgs");
+   tolua_variable(tolua_S,"otherWindow",tolua_get_CEGUI__ActivationEventArgs_otherWindow_ptr,tolua_set_CEGUI__ActivationEventArgs_otherWindow_ptr);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ActivationEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ActivationEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"HeaderSequenceEventArgs","CEGUI::HeaderSequenceEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__HeaderSequenceEventArgs);
+  #else
+  tolua_cclass(tolua_S,"HeaderSequenceEventArgs","CEGUI::HeaderSequenceEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"HeaderSequenceEventArgs");
+   tolua_variable(tolua_S,"oldIdx",tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx,tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_oldIdx);
+   tolua_variable(tolua_S,"newIdx",tolua_get_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx,tolua_set_CEGUI__HeaderSequenceEventArgs_unsigned_newIdx);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_HeaderSequenceEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"LeftButton",CEGUI::LeftButton);
+  tolua_constant(tolua_S,"RightButton",CEGUI::RightButton);
+  tolua_constant(tolua_S,"MiddleButton",CEGUI::MiddleButton);
+  tolua_constant(tolua_S,"X1Button",CEGUI::X1Button);
+  tolua_constant(tolua_S,"X2Button",CEGUI::X2Button);
+  tolua_constant(tolua_S,"MouseButtonCount",CEGUI::MouseButtonCount);
+  tolua_constant(tolua_S,"NoButton",CEGUI::NoButton);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"MouseEventArgs","CEGUI::MouseEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__MouseEventArgs);
+  #else
+  tolua_cclass(tolua_S,"MouseEventArgs","CEGUI::MouseEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"MouseEventArgs");
+   tolua_variable(tolua_S,"position",tolua_get_CEGUI__MouseEventArgs_position,tolua_set_CEGUI__MouseEventArgs_position);
+   tolua_variable(tolua_S,"moveDelta",tolua_get_CEGUI__MouseEventArgs_moveDelta,tolua_set_CEGUI__MouseEventArgs_moveDelta);
+   tolua_variable(tolua_S,"button",tolua_get_CEGUI__MouseEventArgs_button,tolua_set_CEGUI__MouseEventArgs_button);
+   tolua_variable(tolua_S,"sysKeys",tolua_get_CEGUI__MouseEventArgs_unsigned_sysKeys,tolua_set_CEGUI__MouseEventArgs_unsigned_sysKeys);
+   tolua_variable(tolua_S,"wheelChange",tolua_get_CEGUI__MouseEventArgs_wheelChange,tolua_set_CEGUI__MouseEventArgs_wheelChange);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_MouseEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_MouseEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_MouseEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"KeyEventArgs","CEGUI::KeyEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__KeyEventArgs);
+  #else
+  tolua_cclass(tolua_S,"KeyEventArgs","CEGUI::KeyEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"KeyEventArgs");
+   tolua_variable(tolua_S,"codepoint",tolua_get_CEGUI__KeyEventArgs_unsigned_codepoint,tolua_set_CEGUI__KeyEventArgs_unsigned_codepoint);
+   tolua_variable(tolua_S,"scancode",tolua_get_CEGUI__KeyEventArgs_scancode,tolua_set_CEGUI__KeyEventArgs_scancode);
+   tolua_variable(tolua_S,"sysKeys",tolua_get_CEGUI__KeyEventArgs_unsigned_sysKeys,tolua_set_CEGUI__KeyEventArgs_unsigned_sysKeys);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_KeyEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_KeyEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_KeyEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"DragDropEventArgs","CEGUI::DragDropEventArgs","CEGUI::WindowEventArgs",tolua_collect_CEGUI__DragDropEventArgs);
+  #else
+  tolua_cclass(tolua_S,"DragDropEventArgs","CEGUI::DragDropEventArgs","CEGUI::WindowEventArgs",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"DragDropEventArgs");
+   tolua_variable(tolua_S,"dragDropItem",tolua_get_CEGUI__DragDropEventArgs_dragDropItem_ptr,tolua_set_CEGUI__DragDropEventArgs_dragDropItem_ptr);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_DragDropEventArgs_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_DragDropEventArgs_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Event","CEGUI::Event","",NULL);
+  tolua_beginmodule(tolua_S,"Event");
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Event_getName00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"EventConnection","CEGUI::EventConnection","",tolua_collect_CEGUI__EventConnection);
+  #else
+  tolua_cclass(tolua_S,"EventConnection","CEGUI::EventConnection","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"EventConnection");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"EventSet","CEGUI::EventSet","",NULL);
+  tolua_beginmodule(tolua_S,"EventSet");
+   tolua_function(tolua_S,"addEvent",tolua_CEGUI_CEGUI_EventSet_addEvent00);
+   tolua_function(tolua_S,"removeEvent",tolua_CEGUI_CEGUI_EventSet_removeEvent00);
+   tolua_function(tolua_S,"removeAllEvents",tolua_CEGUI_CEGUI_EventSet_removeAllEvents00);
+   tolua_function(tolua_S,"isEventPresent",tolua_CEGUI_CEGUI_EventSet_isEventPresent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_EventSet_subscribeEvent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_EventSet_subscribeEvent01);
+   tolua_function(tolua_S,"fireEvent",tolua_CEGUI_CEGUI_EventSet_fireEvent00);
+   tolua_function(tolua_S,"isMuted",tolua_CEGUI_CEGUI_EventSet_isMuted00);
+   tolua_function(tolua_S,"setMutedState",tolua_CEGUI_CEGUI_EventSet_setMutedState00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_EventSet_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"GlobalEventSet","CEGUI::GlobalEventSet","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"GlobalEventSet");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_GlobalEventSet_getSingleton00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"BlankMouseCursor",CEGUI::BlankMouseCursor);
+  tolua_constant(tolua_S,"DefaultMouseCursor",CEGUI::DefaultMouseCursor);
+  tolua_cclass(tolua_S,"MouseCursor","CEGUI::MouseCursor","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"MouseCursor");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_MouseCursor_getSingleton00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_MouseCursor_setImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_MouseCursor_setImage01);
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_MouseCursor_getImage00);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_MouseCursor_setPosition00);
+   tolua_function(tolua_S,"offsetPosition",tolua_CEGUI_CEGUI_MouseCursor_offsetPosition00);
+   tolua_function(tolua_S,"setConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_setConstraintArea00);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_MouseCursor_getPosition00);
+   tolua_function(tolua_S,"getConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_getConstraintArea00);
+   tolua_function(tolua_S,"getDisplayIndependantPosition",tolua_CEGUI_CEGUI_MouseCursor_getDisplayIndependantPosition00);
+   tolua_function(tolua_S,"setUnifiedConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_setUnifiedConstraintArea00);
+   tolua_function(tolua_S,"getUnifiedConstraintArea",tolua_CEGUI_CEGUI_MouseCursor_getUnifiedConstraintArea00);
+   tolua_function(tolua_S,"hide",tolua_CEGUI_CEGUI_MouseCursor_hide00);
+   tolua_function(tolua_S,"show",tolua_CEGUI_CEGUI_MouseCursor_show00);
+   tolua_function(tolua_S,"setVisible",tolua_CEGUI_CEGUI_MouseCursor_setVisible00);
+   tolua_function(tolua_S,"isVisible",tolua_CEGUI_CEGUI_MouseCursor_isVisible00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_MouseCursor_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"VA_TOP",CEGUI::VA_TOP);
+  tolua_constant(tolua_S,"VA_CENTRE",CEGUI::VA_CENTRE);
+  tolua_constant(tolua_S,"VA_BOTTOM",CEGUI::VA_BOTTOM);
+  tolua_constant(tolua_S,"HA_LEFT",CEGUI::HA_LEFT);
+  tolua_constant(tolua_S,"HA_CENTRE",CEGUI::HA_CENTRE);
+  tolua_constant(tolua_S,"HA_RIGHT",CEGUI::HA_RIGHT);
+  tolua_cclass(tolua_S,"Window","CEGUI::Window","",NULL);
+  tolua_beginmodule(tolua_S,"Window");
+   tolua_function(tolua_S,"getType",tolua_CEGUI_CEGUI_Window_getType00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Window_getName00);
+   tolua_function(tolua_S,"isDestroyedByParent",tolua_CEGUI_CEGUI_Window_isDestroyedByParent00);
+   tolua_function(tolua_S,"isAlwaysOnTop",tolua_CEGUI_CEGUI_Window_isAlwaysOnTop00);
+   tolua_function(tolua_S,"isDisabled",tolua_CEGUI_CEGUI_Window_isDisabled00);
+   tolua_function(tolua_S,"isVisible",tolua_CEGUI_CEGUI_Window_isVisible00);
+   tolua_function(tolua_S,"isActive",tolua_CEGUI_CEGUI_Window_isActive00);
+   tolua_function(tolua_S,"isClippedByParent",tolua_CEGUI_CEGUI_Window_isClippedByParent00);
+   tolua_function(tolua_S,"setDestroyedByParent",tolua_CEGUI_CEGUI_Window_setDestroyedByParent00);
+   tolua_function(tolua_S,"setAlwaysOnTop",tolua_CEGUI_CEGUI_Window_setAlwaysOnTop00);
+   tolua_function(tolua_S,"setEnabled",tolua_CEGUI_CEGUI_Window_setEnabled00);
+   tolua_function(tolua_S,"enable",tolua_CEGUI_CEGUI_Window_enable00);
+   tolua_function(tolua_S,"disable",tolua_CEGUI_CEGUI_Window_disable00);
+   tolua_function(tolua_S,"setVisible",tolua_CEGUI_CEGUI_Window_setVisible00);
+   tolua_function(tolua_S,"show",tolua_CEGUI_CEGUI_Window_show00);
+   tolua_function(tolua_S,"hide",tolua_CEGUI_CEGUI_Window_hide00);
+   tolua_function(tolua_S,"activate",tolua_CEGUI_CEGUI_Window_activate00);
+   tolua_function(tolua_S,"deactivate",tolua_CEGUI_CEGUI_Window_deactivate00);
+   tolua_function(tolua_S,"setClippedByParent",tolua_CEGUI_CEGUI_Window_setClippedByParent00);
+   tolua_function(tolua_S,"getID",tolua_CEGUI_CEGUI_Window_getID00);
+   tolua_function(tolua_S,"setID",tolua_CEGUI_CEGUI_Window_setID00);
+   tolua_function(tolua_S,"getChildCount",tolua_CEGUI_CEGUI_Window_getChildCount00);
+   tolua_function(tolua_S,"isChild",tolua_CEGUI_CEGUI_Window_isChild00);
+   tolua_function(tolua_S,"isChild",tolua_CEGUI_CEGUI_Window_isChild01);
+   tolua_function(tolua_S,"isChild",tolua_CEGUI_CEGUI_Window_isChild02);
+   tolua_function(tolua_S,"isChildRecursive",tolua_CEGUI_CEGUI_Window_isChildRecursive00);
+   tolua_function(tolua_S,"addChildWindow",tolua_CEGUI_CEGUI_Window_addChildWindow00);
+   tolua_function(tolua_S,"addChildWindow",tolua_CEGUI_CEGUI_Window_addChildWindow01);
+   tolua_function(tolua_S,"removeChildWindow",tolua_CEGUI_CEGUI_Window_removeChildWindow00);
+   tolua_function(tolua_S,"removeChildWindow",tolua_CEGUI_CEGUI_Window_removeChildWindow01);
+   tolua_function(tolua_S,"removeChildWindow",tolua_CEGUI_CEGUI_Window_removeChildWindow02);
+   tolua_function(tolua_S,"getChild",tolua_CEGUI_CEGUI_Window_getChild00);
+   tolua_function(tolua_S,"getChild",tolua_CEGUI_CEGUI_Window_getChild01);
+   tolua_function(tolua_S,"getChildAtIdx",tolua_CEGUI_CEGUI_Window_getChildAtIdx00);
+   tolua_function(tolua_S,"getActiveChild",tolua_CEGUI_CEGUI_Window_getActiveChild00);
+   tolua_function(tolua_S,"getChildAtPosition",tolua_CEGUI_CEGUI_Window_getChildAtPosition00);
+   tolua_function(tolua_S,"getTargetChildAtPosition",tolua_CEGUI_CEGUI_Window_getTargetChildAtPosition00);
+   tolua_function(tolua_S,"getChildRecursive",tolua_CEGUI_CEGUI_Window_getChildRecursive00);
+   tolua_function(tolua_S,"getParent",tolua_CEGUI_CEGUI_Window_getParent00);
+   tolua_function(tolua_S,"isAncestor",tolua_CEGUI_CEGUI_Window_isAncestor00);
+   tolua_function(tolua_S,"isAncestor",tolua_CEGUI_CEGUI_Window_isAncestor01);
+   tolua_function(tolua_S,"isAncestor",tolua_CEGUI_CEGUI_Window_isAncestor02);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_Window_setFont00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_Window_setFont01);
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_Window_getFont00);
+   tolua_function(tolua_S,"setText",tolua_CEGUI_CEGUI_Window_setText00);
+   tolua_function(tolua_S,"insertText",tolua_CEGUI_CEGUI_Window_insertText00);
+   tolua_function(tolua_S,"appendText",tolua_CEGUI_CEGUI_Window_appendText00);
+   tolua_function(tolua_S,"getText",tolua_CEGUI_CEGUI_Window_getText00);
+   tolua_function(tolua_S,"inheritsAlpha",tolua_CEGUI_CEGUI_Window_inheritsAlpha00);
+   tolua_function(tolua_S,"getAlpha",tolua_CEGUI_CEGUI_Window_getAlpha00);
+   tolua_function(tolua_S,"getEffectiveAlpha",tolua_CEGUI_CEGUI_Window_getEffectiveAlpha00);
+   tolua_function(tolua_S,"setAlpha",tolua_CEGUI_CEGUI_Window_setAlpha00);
+   tolua_function(tolua_S,"setInheritsAlpha",tolua_CEGUI_CEGUI_Window_setInheritsAlpha00);
+   tolua_function(tolua_S,"requestRedraw",tolua_CEGUI_CEGUI_Window_requestRedraw00);
+   tolua_function(tolua_S,"isZOrderingEnabled",tolua_CEGUI_CEGUI_Window_isZOrderingEnabled00);
+   tolua_function(tolua_S,"setZOrderingEnabled",tolua_CEGUI_CEGUI_Window_setZOrderingEnabled00);
+   tolua_function(tolua_S,"getPixelRect",tolua_CEGUI_CEGUI_Window_getPixelRect00);
+   tolua_function(tolua_S,"getInnerRect",tolua_CEGUI_CEGUI_Window_getInnerRect00);
+   tolua_function(tolua_S,"getUnclippedPixelRect",tolua_CEGUI_CEGUI_Window_getUnclippedPixelRect00);
+   tolua_function(tolua_S,"getUnclippedInnerRect",tolua_CEGUI_CEGUI_Window_getUnclippedInnerRect00);
+   tolua_function(tolua_S,"getParentPixelSize",tolua_CEGUI_CEGUI_Window_getParentPixelSize00);
+   tolua_function(tolua_S,"getParentPixelWidth",tolua_CEGUI_CEGUI_Window_getParentPixelWidth00);
+   tolua_function(tolua_S,"getParentPixelHeight",tolua_CEGUI_CEGUI_Window_getParentPixelHeight00);
+   tolua_function(tolua_S,"getCaptureWindow",tolua_CEGUI_CEGUI_Window_getCaptureWindow00);
+   tolua_function(tolua_S,"setRestoreCapture",tolua_CEGUI_CEGUI_Window_setRestoreCapture00);
+   tolua_function(tolua_S,"restoresOldCapture",tolua_CEGUI_CEGUI_Window_restoresOldCapture00);
+   tolua_function(tolua_S,"distributesCapturedInputs",tolua_CEGUI_CEGUI_Window_distributesCapturedInputs00);
+   tolua_function(tolua_S,"setDistributesCapturedInputs",tolua_CEGUI_CEGUI_Window_setDistributesCapturedInputs00);
+   tolua_function(tolua_S,"captureInput",tolua_CEGUI_CEGUI_Window_captureInput00);
+   tolua_function(tolua_S,"releaseInput",tolua_CEGUI_CEGUI_Window_releaseInput00);
+   tolua_function(tolua_S,"isCapturedByThis",tolua_CEGUI_CEGUI_Window_isCapturedByThis00);
+   tolua_function(tolua_S,"isCapturedByAncestor",tolua_CEGUI_CEGUI_Window_isCapturedByAncestor00);
+   tolua_function(tolua_S,"isCapturedByChild",tolua_CEGUI_CEGUI_Window_isCapturedByChild00);
+   tolua_function(tolua_S,"isHit",tolua_CEGUI_CEGUI_Window_isHit00);
+   tolua_function(tolua_S,"isRiseOnClickEnabled",tolua_CEGUI_CEGUI_Window_isRiseOnClickEnabled00);
+   tolua_function(tolua_S,"setRiseOnClickEnabled",tolua_CEGUI_CEGUI_Window_setRiseOnClickEnabled00);
+   tolua_function(tolua_S,"getMouseCursor",tolua_CEGUI_CEGUI_Window_getMouseCursor00);
+   tolua_function(tolua_S,"setMouseCursor",tolua_CEGUI_CEGUI_Window_setMouseCursor00);
+   tolua_function(tolua_S,"setMouseCursor",tolua_CEGUI_CEGUI_Window_setMouseCursor01);
+   tolua_function(tolua_S,"setMouseCursor",tolua_CEGUI_CEGUI_Window_setMouseCursor02);
+   tolua_function(tolua_S,"moveToFront",tolua_CEGUI_CEGUI_Window_moveToFront00);
+   tolua_function(tolua_S,"moveToBack",tolua_CEGUI_CEGUI_Window_moveToBack00);
+   tolua_function(tolua_S,"wantsMultiClickEvents",tolua_CEGUI_CEGUI_Window_wantsMultiClickEvents00);
+   tolua_function(tolua_S,"isMouseAutoRepeatEnabled",tolua_CEGUI_CEGUI_Window_isMouseAutoRepeatEnabled00);
+   tolua_function(tolua_S,"getAutoRepeatDelay",tolua_CEGUI_CEGUI_Window_getAutoRepeatDelay00);
+   tolua_function(tolua_S,"getAutoRepeatRate",tolua_CEGUI_CEGUI_Window_getAutoRepeatRate00);
+   tolua_function(tolua_S,"setWantsMultiClickEvents",tolua_CEGUI_CEGUI_Window_setWantsMultiClickEvents00);
+   tolua_function(tolua_S,"setMouseAutoRepeatEnabled",tolua_CEGUI_CEGUI_Window_setMouseAutoRepeatEnabled00);
+   tolua_function(tolua_S,"setAutoRepeatDelay",tolua_CEGUI_CEGUI_Window_setAutoRepeatDelay00);
+   tolua_function(tolua_S,"setAutoRepeatRate",tolua_CEGUI_CEGUI_Window_setAutoRepeatRate00);
+   tolua_function(tolua_S,"isUsingDefaultTooltip",tolua_CEGUI_CEGUI_Window_isUsingDefaultTooltip00);
+   tolua_function(tolua_S,"getTooltip",tolua_CEGUI_CEGUI_Window_getTooltip00);
+   tolua_function(tolua_S,"getTooltipType",tolua_CEGUI_CEGUI_Window_getTooltipType00);
+   tolua_function(tolua_S,"getTooltipText",tolua_CEGUI_CEGUI_Window_getTooltipText00);
+   tolua_function(tolua_S,"inheritsTooltipText",tolua_CEGUI_CEGUI_Window_inheritsTooltipText00);
+   tolua_function(tolua_S,"setTooltip",tolua_CEGUI_CEGUI_Window_setTooltip00);
+   tolua_function(tolua_S,"setTooltipType",tolua_CEGUI_CEGUI_Window_setTooltipType00);
+   tolua_function(tolua_S,"setTooltipText",tolua_CEGUI_CEGUI_Window_setTooltipText00);
+   tolua_function(tolua_S,"setInheritsTooltipText",tolua_CEGUI_CEGUI_Window_setInheritsTooltipText00);
+   tolua_function(tolua_S,"testClassName",tolua_CEGUI_CEGUI_Window_testClassName00);
+   tolua_function(tolua_S,"notifyDragDropItemEnters",tolua_CEGUI_CEGUI_Window_notifyDragDropItemEnters00);
+   tolua_function(tolua_S,"notifyDragDropItemLeaves",tolua_CEGUI_CEGUI_Window_notifyDragDropItemLeaves00);
+   tolua_function(tolua_S,"notifyDragDropItemDropped",tolua_CEGUI_CEGUI_Window_notifyDragDropItemDropped00);
+   tolua_function(tolua_S,"getVerticalAlignment",tolua_CEGUI_CEGUI_Window_getVerticalAlignment00);
+   tolua_function(tolua_S,"getHorizontalAlignment",tolua_CEGUI_CEGUI_Window_getHorizontalAlignment00);
+   tolua_function(tolua_S,"setVerticalAlignment",tolua_CEGUI_CEGUI_Window_setVerticalAlignment00);
+   tolua_function(tolua_S,"setHorizontalAlignment",tolua_CEGUI_CEGUI_Window_setHorizontalAlignment00);
+   tolua_function(tolua_S,"getLookNFeel",tolua_CEGUI_CEGUI_Window_getLookNFeel00);
+   tolua_function(tolua_S,"setLookNFeel",tolua_CEGUI_CEGUI_Window_setLookNFeel00);
+   tolua_function(tolua_S,"setWindowRenderer",tolua_CEGUI_CEGUI_Window_setWindowRenderer00);
+   tolua_function(tolua_S,"getWindowRendererName",tolua_CEGUI_CEGUI_Window_getWindowRendererName00);
+   tolua_function(tolua_S,"getModalState",tolua_CEGUI_CEGUI_Window_getModalState00);
+   tolua_function(tolua_S,"setModalState",tolua_CEGUI_CEGUI_Window_setModalState00);
+   tolua_function(tolua_S,"getUserString",tolua_CEGUI_CEGUI_Window_getUserString00);
+   tolua_function(tolua_S,"isUserStringDefined",tolua_CEGUI_CEGUI_Window_isUserStringDefined00);
+   tolua_function(tolua_S,"setUserString",tolua_CEGUI_CEGUI_Window_setUserString00);
+   tolua_function(tolua_S,"beginInitialisation",tolua_CEGUI_CEGUI_Window_beginInitialisation00);
+   tolua_function(tolua_S,"endInitialisation",tolua_CEGUI_CEGUI_Window_endInitialisation00);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_Window_setArea00);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_Window_setArea01);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_Window_setArea02);
+   tolua_function(tolua_S,"setPosition",tolua_CEGUI_CEGUI_Window_setPosition00);
+   tolua_function(tolua_S,"setXPosition",tolua_CEGUI_CEGUI_Window_setXPosition00);
+   tolua_function(tolua_S,"setYPosition",tolua_CEGUI_CEGUI_Window_setYPosition00);
+   tolua_function(tolua_S,"setSize",tolua_CEGUI_CEGUI_Window_setSize00);
+   tolua_function(tolua_S,"setWidth",tolua_CEGUI_CEGUI_Window_setWidth00);
+   tolua_function(tolua_S,"setHeight",tolua_CEGUI_CEGUI_Window_setHeight00);
+   tolua_function(tolua_S,"setMaxSize",tolua_CEGUI_CEGUI_Window_setMaxSize00);
+   tolua_function(tolua_S,"setMinSize",tolua_CEGUI_CEGUI_Window_setMinSize00);
+   tolua_function(tolua_S,"getArea",tolua_CEGUI_CEGUI_Window_getArea00);
+   tolua_function(tolua_S,"getPosition",tolua_CEGUI_CEGUI_Window_getPosition00);
+   tolua_function(tolua_S,"getXPosition",tolua_CEGUI_CEGUI_Window_getXPosition00);
+   tolua_function(tolua_S,"getYPosition",tolua_CEGUI_CEGUI_Window_getYPosition00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Window_getSize00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Window_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Window_getHeight00);
+   tolua_function(tolua_S,"getMaxSize",tolua_CEGUI_CEGUI_Window_getMaxSize00);
+   tolua_function(tolua_S,"getMinSize",tolua_CEGUI_CEGUI_Window_getMinSize00);
+   tolua_function(tolua_S,"isMousePassThroughEnabled",tolua_CEGUI_CEGUI_Window_isMousePassThroughEnabled00);
+   tolua_function(tolua_S,"setMousePassThroughEnabled",tolua_CEGUI_CEGUI_Window_setMousePassThroughEnabled00);
+   tolua_function(tolua_S,"rename",tolua_CEGUI_CEGUI_Window_rename00);
+   tolua_function(tolua_S,"setProperty",tolua_CEGUI_CEGUI_Window_setProperty00);
+   tolua_function(tolua_S,"getProperty",tolua_CEGUI_CEGUI_Window_getProperty00);
+   tolua_function(tolua_S,"getPropertyDefault",tolua_CEGUI_CEGUI_Window_getPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyHelp",tolua_CEGUI_CEGUI_Window_getPropertyHelp00);
+   tolua_function(tolua_S,"isPropertyPresent",tolua_CEGUI_CEGUI_Window_isPropertyPresent00);
+   tolua_function(tolua_S,"isPropertyDefault",tolua_CEGUI_CEGUI_Window_isPropertyDefault00);
+   tolua_function(tolua_S,"getPropertyIterator",tolua_CEGUI_CEGUI_Window_getPropertyIterator00);
+   tolua_function(tolua_S,"addEvent",tolua_CEGUI_CEGUI_Window_addEvent00);
+   tolua_function(tolua_S,"removeEvent",tolua_CEGUI_CEGUI_Window_removeEvent00);
+   tolua_function(tolua_S,"removeAllEvents",tolua_CEGUI_CEGUI_Window_removeAllEvents00);
+   tolua_function(tolua_S,"isEventPresent",tolua_CEGUI_CEGUI_Window_isEventPresent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_Window_subscribeEvent00);
+   tolua_function(tolua_S,"subscribeEvent",tolua_CEGUI_CEGUI_Window_subscribeEvent01);
+   tolua_function(tolua_S,"fireEvent",tolua_CEGUI_CEGUI_Window_fireEvent00);
+   tolua_function(tolua_S,"isMuted",tolua_CEGUI_CEGUI_Window_isMuted00);
+   tolua_function(tolua_S,"setMutedState",tolua_CEGUI_CEGUI_Window_setMutedState00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_Window_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"CoordConverter","CEGUI::CoordConverter","",NULL);
+  tolua_beginmodule(tolua_S,"CoordConverter");
+   tolua_function(tolua_S,"windowToScreenX",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX00);
+   tolua_function(tolua_S,"windowToScreenX",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenX01);
+   tolua_function(tolua_S,"windowToScreenY",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY00);
+   tolua_function(tolua_S,"windowToScreenY",tolua_CEGUI_CEGUI_CoordConverter_windowToScreenY01);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen00);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen01);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen02);
+   tolua_function(tolua_S,"windowToScreen",tolua_CEGUI_CEGUI_CoordConverter_windowToScreen03);
+   tolua_function(tolua_S,"screenToWindowX",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX00);
+   tolua_function(tolua_S,"screenToWindowX",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowX01);
+   tolua_function(tolua_S,"screenToWindowY",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY00);
+   tolua_function(tolua_S,"screenToWindowY",tolua_CEGUI_CEGUI_CoordConverter_screenToWindowY01);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow00);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow01);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow02);
+   tolua_function(tolua_S,"screenToWindow",tolua_CEGUI_CEGUI_CoordConverter_screenToWindow03);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Renderer","CEGUI::Renderer","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"Renderer");
+   tolua_function(tolua_S,"getCurrentZ",tolua_CEGUI_CEGUI_Renderer_getCurrentZ00);
+   tolua_function(tolua_S,"getZLayer",tolua_CEGUI_CEGUI_Renderer_getZLayer00);
+   tolua_function(tolua_S,"isQueueingEnabled",tolua_CEGUI_CEGUI_Renderer_isQueueingEnabled00);
+   tolua_function(tolua_S,"createTexture",tolua_CEGUI_CEGUI_Renderer_createTexture00);
+   tolua_function(tolua_S,"createTexture",tolua_CEGUI_CEGUI_Renderer_createTexture01);
+   tolua_function(tolua_S,"createTexture",tolua_CEGUI_CEGUI_Renderer_createTexture02);
+   tolua_function(tolua_S,"destroyTexture",tolua_CEGUI_CEGUI_Renderer_destroyTexture00);
+   tolua_function(tolua_S,"destroyAllTextures",tolua_CEGUI_CEGUI_Renderer_destroyAllTextures00);
+   tolua_function(tolua_S,"getWidth",tolua_CEGUI_CEGUI_Renderer_getWidth00);
+   tolua_function(tolua_S,"getHeight",tolua_CEGUI_CEGUI_Renderer_getHeight00);
+   tolua_function(tolua_S,"getSize",tolua_CEGUI_CEGUI_Renderer_getSize00);
+   tolua_function(tolua_S,"getRect",tolua_CEGUI_CEGUI_Renderer_getRect00);
+   tolua_function(tolua_S,"getMaxTextureSize",tolua_CEGUI_CEGUI_Renderer_getMaxTextureSize00);
+   tolua_function(tolua_S,"getHorzScreenDPI",tolua_CEGUI_CEGUI_Renderer_getHorzScreenDPI00);
+   tolua_function(tolua_S,"getVertScreenDPI",tolua_CEGUI_CEGUI_Renderer_getVertScreenDPI00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_Renderer_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ScriptWindowHelper","CEGUI::ScriptWindowHelper","",NULL);
+  tolua_beginmodule(tolua_S,"ScriptWindowHelper");
+   tolua_function(tolua_S,"getWindow",tolua_CEGUI_CEGUI_ScriptWindowHelper_getWindow00);
+   tolua_function(tolua_S,"getWindow",tolua_CEGUI_CEGUI_ScriptWindowHelper_getWindow01);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"System","CEGUI::System","CEGUI::EventSet",NULL);
+  tolua_beginmodule(tolua_S,"System");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_System_getSingleton00);
+   tolua_function(tolua_S,"getRenderer",tolua_CEGUI_CEGUI_System_getRenderer00);
+   tolua_function(tolua_S,"setDefaultFont",tolua_CEGUI_CEGUI_System_setDefaultFont00);
+   tolua_function(tolua_S,"setDefaultFont",tolua_CEGUI_CEGUI_System_setDefaultFont01);
+   tolua_function(tolua_S,"getDefaultFont",tolua_CEGUI_CEGUI_System_getDefaultFont00);
+   tolua_function(tolua_S,"signalRedraw",tolua_CEGUI_CEGUI_System_signalRedraw00);
+   tolua_function(tolua_S,"isRedrawRequested",tolua_CEGUI_CEGUI_System_isRedrawRequested00);
+   tolua_function(tolua_S,"renderGUI",tolua_CEGUI_CEGUI_System_renderGUI00);
+   tolua_function(tolua_S,"setGUISheet",tolua_CEGUI_CEGUI_System_setGUISheet00);
+   tolua_function(tolua_S,"getGUISheet",tolua_CEGUI_CEGUI_System_getGUISheet00);
+   tolua_function(tolua_S,"setSingleClickTimeout",tolua_CEGUI_CEGUI_System_setSingleClickTimeout00);
+   tolua_function(tolua_S,"setMultiClickTimeout",tolua_CEGUI_CEGUI_System_setMultiClickTimeout00);
+   tolua_function(tolua_S,"setMultiClickToleranceAreaSize",tolua_CEGUI_CEGUI_System_setMultiClickToleranceAreaSize00);
+   tolua_function(tolua_S,"getSingleClickTimeout",tolua_CEGUI_CEGUI_System_getSingleClickTimeout00);
+   tolua_function(tolua_S,"getMultiClickTimeout",tolua_CEGUI_CEGUI_System_getMultiClickTimeout00);
+   tolua_function(tolua_S,"getMultiClickToleranceAreaSize",tolua_CEGUI_CEGUI_System_getMultiClickToleranceAreaSize00);
+   tolua_function(tolua_S,"setDefaultMouseCursor",tolua_CEGUI_CEGUI_System_setDefaultMouseCursor00);
+   tolua_function(tolua_S,"setDefaultMouseCursor",tolua_CEGUI_CEGUI_System_setDefaultMouseCursor01);
+   tolua_function(tolua_S,"setDefaultMouseCursor",tolua_CEGUI_CEGUI_System_setDefaultMouseCursor02);
+   tolua_function(tolua_S,"getDefaultMouseCursor",tolua_CEGUI_CEGUI_System_getDefaultMouseCursor00);
+   tolua_function(tolua_S,"getWindowContainingMouse",tolua_CEGUI_CEGUI_System_getWindowContainingMouse00);
+   tolua_function(tolua_S,"executeScriptFile",tolua_CEGUI_CEGUI_System_executeScriptFile00);
+   tolua_function(tolua_S,"executeScriptGlobal",tolua_CEGUI_CEGUI_System_executeScriptGlobal00);
+   tolua_function(tolua_S,"executeScriptString",tolua_CEGUI_CEGUI_System_executeScriptString00);
+   tolua_function(tolua_S,"getMouseMoveScaling",tolua_CEGUI_CEGUI_System_getMouseMoveScaling00);
+   tolua_function(tolua_S,"setMouseMoveScaling",tolua_CEGUI_CEGUI_System_setMouseMoveScaling00);
+   tolua_function(tolua_S,"notifyWindowDestroyed",tolua_CEGUI_CEGUI_System_notifyWindowDestroyed00);
+   tolua_function(tolua_S,"isSystemKeyDown",tolua_CEGUI_CEGUI_System_isSystemKeyDown00);
+   tolua_function(tolua_S,"setDefaultTooltip",tolua_CEGUI_CEGUI_System_setDefaultTooltip00);
+   tolua_function(tolua_S,"setDefaultTooltip",tolua_CEGUI_CEGUI_System_setDefaultTooltip01);
+   tolua_function(tolua_S,"getDefaultTooltip",tolua_CEGUI_CEGUI_System_getDefaultTooltip00);
+   tolua_function(tolua_S,"injectMouseMove",tolua_CEGUI_CEGUI_System_injectMouseMove00);
+   tolua_function(tolua_S,"injectMouseLeaves",tolua_CEGUI_CEGUI_System_injectMouseLeaves00);
+   tolua_function(tolua_S,"injectMouseButtonDown",tolua_CEGUI_CEGUI_System_injectMouseButtonDown00);
+   tolua_function(tolua_S,"injectMouseButtonUp",tolua_CEGUI_CEGUI_System_injectMouseButtonUp00);
+   tolua_function(tolua_S,"injectKeyDown",tolua_CEGUI_CEGUI_System_injectKeyDown00);
+   tolua_function(tolua_S,"injectKeyUp",tolua_CEGUI_CEGUI_System_injectKeyUp00);
+   tolua_function(tolua_S,"injectChar",tolua_CEGUI_CEGUI_System_injectChar00);
+   tolua_function(tolua_S,"injectMouseWheelChange",tolua_CEGUI_CEGUI_System_injectMouseWheelChange00);
+   tolua_function(tolua_S,"injectMousePosition",tolua_CEGUI_CEGUI_System_injectMousePosition00);
+   tolua_function(tolua_S,"injectTimePulse",tolua_CEGUI_CEGUI_System_injectTimePulse00);
+   tolua_function(tolua_S,"getEventIterator",tolua_CEGUI_CEGUI_System_getEventIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"WindowManager","CEGUI::WindowManager","",NULL);
+  tolua_beginmodule(tolua_S,"WindowManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_WindowManager_getSingleton00);
+   tolua_function(tolua_S,"createWindow",tolua_CEGUI_CEGUI_WindowManager_createWindow00);
+   tolua_function(tolua_S,"loadWindowLayout",tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout00);
+   tolua_function(tolua_S,"loadWindowLayout",tolua_CEGUI_CEGUI_WindowManager_loadWindowLayout01);
+   tolua_function(tolua_S,"writeWindowLayoutToStream",tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream00);
+   tolua_function(tolua_S,"writeWindowLayoutToStream",tolua_CEGUI_CEGUI_WindowManager_writeWindowLayoutToStream01);
+   tolua_function(tolua_S,"destroyWindow",tolua_CEGUI_CEGUI_WindowManager_destroyWindow00);
+   tolua_function(tolua_S,"destroyWindow",tolua_CEGUI_CEGUI_WindowManager_destroyWindow01);
+   tolua_function(tolua_S,"destroyAllWindows",tolua_CEGUI_CEGUI_WindowManager_destroyAllWindows00);
+   tolua_function(tolua_S,"getWindow",tolua_CEGUI_CEGUI_WindowManager_getWindow00);
+   tolua_function(tolua_S,"isWindowPresent",tolua_CEGUI_CEGUI_WindowManager_isWindowPresent00);
+   tolua_function(tolua_S,"isDeadPoolEmpty",tolua_CEGUI_CEGUI_WindowManager_isDeadPoolEmpty00);
+   tolua_function(tolua_S,"cleanDeadPool",tolua_CEGUI_CEGUI_WindowManager_cleanDeadPool00);
+   tolua_function(tolua_S,"renameWindow",tolua_CEGUI_CEGUI_WindowManager_renameWindow00);
+   tolua_function(tolua_S,"renameWindow",tolua_CEGUI_CEGUI_WindowManager_renameWindow01);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_WindowManager_getIterator00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_WindowManager_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_WindowManager_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FalagardWindowMapping","CEGUI::FalagardWindowMapping","",tolua_collect_CEGUI__FalagardWindowMapping);
+  #else
+  tolua_cclass(tolua_S,"FalagardWindowMapping","CEGUI::FalagardWindowMapping","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FalagardWindowMapping");
+   tolua_variable(tolua_S,"windowType",tolua_get_CEGUI__FalagardWindowMapping_windowType,tolua_set_CEGUI__FalagardWindowMapping_windowType);
+   tolua_variable(tolua_S,"lookName",tolua_get_CEGUI__FalagardWindowMapping_lookName,tolua_set_CEGUI__FalagardWindowMapping_lookName);
+   tolua_variable(tolua_S,"baseType",tolua_get_CEGUI__FalagardWindowMapping_baseType,tolua_set_CEGUI__FalagardWindowMapping_baseType);
+   tolua_variable(tolua_S,"rendererType",tolua_get_CEGUI__FalagardWindowMapping_rendererType,tolua_set_CEGUI__FalagardWindowMapping_rendererType);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"WindowFactory","CEGUI::WindowFactory","",NULL);
+  tolua_beginmodule(tolua_S,"WindowFactory");
+   tolua_function(tolua_S,"getTypeName",tolua_CEGUI_CEGUI_WindowFactory_getTypeName00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"WindowFactoryManager","CEGUI::WindowFactoryManager","",NULL);
+  tolua_beginmodule(tolua_S,"WindowFactoryManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_WindowFactoryManager_getSingleton00);
+   tolua_function(tolua_S,"isFactoryPresent",tolua_CEGUI_CEGUI_WindowFactoryManager_isFactoryPresent00);
+   tolua_function(tolua_S,"addWindowTypeAlias",tolua_CEGUI_CEGUI_WindowFactoryManager_addWindowTypeAlias00);
+   tolua_function(tolua_S,"removeWindowTypeAlias",tolua_CEGUI_CEGUI_WindowFactoryManager_removeWindowTypeAlias00);
+   tolua_function(tolua_S,"addFalagardWindowMapping",tolua_CEGUI_CEGUI_WindowFactoryManager_addFalagardWindowMapping00);
+   tolua_function(tolua_S,"removeFalagardWindowMapping",tolua_CEGUI_CEGUI_WindowFactoryManager_removeFalagardWindowMapping00);
+   tolua_function(tolua_S,"isFalagardMappedType",tolua_CEGUI_CEGUI_WindowFactoryManager_isFalagardMappedType00);
+   tolua_function(tolua_S,"getMappedLookForType",tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedLookForType00);
+   tolua_function(tolua_S,"getMappedRendererForType",tolua_CEGUI_CEGUI_WindowFactoryManager_getMappedRendererForType00);
+   tolua_function(tolua_S,"getDereferencedAliasType",tolua_CEGUI_CEGUI_WindowFactoryManager_getDereferencedAliasType00);
+   tolua_function(tolua_S,"getFalagardMappingForType",tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingForType00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_WindowFactoryManager_getIterator00);
+   tolua_function(tolua_S,"getFalagardMappingIterator",tolua_CEGUI_CEGUI_WindowFactoryManager_getFalagardMappingIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Scheme","CEGUI::Scheme","",NULL);
+  tolua_beginmodule(tolua_S,"Scheme");
+   tolua_function(tolua_S,"loadResources",tolua_CEGUI_CEGUI_Scheme_loadResources00);
+   tolua_function(tolua_S,"unloadResources",tolua_CEGUI_CEGUI_Scheme_unloadResources00);
+   tolua_function(tolua_S,"resourcesLoaded",tolua_CEGUI_CEGUI_Scheme_resourcesLoaded00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_Scheme_getName00);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_Scheme_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_Scheme_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"SchemeManager","CEGUI::SchemeManager","",NULL);
+  tolua_beginmodule(tolua_S,"SchemeManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_SchemeManager_getSingleton00);
+   tolua_function(tolua_S,"loadScheme",tolua_CEGUI_CEGUI_SchemeManager_loadScheme00);
+   tolua_function(tolua_S,"unloadScheme",tolua_CEGUI_CEGUI_SchemeManager_unloadScheme00);
+   tolua_function(tolua_S,"isSchemePresent",tolua_CEGUI_CEGUI_SchemeManager_isSchemePresent00);
+   tolua_function(tolua_S,"getScheme",tolua_CEGUI_CEGUI_SchemeManager_getScheme00);
+   tolua_function(tolua_S,"unloadAllSchemes",tolua_CEGUI_CEGUI_SchemeManager_unloadAllSchemes00);
+   tolua_function(tolua_S,"getIterator",tolua_CEGUI_CEGUI_SchemeManager_getIterator00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PropertyHelper","CEGUI::PropertyHelper","",NULL);
+  tolua_beginmodule(tolua_S,"PropertyHelper");
+   tolua_function(tolua_S,"stringToFloat",tolua_CEGUI_CEGUI_PropertyHelper_stringToFloat00);
+   tolua_function(tolua_S,"stringToUint",tolua_CEGUI_CEGUI_PropertyHelper_stringToUint00);
+   tolua_function(tolua_S,"stringToBool",tolua_CEGUI_CEGUI_PropertyHelper_stringToBool00);
+   tolua_function(tolua_S,"stringToSize",tolua_CEGUI_CEGUI_PropertyHelper_stringToSize00);
+   tolua_function(tolua_S,"stringToPoint",tolua_CEGUI_CEGUI_PropertyHelper_stringToPoint00);
+   tolua_function(tolua_S,"stringToRect",tolua_CEGUI_CEGUI_PropertyHelper_stringToRect00);
+   tolua_function(tolua_S,"stringToImage",tolua_CEGUI_CEGUI_PropertyHelper_stringToImage00);
+   tolua_function(tolua_S,"stringToColour",tolua_CEGUI_CEGUI_PropertyHelper_stringToColour00);
+   tolua_function(tolua_S,"stringToColourRect",tolua_CEGUI_CEGUI_PropertyHelper_stringToColourRect00);
+   tolua_function(tolua_S,"stringToUDim",tolua_CEGUI_CEGUI_PropertyHelper_stringToUDim00);
+   tolua_function(tolua_S,"stringToUVector2",tolua_CEGUI_CEGUI_PropertyHelper_stringToUVector200);
+   tolua_function(tolua_S,"stringToURect",tolua_CEGUI_CEGUI_PropertyHelper_stringToURect00);
+   tolua_function(tolua_S,"floatToString",tolua_CEGUI_CEGUI_PropertyHelper_floatToString00);
+   tolua_function(tolua_S,"uintToString",tolua_CEGUI_CEGUI_PropertyHelper_uintToString00);
+   tolua_function(tolua_S,"boolToString",tolua_CEGUI_CEGUI_PropertyHelper_boolToString00);
+   tolua_function(tolua_S,"sizeToString",tolua_CEGUI_CEGUI_PropertyHelper_sizeToString00);
+   tolua_function(tolua_S,"pointToString",tolua_CEGUI_CEGUI_PropertyHelper_pointToString00);
+   tolua_function(tolua_S,"rectToString",tolua_CEGUI_CEGUI_PropertyHelper_rectToString00);
+   tolua_function(tolua_S,"imageToString",tolua_CEGUI_CEGUI_PropertyHelper_imageToString00);
+   tolua_function(tolua_S,"colourToString",tolua_CEGUI_CEGUI_PropertyHelper_colourToString00);
+   tolua_function(tolua_S,"colourRectToString",tolua_CEGUI_CEGUI_PropertyHelper_colourRectToString00);
+   tolua_function(tolua_S,"udimToString",tolua_CEGUI_CEGUI_PropertyHelper_udimToString00);
+   tolua_function(tolua_S,"uvector2ToString",tolua_CEGUI_CEGUI_PropertyHelper_uvector2ToString00);
+   tolua_function(tolua_S,"urectToString",tolua_CEGUI_CEGUI_PropertyHelper_urectToString00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"GUISheet","CEGUI::GUISheet","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"GUISheet");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Tree","CEGUI::Tree","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Tree");
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_Tree_getItemCount00);
+   tolua_function(tolua_S,"getSelectedCount",tolua_CEGUI_CEGUI_Tree_getSelectedCount00);
+   tolua_function(tolua_S,"getFirstSelectedItem",tolua_CEGUI_CEGUI_Tree_getFirstSelectedItem00);
+   tolua_function(tolua_S,"getLastSelectedItem",tolua_CEGUI_CEGUI_Tree_getLastSelectedItem00);
+   tolua_function(tolua_S,"isSortEnabled",tolua_CEGUI_CEGUI_Tree_isSortEnabled00);
+   tolua_function(tolua_S,"isMultiselectEnabled",tolua_CEGUI_CEGUI_Tree_isMultiselectEnabled00);
+   tolua_function(tolua_S,"isItemTooltipsEnabled",tolua_CEGUI_CEGUI_Tree_isItemTooltipsEnabled00);
+   tolua_function(tolua_S,"findFirstItemWithText",tolua_CEGUI_CEGUI_Tree_findFirstItemWithText00);
+   tolua_function(tolua_S,"findNextItemWithText",tolua_CEGUI_CEGUI_Tree_findNextItemWithText00);
+   tolua_function(tolua_S,"findFirstItemWithID",tolua_CEGUI_CEGUI_Tree_findFirstItemWithID00);
+   tolua_function(tolua_S,"findNextItemWithID",tolua_CEGUI_CEGUI_Tree_findNextItemWithID00);
+   tolua_function(tolua_S,"isTreeItemInList",tolua_CEGUI_CEGUI_Tree_isTreeItemInList00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_Tree_resetList00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_Tree_addItem00);
+   tolua_function(tolua_S,"insertItem",tolua_CEGUI_CEGUI_Tree_insertItem00);
+   tolua_function(tolua_S,"removeItem",tolua_CEGUI_CEGUI_Tree_removeItem00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_Tree_clearAllSelections00);
+   tolua_function(tolua_S,"setSortingEnabled",tolua_CEGUI_CEGUI_Tree_setSortingEnabled00);
+   tolua_function(tolua_S,"setMultiselectEnabled",tolua_CEGUI_CEGUI_Tree_setMultiselectEnabled00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Tree_setItemSelectState00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Tree_setItemSelectState01);
+   tolua_function(tolua_S,"ensureItemIsVisible",tolua_CEGUI_CEGUI_Tree_ensureItemIsVisible00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ButtonBase","CEGUI::ButtonBase","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ButtonBase");
+   tolua_function(tolua_S,"isHovering",tolua_CEGUI_CEGUI_ButtonBase_isHovering00);
+   tolua_function(tolua_S,"isPushed",tolua_CEGUI_CEGUI_ButtonBase_isPushed00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Checkbox","CEGUI::Checkbox","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"Checkbox");
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_Checkbox_isSelected00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_Checkbox_setSelected00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PushButton","CEGUI::PushButton","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"PushButton");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Thumb","CEGUI::Thumb","CEGUI::PushButton",NULL);
+  tolua_beginmodule(tolua_S,"Thumb");
+   tolua_function(tolua_S,"isHotTracked",tolua_CEGUI_CEGUI_Thumb_isHotTracked00);
+   tolua_function(tolua_S,"isVertFree",tolua_CEGUI_CEGUI_Thumb_isVertFree00);
+   tolua_function(tolua_S,"isHorzFree",tolua_CEGUI_CEGUI_Thumb_isHorzFree00);
+   tolua_function(tolua_S,"setHotTracked",tolua_CEGUI_CEGUI_Thumb_setHotTracked00);
+   tolua_function(tolua_S,"setVertFree",tolua_CEGUI_CEGUI_Thumb_setVertFree00);
+   tolua_function(tolua_S,"setHorzFree",tolua_CEGUI_CEGUI_Thumb_setHorzFree00);
+   tolua_function(tolua_S,"getVertRange",tolua_CEGUI_CEGUI_Thumb_getVertRange00);
+   tolua_function(tolua_S,"getHorzRange",tolua_CEGUI_CEGUI_Thumb_getHorzRange00);
+   tolua_function(tolua_S,"setVertRange",tolua_CEGUI_CEGUI_Thumb_setVertRange00);
+   tolua_function(tolua_S,"setHorzRange",tolua_CEGUI_CEGUI_Thumb_setHorzRange00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"RadioButton","CEGUI::RadioButton","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"RadioButton");
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_RadioButton_isSelected00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_RadioButton_setSelected00);
+   tolua_function(tolua_S,"getGroupID",tolua_CEGUI_CEGUI_RadioButton_getGroupID00);
+   tolua_function(tolua_S,"setGroupID",tolua_CEGUI_CEGUI_RadioButton_setGroupID00);
+   tolua_function(tolua_S,"getSelectedButtonInGroup",tolua_CEGUI_CEGUI_RadioButton_getSelectedButtonInGroup00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"TabButton","CEGUI::TabButton","CEGUI::ButtonBase",NULL);
+  tolua_beginmodule(tolua_S,"TabButton");
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_TabButton_isSelected00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_TabButton_setSelected00);
+   tolua_function(tolua_S,"setTargetWindow",tolua_CEGUI_CEGUI_TabButton_setTargetWindow00);
+   tolua_function(tolua_S,"getTargetWindow",tolua_CEGUI_CEGUI_TabButton_getTargetWindow00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"TabControl","CEGUI::TabControl","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"TabControl");
+   tolua_function(tolua_S,"getTabCount",tolua_CEGUI_CEGUI_TabControl_getTabCount00);
+   tolua_function(tolua_S,"setSelectedTab",tolua_CEGUI_CEGUI_TabControl_setSelectedTab00);
+   tolua_function(tolua_S,"setSelectedTab",tolua_CEGUI_CEGUI_TabControl_setSelectedTab01);
+   tolua_function(tolua_S,"setSelectedTabAtIndex",tolua_CEGUI_CEGUI_TabControl_setSelectedTabAtIndex00);
+   tolua_function(tolua_S,"getTabContentsAtIndex",tolua_CEGUI_CEGUI_TabControl_getTabContentsAtIndex00);
+   tolua_function(tolua_S,"getTabContents",tolua_CEGUI_CEGUI_TabControl_getTabContents00);
+   tolua_function(tolua_S,"getTabContents",tolua_CEGUI_CEGUI_TabControl_getTabContents01);
+   tolua_function(tolua_S,"isTabContentsSelected",tolua_CEGUI_CEGUI_TabControl_isTabContentsSelected00);
+   tolua_function(tolua_S,"getSelectedTabIndex",tolua_CEGUI_CEGUI_TabControl_getSelectedTabIndex00);
+   tolua_function(tolua_S,"getTabHeight",tolua_CEGUI_CEGUI_TabControl_getTabHeight00);
+   tolua_function(tolua_S,"getTabTextPadding",tolua_CEGUI_CEGUI_TabControl_getTabTextPadding00);
+   tolua_function(tolua_S,"setTabHeight",tolua_CEGUI_CEGUI_TabControl_setTabHeight00);
+   tolua_function(tolua_S,"setTabTextPadding",tolua_CEGUI_CEGUI_TabControl_setTabTextPadding00);
+   tolua_function(tolua_S,"addTab",tolua_CEGUI_CEGUI_TabControl_addTab00);
+   tolua_function(tolua_S,"removeTab",tolua_CEGUI_CEGUI_TabControl_removeTab00);
+   tolua_function(tolua_S,"removeTab",tolua_CEGUI_CEGUI_TabControl_removeTab01);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Titlebar","CEGUI::Titlebar","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Titlebar");
+   tolua_function(tolua_S,"isDraggingEnabled",tolua_CEGUI_CEGUI_Titlebar_isDraggingEnabled00);
+   tolua_function(tolua_S,"setDraggingEnabled",tolua_CEGUI_CEGUI_Titlebar_setDraggingEnabled00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"TreeItem","CEGUI::TreeItem","",NULL);
+  tolua_beginmodule(tolua_S,"TreeItem");
+   tolua_function(tolua_S,"getTextColours",tolua_CEGUI_CEGUI_TreeItem_getTextColours00);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_TreeItem_setTextColours00);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_TreeItem_setTextColours01);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_TreeItem_setTextColours02);
+   tolua_function(tolua_S,"getText",tolua_CEGUI_CEGUI_TreeItem_getText00);
+   tolua_function(tolua_S,"getTooltipText",tolua_CEGUI_CEGUI_TreeItem_getTooltipText00);
+   tolua_function(tolua_S,"getID",tolua_CEGUI_CEGUI_TreeItem_getID00);
+   tolua_function(tolua_S,"getUserData",tolua_CEGUI_CEGUI_TreeItem_getUserData00);
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_TreeItem_isSelected00);
+   tolua_function(tolua_S,"isDisabled",tolua_CEGUI_CEGUI_TreeItem_isDisabled00);
+   tolua_function(tolua_S,"isAutoDeleted",tolua_CEGUI_CEGUI_TreeItem_isAutoDeleted00);
+   tolua_function(tolua_S,"getOwnerWindow",tolua_CEGUI_CEGUI_TreeItem_getOwnerWindow00);
+   tolua_function(tolua_S,"getSelectionColours",tolua_CEGUI_CEGUI_TreeItem_getSelectionColours00);
+   tolua_function(tolua_S,"setText",tolua_CEGUI_CEGUI_TreeItem_setText00);
+   tolua_function(tolua_S,"setTooltipText",tolua_CEGUI_CEGUI_TreeItem_setTooltipText00);
+   tolua_function(tolua_S,"setUserData",tolua_CEGUI_CEGUI_TreeItem_setUserData00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_TreeItem_setSelected00);
+   tolua_function(tolua_S,"setDisabled",tolua_CEGUI_CEGUI_TreeItem_setDisabled00);
+   tolua_function(tolua_S,"setAutoDeleted",tolua_CEGUI_CEGUI_TreeItem_setAutoDeleted00);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_TreeItem_setSelectionColours00);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_TreeItem_setSelectionColours01);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_TreeItem_setSelectionColours02);
+   tolua_function(tolua_S,"getIsOpen",tolua_CEGUI_CEGUI_TreeItem_getIsOpen00);
+   tolua_function(tolua_S,"toggleIsOpen",tolua_CEGUI_CEGUI_TreeItem_toggleIsOpen00);
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_TreeItem_getItemCount00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_TreeItem_addItem00);
+   tolua_function(tolua_S,"setIcon",tolua_CEGUI_CEGUI_TreeItem_setIcon00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"FrameWindow","CEGUI::FrameWindow","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"FrameWindow");
+   tolua_function(tolua_S,"isSizingEnabled",tolua_CEGUI_CEGUI_FrameWindow_isSizingEnabled00);
+   tolua_function(tolua_S,"isFrameEnabled",tolua_CEGUI_CEGUI_FrameWindow_isFrameEnabled00);
+   tolua_function(tolua_S,"isTitleBarEnabled",tolua_CEGUI_CEGUI_FrameWindow_isTitleBarEnabled00);
+   tolua_function(tolua_S,"isCloseButtonEnabled",tolua_CEGUI_CEGUI_FrameWindow_isCloseButtonEnabled00);
+   tolua_function(tolua_S,"isRollupEnabled",tolua_CEGUI_CEGUI_FrameWindow_isRollupEnabled00);
+   tolua_function(tolua_S,"isRolledup",tolua_CEGUI_CEGUI_FrameWindow_isRolledup00);
+   tolua_function(tolua_S,"isDragMovingEnabled",tolua_CEGUI_CEGUI_FrameWindow_isDragMovingEnabled00);
+   tolua_function(tolua_S,"setSizingEnabled",tolua_CEGUI_CEGUI_FrameWindow_setSizingEnabled00);
+   tolua_function(tolua_S,"setFrameEnabled",tolua_CEGUI_CEGUI_FrameWindow_setFrameEnabled00);
+   tolua_function(tolua_S,"setTitleBarEnabled",tolua_CEGUI_CEGUI_FrameWindow_setTitleBarEnabled00);
+   tolua_function(tolua_S,"setCloseButtonEnabled",tolua_CEGUI_CEGUI_FrameWindow_setCloseButtonEnabled00);
+   tolua_function(tolua_S,"setRollupEnabled",tolua_CEGUI_CEGUI_FrameWindow_setRollupEnabled00);
+   tolua_function(tolua_S,"setDragMovingEnabled",tolua_CEGUI_CEGUI_FrameWindow_setDragMovingEnabled00);
+   tolua_function(tolua_S,"getSizingBorderThickness",tolua_CEGUI_CEGUI_FrameWindow_getSizingBorderThickness00);
+   tolua_function(tolua_S,"setSizingBorderThickness",tolua_CEGUI_CEGUI_FrameWindow_setSizingBorderThickness00);
+   tolua_function(tolua_S,"toggleRollup",tolua_CEGUI_CEGUI_FrameWindow_toggleRollup00);
+   tolua_function(tolua_S,"offsetPixelPosition",tolua_CEGUI_CEGUI_FrameWindow_offsetPixelPosition00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Tooltip","CEGUI::Tooltip","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Tooltip");
+   tolua_function(tolua_S,"setTargetWindow",tolua_CEGUI_CEGUI_Tooltip_setTargetWindow00);
+   tolua_function(tolua_S,"resetTimer",tolua_CEGUI_CEGUI_Tooltip_resetTimer00);
+   tolua_function(tolua_S,"getHoverTime",tolua_CEGUI_CEGUI_Tooltip_getHoverTime00);
+   tolua_function(tolua_S,"setDisplayTime",tolua_CEGUI_CEGUI_Tooltip_setDisplayTime00);
+   tolua_function(tolua_S,"getFadeTime",tolua_CEGUI_CEGUI_Tooltip_getFadeTime00);
+   tolua_function(tolua_S,"setHoverTime",tolua_CEGUI_CEGUI_Tooltip_setHoverTime00);
+   tolua_function(tolua_S,"getDisplayTime",tolua_CEGUI_CEGUI_Tooltip_getDisplayTime00);
+   tolua_function(tolua_S,"setFadeTime",tolua_CEGUI_CEGUI_Tooltip_setFadeTime00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"DragContainer","CEGUI::DragContainer","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"DragContainer");
+   tolua_function(tolua_S,"isDraggingEnabled",tolua_CEGUI_CEGUI_DragContainer_isDraggingEnabled00);
+   tolua_function(tolua_S,"setDraggingEnabled",tolua_CEGUI_CEGUI_DragContainer_setDraggingEnabled00);
+   tolua_function(tolua_S,"isBeingDragged",tolua_CEGUI_CEGUI_DragContainer_isBeingDragged00);
+   tolua_function(tolua_S,"getPixelDragThreshold",tolua_CEGUI_CEGUI_DragContainer_getPixelDragThreshold00);
+   tolua_function(tolua_S,"setPixelDragThreshold",tolua_CEGUI_CEGUI_DragContainer_setPixelDragThreshold00);
+   tolua_function(tolua_S,"getDragAlpha",tolua_CEGUI_CEGUI_DragContainer_getDragAlpha00);
+   tolua_function(tolua_S,"setDragAlpha",tolua_CEGUI_CEGUI_DragContainer_setDragAlpha00);
+   tolua_function(tolua_S,"getDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_getDragCursorImage00);
+   tolua_function(tolua_S,"setDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage00);
+   tolua_function(tolua_S,"setDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage01);
+   tolua_function(tolua_S,"setDragCursorImage",tolua_CEGUI_CEGUI_DragContainer_setDragCursorImage02);
+   tolua_function(tolua_S,"getCurrentDropTarget",tolua_CEGUI_CEGUI_DragContainer_getCurrentDropTarget00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Scrollbar","CEGUI::Scrollbar","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Scrollbar");
+   tolua_function(tolua_S,"getDocumentSize",tolua_CEGUI_CEGUI_Scrollbar_getDocumentSize00);
+   tolua_function(tolua_S,"getPageSize",tolua_CEGUI_CEGUI_Scrollbar_getPageSize00);
+   tolua_function(tolua_S,"getStepSize",tolua_CEGUI_CEGUI_Scrollbar_getStepSize00);
+   tolua_function(tolua_S,"getOverlapSize",tolua_CEGUI_CEGUI_Scrollbar_getOverlapSize00);
+   tolua_function(tolua_S,"getScrollPosition",tolua_CEGUI_CEGUI_Scrollbar_getScrollPosition00);
+   tolua_function(tolua_S,"setDocumentSize",tolua_CEGUI_CEGUI_Scrollbar_setDocumentSize00);
+   tolua_function(tolua_S,"setPageSize",tolua_CEGUI_CEGUI_Scrollbar_setPageSize00);
+   tolua_function(tolua_S,"setStepSize",tolua_CEGUI_CEGUI_Scrollbar_setStepSize00);
+   tolua_function(tolua_S,"setOverlapSize",tolua_CEGUI_CEGUI_Scrollbar_setOverlapSize00);
+   tolua_function(tolua_S,"setScrollPosition",tolua_CEGUI_CEGUI_Scrollbar_setScrollPosition00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ScrolledContainer","CEGUI::ScrolledContainer","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ScrolledContainer");
+   tolua_function(tolua_S,"isContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrolledContainer_isContentPaneAutoSized00);
+   tolua_function(tolua_S,"setContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrolledContainer_setContentPaneAutoSized00);
+   tolua_function(tolua_S,"getContentArea",tolua_CEGUI_CEGUI_ScrolledContainer_getContentArea00);
+   tolua_function(tolua_S,"setContentArea",tolua_CEGUI_CEGUI_ScrolledContainer_setContentArea00);
+   tolua_function(tolua_S,"getChildExtentsArea",tolua_CEGUI_CEGUI_ScrolledContainer_getChildExtentsArea00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ScrollablePane","CEGUI::ScrollablePane","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ScrollablePane");
+   tolua_function(tolua_S,"getContentPane",tolua_CEGUI_CEGUI_ScrollablePane_getContentPane00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrollablePane_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_setShowVertScrollbar00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrollablePane_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"isContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrollablePane_isContentPaneAutoSized00);
+   tolua_function(tolua_S,"setContentPaneAutoSized",tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneAutoSized00);
+   tolua_function(tolua_S,"getContentPaneArea",tolua_CEGUI_CEGUI_ScrollablePane_getContentPaneArea00);
+   tolua_function(tolua_S,"setContentPaneArea",tolua_CEGUI_CEGUI_ScrollablePane_setContentPaneArea00);
+   tolua_function(tolua_S,"getHorizontalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalStepSize00);
+   tolua_function(tolua_S,"setHorizontalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalStepSize00);
+   tolua_function(tolua_S,"getHorizontalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalOverlapSize00);
+   tolua_function(tolua_S,"setHorizontalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalOverlapSize00);
+   tolua_function(tolua_S,"getHorizontalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_getHorizontalScrollPosition00);
+   tolua_function(tolua_S,"setHorizontalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_setHorizontalScrollPosition00);
+   tolua_function(tolua_S,"getVerticalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_getVerticalStepSize00);
+   tolua_function(tolua_S,"setVerticalStepSize",tolua_CEGUI_CEGUI_ScrollablePane_setVerticalStepSize00);
+   tolua_function(tolua_S,"getVerticalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_getVerticalOverlapSize00);
+   tolua_function(tolua_S,"setVerticalOverlapSize",tolua_CEGUI_CEGUI_ScrollablePane_setVerticalOverlapSize00);
+   tolua_function(tolua_S,"getVerticalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_getVerticalScrollPosition00);
+   tolua_function(tolua_S,"setVerticalScrollPosition",tolua_CEGUI_CEGUI_ScrollablePane_setVerticalScrollPosition00);
+   tolua_function(tolua_S,"getViewableArea",tolua_CEGUI_CEGUI_ScrollablePane_getViewableArea00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_ScrollablePane_getHorzScrollbar00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Slider","CEGUI::Slider","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Slider");
+   tolua_function(tolua_S,"getCurrentValue",tolua_CEGUI_CEGUI_Slider_getCurrentValue00);
+   tolua_function(tolua_S,"getMaxValue",tolua_CEGUI_CEGUI_Slider_getMaxValue00);
+   tolua_function(tolua_S,"getClickStep",tolua_CEGUI_CEGUI_Slider_getClickStep00);
+   tolua_function(tolua_S,"setMaxValue",tolua_CEGUI_CEGUI_Slider_setMaxValue00);
+   tolua_function(tolua_S,"setCurrentValue",tolua_CEGUI_CEGUI_Slider_setCurrentValue00);
+   tolua_function(tolua_S,"setClickStep",tolua_CEGUI_CEGUI_Slider_setClickStep00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Spinner","CEGUI::Spinner","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Spinner");
+   tolua_constant(tolua_S,"FloatingPoint",CEGUI::Spinner::FloatingPoint);
+   tolua_constant(tolua_S,"Integer",CEGUI::Spinner::Integer);
+   tolua_constant(tolua_S,"Hexadecimal",CEGUI::Spinner::Hexadecimal);
+   tolua_constant(tolua_S,"Octal",CEGUI::Spinner::Octal);
+   tolua_function(tolua_S,"getCurrentValue",tolua_CEGUI_CEGUI_Spinner_getCurrentValue00);
+   tolua_function(tolua_S,"getStepSize",tolua_CEGUI_CEGUI_Spinner_getStepSize00);
+   tolua_function(tolua_S,"getMaximumValue",tolua_CEGUI_CEGUI_Spinner_getMaximumValue00);
+   tolua_function(tolua_S,"getMinimumValue",tolua_CEGUI_CEGUI_Spinner_getMinimumValue00);
+   tolua_function(tolua_S,"getTextInputMode",tolua_CEGUI_CEGUI_Spinner_getTextInputMode00);
+   tolua_function(tolua_S,"setCurrentValue",tolua_CEGUI_CEGUI_Spinner_setCurrentValue00);
+   tolua_function(tolua_S,"setStepSize",tolua_CEGUI_CEGUI_Spinner_setStepSize00);
+   tolua_function(tolua_S,"setMaximumValue",tolua_CEGUI_CEGUI_Spinner_setMaximumValue00);
+   tolua_function(tolua_S,"setMinimumValue",tolua_CEGUI_CEGUI_Spinner_setMinimumValue00);
+   tolua_function(tolua_S,"setTextInputMode",tolua_CEGUI_CEGUI_Spinner_setTextInputMode00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ProgressBar","CEGUI::ProgressBar","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ProgressBar");
+   tolua_function(tolua_S,"getProgress",tolua_CEGUI_CEGUI_ProgressBar_getProgress00);
+   tolua_function(tolua_S,"getStep",tolua_CEGUI_CEGUI_ProgressBar_getStep00);
+   tolua_function(tolua_S,"setProgress",tolua_CEGUI_CEGUI_ProgressBar_setProgress00);
+   tolua_function(tolua_S,"setStepSize",tolua_CEGUI_CEGUI_ProgressBar_setStepSize00);
+   tolua_function(tolua_S,"step",tolua_CEGUI_CEGUI_ProgressBar_step00);
+   tolua_function(tolua_S,"adjustProgress",tolua_CEGUI_CEGUI_ProgressBar_adjustProgress00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Editbox","CEGUI::Editbox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Editbox");
+   tolua_function(tolua_S,"hasInputFocus",tolua_CEGUI_CEGUI_Editbox_hasInputFocus00);
+   tolua_function(tolua_S,"isReadOnly",tolua_CEGUI_CEGUI_Editbox_isReadOnly00);
+   tolua_function(tolua_S,"isTextMasked",tolua_CEGUI_CEGUI_Editbox_isTextMasked00);
+   tolua_function(tolua_S,"isTextValid",tolua_CEGUI_CEGUI_Editbox_isTextValid00);
+   tolua_function(tolua_S,"getValidationString",tolua_CEGUI_CEGUI_Editbox_getValidationString00);
+   tolua_function(tolua_S,"getCaratIndex",tolua_CEGUI_CEGUI_Editbox_getCaratIndex00);
+   tolua_function(tolua_S,"getSelectionStartIndex",tolua_CEGUI_CEGUI_Editbox_getSelectionStartIndex00);
+   tolua_function(tolua_S,"getSelectionEndIndex",tolua_CEGUI_CEGUI_Editbox_getSelectionEndIndex00);
+   tolua_function(tolua_S,"getSelectionLength",tolua_CEGUI_CEGUI_Editbox_getSelectionLength00);
+   tolua_function(tolua_S,"getMaskCodePoint",tolua_CEGUI_CEGUI_Editbox_getMaskCodePoint00);
+   tolua_function(tolua_S,"getMaxTextLength",tolua_CEGUI_CEGUI_Editbox_getMaxTextLength00);
+   tolua_function(tolua_S,"setReadOnly",tolua_CEGUI_CEGUI_Editbox_setReadOnly00);
+   tolua_function(tolua_S,"setTextMasked",tolua_CEGUI_CEGUI_Editbox_setTextMasked00);
+   tolua_function(tolua_S,"setValidationString",tolua_CEGUI_CEGUI_Editbox_setValidationString00);
+   tolua_function(tolua_S,"setCaratIndex",tolua_CEGUI_CEGUI_Editbox_setCaratIndex00);
+   tolua_function(tolua_S,"setSelection",tolua_CEGUI_CEGUI_Editbox_setSelection00);
+   tolua_function(tolua_S,"setMaskCodePoint",tolua_CEGUI_CEGUI_Editbox_setMaskCodePoint00);
+   tolua_function(tolua_S,"setMaxTextLength",tolua_CEGUI_CEGUI_Editbox_setMaxTextLength00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MultiLineEditbox","CEGUI::MultiLineEditbox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"MultiLineEditbox");
+   tolua_function(tolua_S,"hasInputFocus",tolua_CEGUI_CEGUI_MultiLineEditbox_hasInputFocus00);
+   tolua_function(tolua_S,"isReadOnly",tolua_CEGUI_CEGUI_MultiLineEditbox_isReadOnly00);
+   tolua_function(tolua_S,"getCaratIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getCaratIndex00);
+   tolua_function(tolua_S,"getSelectionStartIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionStartIndex00);
+   tolua_function(tolua_S,"getSelectionEndIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionEndIndex00);
+   tolua_function(tolua_S,"getSelectionLength",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionLength00);
+   tolua_function(tolua_S,"getMaxTextLength",tolua_CEGUI_CEGUI_MultiLineEditbox_getMaxTextLength00);
+   tolua_function(tolua_S,"isWordWrapped",tolua_CEGUI_CEGUI_MultiLineEditbox_isWordWrapped00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_MultiLineEditbox_getVertScrollbar00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_MultiLineEditbox_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_MultiLineEditbox_getHorzScrollbar00);
+   tolua_function(tolua_S,"getTextRenderArea",tolua_CEGUI_CEGUI_MultiLineEditbox_getTextRenderArea00);
+   tolua_function(tolua_S,"getLineNumberFromIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_getLineNumberFromIndex00);
+   tolua_function(tolua_S,"setReadOnly",tolua_CEGUI_CEGUI_MultiLineEditbox_setReadOnly00);
+   tolua_function(tolua_S,"setCaratIndex",tolua_CEGUI_CEGUI_MultiLineEditbox_setCaratIndex00);
+   tolua_function(tolua_S,"setSelection",tolua_CEGUI_CEGUI_MultiLineEditbox_setSelection00);
+   tolua_function(tolua_S,"setMaxTextLength",tolua_CEGUI_CEGUI_MultiLineEditbox_setMaxTextLength00);
+   tolua_function(tolua_S,"ensureCaratIsVisible",tolua_CEGUI_CEGUI_MultiLineEditbox_ensureCaratIsVisible00);
+   tolua_function(tolua_S,"setWordWrapping",tolua_CEGUI_CEGUI_MultiLineEditbox_setWordWrapping00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_MultiLineEditbox_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setSelectionBrushImage",tolua_CEGUI_CEGUI_MultiLineEditbox_setSelectionBrushImage00);
+   tolua_function(tolua_S,"getSelectionBrushImage",tolua_CEGUI_CEGUI_MultiLineEditbox_getSelectionBrushImage00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListboxItem","CEGUI::ListboxItem","",NULL);
+  tolua_beginmodule(tolua_S,"ListboxItem");
+   tolua_function(tolua_S,"getText",tolua_CEGUI_CEGUI_ListboxItem_getText00);
+   tolua_function(tolua_S,"getID",tolua_CEGUI_CEGUI_ListboxItem_getID00);
+   tolua_function(tolua_S,"getUserData",tolua_CEGUI_CEGUI_ListboxItem_getUserData00);
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_ListboxItem_isSelected00);
+   tolua_function(tolua_S,"isDisabled",tolua_CEGUI_CEGUI_ListboxItem_isDisabled00);
+   tolua_function(tolua_S,"isAutoDeleted",tolua_CEGUI_CEGUI_ListboxItem_isAutoDeleted00);
+   tolua_function(tolua_S,"getOwnerWindow",tolua_CEGUI_CEGUI_ListboxItem_getOwnerWindow00);
+   tolua_function(tolua_S,"getSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_getSelectionColours00);
+   tolua_function(tolua_S,"getSelectionBrushImage",tolua_CEGUI_CEGUI_ListboxItem_getSelectionBrushImage00);
+   tolua_function(tolua_S,"setText",tolua_CEGUI_CEGUI_ListboxItem_setText00);
+   tolua_function(tolua_S,"setID",tolua_CEGUI_CEGUI_ListboxItem_setID00);
+   tolua_function(tolua_S,"setUserData",tolua_CEGUI_CEGUI_ListboxItem_setUserData00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_ListboxItem_setSelected00);
+   tolua_function(tolua_S,"setDisabled",tolua_CEGUI_CEGUI_ListboxItem_setDisabled00);
+   tolua_function(tolua_S,"setAutoDeleted",tolua_CEGUI_CEGUI_ListboxItem_setAutoDeleted00);
+   tolua_function(tolua_S,"setOwnerWindow",tolua_CEGUI_CEGUI_ListboxItem_setOwnerWindow00);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours00);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours01);
+   tolua_function(tolua_S,"setSelectionColours",tolua_CEGUI_CEGUI_ListboxItem_setSelectionColours02);
+   tolua_function(tolua_S,"setSelectionBrushImage",tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage00);
+   tolua_function(tolua_S,"setSelectionBrushImage",tolua_CEGUI_CEGUI_ListboxItem_setSelectionBrushImage01);
+   tolua_function(tolua_S,"getPixelSize",tolua_CEGUI_CEGUI_ListboxItem_getPixelSize00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListboxTextItem","CEGUI::ListboxTextItem","CEGUI::ListboxItem",NULL);
+  tolua_beginmodule(tolua_S,"ListboxTextItem");
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_ListboxTextItem_getFont00);
+   tolua_function(tolua_S,"getTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_getTextColours00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_ListboxTextItem_setFont00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_ListboxTextItem_setFont01);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours00);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours01);
+   tolua_function(tolua_S,"setTextColours",tolua_CEGUI_CEGUI_ListboxTextItem_setTextColours02);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Combobox","CEGUI::Combobox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Combobox");
+   tolua_function(tolua_S,"getSingleClickEnabled",tolua_CEGUI_CEGUI_Combobox_getSingleClickEnabled00);
+   tolua_function(tolua_S,"isDropDownListVisible",tolua_CEGUI_CEGUI_Combobox_isDropDownListVisible00);
+   tolua_function(tolua_S,"getEditbox",tolua_CEGUI_CEGUI_Combobox_getEditbox00);
+   tolua_function(tolua_S,"getPushButton",tolua_CEGUI_CEGUI_Combobox_getPushButton00);
+   tolua_function(tolua_S,"getDropList",tolua_CEGUI_CEGUI_Combobox_getDropList00);
+   tolua_function(tolua_S,"hasInputFocus",tolua_CEGUI_CEGUI_Combobox_hasInputFocus00);
+   tolua_function(tolua_S,"isReadOnly",tolua_CEGUI_CEGUI_Combobox_isReadOnly00);
+   tolua_function(tolua_S,"isTextValid",tolua_CEGUI_CEGUI_Combobox_isTextValid00);
+   tolua_function(tolua_S,"getValidationString",tolua_CEGUI_CEGUI_Combobox_getValidationString00);
+   tolua_function(tolua_S,"getCaratIndex",tolua_CEGUI_CEGUI_Combobox_getCaratIndex00);
+   tolua_function(tolua_S,"getSelectionStartIndex",tolua_CEGUI_CEGUI_Combobox_getSelectionStartIndex00);
+   tolua_function(tolua_S,"getSelectionEndIndex",tolua_CEGUI_CEGUI_Combobox_getSelectionEndIndex00);
+   tolua_function(tolua_S,"getSelectionLength",tolua_CEGUI_CEGUI_Combobox_getSelectionLength00);
+   tolua_function(tolua_S,"getMaxTextLength",tolua_CEGUI_CEGUI_Combobox_getMaxTextLength00);
+   tolua_function(tolua_S,"activateEditbox",tolua_CEGUI_CEGUI_Combobox_activateEditbox00);
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_Combobox_getItemCount00);
+   tolua_function(tolua_S,"getSelectedItem",tolua_CEGUI_CEGUI_Combobox_getSelectedItem00);
+   tolua_function(tolua_S,"getListboxItemFromIndex",tolua_CEGUI_CEGUI_Combobox_getListboxItemFromIndex00);
+   tolua_function(tolua_S,"getItemIndex",tolua_CEGUI_CEGUI_Combobox_getItemIndex00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_Combobox_isItemSelected00);
+   tolua_function(tolua_S,"findItemWithText",tolua_CEGUI_CEGUI_Combobox_findItemWithText00);
+   tolua_function(tolua_S,"isListboxItemInList",tolua_CEGUI_CEGUI_Combobox_isListboxItemInList00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_Combobox_resetList00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_Combobox_addItem00);
+   tolua_function(tolua_S,"insertItem",tolua_CEGUI_CEGUI_Combobox_insertItem00);
+   tolua_function(tolua_S,"removeItem",tolua_CEGUI_CEGUI_Combobox_removeItem00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_Combobox_clearAllSelections00);
+   tolua_function(tolua_S,"setSortingEnabled",tolua_CEGUI_CEGUI_Combobox_setSortingEnabled00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_Combobox_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_Combobox_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Combobox_setItemSelectState00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Combobox_setItemSelectState01);
+   tolua_function(tolua_S,"handleUpdatedListItemData",tolua_CEGUI_CEGUI_Combobox_handleUpdatedListItemData00);
+   tolua_function(tolua_S,"isSortEnabled",tolua_CEGUI_CEGUI_Combobox_isSortEnabled00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Combobox_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Combobox_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"showDropList",tolua_CEGUI_CEGUI_Combobox_showDropList00);
+   tolua_function(tolua_S,"hideDropList",tolua_CEGUI_CEGUI_Combobox_hideDropList00);
+   tolua_function(tolua_S,"setSingleClickEnabled",tolua_CEGUI_CEGUI_Combobox_setSingleClickEnabled00);
+   tolua_function(tolua_S,"setReadOnly",tolua_CEGUI_CEGUI_Combobox_setReadOnly00);
+   tolua_function(tolua_S,"setValidationString",tolua_CEGUI_CEGUI_Combobox_setValidationString00);
+   tolua_function(tolua_S,"setCaratIndex",tolua_CEGUI_CEGUI_Combobox_setCaratIndex00);
+   tolua_function(tolua_S,"setSelection",tolua_CEGUI_CEGUI_Combobox_setSelection00);
+   tolua_function(tolua_S,"setMaxTextLength",tolua_CEGUI_CEGUI_Combobox_setMaxTextLength00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Listbox","CEGUI::Listbox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"Listbox");
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_Listbox_getItemCount00);
+   tolua_function(tolua_S,"getSelectedCount",tolua_CEGUI_CEGUI_Listbox_getSelectedCount00);
+   tolua_function(tolua_S,"getFirstSelectedItem",tolua_CEGUI_CEGUI_Listbox_getFirstSelectedItem00);
+   tolua_function(tolua_S,"getNextSelected",tolua_CEGUI_CEGUI_Listbox_getNextSelected00);
+   tolua_function(tolua_S,"getListboxItemFromIndex",tolua_CEGUI_CEGUI_Listbox_getListboxItemFromIndex00);
+   tolua_function(tolua_S,"getItemIndex",tolua_CEGUI_CEGUI_Listbox_getItemIndex00);
+   tolua_function(tolua_S,"findItemWithText",tolua_CEGUI_CEGUI_Listbox_findItemWithText00);
+   tolua_function(tolua_S,"isSortEnabled",tolua_CEGUI_CEGUI_Listbox_isSortEnabled00);
+   tolua_function(tolua_S,"isMultiselectEnabled",tolua_CEGUI_CEGUI_Listbox_isMultiselectEnabled00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_Listbox_isItemSelected00);
+   tolua_function(tolua_S,"isListboxItemInList",tolua_CEGUI_CEGUI_Listbox_isListboxItemInList00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Listbox_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_Listbox_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_Listbox_resetList00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_Listbox_addItem00);
+   tolua_function(tolua_S,"insertItem",tolua_CEGUI_CEGUI_Listbox_insertItem00);
+   tolua_function(tolua_S,"removeItem",tolua_CEGUI_CEGUI_Listbox_removeItem00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_Listbox_clearAllSelections00);
+   tolua_function(tolua_S,"setSortingEnabled",tolua_CEGUI_CEGUI_Listbox_setSortingEnabled00);
+   tolua_function(tolua_S,"setMultiselectEnabled",tolua_CEGUI_CEGUI_Listbox_setMultiselectEnabled00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_Listbox_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_Listbox_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Listbox_setItemSelectState00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_Listbox_setItemSelectState01);
+   tolua_function(tolua_S,"handleUpdatedItemData",tolua_CEGUI_CEGUI_Listbox_handleUpdatedItemData00);
+   tolua_function(tolua_S,"ensureItemIsVisible",tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible00);
+   tolua_function(tolua_S,"ensureItemIsVisible",tolua_CEGUI_CEGUI_Listbox_ensureItemIsVisible01);
+   tolua_function(tolua_S,"getListRenderArea",tolua_CEGUI_CEGUI_Listbox_getListRenderArea00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_Listbox_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_Listbox_getHorzScrollbar00);
+   tolua_function(tolua_S,"getWidestItemWidth",tolua_CEGUI_CEGUI_Listbox_getWidestItemWidth00);
+   tolua_function(tolua_S,"getTotalItemsHeight",tolua_CEGUI_CEGUI_Listbox_getTotalItemsHeight00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ComboDropList","CEGUI::ComboDropList","CEGUI::Listbox",NULL);
+  tolua_beginmodule(tolua_S,"ComboDropList");
+   tolua_function(tolua_S,"setArmed",tolua_CEGUI_CEGUI_ComboDropList_setArmed00);
+   tolua_function(tolua_S,"isArmed",tolua_CEGUI_CEGUI_ComboDropList_isArmed00);
+   tolua_function(tolua_S,"setAutoArmEnabled",tolua_CEGUI_CEGUI_ComboDropList_setAutoArmEnabled00);
+   tolua_function(tolua_S,"isAutoArmEnabled",tolua_CEGUI_CEGUI_ComboDropList_isAutoArmEnabled00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListHeaderSegment","CEGUI::ListHeaderSegment","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ListHeaderSegment");
+   tolua_constant(tolua_S,"None",CEGUI::ListHeaderSegment::None);
+   tolua_constant(tolua_S,"Ascending",CEGUI::ListHeaderSegment::Ascending);
+   tolua_constant(tolua_S,"Descending",CEGUI::ListHeaderSegment::Descending);
+   tolua_function(tolua_S,"isSizingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_isSizingEnabled00);
+   tolua_function(tolua_S,"getSortDirection",tolua_CEGUI_CEGUI_ListHeaderSegment_getSortDirection00);
+   tolua_function(tolua_S,"isDragMovingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_isDragMovingEnabled00);
+   tolua_function(tolua_S,"getDragMoveOffset",tolua_CEGUI_CEGUI_ListHeaderSegment_getDragMoveOffset00);
+   tolua_function(tolua_S,"isClickable",tolua_CEGUI_CEGUI_ListHeaderSegment_isClickable00);
+   tolua_function(tolua_S,"setSizingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_setSizingEnabled00);
+   tolua_function(tolua_S,"setSortDirection",tolua_CEGUI_CEGUI_ListHeaderSegment_setSortDirection00);
+   tolua_function(tolua_S,"setDragMovingEnabled",tolua_CEGUI_CEGUI_ListHeaderSegment_setDragMovingEnabled00);
+   tolua_function(tolua_S,"setClickable",tolua_CEGUI_CEGUI_ListHeaderSegment_setClickable00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ListHeader","CEGUI::ListHeader","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ListHeader");
+   tolua_function(tolua_S,"getColumnCount",tolua_CEGUI_CEGUI_ListHeader_getColumnCount00);
+   tolua_function(tolua_S,"getSegmentFromColumn",tolua_CEGUI_CEGUI_ListHeader_getSegmentFromColumn00);
+   tolua_function(tolua_S,"getSegmentFromID",tolua_CEGUI_CEGUI_ListHeader_getSegmentFromID00);
+   tolua_function(tolua_S,"getSortSegment",tolua_CEGUI_CEGUI_ListHeader_getSortSegment00);
+   tolua_function(tolua_S,"getColumnFromSegment",tolua_CEGUI_CEGUI_ListHeader_getColumnFromSegment00);
+   tolua_function(tolua_S,"getColumnFromID",tolua_CEGUI_CEGUI_ListHeader_getColumnFromID00);
+   tolua_function(tolua_S,"getSortColumn",tolua_CEGUI_CEGUI_ListHeader_getSortColumn00);
+   tolua_function(tolua_S,"getColumnWithText",tolua_CEGUI_CEGUI_ListHeader_getColumnWithText00);
+   tolua_function(tolua_S,"getPixelOffsetToSegment",tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToSegment00);
+   tolua_function(tolua_S,"getPixelOffsetToColumn",tolua_CEGUI_CEGUI_ListHeader_getPixelOffsetToColumn00);
+   tolua_function(tolua_S,"getTotalSegmentsPixelExtent",tolua_CEGUI_CEGUI_ListHeader_getTotalSegmentsPixelExtent00);
+   tolua_function(tolua_S,"getColumnWidth",tolua_CEGUI_CEGUI_ListHeader_getColumnWidth00);
+   tolua_function(tolua_S,"getSortDirection",tolua_CEGUI_CEGUI_ListHeader_getSortDirection00);
+   tolua_function(tolua_S,"isSortingEnabled",tolua_CEGUI_CEGUI_ListHeader_isSortingEnabled00);
+   tolua_function(tolua_S,"isColumnSizingEnabled",tolua_CEGUI_CEGUI_ListHeader_isColumnSizingEnabled00);
+   tolua_function(tolua_S,"isColumnDraggingEnabled",tolua_CEGUI_CEGUI_ListHeader_isColumnDraggingEnabled00);
+   tolua_function(tolua_S,"getSegmentOffset",tolua_CEGUI_CEGUI_ListHeader_getSegmentOffset00);
+   tolua_function(tolua_S,"setSortingEnabled",tolua_CEGUI_CEGUI_ListHeader_setSortingEnabled00);
+   tolua_function(tolua_S,"setSortDirection",tolua_CEGUI_CEGUI_ListHeader_setSortDirection00);
+   tolua_function(tolua_S,"setSortSegment",tolua_CEGUI_CEGUI_ListHeader_setSortSegment00);
+   tolua_function(tolua_S,"setSortColumn",tolua_CEGUI_CEGUI_ListHeader_setSortColumn00);
+   tolua_function(tolua_S,"setSortColumnFromID",tolua_CEGUI_CEGUI_ListHeader_setSortColumnFromID00);
+   tolua_function(tolua_S,"setColumnSizingEnabled",tolua_CEGUI_CEGUI_ListHeader_setColumnSizingEnabled00);
+   tolua_function(tolua_S,"setColumnDraggingEnabled",tolua_CEGUI_CEGUI_ListHeader_setColumnDraggingEnabled00);
+   tolua_function(tolua_S,"addColumn",tolua_CEGUI_CEGUI_ListHeader_addColumn00);
+   tolua_function(tolua_S,"insertColumn",tolua_CEGUI_CEGUI_ListHeader_insertColumn00);
+   tolua_function(tolua_S,"insertColumn",tolua_CEGUI_CEGUI_ListHeader_insertColumn01);
+   tolua_function(tolua_S,"removeColumn",tolua_CEGUI_CEGUI_ListHeader_removeColumn00);
+   tolua_function(tolua_S,"removeSegment",tolua_CEGUI_CEGUI_ListHeader_removeSegment00);
+   tolua_function(tolua_S,"moveColumn",tolua_CEGUI_CEGUI_ListHeader_moveColumn00);
+   tolua_function(tolua_S,"moveColumn",tolua_CEGUI_CEGUI_ListHeader_moveColumn01);
+   tolua_function(tolua_S,"moveSegment",tolua_CEGUI_CEGUI_ListHeader_moveSegment00);
+   tolua_function(tolua_S,"moveSegment",tolua_CEGUI_CEGUI_ListHeader_moveSegment01);
+   tolua_function(tolua_S,"setSegmentOffset",tolua_CEGUI_CEGUI_ListHeader_setSegmentOffset00);
+   tolua_function(tolua_S,"setColumnWidth",tolua_CEGUI_CEGUI_ListHeader_setColumnWidth00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"MCLGridRef","CEGUI::MCLGridRef","",tolua_collect_CEGUI__MCLGridRef);
+  #else
+  tolua_cclass(tolua_S,"MCLGridRef","CEGUI::MCLGridRef","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"MCLGridRef");
+   tolua_variable(tolua_S,"row",tolua_get_CEGUI__MCLGridRef_unsigned_row,tolua_set_CEGUI__MCLGridRef_unsigned_row);
+   tolua_variable(tolua_S,"column",tolua_get_CEGUI__MCLGridRef_unsigned_column,tolua_set_CEGUI__MCLGridRef_unsigned_column);
+   tolua_function(tolua_S,".eq",tolua_CEGUI_CEGUI_MCLGridRef__eq00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_MCLGridRef_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_MCLGridRef_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_MCLGridRef_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MultiColumnList","CEGUI::MultiColumnList","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"MultiColumnList");
+   tolua_constant(tolua_S,"RowSingle",CEGUI::MultiColumnList::RowSingle);
+   tolua_constant(tolua_S,"RowMultiple",CEGUI::MultiColumnList::RowMultiple);
+   tolua_constant(tolua_S,"CellSingle",CEGUI::MultiColumnList::CellSingle);
+   tolua_constant(tolua_S,"CellMultiple",CEGUI::MultiColumnList::CellMultiple);
+   tolua_constant(tolua_S,"NominatedColumnSingle",CEGUI::MultiColumnList::NominatedColumnSingle);
+   tolua_constant(tolua_S,"NominatedColumnMultiple",CEGUI::MultiColumnList::NominatedColumnMultiple);
+   tolua_constant(tolua_S,"ColumnSingle",CEGUI::MultiColumnList::ColumnSingle);
+   tolua_constant(tolua_S,"ColumnMultiple",CEGUI::MultiColumnList::ColumnMultiple);
+   tolua_constant(tolua_S,"NominatedRowSingle",CEGUI::MultiColumnList::NominatedRowSingle);
+   tolua_constant(tolua_S,"NominatedRowMultiple",CEGUI::MultiColumnList::NominatedRowMultiple);
+   tolua_function(tolua_S,"isUserSortControlEnabled",tolua_CEGUI_CEGUI_MultiColumnList_isUserSortControlEnabled00);
+   tolua_function(tolua_S,"isUserColumnSizingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnSizingEnabled00);
+   tolua_function(tolua_S,"isUserColumnDraggingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_isUserColumnDraggingEnabled00);
+   tolua_function(tolua_S,"getColumnCount",tolua_CEGUI_CEGUI_MultiColumnList_getColumnCount00);
+   tolua_function(tolua_S,"getRowCount",tolua_CEGUI_CEGUI_MultiColumnList_getRowCount00);
+   tolua_function(tolua_S,"getSortColumn",tolua_CEGUI_CEGUI_MultiColumnList_getSortColumn00);
+   tolua_function(tolua_S,"getColumnWithID",tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithID00);
+   tolua_function(tolua_S,"getColumnWithHeaderText",tolua_CEGUI_CEGUI_MultiColumnList_getColumnWithHeaderText00);
+   tolua_function(tolua_S,"getTotalColumnHeadersWidth",tolua_CEGUI_CEGUI_MultiColumnList_getTotalColumnHeadersWidth00);
+   tolua_function(tolua_S,"getColumnHeaderWidth",tolua_CEGUI_CEGUI_MultiColumnList_getColumnHeaderWidth00);
+   tolua_function(tolua_S,"getSortDirection",tolua_CEGUI_CEGUI_MultiColumnList_getSortDirection00);
+   tolua_function(tolua_S,"getHeaderSegmentForColumn",tolua_CEGUI_CEGUI_MultiColumnList_getHeaderSegmentForColumn00);
+   tolua_function(tolua_S,"getItemRowIndex",tolua_CEGUI_CEGUI_MultiColumnList_getItemRowIndex00);
+   tolua_function(tolua_S,"getItemColumnIndex",tolua_CEGUI_CEGUI_MultiColumnList_getItemColumnIndex00);
+   tolua_function(tolua_S,"getItemGridReference",tolua_CEGUI_CEGUI_MultiColumnList_getItemGridReference00);
+   tolua_function(tolua_S,"getItemAtGridReference",tolua_CEGUI_CEGUI_MultiColumnList_getItemAtGridReference00);
+   tolua_function(tolua_S,"isListboxItemInColumn",tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInColumn00);
+   tolua_function(tolua_S,"isListboxItemInRow",tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInRow00);
+   tolua_function(tolua_S,"isListboxItemInList",tolua_CEGUI_CEGUI_MultiColumnList_isListboxItemInList00);
+   tolua_function(tolua_S,"findColumnItemWithText",tolua_CEGUI_CEGUI_MultiColumnList_findColumnItemWithText00);
+   tolua_function(tolua_S,"findRowItemWithText",tolua_CEGUI_CEGUI_MultiColumnList_findRowItemWithText00);
+   tolua_function(tolua_S,"findListItemWithText",tolua_CEGUI_CEGUI_MultiColumnList_findListItemWithText00);
+   tolua_function(tolua_S,"getFirstSelectedItem",tolua_CEGUI_CEGUI_MultiColumnList_getFirstSelectedItem00);
+   tolua_function(tolua_S,"getNextSelected",tolua_CEGUI_CEGUI_MultiColumnList_getNextSelected00);
+   tolua_function(tolua_S,"getSelectedCount",tolua_CEGUI_CEGUI_MultiColumnList_getSelectedCount00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_MultiColumnList_isItemSelected00);
+   tolua_function(tolua_S,"getNominatedSelectionColumnID",tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumnID00);
+   tolua_function(tolua_S,"getNominatedSelectionColumn",tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionColumn00);
+   tolua_function(tolua_S,"getNominatedSelectionRow",tolua_CEGUI_CEGUI_MultiColumnList_getNominatedSelectionRow00);
+   tolua_function(tolua_S,"getSelectionMode",tolua_CEGUI_CEGUI_MultiColumnList_getSelectionMode00);
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_MultiColumnList_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_MultiColumnList_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"getColumnID",tolua_CEGUI_CEGUI_MultiColumnList_getColumnID00);
+   tolua_function(tolua_S,"getRowID",tolua_CEGUI_CEGUI_MultiColumnList_getRowID00);
+   tolua_function(tolua_S,"getRowWithID",tolua_CEGUI_CEGUI_MultiColumnList_getRowWithID00);
+   tolua_function(tolua_S,"getListRenderArea",tolua_CEGUI_CEGUI_MultiColumnList_getListRenderArea00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_getHorzScrollbar00);
+   tolua_function(tolua_S,"getListHeader",tolua_CEGUI_CEGUI_MultiColumnList_getListHeader00);
+   tolua_function(tolua_S,"getTotalRowsHeight",tolua_CEGUI_CEGUI_MultiColumnList_getTotalRowsHeight00);
+   tolua_function(tolua_S,"getWidestColumnItemWidth",tolua_CEGUI_CEGUI_MultiColumnList_getWidestColumnItemWidth00);
+   tolua_function(tolua_S,"getHighestRowItemHeight",tolua_CEGUI_CEGUI_MultiColumnList_getHighestRowItemHeight00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_MultiColumnList_resetList00);
+   tolua_function(tolua_S,"addColumn",tolua_CEGUI_CEGUI_MultiColumnList_addColumn00);
+   tolua_function(tolua_S,"insertColumn",tolua_CEGUI_CEGUI_MultiColumnList_insertColumn00);
+   tolua_function(tolua_S,"removeColumn",tolua_CEGUI_CEGUI_MultiColumnList_removeColumn00);
+   tolua_function(tolua_S,"removeColumnWithID",tolua_CEGUI_CEGUI_MultiColumnList_removeColumnWithID00);
+   tolua_function(tolua_S,"moveColumn",tolua_CEGUI_CEGUI_MultiColumnList_moveColumn00);
+   tolua_function(tolua_S,"moveColumnWithID",tolua_CEGUI_CEGUI_MultiColumnList_moveColumnWithID00);
+   tolua_function(tolua_S,"addRow",tolua_CEGUI_CEGUI_MultiColumnList_addRow00);
+   tolua_function(tolua_S,"addRow",tolua_CEGUI_CEGUI_MultiColumnList_addRow01);
+   tolua_function(tolua_S,"insertRow",tolua_CEGUI_CEGUI_MultiColumnList_insertRow00);
+   tolua_function(tolua_S,"insertRow",tolua_CEGUI_CEGUI_MultiColumnList_insertRow01);
+   tolua_function(tolua_S,"removeRow",tolua_CEGUI_CEGUI_MultiColumnList_removeRow00);
+   tolua_function(tolua_S,"setItem",tolua_CEGUI_CEGUI_MultiColumnList_setItem00);
+   tolua_function(tolua_S,"setItem",tolua_CEGUI_CEGUI_MultiColumnList_setItem01);
+   tolua_function(tolua_S,"setSelectionMode",tolua_CEGUI_CEGUI_MultiColumnList_setSelectionMode00);
+   tolua_function(tolua_S,"setNominatedSelectionColumnID",tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumnID00);
+   tolua_function(tolua_S,"setNominatedSelectionColumn",tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionColumn00);
+   tolua_function(tolua_S,"setNominatedSelectionRow",tolua_CEGUI_CEGUI_MultiColumnList_setNominatedSelectionRow00);
+   tolua_function(tolua_S,"setSortDirection",tolua_CEGUI_CEGUI_MultiColumnList_setSortDirection00);
+   tolua_function(tolua_S,"setSortColumn",tolua_CEGUI_CEGUI_MultiColumnList_setSortColumn00);
+   tolua_function(tolua_S,"setSortColumnByID",tolua_CEGUI_CEGUI_MultiColumnList_setSortColumnByID00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_MultiColumnList_setShowHorzScrollbar00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_MultiColumnList_clearAllSelections00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState00);
+   tolua_function(tolua_S,"setItemSelectState",tolua_CEGUI_CEGUI_MultiColumnList_setItemSelectState01);
+   tolua_function(tolua_S,"handleUpdatedItemData",tolua_CEGUI_CEGUI_MultiColumnList_handleUpdatedItemData00);
+   tolua_function(tolua_S,"setColumnHeaderWidth",tolua_CEGUI_CEGUI_MultiColumnList_setColumnHeaderWidth00);
+   tolua_function(tolua_S,"setUserSortControlEnabled",tolua_CEGUI_CEGUI_MultiColumnList_setUserSortControlEnabled00);
+   tolua_function(tolua_S,"setUserColumnSizingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnSizingEnabled00);
+   tolua_function(tolua_S,"setUserColumnDraggingEnabled",tolua_CEGUI_CEGUI_MultiColumnList_setUserColumnDraggingEnabled00);
+   tolua_function(tolua_S,"autoSizeColumnHeader",tolua_CEGUI_CEGUI_MultiColumnList_autoSizeColumnHeader00);
+   tolua_function(tolua_S,"setRowID",tolua_CEGUI_CEGUI_MultiColumnList_setRowID00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ItemEntry","CEGUI::ItemEntry","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ItemEntry");
+   tolua_function(tolua_S,"getItemPixelSize",tolua_CEGUI_CEGUI_ItemEntry_getItemPixelSize00);
+   tolua_function(tolua_S,"getOwnerList",tolua_CEGUI_CEGUI_ItemEntry_getOwnerList00);
+   tolua_function(tolua_S,"isSelected",tolua_CEGUI_CEGUI_ItemEntry_isSelected00);
+   tolua_function(tolua_S,"isSelectable",tolua_CEGUI_CEGUI_ItemEntry_isSelectable00);
+   tolua_function(tolua_S,"setSelected",tolua_CEGUI_CEGUI_ItemEntry_setSelected00);
+   tolua_function(tolua_S,"select",tolua_CEGUI_CEGUI_ItemEntry_select00);
+   tolua_function(tolua_S,"deselect",tolua_CEGUI_CEGUI_ItemEntry_deselect00);
+   tolua_function(tolua_S,"setSelectable",tolua_CEGUI_CEGUI_ItemEntry_setSelectable00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ItemListBase","CEGUI::ItemListBase","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"ItemListBase");
+   tolua_constant(tolua_S,"Ascending",CEGUI::ItemListBase::Ascending);
+   tolua_constant(tolua_S,"Descending",CEGUI::ItemListBase::Descending);
+   tolua_constant(tolua_S,"UserSort",CEGUI::ItemListBase::UserSort);
+   tolua_function(tolua_S,"getItemCount",tolua_CEGUI_CEGUI_ItemListBase_getItemCount00);
+   tolua_function(tolua_S,"getItemFromIndex",tolua_CEGUI_CEGUI_ItemListBase_getItemFromIndex00);
+   tolua_function(tolua_S,"getItemIndex",tolua_CEGUI_CEGUI_ItemListBase_getItemIndex00);
+   tolua_function(tolua_S,"findItemWithText",tolua_CEGUI_CEGUI_ItemListBase_findItemWithText00);
+   tolua_function(tolua_S,"isItemInList",tolua_CEGUI_CEGUI_ItemListBase_isItemInList00);
+   tolua_function(tolua_S,"isAutoResizeEnabled",tolua_CEGUI_CEGUI_ItemListBase_isAutoResizeEnabled00);
+   tolua_function(tolua_S,"isSortEnabled",tolua_CEGUI_CEGUI_ItemListBase_isSortEnabled00);
+   tolua_function(tolua_S,"getSortMode",tolua_CEGUI_CEGUI_ItemListBase_getSortMode00);
+   tolua_function(tolua_S,"getItemRenderArea",tolua_CEGUI_CEGUI_ItemListBase_getItemRenderArea00);
+   tolua_function(tolua_S,"getContentPane",tolua_CEGUI_CEGUI_ItemListBase_getContentPane00);
+   tolua_function(tolua_S,"resetList",tolua_CEGUI_CEGUI_ItemListBase_resetList00);
+   tolua_function(tolua_S,"addItem",tolua_CEGUI_CEGUI_ItemListBase_addItem00);
+   tolua_function(tolua_S,"insertItem",tolua_CEGUI_CEGUI_ItemListBase_insertItem00);
+   tolua_function(tolua_S,"removeItem",tolua_CEGUI_CEGUI_ItemListBase_removeItem00);
+   tolua_function(tolua_S,"handleUpdatedItemData",tolua_CEGUI_CEGUI_ItemListBase_handleUpdatedItemData00);
+   tolua_function(tolua_S,"setAutoResizeEnabled",tolua_CEGUI_CEGUI_ItemListBase_setAutoResizeEnabled00);
+   tolua_function(tolua_S,"sizeToContent",tolua_CEGUI_CEGUI_ItemListBase_sizeToContent00);
+   tolua_function(tolua_S,"setSortEnabled",tolua_CEGUI_CEGUI_ItemListBase_setSortEnabled00);
+   tolua_function(tolua_S,"setSortMode",tolua_CEGUI_CEGUI_ItemListBase_setSortMode00);
+   tolua_function(tolua_S,"sortList",tolua_CEGUI_CEGUI_ItemListBase_sortList00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MenuBase","CEGUI::MenuBase","CEGUI::ItemListBase",NULL);
+  tolua_beginmodule(tolua_S,"MenuBase");
+   tolua_function(tolua_S,"getItemSpacing",tolua_CEGUI_CEGUI_MenuBase_getItemSpacing00);
+   tolua_function(tolua_S,"isMultiplePopupsAllowed",tolua_CEGUI_CEGUI_MenuBase_isMultiplePopupsAllowed00);
+   tolua_function(tolua_S,"getPopupMenuItem",tolua_CEGUI_CEGUI_MenuBase_getPopupMenuItem00);
+   tolua_function(tolua_S,"setItemSpacing",tolua_CEGUI_CEGUI_MenuBase_setItemSpacing00);
+   tolua_function(tolua_S,"changePopupMenuItem",tolua_CEGUI_CEGUI_MenuBase_changePopupMenuItem00);
+   tolua_function(tolua_S,"setAllowMultiplePopups",tolua_CEGUI_CEGUI_MenuBase_setAllowMultiplePopups00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"Menubar","CEGUI::Menubar","CEGUI::MenuBase",NULL);
+  tolua_beginmodule(tolua_S,"Menubar");
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PopupMenu","CEGUI::PopupMenu","CEGUI::MenuBase",NULL);
+  tolua_beginmodule(tolua_S,"PopupMenu");
+   tolua_function(tolua_S,"getFadeInTime",tolua_CEGUI_CEGUI_PopupMenu_getFadeInTime00);
+   tolua_function(tolua_S,"getFadeOutTime",tolua_CEGUI_CEGUI_PopupMenu_getFadeOutTime00);
+   tolua_function(tolua_S,"setFadeInTime",tolua_CEGUI_CEGUI_PopupMenu_setFadeInTime00);
+   tolua_function(tolua_S,"setFadeOutTime",tolua_CEGUI_CEGUI_PopupMenu_setFadeOutTime00);
+   tolua_function(tolua_S,"openPopupMenu",tolua_CEGUI_CEGUI_PopupMenu_openPopupMenu00);
+   tolua_function(tolua_S,"closePopupMenu",tolua_CEGUI_CEGUI_PopupMenu_closePopupMenu00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"MenuItem","CEGUI::MenuItem","CEGUI::ItemEntry",NULL);
+  tolua_beginmodule(tolua_S,"MenuItem");
+   tolua_function(tolua_S,"isHovering",tolua_CEGUI_CEGUI_MenuItem_isHovering00);
+   tolua_function(tolua_S,"isPushed",tolua_CEGUI_CEGUI_MenuItem_isPushed00);
+   tolua_function(tolua_S,"getPopupMenu",tolua_CEGUI_CEGUI_MenuItem_getPopupMenu00);
+   tolua_function(tolua_S,"setPopupMenu",tolua_CEGUI_CEGUI_MenuItem_setPopupMenu00);
+   tolua_function(tolua_S,"openPopupMenu",tolua_CEGUI_CEGUI_MenuItem_openPopupMenu00);
+   tolua_function(tolua_S,"closePopupMenu",tolua_CEGUI_CEGUI_MenuItem_closePopupMenu00);
+   tolua_function(tolua_S,"togglePopupMenu",tolua_CEGUI_CEGUI_MenuItem_togglePopupMenu00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ScrolledItemListBase","CEGUI::ScrolledItemListBase","CEGUI::ItemListBase",NULL);
+  tolua_beginmodule(tolua_S,"ScrolledItemListBase");
+   tolua_function(tolua_S,"isVertScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrolledItemListBase_isVertScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"isHorzScrollbarAlwaysShown",tolua_CEGUI_CEGUI_ScrolledItemListBase_isHorzScrollbarAlwaysShown00);
+   tolua_function(tolua_S,"getVertScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_getVertScrollbar00);
+   tolua_function(tolua_S,"getHorzScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_getHorzScrollbar00);
+   tolua_function(tolua_S,"setShowVertScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowVertScrollbar00);
+   tolua_function(tolua_S,"setShowHorzScrollbar",tolua_CEGUI_CEGUI_ScrolledItemListBase_setShowHorzScrollbar00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"ItemListbox","CEGUI::ItemListbox","CEGUI::ScrolledItemListBase",NULL);
+  tolua_beginmodule(tolua_S,"ItemListbox");
+   tolua_function(tolua_S,"getSelectedCount",tolua_CEGUI_CEGUI_ItemListbox_getSelectedCount00);
+   tolua_function(tolua_S,"getLastSelectedItem",tolua_CEGUI_CEGUI_ItemListbox_getLastSelectedItem00);
+   tolua_function(tolua_S,"getFirstSelectedItem",tolua_CEGUI_CEGUI_ItemListbox_getFirstSelectedItem00);
+   tolua_function(tolua_S,"getNextSelectedItem",tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItem00);
+   tolua_function(tolua_S,"getNextSelectedItemAfter",tolua_CEGUI_CEGUI_ItemListbox_getNextSelectedItemAfter00);
+   tolua_function(tolua_S,"isMultiSelectEnabled",tolua_CEGUI_CEGUI_ItemListbox_isMultiSelectEnabled00);
+   tolua_function(tolua_S,"isItemSelected",tolua_CEGUI_CEGUI_ItemListbox_isItemSelected00);
+   tolua_function(tolua_S,"setMultiSelectEnabled",tolua_CEGUI_CEGUI_ItemListbox_setMultiSelectEnabled00);
+   tolua_function(tolua_S,"clearAllSelections",tolua_CEGUI_CEGUI_ItemListbox_clearAllSelections00);
+   tolua_function(tolua_S,"selectRange",tolua_CEGUI_CEGUI_ItemListbox_selectRange00);
+   tolua_function(tolua_S,"selectAllItems",tolua_CEGUI_CEGUI_ItemListbox_selectAllItems00);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"GroupBox","CEGUI::GroupBox","CEGUI::Window",NULL);
+  tolua_beginmodule(tolua_S,"GroupBox");
+   tolua_function(tolua_S,"drawAroundWidget",tolua_CEGUI_CEGUI_GroupBox_drawAroundWidget00);
+  tolua_endmodule(tolua_S);
+  tolua_constant(tolua_S,"DT_LEFT_EDGE",CEGUI::DT_LEFT_EDGE);
+  tolua_constant(tolua_S,"DT_X_POSITION",CEGUI::DT_X_POSITION);
+  tolua_constant(tolua_S,"DT_TOP_EDGE",CEGUI::DT_TOP_EDGE);
+  tolua_constant(tolua_S,"DT_Y_POSITION",CEGUI::DT_Y_POSITION);
+  tolua_constant(tolua_S,"DT_RIGHT_EDGE",CEGUI::DT_RIGHT_EDGE);
+  tolua_constant(tolua_S,"DT_BOTTOM_EDGE",CEGUI::DT_BOTTOM_EDGE);
+  tolua_constant(tolua_S,"DT_WIDTH",CEGUI::DT_WIDTH);
+  tolua_constant(tolua_S,"DT_HEIGHT",CEGUI::DT_HEIGHT);
+  tolua_constant(tolua_S,"DT_X_OFFSET",CEGUI::DT_X_OFFSET);
+  tolua_constant(tolua_S,"DT_Y_OFFSET",CEGUI::DT_Y_OFFSET);
+  tolua_constant(tolua_S,"DT_INVALID",CEGUI::DT_INVALID);
+  tolua_constant(tolua_S,"VF_TOP_ALIGNED",CEGUI::VF_TOP_ALIGNED);
+  tolua_constant(tolua_S,"VF_CENTRE_ALIGNED",CEGUI::VF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"VF_BOTTOM_ALIGNED",CEGUI::VF_BOTTOM_ALIGNED);
+  tolua_constant(tolua_S,"VF_STRETCHED",CEGUI::VF_STRETCHED);
+  tolua_constant(tolua_S,"VF_TILED",CEGUI::VF_TILED);
+  tolua_constant(tolua_S,"HF_LEFT_ALIGNED",CEGUI::HF_LEFT_ALIGNED);
+  tolua_constant(tolua_S,"HF_CENTRE_ALIGNED",CEGUI::HF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"HF_RIGHT_ALIGNED",CEGUI::HF_RIGHT_ALIGNED);
+  tolua_constant(tolua_S,"HF_STRETCHED",CEGUI::HF_STRETCHED);
+  tolua_constant(tolua_S,"HF_TILED",CEGUI::HF_TILED);
+  tolua_constant(tolua_S,"VTF_TOP_ALIGNED",CEGUI::VTF_TOP_ALIGNED);
+  tolua_constant(tolua_S,"VTF_CENTRE_ALIGNED",CEGUI::VTF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"VTF_BOTTOM_ALIGNED",CEGUI::VTF_BOTTOM_ALIGNED);
+  tolua_constant(tolua_S,"HTF_LEFT_ALIGNED",CEGUI::HTF_LEFT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_RIGHT_ALIGNED",CEGUI::HTF_RIGHT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_CENTRE_ALIGNED",CEGUI::HTF_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"HTF_JUSTIFIED",CEGUI::HTF_JUSTIFIED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_LEFT_ALIGNED",CEGUI::HTF_WORDWRAP_LEFT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_RIGHT_ALIGNED",CEGUI::HTF_WORDWRAP_RIGHT_ALIGNED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_CENTRE_ALIGNED",CEGUI::HTF_WORDWRAP_CENTRE_ALIGNED);
+  tolua_constant(tolua_S,"HTF_WORDWRAP_JUSTIFIED",CEGUI::HTF_WORDWRAP_JUSTIFIED);
+  tolua_constant(tolua_S,"FMT_LINE_SPACING",CEGUI::FMT_LINE_SPACING);
+  tolua_constant(tolua_S,"FMT_BASELINE",CEGUI::FMT_BASELINE);
+  tolua_constant(tolua_S,"FMT_HORZ_EXTENT",CEGUI::FMT_HORZ_EXTENT);
+  tolua_constant(tolua_S,"DOP_NOOP",CEGUI::DOP_NOOP);
+  tolua_constant(tolua_S,"DOP_ADD",CEGUI::DOP_ADD);
+  tolua_constant(tolua_S,"DOP_SUBTRACT",CEGUI::DOP_SUBTRACT);
+  tolua_constant(tolua_S,"DOP_MULTIPLY",CEGUI::DOP_MULTIPLY);
+  tolua_constant(tolua_S,"DOP_DIVIDE",CEGUI::DOP_DIVIDE);
+  tolua_constant(tolua_S,"FIC_BACKGROUND",CEGUI::FIC_BACKGROUND);
+  tolua_constant(tolua_S,"FIC_TOP_LEFT_CORNER",CEGUI::FIC_TOP_LEFT_CORNER);
+  tolua_constant(tolua_S,"FIC_TOP_RIGHT_CORNER",CEGUI::FIC_TOP_RIGHT_CORNER);
+  tolua_constant(tolua_S,"FIC_BOTTOM_LEFT_CORNER",CEGUI::FIC_BOTTOM_LEFT_CORNER);
+  tolua_constant(tolua_S,"FIC_BOTTOM_RIGHT_CORNER",CEGUI::FIC_BOTTOM_RIGHT_CORNER);
+  tolua_constant(tolua_S,"FIC_LEFT_EDGE",CEGUI::FIC_LEFT_EDGE);
+  tolua_constant(tolua_S,"FIC_RIGHT_EDGE",CEGUI::FIC_RIGHT_EDGE);
+  tolua_constant(tolua_S,"FIC_TOP_EDGE",CEGUI::FIC_TOP_EDGE);
+  tolua_constant(tolua_S,"FIC_BOTTOM_EDGE",CEGUI::FIC_BOTTOM_EDGE);
+  tolua_constant(tolua_S,"FIC_FRAME_IMAGE_COUNT",CEGUI::FIC_FRAME_IMAGE_COUNT);
+  tolua_cclass(tolua_S,"BaseDim","CEGUI::BaseDim","",NULL);
+  tolua_beginmodule(tolua_S,"BaseDim");
+   tolua_function(tolua_S,"getValue",tolua_CEGUI_CEGUI_BaseDim_getValue00);
+   tolua_function(tolua_S,"getValue",tolua_CEGUI_CEGUI_BaseDim_getValue01);
+   tolua_function(tolua_S,"clone",tolua_CEGUI_CEGUI_BaseDim_clone00);
+   tolua_function(tolua_S,"getDimensionOperator",tolua_CEGUI_CEGUI_BaseDim_getDimensionOperator00);
+   tolua_function(tolua_S,"setDimensionOperator",tolua_CEGUI_CEGUI_BaseDim_setDimensionOperator00);
+   tolua_function(tolua_S,"getOperand",tolua_CEGUI_CEGUI_BaseDim_getOperand00);
+   tolua_function(tolua_S,"setOperand",tolua_CEGUI_CEGUI_BaseDim_setOperand00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"AbsoluteDim","CEGUI::AbsoluteDim","CEGUI::BaseDim",tolua_collect_CEGUI__AbsoluteDim);
+  #else
+  tolua_cclass(tolua_S,"AbsoluteDim","CEGUI::AbsoluteDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"AbsoluteDim");
+   tolua_function(tolua_S,"setValue",tolua_CEGUI_CEGUI_AbsoluteDim_setValue00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_AbsoluteDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_AbsoluteDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_AbsoluteDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImageDim","CEGUI::ImageDim","CEGUI::BaseDim",tolua_collect_CEGUI__ImageDim);
+  #else
+  tolua_cclass(tolua_S,"ImageDim","CEGUI::ImageDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImageDim");
+   tolua_function(tolua_S,"setSourceImage",tolua_CEGUI_CEGUI_ImageDim_setSourceImage00);
+   tolua_function(tolua_S,"setSourceDimension",tolua_CEGUI_CEGUI_ImageDim_setSourceDimension00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImageDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImageDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImageDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetDim","CEGUI::WidgetDim","CEGUI::BaseDim",tolua_collect_CEGUI__WidgetDim);
+  #else
+  tolua_cclass(tolua_S,"WidgetDim","CEGUI::WidgetDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetDim");
+   tolua_function(tolua_S,"setWidgetName",tolua_CEGUI_CEGUI_WidgetDim_setWidgetName00);
+   tolua_function(tolua_S,"setSourceDimension",tolua_CEGUI_CEGUI_WidgetDim_setSourceDimension00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"UnifiedDim","CEGUI::UnifiedDim","CEGUI::BaseDim",tolua_collect_CEGUI__UnifiedDim);
+  #else
+  tolua_cclass(tolua_S,"UnifiedDim","CEGUI::UnifiedDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"UnifiedDim");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_UnifiedDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_UnifiedDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_UnifiedDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FontDim","CEGUI::FontDim","CEGUI::BaseDim",tolua_collect_CEGUI__FontDim);
+  #else
+  tolua_cclass(tolua_S,"FontDim","CEGUI::FontDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FontDim");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FontDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FontDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FontDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyDim","CEGUI::PropertyDim","CEGUI::BaseDim",tolua_collect_CEGUI__PropertyDim);
+  #else
+  tolua_cclass(tolua_S,"PropertyDim","CEGUI::PropertyDim","CEGUI::BaseDim",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyDim");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyDim_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyDim_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyDim_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"Dimension","CEGUI::Dimension","",tolua_collect_CEGUI__Dimension);
+  #else
+  tolua_cclass(tolua_S,"Dimension","CEGUI::Dimension","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"Dimension");
+   tolua_function(tolua_S,"getBaseDimension",tolua_CEGUI_CEGUI_Dimension_getBaseDimension00);
+   tolua_function(tolua_S,"setBaseDimension",tolua_CEGUI_CEGUI_Dimension_setBaseDimension00);
+   tolua_function(tolua_S,"getDimensionType",tolua_CEGUI_CEGUI_Dimension_getDimensionType00);
+   tolua_function(tolua_S,"setDimensionType",tolua_CEGUI_CEGUI_Dimension_setDimensionType00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Dimension_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Dimension_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Dimension_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Dimension_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Dimension_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Dimension_new01_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_Dimension_new02);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_Dimension_new02_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_Dimension_new02_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ComponentArea","CEGUI::ComponentArea","",tolua_collect_CEGUI__ComponentArea);
+  #else
+  tolua_cclass(tolua_S,"ComponentArea","CEGUI::ComponentArea","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ComponentArea");
+   tolua_function(tolua_S,"getPixelRect",tolua_CEGUI_CEGUI_ComponentArea_getPixelRect00);
+   tolua_function(tolua_S,"getPixelRect",tolua_CEGUI_CEGUI_ComponentArea_getPixelRect01);
+   tolua_function(tolua_S,"isAreaFetchedFromProperty",tolua_CEGUI_CEGUI_ComponentArea_isAreaFetchedFromProperty00);
+   tolua_function(tolua_S,"getAreaPropertySource",tolua_CEGUI_CEGUI_ComponentArea_getAreaPropertySource00);
+   tolua_function(tolua_S,"setAreaPropertySource",tolua_CEGUI_CEGUI_ComponentArea_setAreaPropertySource00);
+   tolua_variable(tolua_S,"d_left",tolua_get_CEGUI__ComponentArea_d_left,tolua_set_CEGUI__ComponentArea_d_left);
+   tolua_variable(tolua_S,"d_top",tolua_get_CEGUI__ComponentArea_d_top,tolua_set_CEGUI__ComponentArea_d_top);
+   tolua_variable(tolua_S,"d_right_or_width",tolua_get_CEGUI__ComponentArea_d_right_or_width,tolua_set_CEGUI__ComponentArea_d_right_or_width);
+   tolua_variable(tolua_S,"d_bottom_or_height",tolua_get_CEGUI__ComponentArea_d_bottom_or_height,tolua_set_CEGUI__ComponentArea_d_bottom_or_height);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ComponentArea_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ComponentArea_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ComponentArea_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"NamedArea","CEGUI::NamedArea","",tolua_collect_CEGUI__NamedArea);
+  #else
+  tolua_cclass(tolua_S,"NamedArea","CEGUI::NamedArea","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"NamedArea");
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_NamedArea_getName00);
+   tolua_function(tolua_S,"getArea",tolua_CEGUI_CEGUI_NamedArea_getArea00);
+   tolua_function(tolua_S,"setArea",tolua_CEGUI_CEGUI_NamedArea_setArea00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_NamedArea_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_NamedArea_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_NamedArea_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_NamedArea_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_NamedArea_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_NamedArea_new01_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"PropertyDefinitionBase","CEGUI::PropertyDefinitionBase","CEGUI::Property",NULL);
+  tolua_beginmodule(tolua_S,"PropertyDefinitionBase");
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_PropertyDefinitionBase_set00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyDefinition","CEGUI::PropertyDefinition","CEGUI::PropertyDefinitionBase",tolua_collect_CEGUI__PropertyDefinition);
+  #else
+  tolua_cclass(tolua_S,"PropertyDefinition","CEGUI::PropertyDefinition","CEGUI::PropertyDefinitionBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyDefinition");
+   tolua_function(tolua_S,"get",tolua_CEGUI_CEGUI_PropertyDefinition_get00);
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_PropertyDefinition_set00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyDefinition_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyDefinition_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyDefinition_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyInitialiser","CEGUI::PropertyInitialiser","",tolua_collect_CEGUI__PropertyInitialiser);
+  #else
+  tolua_cclass(tolua_S,"PropertyInitialiser","CEGUI::PropertyInitialiser","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyInitialiser");
+   tolua_function(tolua_S,"apply",tolua_CEGUI_CEGUI_PropertyInitialiser_apply00);
+   tolua_function(tolua_S,"getTargetPropertyName",tolua_CEGUI_CEGUI_PropertyInitialiser_getTargetPropertyName00);
+   tolua_function(tolua_S,"getInitialiserValue",tolua_CEGUI_CEGUI_PropertyInitialiser_getInitialiserValue00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyInitialiser_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyInitialiser_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"PropertyLinkDefinition","CEGUI::PropertyLinkDefinition","CEGUI::PropertyDefinitionBase",tolua_collect_CEGUI__PropertyLinkDefinition);
+  #else
+  tolua_cclass(tolua_S,"PropertyLinkDefinition","CEGUI::PropertyLinkDefinition","CEGUI::PropertyDefinitionBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"PropertyLinkDefinition");
+   tolua_function(tolua_S,"get",tolua_CEGUI_CEGUI_PropertyLinkDefinition_get00);
+   tolua_function(tolua_S,"set",tolua_CEGUI_CEGUI_PropertyLinkDefinition_set00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_PropertyLinkDefinition_new00_local);
+  tolua_endmodule(tolua_S);
+  tolua_cclass(tolua_S,"FalagardComponentBase","CEGUI::FalagardComponentBase","",NULL);
+  tolua_beginmodule(tolua_S,"FalagardComponentBase");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_FalagardComponentBase_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_FalagardComponentBase_render01);
+   tolua_function(tolua_S,"getComponentArea",tolua_CEGUI_CEGUI_FalagardComponentBase_getComponentArea00);
+   tolua_function(tolua_S,"setComponentArea",tolua_CEGUI_CEGUI_FalagardComponentBase_setComponentArea00);
+   tolua_function(tolua_S,"getColours",tolua_CEGUI_CEGUI_FalagardComponentBase_getColours00);
+   tolua_function(tolua_S,"setColours",tolua_CEGUI_CEGUI_FalagardComponentBase_setColours00);
+   tolua_function(tolua_S,"setColoursPropertySource",tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertySource00);
+   tolua_function(tolua_S,"setColoursPropertyIsColourRect",tolua_CEGUI_CEGUI_FalagardComponentBase_setColoursPropertyIsColourRect00);
+   tolua_function(tolua_S,"setVertFormattingPropertySource",tolua_CEGUI_CEGUI_FalagardComponentBase_setVertFormattingPropertySource00);
+   tolua_function(tolua_S,"setHorzFormattingPropertySource",tolua_CEGUI_CEGUI_FalagardComponentBase_setHorzFormattingPropertySource00);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FrameComponent","CEGUI::FrameComponent","CEGUI::FalagardComponentBase",tolua_collect_CEGUI__FrameComponent);
+  #else
+  tolua_cclass(tolua_S,"FrameComponent","CEGUI::FrameComponent","CEGUI::FalagardComponentBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FrameComponent");
+   tolua_function(tolua_S,"getBackgroundVerticalFormatting",tolua_CEGUI_CEGUI_FrameComponent_getBackgroundVerticalFormatting00);
+   tolua_function(tolua_S,"setBackgroundVerticalFormatting",tolua_CEGUI_CEGUI_FrameComponent_setBackgroundVerticalFormatting00);
+   tolua_function(tolua_S,"getBackgroundHorizontalFormatting",tolua_CEGUI_CEGUI_FrameComponent_getBackgroundHorizontalFormatting00);
+   tolua_function(tolua_S,"setBackgroundHorizontalFormatting",tolua_CEGUI_CEGUI_FrameComponent_setBackgroundHorizontalFormatting00);
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_FrameComponent_getImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_FrameComponent_setImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_FrameComponent_setImage01);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FrameComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FrameComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FrameComponent_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImageryComponent","CEGUI::ImageryComponent","CEGUI::FalagardComponentBase",tolua_collect_CEGUI__ImageryComponent);
+  #else
+  tolua_cclass(tolua_S,"ImageryComponent","CEGUI::ImageryComponent","CEGUI::FalagardComponentBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImageryComponent");
+   tolua_function(tolua_S,"getImage",tolua_CEGUI_CEGUI_ImageryComponent_getImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_ImageryComponent_setImage00);
+   tolua_function(tolua_S,"setImage",tolua_CEGUI_CEGUI_ImageryComponent_setImage01);
+   tolua_function(tolua_S,"getVerticalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_getVerticalFormatting00);
+   tolua_function(tolua_S,"setVerticalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_setVerticalFormatting00);
+   tolua_function(tolua_S,"getHorizontalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_getHorizontalFormatting00);
+   tolua_function(tolua_S,"setHorizontalFormatting",tolua_CEGUI_CEGUI_ImageryComponent_setHorizontalFormatting00);
+   tolua_function(tolua_S,"isImageFetchedFromProperty",tolua_CEGUI_CEGUI_ImageryComponent_isImageFetchedFromProperty00);
+   tolua_function(tolua_S,"getImagePropertySource",tolua_CEGUI_CEGUI_ImageryComponent_getImagePropertySource00);
+   tolua_function(tolua_S,"setImagePropertySource",tolua_CEGUI_CEGUI_ImageryComponent_setImagePropertySource00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImageryComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImageryComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImageryComponent_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"TextComponent","CEGUI::TextComponent","CEGUI::FalagardComponentBase",tolua_collect_CEGUI__TextComponent);
+  #else
+  tolua_cclass(tolua_S,"TextComponent","CEGUI::TextComponent","CEGUI::FalagardComponentBase",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"TextComponent");
+   tolua_function(tolua_S,"getText",tolua_CEGUI_CEGUI_TextComponent_getText00);
+   tolua_function(tolua_S,"setText",tolua_CEGUI_CEGUI_TextComponent_setText00);
+   tolua_function(tolua_S,"getFont",tolua_CEGUI_CEGUI_TextComponent_getFont00);
+   tolua_function(tolua_S,"setFont",tolua_CEGUI_CEGUI_TextComponent_setFont00);
+   tolua_function(tolua_S,"getVerticalFormatting",tolua_CEGUI_CEGUI_TextComponent_getVerticalFormatting00);
+   tolua_function(tolua_S,"setVerticalFormatting",tolua_CEGUI_CEGUI_TextComponent_setVerticalFormatting00);
+   tolua_function(tolua_S,"getHorizontalFormatting",tolua_CEGUI_CEGUI_TextComponent_getHorizontalFormatting00);
+   tolua_function(tolua_S,"setHorizontalFormatting",tolua_CEGUI_CEGUI_TextComponent_setHorizontalFormatting00);
+   tolua_function(tolua_S,"isTextFetchedFromProperty",tolua_CEGUI_CEGUI_TextComponent_isTextFetchedFromProperty00);
+   tolua_function(tolua_S,"getTextPropertySource",tolua_CEGUI_CEGUI_TextComponent_getTextPropertySource00);
+   tolua_function(tolua_S,"setTextPropertySource",tolua_CEGUI_CEGUI_TextComponent_setTextPropertySource00);
+   tolua_function(tolua_S,"isFontFetchedFromProperty",tolua_CEGUI_CEGUI_TextComponent_isFontFetchedFromProperty00);
+   tolua_function(tolua_S,"getFontPropertySource",tolua_CEGUI_CEGUI_TextComponent_getFontPropertySource00);
+   tolua_function(tolua_S,"setFontPropertySource",tolua_CEGUI_CEGUI_TextComponent_setFontPropertySource00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_TextComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_TextComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_TextComponent_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"ImagerySection","CEGUI::ImagerySection","",tolua_collect_CEGUI__ImagerySection);
+  #else
+  tolua_cclass(tolua_S,"ImagerySection","CEGUI::ImagerySection","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"ImagerySection");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_ImagerySection_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_ImagerySection_render01);
+   tolua_function(tolua_S,"addImageryComponent",tolua_CEGUI_CEGUI_ImagerySection_addImageryComponent00);
+   tolua_function(tolua_S,"clearImageryComponents",tolua_CEGUI_CEGUI_ImagerySection_clearImageryComponents00);
+   tolua_function(tolua_S,"addTextComponent",tolua_CEGUI_CEGUI_ImagerySection_addTextComponent00);
+   tolua_function(tolua_S,"clearTextComponents",tolua_CEGUI_CEGUI_ImagerySection_clearTextComponents00);
+   tolua_function(tolua_S,"clearFrameComponents",tolua_CEGUI_CEGUI_ImagerySection_clearFrameComponents00);
+   tolua_function(tolua_S,"addFrameComponent",tolua_CEGUI_CEGUI_ImagerySection_addFrameComponent00);
+   tolua_function(tolua_S,"getMasterColours",tolua_CEGUI_CEGUI_ImagerySection_getMasterColours00);
+   tolua_function(tolua_S,"setMasterColours",tolua_CEGUI_CEGUI_ImagerySection_setMasterColours00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_ImagerySection_getName00);
+   tolua_function(tolua_S,"setMasterColoursPropertySource",tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertySource00);
+   tolua_function(tolua_S,"setMasterColoursPropertyIsColourRect",tolua_CEGUI_CEGUI_ImagerySection_setMasterColoursPropertyIsColourRect00);
+   tolua_function(tolua_S,"getBoundingRect",tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect00);
+   tolua_function(tolua_S,"getBoundingRect",tolua_CEGUI_CEGUI_ImagerySection_getBoundingRect01);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImagerySection_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImagerySection_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImagerySection_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_ImagerySection_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_ImagerySection_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_ImagerySection_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"SectionSpecification","CEGUI::SectionSpecification","",tolua_collect_CEGUI__SectionSpecification);
+  #else
+  tolua_cclass(tolua_S,"SectionSpecification","CEGUI::SectionSpecification","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"SectionSpecification");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_SectionSpecification_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_SectionSpecification_render01);
+   tolua_function(tolua_S,"getOwnerWidgetLookFeel",tolua_CEGUI_CEGUI_SectionSpecification_getOwnerWidgetLookFeel00);
+   tolua_function(tolua_S,"getSectionName",tolua_CEGUI_CEGUI_SectionSpecification_getSectionName00);
+   tolua_function(tolua_S,"getOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_getOverrideColours00);
+   tolua_function(tolua_S,"setOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColours00);
+   tolua_function(tolua_S,"isUsingOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_isUsingOverrideColours00);
+   tolua_function(tolua_S,"setUsingOverrideColours",tolua_CEGUI_CEGUI_SectionSpecification_setUsingOverrideColours00);
+   tolua_function(tolua_S,"setOverrideColoursPropertySource",tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertySource00);
+   tolua_function(tolua_S,"setOverrideColoursPropertyIsColourRect",tolua_CEGUI_CEGUI_SectionSpecification_setOverrideColoursPropertyIsColourRect00);
+   tolua_function(tolua_S,"setRenderControlPropertySource",tolua_CEGUI_CEGUI_SectionSpecification_setRenderControlPropertySource00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_SectionSpecification_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_SectionSpecification_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_SectionSpecification_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_SectionSpecification_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_SectionSpecification_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_SectionSpecification_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"LayerSpecification","CEGUI::LayerSpecification","",tolua_collect_CEGUI__LayerSpecification);
+  #else
+  tolua_cclass(tolua_S,"LayerSpecification","CEGUI::LayerSpecification","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"LayerSpecification");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_LayerSpecification_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_LayerSpecification_render01);
+   tolua_function(tolua_S,"addSectionSpecification",tolua_CEGUI_CEGUI_LayerSpecification_addSectionSpecification00);
+   tolua_function(tolua_S,"clearSectionSpecifications",tolua_CEGUI_CEGUI_LayerSpecification_clearSectionSpecifications00);
+   tolua_function(tolua_S,"getLayerPriority",tolua_CEGUI_CEGUI_LayerSpecification_getLayerPriority00);
+   tolua_function(tolua_S,".lt",tolua_CEGUI_CEGUI_LayerSpecification__lt00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_LayerSpecification_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_LayerSpecification_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_LayerSpecification_new00_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"StateImagery","CEGUI::StateImagery","",tolua_collect_CEGUI__StateImagery);
+  #else
+  tolua_cclass(tolua_S,"StateImagery","CEGUI::StateImagery","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"StateImagery");
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_StateImagery_render00);
+   tolua_function(tolua_S,"render",tolua_CEGUI_CEGUI_StateImagery_render01);
+   tolua_function(tolua_S,"addLayer",tolua_CEGUI_CEGUI_StateImagery_addLayer00);
+   tolua_function(tolua_S,"clearLayers",tolua_CEGUI_CEGUI_StateImagery_clearLayers00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_StateImagery_getName00);
+   tolua_function(tolua_S,"isClippedToDisplay",tolua_CEGUI_CEGUI_StateImagery_isClippedToDisplay00);
+   tolua_function(tolua_S,"setClippedToDisplay",tolua_CEGUI_CEGUI_StateImagery_setClippedToDisplay00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_StateImagery_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_StateImagery_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_StateImagery_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_StateImagery_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_StateImagery_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_StateImagery_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetComponent","CEGUI::WidgetComponent","",tolua_collect_CEGUI__WidgetComponent);
+  #else
+  tolua_cclass(tolua_S,"WidgetComponent","CEGUI::WidgetComponent","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetComponent");
+   tolua_function(tolua_S,"create",tolua_CEGUI_CEGUI_WidgetComponent_create00);
+   tolua_function(tolua_S,"getComponentArea",tolua_CEGUI_CEGUI_WidgetComponent_getComponentArea00);
+   tolua_function(tolua_S,"setComponentArea",tolua_CEGUI_CEGUI_WidgetComponent_setComponentArea00);
+   tolua_function(tolua_S,"getBaseWidgetType",tolua_CEGUI_CEGUI_WidgetComponent_getBaseWidgetType00);
+   tolua_function(tolua_S,"setBaseWidgetType",tolua_CEGUI_CEGUI_WidgetComponent_setBaseWidgetType00);
+   tolua_function(tolua_S,"getWidgetLookName",tolua_CEGUI_CEGUI_WidgetComponent_getWidgetLookName00);
+   tolua_function(tolua_S,"setWidgetLookName",tolua_CEGUI_CEGUI_WidgetComponent_setWidgetLookName00);
+   tolua_function(tolua_S,"getWidgetNameSuffix",tolua_CEGUI_CEGUI_WidgetComponent_getWidgetNameSuffix00);
+   tolua_function(tolua_S,"setWidgetNameSuffix",tolua_CEGUI_CEGUI_WidgetComponent_setWidgetNameSuffix00);
+   tolua_function(tolua_S,"getWindowRendererType",tolua_CEGUI_CEGUI_WidgetComponent_getWindowRendererType00);
+   tolua_function(tolua_S,"setWindowRendererType",tolua_CEGUI_CEGUI_WidgetComponent_setWindowRendererType00);
+   tolua_function(tolua_S,"getVerticalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_getVerticalWidgetAlignment00);
+   tolua_function(tolua_S,"setVerticalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_setVerticalWidgetAlignment00);
+   tolua_function(tolua_S,"getHorizontalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_getHorizontalWidgetAlignment00);
+   tolua_function(tolua_S,"setHorizontalWidgetAlignment",tolua_CEGUI_CEGUI_WidgetComponent_setHorizontalWidgetAlignment00);
+   tolua_function(tolua_S,"addPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetComponent_addPropertyInitialiser00);
+   tolua_function(tolua_S,"clearPropertyInitialisers",tolua_CEGUI_CEGUI_WidgetComponent_clearPropertyInitialisers00);
+   tolua_function(tolua_S,"layout",tolua_CEGUI_CEGUI_WidgetComponent_layout00);
+   tolua_function(tolua_S,"findPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetComponent_findPropertyInitialiser00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetComponent_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetComponent_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetComponent_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetComponent_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetComponent_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetComponent_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetLookFeel","CEGUI::WidgetLookFeel","",tolua_collect_CEGUI__WidgetLookFeel);
+  #else
+  tolua_cclass(tolua_S,"WidgetLookFeel","CEGUI::WidgetLookFeel","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetLookFeel");
+   tolua_function(tolua_S,"getStateImagery",tolua_CEGUI_CEGUI_WidgetLookFeel_getStateImagery00);
+   tolua_function(tolua_S,"getImagerySection",tolua_CEGUI_CEGUI_WidgetLookFeel_getImagerySection00);
+   tolua_function(tolua_S,"getName",tolua_CEGUI_CEGUI_WidgetLookFeel_getName00);
+   tolua_function(tolua_S,"addImagerySection",tolua_CEGUI_CEGUI_WidgetLookFeel_addImagerySection00);
+   tolua_function(tolua_S,"addWidgetComponent",tolua_CEGUI_CEGUI_WidgetLookFeel_addWidgetComponent00);
+   tolua_function(tolua_S,"addStateSpecification",tolua_CEGUI_CEGUI_WidgetLookFeel_addStateSpecification00);
+   tolua_function(tolua_S,"addPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyInitialiser00);
+   tolua_function(tolua_S,"clearImagerySections",tolua_CEGUI_CEGUI_WidgetLookFeel_clearImagerySections00);
+   tolua_function(tolua_S,"clearWidgetComponents",tolua_CEGUI_CEGUI_WidgetLookFeel_clearWidgetComponents00);
+   tolua_function(tolua_S,"clearStateSpecifications",tolua_CEGUI_CEGUI_WidgetLookFeel_clearStateSpecifications00);
+   tolua_function(tolua_S,"clearPropertyInitialisers",tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyInitialisers00);
+   tolua_function(tolua_S,"initialiseWidget",tolua_CEGUI_CEGUI_WidgetLookFeel_initialiseWidget00);
+   tolua_function(tolua_S,"isStateImageryPresent",tolua_CEGUI_CEGUI_WidgetLookFeel_isStateImageryPresent00);
+   tolua_function(tolua_S,"addNamedArea",tolua_CEGUI_CEGUI_WidgetLookFeel_addNamedArea00);
+   tolua_function(tolua_S,"clearNamedAreas",tolua_CEGUI_CEGUI_WidgetLookFeel_clearNamedAreas00);
+   tolua_function(tolua_S,"getNamedArea",tolua_CEGUI_CEGUI_WidgetLookFeel_getNamedArea00);
+   tolua_function(tolua_S,"isNamedAreaDefined",tolua_CEGUI_CEGUI_WidgetLookFeel_isNamedAreaDefined00);
+   tolua_function(tolua_S,"layoutChildWidgets",tolua_CEGUI_CEGUI_WidgetLookFeel_layoutChildWidgets00);
+   tolua_function(tolua_S,"addPropertyDefinition",tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyDefinition00);
+   tolua_function(tolua_S,"addPropertyLinkDefinition",tolua_CEGUI_CEGUI_WidgetLookFeel_addPropertyLinkDefinition00);
+   tolua_function(tolua_S,"clearPropertyDefinitions",tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyDefinitions00);
+   tolua_function(tolua_S,"clearPropertyLinkDefinitions",tolua_CEGUI_CEGUI_WidgetLookFeel_clearPropertyLinkDefinitions00);
+   tolua_function(tolua_S,"renameChildren",tolua_CEGUI_CEGUI_WidgetLookFeel_renameChildren00);
+   tolua_function(tolua_S,"findPropertyInitialiser",tolua_CEGUI_CEGUI_WidgetLookFeel_findPropertyInitialiser00);
+   tolua_function(tolua_S,"findWidgetComponent",tolua_CEGUI_CEGUI_WidgetLookFeel_findWidgetComponent00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetLookFeel_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetLookFeel_new00_local);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetLookFeel_new01);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetLookFeel_new01_local);
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"WidgetLookManager","CEGUI::WidgetLookManager","",tolua_collect_CEGUI__WidgetLookManager);
+  #else
+  tolua_cclass(tolua_S,"WidgetLookManager","CEGUI::WidgetLookManager","",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"WidgetLookManager");
+   tolua_function(tolua_S,"getSingleton",tolua_CEGUI_CEGUI_WidgetLookManager_getSingleton00);
+   tolua_function(tolua_S,"parseLookNFeelSpecification",tolua_CEGUI_CEGUI_WidgetLookManager_parseLookNFeelSpecification00);
+   tolua_function(tolua_S,"isWidgetLookAvailable",tolua_CEGUI_CEGUI_WidgetLookManager_isWidgetLookAvailable00);
+   tolua_function(tolua_S,"getWidgetLook",tolua_CEGUI_CEGUI_WidgetLookManager_getWidgetLook00);
+   tolua_function(tolua_S,"eraseWidgetLook",tolua_CEGUI_CEGUI_WidgetLookManager_eraseWidgetLook00);
+   tolua_function(tolua_S,"addWidgetLook",tolua_CEGUI_CEGUI_WidgetLookManager_addWidgetLook00);
+   tolua_function(tolua_S,"writeWidgetLookToStream",tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookToStream00);
+   tolua_function(tolua_S,"writeWidgetLookSeriesToStream",tolua_CEGUI_CEGUI_WidgetLookManager_writeWidgetLookSeriesToStream00);
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_WidgetLookManager_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_WidgetLookManager_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_WidgetLookManager_new00_local);
+   tolua_function(tolua_S,"setDefaultResourceGroup",tolua_CEGUI_CEGUI_WidgetLookManager_setDefaultResourceGroup00);
+   tolua_function(tolua_S,"getDefaultResourceGroup",tolua_CEGUI_CEGUI_WidgetLookManager_getDefaultResourceGroup00);
+  tolua_endmodule(tolua_S);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73,
+    46,116,111, 77,111,117,115,101, 67,117,114,115,111,114, 69,
+   118,101,110,116, 65,114,103,115, 40,101, 41, 10,114,101,116,
+   117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,
+   101, 44, 34, 99,111,110,115,116, 32, 67, 69, 71, 85, 73, 58,
+    58, 77,111,117,115,101, 67,117,114,115,111,114, 69,118,101,
+   110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    87,105,110,100,111,119, 69,118,101,110,116, 65,114,103,115,
+    40,101, 41, 10,114,101,116,117,114,110, 32,116,111,108,117,
+    97, 46, 99, 97,115,116, 40,101, 44, 34, 99,111,110,115,116,
+    32, 67, 69, 71, 85, 73, 58, 58, 87,105,110,100,111,119, 69,
+   118,101,110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,
+   102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 65, 99,116,105,118, 97,116,105,111,110, 69,118,101,
+   110,116, 65,114,103,115, 40,101, 41, 10,114,101,116,117,114,
+   110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,101, 44,
+    34, 99,111,110,115,116, 32, 67, 69, 71, 85, 73, 58, 58, 65,
+    99,116,105,118, 97,116,105,111,110, 69,118,101,110,116, 65,
+   114,103,115, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,
+   105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 72,101, 97,
+   100,101,114, 83,101,113,117,101,110, 99,101, 69,118,101,110,
+   116, 65,114,103,115, 40,101, 41, 10,114,101,116,117,114,110,
+    32,116,111,108,117, 97, 46, 99, 97,115,116, 40,101, 44, 34,
+    99,111,110,115,116, 32, 67, 69, 71, 85, 73, 58, 58, 72,101,
+    97,100,101,114, 83,101,113,117,101,110, 99,101, 69,118,101,
+   110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    77,111,117,115,101, 69,118,101,110,116, 65,114,103,115, 40,
+   101, 41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97,
+    46, 99, 97,115,116, 40,101, 44, 34, 99,111,110,115,116, 32,
+    67, 69, 71, 85, 73, 58, 58, 77,111,117,115,101, 69,118,101,
+   110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    75,101,121, 69,118,101,110,116, 65,114,103,115, 40,101, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,101, 44, 34, 99,111,110,115,116, 32, 67, 69,
+    71, 85, 73, 58, 58, 75,101,121, 69,118,101,110,116, 65,114,
+   103,115, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 68,114, 97,103,
+    68,114,111,112, 69,118,101,110,116, 65,114,103,115, 40,101,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,101, 44, 34, 99,111,110,115,116, 32, 67,
+    69, 71, 85, 73, 58, 58, 68,114, 97,103, 68,114,111,112, 69,
+   118,101,110,116, 65,114,103,115, 34, 41, 10,101,110,100, 10,
+    67, 69, 71, 85, 73, 46, 69,118,101,110,116, 65,114,103,115,
+    46,116,111, 77,111,117,115,101, 67,117,114,115,111,114, 69,
+   118,101,110,116, 65,114,103,115, 32, 61, 32, 67, 69, 71, 85,
+    73, 46,116,111, 77,111,117,115,101, 67,117,114,115,111,114,
+    69,118,101,110,116, 65,114,103,115, 10, 67, 69, 71, 85, 73,
+    46, 69,118,101,110,116, 65,114,103,115, 46,116,111, 87,105,
+   110,100,111,119, 69,118,101,110,116, 65,114,103,115, 32, 61,
+    32, 67, 69, 71, 85, 73, 46,116,111, 87,105,110,100,111,119,
+    69,118,101,110,116, 65,114,103,115, 10, 67, 69, 71, 85, 73,
+    46, 69,118,101,110,116, 65,114,103,115, 46,116,111, 65, 99,
+   116,105,118, 97,116,105,111,110, 69,118,101,110,116, 65,114,
+   103,115, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 65, 99,
+   116,105,118, 97,116,105,111,110, 69,118,101,110,116, 65,114,
+   103,115, 10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116, 65,
+   114,103,115, 46,116,111, 72,101, 97,100,101,114, 83,101,113,
+   117,101,110, 99,101, 69,118,101,110,116, 65,114,103,115, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 72,101, 97,100,101,
+   114, 83,101,113,117,101,110, 99,101, 69,118,101,110,116, 65,
+   114,103,115, 10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116,
+    65,114,103,115, 46,116,111, 77,111,117,115,101, 69,118,101,
+   110,116, 65,114,103,115, 32, 61, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 77,111,117,115,101, 69,118,101,110,116, 65,114,103,
+   115, 10, 67, 69, 71, 85, 73, 46, 69,118,101,110,116, 65,114,
+   103,115, 46,116,111, 75,101,121, 69,118,101,110,116, 65,114,
+   103,115, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 75,101,
+   121, 69,118,101,110,116, 65,114,103,115, 10, 67, 69, 71, 85,
+    73, 46, 69,118,101,110,116, 65,114,103,115, 46,116,111, 68,
+   114, 97,103, 68,114,111,112, 69,118,101,110,116, 65,114,103,
+   115, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 68,114, 97,
+   103, 68,114,111,112, 69,118,101,110,116, 65,114,103,115,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 12");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+  10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73,
+    46,116,111, 66,117,116,116,111,110, 66, 97,115,101, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    66,117,116,116,111,110, 66, 97,115,101, 34, 41, 10,101,110,
+   100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85,
+    73, 46,116,111, 67,104,101, 99,107, 98,111,120, 40,119, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 67,
+   104,101, 99,107, 98,111,120, 34, 41, 10,101,110,100, 10,102,
+   117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 67,111,109, 98,111, 98,111,120, 40,119, 41, 10,114,101,
+   116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116,
+    40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 67,111,109, 98,
+   111, 98,111,120, 34, 41, 10,101,110,100, 10,102,117,110, 99,
+   116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 67,111,
+   109, 98,111, 68,114,111,112, 76,105,115,116, 40,119, 41, 10,
+   114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,
+   115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 67,111,
+   109, 98,111, 68,114,111,112, 76,105,115,116, 34, 41, 10,101,
+   110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71,
+    85, 73, 46,116,111, 68,114, 97,103, 67,111,110,116, 97,105,
+   110,101,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 68,114, 97,103, 67,111,110,116, 97,105,
+   110,101,114, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,
+   105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 69,100,105,
+   116, 98,111,120, 40,119, 41, 10,114,101,116,117,114,110, 32,
+   116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67,
+    69, 71, 85, 73, 58, 58, 69,100,105,116, 98,111,120, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 70,114, 97,109,101, 87,105,110,
+   100,111,119, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 70,114, 97,109,101, 87,105,110,100,111,
+   119, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 71, 85, 73, 83,104,
+   101,101,116, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 71, 85, 73, 83,104,101,101,116, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 73,116,101,109, 69,110,116,114,
+   121, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,108,
+   117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85,
+    73, 58, 58, 73,116,101,109, 69,110,116,114,121, 34, 41, 10,
+   101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69,
+    71, 85, 73, 46,116,111, 73,116,101,109, 76,105,115,116, 66,
+    97,115,101, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 73,116,101,109, 76,105,115,116, 66, 97,
+   115,101, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 73,116,101,109,
+    76,105,115,116, 98,111,120, 40,119, 41, 10,114,101,116,117,
+   114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119,
+    44, 34, 67, 69, 71, 85, 73, 58, 58, 73,116,101,109, 76,105,
+   115,116, 98,111,120, 34, 41, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 76,
+   105,115,116, 98,111,120, 40,119, 41, 10,114,101,116,117,114,
+   110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44,
+    34, 67, 69, 71, 85, 73, 58, 58, 76,105,115,116, 98,111,120,
+    34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+    32, 67, 69, 71, 85, 73, 46,116,111, 76,105,115,116, 72,101,
+    97,100,101,114, 40,119, 41, 10,114,101,116,117,114,110, 32,
+   116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67,
+    69, 71, 85, 73, 58, 58, 76,105,115,116, 72,101, 97,100,101,
+   114, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 76,105,115,116, 72,
+   101, 97,100,101,114, 83,101,103,109,101,110,116, 40,119, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 76,
+   105,115,116, 72,101, 97,100,101,114, 83,101,103,109,101,110,
+   116, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 77,101,110,117, 98,
+    97,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,
+   108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71,
+    85, 73, 58, 58, 77,101,110,117, 98, 97,114, 34, 41, 10,101,
+   110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69, 71,
+    85, 73, 46,116,111, 77,101,110,117, 66, 97,115,101, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    77,101,110,117, 66, 97,115,101, 34, 41, 10,101,110,100, 10,
+   102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 77,101,110,117, 73,116,101,109, 40,119, 41, 10,114,
+   101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,
+   116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 77,101,110,
+   117, 73,116,101,109, 34, 41, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 77,
+   117,108,116,105, 67,111,108,117,109,110, 76,105,115,116, 40,
+   119, 41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97,
+    46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58,
+    58, 77,117,108,116,105, 67,111,108,117,109,110, 76,105,115,
+   116, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 77,117,108,116,105,
+    76,105,110,101, 69,100,105,116, 98,111,120, 40,119, 41, 10,
+   114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,
+   115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 77,117,
+   108,116,105, 76,105,110,101, 69,100,105,116, 98,111,120, 34,
+    41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+    67, 69, 71, 85, 73, 46,116,111, 80,111,112,117,112, 77,101,
+   110,117, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,
+   108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71,
+    85, 73, 58, 58, 80,111,112,117,112, 77,101,110,117, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 80,114,111,103,114,101,115,115,
+    66, 97,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,
+   111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69,
+    71, 85, 73, 58, 58, 80,114,111,103,114,101,115,115, 66, 97,
+   114, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+   110, 32, 67, 69, 71, 85, 73, 46,116,111, 80,117,115,104, 66,
+   117,116,116,111,110, 40,119, 41, 10,114,101,116,117,114,110,
+    32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34,
+    67, 69, 71, 85, 73, 58, 58, 80,117,115,104, 66,117,116,116,
+   111,110, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 82, 97,100,105,
+   111, 66,117,116,116,111,110, 40,119, 41, 10,114,101,116,117,
+   114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,119,
+    44, 34, 67, 69, 71, 85, 73, 58, 58, 82, 97,100,105,111, 66,
+   117,116,116,111,110, 34, 41, 10,101,110,100, 10,102,117,110,
+    99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 83,
+    99,114,111,108,108, 97, 98,108,101, 80, 97,110,101, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    83, 99,114,111,108,108, 97, 98,108,101, 80, 97,110,101, 34,
+    41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+    67, 69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108, 98,
+    97,114, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,
+   108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71,
+    85, 73, 58, 58, 83, 99,114,111,108,108, 98, 97,114, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108,101,100,
+    67,111,110,116, 97,105,110,101,114, 40,119, 41, 10,114,101,
+   116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116,
+    40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 83, 99,114,111,
+   108,108,101,100, 67,111,110,116, 97,105,110,101,114, 34, 41,
+    10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108,101,100,
+    73,116,101,109, 76,105,115,116, 66, 97,115,101, 40,119, 41,
+    10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46, 99,
+    97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 83,
+    99,114,111,108,108,101,100, 73,116,101,109, 76,105,115,116,
+    66, 97,115,101, 34, 41, 10,101,110,100, 10,102,117,110, 99,
+   116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 83,108,
+   105,100,101,114, 40,119, 41, 10,114,101,116,117,114,110, 32,
+   116,111,108,117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67,
+    69, 71, 85, 73, 58, 58, 83,108,105,100,101,114, 34, 41, 10,
+   101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, 69,
+    71, 85, 73, 46,116,111, 83,112,105,110,110,101,114, 40,119,
+    41, 10,114,101,116,117,114,110, 32,116,111,108,117, 97, 46,
+    99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58,
+    83,112,105,110,110,101,114, 34, 41, 10,101,110,100, 10,102,
+   117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 84, 97, 98, 66,117,116,116,111,110, 40,119, 41, 10,114,
+   101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,
+   116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84, 97, 98,
+    66,117,116,116,111,110, 34, 41, 10,101,110,100, 10,102,117,
+   110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,111,
+    84, 97, 98, 67,111,110,116,114,111,108, 40,119, 41, 10,114,
+   101,116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,
+   116, 40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84, 97, 98,
+    67,111,110,116,114,111,108, 34, 41, 10,101,110,100, 10,102,
+   117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 84, 97, 98, 80, 97,110,101, 40,119, 41, 10,114,101,116,
+   117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116, 40,
+   119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84, 97, 98, 80, 97,
+   110,101, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+   111,110, 32, 67, 69, 71, 85, 73, 46,116,111, 84,104,117,109,
+    98, 40,119, 41, 10,114,101,116,117,114,110, 32,116,111,108,
+   117, 97, 46, 99, 97,115,116, 40,119, 44, 34, 67, 69, 71, 85,
+    73, 58, 58, 84,104,117,109, 98, 34, 41, 10,101,110,100, 10,
+   102,117,110, 99,116,105,111,110, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 84,111,111,108,116,105,112, 40,119, 41, 10,114,101,
+   116,117,114,110, 32,116,111,108,117, 97, 46, 99, 97,115,116,
+    40,119, 44, 34, 67, 69, 71, 85, 73, 58, 58, 84,111,111,108,
+   116,105,112, 34, 41, 10,101,110,100, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 66,117,116,116,111,
+   110, 66, 97,115,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 66,117,116,116,111,110, 66, 97,115,101, 10, 67, 69, 71,
+    85, 73, 46, 87,105,110,100,111,119, 46,116,111, 67,104,101,
+    99,107, 98,111,120, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 67,104,101, 99,107, 98,111,120, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 67,111,109, 98,111,
+    98,111,120, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 67,
+   111,109, 98,111, 98,111,120, 10, 67, 69, 71, 85, 73, 46, 87,
+   105,110,100,111,119, 46,116,111, 67,111,109, 98,111, 68,114,
+   111,112, 76,105,115,116, 32, 61, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 67,111,109, 98,111, 68,114,111,112, 76,105,115,116,
+    10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,
+   111, 68,114, 97,103, 67,111,110,116, 97,105,110,101,114, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 68,114, 97,103, 67,
+   111,110,116, 97,105,110,101,114, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 69,100,105,116, 98,111,
+   120, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 69,100,105,
+   116, 98,111,120, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,
+   111,119, 46,116,111, 70,114, 97,109,101, 87,105,110,100,111,
+   119, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 70,114, 97,
+   109,101, 87,105,110,100,111,119, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 71, 85, 73, 83,104,101,
+   101,116, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 71, 85,
+    73, 83,104,101,101,116, 10, 67, 69, 71, 85, 73, 46, 87,105,
+   110,100,111,119, 46,116,111, 73,116,101,109, 69,110,116,114,
+   121, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 73,116,101,
+   109, 69,110,116,114,121, 10, 67, 69, 71, 85, 73, 46, 87,105,
+   110,100,111,119, 46,116,111, 73,116,101,109, 76,105,115,116,
+    66, 97,115,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    73,116,101,109, 76,105,115,116, 66, 97,115,101, 10, 67, 69,
+    71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 73,116,
+   101,109, 76,105,115,116, 98,111,120, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 73,116,101,109, 76,105,115,116, 66, 97,
+   115,101, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119,
+    46,116,111, 76,105,115,116, 98,111,120, 32, 61, 32, 67, 69,
+    71, 85, 73, 46,116,111, 76,105,115,116, 98,111,120, 10, 67,
+    69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 76,
+   105,115,116, 72,101, 97,100,101,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 76,105,115,116, 72,101, 97,100,101,114,
+    10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,
+   111, 76,105,115,116, 72,101, 97,100,101,114, 83,101,103,109,
+   101,110,116, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 76,
+   105,115,116, 72,101, 97,100,101,114, 83,101,103,109,101,110,
+   116, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,
+   116,111, 77,101,110,117, 98, 97,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 77,101,110,117, 98, 97,114, 10, 67, 69,
+    71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 77,101,
+   110,117, 66, 97,115,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,
+   116,111, 77,101,110,117, 66, 97,115,101, 10, 67, 69, 71, 85,
+    73, 46, 87,105,110,100,111,119, 46,116,111, 77,101,110,117,
+    73,116,101,109, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    77,101,110,117, 73,116,101,109, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 77,117,108,116,105, 67,
+   111,108,117,109,110, 76,105,115,116, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 77,117,108,116,105, 67,111,108,117,109,
+   110, 76,105,115,116, 10, 67, 69, 71, 85, 73, 46, 87,105,110,
+   100,111,119, 46,116,111, 77,117,108,116,105, 76,105,110,101,
+    69,100,105,116, 98,111,120, 32, 61, 32, 67, 69, 71, 85, 73,
+    46,116,111, 77,117,108,116,105, 76,105,110,101, 69,100,105,
+   116, 98,111,120, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,
+   111,119, 46,116,111, 80,111,112,117,112, 77,101,110,117, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 80,111,112,117,112,
+    77,101,110,117, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,
+   111,119, 46,116,111, 80,114,111,103,114,101,115,115, 66, 97,
+   114, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 80,114,111,
+   103,114,101,115,115, 66, 97,114, 10, 67, 69, 71, 85, 73, 46,
+    87,105,110,100,111,119, 46,116,111, 80,117,115,104, 66,117,
+   116,116,111,110, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    80,117,115,104, 66,117,116,116,111,110, 10, 67, 69, 71, 85,
+    73, 46, 87,105,110,100,111,119, 46,116,111, 82, 97,100,105,
+   111, 66,117,116,116,111,110, 32, 61, 32, 67, 69, 71, 85, 73,
+    46,116,111, 82, 97,100,105,111, 66,117,116,116,111,110, 10,
+    67, 69, 71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111,
+    83, 99,114,111,108,108, 97, 98,108,101, 80, 97,110,101, 32,
+    61, 32, 67, 69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,
+   108, 97, 98,108,101, 80, 97,110,101, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 83, 99,114,111,108,
+   108, 98, 97,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    83, 99,114,111,108,108, 98, 97,114, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 83, 99,114,111,108,
+   108,101,100, 67,111,110,116, 97,105,110,101,114, 32, 61, 32,
+    67, 69, 71, 85, 73, 46,116,111, 83, 99,114,111,108,108,101,
+   100, 67,111,110,116, 97,105,110,101,114, 10, 67, 69, 71, 85,
+    73, 46, 87,105,110,100,111,119, 46,116,111, 83, 99,114,111,
+   108,108,101,100, 73,116,101,109, 76,105,115,116, 66, 97,115,
+   101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 83, 99,114,
+   111,108,108,101,100, 73,116,101,109, 76,105,115,116, 66, 97,
+   115,101, 10, 67, 69, 71, 85, 73, 46, 87,105,110,100,111,119,
+    46,116,111, 83,108,105,100,101,114, 32, 61, 32, 67, 69, 71,
+    85, 73, 46,116,111, 83,108,105,100,101,114, 10, 67, 69, 71,
+    85, 73, 46, 87,105,110,100,111,119, 46,116,111, 83,112,105,
+   110,110,101,114, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111,
+    83,112,105,110,110,101,114, 10, 67, 69, 71, 85, 73, 46, 87,
+   105,110,100,111,119, 46,116,111, 84, 97, 98, 66,117,116,116,
+   111,110, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 84, 97,
+    98, 66,117,116,116,111,110, 10, 67, 69, 71, 85, 73, 46, 87,
+   105,110,100,111,119, 46,116,111, 84, 97, 98, 67,111,110,116,
+   114,111,108, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 84,
+    97, 98, 67,111,110,116,114,111,108, 10, 67, 69, 71, 85, 73,
+    46, 87,105,110,100,111,119, 46,116,111, 84, 97, 98, 80, 97,
+   110,101, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,111, 84, 97,
+    98, 80, 97,110,101, 10, 67, 69, 71, 85, 73, 46, 87,105,110,
+   100,111,119, 46,116,111, 84,104,117,109, 98, 32, 61, 32, 67,
+    69, 71, 85, 73, 46,116,111, 84,104,117,109, 98, 10, 67, 69,
+    71, 85, 73, 46, 87,105,110,100,111,119, 46,116,111, 84,111,
+   111,108,116,105,112, 32, 61, 32, 67, 69, 71, 85, 73, 46,116,
+   111, 84,111,111,108,116,105,112,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 13");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+  tolua_function(tolua_S,"createListboxTextItem",tolua_CEGUI_CEGUI_createListboxTextItem00);
+  tolua_cclass(tolua_S,"OutStream","CEGUI::OutStream","",NULL);
+  tolua_beginmodule(tolua_S,"OutStream");
+  tolua_endmodule(tolua_S);
+  #ifdef __cplusplus
+  tolua_cclass(tolua_S,"FileStream","CEGUI::FileStream","CEGUI::OutStream",tolua_collect_CEGUI__FileStream);
+  #else
+  tolua_cclass(tolua_S,"FileStream","CEGUI::FileStream","CEGUI::OutStream",NULL);
+  #endif
+  tolua_beginmodule(tolua_S,"FileStream");
+   tolua_function(tolua_S,"new",tolua_CEGUI_CEGUI_FileStream_new00);
+   tolua_function(tolua_S,"new_local",tolua_CEGUI_CEGUI_FileStream_new00_local);
+   tolua_function(tolua_S,".call",tolua_CEGUI_CEGUI_FileStream_new00_local);
+   tolua_function(tolua_S,"is_open",tolua_CEGUI_CEGUI_FileStream_is_open00);
+   tolua_function(tolua_S,"open",tolua_CEGUI_CEGUI_FileStream_open00);
+   tolua_function(tolua_S,"close",tolua_CEGUI_CEGUI_FileStream_close00);
+  tolua_endmodule(tolua_S);
+ tolua_endmodule(tolua_S);
+ tolua_endmodule(tolua_S);
+ return 1;
+}
+
+
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
+ int luaopen_CEGUI (lua_State* tolua_S) {
+ return tolua_CEGUI_open(tolua_S);
+};
+#endif
+
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/required.cpp
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/required.cpp	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/required.cpp	(revision 2122)
@@ -0,0 +1,88 @@
+/***********************************************************************
+	filename: required.cpp
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+	
+	purpose:  Implementation of helper functions
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#include "CEGUI.h"
+#include "required.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+
+/*************************************************************************
+	Functions for getting Thumb range pairs as two return values
+*************************************************************************/
+
+// returns horizontal range as two values for lua
+void ceguiLua_Thumb_getHorzRange(Thumb* wnd, float* min, float* max)
+{
+	std::pair<float,float> range_pair = wnd->getHorzRange();
+	*min = range_pair.first;
+	*max = range_pair.second;
+}
+
+
+// returns vertical range as two values for lua
+void ceguiLua_Thumb_getVertRange(Thumb* wnd, float* min, float* max)
+{
+	std::pair<float,float> range_pair = wnd->getVertRange();
+	*min = range_pair.first;
+	*max = range_pair.second;
+}
+
+
+/*************************************************************************
+	Functions for creating list box items
+*************************************************************************/
+
+// allocates and returns a new ListboxTextItem
+ListboxTextItem* ceguiLua_createListboxTextItem(const String& text, uint item_id, void* item_data, bool disabled, bool auto_delete)
+{
+	return new ListboxTextItem(text,item_id,item_data,disabled,auto_delete);
+}
+
+
+/************************************************************************
+    OutStream
+*************************************************************************/
+void ceguiLua_FileStream_open(FileStream* os, const char* filename)
+{
+    os->open(filename, std::ios::binary);
+}
+
+
+/************************************************************************
+    CEGUI::System::getSystemKeys alternative
+*************************************************************************/
+bool ceguiLua_System_isSystemKeyDown(const System* sys, SystemKey k)
+{
+    return (k & sys->getSystemKeys()) != 0;
+}
+
+
+} // namespace CEGUI
Index: /code/branches/physics/src/ceguilua-0.6.1/ceguilua/required.h
===================================================================
--- /code/branches/physics/src/ceguilua-0.6.1/ceguilua/required.h	(revision 2122)
+++ /code/branches/physics/src/ceguilua-0.6.1/ceguilua/required.h	(revision 2122)
@@ -0,0 +1,113 @@
+/***********************************************************************
+	filename: required.h
+	created:  16/3/2005
+	author:   Tomas Lindquist Olsen
+
+	purpose:  Header that includes the necessary stuff needed for the Lua bindings
+*************************************************************************/
+/***************************************************************************
+ *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be
+ *   included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+#include "CEGUI.h"
+#include "CEGUILua.h"
+#include "CEGUILuaFunctor.h"
+#include <fstream>
+
+#define __operator_increment    operator++
+#define __operator_decrement    operator--
+#define __operator_dereference  operator*
+
+#define LuaFunctorSubscribeEvent CEGUI::LuaFunctor::SubscribeEvent
+
+//This is used to keep compilers happy
+#define CEGUIDeadException(e) &
+
+#if defined(_MSC_VER) && !defined(snprintf)
+#   define snprintf   _snprintf
+#endif
+
+typedef CEGUI::String string;
+
+namespace CEGUI
+{
+
+typedef Event::Connection EventConnection;
+
+/*************************************************************************
+	Functions for getting Thumb range pairs as two return values
+*************************************************************************/
+void ceguiLua_Thumb_getHorzRange(Thumb* wnd, float* min, float* max);
+void ceguiLua_Thumb_getVertRange(Thumb* wnd, float* min, float* max);
+
+
+/*************************************************************************
+	Functions for creating list box items
+*************************************************************************/
+ListboxTextItem* ceguiLua_createListboxTextItem(const String& text, uint item_id, void* item_data, bool disabled, bool auto_delete);
+
+
+/************************************************************************
+    Stuff needed to make the iterators work
+*************************************************************************/
+typedef PropertySet::Iterator PropertyIterator;
+typedef EventSet::Iterator EventIterator;
+typedef WindowManager::WindowIterator WindowIterator;
+typedef WindowFactoryManager::WindowFactoryIterator WindowFactoryIterator;
+typedef WindowFactoryManager::FalagardMappingIterator FalagardMappingIterator;
+typedef WindowFactoryManager::FalagardWindowMapping FalagardWindowMapping;
+typedef ImagesetManager::ImagesetIterator ImagesetIterator;
+typedef Imageset::ImageIterator ImageIterator;
+typedef SchemeManager::SchemeIterator SchemeIterator;
+typedef FontManager::FontIterator FontIterator;
+
+template <typename T>
+inline PropertyIterator ceguiLua_getPropertyIterator(const T* self)
+{
+    return static_cast<const PropertySet*>(self)->getIterator();
+}
+
+template <typename T>
+inline EventIterator ceguiLua_getEventIterator(const T* self)
+{
+    return static_cast<const EventSet*>(self)->getIterator();
+}
+
+
+/************************************************************************
+    OutStream
+*************************************************************************/
+typedef std::ofstream FileStream;
+void ceguiLua_FileStream_open(FileStream*, const char* filename);
+
+
+/************************************************************************
+    CEGUI::System::getSystemKeys alternative
+*************************************************************************/
+bool ceguiLua_System_isSystemKeyDown(const System* sys, SystemKey k);
+
+}
+
+// the binding file generates alot of
+// warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
+#if defined(_MSC_VER)
+#   pragma warning(disable : 4800)
+#endif
Index: /code/branches/physics/src/core/ArgumentCompleter.h
===================================================================
--- /code/branches/physics/src/core/ArgumentCompleter.h	(revision 2122)
+++ /code/branches/physics/src/core/ArgumentCompleter.h	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompleter_H__
+#define _ArgumentCompleter_H__
+
+#include "CorePrereqs.h"
+#include "ArgumentCompletionListElement.h"
+
+namespace orxonox
+{
+    class _CoreExport ArgumentCompleter
+    {
+        public:
+            ArgumentCompleter(ArgumentCompletionList (*function) (void)) : paramCount_(0), function_0_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1)) : paramCount_(1), function_1_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2)) : paramCount_(2), function_2_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3)) : paramCount_(3), function_3_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4)) : paramCount_(4), function_4_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)) : paramCount_(5), function_5_(function) {}
+
+            ArgumentCompletionList operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "")
+            {
+                switch (this->paramCount_)
+                {
+                    case 0:
+                        return (*this->function_0_)();
+                    case 1:
+                        return (*this->function_1_)(param1);
+                    case 2:
+                        return (*this->function_2_)(param1, param2);
+                    case 3:
+                        return (*this->function_3_)(param1, param2, param3);
+                    case 4:
+                        return (*this->function_4_)(param1, param2, param3, param4);
+                    case 5:
+                        return (*this->function_5_)(param1, param2, param3, param4, param5);
+                    default:
+                        return ArgumentCompletionList();
+                }
+            }
+
+        private:
+            unsigned char paramCount_;
+            ArgumentCompletionList (*function_0_) (void);
+            ArgumentCompletionList (*function_1_) (const std::string& param1);
+            ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2);
+            ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3);
+            ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4);
+            ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5);
+    };
+}
+
+#endif /* _ArgumentCompleter_H__ */
Index: /code/branches/physics/src/core/ArgumentCompletionFunctions.cc
===================================================================
--- /code/branches/physics/src/core/ArgumentCompletionFunctions.cc	(revision 2122)
+++ /code/branches/physics/src/core/ArgumentCompletionFunctions.cc	(revision 2122)
@@ -0,0 +1,144 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <iostream>
+#include <map>
+
+#include <boost/filesystem.hpp>
+
+#include "ArgumentCompletionFunctions.h"
+#include "CoreIncludes.h"
+#include "Identifier.h"
+#include "ConfigValueContainer.h"
+#include "TclThreadManager.h"
+#include "util/Convert.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    namespace autocompletion
+    {
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(fallback)()
+        {
+            return ArgumentCompletionList();
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment)
+        {
+            ArgumentCompletionList dirlist;
+            ArgumentCompletionList filelist;
+
+            try
+            {
+                boost::filesystem::path input(fragment);
+                boost::filesystem::path startdirectory(input.branch_path());
+
+                if (!boost::filesystem::exists(startdirectory))
+                {
+                    startdirectory = ".";
+                }
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+                else
+                {
+                    std::string dir = startdirectory.string();
+                    if (dir.size() > 0 && dir[dir.size() - 1] == ':')
+                        startdirectory = dir + "/";
+                }
+#endif
+
+                boost::filesystem::directory_iterator file(startdirectory);
+                boost::filesystem::directory_iterator end;
+
+                while (file != end)
+                {
+                    if (boost::filesystem::is_directory(*file))
+                        dirlist.push_back(ArgumentCompletionListElement((*file).string() + "/", getLowercase((*file).string()) + "/", (*file).leaf() + "/"));
+                    else
+                        filelist.push_back(ArgumentCompletionListElement((*file).string(), getLowercase((*file).string()), (*file).leaf()));
+                    ++file;
+                }
+            }
+            catch (...) {}
+
+            filelist.insert(filelist.begin(), dirlist.begin(), dirlist.end());
+            return filelist;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalueclasses)()
+        {
+            ArgumentCompletionList classlist;
+
+            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
+                if ((*it).second->hasConfigValues())
+                    classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+
+            return classlist;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname)
+        {
+            ArgumentCompletionList configvalues;
+            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getIdentifierMap().find(classname);
+
+            if (identifier != Identifier::getIdentifierMapEnd() && (*identifier).second->hasConfigValues())
+            {
+                for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it)
+                    configvalues.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+            }
+
+            return configvalues;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname)
+        {
+            ArgumentCompletionList oldvalue;
+            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
+            if (identifier != Identifier::getLowercaseIdentifierMapEnd())
+            {
+                std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
+                if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+                {
+                    std::string valuestring = (*variable).second->toString();
+                    oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
+                }
+            }
+            return oldvalue;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(tclthreads)()
+        {
+            std::list<unsigned int> threadnumbers = TclThreadManager::getInstance().getThreadList();
+            ArgumentCompletionList threads;
+
+            for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
+                threads.push_back(ArgumentCompletionListElement(getConvertedValue<unsigned int, std::string>(*it)));
+
+            return threads;
+        }
+    }
+}
Index: /code/branches/physics/src/core/ArgumentCompletionFunctions.h
===================================================================
--- /code/branches/physics/src/core/ArgumentCompletionFunctions.h	(revision 2122)
+++ /code/branches/physics/src/core/ArgumentCompletionFunctions.h	(revision 2122)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompletionFunctions_H__
+#define _ArgumentCompletionFunctions_H__
+
+#include "CorePrereqs.h"
+#include "ArgumentCompleter.h"
+
+
+#define ARGUMENT_COMPLETION_FUNCTION_DECLARATION(functionname) \
+    _CoreExport ArgumentCompleter* functionname(); \
+    _CoreExport ArgumentCompletionList acf_##functionname
+
+#define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(functionname) \
+    ArgumentCompleter* functionname() \
+    { \
+        static ArgumentCompleter completer = ArgumentCompleter(&acf_##functionname); \
+        return &completer; \
+    } \
+    \
+    ArgumentCompletionList acf_##functionname
+
+
+namespace orxonox
+{
+    namespace autocompletion
+    {
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalueclasses)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalues)(const std::string& fragment, const std::string& classname);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(tclthreads)();
+    }
+}
+
+#endif /* _ArgumentCompletionFunctions_H__ */
Index: /code/branches/physics/src/core/ArgumentCompletionListElement.h
===================================================================
--- /code/branches/physics/src/core/ArgumentCompletionListElement.h	(revision 2122)
+++ /code/branches/physics/src/core/ArgumentCompletionListElement.h	(revision 2122)
@@ -0,0 +1,74 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompletionListElement_H__
+#define _ArgumentCompletionListElement_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+
+namespace orxonox
+{
+    const int ACL_MODE_NORMAL    = 1;
+    const int ACL_MODE_LOWERCASE = 2;
+    const int ACL_MODE_DISPLAY   = 4;
+
+    typedef std::list<ArgumentCompletionListElement> ArgumentCompletionList;
+
+    class _CoreExport ArgumentCompletionListElement
+    {
+        public:
+            ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normalCase_(normalcase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE), normalCase_(normalcase), lowerCase_(lowercase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE | ACL_MODE_DISPLAY), normalCase_(normalcase), lowerCase_(lowercase), display_(display) {}
+
+            const std::string& getString() const
+                { return this->normalCase_; }
+            const std::string& getComparable() const
+                { if (this->mode_ & ACL_MODE_LOWERCASE) { return this->lowerCase_; } else { return this->normalCase_; } }
+            const std::string& getDisplay() const
+                { if (this->mode_ & ACL_MODE_DISPLAY) { return this->display_; } else { return this->normalCase_; } }
+
+            bool lowercaseComparison() const
+                { return (this->mode_ & ACL_MODE_LOWERCASE); }
+
+            bool operator<(const ArgumentCompletionListElement& other) const
+                { return (this->getComparable() < other.getComparable()); }
+
+        private:
+            unsigned char mode_;
+            std::string normalCase_;
+            std::string lowerCase_;
+            std::string display_;
+    };
+}
+
+#endif /* _ArgumentCompletionListElement_H__ */
Index: /code/branches/physics/src/core/BaseObject.cc
===================================================================
--- /code/branches/physics/src/core/BaseObject.cc	(revision 2122)
+++ /code/branches/physics/src/core/BaseObject.cc	(revision 2122)
@@ -0,0 +1,280 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the BaseObject class.
+*/
+
+#include "BaseObject.h"
+#include "tinyxml/tinyxml.h"
+#include "CoreIncludes.h"
+#include "EventIncludes.h"
+#include "XMLPort.h"
+#include "XMLFile.h"
+#include "XMLNameListener.h"
+#include "Template.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    CreateFactory(BaseObject);
+
+    /**
+        @brief Constructor: Registers the object in the BaseObject-list.
+    */
+    BaseObject::BaseObject(BaseObject* creator) : bInitialized_(false)
+    {
+        RegisterRootObject(BaseObject);
+
+        this->bInitialized_ = true;
+
+        this->bActive_ = true;
+        this->bVisible_ = true;
+        this->oldGametype_ = 0;
+
+        this->setCreator(creator);
+        if (this->creator_)
+        {
+            this->setFile(this->creator_->getFile());
+            this->setNamespace(this->creator_->getNamespace());
+            this->setScene(this->creator_->getScene());
+            this->setGametype(this->creator_->getGametype());
+        }
+        else
+        {
+            this->file_ = 0;
+            this->namespace_ = 0;
+            this->scene_ = 0;
+            this->gametype_ = 0;
+        }
+    }
+
+    /**
+        @brief Destructor
+    */
+    BaseObject::~BaseObject()
+    {
+        for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
+            (*it)->unregisterEventListener(this);
+
+        for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
+            it->first->removeEvent(this);
+    }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        XMLPortParam(BaseObject, "name", setXMLName, getName, xmlelement, mode);
+        XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);
+        XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);
+
+        XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
+
+        Element* events = xmlelement.FirstChildElement("events", false);
+
+        if (events)
+        {
+            std::list<std::string> eventnames;
+
+            if (mode == XMLPort::LoadObject)
+            {
+                for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++)
+                    eventnames.push_back(child->Value());
+            }
+            else if (mode == XMLPort::SaveObject)
+            {
+                for (std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->getIdentifier()->getXMLPortEventMapBegin(); it != this->getIdentifier()->getXMLPortEventMapEnd(); ++it)
+                    eventnames.push_back(it->first);
+            }
+
+            for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
+            {
+                std::string sectionname = (*it);
+                ExecutorMember<BaseObject>* loadexecutor = createExecutor(createFunctor(&BaseObject::addEvent), std::string( "BaseObject" ) + "::" + "addEvent");
+                ExecutorMember<BaseObject>* saveexecutor = createExecutor(createFunctor(&BaseObject::getEvent), std::string( "BaseObject" ) + "::" + "getEvent");
+                loadexecutor->setDefaultValue(1, sectionname);
+
+                XMLPortClassObjectContainer<BaseObject, BaseObject>* container = 0;
+                container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(this->getIdentifier()->getXMLPortEventContainer(sectionname));
+                if (!container)
+                {
+                    container = new XMLPortClassObjectContainer<BaseObject, BaseObject>(sectionname, this->getIdentifier(), loadexecutor, saveexecutor, false, true);
+                    this->getIdentifier()->addXMLPortEventContainer(sectionname, container);
+                }
+                container->port(this, *events, mode);
+            }
+        }
+    }
+
+    /**
+        @brief Loads the name of the object through XML and calls all XMLNameListener.
+        @param name The name of the object
+    */
+    void BaseObject::setXMLName(const std::string& name)
+    {
+        this->setName(name);
+
+        for (ObjectList<XMLNameListener>::iterator it = ObjectList<XMLNameListener>::begin(); it != ObjectList<XMLNameListener>::end(); ++it)
+            it->loadedNewXMLName(this);
+    }
+
+    /**
+        @brief Returns the levelfile that loaded this object.
+        @return The levelfile
+    */
+    const std::string& BaseObject::getFilename() const
+    {
+        if (this->file_)
+            return this->file_->getFilename();
+        else
+            return BLANKSTRING;
+    }
+
+    /**
+        @brief Adds a Template to the object.
+        @param name The name of the Template
+    */
+    void BaseObject::addTemplate(const std::string& name)
+    {
+        Template* temp = Template::getTemplate(name);
+        if (temp)
+            this->addTemplate(temp);
+        else
+            COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl;
+    }
+
+    /**
+        @brief Adds a Template to the object.
+        @param temp The Template
+    */
+    void BaseObject::addTemplate(Template* temp)
+    {
+        this->templates_.insert(temp);
+        temp->applyOn(this);
+    }
+
+    /**
+        @brief Returns the Template with the given index.
+        @param index The index
+    */
+    Template* BaseObject::getTemplate(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            i++;
+        }
+        return 0;
+    }
+
+    void BaseObject::addEvent(BaseObject* event, const std::string& sectionname)
+    {
+        event->registerEventListener(this, sectionname);
+        this->events_.push_back(event);
+    }
+
+    void BaseObject::removeEvent(BaseObject* event)
+    {
+        this->events_.remove(event);
+    }
+
+    BaseObject* BaseObject::getEvent(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
+
+    void BaseObject::addEventContainer(const std::string& sectionname, EventContainer* container)
+    {
+        std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);
+        if (it != this->eventContainers_.end())
+        {
+            COUT(2) << "Warning: Overwriting EventContainer in class " << this->getIdentifier()->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->eventContainers_[sectionname] = container;
+    }
+
+    EventContainer* BaseObject::getEventContainer(const std::string& sectionname) const
+    {
+        std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);
+        if (it != this->eventContainers_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    void BaseObject::fireEvent()
+    {
+        this->fireEvent(true);
+        this->fireEvent(false);
+    }
+
+    void BaseObject::fireEvent(bool activate)
+    {
+        this->fireEvent(activate, this);
+    }
+
+    void BaseObject::fireEvent(bool activate, BaseObject* originator)
+    {
+        Event event(activate, originator);
+
+        for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
+        {
+            event.sectionname_ = it->second;
+            it->first->processEvent(event);
+        }
+    }
+
+    void BaseObject::fireEvent(Event& event)
+    {
+        for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
+            it->first->processEvent(event);
+    }
+
+    void BaseObject::processEvent(Event& event)
+    {
+        SetEvent(BaseObject, "activity", setActive, event);
+        SetEvent(BaseObject, "visibility", setVisible, event);
+    }
+}
Index: /code/branches/physics/src/core/BaseObject.h
===================================================================
--- /code/branches/physics/src/core/BaseObject.h	(revision 2122)
+++ /code/branches/physics/src/core/BaseObject.h	(revision 2122)
@@ -0,0 +1,167 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file BaseObject.h
+    @brief Definition of the BaseObject class.
+
+    The BaseObject is the parent of all classes representing an instance in the game.
+*/
+
+#ifndef _BaseObject_H__
+#define _BaseObject_H__
+
+#include <map>
+
+#include "CorePrereqs.h"
+
+#include "Super.h"
+#include "OrxonoxClass.h"
+#include "XMLIncludes.h"
+#include "Event.h"
+
+namespace orxonox
+{
+    class Scene;
+    class Gametype;
+
+    //! The BaseObject is the parent of all classes representing an instance in the game.
+    class _CoreExport BaseObject : virtual public OrxonoxClass
+    {
+        public:
+            BaseObject(BaseObject* creator);
+            virtual ~BaseObject();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */
+            inline bool isInitialized() const { return this->bInitialized_; }
+
+            /** @brief Sets the name of the object. @param name The name */
+            inline void setName(const std::string& name) { this->oldName_ = this->name_; this->name_ = name; this->changedName(); }
+            /** @brief Returns the name of the object. */
+            inline const std::string& getName() const { return this->name_; }
+            /** @brief Returns the old name of the object. */
+            inline const std::string& getOldName() const { return this->oldName_; }
+            /** @brief This function gets called if the name of the object changes. */
+            virtual void changedName() {}
+
+            /** @brief Sets the state of the objects activity. @param bActive True = active */
+            inline void setActive(bool bActive) { this->bActive_ = bActive; this->changedActivity(); }
+            /** @brief Returns the state of the objects activity. @return The state of the activity */
+            inline bool isActive() const { return this->bActive_; }
+            /** @brief This function gets called if the activity of the object changes. */
+            virtual void changedActivity() {}
+
+            /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
+            inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }
+            /** @brief Returns the state of the objects visibility. @return The state of the visibility */
+            inline bool isVisible() const { return this->bVisible_; }
+            /** @brief This function gets called if the visibility of the object changes. */
+            virtual void changedVisibility() {}
+
+            /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */
+            inline void setFile(const XMLFile* file) { this->file_ = file; }
+            /** @brief Returns a pointer to the XMLFile that loaded this object. @return The XMLFile */
+            inline const XMLFile* getFile() const { return this->file_; }
+            const std::string& getFilename() const;
+
+            void addTemplate(const std::string& name);
+            void addTemplate(Template* temp);
+            /** @brief Returns the set of all aplied templates. */
+            inline const std::set<Template*>& getTemplates() const
+                { return this->templates_; }
+
+            virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; }
+            inline Namespace* getNamespace() const { return this->namespace_; }
+
+            inline void setCreator(BaseObject* creator) { this->creator_ = creator; }
+            inline BaseObject* getCreator() const { return this->creator_; }
+
+            inline void setScene(Scene* scene) { this->scene_ = scene; }
+            inline Scene* getScene() const { return this->scene_; }
+
+            inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); }
+            inline Gametype* getGametype() const { return this->gametype_; }
+            inline Gametype* getOldGametype() const { return this->oldGametype_; }
+            virtual inline void changedGametype() {}
+
+            void fireEvent();
+            void fireEvent(bool activate);
+            void fireEvent(bool activate, BaseObject* originator);
+            void fireEvent(Event& event);
+
+            virtual void processEvent(Event& event);
+
+            inline void registerEventListener(BaseObject* object, const std::string& sectionname)
+                { this->eventListeners_[object] = sectionname; }
+            inline void unregisterEventListener(BaseObject* object)
+                { this->eventListeners_.erase(object); }
+
+            void addEvent(BaseObject* event, const std::string& sectionname);
+            void removeEvent(BaseObject* event);
+            BaseObject* getEvent(unsigned int index) const;
+
+            void addEventContainer(const std::string& sectionname, EventContainer* container);
+            EventContainer* getEventContainer(const std::string& sectionname) const;
+
+            /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */
+            inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; }
+            /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */
+            inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }
+
+        protected:
+            std::string name_;                          //!< The name of the object
+            std::string oldName_;                       //!< The old name of the object
+            bool bActive_;                              //!< True = the object is active
+            bool bVisible_;                             //!< True = the object is visible
+
+        private:
+            void setXMLName(const std::string& name);
+            Template* getTemplate(unsigned int index) const;
+
+            bool                  bInitialized_;         //!< True if the object was initialized (passed the object registration)
+            const XMLFile*        file_;                 //!< The XMLFile that loaded this object
+            std::string           loaderIndentation_;    //!< Indentation of the debug output in the Loader
+            Namespace*            namespace_;
+            BaseObject*           creator_;
+            Scene*                scene_;
+            Gametype*             gametype_;
+            Gametype*             oldGametype_;
+            std::set<Template*>   templates_;
+            std::map<BaseObject*, std::string> eventListeners_;
+            std::list<BaseObject*> events_;
+            std::map<std::string, EventContainer*> eventContainers_;
+    };
+
+    SUPER_FUNCTION(0, BaseObject, XMLPort, false);
+    SUPER_FUNCTION(2, BaseObject, changedActivity, false);
+    SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
+    SUPER_FUNCTION(4, BaseObject, processEvent, false);
+}
+
+#endif /* _BaseObject_H__ */
Index: /code/branches/physics/src/core/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/core/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/core/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,84 @@
+SET(CORE_SRC_FILES
+  Clock.cc
+  ConfigFileManager.cc
+  ConfigValueContainer.cc
+  Core.cc
+  Event.cc
+  GameState.cc
+  Language.cc
+  LuaBind.cc
+  ObjectListBase.cc
+  OrxonoxClass.cc
+  RootGameState.cc
+
+  # command
+  ArgumentCompletionFunctions.cc
+  CommandEvaluation.cc
+  CommandExecutor.cc
+  CommandLine.cc
+  ConsoleCommand.cc
+  ConsoleCommandCompilation.cc
+  Executor.cc
+
+  # hierarchy
+  Factory.cc
+  Identifier.cc
+  MetaObjectList.cc
+
+  # level
+  BaseObject.cc
+  ClassTreeMask.cc
+  Loader.cc
+  Namespace.cc
+  NamespaceNode.cc
+  Template.cc
+  XMLPort.cc
+  XMLNameListener.cc
+
+  # shell
+  IRC.cc
+  Shell.cc
+  TclBind.cc
+  TclThreadManager.cc
+
+  # input
+  input/Button.cc
+  input/CalibratorCallback.cc
+  input/ExtendedInputState.cc
+  input/HalfAxis.cc
+  input/InputBuffer.cc
+  input/InputCommands.cc
+  input/InputManager.cc
+  input/JoyStickDeviceNumberListener.cc
+  input/KeyBinder.cc
+  input/KeyDetector.cc
+  input/SimpleInputState.cc
+
+  tolua/tolua_bind.cc
+)
+
+GET_TARGET_PROPERTY(TOLUA_EXE tolua_orxonox LOCATION)
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.cc ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.h
+  COMMAND ${TOLUA_EXE} -n Core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg
+  DEPENDS
+    tolua_orxonox
+    tolua/tolua.pkg
+    LuaBind.h
+    CommandExecutor.h
+  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
+)
+
+ADD_LIBRARY(core SHARED ${CORE_SRC_FILES})
+
+TARGET_LINK_LIBRARIES(core
+  ${OGRE_LIBRARIES}
+  ${Boost_thread_LIBRARIES}
+  ${Boost_filesystem_LIBRARIES}
+  lua_orxonox
+  cpptcl_orxonox
+  ois_orxonox
+  tinyxml_orxonox
+  tolualib_orxonox
+  util
+)
Index: /code/branches/physics/src/core/ClassFactory.h
===================================================================
--- /code/branches/physics/src/core/ClassFactory.h	(revision 2122)
+++ /code/branches/physics/src/core/ClassFactory.h	(revision 2122)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ClassFactory.h
+    @brief Definition and implementation of the ClassFactory class
+
+    The ClassFactory is able to create new objects of a specific class.
+*/
+
+#ifndef _ClassFactory_H__
+#define _ClassFactory_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+#include "Factory.h"
+#include "Identifier.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###      ClassFactory       ###
+    // ###############################
+    //! The ClassFactory is able to create new objects of a specific class.
+    template <class T>
+    class ClassFactory : public BaseFactory
+    {
+        public:
+            static bool create(const std::string& name, bool bLoadable = true);
+            BaseObject* fabricate(BaseObject* creator);
+
+        private:
+            ClassFactory() {}                               // Don't create
+            ClassFactory(const ClassFactory& factory) {}    // Don't copy
+            virtual ~ClassFactory() {}                      // Don't delete
+
+            static T* createNewObject(BaseObject* creator);
+    };
+
+    /**
+        @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
+        @param name The name of the class
+        @param bLoadable True if the class can be loaded through XML
+        @return Always true (this is needed because the compiler only allows assignments before main())
+    */
+    template <class T>
+    bool ClassFactory<T>::create(const std::string& name, bool bLoadable)
+    {
+        COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
+        ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
+        ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
+        Factory::add(name, ClassIdentifier<T>::getIdentifier());
+
+        return true;
+    }
+
+    /**
+        @brief Creates and returns a new object of class T.
+        @return The new object
+    */
+    template <class T>
+    BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
+    {
+        return ClassFactory<T>::createNewObject(creator);
+    }
+
+    /**
+        @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
+        @return The new object
+    */
+    template <class T>
+    T* ClassFactory<T>::createNewObject(BaseObject* creator)
+    {
+        return new T(creator);
+    }
+}
+
+#endif /* _ClassFactory_H__ */
Index: /code/branches/physics/src/core/ClassTreeMask.cc
===================================================================
--- /code/branches/physics/src/core/ClassTreeMask.cc	(revision 2122)
+++ /code/branches/physics/src/core/ClassTreeMask.cc	(revision 2122)
@@ -0,0 +1,964 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ClassTreeMask.cc
+    @brief Implementation of the ClassTreeMask, ClassTreeMaskNode and ClassTreeMaskIterator classes.
+*/
+
+#include "ClassTreeMask.h"
+#include "Identifier.h"
+#include "BaseObject.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###    ClassTreeMaskNode    ###
+    // ###############################
+    /**
+        @brief Constructor: Creates the node, sets the subclass and the rule.
+        @param subclass The subclass the rule refers to
+        @param bIncluded The rule: included (true) or excluded (false)
+    */
+    ClassTreeMaskNode::ClassTreeMaskNode(const Identifier* subclass, bool bIncluded)
+    {
+        this->subclass_ = subclass;
+        this->bIncluded_ = bIncluded;
+    }
+
+    /**
+        @brief Destructor: Deletes all subnodes.
+    */
+    ClassTreeMaskNode::~ClassTreeMaskNode()
+    {
+        // Go through the list of all subnodes and delete them
+        this->deleteAllSubnodes();
+    }
+
+    /**
+        @brief Sets the rule for the node to "included".
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMaskNode::include(bool overwrite)
+    {
+        this->setIncluded(true, overwrite);
+    }
+
+    /**
+        @brief Sets the rule for the node to "excluded".
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMaskNode::exclude(bool overwrite)
+    {
+        this->setIncluded(false, overwrite);
+    }
+
+    /**
+        @brief Sets the rule for the node to a given value and erases all following rules.
+        @param bIncluded The rule: included (true) or excluded (false)
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMaskNode::setIncluded(bool bIncluded, bool overwrite)
+    {
+        if (overwrite)
+            this->deleteAllSubnodes();
+
+        this->bIncluded_ = bIncluded;
+    }
+
+    /**
+        @brief Adds a new subnode to the list of subnodes.
+        @param subnode The new subnode
+    */
+    void ClassTreeMaskNode::addSubnode(ClassTreeMaskNode* subnode)
+    {
+        this->subnodes_.insert(this->subnodes_.end(), subnode);
+    }
+
+    /**
+        @brief Deletes all subnodes of this node.
+    */
+    void ClassTreeMaskNode::deleteAllSubnodes()
+    {
+        // Go through the list of all subnodes and delete them
+        for (std::list<ClassTreeMaskNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); )
+            delete (*(it++));
+
+        // Clear the list
+        this->subnodes_.clear();
+    }
+
+
+    // ###############################
+    // ###  ClassTreeMaskIterator  ###
+    // ###############################
+    /**
+        @brief Constructor: Initializes the iterator by creating a helper-list with the root-node and putting it to the stack.
+        @param node The root-node
+    */
+    ClassTreeMaskIterator::ClassTreeMaskIterator(ClassTreeMaskNode* node)
+    {
+        // Create a list and put the root-note into it
+        std::list<ClassTreeMaskNode*>::iterator it = this->rootlist_.insert(this->rootlist_.end(), node);
+
+        // Put the iterator to the only element of the list and the corresponding end()-iterator on the stack
+        this->nodes_.push(std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator>(it, this->rootlist_.end()));
+    }
+
+    /**
+        @brief Destructor: Does nothing.
+    */
+    ClassTreeMaskIterator::~ClassTreeMaskIterator()
+    {
+    }
+
+    /**
+        @brief Iterates through the rule-tree.
+        @return A reference to the iterator itself
+    */
+    const ClassTreeMaskIterator& ClassTreeMaskIterator::operator++()
+    {
+        // Check if the actual node has subnodes
+        if ((*this->nodes_.top().first)->subnodes_.begin() != (*this->nodes_.top().first)->subnodes_.end())
+        {
+            // Yes it has: Push an iterator, pointing at the first subnode, on the stack
+            this->nodes_.push(std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator>((*this->nodes_.top().first)->subnodes_.begin(), (*this->nodes_.top().first)->subnodes_.end()));
+        }
+        else
+        {
+            // No subnodes, meaning we reached a leaf: Go to the next node
+            do
+            {
+                // Iterate one step in the current list
+                ++this->nodes_.top().first;
+
+                // Check if we reached the end of the list (the second item in the stored pair always represents the end)
+                if (this->nodes_.top().first == this->nodes_.top().second)
+                {
+                    // Yes we've reached the end: Pop the list-iterator from the stack
+                    this->nodes_.pop();
+
+                    // Continue with the loop, meaning: Try to iterate through the previous list
+                    continue;
+                }
+
+                // If we reached this point, we aren't yet at the end of the list: Leave the loop
+                break;
+            } while (!this->nodes_.empty()); // Stop looping if the stack is empty, meaning: We've iterated to the end
+        }
+
+        // Finally return a reference to the iterator itself
+        return *this;
+    }
+
+    /**
+        @brief Returns a pointer to the ClassTreeMaskNode whereon the iterator points.
+        @return The pointer to the node
+    */
+    ClassTreeMaskNode* ClassTreeMaskIterator::operator*() const
+    {
+        return (*this->nodes_.top().first);
+    }
+
+    /**
+        @brief Returns a pointer to the ClassTreeMaskNode whereon the iterator points.
+        @return The pointer to the node
+    */
+    ClassTreeMaskNode* ClassTreeMaskIterator::operator->() const
+    {
+        return (*this->nodes_.top().first);
+    }
+
+    /**
+        @brief Returns true if the stack is empty, meaning we've reached the end of the tree.
+        @return True if we've reached the end of the tree
+    */
+    ClassTreeMaskIterator::operator bool() const
+    {
+        return (!this->nodes_.empty());
+    }
+
+    /**
+        @brief Compares the current node with the given one and returns true if they match.
+        @param compare The node to compare with
+        @return The result of the comparison (true if they match)
+    */
+    bool ClassTreeMaskIterator::operator==(ClassTreeMaskNode* compare) const
+    {
+        if (!this->nodes_.empty())
+            return ((*this->nodes_.top().first) == compare);
+        else
+            return (compare == 0);
+    }
+
+    /**
+        @brief Compares the current node with the given one and returns true if they don't match.
+        @param compare The node to compare with
+        @return The result of the comparison (true if they don't match)
+    */
+    bool ClassTreeMaskIterator::operator!=(ClassTreeMaskNode* compare) const
+    {
+        if (!this->nodes_.empty())
+            return ((*this->nodes_.top().first) != compare);
+        else
+            return (compare != 0);
+    }
+
+
+    // ###############################
+    // ###      ClassTreeMask      ###
+    // ###############################
+    /**
+        @brief Constructor: Adds the root-node of the tree with the first rule ("include everything").
+    */
+    ClassTreeMask::ClassTreeMask()
+    {
+        this->root_ = new ClassTreeMaskNode(ClassIdentifier<BaseObject>::getIdentifier(), true);
+    }
+
+    /**
+        @brief Copyconstructor: Adds the root-node of the tree with the first rule ("include everything") and adds all rules from the other mask.
+        @param other The other mask
+    */
+    ClassTreeMask::ClassTreeMask(const ClassTreeMask& other)
+    {
+        this->root_ = new ClassTreeMaskNode(ClassIdentifier<BaseObject>::getIdentifier(), true);
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+            this->add(it->getClass(), it->isIncluded(), false);
+    }
+
+    /**
+        @brief Destructor: Deletes the root node (which will delete all subnodes too).
+    */
+    ClassTreeMask::~ClassTreeMask()
+    {
+        delete this->root_;
+    }
+
+    /**
+        @brief Adds a new "include" rule for a given subclass to the mask.
+        @param subclass The subclass
+        @param overwrite True = overwrite previously added rules for inheriting classes
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::include(const Identifier* subclass, bool overwrite, bool clean)
+    {
+        this->add(subclass, true, overwrite, clean);
+    }
+
+    /**
+        @brief Adds a new "exclude" rule for a given subclass to the mask.
+        @param subclass The subclass
+        @param overwrite True = overwrite previously added rules for inheriting classes
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::exclude(const Identifier* subclass, bool overwrite, bool clean)
+    {
+        this->add(subclass, false, overwrite, clean);
+    }
+
+    /**
+        @brief Adds a new rule for a given subclass to the mask.
+        @param subclass The subclass
+        @param bInclude The rule: include (true) or exclude (false)
+        @param overwrite True = overwrite previously added rules for inheriting classes
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::add(const Identifier* subclass, bool bInclude, bool overwrite, bool clean)
+    {
+        // Check if the given subclass is a child of our root-class
+        if (subclass->isA(this->root_->getClass()))
+        {
+            // Yes it is: Just add the rule to the three
+            this->add(this->root_, subclass, bInclude, overwrite);
+        }
+        else
+        {
+            // No it's not: Search for classes inheriting from the given class and add the rules for them
+            for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+                if ((*it)->isA(this->root_->getClass()))
+                    if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist
+                        this->add(this->root_, *it, bInclude, overwrite);
+        }
+
+        // Clean the rule-tree
+        if (clean)
+            this->clean();
+    }
+
+    /**
+        @brief Adds a new rule for a given subclass to a node of the internal rule-tree (recursive function).
+        @param node The node
+        @param subclass The subclass
+        @param bInclude The rule: include (true) or exclude (false)
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite)
+    {
+        // Check if the current node contains exactly the subclass we want to add
+        if (subclass == node->getClass())
+        {
+            // We're at the right place, just change the mask and return
+            node->setIncluded(bInclude, overwrite);
+            return;
+        }
+        else if (subclass->isA(node->getClass()))
+        {
+            // Search for an already existing node, containing the subclass we want to add
+            for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)
+            {
+                if (subclass->isA((*it)->getClass()))
+                {
+                    // We've found an existing node -> delegate the work with a recursive function-call and return
+                    this->add(*it, subclass, bInclude, overwrite);
+                    return;
+                }
+            }
+
+            // There is no existing node satisfying our needs -> we create a new node
+            ClassTreeMaskNode* newnode = new ClassTreeMaskNode(subclass, bInclude);
+
+            // Search for nodes that should actually be subnodes of our new node and erase them
+            for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); )
+            {
+                if ((*it)->getClass()->isChildOf(subclass))
+                {
+                    // We've found a subnode: add it to the new node and erase it from the current node
+                    if (!overwrite)
+                        newnode->addSubnode(*it);
+                    else
+                        delete (*it);
+
+                    node->subnodes_.erase(it++);
+                }
+                else
+                {
+                    ++it;
+                }
+            }
+
+            // Finally add the new node as a subnode to the current node
+            node->addSubnode(newnode);
+        }
+    }
+
+    /**
+        @brief Adds a new "include" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
+        @param subclass The subclass
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::includeSingle(const Identifier* subclass, bool clean)
+    {
+        this->addSingle(subclass, true, clean);
+    }
+
+    /**
+        @brief Adds a new "exclude" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
+        @param subclass The subclass
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::excludeSingle(const Identifier* subclass, bool clean)
+    {
+        this->addSingle(subclass, false, clean);
+    }
+
+    /**
+        @brief Adds a new rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
+        @param bInclude The rule: include (true) or exclude (false)
+        @param subclass The subclass
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::addSingle(const Identifier* subclass, bool bInclude, bool clean)
+    {
+        for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+            this->add(*it, this->isIncluded(*it), false, false);
+
+        this->add(subclass, bInclude, false, clean);
+    }
+
+    /**
+        @brief Resets the mask to "include everything".
+    */
+    void ClassTreeMask::reset()
+    {
+        delete this->root_;
+        this->root_ = new ClassTreeMaskNode(ClassIdentifier<BaseObject>::getIdentifier(), true);
+    }
+
+    /**
+        @brief Tells if a given subclass is included or not.
+        @param subclass The subclass
+        @return Included (true) or excluded (false)
+    */
+    bool ClassTreeMask::isIncluded(const Identifier* subclass) const
+    {
+        return this->isIncluded(this->root_, subclass);
+    }
+
+    /**
+        @brief Tells if a given subclass of a node in the rule-tree is included or not (recursive function).
+        @param node The node
+        @param subclass The subclass
+        @return Included (true) or excluded (false)
+    */
+    bool ClassTreeMask::isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const
+    {
+        // Check if the searched subclass is of the same type as the class in the current node or a derivative
+        if (subclass->isA(node->getClass()))
+        {
+            // Check for the special case
+            if (subclass == node->getClass())
+                return node->isIncluded();
+
+            // Go through the list of subnodes and look for a node containing the searched subclass and delegate the request by a recursive function-call.
+            for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)
+                if (subclass->isA((*it)->getClass()))
+                    return isIncluded(*it, subclass);
+
+            // There is no subnode containing our class -> the rule of the current node takes in effect
+            return node->isIncluded();
+        }
+        else
+        {
+            // The class is not included in the mask: return false
+            return false;
+        }
+    }
+
+    /**
+        @brief Tells if a given subclass is excluded or not.
+        @param subclass The subclass
+        @return The inverted rule: Excluded (true) or included (false)
+    */
+    bool ClassTreeMask::isExcluded(const Identifier* subclass) const
+    {
+        return (!this->isIncluded(subclass));
+    }
+
+    /**
+        @brief Removes all unneeded rules that don't change the information of the mask.
+    */
+    void ClassTreeMask::clean()
+    {
+        this->clean(this->root_);
+    }
+
+    /**
+        @brief Removes all unneded rules that don't change the information of a node of a mask (recursive function).
+        @param node The node
+    */
+    void ClassTreeMask::clean(ClassTreeMaskNode* node)
+    {
+        // Iterate through all subnodes of the given node
+        for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); )
+        {
+            // Recursive function-call: Clean the subnode
+            this->clean(*it);
+
+            // Now check if the subnode contains the same rule as the current node
+            if ((*it)->isIncluded() == node->isIncluded())
+            {
+                // It does: Move all subnodes of the redundant subnode to the current node
+                node->subnodes_.insert(node->subnodes_.end(), (*it)->subnodes_.begin(), (*it)->subnodes_.end());
+                (*it)->subnodes_.clear();
+
+                // Remove the redundant subnode from the current node
+                node->subnodes_.erase(it++);
+            }
+            else
+            {
+                // The subnode is necessary: Move on to the next subnode
+                ++it;
+            }
+        }
+    }
+
+    /**
+        @brief Checks if a node for the given subclass exists.
+        @param subclass The Identifier of the subclass
+        @return True = the node exists
+    */
+    bool ClassTreeMask::nodeExists(const Identifier* subclass)
+    {
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+            if ((*it)->getClass() == subclass)
+                return true;
+
+        return false;
+    }
+
+    /**
+        @brief Assignment operator: Adds all rules of the other mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator=(const ClassTreeMask& other)
+    {
+        // Make a copy to avoid troubles with self-assignments (like A = A).
+        ClassTreeMask temp(other);
+
+        // Removes all current rules
+        this->reset();
+
+        // Copy all rules from the other mask
+        for (ClassTreeMaskIterator it = temp.root_; it; ++it)
+            this->add(it->getClass(), it->isIncluded(), false, false);
+
+        // Return a reference to the mask itself
+        return (*this);
+    }
+
+    /**
+        @brief Compares the mask with another mask and returns true if they represent the same logic.
+        @param other The other mask
+        @return True if both masks represent the same logic
+    */
+    bool ClassTreeMask::operator==(const ClassTreeMask& other) const
+    {
+        ClassTreeMask temp1 = other;
+        ClassTreeMask temp2 = (*this);
+
+        temp1.clean();
+        temp2.clean();
+
+        ClassTreeMaskIterator it1 = temp1.root_;
+        ClassTreeMaskIterator it2 = temp2.root_;
+
+        for ( ; it1 && it2; ++it1, ++it2)
+            if (it1->getClass() != it2->getClass())
+                return false;
+
+        return true;
+    }
+
+    /**
+        @brief Compares the mask with another mask and returns true if they represent different logics.
+        @param other The other mask
+        @return True if the masks represent different logics
+    */
+    bool ClassTreeMask::operator!=(const ClassTreeMask& other) const
+    {
+        return (!((*this) == other));
+    }
+
+    /**
+        @brief Prefix operator + does nothing.
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator+() const
+    {
+        return (*this);
+    }
+
+    /**
+        @brief Prefix operator - inverts the mask.
+        @return The inverted mask
+    */
+    ClassTreeMask ClassTreeMask::operator-() const
+    {
+        return (!(*this));
+    }
+
+    /**
+        @brief Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).
+        @param other The mask to unite with
+        @return The union
+    */
+    ClassTreeMask ClassTreeMask::operator+(const ClassTreeMask& other) const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the first mask, calculate the rule with the or-operation
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false);
+        }
+
+        // Add all nodes from the second mask, calculate the rule with the or-operation
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false);
+        }
+
+        // Drop all redundant rules
+        newmask.clean();
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).
+        @param other The mask to intersect with
+        @return The intersection
+    */
+    ClassTreeMask ClassTreeMask::operator*(const ClassTreeMask& other) const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the first mask, calculate the rule with the and-operation
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false);
+        }
+
+        // Add all nodes from the second mask, calculate the rule with the and-operation
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false);
+        }
+
+        // Drop all redundant rules
+        newmask.clean();
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Removes all elements of the second mask from the first mask (all classes that are included in the first mask stay included, except those that are included in the second mask too).
+        @param other The mask to subtract.
+        @return The difference
+    */
+    ClassTreeMask ClassTreeMask::operator-(const ClassTreeMask& other) const
+    {
+        return ((*this) * (!other));
+    }
+
+    /**
+        @brief Inverts the mask (all included classes are now excluded and vice versa).
+        @return The complement
+    */
+    ClassTreeMask ClassTreeMask::operator!() const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the other mask, inverting the rules
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, !this->isIncluded(subclass), false, false);
+        }
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Unites this mask with another mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator+=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) + other;
+        return (*this);
+    }
+
+    /**
+        @brief Intersects this mask with another mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator*=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) * other;
+        return (*this);
+    }
+
+    /**
+        @brief Subtracts another mask from this mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator-=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) - other;
+        return (*this);
+    }
+
+    /**
+        @brief Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).
+        @param other The mask to intersect with
+        @return The intersection
+    */
+    ClassTreeMask ClassTreeMask::operator&(const ClassTreeMask& other) const
+    {
+        return ((*this) * other);
+    }
+
+    /**
+        @brief Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).
+        @param other The mask to unite with
+        @return The union
+    */
+    ClassTreeMask ClassTreeMask::operator|(const ClassTreeMask& other) const
+    {
+        return ((*this) + other);
+    }
+
+    /**
+        @brief Joins two masks in the sense of a xor (exclusivity) operation (all classes that are included in exactly one of the masks, but not in both, will be included in the resulting mask too).
+        @param other The mask to join with
+        @return The result
+    */
+    ClassTreeMask ClassTreeMask::operator^(const ClassTreeMask& other) const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the first mask, calculate the rule with the xor-operation
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false);
+        }
+
+        // Add all nodes from the second mask, calculate the rule with the xor-operation
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false);
+        }
+
+        // Drop all redundant rules
+        newmask.clean();
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Inverts the mask (all included classes are now excluded and vice versa).
+        @return The complement
+    */
+    ClassTreeMask ClassTreeMask::operator~() const
+    {
+        return (!(*this));
+    }
+
+    /**
+        @brief Intersects this mask with another mask (and-operation)
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator&=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) & other;
+        return (*this);
+    }
+
+    /**
+        @brief Unites this mask with another mask (or-operation).
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator|=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) | other;
+        return (*this);
+    }
+
+    /**
+        @brief Joins this mask with another mask with a xor-operation.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator^=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) ^ other;
+        return (*this);
+    }
+
+    /**
+        @brief Converts the content of a mask into a human readable string and puts it on the ostream.
+        @param out The ostream
+        @param mask The mask
+        @return A reference to the ostream
+    */
+    std::ostream& operator<<(std::ostream& out, const ClassTreeMask& mask)
+    {
+        // Iterate through all rules
+        for (ClassTreeMaskIterator it = mask.root_; it; ++it)
+        {
+            // Calculate the prefix: + means included, - means excluded
+            if (it->isIncluded())
+                out << "+";
+            else
+                out << "-";
+
+            // Put the name of the corresponding class on the stream
+            out << it->getClass()->getName() << " ";
+        }
+
+        return out;
+    }
+
+
+    // ###################################
+    // ### ClassTreeMaskObjectIterator ###
+    // ###################################
+    /**
+        @brief Initializes the iterator from a given ClassTreeMask.
+        @param mask The mask
+    */
+    const ClassTreeMaskObjectIterator& ClassTreeMaskObjectIterator::operator=(const ClassTreeMask& mask)
+    {
+        // Clear everything, use a cleaned copy of the mask
+        this->subclasses_.clear();
+        ClassTreeMask temp = mask;
+        temp.clean();
+
+        // Create the subclass-list by going through the mask-tree, starting with the root-node
+        this->create(temp.root_);
+
+        // Move the subclass-iterator to the beginning of the subclass-list
+        this->subclassIterator_ = this->subclasses_.begin();
+
+        // If there is a first subclass, move the object-iterator to the first object of this class. Else go to the end
+        if (this->subclassIterator_ != this->subclasses_.end())
+            this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+        else
+            this->objectIterator_ = ObjectList<BaseObject>::end();
+
+        // Check if the iterator points on a valid object. If not, go to the next object by calling ++
+        if (!this->objectIterator_ || ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first)))
+            this->operator++();
+
+        return (*this);
+    }
+
+    /**
+        @brief Iterate to the next object (if any).
+        @return The iterator itself
+    */
+    const ClassTreeMaskObjectIterator& ClassTreeMaskObjectIterator::operator++()
+    {
+        if (this->objectIterator_)
+        {
+            // The iterator points on a valid object, therefore we also have a valid subclass-iterator at the moment
+            do
+            {
+                // Go to the next object
+                ++this->objectIterator_;
+
+                while (!this->objectIterator_)
+                {
+                    // We reached the end of the current objectlist - go to the next class
+                    ++this->subclassIterator_;
+
+                    // Check if there really is a next class. If yes, move the object-iterator to the first object
+                    if (this->subclassIterator_ != this->subclasses_.end())
+                        this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+                    else
+                        return (*this);
+                }
+
+            // Repeat this until we reach a valid object or the end
+            } while ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first));
+        }
+        return (*this);
+    }
+
+    /**
+        @brief Recursive function to create the Iterators subclass-list by going through the node-tree of the mask.
+        @param node The current node
+    */
+    void ClassTreeMaskObjectIterator::create(ClassTreeMaskNode* node)
+    {
+        // Add the class of this node to the list, if the class is included
+        if (node->isIncluded())
+        {
+            // If there are some subnodes, the bool is "true", meaning we have to check for the exact clss when iterating
+            if (node->hasSubnodes())
+                this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(node->getClass(), true));
+            else
+                this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(node->getClass(), false));
+        }
+
+        // Now check if the node has subnodes
+        if (node->hasSubnodes())
+        {
+            // Get all _direct_ children of the nodes class
+            std::set<const Identifier*> directChildren = node->getClass()->getDirectChildren();
+
+            // Iterate through all subnodes
+            for (std::list<ClassTreeMaskNode*>::iterator it1 = node->subnodes_.begin(); it1 != node->subnodes_.end(); ++it1)
+            {
+                // Recursive call to this function with the subnode
+                this->create(*it1);
+
+                // Only execute the following code if the current node is included, meaning some of the subnodes might be included too
+                if (node->isIncluded())
+                {
+                    scanChildren: // This is a label for goto
+
+                    // Iterate through all direct children
+                    for (std::set<const Identifier*>::iterator it2 = directChildren.begin(); it2 != directChildren.end(); ++it2)
+                    {
+                        // Check if the subnode (it1) is a child of the directChild (it2)
+                        if ((*it1)->getClass()->isA(*it2))
+                        {
+                            // Yes it is - remove the directChild (it2) from the list, because it will already be handled by a recursive call to the create() function
+                            directChildren.erase(it2);
+
+                            // Check if the removed directChild was exactly the subnode
+                            if (!(*it1)->getClass()->isExactlyA(*it2))
+                            {
+                                // No, it wasn't exactly the subnode - therefore there are some classes between
+
+                                // Add the previously removed directChild (it2) to the subclass-list
+                                this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it2, true));
+
+                                // Insert all directChildren of the directChild
+                                directChildren.insert((*it2)->getDirectChildrenBegin(), (*it2)->getDirectChildrenEnd());
+
+                                // Restart the scan with the expanded set of directChildren
+                                goto scanChildren;
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+
+            // Now add all directChildren which don't have subnodes on their own to the subclass-list
+            // The bool is "false", meaning they have no subnodes and therefore need no further checks
+            if (node->isIncluded())
+                for (std::set<const Identifier*>::iterator it = directChildren.begin(); it != directChildren.end(); ++it)
+                    this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it, false));
+        }
+    }
+}
Index: /code/branches/physics/src/core/ClassTreeMask.h
===================================================================
--- /code/branches/physics/src/core/ClassTreeMask.h	(revision 2122)
+++ /code/branches/physics/src/core/ClassTreeMask.h	(revision 2122)
@@ -0,0 +1,287 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ClassTreeMask.h
+    @brief Definition of the ClassTreeMask, ClassTreeMaskNode and ClassTreeMaskIterator classes.
+
+    ClassTreeMask is a class to define a mask of the class-tree beginning with BaseObject.
+    You can include or exclude classes by calling the corresponding functions with the
+    Identifier of the class.
+
+    You can work with a ClassTreeMask in the sense of the set-theory, meaning that you can create
+    unions, intersections, complements and differences by using overloaded operators.
+
+
+
+    The ClassTreeMask is internally represented by a tree. The nodes in the tree are
+    ClassTreeMaskNodes, containing the rule (included or excluded) for this class and all
+    subclasses and a list of all subnodes. To minimize the size, the tree contains only
+    nodes changing the mask. By adding new rules, the tree gets reordered dynamically.
+
+    Adding a new rule overwrites all rules assigned to inherited classes. Use overwrite = false
+    if you don't like this feature. Useless rules that don't change the information of the mask
+    aren't saved in the internal tree. Use clean = false if you wan't to save them.
+
+    With overwrite = false and clean = false it doesn't matter in which way you create the mask.
+    You can manually drop useless rules from the tree by calling clean().
+
+
+
+    Because of the complicated shape of the internal tree, there is an iterator to iterate
+    through all ClassTreeMaskNodes of a mask. It starts with the BaseObject and moves on to
+    the first subclass until it reaches a leaf of the tree. Then the iterator moves one step
+    back and iterates to the second subclass. If there are no more subclasses, it steps another
+    step back, and so on.
+
+    Example: A and B are children of BaseObject, A1 and A2 are children of A, B1 and B2 are children of B.
+    The ClassTreeMaskIterator would move trough the tree in the following order:
+    BaseObject, A, A1, A2, B, B1, B2.
+
+    Note that the iterator doesn't move trough the whole class-tree, but only through the
+    internal tree of the mask, containing the minimal needed set of nodes to describe the mask.
+*/
+
+#ifndef _ClassTreeMask_H__
+#define _ClassTreeMask_H__
+
+#include "CorePrereqs.h"
+
+#include <list>
+#include <stack>
+
+#include "Iterator.h"
+#include "BaseObject.h"
+
+namespace orxonox
+{
+    // ###################################
+    // ###      ClassTreeMaskNode      ###
+    // ###################################
+    //! The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask.
+    /**
+        The ClassTreeMaskNode is used to store the rule (included or excluded) for a given
+        class (described by the corresponding Identifier). The nodes are used in the internal
+        tree of ClassTreeMask. To build a tree, they store a list of all subnodes.
+    */
+    class _CoreExport ClassTreeMaskNode
+    {
+        friend class ClassTreeMask;
+        friend class ClassTreeMaskIterator;
+        friend class ClassTreeMaskObjectIterator;
+
+        public:
+            ClassTreeMaskNode(const Identifier* subclass, bool bIncluded = true);
+            ~ClassTreeMaskNode();
+
+            void include(bool overwrite = true);
+            void exclude(bool overwrite = true);
+            void setIncluded(bool bIncluded, bool overwrite = true);
+
+            void addSubnode(ClassTreeMaskNode* subnode);
+
+            /** @brief Tells if the rule is "included" or not. @return The rule: true = included, false = excluded */
+            inline bool isIncluded() const { return this->bIncluded_; }
+            /** @brief Tells if the rule is "excluded" or not. @return The inverted rule: true = excluded, false = included */
+            inline bool isExcluded() const { return (!this->bIncluded_); }
+
+            /** @brief Returns the Identifier of the class the rule refers to. @return The Identifier representing the class */
+            inline const Identifier* getClass() const { return this->subclass_; }
+
+            /** @brief Returns true if the Node has some subnodes. */
+            inline bool hasSubnodes() const { return !this->subnodes_.empty(); }
+
+        private:
+            void deleteAllSubnodes();
+
+            const Identifier* subclass_;                //!< The Identifier of the subclass the rule refers to
+            bool bIncluded_;                            //!< The rule: included or excluded
+            std::list<ClassTreeMaskNode*> subnodes_;    //!< A list containing all subnodes in the tree
+    };
+
+
+    // ###################################
+    // ###    ClassTreeMaskIterator    ###
+    // ###################################
+    //! The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask, containing the rules.
+    /**
+        Because of the complicated shape of the internal rule-tree of ClassTreeMask, an
+        iterator is used to move through all nodes of the tree. It starts with the BaseObject
+        and moves on to the first subclass until it reaches a leaf of the tree. Then the
+        iterator moves one step back and iterates to the second subclass. If there are no more
+        subclasses, it steps another step back, and so on.
+    */
+    class _CoreExport ClassTreeMaskIterator
+    {
+        public:
+            ClassTreeMaskIterator(ClassTreeMaskNode* node);
+            ~ClassTreeMaskIterator();
+
+            const ClassTreeMaskIterator& operator++();
+            ClassTreeMaskNode* operator*() const;
+            ClassTreeMaskNode* operator->() const;
+            operator bool() const;
+            bool operator==(ClassTreeMaskNode* compare) const;
+            bool operator!=(ClassTreeMaskNode* compare) const;
+
+        private:
+            std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_;    //!< A stack to store list-iterators
+            std::list<ClassTreeMaskNode*> rootlist_;                                                                            //!< A list for internal use (it only stores the root-node)
+    };
+
+
+    // ###################################
+    // ###        ClassTreeMask        ###
+    // ###################################
+    //! The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.
+    /**
+        With a ClassTreeMask, you can include or exclude subtrees of the class-tree, starting
+        with a given subclass, described by the corresponding Identifier. To minimize the size
+        of the mask, the mask saves only relevant rules. But you can manually add rules that
+        don't change the information of the mask by using clean = false. If you want to drop
+        useless rules, call the clean() function.
+    */
+    class _CoreExport ClassTreeMask
+    {
+        friend class ClassTreeMaskObjectIterator;
+
+        public:
+            ClassTreeMask();
+            ClassTreeMask(const ClassTreeMask& other);
+            ~ClassTreeMask();
+
+            void include(const Identifier* subclass, bool overwrite = true, bool clean = true);
+            void exclude(const Identifier* subclass, bool overwrite = true, bool clean = true);
+            void add(const Identifier* subclass, bool bInclude, bool overwrite = true, bool clean = true);
+
+            void includeSingle(const Identifier* subclass, bool clean = true);
+            void excludeSingle(const Identifier* subclass, bool clean = true);
+            void addSingle(const Identifier* subclass, bool bInclude, bool clean = true);
+
+            void reset();
+            void clean();
+
+            bool isIncluded(const Identifier* subclass) const;
+            bool isExcluded(const Identifier* subclass) const;
+
+            /** @brief Begin of the ClassTreeMaskObjectIterator. */
+            inline const ClassTreeMask& begin() const { return (*this); }
+            /** @brief End of the ClassTreeMaskObjectIterator. */
+            inline BaseObject*          end()   const { return 0; }
+
+            const ClassTreeMask& operator=(const ClassTreeMask& other);
+
+            bool operator==(const ClassTreeMask& other) const;
+            bool operator!=(const ClassTreeMask& other) const;
+
+            const ClassTreeMask& operator+() const;
+            ClassTreeMask operator-() const;
+
+            ClassTreeMask operator+(const ClassTreeMask& other) const;
+            ClassTreeMask operator*(const ClassTreeMask& other) const;
+            ClassTreeMask operator-(const ClassTreeMask& other) const;
+            ClassTreeMask operator!() const;
+
+            const ClassTreeMask& operator+=(const ClassTreeMask& other);
+            const ClassTreeMask& operator*=(const ClassTreeMask& other);
+            const ClassTreeMask& operator-=(const ClassTreeMask& other);
+
+            ClassTreeMask operator&(const ClassTreeMask& other) const;
+            ClassTreeMask operator|(const ClassTreeMask& other) const;
+            ClassTreeMask operator^(const ClassTreeMask& other) const;
+            ClassTreeMask operator~() const;
+
+            const ClassTreeMask& operator&=(const ClassTreeMask& other);
+            const ClassTreeMask& operator|=(const ClassTreeMask& other);
+            const ClassTreeMask& operator^=(const ClassTreeMask& other);
+
+            friend std::ostream& operator<<(std::ostream& out, const ClassTreeMask& mask);
+
+        private:
+            void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite = true);
+            bool isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const;
+            void clean(ClassTreeMaskNode* node);
+            bool nodeExists(const Identifier* subclass);
+
+            ClassTreeMaskNode* root_;   //!< The root-node of the internal rule-tree, usually BaseObject
+    };
+
+
+    // ###################################
+    // ### ClassTreeMaskObjectIterator ###
+    // ###################################
+    //! The ClassTreeMaskObjectIterator iterates through all objects of all classes, included by a ClassTreeMask.
+    /**
+        The ClassTreeMaskObjectIterator iterates through all objects of all classes,
+        included by a ClassTreeMask. This is done the following way:
+
+        ClassTreeMask mask;
+        for (ClassTreeMaskObjectIterator it = mask.begin(); it != mask.end(); ++it)
+            it->doSomething();
+
+        Note: The ClassTreeMaskObjectIterator handles all objects as BaseObjects. If
+              you want to use another class, you should use a dynamic_cast.
+
+        Performance of ClassTreeMaskObjectIterator is good as long as you don't exclude
+        subclasses of included classes. Of course you can still exlucde subclasses, but
+        if this is done more often, we need a new implementation using a second ObjectList
+        in the Identifier, containing all objects of exactly one class.
+    */
+    class _CoreExport ClassTreeMaskObjectIterator
+    {
+        public:
+            /** @brief Defaultconstructor: Does nothing. */
+            inline ClassTreeMaskObjectIterator() {}
+            /** @brief Constructor: Initializes the iterator from a given ClassTreeMask. @param mask The mask */
+            inline ClassTreeMaskObjectIterator(const ClassTreeMask& mask) { (*this) = mask; }
+
+            const ClassTreeMaskObjectIterator& operator=(const ClassTreeMask& mask);
+
+            const ClassTreeMaskObjectIterator& operator++();
+
+            /** @brief Returns true if the ClassTreeMaskObjectIterator points at the given object. @param pointer The pointer of the object */
+            inline bool operator==(BaseObject* pointer) const { return ((*this->objectIterator_) == pointer); }
+            /** @brief Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. @param pointer The pointer of the object */
+            inline bool operator!=(BaseObject* pointer) const { return ((*this->objectIterator_) != pointer); }
+            /** @brief Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. */
+            inline operator bool() const { return (this->objectIterator_); }
+            /** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */
+            inline BaseObject* operator*() const { return (*this->objectIterator_); }
+            /** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */
+            inline BaseObject* operator->() const { return (*this->objectIterator_); }
+
+        private:
+            void create(ClassTreeMaskNode* node);
+
+            std::list<std::pair<const Identifier*, bool> >           subclasses_;       //!< A list of all Identifiers through which objects the iterator should iterate
+            std::list<std::pair<const Identifier*, bool> >::iterator subclassIterator_; //!< The current class of the iterator
+            Iterator<BaseObject>                                     objectIterator_;   //!< The current object of the iterator
+    };
+}
+
+#endif /* _ClassTreeMask_H__ */
Index: /code/branches/physics/src/core/Clock.cc
===================================================================
--- /code/branches/physics/src/core/Clock.cc	(revision 2122)
+++ /code/branches/physics/src/core/Clock.cc	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief
+*/
+
+#include "Clock.h"
+#include <OgreTimer.h>
+
+namespace orxonox
+{
+    Clock::Clock()
+        : timer_(new Ogre::Timer())
+        , storedTime_(0)
+        , tickTime_(0)
+        , tickDt_(0)
+        , tickDtFloat_(0.0f)
+        , lastTimersTime_(0)
+    {
+    }
+
+    Clock::~Clock()
+    {
+        delete timer_;
+    }
+    
+    void Clock::capture()
+    {
+        unsigned long timersTime = timer_->getMicroseconds();
+        tickTime_ = storedTime_ + timersTime;
+        tickDt_ = timersTime - lastTimersTime_;
+        tickDtFloat_ = (float)tickDt_ / 1000000.0f;
+
+        if (timersTime > 0x7FFFFFF0)
+        {
+            // Ogre timer will overflow at 2^32 microseconds if unsigned long is 32 bit
+            storedTime_ += timersTime;
+            lastTimersTime_ = 0;
+            timer_->reset();
+        }
+        else
+        {
+            lastTimersTime_ = timersTime;
+        }
+    }
+
+    unsigned long long Clock::getRealMicroseconds() const
+    {
+        return this->timer_->getMicroseconds();
+    }
+}
Index: /code/branches/physics/src/core/Clock.h
===================================================================
--- /code/branches/physics/src/core/Clock.h	(revision 2122)
+++ /code/branches/physics/src/core/Clock.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+/**
+    @file Core.h
+    @brief Declaration of the Core class.
+
+    The Core class is a singleton, only used to configure some variables
+    in the core through the config-file.
+*/
+
+#ifndef _Clock_H__
+#define _Clock_H__
+
+#include "CorePrereqs.h"
+#include <OgrePrerequisites.h>
+
+namespace orxonox
+{
+    class _CoreExport Clock
+    {
+        friend class RootGameState;
+
+    public:
+        Clock();
+        ~Clock();
+
+        unsigned long long getMicroseconds()   const { return tickTime_; }
+        unsigned long long getMilliseconds()   const { return tickTime_ / 1000; }
+        int                getSeconds()        const { return tickTime_ / 1000000; }
+        float              getSecondsPrecise() const { return (float)tickTime_ / 1000000.0f; }
+
+        float              getDeltaTime()      const { return tickDtFloat_; }
+        int                getDeltaTimeMicroseconds() const { return tickDt_; }
+
+        unsigned long long getRealMicroseconds() const;
+
+    private:
+        Clock(const Clock& instance);
+        void capture();
+
+        Ogre::Timer*       timer_;
+        unsigned long long storedTime_;
+        unsigned long long tickTime_;
+        int                tickDt_;
+        float              tickDtFloat_;
+        unsigned long      lastTimersTime_;
+    };
+}
+
+#endif /* _Clock_H__ */
Index: /code/branches/physics/src/core/CommandEvaluation.cc
===================================================================
--- /code/branches/physics/src/core/CommandEvaluation.cc	(revision 2122)
+++ /code/branches/physics/src/core/CommandEvaluation.cc	(revision 2122)
@@ -0,0 +1,312 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandEvaluation.h"
+#include "ConsoleCommand.h"
+#include "Identifier.h"
+#include "util/Debug.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    CommandEvaluation::CommandEvaluation()
+    {
+        this->initialize("");
+        this->state_ = CS_Uninitialized;
+    }
+
+    void CommandEvaluation::initialize(const std::string& command)
+    {
+        this->bNewCommand_ = true;
+        this->bCommandChanged_ = false;
+        this->originalCommand_ = command;
+        this->command_ = command;
+        this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
+
+        this->additionalParameter_ = "";
+
+        this->bEvaluatedParams_ = false;
+
+        this->listOfPossibleIdentifiers_.clear();
+        this->listOfPossibleFunctions_.clear();
+        this->listOfPossibleArguments_.clear();
+
+        this->functionclass_ = 0;
+        this->function_ = 0;
+        this->possibleArgument_ = "";
+        this->argument_ = "";
+
+        this->errorMessage_ = "";
+        this->state_ = CS_Empty;
+    }
+
+    bool CommandEvaluation::isValid() const
+    {
+        return (this->function_);
+    }
+
+    bool CommandEvaluation::execute() const
+    {
+        if (!this->isValid())
+            return false;
+
+        if (this->bEvaluatedParams_ && this->function_)
+        {
+            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
+            (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
+            return true;
+        }
+
+        if (!this->bCommandChanged_ || removeTrailingWhitespaces(this->command_) == removeTrailingWhitespaces(this->originalCommand_))
+        {
+            COUT(4) << "CE_execute: " << this->command_ << "\n";
+
+            unsigned int startindex = this->getStartindex();
+            if (this->commandTokens_.size() > startindex)
+                return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));
+            else
+                return this->function_->parse(removeSlashes(this->additionalParameter_));
+        }
+
+        return false;
+    }
+
+    std::string CommandEvaluation::complete()
+    {
+        if (!this->bNewCommand_)
+        {
+            switch (this->state_)
+            {
+                case CS_Uninitialized:
+                    break;
+                case CS_Empty:
+                    break;
+                case CS_ShortcutOrIdentifier:
+                    if (this->function_)
+                    {
+                        if (this->function_->getParamCount() == 0)
+                            return (this->command_ = this->function_->getName());
+                        else
+                            return (this->command_ = this->function_->getName() + " ");
+                    }
+                    else if (this->functionclass_)
+                        return (this->command_ = this->functionclass_->getName() + " ");
+                    break;
+                case CS_Function:
+                    if (this->function_)
+                    {
+                        if (this->function_->getParamCount() == 0)
+                            return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName());
+                        else
+                            return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName() + " ");
+                    }
+                    break;
+                case CS_ParamPreparation:
+                case CS_Params:
+                {
+                    if (this->argument_ == "" && this->possibleArgument_ == "")
+                        break;
+
+                    unsigned int maxIndex = this->commandTokens_.size();
+                    if (this->command_[this->command_.size() - 1] != ' ')
+                        maxIndex -= 1;
+                    std::string whitespace = "";
+
+                    if (this->possibleArgument_ != "")
+                    {
+                        this->argument_ = this->possibleArgument_;
+                        if (this->function_->getParamCount() > (maxIndex + 1 - this->getStartindex()))
+                            whitespace = " ";
+                    }
+
+                    return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + " " + this->argument_ + whitespace);
+                    break;
+                }
+                case CS_Finished:
+                    break;
+                case CS_Error:
+                    break;
+            }
+        }
+        this->bNewCommand_ = false;
+        return this->command_;
+    }
+
+    std::string CommandEvaluation::hint() const
+    {
+        switch (this->state_)
+        {
+            case CS_Uninitialized:
+                break;
+            case CS_Empty:
+            case CS_ShortcutOrIdentifier:
+                if (this->listOfPossibleFunctions_.size() == 0)
+                    return CommandEvaluation::dump(this->listOfPossibleIdentifiers_);
+                else if (this->listOfPossibleIdentifiers_.size() == 0)
+                    return CommandEvaluation::dump(this->listOfPossibleFunctions_);
+                else
+                    return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
+                break;
+            case CS_Function:
+                return CommandEvaluation::dump(this->listOfPossibleFunctions_);
+                break;
+            case CS_ParamPreparation:
+            case CS_Params:
+                if (this->listOfPossibleArguments_.size() > 0)
+                    return CommandEvaluation::dump(this->listOfPossibleArguments_);
+                else
+                    return CommandEvaluation::dump(this->function_);
+            case CS_Finished:
+                if (this->function_)
+                    return CommandEvaluation::dump(this->function_);
+                break;
+            case CS_Error:
+                return this->errorMessage_;
+                break;
+        }
+
+        return "";
+    }
+
+    void CommandEvaluation::evaluateParams()
+    {
+        this->bEvaluatedParams_ = false;
+
+        for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++)
+            this->param_[i] = MT_null;
+
+        if (!this->isValid())
+            return;
+
+        unsigned int startindex = this->getStartindex();
+
+        if (this->commandTokens_.size() <= startindex)
+        {
+            if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " "))
+                this->bEvaluatedParams_ = true;
+        }
+        else if (this->commandTokens_.size() > startindex)
+        {
+            if (this->function_->evaluate(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))
+                this->bEvaluatedParams_ = true;
+        }
+    }
+
+    void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType param)
+    {
+        if (index < MAX_FUNCTOR_ARGUMENTS)
+            this->param_[index] = param;
+    }
+
+    MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const
+    {
+        if (index < MAX_FUNCTOR_ARGUMENTS)
+            return this->param_[index];
+
+        return MT_null;
+    }
+
+    bool CommandEvaluation::hasReturnvalue() const
+    {
+        if (this->function_)
+            return this->function_->hasReturnvalue();
+
+        return MT_null;
+    }
+
+    MultiType CommandEvaluation::getReturnvalue() const
+    {
+        if (this->function_)
+            return this->function_->getReturnvalue();
+
+        return MultiType();
+    }
+
+
+    unsigned int CommandEvaluation::getStartindex() const
+    {
+        if (this->functionclass_ && this->function_)
+            return 2;
+        else if (this->function_)
+            return 1;
+        else
+            return 0;
+    }
+
+    std::string CommandEvaluation::dump(const std::list<std::pair<const std::string*, const std::string*> >& list)
+    {
+        std::string output = "";
+        for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            if (it != list.begin())
+                output += " ";
+
+            output += *(*it).second;
+        }
+        return output;
+    }
+
+    std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
+    {
+        std::string output = "";
+        for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            if (it != list.begin())
+                output += " ";
+
+            output += (*it).getDisplay();
+        }
+        return output;
+    }
+
+    std::string CommandEvaluation::dump(const ConsoleCommand* command)
+    {
+        std::string output = command->getName();
+        if (command->getParamCount() > 0)
+            output += ": ";
+
+        for (unsigned int i = 0; i < command->getParamCount(); i++)
+        {
+            if (i != 0)
+                output += " ";
+
+            if (command->defaultValueSet(i))
+                output += "[";
+            else
+                output += "{";
+
+            output += command->getTypenameParam(i);
+
+            if (command->defaultValueSet(i))
+                output += "=" + command->getDefaultValue(i).getString() + "]";
+            else
+                output += "}";
+        }
+        return output;
+    }
+}
Index: /code/branches/physics/src/core/CommandEvaluation.h
===================================================================
--- /code/branches/physics/src/core/CommandEvaluation.h	(revision 2122)
+++ /code/branches/physics/src/core/CommandEvaluation.h	(revision 2122)
@@ -0,0 +1,121 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandEvaluation_H__
+#define _CommandEvaluation_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+#include "ArgumentCompletionListElement.h"
+#include "util/SubString.h"
+#include "util/MultiType.h"
+
+namespace orxonox
+{
+    enum CommandState
+    {
+        CS_Uninitialized,
+        CS_Empty,
+        CS_ShortcutOrIdentifier,
+        CS_Function,
+        CS_ParamPreparation,
+        CS_Params,
+        CS_Finished,
+        CS_Error
+    };
+
+    class _CoreExport CommandEvaluation
+    {
+        friend class CommandExecutor;
+
+        public:
+            CommandEvaluation();
+
+            void initialize(const std::string& command);
+
+            bool execute() const;
+            std::string complete();
+            std::string hint() const;
+            void evaluateParams();
+
+            bool isValid() const;
+
+            inline ConsoleCommand* getConsoleCommand() const
+                { return this->function_; }
+            inline const std::string& getOriginalCommand() const
+                { return this->originalCommand_; }
+            inline const std::string& getCommand() const
+                { return this->command_; }
+
+            inline void setAdditionalParameter(const std::string& param)
+                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
+            inline std::string getAdditionalParameter() const
+                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
+
+            void setEvaluatedParameter(unsigned int index, MultiType param);
+            MultiType getEvaluatedParameter(unsigned int index) const;
+
+            bool hasReturnvalue() const;
+            MultiType getReturnvalue() const;
+
+        private:
+            unsigned int getStartindex() const;
+            static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
+            static std::string dump(const ArgumentCompletionList& list);
+            static std::string dump(const ConsoleCommand* command);
+
+
+            bool bNewCommand_;
+            bool bCommandChanged_;
+
+            std::string originalCommand_;
+            std::string command_;
+            SubString commandTokens_;
+            std::string additionalParameter_;
+
+            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
+            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
+            ArgumentCompletionList listOfPossibleArguments_;
+
+            Identifier* functionclass_;
+            ConsoleCommand* function_;
+            std::string possibleArgument_;
+            std::string argument_;
+
+            std::string errorMessage_;
+            CommandState state_;
+
+            bool bEvaluatedParams_;
+            MultiType param_[5];
+    };
+}
+
+#endif /* _CommandEvaluation_H__ */
Index: /code/branches/physics/src/core/CommandExecutor.cc
===================================================================
--- /code/branches/physics/src/core/CommandExecutor.cc	(revision 2122)
+++ /code/branches/physics/src/core/CommandExecutor.cc	(revision 2122)
@@ -0,0 +1,649 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandExecutor.h"
+#include "ConsoleCommand.h"
+#include "util/String.h"
+#include "util/Debug.h"
+#include "Identifier.h"
+#include "Language.h"
+#include "TclBind.h"
+
+namespace orxonox
+{
+    CommandExecutor& CommandExecutor::getInstance()
+    {
+        static CommandExecutor instance;
+        return instance;
+    }
+
+    CommandEvaluation& CommandExecutor::getEvaluation()
+    {
+        return CommandExecutor::getInstance().evaluation_;
+    }
+
+    const CommandEvaluation& CommandExecutor::getLastEvaluation()
+    {
+        return CommandExecutor::getInstance().evaluation_;
+    }
+
+    ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(command->getName());
+        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
+        {
+            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << "." << std::endl;
+        }
+
+
+        CommandExecutor::getInstance().consoleCommandShortcuts_[command->getName()] = command;
+        CommandExecutor::getInstance().consoleCommandShortcuts_LC_[getLowercase(command->getName())] = command;
+        return (*command);
+    }
+
+    /**
+        @brief Returns the executor of a console command shortcut with given name.
+        @brief name The name of the requested console command shortcut
+        @return The executor of the requested console command shortcut
+    */
+    ConsoleCommand* CommandExecutor::getConsoleCommandShortcut(const std::string& name)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);
+        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns the executor of a console command shortcut with given name in lowercase.
+        @brief name The name of the requested console command shortcut in lowercase
+        @return The executor of the requested console command shortcut
+    */
+    ConsoleCommand* CommandExecutor::getLowercaseConsoleCommandShortcut(const std::string& name)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);
+        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    bool CommandExecutor::execute(const std::string& command, bool useTcl)
+    {
+        if (useTcl)
+            return TclBind::eval(command);
+
+        CommandExecutor::parseIfNeeded(command);
+        return CommandExecutor::getEvaluation().execute();
+    }
+
+    std::string CommandExecutor::complete(const std::string& command)
+    {
+        CommandExecutor::parseIfNeeded(command);
+        return CommandExecutor::getEvaluation().complete();
+    }
+
+    std::string CommandExecutor::hint(const std::string& command)
+    {
+        CommandExecutor::parseIfNeeded(command);
+        return CommandExecutor::getEvaluation().hint();
+    }
+
+    CommandEvaluation CommandExecutor::evaluate(const std::string& command)
+    {
+        CommandExecutor::parse(command);
+        CommandExecutor::getEvaluation().evaluateParams();
+        return CommandExecutor::getEvaluation();
+    }
+
+    void CommandExecutor::parseIfNeeded(const std::string& command)
+    {
+        if (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)
+        {
+            CommandExecutor::parse(command);
+        }
+        else if (CommandExecutor::getEvaluation().originalCommand_ != command)
+        {
+            if (CommandExecutor::getEvaluation().command_ == command)
+            {
+                CommandExecutor::parse(command);
+                CommandExecutor::getEvaluation().bNewCommand_ = false;
+            }
+            else
+            {
+                CommandExecutor::parse(command);
+            }
+        }
+    }
+
+    void CommandExecutor::parse(const std::string& command, bool bInitialize)
+    {
+        if (bInitialize)
+            CommandExecutor::getEvaluation().initialize(command);
+
+        CommandExecutor::getEvaluation().commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
+        CommandExecutor::getEvaluation().command_ = command;
+
+        switch (CommandExecutor::getEvaluation().state_)
+        {
+            case CS_Uninitialized:
+            {
+                // Impossible
+                break;
+            }
+            case CS_Empty:
+            {
+                if (CommandExecutor::argumentsGiven() == 0)
+                {
+                    CommandExecutor::createListOfPossibleFunctions("");
+                    CommandExecutor::createListOfPossibleIdentifiers("");
+                    break;
+                }
+                else
+                {
+                    CommandExecutor::getEvaluation().state_ = CS_ShortcutOrIdentifier;
+                    // Move on to next case
+                }
+            }
+            case CS_ShortcutOrIdentifier:
+            {
+                if (CommandExecutor::argumentsGiven() > 1)
+                {
+                    // There's a finished first argument - check if it's a shortcut or a classname
+                    CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
+                    CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
+
+                    if (CommandExecutor::getEvaluation().function_)
+                    {
+                        // It's a shortcut
+                        CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                        CommandExecutor::getEvaluation().functionclass_ = 0;
+                        // Move on to next case
+                    }
+                    else if (CommandExecutor::getEvaluation().functionclass_)
+                    {
+                        // It's a functionname
+                        CommandExecutor::getEvaluation().state_ = CS_Function;
+                        CommandExecutor::getEvaluation().function_ = 0;
+                        // Move on to next case
+                    }
+                    else
+                    {
+                        // The first argument is bad
+                        CommandExecutor::getEvaluation().state_ = CS_Error;
+                        AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
+                        return;
+                    }
+                }
+                else
+                {
+                    // There's no finished first argument - search possible shortcuts or classnames
+                    CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0));
+                    CommandExecutor::createListOfPossibleIdentifiers(CommandExecutor::getArgument(0));
+
+                    unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
+                    unsigned int num_identifiers = CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.size();
+
+                    if (num_functions == 1 && num_identifiers == 0)
+                    {
+                        // It's a shortcut
+                        std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname);
+                        if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0)))
+                        {
+                            // Unfinished shortcut
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        }
+                        CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                        CommandExecutor::getEvaluation().functionclass_ = 0;
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
+                        if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
+                        {
+                            CommandExecutor::getEvaluation().command_ += " ";
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        }
+                        // Move on to next case
+                    }
+                    else if (num_identifiers == 1 && num_functions == 0)
+                    {
+                        // It's a classname
+                        std::string classname = *(*CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()).first;
+                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname);
+                        if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0)))
+                        {
+                            // Unfinished classname
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        }
+                        CommandExecutor::getEvaluation().state_ = CS_Function;
+                        CommandExecutor::getEvaluation().function_ = 0;
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";
+                        // Move on to next case
+                    }
+                    else if (num_identifiers == 0 && num_functions == 0)
+                    {
+                        // No possibilities
+                        CommandExecutor::getEvaluation().state_ = CS_Error;
+                        AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";
+                        return;
+                    }
+                    else
+                    {
+                        // There are several possiblilities
+                        std::list<std::pair<const std::string*, const std::string*> > temp;
+                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.end());
+                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.end());
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getCommonBegin(temp);
+                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
+                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
+                        CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        return;
+                    }
+                }
+            }
+            case CS_Function:
+            {
+                if (CommandExecutor::getEvaluation().functionclass_)
+                {
+                    // There is a classname - search for the commandname
+                    if (CommandExecutor::argumentsGiven() > 2)
+                    {
+                        // There is a finished second argument - check if it's a commandname
+                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
+
+                        if (CommandExecutor::getEvaluation().function_)
+                        {
+                            // It's a function
+                            CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                            // Move on to next case
+                        }
+                        else
+                        {
+                            // The second argument is bad
+                            CommandExecutor::getEvaluation().state_ = CS_Error;
+                            AddLanguageEntry("commandexecutorunknownsecondargument", "is not a function of");
+                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknownsecondargument") + " " + CommandExecutor::getEvaluation().functionclass_->getName() + ".";
+                            return;
+                        }
+                    }
+                    else
+                    {
+                        // There is no finished second argument - search for possibilities
+                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
+                        unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
+
+                        if (num_functions == 1)
+                        {
+                            // It's a function
+                            std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname, CommandExecutor::getEvaluation().functionclass_);
+                            if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(1)))
+                            {
+                                // Unfinished function
+                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                            }
+                            CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
+                            if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
+                            {
+                                CommandExecutor::getEvaluation().command_ += " ";
+                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                            }
+                            // Move on to next case
+                        }
+                        else if (num_functions == 0)
+                        {
+                            // No possibilities
+                            CommandExecutor::getEvaluation().state_ = CS_Error;
+                            AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
+                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";
+                            return;
+                        }
+                        else
+                        {
+                            // There are several possibilities
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
+                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                            return;
+                        }
+                    }
+                }
+                else
+                {
+                    // There is no classname - move on to CS_ParamPreparation
+                }
+            }
+            case CS_ParamPreparation:
+            {
+                if (CommandExecutor::getEvaluation().function_->getParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))
+                {
+                    CommandExecutor::getEvaluation().state_ = CS_Finished;
+                    return;
+                }
+                else
+                {
+                    unsigned int argumentNumber = CommandExecutor::argumentsGiven() - 2;
+                    if (CommandExecutor::getEvaluation().functionclass_)
+                        argumentNumber -= 1;
+
+                    CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
+                    CommandExecutor::getEvaluation().state_ = CS_Params;
+
+                    if (CommandExecutor::getEvaluation().bCommandChanged_)
+                    {
+                        // Don't do more than one change
+                        return;
+                    }
+                }
+            }
+            case CS_Params:
+            {
+                if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 1)
+                {
+                    // There is exactly one possible argument
+                    CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
+                    CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
+                    CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                    return;
+                }
+                else if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 0)
+                {
+                    // The user tries something new - we let him do
+                    CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getLastArgument();
+                    return;
+                }
+                else
+                {
+                    // There are several possibilities
+                    unsigned int argumentNumber = CommandExecutor::argumentsGiven();
+                    if (argumentNumber > 0)
+                        --argumentNumber;
+                    if (CommandExecutor::getEvaluation().functionclass_ && argumentNumber > 0)
+                        --argumentNumber;
+
+                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleArguments_);
+                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
+                    CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                    return;
+                }
+            }
+            case CS_Finished:
+            {
+                // Nothing more to do
+                break;
+            }
+            case CS_Error:
+            {
+                // Bad, very bad
+                break;
+            }
+        }
+    }
+
+    unsigned int CommandExecutor::argumentsFinished()
+    {
+        unsigned int argumentsGiven = CommandExecutor::argumentsGiven();
+        if (argumentsGiven > 0)
+            return argumentsGiven - 1;
+        else
+            return 0;
+    }
+
+    unsigned int CommandExecutor::argumentsGiven()
+    {
+        if (CommandExecutor::getEvaluation().command_.size() > 0 && CommandExecutor::getEvaluation().command_[CommandExecutor::getEvaluation().command_.size() - 1] == ' ')
+            return CommandExecutor::getEvaluation().commandTokens_.size() + 1;
+        else
+            return CommandExecutor::getEvaluation().commandTokens_.size();
+    }
+
+    bool CommandExecutor::enoughArgumentsGiven(ConsoleCommand* command)
+    {
+        if (CommandExecutor::getEvaluation().functionclass_)
+            return (CommandExecutor::argumentsGiven() > (2 + command->getParamCount()));
+        else
+            return (CommandExecutor::argumentsGiven() > (1 + command->getParamCount()));
+    }
+
+    std::string CommandExecutor::getArgument(unsigned int index)
+    {
+        if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
+            return CommandExecutor::getEvaluation().commandTokens_[index];
+        else
+            return "";
+    }
+
+    std::string CommandExecutor::getLastArgument()
+    {
+        return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1);
+    }
+
+    void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment)
+    {
+        CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
+        std::string lowercase = getLowercase(fragment);
+        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)
+            if ((*it).second->hasConsoleCommands())
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+    }
+
+    void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier)
+    {
+        CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear();
+        std::string lowercase = getLowercase(fragment);
+        if (!identifier)
+        {
+            for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+        }
+        else
+        {
+            for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+        }
+    }
+
+    void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param)
+    {
+        CommandExecutor::createArgumentCompletionList(command, param);
+
+        CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
+        std::string lowercase = getLowercase(fragment);
+        for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
+        {
+            if ((*it).lowercaseComparison())
+            {
+                if ((*it).getComparable().find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
+            }
+            else
+            {
+                if ((*it).getComparable().find(fragment) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
+            }
+        }
+    }
+
+    Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
+    {
+        std::string lowercase = getLowercase(name);
+        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMap().find(lowercase);
+        if ((it != Identifier::getLowercaseIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
+            return (*it).second;
+
+        return 0;
+    }
+
+    ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
+    {
+        std::string lowercase = getLowercase(name);
+        if (!identifier)
+        {
+            std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);
+            if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd())
+                return (*it).second;
+        }
+        else
+        {
+            std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
+            if (it != identifier->getLowercaseConsoleCommandMapEnd())
+                return (*it).second;
+        }
+        return 0;
+    }
+
+    std::string CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
+    {
+        CommandExecutor::createArgumentCompletionList(command, param);
+
+        std::string lowercase = getLowercase(name);
+        for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
+        {
+            if ((*it).lowercaseComparison())
+            {
+                if ((*it).getComparable() == lowercase)
+                    return (*it).getString();
+            }
+            else
+            {
+                if ((*it).getComparable() == name)
+                    return (*it).getString();
+            }
+        }
+
+        return "";
+    }
+
+    void CommandExecutor::createArgumentCompletionList(ConsoleCommand* command, unsigned int param)
+    {
+        std::string params[5];
+
+        unsigned int index = 0;
+        unsigned int lowestIndex = 1 + (CommandExecutor::getEvaluation().functionclass_ != 0);
+
+        for (unsigned int i = CommandExecutor::argumentsGiven() - 1; i >= lowestIndex; --i)
+        {
+            params[index] = CommandExecutor::getArgument(i);
+            ++index;
+            if (index >= 5)
+                break;
+        }
+
+        command->createArgumentCompletionList(param, params[0], params[1], params[2], params[3], params[4]);
+    }
+
+    std::string CommandExecutor::getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list)
+    {
+        if (list.size() == 0)
+        {
+            return "";
+        }
+        else if (list.size() == 1)
+        {
+            return ((*(*list.begin()).first) + " ");
+        }
+        else
+        {
+            std::string output = "";
+            for (unsigned int i = 0; true; i++)
+            {
+                char temp = 0;
+                for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
+                {
+                    if ((*(*it).first).size() > i)
+                    {
+                        if (it == list.begin())
+                        {
+                            temp = (*(*it).first)[i];
+                        }
+                        else
+                        {
+                            if (temp != (*(*it).first)[i])
+                                return output;
+                        }
+                    }
+                    else
+                    {
+                        return output;
+                    }
+                }
+                output += temp;
+            }
+            return output;
+        }
+    }
+
+    std::string CommandExecutor::getCommonBegin(const ArgumentCompletionList& list)
+    {
+        if (list.size() == 0)
+        {
+            return "";
+        }
+        else if (list.size() == 1)
+        {
+            return ((*list.begin()).getComparable() + " ");
+        }
+        else
+        {
+            std::string output = "";
+            for (unsigned int i = 0; true; i++)
+            {
+                char temp = 0;
+                for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+                {
+                    std::string argument = (*it).getComparable();
+                    if (argument.size() > i)
+                    {
+                        if (it == list.begin())
+                        {
+                            temp = argument[i];
+                        }
+                        else
+                        {
+                            if (temp != argument[i])
+                                return output;
+                        }
+                    }
+                    else
+                    {
+                        return output;
+                    }
+                }
+                output += temp;
+            }
+            return output;
+        }
+    }
+}
Index: /code/branches/physics/src/core/CommandExecutor.h
===================================================================
--- /code/branches/physics/src/core/CommandExecutor.h	(revision 2122)
+++ /code/branches/physics/src/core/CommandExecutor.h	(revision 2122)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandExecutor_H__
+#define _CommandExecutor_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+
+#include "CommandEvaluation.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+    class _CoreExport CommandExecutor
+    /*
+    class CommandExecutor { // tolua_export
+    */
+    {
+        public:
+            static bool execute(const std::string& command, bool useTcl = true); // tolua_export
+            static std::string complete(const std::string& command);
+            static std::string hint(const std::string& command);
+
+            static CommandEvaluation evaluate(const std::string& command);
+            static const CommandEvaluation& getLastEvaluation();
+
+            static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command);
+            static ConsoleCommand* getConsoleCommandShortcut(const std::string& name);
+            static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name);
+
+            /** @brief Returns the map that stores all console commands. @return The const_iterator */
+            static inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); }
+
+            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            static inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }
+
+        private:
+            CommandExecutor() {}
+            CommandExecutor(const CommandExecutor& other);
+            ~CommandExecutor() {}
+
+            static CommandExecutor& getInstance();
+            static CommandEvaluation& getEvaluation();
+
+            static void parseIfNeeded(const std::string& command);
+            static void parse(const std::string& command, bool bInitialize = true);
+
+            static unsigned int argumentsFinished();
+            static unsigned int argumentsGiven();
+            static bool enoughArgumentsGiven(ConsoleCommand* command);
+            static std::string getArgument(unsigned int index);
+            static std::string getLastArgument();
+
+            static void createListOfPossibleIdentifiers(const std::string& fragment);
+            static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
+            static void createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param);
+
+            static Identifier* getPossibleIdentifier(const std::string& name);
+            static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
+            static std::string getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
+
+            static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param);
+            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
+            static std::string getCommonBegin(const ArgumentCompletionList& list);
+
+            CommandEvaluation evaluation_;
+            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_;
+            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_;
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _CommandExecutor_H__ */
Index: /code/branches/physics/src/core/CommandLine.cc
===================================================================
--- /code/branches/physics/src/core/CommandLine.cc	(revision 2122)
+++ /code/branches/physics/src/core/CommandLine.cc	(revision 2122)
@@ -0,0 +1,327 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandLine.h"
+
+#include "util/String.h"
+#include "util/SubString.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(optionsFile, "start.ini").shortcut("o");
+
+    /**
+    @brief
+        Parses a value string for a command line argument.
+        It simply uses convertValue(Output, Input) to do that.
+        Bools are treated specially. That is necessary
+        so that you can have simple command line switches.
+    */
+    void CommandLineArgument::parse(const std::string& value)
+    {
+        if (value_.getType() == MT_bool)
+        {
+            // simulate command line switch
+            bool temp;
+            if (convertValue(&temp, value))
+            {
+                this->bHasDefaultValue_ = false;
+                this->value_ = temp;
+            }
+            else if (value == "")
+            {
+                this->bHasDefaultValue_ = false;
+                this->value_ = true;
+            }
+            else
+            {
+                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+            }
+        }
+        else
+        {
+            if (!value_.setValue(value))
+            {
+                value_.setValue(defaultValue_);
+                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+            }
+            else
+                this->bHasDefaultValue_ = false;
+        }
+    }
+
+
+    /**
+    @brief
+        Destructor destroys all CommandLineArguments with it.
+    */
+    CommandLine::~CommandLine()
+    {
+        for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+            it != cmdLineArgs_.end(); ++it)
+        {
+            delete it->second;
+        }
+    }
+
+    /**
+    @brief
+        Returns a unique instance (Meyers Singleton).
+    */
+    CommandLine& CommandLine::_getInstance()
+    {
+        static CommandLine instance;
+        return instance;
+    }
+
+    /**
+    @brief
+        Reads the command line parses the values of each argument.
+        It is then stored in the corresponding CommandLineArgument.
+    @note
+        The reason that you have to provide the string to be parsed as
+        space separted list is because of argc and argv. If you only have
+        a whole string, simply use getAllStrings() of SubString.
+    @param arguments
+        Vector of space separated strings.
+    */
+    void CommandLine::_parse(const std::vector<std::string>& arguments)
+    {
+        // why this? See bFirstTimeParse_ declaration.
+        if (bFirstTimeParse_)
+        {
+            // first shove all the shortcuts in a map
+            for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+                it != cmdLineArgs_.end(); ++it)
+            {
+                OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
+                    "Cannot have two command line shortcut with the same name.");
+                if (it->second->getShortcut() != "")
+                    cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+            }
+            bFirstTimeParse_ = false;
+        }
+
+        std::string name;
+        std::string shortcut;
+        std::string value;
+        for (unsigned int i = 0; i < arguments.size(); ++i)
+        {
+            if (arguments[i].size() != 0)
+            {
+                // sure not ""
+                if (arguments[i][0] == '-')
+                {
+                    // start with "-"
+                    if (arguments[i].size() == 1)
+                    {
+                        // argument[i] is "-", probably a minus sign
+                        value += "- ";
+                    }
+                    else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
+                    {
+                        // negative number as a value
+                        value += arguments[i] + " ";
+                    }
+                    else
+                    {
+                        // can be shortcut or full name argument
+
+                        // save old data first
+                        value = removeTrailingWhitespaces(value);
+                        if (name != "")
+                        {
+                            checkFullArgument(name, value);
+                            name = "";
+                            assert(shortcut == "");
+                        }
+                        else if (shortcut != "")
+                        {
+                            checkShortcut(shortcut, value);
+                            shortcut = "";
+                            assert(name == "");
+                        }
+
+                        if (arguments[i][1] == '-')
+                        {
+                            // full name argument with "--name"
+                            name = arguments[i].substr(2);
+                        }
+                        else
+                        {
+                            // shortcut with "-s"
+                            shortcut = arguments[i].substr(1);
+                        }
+
+                        // reset value string
+                        value = "";
+                    }
+                }
+                else
+                {
+                    // value string
+
+                    if (name == "" && shortcut == "")
+                    {
+                        ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
+                    }
+
+                    // Concatenate strings as long as there's no new argument by "-" or "--"
+                    value += arguments[i] + ' ';
+                }
+            }
+        }
+
+        // parse last argument
+        value = removeTrailingWhitespaces(value);
+        if (name != "")
+        {
+            checkFullArgument(name, value);
+            assert(shortcut == "");
+        }
+        else if (shortcut != "")
+        {
+            checkShortcut(shortcut, value);
+            assert(name == "");
+        }
+    }
+
+    /**
+    @brief
+        Parses an argument based on its full name.
+    @param name
+        Full name of the argument
+    @param value
+        String containing the value
+    */
+    void CommandLine::checkFullArgument(const std::string& name, const std::string& value)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
+        if (it == cmdLineArgs_.end())
+            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    /**
+    @brief
+        Parses an argument based on its shortcut.
+    @param shortcut
+        Shotcut to the argument
+    @param value
+        String containing the value
+    */
+    void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
+        if (it == cmdLineArgsShortcut_.end())
+            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    std::string CommandLine::getUsageInformation()
+    {
+        CommandLine* inst = &_getInstance();
+        std::string infoStr;
+        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin();
+            it != inst->cmdLineArgs_.end(); ++it)
+        {
+            infoStr += "[--" + it->second->getName() + " " + it->second->getInformation() + "] ";
+        }
+        return infoStr;
+    }
+
+    /**
+    @brief
+        Retrieves a CommandLineArgument.
+        The method throws an exception if 'name' was not found or the value could not be converted.
+    @note
+        You shold of course not call this method before the command line has been parsed.
+    */
+    const CommandLineArgument* CommandLine::getArgument(const std::string& name)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        if (it == _getInstance().cmdLineArgs_.end())
+        {
+            ThrowException(Argument, "Could find command line argument '" + name + "'.");
+        }
+        else
+        {
+            return it->second;
+        }
+    }
+
+    /**
+    @brief
+        Parses both command line and start.ini for CommandLineArguments.
+    */
+    void CommandLine::_parseAll(int argc, char** argv)
+    {
+        // parse command line first
+        std::vector<std::string> args;
+        for (int i = 1; i < argc; ++i)
+            args.push_back(argv[i]);
+        this->_parse(args);
+
+        // look for additional arguments in given file or start.ini as default
+        // They will not overwrite the arguments given directly
+        std::ifstream file;
+        std::string filename = CommandLine::getValue("optionsFile").getString();
+        file.open(filename.c_str());
+        args.clear();
+        if (file)
+        {
+            while (!file.eof())
+            {
+                std::string line;
+                std::getline(file, line);
+                line = removeTrailingWhitespaces(line);
+                //if (!(line[0] == '#' || line[0] == '%'))
+                //{
+                SubString tokens(line, " ", " ", false, 92, false, 34, false, 40, 41, false, '#');
+                for (unsigned i = 0; i < tokens.size(); ++i)
+                    if (tokens[i][0] != '#')
+                        args.push_back(tokens[i]);
+                //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
+                //}
+            }
+            file.close();
+        }
+
+        try
+        {
+            _parse(args);
+        }
+        catch (orxonox::ArgumentException& ex)
+        {
+            COUT(1) << "An Exception occured while parsing " << filename << std::endl;
+            throw(ex);
+        }
+    }
+}
Index: /code/branches/physics/src/core/CommandLine.h
===================================================================
--- /code/branches/physics/src/core/CommandLine.h	(revision 2122)
+++ /code/branches/physics/src/core/CommandLine.h	(revision 2122)
@@ -0,0 +1,210 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandLine_H__
+#define _CommandLine_H__
+
+#include "CorePrereqs.h"
+#include <map>
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "util/MultiType.h"
+
+#define SetCommandLineArgument(name, defaultValue) \
+    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLine::addArgument(#name, defaultValue)
+#define SetCommandLineSwitch(name) \
+    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLine::addArgument(#name, false)
+
+
+namespace orxonox
+{
+    /**
+    @brief
+        Container class for a command line argument of any type supported by MultiType.
+
+        Whenever you want to have an option specified by a command line switch,
+        you need to first define it with SetCommandLineArgument(name, defaultValue).
+        It is then added to a map and possibly changed when the command line is being parsed.
+        If the option was not given, you can detect this by asking hasDefaultValue().
+
+        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
+        Note the difference between "-" and "--"!
+        Also, there is no restriction to the number of strings you add after --name.
+        So "--startVector (2, 4, 5)" is perfectly legal.
+
+        Retrieving an argument is possible with the getCommandLineArgument function of the
+        CommandLine class. It is a Singleton, but the public interface is static.
+    */
+    class _CoreExport CommandLineArgument
+    {
+        friend class CommandLine;
+
+    public:
+        //! Tells whether the value has been changed by the command line.
+        bool hasDefaultValue() const { return bHasDefaultValue_; }
+        //! Returns the name of the argument.
+        const std::string& getName() const { return name_; }
+
+        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
+        //! Evaluates to "" if none there is none.
+        const std::string& getShortcut() const { return shortcut_; }
+        //! Sets the shortcut for the argument
+        CommandLineArgument& shortcut(const std::string& shortcut)
+        { this->shortcut_ = shortcut; return *this; }
+
+        //! Returns the usage information
+        const std::string& getInformation() const { return this->usageInformation_; }
+        //! Sets the option information when displaying orxonox usage.
+        CommandLineArgument& information(const std::string& usage)
+        { this->usageInformation_ = usage; return *this; }
+
+        //! Returns the actual value of the argument. Can be equal to default value.
+        MultiType getValue() const { return value_; }
+        //! Returns the given default value as type T.
+        MultiType getDefaultValue() const { return defaultValue_; }
+
+    private:
+        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
+        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
+            : bHasDefaultValue_(true)
+            , name_(name)
+            , value_(defaultValue)
+            , defaultValue_(defaultValue)
+        { }
+
+        //! Undefined copy constructor
+        CommandLineArgument(const CommandLineArgument& instance);
+        ~CommandLineArgument() { }
+
+        //! Parses the value string of a command line argument.
+        void parse(const std::string& value);
+
+        //! Tells whether the value has been changed by the command line.
+        bool bHasDefaultValue_;
+
+    private:
+        std::string name_;             //!< Name of the argument
+        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
+        std::string usageInformation_; //!< Tells about the usage of this parameter
+
+        MultiType value_;            //!< The actual value
+        MultiType defaultValue_;     //!< Default value. Should not be changed.
+    };
+
+
+    /**
+    @brief
+        Global interface to command line options.
+        Allows to add and retrieve command line arguments. Also does the parsing.
+    @note
+        Internally it is a Singleton, but the public interface is static.
+    @see
+        CommandLineArgument
+    */
+    class _CoreExport CommandLine
+    {
+    public:
+
+        //! Parse redirection to internal member method.
+        static void parseAll(int argc, char** argv) { _getInstance()._parseAll(argc, argv); }
+
+        static std::string getUsageInformation();
+
+        static const CommandLineArgument* getArgument(const std::string& name);
+        //! Writes the argument value in the given parameter.
+        template <class T>
+        static void getValue(const std::string& name, T* value)
+        { *value = (T)(getArgument(name)->getValue()); }
+        static MultiType getValue(const std::string& name)
+        { return getArgument(name)->getValue(); }
+        template <class T>
+        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
+
+        static bool existsArgument(const std::string& name)
+        {
+            std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+            return !(it == _getInstance().cmdLineArgs_.end());
+        }
+
+
+    private:
+        //! Constructor initialises bFirstTimeParse_ with true.
+        CommandLine() : bFirstTimeParse_(true) { }
+        //! Undefined copy constructor
+        CommandLine(const CommandLine& instance);
+        ~CommandLine();
+
+        static CommandLine& _getInstance();
+
+        void _parseAll(int argc, char** argv);
+        void _parse(const std::vector<std::string>& arguments);
+        void checkFullArgument(const std::string& name, const std::string& value);
+        void checkShortcut(const std::string& shortcut, const std::string& value);
+
+        /**
+            Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
+            So when we call parse() the first time, we need to create a map with all shortcuts since these
+            get added after addCommandLineArgument().
+        */
+        bool bFirstTimeParse_;
+
+        //! Holds all pointers to the arguments and serves as a search map by name.
+        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
+        //! Search map by chortcut for the arguments.
+        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
+    };
+
+    template <>
+    inline void CommandLine::getValue<std::string>(const std::string& name, std::string* value)
+    {
+        *value = (std::string)(getArgument(name)->getValue().getString());
+    }
+
+    /**
+    @brief
+        Adds a new CommandLineArgument to the internal map.
+        Note that only such arguments are actually valid.
+    @param name
+        Name of the argument. Shortcut can be added later.
+    @param defaultValue
+        Default value that is used when argument was not given.
+    */
+    template <class T>
+    CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue)
+    {
+        OrxAssert(!_getInstance().existsArgument(name),
+            "Cannot add a command line argument with name '" + name + "' twice.");
+
+        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
+    }
+}
+
+#endif /* _CommandLine_H__ */
Index: /code/branches/physics/src/core/ConfigFileManager.cc
===================================================================
--- /code/branches/physics/src/core/ConfigFileManager.cc	(revision 2122)
+++ /code/branches/physics/src/core/ConfigFileManager.cc	(revision 2122)
@@ -0,0 +1,573 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConfigFileManager.h"
+
+#include <cassert>
+#include "util/Convert.h"
+#include "util/String.h"
+#include "ConsoleCommand.h"
+#include "ConfigValueContainer.h"
+
+namespace orxonox
+{
+    const int CONFIG_FILE_MAX_LINELENGHT  = 1024;
+    const char* const DEFAULT_CONFIG_FILE = "default.ini";
+
+    ConfigFileManager* ConfigFileManager::singletonRef_s = 0;
+
+    SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
+    SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
+    SetConsoleCommandShortcutExtern(reloadConfig);
+    SetConsoleCommandShortcutExtern(cleanConfig);
+    SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files());
+
+    bool config(const std::string& classname, const std::string& varname, const std::string& value)
+    {
+        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
+        if (identifier != Identifier::getLowercaseIdentifierMapEnd())
+        {
+            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
+            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+                return (*variable).second->set(value);
+        }
+        return false;
+    }
+
+    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
+    {
+        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
+        if (identifier != Identifier::getLowercaseIdentifierMapEnd())
+        {
+            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
+            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+                return (*variable).second->tset(value);
+        }
+        return false;
+    }
+
+    void reloadConfig()
+    {
+        ConfigFileManager::getInstance().load();
+    }
+
+    void cleanConfig()
+    {
+        ConfigFileManager::getInstance().clean(false);
+    }
+
+    void loadSettings(const std::string& filename)
+    {
+        ConfigFileManager::getInstance().setFilename(ConfigFileType::Settings, filename);
+    }
+
+    //////////////////////////
+    // ConfigFileEntryValue //
+    //////////////////////////
+
+    void ConfigFileEntryValue::setValue(const std::string& value)
+    {
+        if (!this->bString_)
+            this->value_ = value;
+        else
+            this->value_ = "\"" + addSlashes(stripEnclosingQuotes(value)) + "\"";
+    }
+
+    std::string ConfigFileEntryValue::getValue() const
+    {
+        if (!this->bString_)
+            return this->value_;
+        else
+            return removeSlashes(stripEnclosingQuotes(this->value_));
+    }
+
+    std::string ConfigFileEntryValue::getFileEntry() const
+    {
+        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
+            return (this->name_ + "=" + this->value_);
+        else
+            return (this->name_ + "=" + this->value_ + " " + this->additionalComment_);
+    }
+
+
+    ////////////////////////////////
+    // ConfigFileEntryVectorValue //
+    ////////////////////////////////
+    std::string ConfigFileEntryVectorValue::getFileEntry() const
+    {
+        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
+            return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]" + "=" + this->value_);
+        else
+            return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]=" + this->value_ + " " + this->additionalComment_);
+    }
+
+
+    ///////////////////////
+    // ConfigFileSection //
+    ///////////////////////
+    ConfigFileSection::~ConfigFileSection()
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); )
+            delete (*(it++));
+    }
+
+    void ConfigFileSection::deleteVectorEntries(const std::string& name, unsigned int startindex)
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); )
+        {
+            if (((*it)->getName() == name) && ((*it)->getIndex() >= startindex))
+            {
+                delete (*it);
+                this->entries_.erase(it++);
+            }
+            else
+            {
+                ++it;
+            }
+        }
+    }
+
+    unsigned int ConfigFileSection::getVectorSize(const std::string& name)
+    {
+        unsigned int size = 0;
+        for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+            if ((*it)->getName() == name)
+                if ((*it)->getIndex() > size)
+                    size = (*it)->getIndex();
+        return (size + 1);
+    }
+
+    std::string ConfigFileSection::getFileEntry() const
+    {
+        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
+            return ("[" + this->name_ + "]");
+        else
+            return ("[" + this->name_ + "] " + this->additionalComment_);
+    }
+
+    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, const std::string& fallback, bool bString)
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+        {
+            if ((*it)->getName() == name)
+            {
+                (*it)->setString(bString);
+                return it;
+            }
+        }
+
+        this->bUpdated_ = true;
+
+        return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryValue(name, fallback, bString)));
+    }
+
+    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+        {
+            if (((*it)->getName() == name) && ((*it)->getIndex() == index))
+            {
+                (*it)->setString(bString);
+                return it;
+            }
+        }
+
+        this->bUpdated_ = true;
+
+        if (index == 0)
+            return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+        else
+            return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+    }
+
+
+    ////////////////
+    // ConfigFile //
+    ////////////////
+    ConfigFile::~ConfigFile()
+    {
+        this->clear();
+    }
+
+    void ConfigFile::load(bool bCreateIfNotExisting)
+    {
+        // Be sure we start from new
+        this->clear();
+
+        // This creates the config file if it's not existing
+        std::ofstream createFile;
+        createFile.open(this->filename_.c_str(), std::fstream::app);
+        createFile.close();
+
+        // Open the file
+        std::ifstream file;
+        file.open(this->filename_.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in ConfigFileManager.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open config-file \"" << this->filename_ << "\"." << std::endl;
+            return;
+        }
+
+        char linearray[CONFIG_FILE_MAX_LINELENGHT];
+
+        ConfigFileSection* newsection = 0;
+
+        while (file.good() && !file.eof())
+        {
+            file.getline(linearray, CONFIG_FILE_MAX_LINELENGHT);
+
+            std::string line = std::string(linearray);
+
+            std::string temp = getStripped(line);
+            if (!isEmpty(temp) && !isComment(temp))
+            {
+                size_t   pos1 = temp.find('[');
+                if (pos1 == 0) pos1 = line.find('['); else pos1 = std::string::npos;
+                size_t   pos2 = line.find(']');
+
+                if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1)
+                {
+                    // New section
+                    std::string comment = line.substr(pos2 + 1);
+                    if (isComment(comment))
+                        newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
+                    else
+                        newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1));
+                    this->sections_.insert(this->sections_.end(), newsection);
+                    continue;
+                }
+            }
+
+            if (newsection != 0)
+            {
+                if (isComment(line))
+                {
+                    // New comment
+                    newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryComment(removeTrailingWhitespaces(line)));
+                    continue;
+                }
+                else
+                {
+                    size_t pos1 = line.find('=');
+
+                    if (pos1 != std::string::npos && pos1 > 0)
+                    {
+                        // New entry
+                        size_t pos2 = line.find('[');
+                        size_t pos3 = line.find(']');
+                        size_t commentposition = getNextCommentPosition(line, pos1 + 1);
+                        while (isBetweenQuotes(line, commentposition))
+                        {
+                            commentposition = getNextCommentPosition(line, commentposition + 1);
+                        }
+                        std::string value = "", comment = "";
+                        if (commentposition == std::string::npos)
+                        {
+                            value = removeTrailingWhitespaces(line.substr(pos1 + 1));
+                        }
+                        else
+                        {
+                            value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));
+                            comment = removeTrailingWhitespaces(line.substr(commentposition));
+                        }
+
+                        if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1)
+                        {
+                            // There might be an array index
+                            unsigned int index = 0;
+                            if (ConvertValue(&index, line.substr(pos2 + 1, pos3 - pos2 - 1)))
+                            {
+                                // New array
+                                std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
+                                (*it)->setValue(value);
+                                (*it)->setComment(comment);
+                                continue;
+                            }
+                        }
+
+                        // New value
+                        newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryValue(getStripped(line.substr(0, pos1)), value, false, comment));
+                        continue;
+                    }
+                }
+            }
+        }
+
+        file.close();
+
+        COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
+
+        // Save the file in case something changed (like stripped whitespaces)
+        this->save();
+
+        // Update all ConfigValueContainers
+        this->updateConfigValues();
+    }
+
+    void ConfigFile::save() const
+    {
+        std::ofstream file;
+        file.open(this->filename_.c_str(), std::fstream::out);
+        file.setf(std::ios::fixed, std::ios::floatfield);
+        file.precision(6);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in ConfigFileManager.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open config-file \"" << this->filename_ << "\"." << std::endl;
+            return;
+        }
+
+        for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+        {
+            file << (*it)->getFileEntry() << std::endl;
+
+            for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)
+            {
+                file << (*it_entries)->getFileEntry() << std::endl;
+            }
+
+            file << std::endl;
+        }
+
+        file.close();
+
+        COUT(4) << "Saved config file \"" << this->filename_ << "\"." << std::endl;
+    }
+
+    void ConfigFile::saveAs(const std::string& filename)
+    {
+        std::string temp = this->filename_;
+        this->filename_ = filename;
+        this->save();
+        this->filename_ = temp;
+    }
+
+    void ConfigFile::clean(bool bCleanComments)
+    {
+        for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
+        {
+            std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getIdentifierMap().find((*it1)->getName());
+            if (it2 != Identifier::getIdentifierMapEnd() && (*it2).second->hasConfigValues())
+            {
+                // The section exists, delete comment
+                if (bCleanComments)
+                    (*it1)->setComment("");
+                for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); )
+                {
+                    std::map<std::string, ConfigValueContainer*>::const_iterator it4 = (*it2).second->getConfigValueMap().find((*it3)->getName());
+                    if (it4 != (*it2).second->getConfigValueMapEnd())
+                    {
+                        // The config-value exists, delete comment
+                        if (bCleanComments)
+                            (*it3)->setComment("");
+                        ++it3;
+                    }
+                    else
+                    {
+                        // The config-value doesn't exist
+                        delete (*it3);
+                        (*it1)->entries_.erase(it3++);
+                    }
+                }
+                ++it1;
+            }
+            else
+            {
+                // The section doesn't exist
+                delete (*it1);
+                this->sections_.erase(it1++);
+            }
+        }
+
+        // Save the file
+        this->save();
+    }
+
+    void ConfigFile::clear()
+    {
+        for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); )
+            delete (*(it++));
+        this->sections_.clear();
+    }
+
+    ConfigFileSection* ConfigFile::getSection(const std::string& section)
+    {
+        for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+            if ((*it)->getName() == section)
+                return (*it);
+
+        this->bUpdated_ = true;
+
+        return (*this->sections_.insert(this->sections_.end(), new ConfigFileSection(section)));
+    }
+
+    void ConfigFile::saveIfUpdated()
+    {
+        bool sectionsUpdated = false;
+
+        for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+        {
+            if ((*it)->bUpdated_)
+            {
+                sectionsUpdated = true;
+                (*it)->bUpdated_ = false;
+            }
+        }
+
+        if (this->bUpdated_ || sectionsUpdated)
+        {
+            this->bUpdated_ = false;
+            this->save();
+        }
+    }
+
+    void ConfigFile::updateConfigValues()
+    {
+        if (this->type_ == ConfigFileType::Settings)
+        {
+            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
+            {
+                if (it->second->hasConfigValues())
+                {
+                    for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = (*it).second->getConfigValueMapBegin(); it2 != (*it).second->getConfigValueMapEnd(); ++it2)
+                        it2->second->update();
+
+                    it->second->updateConfigValues();
+                }
+            }
+        }
+    }
+
+
+    ///////////////////////
+    // ConfigFileManager //
+    ///////////////////////
+
+    ConfigFileManager::ConfigFileManager()
+         : mininmalFreeType_(ConfigFileType::numberOfReservedTypes)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+    }
+
+    ConfigFileManager::~ConfigFileManager()
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); )
+            delete (it++)->second;
+
+        assert(singletonRef_s != 0);
+        singletonRef_s = 0;
+    }
+
+    void ConfigFileManager::setFilename(ConfigFileType type, const std::string& filename)
+    {
+        std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
+        if (it != this->configFiles_.end())
+        {
+            assert(it->second);
+            delete it->second;
+        }
+        this->configFiles_[type] = new ConfigFile(filename, type);
+        this->load(type);
+    }
+
+    void ConfigFileManager::load()
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            it->second->load();
+    }
+
+    void ConfigFileManager::save()
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            it->second->save();
+    }
+
+    void ConfigFileManager::clean(bool bCleanComments)
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            this->clean(it->first, bCleanComments);
+    }
+
+    void ConfigFileManager::load(ConfigFileType type)
+    {
+        this->getFile(type)->load();
+    }
+
+    void ConfigFileManager::save(ConfigFileType type)
+    {
+        this->getFile(type)->save();
+    }
+
+    void ConfigFileManager::saveAs(ConfigFileType type, const std::string& saveFilename)
+    {
+        this->getFile(type)->saveAs(saveFilename);
+    }
+
+    void ConfigFileManager::clean(ConfigFileType type, bool bCleanComments)
+    {
+        this->getFile(type)->clean(bCleanComments);
+    }
+
+    void ConfigFileManager::updateConfigValues()
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            it->second->updateConfigValues();
+    }
+
+    void ConfigFileManager::updateConfigValues(ConfigFileType type)
+    {
+        this->getFile(type)->updateConfigValues();
+    }
+
+    const std::string& ConfigFileManager::getFilename(ConfigFileType type)
+    {
+        std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
+        if (it != this->configFiles_.end())
+            return it->second->getFilename();
+        else
+            return BLANKSTRING;
+    }
+
+    ConfigFile* ConfigFileManager::getFile(ConfigFileType type)
+    {
+        std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
+        if (it != this->configFiles_.end())
+            return it->second;
+        else
+        {
+            COUT(1) << "ConfigFileManager: Can't find a config file for type with ID " << (int)type << std::endl;
+            COUT(1) << "Using " << DEFAULT_CONFIG_FILE << " file." << std::endl;
+            this->setFilename(type, DEFAULT_CONFIG_FILE);
+            return getFile(type);
+        }
+    }
+}
Index: /code/branches/physics/src/core/ConfigFileManager.h
===================================================================
--- /code/branches/physics/src/core/ConfigFileManager.h	(revision 2122)
+++ /code/branches/physics/src/core/ConfigFileManager.h	(revision 2122)
@@ -0,0 +1,332 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ConfigFileManager_H__
+#define _ConfigFileManager_H__
+
+#include "CorePrereqs.h"
+
+#include <iostream>
+#include <string>
+#include <list>
+#include <map>
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    // Use unsigned int as config file type to have an arbitrary number of files
+    class ConfigFileType
+    {
+    public:
+        ConfigFileType() { }
+        ConfigFileType(unsigned int type)              { type_ = type; }
+        ConfigFileType(const ConfigFileType& instance) { type_ = instance.type_; }
+
+        operator unsigned int() { return type_; }
+        ConfigFileType& operator =(unsigned int type) { type_ = type; return *this; }
+        bool operator <(const ConfigFileType& right) const   { return (type_ < right.type_); }
+
+        /* *** Put the different config file types here *** */
+        static const unsigned int NoType              = 0;
+        static const unsigned int Settings            = 1;
+        static const unsigned int JoyStickCalibration = 2;
+
+        static const unsigned int numberOfReservedTypes = 1024;
+
+    private:
+        unsigned int type_;
+    };
+
+    bool config(const std::string& classname, const std::string& varname, const std::string& value);
+    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
+    void reloadConfig();
+    void saveConfig();
+    void cleanConfig();
+    void loadSettings(const std::string& filename);
+
+
+    /////////////////////
+    // ConfigFileEntry //
+    /////////////////////
+    class _CoreExport ConfigFileEntry
+    {
+        public:
+            virtual ~ConfigFileEntry() {};
+            virtual void setValue(const std::string& value) = 0;
+            virtual std::string getValue() const = 0;
+            virtual const std::string& getName() const = 0;
+            virtual void setComment(const std::string& comment) = 0;
+            virtual unsigned int getIndex() const { return 0; }
+            virtual void setString(bool bString) = 0;
+            virtual std::string getFileEntry() const = 0;
+    };
+
+
+    //////////////////////////
+    // ConfigFileEntryValue //
+    //////////////////////////
+    class _CoreExport ConfigFileEntryValue : public ConfigFileEntry
+    {
+        public:
+            inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : name_(name), value_(value), bString_(bString), additionalComment_(additionalComment) {}
+            inline virtual ~ConfigFileEntryValue() {}
+
+            inline virtual const std::string& getName() const
+                { return this->name_; }
+
+            inline virtual void setComment(const std::string& comment)
+                { this->additionalComment_ = comment; }
+
+            virtual void setValue(const std::string& value);
+            virtual std::string getValue() const;
+
+            inline bool isString() const
+                { return this->bString_; }
+            inline void setString(bool bString)
+                { this->bString_ = bString; }
+
+            virtual std::string getFileEntry() const;
+
+        protected:
+            std::string name_;
+            std::string value_;
+            bool bString_;
+            std::string additionalComment_;
+    };
+
+
+    ///////////////////////////////
+    // ConfigFileEntryVectorValue //
+    ///////////////////////////////
+    class _CoreExport ConfigFileEntryVectorValue : public ConfigFileEntryValue
+    {
+        public:
+            inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : ConfigFileEntryValue(name, value, bString, additionalComment), index_(index) {}
+            inline virtual ~ConfigFileEntryVectorValue() {}
+
+            inline virtual unsigned int getIndex() const
+                { return this->index_; }
+
+            virtual std::string getFileEntry() const;
+
+        private:
+            unsigned int index_;
+    };
+
+
+    ////////////////////////////
+    // ConfigFileEntryComment //
+    ////////////////////////////
+    class _CoreExport ConfigFileEntryComment : public ConfigFileEntry
+    {
+        public:
+            inline ConfigFileEntryComment(const std::string& comment) : comment_(comment) {}
+            inline virtual ~ConfigFileEntryComment() {}
+
+            inline virtual const std::string& getName() const
+                { return this->comment_; }
+
+            inline virtual void setComment(const std::string& comment)
+                { this->comment_ = comment; }
+
+            inline virtual void setValue(const std::string& value)
+                {}
+            inline virtual std::string getValue() const
+                { return this->comment_; }
+
+            inline void setString(bool bString) {}
+
+            inline virtual std::string getFileEntry() const
+                { return this->comment_; }
+
+        private:
+            std::string comment_;
+    };
+
+
+    ///////////////////////
+    // ConfigFileSection //
+    ///////////////////////
+    class _CoreExport ConfigFileSection
+    {
+        friend class ConfigFile;
+
+        public:
+            inline ConfigFileSection(const std::string& name, const std::string& additionalComment = "") : name_(name), additionalComment_(additionalComment), bUpdated_(false) {}
+            ~ConfigFileSection();
+
+            inline const std::string& getName() const
+                { return this->name_; }
+
+            inline void setComment(const std::string& comment)
+                { this->additionalComment_ = comment; }
+
+            inline void setValue(const std::string& name, const std::string& value, bool bString)
+                { this->getEntry(name, value, bString)->setValue(value); }
+            inline std::string getValue(const std::string& name, const std::string& fallback, bool bString)
+                { return this->getEntry(name, fallback, bString)->getValue(); }
+
+            inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString)
+                { this->getEntry(name, index, value, bString)->setValue(value); }
+            inline std::string getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return this->getEntry(name, index, fallback, bString)->getValue(); }
+
+            void deleteVectorEntries(const std::string& name, unsigned int startindex = 0);
+            unsigned int getVectorSize(const std::string& name);
+
+            std::string getFileEntry() const;
+
+        private:
+            std::list<ConfigFileEntry*>& getEntries()
+                { return this->entries_; }
+            std::list<ConfigFileEntry*>::const_iterator getEntriesBegin() const
+                { return this->entries_.begin(); }
+            std::list<ConfigFileEntry*>::const_iterator getEntriesEnd() const
+                { return this->entries_.end(); }
+
+            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback, bool bString);
+            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
+
+            inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback, bool bString)
+                { return (*this->getEntryIterator(name, fallback, bString)); }
+            inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return (*this->getEntryIterator(name, index, fallback, bString)); }
+
+            std::string name_;
+            std::string additionalComment_;
+            std::list<ConfigFileEntry*> entries_;
+            bool bUpdated_;
+    };
+
+
+    ////////////////
+    // ConfigFile //
+    ////////////////
+    class _CoreExport ConfigFile
+    {
+        public:
+            inline ConfigFile(const std::string& filename, ConfigFileType type)
+                : filename_(filename)
+                , type_(type)
+                , bUpdated_(false)
+            { }
+            ~ConfigFile();
+
+            void load(bool bCreateIfNotExisting = true);
+            void save() const;
+            void saveAs(const std::string& filename);
+            void clean(bool bCleanComments = false);
+            void clear();
+
+            const std::string& getFilename() { return this->filename_; }
+
+            inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString)
+                { this->getSection(section)->setValue(name, value, bString); this->save(); }
+            inline std::string getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
+                { std::string output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
+
+            inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
+                { this->getSection(section)->setValue(name, index, value, bString); this->save(); }
+            inline std::string getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { std::string output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
+
+            inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
+                { this->getSection(section)->deleteVectorEntries(name, startindex); }
+            inline unsigned int getVectorSize(const std::string& section, const std::string& name)
+                { return this->getSection(section)->getVectorSize(name); }
+
+            void updateConfigValues();
+
+        private:
+            ConfigFileSection* getSection(const std::string& section);
+            void saveIfUpdated();
+
+            std::string filename_;
+            ConfigFileType type_;
+            std::list<ConfigFileSection*> sections_;
+            bool bUpdated_;
+    };
+
+
+    ///////////////////////
+    // ConfigFileManager //
+    ///////////////////////
+    class _CoreExport ConfigFileManager
+    {
+        public:
+            ConfigFileManager();
+            ~ConfigFileManager();
+
+            void load();
+            void save();
+            void clean(bool bCleanComments = false);
+
+            void setFilename(ConfigFileType type, const std::string& filename);
+            const std::string& getFilename(ConfigFileType type);
+
+            ConfigFileType getNewConfigFileType() { return mininmalFreeType_++; }
+
+            void load(ConfigFileType type);
+            void save(ConfigFileType type);
+            void saveAs(ConfigFileType type, const std::string& saveFilename);
+            void clean(ConfigFileType type, bool bCleanComments = false);
+
+            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value, bool bString)
+                { this->getFile(type)->setValue(section, name, value, bString); }
+            inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString)
+                { return this->getFile(type)->getValue(section, name, fallback, bString); }
+
+            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
+                { this->getFile(type)->setValue(section, name, index, value, bString); }
+            inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return this->getFile(type)->getValue(section, name, index, fallback, bString); }
+
+            inline void deleteVectorEntries(ConfigFileType type, const std::string& section, const std::string& name, unsigned int startindex = 0)
+                { this->getFile(type)->deleteVectorEntries(section, name, startindex); }
+            inline unsigned int getVectorSize(ConfigFileType type, const std::string& section, const std::string& name)
+                { return this->getFile(type)->getVectorSize(section, name); }
+
+            void updateConfigValues();
+            void updateConfigValues(ConfigFileType type);
+
+            static ConfigFileManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+        private:
+            ConfigFileManager(const ConfigFileManager&);
+
+            ConfigFile* getFile(ConfigFileType type);
+
+            std::map<ConfigFileType, ConfigFile*> configFiles_;
+            unsigned int mininmalFreeType_;
+
+            static ConfigFileManager* singletonRef_s;
+    };
+}
+
+#endif /* _ConfigFileManager_H__ */
Index: /code/branches/physics/src/core/ConfigValueContainer.cc
===================================================================
--- /code/branches/physics/src/core/ConfigValueContainer.cc	(revision 2122)
+++ /code/branches/physics/src/core/ConfigValueContainer.cc	(revision 2122)
@@ -0,0 +1,348 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ConfigValueContainer.cc
+    @brief Implementation of the ConfigValueContainer class.
+*/
+
+#include "ConfigValueContainer.h"
+
+#include <fstream>
+
+#include "util/SubString.h"
+#include "util/Convert.h"
+#include "Language.h"
+#include "Identifier.h"
+
+
+
+namespace orxonox
+{
+    const unsigned int MAX_VECTOR_INDEX  = 255; // to avoid up to 4*10^9 vector entries in the config file after accidentally using a wrong argument
+
+    /**
+        @brief Initializes the ConfigValueContainer with defaultvalues.
+    */
+    void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname)
+    {
+        this->type_ = type;
+        this->identifier_ = identifier;
+        this->sectionname_ = sectionname;
+        this->varname_ = varname;
+        this->callback_ = 0;
+        this->bContainerIsNew_ = true;
+        this->bDoInitialCallback_ = false;
+        this->bAddedDescription_ = false;
+    }
+
+    /**
+        @brief Does some special initialization for single config-values.
+    */
+    void ConfigValueContainer::initValue(const MultiType& defvalue)
+    {
+        this->value_ = defvalue;
+        this->bIsVector_ = false;
+
+        this->defvalueString_ = this->value_.getString();
+        this->update();
+    }
+
+    /**
+        @brief Does some special initialization for vector config-values.
+    */
+    void ConfigValueContainer::initVector()
+    {
+        this->bIsVector_ = true;
+
+        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
+        {
+            ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
+            this->defvalueStringVector_.push_back(this->valueVector_[i]);
+        }
+
+        this->update();
+    }
+
+    /**
+        @brief Destructor: Deletes the callback object if necessary.
+    */
+    ConfigValueContainer::~ConfigValueContainer()
+    {
+        if (this->callback_)
+            delete this->callback_;
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects and writes the change into the config-file.
+        @param input The new value
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::set(const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            return this->callFunctionWithIndex(&ConfigValueContainer::set, input);
+        }
+        else
+        {
+            if (this->tset(input))
+            {
+                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_string));
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects and writes the change into the config-file.
+        @param index The index in the vector
+        @param input The new value
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::set(unsigned int index, const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            if (this->tset(index, input))
+            {
+                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_string));
+                return true;
+            }
+        }
+        else
+        {
+            COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+        }
+        return false;
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary).
+        @param input The new value. If bIsVector_ then write "index value"
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::tset(const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            return this->callFunctionWithIndex(&ConfigValueContainer::tset, input);
+            return false;
+        }
+        else
+        {
+            this->value_ = input;
+
+            if (this->identifier_)
+                this->identifier_->updateConfigValues();
+
+            return true;
+        }
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary).
+        @param index The index in the vector
+        @param input The new value
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::tset(unsigned int index, const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            if (index > MAX_VECTOR_INDEX)
+            {
+                COUT(1) << "Error: Index " << index << " is too large." << std::endl;
+                return false;
+            }
+
+            if (index >= this->valueVector_.size())
+            {
+                for (unsigned int i = this->valueVector_.size(); i <= index; i++)
+                {
+                    this->valueVector_.push_back(MultiType());
+                }
+            }
+
+            this->valueVector_[index] = input;
+
+            if (this->identifier_)
+                this->identifier_->updateConfigValues();
+
+            return true;
+        }
+        else
+        {
+            COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+            return false;
+        }
+    }
+
+    /**
+        @brief Adds a new entry to the end of the vector.
+        @param input The new entry
+        @return True if the new entry was successfully added
+    */
+    bool ConfigValueContainer::add(const MultiType& input)
+    {
+        if (this->bIsVector_)
+            return this->set(this->valueVector_.size(), input);
+
+        COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+        return false;
+    }
+
+    /**
+        @brief Removes an existing entry from the vector.
+        @param index The index of the entry
+        @return True if the entry was removed
+    */
+    bool ConfigValueContainer::remove(unsigned int index)
+    {
+        if (this->bIsVector_)
+        {
+            if (index < this->valueVector_.size())
+            {
+                // Erase the entry from the vector, change (shift) all entries beginning with index in the config file, remove the last entry from the file
+                this->valueVector_.erase(this->valueVector_.begin() + index);
+                for (unsigned int i = index; i < this->valueVector_.size(); i++)
+                    ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
+                ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
+
+                return true;
+            }
+            COUT(1) << "Error: Invalid vector-index." << std::endl;
+        }
+
+        COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+        return false;
+    }
+
+    /**
+        @brief Sets the value of the variable back to the default value and resets the config-file entry.
+    */
+    bool ConfigValueContainer::reset()
+    {
+        if (!this->bIsVector_)
+            return this->set(this->defvalueString_);
+        else
+        {
+            bool success = true;
+            for (unsigned int i = 0; i < this->defvalueStringVector_.size(); i++)
+                if (!this->set(i, this->defvalueStringVector_[i]))
+                    success = false;
+            ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size());
+            return success;
+        }
+    }
+
+    /**
+        @brief Retrieves the configured value from the currently loaded config-file.
+    */
+    void ConfigValueContainer::update()
+    {
+        if (!this->bIsVector_)
+            this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_string));
+        else
+        {
+            this->valueVector_.clear();
+            for (unsigned int i = 0; i < ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_); i++)
+            {
+                if (i < this->defvalueStringVector_.size())
+                {
+                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_string));
+                }
+                else
+                {
+                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_string));
+                }
+
+                this->valueVector_.push_back(this->value_);
+            }
+        }
+    }
+
+    /**
+        @brief Calls the given function with parsed index and the parsed argument from the input string.
+        @param function The function to call
+        @param input The input string
+        @return The returnvalue of the functioncall
+    */
+    bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input)
+    {
+        SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '(', ')', false, '\0');
+        int index = -1;
+        bool success = false;
+
+        if (token.size() > 0)
+            success = ConvertValue(&index, token[0]);
+
+        if (!success || index < 0 || index > (signed int)MAX_VECTOR_INDEX)
+        {
+            if (!success)
+            {
+                COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is a vector." << std::endl;
+            }
+            else
+            {
+                COUT(1) << "Error: Invalid vector-index." << std::endl;
+            }
+            return false;
+        }
+
+        if (token.size() >= 2)
+            return (this->*function)(index, token.subSet(1).join());
+        else
+            return (this->*function)(index, "");
+    }
+
+    /**
+        @brief Adds a description to the config-value.
+        @param description The description
+    */
+    ConfigValueContainer& ConfigValueContainer::description(const std::string& description)
+    {
+        if (!this->bAddedDescription_)
+        {
+            this->description_ = std::string("ConfigValueDescription::" + this->sectionname_ + "::" + this->varname_);
+            AddLanguageEntry(this->description_, description);
+            this->bAddedDescription_ = true;
+        }
+        return (*this);
+    }
+
+    /**
+        @brief Returns the description of the config-value.
+        @return The description
+    */
+    const std::string& ConfigValueContainer::getDescription() const
+    {
+        return GetLocalisation(this->description_);
+    }
+}
Index: /code/branches/physics/src/core/ConfigValueContainer.h
===================================================================
--- /code/branches/physics/src/core/ConfigValueContainer.h	(revision 2122)
+++ /code/branches/physics/src/core/ConfigValueContainer.h	(revision 2122)
@@ -0,0 +1,296 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ConfigValueContainer.h
+    @brief Definition of the ConfigValueContainer class.
+
+    The ConfigValueContainer class contains all needed informations about a configurable variable:
+     - the name of the variable
+     - the name of the class the variable belongs to
+     - the default value
+     - the user-specified value
+     - a pointer to the entry in the config-file
+
+    This is needed to assign the configured values to all newly created objects.
+*/
+
+#ifndef _ConfigValueContainer_H__
+#define _ConfigValueContainer_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <vector>
+
+#include "util/Math.h"
+#include "util/MultiType.h"
+#include "ConfigFileManager.h"
+#include "Identifier.h"
+
+namespace orxonox
+{
+    class ConfigValueCallbackBase
+    {
+        public:
+            virtual void call(void* object) = 0;
+            inline virtual ~ConfigValueCallbackBase() {}
+    };
+
+    template <class T>
+    class ConfigValueCallback: public ConfigValueCallbackBase
+    {
+        public:
+            inline ConfigValueCallback(void (T::*function) (void)) : function_(function) {}
+            inline virtual ~ConfigValueCallback() {}
+            inline virtual void call(void* object)
+                { if (!Identifier::isCreatingHierarchy()) { (((T*)object)->*this->function_)(); } }
+
+        private:
+            void (T::*function_) (void);
+    };
+
+
+    //! The ConfigValuecontainer contains all needed informations about a configurable variable.
+    /**
+        The ConfigValueContainer class contains all needed informations about a configurable variable:
+         - the name of the variable
+         - the name of the class the variable belongs to
+         - the default value
+         - the user-specified value
+         - a pointer to the entry in the config-file
+
+        This is needed to assign the configured values to all newly created objects.
+
+        The container searches for the entry in the config file.
+        If there is an entry, it parses the specified value and assigns it to the variable of the right type.
+        If there is no entry, it adds the entry with the default-value to the section of the variables class.
+        If there is no section, the section and the entry are added to the end of the config-file.
+    */
+    class _CoreExport ConfigValueContainer
+    {
+        public:
+            /**
+                @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
+                @param type The type of the corresponding config-file
+                @param identifier The identifier of the class the variable belongs to
+                @param sectionname Name of the section the configValue should be put in.
+                @param varname The name of the variable
+                @param defvalue The default-value
+                @param value Only needed do determine the right type.
+            */
+            template <class D, class V>
+            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const D& defvalue, const V& value)
+            {
+                this->init(type, identifier, sectionname, varname);
+                this->initValue((V)defvalue);
+            }
+
+            /**
+                @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
+                @param type The type of the corresponding config-file
+                @param identifier The identifier of the class the variable belongs to
+                @param varname The name of the variable
+                @param defvalue The default-value
+            */
+            template <class V>
+            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<V>& defvalue)
+            {
+                this->init(type, identifier, sectionname, varname);
+
+                this->value_ = V();
+                for (unsigned int i = 0; i < defvalue.size(); i++)
+                    this->valueVector_.push_back(MultiType(defvalue[i]));
+
+                this->initVector();
+            }
+
+            ~ConfigValueContainer();
+
+            /**
+                @brief Returns the configured value.
+                @param value A pointer to the variable to store the value.
+                @param object The object calling this function
+                @return The ConfigValueContainer
+            */
+            template <typename T, class C>
+            ConfigValueContainer& getValue(T* value, C* object)
+            {
+                if ((this->callback_ && object) || this->bContainerIsNew_)
+                {
+                    if (this->bContainerIsNew_)
+                        this->bContainerIsNew_ = false;
+
+                    T temp = *value;
+                    this->value_.getValue(value);
+                    if ((*value) != temp)
+                    {
+                        if (this->callback_ && object)
+                            this->callback_->call(object);
+                        else
+                            this->bDoInitialCallback_ = true;
+                    }
+                }
+                else
+                {
+                    this->value_.getValue(value);
+                }
+                return *this;
+            }
+
+            /**
+                @brief Returns the configured vector.
+                @param value A pointer to the vector to store the values.
+                @param object The object calling this function
+                @return The ConfigValueContainer
+            */
+            template <typename T, class C>
+            ConfigValueContainer& getValue(std::vector<T>* value, C* object)
+            {
+                if ((this->callback_ && object) || this->bContainerIsNew_)
+                {
+                    if (this->bContainerIsNew_)
+                        this->bContainerIsNew_ = false;
+
+                    std::vector<T> temp = *value;
+                    value->clear();
+                    for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
+                        value->push_back(this->valueVector_[i]);
+
+                    if (value->size() != temp.size())
+                    {
+                        if (this->callback_ && object)
+                            this->callback_->call(object);
+                        else
+                            this->bDoInitialCallback_ = true;
+                    }
+                    else
+                    {
+                        for (unsigned int i = 0; i < value->size(); ++i)
+                        {
+                            if ((*value)[i] != temp[i])
+                            {
+                                if (this->callback_ && object)
+                                    this->callback_->call(object);
+                                else
+                                    this->bDoInitialCallback_ = true;
+                                break;
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    value->clear();
+                    for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
+                        value->push_back(this->valueVector_[i]);
+                }
+                return *this;
+            }
+
+            /** @brief Returns the name of this container. */
+            inline const std::string& getName() const
+                { return this->varname_; }
+            /** @brief Returns true if this config-value is a vector */
+            inline bool isVector() const
+                { return this->bIsVector_; }
+            /** @brief Returns the vectors size (or zero if it's not a vector). */
+            inline unsigned int getVectorSize() const
+                { return this->valueVector_.size(); }
+
+            ConfigValueContainer& description(const std::string& description);
+            const std::string& getDescription() const;
+
+            /**
+                @brief Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable.
+                @param object The object to call the function
+                @param function The callback function
+            */
+            template <class T>
+            inline ConfigValueContainer& callback(T* object, void (T::*function) (void))
+            {
+                if (!this->callback_)
+                {
+                    this->callback_ = new ConfigValueCallback<T>(function);
+
+                    if (this->bDoInitialCallback_)
+                    {
+                        this->bDoInitialCallback_ = false;
+                        this->callback_->call(object);
+                    }
+                }
+
+                return (*this);
+            }
+
+            bool set(const MultiType& input);
+            bool tset(const MultiType& input);
+
+            bool set(unsigned int index, const MultiType& input);
+            bool tset(unsigned int index, const MultiType& input);
+            bool add(const MultiType& input);
+            bool remove(unsigned int index);
+
+            bool reset();
+            void update();
+
+            /** @brief Converts the config-value to a string. @return The string */
+            inline std::string toString() const
+                { return this->value_; }
+            /** @brief Returns the typename of the assigned config-value. @return The typename */
+            inline std::string getTypename() const
+                { return this->value_.getTypename(); }
+
+        private:
+            void init(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname);
+            void initValue(const MultiType& defvalue);
+            void initVector();
+            bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input);
+
+            bool                       bIsVector_;                  //!< True if the container contains a std::vector
+
+            ConfigFileType             type_;                       //!< The type of the corresponding config-file
+            Identifier*                identifier_;                 //!< The identifier of the class
+            std::string                sectionname_;                //!< The name of the class the variable belongs to
+            std::string                varname_;                    //!< The name of the variable
+            std::string                defvalueString_;             //!< The string of the default-value
+            std::vector<std::string>   defvalueStringVector_;       //!< A vector, containg the strings of the default-values in case we're storing a vector
+
+            MultiType                  value_;                      //!< The value
+            std::vector<MultiType>     valueVector_;                //!< A vector, containg the values in case we're storing a vector
+
+            bool                       bAddedDescription_;          //!< True if a description was added
+            LanguageEntryLabel         description_;                //!< The description
+            ConfigValueCallbackBase*   callback_;                   //!< A callback function to call after getValue if the value changed
+
+            bool                       bContainerIsNew_;            //!< True if it's the first time getValue() gets called
+            bool                       bDoInitialCallback_;         //!< True if the callback should be called as soon as it gets created
+    };
+}
+
+#endif /* _ConfigValueContainer_H__ */
Index: /code/branches/physics/src/core/ConfigValueIncludes.h
===================================================================
--- /code/branches/physics/src/core/ConfigValueIncludes.h	(revision 2122)
+++ /code/branches/physics/src/core/ConfigValueIncludes.h	(revision 2122)
@@ -0,0 +1,114 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ConfigValueIncludes.h
+    @brief Definition of macros for config-values.
+*/
+
+#ifndef _ConfigValueIncludes_H__
+#define _ConfigValueIncludes_H__
+
+#include "CorePrereqs.h"
+
+#include "Identifier.h"
+#include "ConfigValueContainer.h"
+#include "ConfigFileManager.h"
+
+
+/**
+    @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file).
+    @param varname The name of the variable
+    @param defvalue The default-value of the variable
+*/
+#define SetConfigValueGeneric(type, varname, defvalue) \
+    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
+    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
+    if (!container##varname) \
+    { \
+        container##varname = new orxonox::ConfigValueContainer(ConfigFileType::Settings, identifier##varname, identifier##varname->getName(), #varname, defvalue, varname); \
+        identifier##varname->addConfigValueContainer(#varname, container##varname); \
+    } \
+    container##varname->getValue(&varname, this)
+
+#define SetConfigValue(varname, defvalue) SetConfigValueGeneric(ConfigFileType::Settings, varname, defvalue)
+
+
+/**
+    @brief Assigns the vector-values, defined in the config-file, to the vector (or the default-value, if there are no entries in the file).
+    @param varname The name of the std::vector
+    @param defvalue The default-value
+*/
+#define SetConfigValueVectorGeneric(type, varname, defvalue) \
+    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
+    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
+    if (!container##varname) \
+    { \
+        container##varname = new orxonox::ConfigValueContainer(ConfigFileType::Settings, identifier##varname, identifier##varname->getName(), #varname, defvalue); \
+        identifier##varname->addConfigValueContainer(#varname, container##varname); \
+    } \
+    container##varname->getValue(&varname, this)
+
+#define SetConfigValueVector(varname, defvalue) SetConfigValueVectorGeneric(ConfigFileType::Settings, varname, defvalue)
+
+
+/**
+    @brief Sets the variable and the config-file entry back to the previously defined default-value.
+    @param varname The name of the variable
+*/
+#define ResetConfigValue(varname) \
+    orxonox::ConfigValueContainer* container##varname##reset = this->getIdentifier()->getConfigValueContainer(#varname); \
+    if (container##varname##reset) \
+    { \
+        container##varname##reset->reset(); \
+        container##varname##reset->getValue(&varname, this); \
+    } \
+    else \
+    { \
+        COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
+    }
+
+
+/**
+    @brief Modifies a config-value by using a modifier and some arguments.
+    @param varname The name of the config-value
+    @param modifier The name of the modifier: set, tset, add, remove, reset, update
+*/
+#define ModifyConfigValue(varname, modifier, ...) \
+    orxonox::ConfigValueContainer* container##varname##modify##modifier = this->getIdentifier()->getConfigValueContainer(#varname); \
+    if (container##varname##modify##modifier) \
+    { \
+        container##varname##modify##modifier->modifier(__VA_ARGS__); \
+        container##varname##modify##modifier->getValue(&varname, this); \
+    } \
+    else \
+    { \
+        COUT(2) << "Warning: Couln't modify config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
+    }
+
+#endif /* _ConfigValueIncludes_H__ */
Index: /code/branches/physics/src/core/ConsoleCommand.cc
===================================================================
--- /code/branches/physics/src/core/ConsoleCommand.cc	(revision 2122)
+++ /code/branches/physics/src/core/ConsoleCommand.cc	(revision 2122)
@@ -0,0 +1,72 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConsoleCommand.h"
+
+namespace orxonox
+{
+    ConsoleCommand::ConsoleCommand(Functor* functor, const std::string& name) : Executor(functor, name)
+    {
+        this->accessLevel_ = AccessLevel::None;
+        this->argumentCompleter_[0] = 0;
+        this->argumentCompleter_[1] = 0;
+        this->argumentCompleter_[2] = 0;
+        this->argumentCompleter_[3] = 0;
+        this->argumentCompleter_[4] = 0;
+
+        this->keybindMode_ = KeybindMode::OnPress;
+        this->inputConfiguredParam_ = -1;
+    }
+
+    ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer)
+    {
+        if (param < 5)
+            this->argumentCompleter_[param] = completer;
+        else
+        {
+            COUT(2) << "Warning: Couldn't add autocompletion-function for param " << param << ": index out of bound." << std::endl;
+        }
+        return (*this);
+    }
+
+    ArgumentCompleter* ConsoleCommand::getArgumentCompleter(unsigned int param) const
+    {
+        if (param < 5)
+            return this->argumentCompleter_[param];
+        else
+            return 0;
+    }
+
+    void ConsoleCommand::createArgumentCompletionList(unsigned int param, const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)
+    {
+        if (param < 5 && this->argumentCompleter_[param])
+            this->argumentList_ = (*this->argumentCompleter_[param])(param1, param2, param3, param4, param5);
+        else
+            this->argumentList_.clear();
+    }
+}
Index: /code/branches/physics/src/core/ConsoleCommand.h
===================================================================
--- /code/branches/physics/src/core/ConsoleCommand.h	(revision 2122)
+++ /code/branches/physics/src/core/ConsoleCommand.h	(revision 2122)
@@ -0,0 +1,157 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ConsoleCommand_H__
+#define _ConsoleCommand_H__
+
+#include "CorePrereqs.h"
+
+#include "Executor.h"
+#include "Identifier.h"
+#include "CommandExecutor.h"
+#include "ArgumentCompletionFunctions.h"
+
+
+#define SetConsoleCommand(classname, function, bCreateShortcut) \
+    SetConsoleCommandAliasMulti(classname, function, #function, 0, bCreateShortcut)
+#define SetConsoleCommandAlias(classname, function, name, bCreateShortcut) \
+    SetConsoleCommandAliasMulti(classname, function, name, 0, bCreateShortcut)
+#define SetConsoleCommandAliasMulti(classname, function, name, number, bCreateShortcut) \
+    SetConsoleCommandGeneric(classname##function##consolecommand__##number, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name), bCreateShortcut)
+
+#define SetConsoleCommandGeneric(fakevariable, classname, command, bCreateShortcut) \
+    orxonox::ConsoleCommand& fakevariable = orxonox::ClassIdentifier<classname>::getIdentifier(#classname)->addConsoleCommand(command, bCreateShortcut)
+
+
+#define SetConsoleCommandShortcut(classname, function) \
+    SetConsoleCommandShortcutAliasMulti(classname, function, #function, 0)
+#define SetConsoleCommandShortcutAlias(classname, function, name) \
+    SetConsoleCommandShortcutAliasMulti(classname, function, name, 0)
+#define SetConsoleCommandShortcutAliasMulti(classname, function, name, number) \
+    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name))
+
+#define SetConsoleCommandShortcutExtern(function) \
+    SetConsoleCommandShortcutExternAliasMulti(function, #function, 0)
+#define SetConsoleCommandShortcutExternAlias(function, name) \
+    SetConsoleCommandShortcutExternAliasMulti(function, name, 0)
+#define SetConsoleCommandShortcutExternAliasMulti(function, name, number) \
+    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&function), name))
+
+#define SetConsoleCommandShortcutGeneric(fakevariable, command) \
+    orxonox::ConsoleCommand& fakevariable = orxonox::CommandExecutor::addConsoleCommandShortcut(command)
+
+
+namespace orxonox
+{
+    namespace AccessLevel
+    {
+        enum Level
+        {
+            None,
+            User,
+            Admin,
+            Offline,
+            Debug,
+            Disabled
+        };
+    }
+
+    class _CoreExport ConsoleCommand : public Executor
+    {
+        public:
+            ConsoleCommand(Functor* functor, const std::string& name = "");
+
+            inline ConsoleCommand& description(const std::string& description)
+                { this->Executor::setDescription(description); return (*this); }
+            inline ConsoleCommand& descriptionParam(int param, const std::string& description)
+                { this->Executor::setDescriptionParam(param, description); return (*this); }
+            inline ConsoleCommand& descriptionReturnvalue(const std::string& description)
+                { this->Executor::setDescriptionReturnvalue(description); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1)
+                { this->Executor::setDefaultValues(param1); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2)
+                { this->Executor::setDefaultValues(param1, param2); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+                { this->Executor::setDefaultValues(param1, param2, param3); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+                { this->Executor::setDefaultValues(param1, param2, param3, param4); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+                { this->Executor::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
+            inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param)
+                { this->Executor::setDefaultValue(index, param); return (*this); }
+
+            inline ConsoleCommand& accessLevel(AccessLevel::Level level)
+                { this->accessLevel_ = level; return (*this); }
+            inline AccessLevel::Level getAccessLevel() const
+                { return this->accessLevel_; }
+
+            ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
+            ArgumentCompleter* getArgumentCompleter(unsigned int param) const;
+
+            void createArgumentCompletionList(unsigned int param, const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "");
+            const ArgumentCompletionList& getArgumentCompletionList() const
+                { return this->argumentList_; }
+            ArgumentCompletionList::const_iterator getArgumentCompletionListBegin() const
+                { return this->argumentList_.begin(); }
+            ArgumentCompletionList::const_iterator getArgumentCompletionListEnd() const
+                { return this->argumentList_.end(); }
+
+            inline ConsoleCommand& setAsInputCommand()
+            {
+                this->keybindMode(KeybindMode::OnHold);
+                this->defaultValue(0, Vector2(0.0f, 0.0f));
+                this->inputConfiguredParam(0);
+                return *this;
+            }
+
+            inline ConsoleCommand& keybindMode(KeybindMode::Enum mode)
+                { this->keybindMode_ = mode; return *this; }
+            inline KeybindMode::Enum getKeybindMode() const
+                { return this->keybindMode_; }
+
+            inline ConsoleCommand& inputConfiguredParam(int index)
+                { this->inputConfiguredParam_ = index; return *this; }
+            inline int getInputConfiguredParam_() const
+                { return this->inputConfiguredParam_; }
+
+        private:
+            AccessLevel::Level accessLevel_;
+            ArgumentCompleter* argumentCompleter_[5];
+            ArgumentCompletionList argumentList_;
+
+            KeybindMode::Enum keybindMode_;
+            int inputConfiguredParam_;
+    };
+
+    inline ConsoleCommand* createConsoleCommand(Functor* functor, const std::string& name = "")
+    {
+        return new ConsoleCommand(functor, name);
+    }
+}
+
+#endif /* _ConsoleCommand_H__ */
Index: /code/branches/physics/src/core/ConsoleCommandCompilation.cc
===================================================================
--- /code/branches/physics/src/core/ConsoleCommandCompilation.cc	(revision 2122)
+++ /code/branches/physics/src/core/ConsoleCommandCompilation.cc	(revision 2122)
@@ -0,0 +1,175 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConsoleCommandCompilation.h"
+#include "ConsoleCommand.h"
+#include "util/Debug.h"
+#include "util/ExprParser.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(echo);
+    SetConsoleCommandShortcutExtern(puts);
+
+    SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files());
+
+    SetConsoleCommandShortcutExtern(calculate);
+
+    void source(const std::string& filename)
+    {
+        static std::set<std::string> executingFiles;
+
+        std::set<std::string>::const_iterator it = executingFiles.find(filename);
+        if (it != executingFiles.end())
+        {
+            COUT(1) << "Error: Recurring source command in \"" << filename << "\". Stopped execution." << std::endl;
+            return;
+        }
+
+        // Open the file
+        std::ifstream file;
+        file.open(filename.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't open file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        executingFiles.insert(filename);
+
+        // Iterate through the file and put the lines into the CommandExecutor
+        char line[1024];
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            CommandExecutor::execute(line);
+        }
+
+        executingFiles.erase(filename);
+        file.close();
+    }
+
+    std::string echo(const std::string& text)
+    {
+        std::cout << text << std::endl;
+        return text;
+    }
+
+    void puts(bool newline, const std::string& text)
+    {
+        if (newline)
+        {
+            COUT(0) << text << std::endl;
+        }
+        else
+        {
+            COUT(0) << text;
+        }
+    }
+
+    void write(const std::string& filename, const std::string& text)
+    {
+        std::ofstream file;
+        file.open(filename.c_str(), std::fstream::out);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't write to file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        file << text << std::endl;
+        file.close();
+    }
+
+    void append(const std::string& filename, const std::string& text)
+    {
+        std::ofstream file;
+        file.open(filename.c_str(), std::fstream::app);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't append to file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        file << text << std::endl;
+        file.close();
+    }
+
+    std::string read(const std::string& filename)
+    {
+        std::ifstream file;
+        file.open(filename.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't read from file \"" << filename << "\"." << std::endl;
+            return "";
+        }
+
+        std::string output = "";
+        char line[1024];
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            output += line;
+            output += "\n";
+        }
+
+        file.close();
+
+        return output;
+    }
+
+    float calculate(const std::string& calculation)
+    {
+        ExprParser expr(calculation);
+        if (expr.getSuccess())
+        {
+            if (expr.getResult() == 42.0)
+            {
+                COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;
+            }
+            if (expr.getRemains() != "")
+            {
+                COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << "'" << std::endl;
+            }
+            return expr.getResult();
+        }
+        else
+        {
+            COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;
+            return 0;
+        }
+    }
+}
Index: /code/branches/physics/src/core/ConsoleCommandCompilation.h
===================================================================
--- /code/branches/physics/src/core/ConsoleCommandCompilation.h	(revision 2122)
+++ /code/branches/physics/src/core/ConsoleCommandCompilation.h	(revision 2122)
@@ -0,0 +1,49 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ConsoleCommandCompilation_H__
+#define _ConsoleCommandCompilation_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+namespace orxonox
+{
+    _CoreExport void source(const std::string& filename);
+    _CoreExport std::string echo(const std::string& text);
+    _CoreExport void puts(bool newline, const std::string& test);
+
+    _CoreExport void write(const std::string& filename, const std::string& text);
+    _CoreExport void append(const std::string& filename, const std::string& text);
+    _CoreExport std::string read(const std::string& filename);
+
+    _CoreExport float calculate(const std::string& calculation);
+}
+
+#endif /* _ConsoleCommandCompilation_H__ */
Index: /code/branches/physics/src/core/Core.cc
===================================================================
--- /code/branches/physics/src/core/Core.cc	(revision 2122)
+++ /code/branches/physics/src/core/Core.cc	(revision 2122)
@@ -0,0 +1,211 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+/**
+    @file Core.cc
+    @brief Implementation of the Core class.
+*/
+
+#include "Core.h"
+#include <cassert>
+#include "Language.h"
+#include "CoreIncludes.h"
+#include "ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    bool Core::bShowsGraphics_s = false;
+    bool Core::bHasServer_s     = false;
+    bool Core::bIsClient_s      = false;
+    bool Core::bIsStandalone_s  = false;
+    bool Core::bIsMaster_s      = false;
+
+    /**
+        @brief Constructor: Registers the object and sets the config-values.
+        @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel()
+    */
+    Core::Core()
+    {
+        RegisterRootObject(Core);
+        this->setConfigValues();
+        isCreatingCoreSettings() = false;
+    }
+
+    /**
+        @brief Sets the bool to true to avoid static functions accessing a deleted object.
+    */
+    Core::~Core()
+    {
+        isCreatingCoreSettings() = true;
+    }
+
+    /**
+        @brief Returns true if the Core instance is not yet ready and the static functions have to return a default value.
+    */
+    bool& Core::isCreatingCoreSettings()
+    {
+        static bool bCreatingCoreSettings = true;
+        return bCreatingCoreSettings;
+    }
+
+    /**
+        @brief Returns a unique instance of Core.
+        @return The instance
+    */
+    Core& Core::getInstance()
+    {
+        // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class
+        //if (Core::isCreatingCoreSettings())
+        //{
+        //    isCreatingCoreSettings() = false;
+        //    //instance.setConfigValues();
+        //}
+
+        static bool firstTime = true;
+        if (firstTime)
+            isCreatingCoreSettings() = true;
+
+        static Core instance;
+        return instance;
+    }
+
+    /**
+        @brief Function to collect the SetConfigValue-macro calls.
+    */
+    void Core::setConfigValues()
+    {
+        SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
+        SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
+        SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
+        SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
+    }
+
+    /**
+        @brief Callback function if the debug level has changed.
+    */
+    void Core::debugLevelChanged()
+    {
+        // softDebugLevel_ is the maximum of the 3 variables
+        this->softDebugLevel_ = this->softDebugLevelConsole_;
+        if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
+            this->softDebugLevel_ = this->softDebugLevelLogfile_;
+        if (this->softDebugLevelShell_ > this->softDebugLevel_)
+            this->softDebugLevel_ = this->softDebugLevelShell_;
+
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
+    }
+
+    /**
+        @brief Callback function if the language has changed.
+    */
+    void Core::languageChanged()
+    {
+        // Read the translation file after the language was configured
+        Language::getLanguage().readTranslatedLanguageFile();
+    }
+
+    /**
+        @brief Returns the softDebugLevel for the given device (returns a default-value if the class ist right about to be created).
+        @param device The device
+        @return The softDebugLevel
+    */
+    int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
+    {
+        if (!Core::isCreatingCoreSettings())
+        {
+            switch (device)
+            {
+            case OutputHandler::LD_All:
+                return Core::getInstance().softDebugLevel_;
+            case OutputHandler::LD_Console:
+                return Core::getInstance().softDebugLevelConsole_;
+            case OutputHandler::LD_Logfile:
+                return Core::getInstance().softDebugLevelLogfile_;
+            case OutputHandler::LD_Shell:
+                return Core::getInstance().softDebugLevelShell_;
+            default:
+                assert(0);
+            }
+        }
+
+        // Return a constant value while we're creating the object
+        return 2;
+    }
+
+     /**
+        @brief Sets the softDebugLevel for the given device. Please use this only temporary and restore the value afterwards, as it overrides the configured value.
+        @param device The device
+        @param level The level
+    */
+     void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
+     {
+        if (!Core::isCreatingCoreSettings())
+        {
+            if (device == OutputHandler::LD_All)
+                Core::getInstance().softDebugLevel_ = level;
+            else if (device == OutputHandler::LD_Console)
+                Core::getInstance().softDebugLevelConsole_ = level;
+            else if (device == OutputHandler::LD_Logfile)
+                Core::getInstance().softDebugLevelLogfile_ = level;
+            else if (device == OutputHandler::LD_Shell)
+                Core::getInstance().softDebugLevelShell_ = level;
+
+            OutputHandler::setSoftDebugLevel(device, level);
+        }
+     }
+
+    /**
+        @brief Returns the configured language.
+    */
+    const std::string& Core::getLanguage()
+    {
+        if (!Core::isCreatingCoreSettings())
+            return Core::getInstance().language_;
+
+        return Language::getLanguage().defaultLanguage_;
+    }
+
+    /**
+        @brief Sets the language in the config-file back to the default.
+    */
+    void Core::resetLanguage()
+    {
+        Core::getInstance().resetLanguageIntern();
+    }
+
+    /**
+        @brief Sets the language in the config-file back to the default.
+    */
+    void Core::resetLanguageIntern()
+    {
+        ResetConfigValue(language_);
+    }
+}
Index: /code/branches/physics/src/core/Core.h
===================================================================
--- /code/branches/physics/src/core/Core.h	(revision 2122)
+++ /code/branches/physics/src/core/Core.h	(revision 2122)
@@ -0,0 +1,95 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+/**
+    @file Core.h
+    @brief Declaration of the Core class.
+
+    The Core class is a singleton, only used to configure some variables
+    in the core through the config-file.
+*/
+
+#ifndef _Core_H__
+#define _Core_H__
+
+#include "CorePrereqs.h"
+
+#include "OrxonoxClass.h"
+#include "util/OutputHandler.h"
+
+namespace orxonox
+{
+    //! The Core class is a singleton, only used to configure some config-values.
+    class _CoreExport Core : public OrxonoxClass
+    {
+        public:
+            static Core& getInstance();
+            static bool& isCreatingCoreSettings();
+            void setConfigValues();
+            void debugLevelChanged();
+            void languageChanged();
+
+            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
+            static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
+            static const std::string& getLanguage();
+            static void resetLanguage();
+
+            // fast access global variables.
+            static bool showsGraphics() { return bShowsGraphics_s; }
+            static bool hasServer()     { return bHasServer_s; }
+            static bool isClient()      { return bIsClient_s; }
+            static bool isStandalone()  { return bIsStandalone_s; }
+            static bool isMaster()      { return bIsMaster_s; }
+            static void setShowsGraphics(bool val) { bShowsGraphics_s = val; updateIsMaster(); }
+            static void setHasServer    (bool val) { bHasServer_s     = val; updateIsMaster(); }
+            static void setIsClient     (bool val) { bIsClient_s      = val; updateIsMaster(); }
+            static void setIsStandalone (bool val) { bIsStandalone_s  = val; updateIsMaster(); }
+            static void updateIsMaster  ()         { bIsMaster_s      = (bHasServer_s || bIsStandalone_s); }
+
+        private:
+            void resetLanguageIntern();
+
+            Core();
+            Core(const Core& other);
+            virtual ~Core();
+
+            int softDebugLevel_;                            //!< The debug level
+            int softDebugLevelConsole_;                     //!< The debug level for the console
+            int softDebugLevelLogfile_;                     //!< The debug level for the logfile
+            int softDebugLevelShell_;                       //!< The debug level for the ingame shell
+            std::string language_;                          //!< The language
+
+            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
+            static bool bHasServer_s;                       //!< global variable that tells whether this is a server
+            static bool bIsClient_s;
+            static bool bIsStandalone_s;
+            static bool bIsMaster_s;
+    };
+}
+
+#endif /* _Core_H__ */
Index: /code/branches/physics/src/core/CoreIncludes.h
===================================================================
--- /code/branches/physics/src/core/CoreIncludes.h	(revision 2122)
+++ /code/branches/physics/src/core/CoreIncludes.h	(revision 2122)
@@ -0,0 +1,139 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file CoreIncludes.h
+    @brief Definition of macros for Identifier and Factory.
+
+    Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface
+    or the BaseObject itself, it needs the macro RegisterRootObject(class) instead.
+
+    To allow the object being created through the factory, use the CreateFactory(class) macro outside
+    the of the class implementation, so it gets executed before main().
+*/
+
+#ifndef _CoreIncludes_H__
+#define _CoreIncludes_H__
+
+#include "CorePrereqs.h"
+
+#include "Identifier.h"
+#include "Factory.h"
+#include "ClassFactory.h"
+#include "Functor.h"
+#include "util/Debug.h"
+
+
+/**
+    @brief Intern macro, containing the common parts of RegisterObject and RegisterRootObject.
+    @param ClassName The name of the class
+    @param bRootClass True if the class is directly derived from OrxonoxClass
+*/
+#define InternRegisterObject(ClassName, bRootClass) \
+    this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \
+    if (orxonox::Identifier::isCreatingHierarchy()) \
+    { \
+        if (this->getParents()) \
+        { \
+            orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \
+            this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
+        } \
+        this->setConfigValues(); \
+        return; \
+    } \
+    orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this)
+
+/**
+    @brief Intern macro, containing the specific part of RegisterRootObject.
+    @param ClassName The name of the class
+*/
+#define InternRegisterRootObject(ClassName) \
+    if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) \
+        this->createParents(); \
+    InternRegisterObject(ClassName, true)
+
+/**
+    @brief RegisterObject - with and without debug output.
+    @param ClassName The name of the class
+*/
+#define RegisterObject(ClassName) \
+    COUT(5) << "*** Register Object: " << #ClassName << std::endl; \
+    InternRegisterObject(ClassName, false)
+
+/**
+    @brief RegisterRootObject - with and without debug output.
+    @param ClassName The name of the class
+*/
+#define RegisterRootObject(ClassName) \
+    COUT(5) << "*** Register Root-Object: " << #ClassName << std::endl; \
+    InternRegisterRootObject(ClassName)
+
+/**
+    @brief Creates the entry in the Factory.
+    @param ClassName The name of the class
+*/
+#define CreateFactory(ClassName) \
+    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true)
+
+/**
+    @brief Creates the entry in the Factory for classes which should not be loaded through XML.
+    @param ClassName The name of the class
+*/
+#define CreateUnloadableFactory(ClassName) \
+    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false)
+
+/**
+    @brief Returns the Identifier of the given class.
+    @param ClassName The name of the class
+*/
+#define Class(ClassName) \
+    orxonox::ClassIdentifier<ClassName>::getIdentifier()
+
+/**
+    @brief Returns the Identifier with a given name through the factory.
+    @param String The name of the class
+*/
+#define ClassByString(String) \
+    orxonox::Factory::getIdentifier(String)
+
+/**
+    @brief Returns the Identifier with a given network ID through the factory.
+    @param networkID The network ID of the class
+*/
+#define ClassByID(networkID) \
+    orxonox::Factory::getIdentifier(networkID)
+
+/**
+    @brief Registers a member function as callback when an object of 'type' is created.
+    @param
+*/
+#define RegisterConstructionCallback(ThisClassName, TargetClassName, FunctionName) \
+    orxonox::ClassIdentifier<TargetClassName>::getIdentifier()->addConstructionCallback( \
+        orxonox::createFunctor(&ThisClassName::FunctionName)->setObject(this))
+
+#endif /* _CoreIncludes_H__ */
Index: /code/branches/physics/src/core/CorePrereqs.h
===================================================================
--- /code/branches/physics/src/core/CorePrereqs.h	(revision 2122)
+++ /code/branches/physics/src/core/CorePrereqs.h	(revision 2122)
@@ -0,0 +1,191 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _CorePrereqs_H__
+#define _CorePrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+#include <string>
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( CORE_STATIC_BUILD )
+#  ifdef CORE_SHARED_BUILD
+#    define _CoreExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _CoreExport
+#    else
+#      define _CoreExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _CoreExport  __attribute__ ((visibility("default")))
+#else
+#  define _CoreExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace orxonox
+{
+  namespace XMLPort
+  {
+    enum Mode
+    {
+      LoadObject,
+      SaveObject
+    };
+  }
+
+  namespace KeybindMode
+  {
+    enum Enum
+    {
+      OnPress,
+      OnHold,
+      OnRelease,
+      None
+    };
+  };
+
+  typedef std::string LanguageEntryLabel;
+
+  class ArgumentCompleter;
+  class ArgumentCompletionListElement;
+  class BaseFactory;
+  class BaseMetaObjectListElement;
+  class BaseObject;
+  template <class T>
+  class ClassFactory;
+  template <class T>
+  class ClassIdentifier;
+  class ClassTreeMask;
+  class ClassTreeMaskIterator;
+  class ClassTreeMaskNode;
+  class ClassTreeMaskObjectIterator;
+  class Clock;
+  class CommandEvaluation;
+  class CommandExecutor;
+  class CommandLine;
+  class CommandLineArgument;
+  class ConfigFile;
+  class ConfigFileEntry;
+  class ConfigFileEntryComment;
+  class ConfigFileEntryValue;
+  class ConfigFileManager;
+  class ConfigFileSection;
+  class ConfigValueContainer;
+  class ConsoleCommand;
+  class Core;
+  struct Event;
+  class EventContainer;
+  class Executor;
+  template <class T>
+  class ExecutorMember;
+  class ExecutorStatic;
+  class Factory;
+  class Functor;
+  template <class T>
+  class FunctorMember;
+  class FunctorStatic;
+  class Identifier;
+  class IRC;
+  template <class T>
+  class Iterator;
+  class IteratorBase;
+  class Language;
+  class LanguageEntry;
+  class Loader;
+  class MetaObjectList;
+  class MetaObjectListElement;
+  class Namespace;
+  class NamespaceNode;
+  template <class T>
+  class ObjectList;
+  class ObjectListBase;
+  class ObjectListBaseElement;
+  template <class T>
+  class ObjectListElement;
+  template <class T>
+  class ObjectListIterator;
+  class OrxonoxClass;
+  class Shell;
+  class ShellListener;
+  template <class T>
+  class SubclassIdentifier;
+  class TclBind;
+  struct TclInterpreterBundle;
+  class TclThreadManager;
+  class Template;
+  class Tickable;
+  class XMLFile;
+  class XMLNameListener;
+  template <class T, class O>
+  class XMLPortClassObjectContainer;
+  template <class T>
+  class XMLPortClassParamContainer;
+  class XMLPortObjectContainer;
+  class XMLPortParamContainer;
+
+  // game states
+  class GameStateBase;
+  template <class ParentType>
+  class GameState;
+  class RootGameState;
+
+  // input
+  class BaseCommand;
+  class BufferedParamCommand;
+  class Button;
+  class CalibratorCallback;
+  class ExtendedInputState;
+  class HalfAxis;
+  class InputBuffer;
+  class InputManager;
+  class InputState;
+  class JoyStickHandler;
+  class MouseHandler;
+  class KeyBinder;
+  class KeyDetector;
+  class KeyHandler;
+  class ParamCommand;
+  class SimpleCommand;
+  class SimpleInputState;
+}
+
+#endif /* _CorePrereqs_H__ */
Index: /code/branches/physics/src/core/Event.cc
===================================================================
--- /code/branches/physics/src/core/Event.cc	(revision 2122)
+++ /code/branches/physics/src/core/Event.cc	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Event.h"
+#include "BaseObject.h"
+#include "Executor.h"
+
+namespace orxonox
+{
+    EventContainer::~EventContainer()
+    {
+        delete this->eventfunction_;
+    }
+
+    void EventContainer::process(BaseObject* object, const Event& event)
+    {
+        if (this->bActive_)
+        {
+            COUT(2) << "Warning: Detected Event loop in section \"" << this->eventname_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << "\"" << std::endl;
+            return;
+        }
+
+        this->bActive_ = true;
+
+        if (this->eventname_ == event.sectionname_)
+        {
+            if (event.originator_->isA(this->subclass_))
+            {
+                if (event.activate_)
+                    ++this->activeEvents_;
+                else
+                {
+                    --this->activeEvents_;
+
+                    if (this->activeEvents_ < 0)
+                        this->activeEvents_ = 0;
+                }
+
+                if (this->eventfunction_->getParamCount() == 0 && event.activate_)
+                    (*this->eventfunction_)();
+                else if ((this->activeEvents_ == 1 && event.activate_) || (this->activeEvents_ == 0 && !event.activate_))
+                {
+                    if (this->eventfunction_->getParamCount() == 1)
+                        (*this->eventfunction_)(this->activeEvents_);
+                    else if (this->eventfunction_->getParamCount() >= 2 && event.castedOriginator_)
+                        (*this->eventfunction_)(this->activeEvents_, event.castedOriginator_);
+                }
+            }
+        }
+
+        this->bActive_ = false;
+    }
+}
Index: /code/branches/physics/src/core/Event.h
===================================================================
--- /code/branches/physics/src/core/Event.h	(revision 2122)
+++ /code/branches/physics/src/core/Event.h	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Event_H__
+#define _Event_H__
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+    struct _CoreExport Event
+    {
+            Event(bool activate, BaseObject* originator) : activate_(activate), originator_(originator), castedOriginator_(0) {}
+
+            bool        activate_;
+            BaseObject* originator_;
+            void*       castedOriginator_;
+            std::string sectionname_;
+    };
+
+    class _CoreExport EventContainer
+    {
+        public:
+            EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
+            virtual ~EventContainer();
+
+            void process(BaseObject* object, const Event& event);
+
+        private:
+            bool bActive_;
+            std::string eventname_;
+            Executor* eventfunction_;
+            Identifier* subclass_;
+
+            int activeEvents_;
+    };
+}
+
+#endif /* _Event_H__ */
Index: /code/branches/physics/src/core/EventIncludes.h
===================================================================
--- /code/branches/physics/src/core/EventIncludes.h	(revision 2122)
+++ /code/branches/physics/src/core/EventIncludes.h	(revision 2122)
@@ -0,0 +1,71 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _EventIncludes_H__
+#define _EventIncludes_H__
+
+#include "CorePrereqs.h"
+#include "Executor.h"
+
+#define SetEvent(classname, eventname, functionname, event) \
+    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, functionname, event, BaseObject)
+
+#define SetEventTemplate(classname, eventname, functionname, event, ...) \
+    SetEventGenericTemplate(eventcontainer##classname##functionname, classname, eventname, functionname, event, BaseObject, __VA_ARGS__)
+
+#define SetSubclassEvent(classname, eventname, functionname, event, subclassname) \
+    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname)
+
+#define SetSubclassEventTemplate(classname, eventname, functionname, event, subclassname, ...) \
+    SetEventGenericTemplate(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname, __VA_ARGS__)
+
+#define SetEventGeneric(containername, classname, eventname, functionname, event, subclassname) \
+    orxonox::EventContainer* containername = this->getEventContainer(eventname); \
+    if (!containername) \
+    { \
+        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
+        executor->setObject(this); \
+        containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
+        this->addEventContainer(eventname, containername); \
+    } \
+    event.castedOriginator_ = dynamic_cast<subclassname*>(event.originator_); \
+    containername->process(this, event)
+
+#define SetEventGenericTemplate(containername, classname, eventname, functionname, event, subclassname, ...) \
+    orxonox::EventContainer* containername = this->getEventContainer(eventname); \
+    if (!containername) \
+    { \
+        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
+        executor->setObject(this); \
+        containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
+        this->addEventContainer(eventname, containername); \
+    } \
+    event.castedOriginator_ = dynamic_cast<subclassname*>(event.originator_); \
+    containername->process(this, event)
+
+#endif /* _EventIncludes_H__ */
Index: /code/branches/physics/src/core/Executor.cc
===================================================================
--- /code/branches/physics/src/core/Executor.cc	(revision 2122)
+++ /code/branches/physics/src/core/Executor.cc	(revision 2122)
@@ -0,0 +1,252 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ *   Inspiration: Executor by Benjamin Grauer
+ */
+
+#include "Executor.h"
+#include "util/Math.h"
+#include "util/Convert.h"
+#include "Language.h"
+
+namespace orxonox
+{
+    Executor::Executor(Functor* functor, const std::string& name)
+    {
+        this->functor_ = functor;
+        this->name_ = name;
+
+        this->bAddedDescription_ = false;
+        this->bAddedDescriptionReturnvalue_ = false;
+
+        this->bAddedDescriptionParam_[0] = false;
+        this->bAddedDescriptionParam_[1] = false;
+        this->bAddedDescriptionParam_[2] = false;
+        this->bAddedDescriptionParam_[3] = false;
+        this->bAddedDescriptionParam_[4] = false;
+
+        this->bAddedDefaultValue_[0] = false;
+        this->bAddedDefaultValue_[1] = false;
+        this->bAddedDefaultValue_[2] = false;
+        this->bAddedDefaultValue_[3] = false;
+        this->bAddedDefaultValue_[4] = false;
+    }
+
+    Executor::~Executor()
+    {
+        delete this->functor_;
+    }
+
+    bool Executor::parse(const std::string& params, const std::string& delimiter) const
+    {
+        EXECUTOR_PARSE(normal);
+    }
+
+    bool Executor::evaluate(const std::string& params, MultiType param[5], const std::string& delimiter) const
+    {
+        unsigned int paramCount = this->functor_->getParamCount();
+
+        if (paramCount == 1)
+        {
+            // only one param: check if there are params given, otherwise try to use default values
+            std::string temp = getStripped(params);
+            if ((temp != "") && (temp.size() != 0))
+            {
+                param[0] = params;
+                this->functor_->evaluateParam(0, param[0]);
+                return true;
+            }
+            else if (this->bAddedDefaultValue_[0])
+            {
+                param[0] = this->defaultValue_[0];
+                this->functor_->evaluateParam(0, param[0]);
+                return true;
+            }
+            return false;
+        }
+        else
+        {
+            // more than one param
+            SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
+
+            // if there are not enough params given, check if there are default values
+            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
+                if (!this->bAddedDefaultValue_[i])
+                    return false;
+
+            // assign all given arguments to the multitypes
+            for (unsigned int i = 0; i < min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+                param[i] = tokens[i];
+
+            // fill the remaining multitypes with default values
+            for (unsigned int i = tokens.size(); i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+                param[i] = this->defaultValue_[i];
+
+            // evaluate the param types through the functor
+            for (unsigned int i = 0; i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+                this->functor_->evaluateParam(i, param[i]);
+
+            return true;
+        }
+    }
+
+    Executor& Executor::setDescription(const std::string& description)
+    {
+        if (!this->bAddedDescription_)
+        {
+            this->description_ = std::string("ExecutorDescription::" + this->name_ + "::function");
+            AddLanguageEntry(this->description_, description);
+            this->bAddedDescription_ = true;
+        }
+        return (*this);
+    }
+
+    const std::string& Executor::getDescription() const
+    {
+        return GetLocalisation(this->description_);
+    }
+
+    Executor& Executor::setDescriptionParam(unsigned int param, const std::string& description)
+    {
+        if (param < MAX_FUNCTOR_ARGUMENTS)
+        {
+            if (!this->bAddedDescriptionParam_[param])
+            {
+                std::string paramnumber;
+                if (!convertValue(&paramnumber, param))
+                    return (*this);
+
+                this->descriptionParam_[param] = std::string("ExecutorDescription::" + this->name_ + "::param" + paramnumber);
+                AddLanguageEntry(this->descriptionParam_[param], description);
+                this->bAddedDescriptionParam_[param] = true;
+            }
+        }
+        return (*this);
+    }
+
+    const std::string& Executor::getDescriptionParam(unsigned int param) const
+    {
+        if (param < MAX_FUNCTOR_ARGUMENTS)
+            return GetLocalisation(this->descriptionParam_[param]);
+
+        return this->descriptionParam_[0];
+    }
+
+    Executor& Executor::setDescriptionReturnvalue(const std::string& description)
+    {
+        if (!this->bAddedDescriptionReturnvalue_)
+        {
+            this->descriptionReturnvalue_ = std::string("ExecutorDescription::" + this->name_ + "::returnvalue");
+            AddLanguageEntry(this->descriptionReturnvalue_, description);
+            this->bAddedDescriptionReturnvalue_ = true;
+        }
+        return (*this);
+    }
+
+    const std::string& Executor::getDescriptionReturnvalue(int param) const
+    {
+        return GetLocalisation(this->descriptionReturnvalue_);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+        this->defaultValue_[2] = param3;
+        this->bAddedDefaultValue_[2] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+        this->defaultValue_[2] = param3;
+        this->bAddedDefaultValue_[2] = true;
+        this->defaultValue_[3] = param4;
+        this->bAddedDefaultValue_[3] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+        this->defaultValue_[2] = param3;
+        this->bAddedDefaultValue_[2] = true;
+        this->defaultValue_[3] = param4;
+        this->bAddedDefaultValue_[3] = true;
+        this->defaultValue_[4] = param5;
+        this->bAddedDefaultValue_[4] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValue(unsigned int index, const MultiType& param)
+    {
+        if (index < MAX_FUNCTOR_ARGUMENTS)
+        {
+            this->defaultValue_[index] = param;
+            this->bAddedDefaultValue_[index] = true;
+        }
+        return (*this);
+    }
+
+    bool Executor::allDefaultValuesSet() const
+    {
+        for (unsigned int i = 0; i < this->functor_->getParamCount(); i++)
+            if (!this->bAddedDefaultValue_[i])
+                return false;
+
+        return true;
+    }
+}
Index: /code/branches/physics/src/core/Executor.h
===================================================================
--- /code/branches/physics/src/core/Executor.h	(revision 2122)
+++ /code/branches/physics/src/core/Executor.h	(revision 2122)
@@ -0,0 +1,305 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ *   Inspiration: Executor by Benjamin Grauer
+ */
+
+#ifndef _Executor_H__
+#define _Executor_H__
+
+#include "CorePrereqs.h"
+
+#include "util/SubString.h"
+#include "util/String.h"
+#include "util/Math.h"
+#include "Functor.h"
+#include "util/Debug.h"
+
+
+#define EXECUTOR_PARSE_FUNCTORCALL(mode) EXECUTOR_PARSE_FUNCTORCALL##mode
+#define EXECUTOR_PARSE_FUNCTORCALLnormal (*this->functor_)
+#define EXECUTOR_PARSE_FUNCTORCALLobject (*((FunctorMember<T>*)this->functor_))
+
+#define EXECUTOR_PARSE_OBJECT(mode, comma) EXECUTOR_PARSE_OBJECT##mode##comma
+#define EXECUTOR_PARSE_OBJECTnormal0
+#define EXECUTOR_PARSE_OBJECTnormal1
+#define EXECUTOR_PARSE_OBJECTobject0 object
+#define EXECUTOR_PARSE_OBJECTobject1 object,
+
+#define EXECUTOR_PARSE(mode) \
+    unsigned int paramCount = this->functor_->getParamCount(); \
+    \
+    if (paramCount == 0) \
+    { \
+        COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl; \
+        EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 0)); \
+    } \
+    else if (paramCount == 1) \
+    { \
+        std::string temp = getStripped(params); \
+        if ((temp != "") && (temp.size() != 0)) \
+        { \
+            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \
+            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType(params)); \
+        } \
+        else if (this->bAddedDefaultValue_[0]) \
+        { \
+            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl; \
+            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) this->defaultValue_[0]); \
+        } \
+        else \
+        { \
+            COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; \
+            return false; \
+        } \
+    } \
+    else \
+    { \
+        SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0'); \
+        \
+        for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++) \
+        { \
+            if (!this->bAddedDefaultValue_[i]) \
+            { \
+                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; \
+                return false; \
+            } \
+        } \
+        \
+        MultiType param[MAX_FUNCTOR_ARGUMENTS]; \
+        COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens ("; \
+        for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++) \
+        { \
+            param[i] = tokens[i]; \
+            if (i != 0) \
+            { \
+                COUT(5) << ", "; \
+            } \
+            COUT(5) << tokens[i]; \
+        } \
+        COUT(5) << ") and " << max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
+        for (unsigned int i = tokens.size(); i < paramCount; i++) \
+        { \
+            param[i] = this->defaultValue_[i]; \
+            if (i != 0) \
+            { \
+                COUT(5) << ", "; \
+            } \
+            COUT(5) << this->defaultValue_[i]; \
+        } \
+        COUT(5) << ")." << std::endl; \
+        \
+        if ((tokens.size() > paramCount) && (this->functor_->getTypenameParam(paramCount - 1) == "string")) \
+            param[paramCount - 1] = tokens.subSet(paramCount - 1).join(); \
+        \
+        switch(paramCount) \
+        { \
+            case 2: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1]); \
+                break; \
+            case 3: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2]); \
+                break; \
+            case 4: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2], param[3]); \
+                break; \
+            case 5: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2], param[3], param[4]); \
+                break; \
+        } \
+    } \
+    \
+    return true
+
+namespace orxonox
+{
+    class _CoreExport Executor
+    {
+        public:
+            Executor(Functor* functor, const std::string& name = "");
+            virtual ~Executor();
+
+            inline void operator()() const
+                { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1) const
+                { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2) const
+                { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { (*this->functor_)(param1, param2, param3, param4, param5); }
+
+            bool parse(const std::string& params, const std::string& delimiter = " ") const;
+
+            bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
+
+            Executor& setDescription(const std::string& description);
+            const std::string& getDescription() const;
+
+            Executor& setDescriptionParam(unsigned int param, const std::string& description);
+            const std::string& getDescriptionParam(unsigned int param) const;
+
+            Executor& setDescriptionReturnvalue(const std::string& description);
+            const std::string& getDescriptionReturnvalue(int param) const;
+
+            inline Functor* getFunctor() const
+                { return this->functor_; }
+            inline unsigned int getParamCount() const
+                { return this->functor_->getParamCount(); }
+            inline bool hasReturnvalue() const
+                { return this->functor_->hasReturnvalue(); }
+            inline FunctionType getType() const
+                { return this->functor_->getType(); }
+            inline const MultiType& getReturnvalue() const
+                { return this->functor_->getReturnvalue(); }
+            inline const std::string& getTypenameParam(unsigned int param) const
+                { return this->functor_->getTypenameParam(param); }
+            inline const std::string& getTypenameReturnvalue() const
+                { return this->functor_->getTypenameReturnvalue(); }
+
+            inline void setName(const std::string name)
+                { this->name_ = name; }
+            inline const std::string& getName() const
+                { return this->name_; }
+
+            Executor& setDefaultValues(const MultiType& param1);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
+            Executor& setDefaultValue(unsigned int index, const MultiType& param);
+
+            inline MultiType getDefaultValue(unsigned int index) const
+            {
+                if (index < MAX_FUNCTOR_ARGUMENTS)
+                    return this->defaultValue_[index];
+
+                return MT_null;
+            }
+
+            bool allDefaultValuesSet() const;
+            inline bool defaultValueSet(unsigned int index) const
+            {
+                if (index < MAX_FUNCTOR_ARGUMENTS)
+                    return this->bAddedDefaultValue_[index];
+
+                return false;
+            }
+
+        protected:
+            Functor* functor_;
+            std::string name_;
+            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
+            bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
+
+        private:
+            LanguageEntryLabel description_;
+            LanguageEntryLabel descriptionReturnvalue_;
+            LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS];
+
+            bool bAddedDescription_;
+            bool bAddedDescriptionReturnvalue_;
+            bool bAddedDescriptionParam_[MAX_FUNCTOR_ARGUMENTS];
+    };
+
+    class _CoreExport ExecutorStatic : public Executor
+    {
+        public:
+            ExecutorStatic(FunctorStatic* functor, const std::string& name = "") : Executor(functor, name) {}
+            virtual ~ExecutorStatic() {}
+    };
+
+    template <class T>
+    class ExecutorMember : public Executor
+    {
+        public:
+            ExecutorMember(FunctorMember<T>* functor, const std::string& name = "") : Executor(functor, name) {}
+            virtual ~ExecutorMember() {}
+
+            inline void operator()(T* object) const
+                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
+
+
+            inline void operator()(const T* object) const
+                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
+
+            inline void setObject(T* object) const
+                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
+            inline void setObject(const T* object) const
+                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
+
+            bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const
+            {
+                EXECUTOR_PARSE(object);
+            }
+
+            bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const
+            {
+                EXECUTOR_PARSE(object);
+            }
+    };
+
+    inline Executor* createExecutor(Functor* functor, const std::string& name = "")
+    {
+        return new Executor(functor, name);
+    }
+
+    template <class T>
+    inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "")
+    {
+        return new ExecutorMember<T>(functor, name);
+    }
+
+    inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "")
+    {
+        return new ExecutorStatic(functor, name);
+    }
+}
+
+#endif /* _Executor_H__ */
Index: /code/branches/physics/src/core/Factory.cc
===================================================================
--- /code/branches/physics/src/core/Factory.cc	(revision 2122)
+++ /code/branches/physics/src/core/Factory.cc	(revision 2122)
@@ -0,0 +1,122 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Factory.cc
+    @brief Implementation of the Factory class.
+*/
+
+#include "Factory.h"
+#include "Identifier.h"
+#include "BaseObject.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    /**
+        @brief Returns the Identifier with a given name.
+        @param name The name of the wanted Identifier
+        @return The Identifier
+    */
+    Identifier* Factory::getIdentifier(const std::string& name)
+    {
+        std::map<std::string, Identifier*>::const_iterator it = getFactoryPointer()->identifierStringMap_.find(name);
+        if (it != getFactoryPointer()->identifierStringMap_.end())
+            return it->second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns the Identifier with a given network ID.
+        @param id The network ID of the wanted Identifier
+        @return The Identifier
+    */
+    Identifier* Factory::getIdentifier(const unsigned int id)
+    {
+        std::map<unsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
+        if (it != getFactoryPointer()->identifierNetworkIDMap_.end())
+            return it->second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new Identifier to both maps.
+        @param name The name of the identifier
+        @param identifier The identifier to add
+    */
+    void Factory::add(const std::string& name, Identifier* identifier)
+    {
+        getFactoryPointer()->identifierStringMap_[name] = identifier;
+        getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
+//std::cout << identifier->getName() << ": " << identifier->getNetworkID() << std::endl;
+    }
+
+    /**
+        @brief Removes the entry with the old network ID and adds a new one.
+        @param identifier The identifier to change
+        @param oldID The old networkID
+        @param newID The new networkID
+    */
+    void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID)
+    {
+        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
+        getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier;
+//std::cout << identifier->getName() << ": " << oldID << " -> " << newID << std::endl;
+    }
+
+    /**
+        @brief Creates the class-hierarchy by creating and destroying one object of each type.
+    */
+    void Factory::createClassHierarchy()
+    {
+        COUT(3) << "*** Factory: Create class-hierarchy" << std::endl;
+        std::map<std::string, Identifier*>::iterator it;
+        it = getFactoryPointer()->identifierStringMap_.begin();
+        (*getFactoryPointer()->identifierStringMap_.begin()).second->startCreatingHierarchy();
+        for (it = getFactoryPointer()->identifierStringMap_.begin(); it != getFactoryPointer()->identifierStringMap_.end(); ++it)
+        {
+            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
+            BaseObject* temp = (*it).second->fabricate(0);
+            delete temp;
+        }
+        (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy();
+        COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl;
+    }
+
+    /**
+        @brief Ensures the Factory gets created in the right moment.
+        @return The Factory.
+    */
+    Factory* Factory::getFactoryPointer()
+    {
+      static Factory theOneAndOnlyFactoryInstance = Factory();
+      return &theOneAndOnlyFactoryInstance;
+    }
+}
Index: /code/branches/physics/src/core/Factory.h
===================================================================
--- /code/branches/physics/src/core/Factory.h	(revision 2122)
+++ /code/branches/physics/src/core/Factory.h	(revision 2122)
@@ -0,0 +1,100 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Factory.h
+    @brief Definition of the Factory and the BaseFactory class.
+
+    The Factory is a singleton, containing two maps to map either the name or the network ID
+    of a class with the corresponding Identifier.
+
+    Usage:
+    ID(classname) or ID(networkID) returns the corresponding Identifier.
+
+
+    BaseObject is the parent of ClassFactory which is defined in ClassFactory.h.
+    It can't be defined in ClassFactory.h, because of circular dependencies.
+*/
+
+#ifndef _Factory_H__
+#define _Factory_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+#include <string>
+
+namespace orxonox
+{
+    // ###############################
+    // ###         Factory         ###
+    // ###############################
+    //! The Factory is used to map the name or the network ID of a class with its Identifier.
+    class _CoreExport Factory
+    {
+        public:
+            static Identifier* getIdentifier(const std::string& name);
+            static Identifier* getIdentifier(const unsigned int id);
+            static void add(const std::string& name, Identifier* identifier);
+            static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
+            static void createClassHierarchy();
+
+            static Factory* getFactoryPointer();    // avoid overriding order problem in the static intialisation process
+
+            /** @brief Returns the factory-map. */
+            static const std::map<std::string, Identifier*>& getFacbtoryMap()
+                { return Factory::getFactoryPointer()->identifierStringMap_; }
+            /** @brief Returns the begin-iterator of the factory-map. */
+            static std::map<std::string, Identifier*>::const_iterator getFactoryMapBegin()
+                { return Factory::getFactoryPointer()->identifierStringMap_.begin(); }
+            /** @brief Returns the end-iterator of the factory-map. */
+            static std::map<std::string, Identifier*>::const_iterator getFactoryMapEnd()
+                { return Factory::getFactoryPointer()->identifierStringMap_.end(); }
+
+        private:
+            Factory() {}                            // don't create
+            Factory(const Factory& factory);        // don't copy
+            ~Factory() {}                           // don't delete
+
+            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
+            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
+    };
+
+    // ###############################
+    // ###       BaseFactory       ###
+    // ###############################
+    //! Base-class of ClassFactory. Has to be defined separate because of circular dependencies.
+    class _CoreExport BaseFactory
+    {
+        public:
+            virtual BaseObject* fabricate(BaseObject* creator) = 0;
+            virtual ~BaseFactory() {};
+    };
+}
+
+#endif /* _Factory_H__ */
Index: /code/branches/physics/src/core/Functor.h
===================================================================
--- /code/branches/physics/src/core/Functor.h	(revision 2122)
+++ /code/branches/physics/src/core/Functor.h	(revision 2122)
@@ -0,0 +1,481 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ *   Inspiration: Functor by Benjamin Grauer
+ */
+
+#ifndef _Functor_H__
+#define _Functor_H__
+
+#include "CorePrereqs.h"
+
+#include "util/MultiType.h"
+#include "util/String.h"
+#include "util/Debug.h"
+
+
+namespace orxonox
+{
+    const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
+
+    enum FunctionType
+    {
+        FT_MEMBER,
+        FT_CONSTMEMBER,
+        FT_STATIC
+    };
+
+
+    template <class T>
+    inline std::string typeToString() { return "unknown"; }
+
+#define CreateTypeToStringTemplate(type) \
+    template <> \
+    inline std::string typeToString<type>() { return #type; } \
+    template <> \
+    inline std::string typeToString<type&>() { return #type; } \
+    template <> \
+    inline std::string typeToString<const type>() { return #type; } \
+    template <> \
+    inline std::string typeToString<const type&>() { return #type; }
+
+    CreateTypeToStringTemplate(int);
+    CreateTypeToStringTemplate(unsigned int);
+    CreateTypeToStringTemplate(char);
+    CreateTypeToStringTemplate(unsigned char);
+    CreateTypeToStringTemplate(short);
+    CreateTypeToStringTemplate(unsigned short);
+    CreateTypeToStringTemplate(long);
+    CreateTypeToStringTemplate(unsigned long);
+    CreateTypeToStringTemplate(long long);
+    CreateTypeToStringTemplate(unsigned long long);
+    CreateTypeToStringTemplate(float);
+    CreateTypeToStringTemplate(double);
+    CreateTypeToStringTemplate(long double);
+    CreateTypeToStringTemplate(bool);
+    CreateTypeToStringTemplate(Vector2);
+    CreateTypeToStringTemplate(Vector3);
+    CreateTypeToStringTemplate(Quaternion);
+    CreateTypeToStringTemplate(ColourValue);
+    CreateTypeToStringTemplate(Radian);
+    CreateTypeToStringTemplate(Degree);
+
+    template <>
+    inline std::string typeToString<std::string>() { return "string"; }
+    template <>
+    inline std::string typeToString<std::string&>() { return "string"; }
+    template <>
+    inline std::string typeToString<const std::string>() { return "string"; }
+    template <>
+    inline std::string typeToString<const std::string&>() { return "string"; }
+
+    class _CoreExport Functor
+    {
+        public:
+            Functor() {}
+            virtual ~Functor() {}
+
+            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+
+            inline unsigned int getParamCount() const { return this->numParams_; }
+            inline bool hasReturnvalue() const { return this->hasReturnValue_; }
+            inline FunctionType getType() const { return this->type_; }
+            inline const MultiType& getReturnvalue() const { return this->returnedValue_; }
+
+            const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : BLANKSTRING; }
+            const std::string& getTypenameReturnvalue() const { return this->typeReturnvalue_; }
+
+            virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
+
+        protected:
+            unsigned int numParams_;
+            bool hasReturnValue_;
+            FunctionType type_;
+            MultiType returnedValue_;
+
+            std::string typeReturnvalue_;
+            std::string typeParam_[MAX_FUNCTOR_ARGUMENTS];
+    };
+
+    class _CoreExport FunctorStatic : public Functor
+    {
+        public:
+            virtual ~FunctorStatic() {}
+            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+    };
+
+    template <class T>
+    class FunctorMember : public Functor
+    {
+        public:
+            FunctorMember()
+            {
+                constObject_ = 0;
+                object_ = 0;
+                bConstObject_ = false;
+            }
+            virtual ~FunctorMember() {}
+
+            virtual void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+            virtual void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+
+            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null)
+            {
+                if (this->bConstObject_)
+                {
+                    if (this->constObject_)
+                        (*this)(this->constObject_, param1, param2, param3, param4, param5);
+                    else
+                    {
+                        COUT(1) << "An error occurred in Functor.h:" << std::endl;
+                        COUT(1) << "Error: No const object set." << std::endl;
+                    }
+                }
+                else
+                {
+                    if (this->object_)
+                        (*this)(this->object_, param1, param2, param3, param4, param5);
+                    else
+                    {
+                        COUT(1) << "An error occurred in Functor.h:" << std::endl;
+                        COUT(1) << "Error: No object set." << std::endl;
+                    }
+                }
+            }
+
+            FunctorMember* setObject(T* object)
+            {
+                this->bConstObject_ = false;
+                this->object_ = object;
+                return this;
+            }
+
+            FunctorMember* setObject(const T* object)
+            {
+                this->bConstObject_ = true;
+                this->constObject_ = object;
+                return this;
+            }
+
+        private:
+            const T* constObject_;
+            T* object_;
+            bool bConstObject_;
+    };
+
+
+
+#define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams
+#define FUNCTOR_TEMPLATE000
+#define FUNCTOR_TEMPLATE001 template <class P1>
+#define FUNCTOR_TEMPLATE002 template <class P1, class P2>
+#define FUNCTOR_TEMPLATE003 template <class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE004 template <class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE005 template <class P1, class P2, class P3, class P4, class P5>
+#define FUNCTOR_TEMPLATE010 template <class R>
+#define FUNCTOR_TEMPLATE011 template <class R, class P1>
+#define FUNCTOR_TEMPLATE012 template <class R, class P1, class P2>
+#define FUNCTOR_TEMPLATE013 template <class R, class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE014 template <class R, class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE015 template <class R, class P1, class P2, class P3, class P4, class P5>
+#define FUNCTOR_TEMPLATE100 template <class T>
+#define FUNCTOR_TEMPLATE101 template <class T, class P1>
+#define FUNCTOR_TEMPLATE102 template <class T, class P1, class P2>
+#define FUNCTOR_TEMPLATE103 template <class T, class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE104 template <class T, class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE105 template <class T, class P1, class P2, class P3, class P4, class P5>
+#define FUNCTOR_TEMPLATE110 template <class T, class R>
+#define FUNCTOR_TEMPLATE111 template <class T, class R, class P1>
+#define FUNCTOR_TEMPLATE112 template <class T, class R, class P1, class P2>
+#define FUNCTOR_TEMPLATE113 template <class T, class R, class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE114 template <class T, class R, class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE115 template <class T, class R, class P1, class P2, class P3, class P4, class P5>
+
+
+
+#define FUNCTOR_TEMPLATE_CLASSES(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE_CLASSES##ismember##returnvalue##numparams
+#define FUNCTOR_TEMPLATE_CLASSES000
+#define FUNCTOR_TEMPLATE_CLASSES001 <P1>
+#define FUNCTOR_TEMPLATE_CLASSES002 <P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES003 <P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES004 <P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES005 <P1, P2, P3, P4, P5>
+#define FUNCTOR_TEMPLATE_CLASSES010 <R>
+#define FUNCTOR_TEMPLATE_CLASSES011 <R, P1>
+#define FUNCTOR_TEMPLATE_CLASSES012 <R, P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES013 <R, P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES014 <R, P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES015 <R, P1, P2, P3, P4, P5>
+#define FUNCTOR_TEMPLATE_CLASSES100 <T>
+#define FUNCTOR_TEMPLATE_CLASSES101 <T, P1>
+#define FUNCTOR_TEMPLATE_CLASSES102 <T, P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES103 <T, P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES104 <T, P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES105 <T, P1, P2, P3, P4, P5>
+#define FUNCTOR_TEMPLATE_CLASSES110 <T, R>
+#define FUNCTOR_TEMPLATE_CLASSES111 <T, R, P1>
+#define FUNCTOR_TEMPLATE_CLASSES112 <T, R, P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES113 <T, R, P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES114 <T, R, P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES115 <T, R, P1, P2, P3, P4, P5>
+
+
+
+#define FUNCTOR_TYPENAME_PARAMS(numparams) FUNCTOR_TYPENAME_PARAMS##numparams
+#define FUNCTOR_TYPENAME_PARAMS0
+#define FUNCTOR_TYPENAME_PARAMS1 this->typeParam_[0] = typeToString<P1>();
+#define FUNCTOR_TYPENAME_PARAMS2 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>();
+#define FUNCTOR_TYPENAME_PARAMS3 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>();
+#define FUNCTOR_TYPENAME_PARAMS4 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>();
+#define FUNCTOR_TYPENAME_PARAMS5 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>(); this->typeParam_[4] = typeToString<P5>();
+
+#define FUNCTOR_TYPENAME_RETURN(returnvalue) FUNCTOR_TYPENAME_RETURN##returnvalue
+#define FUNCTOR_TYPENAME_RETURN0
+#define FUNCTOR_TYPENAME_RETURN1 this->typeReturnvalue_ = typeToString<R>();
+
+
+
+#define FUNCTOR_FUNCTION_PARAMS(numparams) FUNCTOR_FUNCTION_PARAMS##numparams
+#define FUNCTOR_FUNCTION_PARAMS0
+#define FUNCTOR_FUNCTION_PARAMS1 P1 param1
+#define FUNCTOR_FUNCTION_PARAMS2 P1 param1, P2 param2
+#define FUNCTOR_FUNCTION_PARAMS3 P1 param1, P2 param2, P3 param3
+#define FUNCTOR_FUNCTION_PARAMS4 P1 param1, P2 param2, P3 param3, P4 param4
+#define FUNCTOR_FUNCTION_PARAMS5 P1 param1, P2 param2, P3 param3, P4 param4, P5 param5
+
+#define FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) FUNCTOR_FUNCTION_RETURNVALUE##returnvalue
+#define FUNCTOR_FUNCTION_RETURNVALUE0 void
+#define FUNCTOR_FUNCTION_RETURNVALUE1 R
+
+
+
+#define FUNCTOR_FUNCTION_CALL(numparams) FUNCTOR_FUNCTION_CALL##numparams
+#define FUNCTOR_FUNCTION_CALL0
+#define FUNCTOR_FUNCTION_CALL1 param1
+#define FUNCTOR_FUNCTION_CALL2 param1, param2
+#define FUNCTOR_FUNCTION_CALL3 param1, param2, param3
+#define FUNCTOR_FUNCTION_CALL4 param1, param2, param3, param4
+#define FUNCTOR_FUNCTION_CALL5 param1, param2, param3, param4, param5
+
+#define FUNCTOR_STORE_RETURNVALUE(returnvalue, functioncall) FUNCTOR_STORE_RETURNVALUE##returnvalue(functioncall)
+#define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall
+#define FUNCTOR_STORE_RETURNVALUE1(functioncall) this->returnedValue_ = functioncall
+
+
+
+#define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams
+#define FUNCTOR_EVALUATE_PARAM0
+#define FUNCTOR_EVALUATE_PARAM1 \
+    if (index == 0) { param.convert<P1>(); }
+#define FUNCTOR_EVALUATE_PARAM2 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); }
+#define FUNCTOR_EVALUATE_PARAM3 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); } \
+    else if (index == 2) { param.convert<P3>(); }
+#define FUNCTOR_EVALUATE_PARAM4 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); } \
+    else if (index == 2) { param.convert<P3>(); } \
+    else if (index == 3) { param.convert<P4>(); }
+#define FUNCTOR_EVALUATE_PARAM5 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); } \
+    else if (index == 2) { param.convert<P3>(); } \
+    else if (index == 3) { param.convert<P4>(); } \
+    else if (index == 4) { param.convert<P5>(); }
+
+
+
+
+
+#define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \
+    FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
+    class FunctorStatic##returnvalue##numparams : public FunctorStatic \
+    { \
+        public: \
+            FunctorStatic##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+            { \
+                this->numParams_ = numparams; \
+                this->hasReturnValue_ = returnvalue; \
+                this->type_ = FT_STATIC; \
+                this->functionPointer_ = functionPointer; \
+                \
+                FUNCTOR_TYPENAME_PARAMS(numparams); \
+                FUNCTOR_TYPENAME_RETURN(returnvalue); \
+            } \
+    \
+            void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            { \
+                FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+        private: \
+            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
+    }; \
+    \
+    \
+    FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
+    inline FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+    { \
+        return new FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams) (functionPointer); \
+    }
+
+
+
+
+
+#define CREATE_MEMBER_FUNCTOR(returnvalue, numparams) \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    class FunctorMember##returnvalue##numparams : public FunctorMember<T> \
+    { \
+        public: \
+            FunctorMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+            { \
+                this->numParams_ = numparams; \
+                this->hasReturnValue_ = returnvalue; \
+                this->type_ = FT_MEMBER; \
+                this->functionPointer_ = functionPointer; \
+            } \
+    \
+            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                COUT(1) << "An error occurred in Functor.h:" << std::endl; \
+                COUT(1) << "Error: Function is not const." << std::endl; \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            { \
+                FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+        private: \
+            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
+    }; \
+    \
+    \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    class FunctorConstMember##returnvalue##numparams : public FunctorMember<T> \
+    { \
+        public: \
+            FunctorConstMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
+            { \
+                this->numParams_ = numparams; \
+                this->hasReturnValue_ = returnvalue; \
+                this->type_ = FT_CONSTMEMBER; \
+                this->functionPointer_ = functionPointer; \
+            } \
+    \
+            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            { \
+                FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+        private: \
+            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)) const; \
+    }; \
+    \
+    \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+    { \
+        return new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
+    } \
+    \
+    \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
+    { \
+        return new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
+    }
+
+
+// disable annoying warning about forcing value to boolean
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(push)
+#pragma warning(disable:4100 4800)
+#endif
+
+#define CREATE_ALL_STATIC_FUNCTORS() \
+    CREATE_STATIC_FUNCTOR(0, 0); \
+    CREATE_STATIC_FUNCTOR(0, 1); \
+    CREATE_STATIC_FUNCTOR(0, 2); \
+    CREATE_STATIC_FUNCTOR(0, 3); \
+    CREATE_STATIC_FUNCTOR(0, 4); \
+    CREATE_STATIC_FUNCTOR(0, 5); \
+    CREATE_STATIC_FUNCTOR(1, 0); \
+    CREATE_STATIC_FUNCTOR(1, 1); \
+    CREATE_STATIC_FUNCTOR(1, 2); \
+    CREATE_STATIC_FUNCTOR(1, 3); \
+    CREATE_STATIC_FUNCTOR(1, 4); \
+    CREATE_STATIC_FUNCTOR(1, 5)
+
+
+#define CREATE_ALL_MEMBER_FUNCTORS() \
+    CREATE_MEMBER_FUNCTOR(0, 0); \
+    CREATE_MEMBER_FUNCTOR(0, 1); \
+    CREATE_MEMBER_FUNCTOR(0, 2); \
+    CREATE_MEMBER_FUNCTOR(0, 3); \
+    CREATE_MEMBER_FUNCTOR(0, 4); \
+    CREATE_MEMBER_FUNCTOR(0, 5); \
+    CREATE_MEMBER_FUNCTOR(1, 0); \
+    CREATE_MEMBER_FUNCTOR(1, 1); \
+    CREATE_MEMBER_FUNCTOR(1, 2); \
+    CREATE_MEMBER_FUNCTOR(1, 3); \
+    CREATE_MEMBER_FUNCTOR(1, 4); \
+    CREATE_MEMBER_FUNCTOR(1, 5)
+
+
+    CREATE_ALL_STATIC_FUNCTORS();
+    CREATE_ALL_MEMBER_FUNCTORS();
+}
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
+#endif /* _Functor_H__ */
Index: /code/branches/physics/src/core/GameState.cc
===================================================================
--- /code/branches/physics/src/core/GameState.cc	(revision 2122)
+++ /code/branches/physics/src/core/GameState.cc	(revision 2122)
@@ -0,0 +1,366 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of GameStateBase class.
+*/
+
+#include "GameState.h"
+#include "util/Debug.h"
+#include "util/Exception.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Constructor only initialises variables and sets the name permanently.
+    */
+    GameStateBase::GameStateBase(const std::string& name)
+        : name_(name)
+        //, parent_(0)
+        , activeChild_(0)
+        //, bPausegetParent()(false)
+    {
+        Operations temp = {false, false, false, false, false};
+        this->operation_ = temp;
+    }
+
+    /**
+    @brief
+        Destructor only checks that we don't delete an active state.
+    */
+    GameStateBase::~GameStateBase()
+    {
+        OrxAssert(this->operation_.active == false, "Deleting an active GameState is a very bad idea..");
+    }
+
+    /**
+    @brief
+        Adds a child to the current tree. The Child can contain children of its own.
+        But you cannot a state tree that already has an active state.
+    @param state
+        The state to be added.
+    */
+    void GameStateBase::addChild(GameStateBase* state)
+    {
+        if (!state)
+            return;
+        // check if the state/tree to be added has states in it that already exist in this tree.
+        for (std::map<std::string, GameStateBase*>::const_iterator it = state->allChildren_.begin();
+            it != state->allChildren_.end(); ++it)
+        {
+            if (this->getState(it->second->getName()))
+            {
+                ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
+                return;
+            }
+        }
+        if (this->getState(state->name_))
+        {
+            ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
+            return;
+        }
+        // Make sure we don't add a tree that already has an active state.
+        if (state->getCurrentState())
+        {
+            ThrowException(GameState, "Cannot merge a tree that is already active.");
+            return;
+        }
+
+        // merge the child's children into this tree
+        for (std::map<std::string, GameStateBase*>::const_iterator it = state->allChildren_.begin();
+            it != state->allChildren_.end(); ++it)
+            this->grandchildAdded(state, it->second);
+        // merge 'state' into this tree
+        this->grandchildAdded(state, state);
+
+        // mark us as parent
+        state->setParent(this);
+    }
+
+    /**
+    @brief
+        Removes a child by instance. This splits the tree in two parts,
+        each of them functional on its own.
+    @param state
+        GameState by instance pointer
+    */
+    void GameStateBase::removeChild(GameStateBase* state)
+    {
+        std::map<GameStateBase*, GameStateBase*>::iterator it = this->grandchildrenToChildren_.find(state);
+        if (it != this->grandchildrenToChildren_.end())
+        {
+            if (state->isInSubtree(getCurrentState()))
+            {
+                ThrowException(GameState, "Cannot remove an active game state child '"
+                    + state->getName() + "' from '" + name_ + "'.");
+                //COUT(2) << "Warning: Cannot remove an active game state child '" << state->getName()
+                //    << "' from '" << name_ << "'." << std::endl;
+            }
+            else
+            {
+                for (std::map<GameStateBase*, GameStateBase*>::const_iterator it = state->grandchildrenToChildren_.begin();
+                    it != state->grandchildrenToChildren_.end(); ++it)
+                    this->grandchildRemoved(it->first);
+                this->grandchildRemoved(state);
+            }
+        }
+        else
+        {
+            ThrowException(GameState, "Game state '" + name_ + "' doesn't have a child named '"
+                + state->getName() + "'.");
+            //COUT(2) << "Warning: Game state '" << name_ << "' doesn't have a child named '"
+            //    << state->getName() << "'. Removal skipped." << std::endl;
+        }
+    }
+
+    /**
+    @brief
+        Removes a child by name. This splits the tree in two parts,
+        each of them functional on its own.
+    @param state
+        GameState by name
+    */
+
+    void GameStateBase::removeChild(const std::string& name)
+    {
+        GameStateBase* state = getState(name);
+        if (state)
+        {
+            removeChild(state);
+        }
+        else
+        {
+            ThrowException(GameState, "GameState '" + name + "' doesn't exist.");
+            //COUT(2) << "Warning: GameState '" << name << "' doesn't exist." << std::endl;
+        }
+    }
+
+    /**
+    @brief
+        Tells a state that one of its children has added a child. This is necessary
+        to fill the internal maps correctly.
+    @param child
+        The child who notices this state.
+    @param grandchild
+        The child that has been added.
+    */
+    inline void GameStateBase::grandchildAdded(GameStateBase* child, GameStateBase* grandchild)
+    {
+        // fill the two maps correctly.
+        this->allChildren_[grandchild->getName()] = grandchild;
+        this->grandchildrenToChildren_[grandchild] = child;
+        if (this->getParent())
+            this->getParent()->grandchildAdded(this, grandchild);
+    }
+
+    /**
+    @brief
+        Tells a state that one of its children has removed a child. This is necessary
+        to fill the internal maps correctly.
+    @param child
+        The child who notices this state.
+    @param grandchild
+        The child that has been removed.
+    */
+    inline void GameStateBase::grandchildRemoved(GameStateBase* grandchild)
+    {
+        // adjust the two maps correctly.
+        this->allChildren_.erase(grandchild->getName());
+        this->grandchildrenToChildren_.erase(grandchild);
+        if (this->getParent())
+            this->getParent()->grandchildRemoved(grandchild);
+    }
+
+    /**
+    @brief
+        Checks whether a specific game states exists in the hierarchy.
+    @remarks
+        Remember that the every node has a map with all its child nodes.
+    */
+    GameStateBase* GameStateBase::getState(const std::string& name)
+    {
+        if (this->getParent())
+            return this->getParent()->getState(name);
+        else
+        {
+            // The map only contains children, so check ourself first
+            if (name == this->name_)
+                return this;
+            // Search in the map. If there is no entry, we can be sure the state doesn't exist.
+            std::map<std::string, GameStateBase*>::const_iterator it = this->allChildren_.find(name);
+            return (it!= this->allChildren_.end() ? it->second : 0);
+        }
+    }
+
+    /**
+    @brief
+        Returns the root node of the tree.
+    */
+    GameStateBase* GameStateBase::getRoot()
+    {
+        if (this->getParent())
+            return this->getParent()->getRoot();
+        else
+            return this;
+    }
+
+    /**
+    @brief
+        Returns the current active state.
+    @remarks
+        Remember that the current active state is the one that does not
+        have active children itself. Many states can be active at once.
+    */
+    GameStateBase* GameStateBase::getCurrentState()
+    {
+        if (this->operation_.active)
+        {
+            if (this->activeChild_)
+                return this->activeChild_->getCurrentState();
+            else
+                return this;
+        }
+        else
+        {
+            if (this->getParent())
+                return this->getParent()->getCurrentState();
+            else
+                return 0;
+        }
+    }
+
+    /**
+    @brief
+        Determines whether 'state' is in this subtree, including this node.
+    */
+    bool GameStateBase::isInSubtree(GameStateBase* state) const
+    {
+        return (grandchildrenToChildren_.find(state) != grandchildrenToChildren_.end()
+                || state == this);
+    }
+
+    /**
+    @brief
+        Makes a state transition according to the state tree. You can choose any state
+        in the tree to do the call. The function finds the current state on its own.
+    @param state
+        The state to be entered, has to exist in the tree.
+    */
+    void GameStateBase::requestState(const std::string& name)
+    {
+        assert(getRoot());
+        getRoot()->requestState(name);
+    }
+
+    /**
+    @brief
+        Internal method that actually makes the state transition. Since it is internal,
+        the method can assume certain things to be granted (like 'this' is always active).
+    */
+    void GameStateBase::makeTransition(GameStateBase* source, GameStateBase* destination)
+    {
+        if (source == this->getParent())
+        {
+            // call is from the parent
+            this->activate();
+        }
+        else if (source == 0)
+        {
+            // call was just started by root
+            // don't do anyting yet
+        }
+        else
+        {
+            // call is from a child
+            this->activeChild_ = 0;
+        }
+
+        if (destination == this)
+            return;
+
+        // Check for 'destination' in the children map first
+        std::map<GameStateBase*, GameStateBase*>::const_iterator it
+            = this->grandchildrenToChildren_.find(destination);
+        if (it != this->grandchildrenToChildren_.end())
+        {
+            // child state. Don't use 'state', might be a grandchild!
+            this->activeChild_ = it->second;
+            it->second->makeTransition(this, destination);
+        }
+        else
+        {
+            // parent. We can be sure of this.
+            assert(this->getParent() != 0);
+
+            this->deactivate();
+            this->getParent()->makeTransition(this, destination);
+        }
+    }
+
+    /**
+    @brief
+        Activates the state. Only sets bActive_ to true and notifies the parent.
+    */
+    void GameStateBase::activate()
+    {
+        this->operation_.active = true;
+        this->operation_.entering = true;
+        this->enter();
+        this->operation_.entering = false;
+    }
+
+    /**
+        Activates the state. Only sets bActive_ to false and notifies the parent.
+    */
+    void GameStateBase::deactivate()
+    {
+        this->operation_.leaving = true;
+        this->leave();
+        this->operation_.leaving = false;
+        this->operation_.active = false;
+    }
+
+    /**
+    @brief
+        Update method that calls ticked() with enclosed bRunning_ = true
+        If there was a state transition request within ticked() then this
+        method will transition in the end.
+    @param dt Delta time
+    @note
+        This method is not virtual! You cannot override it therefore.
+    */
+    void GameStateBase::tick(const Clock& time)
+    {
+        this->operation_.running = true;
+        this->ticked(time);
+        this->operation_.running = false;
+    }
+}
Index: /code/branches/physics/src/core/GameState.h
===================================================================
--- /code/branches/physics/src/core/GameState.h	(revision 2122)
+++ /code/branches/physics/src/core/GameState.h	(revision 2122)
@@ -0,0 +1,161 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Definition of GameState class.
+*/
+
+#ifndef _GameState_H__
+#define _GameState_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <vector>
+#include <map>
+#include <cassert>
+#include "Clock.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        An implementation of a tree to manage game states.
+        This leads to a certain hierarchy that is created at runtime.
+        To actually use the structure, you will have to derive from it and
+        implement 'enter', 'leave' and 'tick'. The latter corresponds to an
+        update function.
+
+        Internally the tree is managed by two maps per node: One stores all its
+        children, grandchildren, etc. by name of the state. The other maps these
+        children states to the actual child of the node.
+        An example: Foo is a grandchildren of Bar and Foofoo is the Foo's parent.
+        Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.
+    */
+    class _CoreExport GameStateBase
+    {
+        friend class RootGameState;
+        template <class ParentType>
+        friend class GameState;
+
+    public:
+        /**
+        @brief
+            Gives information about what the GameState is currently doing
+        */
+        struct Operations
+        {
+            unsigned active    : 1;
+            unsigned entering  : 1;
+            unsigned leaving   : 1;
+            unsigned running   : 1;
+            unsigned suspended : 1;
+        };
+
+    public:
+        virtual ~GameStateBase();
+
+        const std::string& getName() const { return name_; }
+        const Operations getOperation() const { return this->operation_; }
+        bool isInSubtree(GameStateBase* state) const;
+
+        GameStateBase* getState(const std::string& name);
+        GameStateBase* getRoot();
+        //! Returns the currently active game state
+        virtual GameStateBase* getCurrentState();
+
+        virtual void requestState(const std::string& name);
+
+        void addChild(GameStateBase* state);
+        void removeChild(GameStateBase* state);
+        void removeChild(const std::string& name);
+
+    protected:
+        virtual void enter() = 0;
+        virtual void leave() = 0;
+        virtual void ticked(const Clock& time) = 0;
+
+        GameStateBase* getActiveChild() { return this->activeChild_; }
+
+        void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
+
+        virtual GameStateBase* getParent() const = 0;
+        virtual void setParent(GameStateBase* state) = 0;
+
+    private:
+        // Making the constructor private ensures that game states
+        // are always derivates of GameState<T>. Note the friend declaration above.
+        GameStateBase(const std::string& name);
+
+        //! Performs a transition to 'destination'
+        virtual void makeTransition(GameStateBase* source, GameStateBase* destination);
+
+        void grandchildAdded(GameStateBase* child, GameStateBase* grandchild);
+        void grandchildRemoved(GameStateBase* grandchild);
+
+        void tick(const Clock& time);
+        void activate();
+        void deactivate();
+
+        const std::string                        name_;
+        Operations                               operation_;
+        GameStateBase*                           activeChild_;
+        //bool                                     bPauseParent_;
+        std::map<std::string, GameStateBase*>    allChildren_;
+        std::map<GameStateBase*, GameStateBase*> grandchildrenToChildren_;
+    };
+
+
+    template <class ParentType>
+    class GameState : public GameStateBase
+    {
+    public:
+        GameState(const std::string& name)
+            : GameStateBase(name)
+            , parent_(0)
+        { }
+        virtual ~GameState() { }
+
+        ParentType* getParent() const
+            { return parent_; }
+
+    protected:
+        void setParent(GameStateBase* state)
+        {
+            assert(dynamic_cast<ParentType*>(state) != 0);
+            this->parent_ = dynamic_cast<ParentType*>(state);
+        }
+
+    private:
+        ParentType* parent_;
+    };
+}
+
+#endif /* _GameState_H__ */
Index: /code/branches/physics/src/core/IRC.cc
===================================================================
--- /code/branches/physics/src/core/IRC.cc	(revision 2122)
+++ /code/branches/physics/src/core/IRC.cc	(revision 2122)
@@ -0,0 +1,140 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "IRC.h"
+
+#include <boost/thread/thread.hpp>
+#include "ConsoleCommand.h"
+#include "TclThreadManager.h"
+#include "CoreIncludes.h"
+#include "util/Convert.h"
+
+
+namespace orxonox
+{
+    static const unsigned int IRC_TCL_THREADID  = 1421421421;
+
+    SetConsoleCommand(IRC, say,  true).accessLevel(AccessLevel::User);
+    SetConsoleCommand(IRC, msg,  false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User);
+
+    IRC::IRC()
+    {
+        RegisterRootObject(IRC);
+        this->bundle_ = 0;
+    }
+
+    void IRC::initialize()
+    {
+        unsigned int threadID = (unsigned int)IRC_TCL_THREADID;
+        TclThreadManager::createID(threadID);
+        this->bundle_ = TclThreadManager::getInstance().getInterpreterBundle(threadID);
+
+        try
+        {
+            this->bundle_->interpreter_->def("orxonox::irc::say", IRC::tcl_say, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::privmsg", IRC::tcl_privmsg, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::action", IRC::tcl_action, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while initializing Tcl (IRC): " << e.what();   }
+
+        this->nickname_ = "orx" + getConvertedValue<int, std::string>((unsigned int)rand());
+        TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
+        TclThreadManager::execute(threadID, "source irc.tcl");
+    }
+
+    IRC& IRC::getInstance()
+    {
+        static IRC instance;
+        return instance;
+    }
+
+    bool IRC::eval(const std::string& command)
+    {
+        if (!IRC::getInstance().bundle_)
+        {
+            IRC::getInstance().initialize();
+            COUT(1) << "Error: IRC client wasn't yet initialized, please try again." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            IRC::getInstance().bundle_->interpreter_->eval(command);
+            return true;
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while executing Tcl (IRC): " << e.what();   }
+
+        return false;
+    }
+
+    void IRC::say(const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn #orxonox {" + message + "}"))
+            IRC::tcl_say(Tcl::object(), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::msg(const std::string& channel, const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn " + channel + " {" + message + "}"))
+            IRC::tcl_privmsg(Tcl::object(channel), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::nick(const std::string& nickname)
+    {
+        if (IRC::eval("irk::nick $conn " + nickname))
+            IRC::getInstance().nickname_ = nickname;
+    }
+
+    void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> * " << nick.get() << " " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> --> " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+}
Index: /code/branches/physics/src/core/IRC.h
===================================================================
--- /code/branches/physics/src/core/IRC.h	(revision 2122)
+++ /code/branches/physics/src/core/IRC.h	(revision 2122)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _IRC_H__
+#define _IRC_H__
+
+#include "CorePrereqs.h"
+
+#include "OrxonoxClass.h"
+#include "cpptcl/CppTcl.h"
+
+namespace orxonox
+{
+    class _CoreExport IRC : public OrxonoxClass
+    {
+        public:
+            static IRC& getInstance();
+
+            static void say(const std::string& message);
+            static void msg(const std::string& channel, const std::string& message);
+            static void nick(const std::string& nickname);
+
+            static void tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_info(Tcl::object const &channel, Tcl::object const &args);
+
+        private:
+            static bool eval(const std::string& command);
+            void initialize();
+
+            IRC();
+            IRC(const IRC& other);
+            ~IRC() {}
+
+            TclInterpreterBundle* bundle_;
+            std::string nickname_;
+    };
+}
+
+#endif /* _IRC_H__ */
Index: /code/branches/physics/src/core/Identifier.cc
===================================================================
--- /code/branches/physics/src/core/Identifier.cc	(revision 2122)
+++ /code/branches/physics/src/core/Identifier.cc	(revision 2122)
@@ -0,0 +1,555 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Identifier.cc
+    @brief Implementation of the Identifier class.
+*/
+
+#include "Identifier.h"
+
+#include <ostream>
+
+#include "Factory.h"
+#include "ConfigValueContainer.h"
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "XMLPort.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###       Identifier        ###
+    // ###############################
+    int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero (this static member variable is ok: it's used in main(), not before)
+
+    /**
+        @brief Constructor: No factory, no object created, new ObjectList and a unique networkID.
+    */
+    Identifier::Identifier()
+    {
+        this->objects_ = new ObjectListBase(this);
+
+        this->bCreatedOneObject_ = false;
+        this->bSetName_ = false;
+        this->factory_ = 0;
+        this->bLoadable_ = true;
+
+        this->bHasConfigValues_ = false;
+        this->bHasConsoleCommands_ = false;
+        this->bHasConstructionCallback_ = false;
+
+        this->children_ = new std::set<const Identifier*>();
+        this->directChildren_ = new std::set<const Identifier*>();
+
+        // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables
+        static unsigned int classIDcounter_s = 0;
+        this->classID_ = classIDcounter_s++;
+    }
+
+    /**
+        @brief Destructor: Deletes the list containing the children.
+    */
+    Identifier::~Identifier()
+    {
+        delete this->children_;
+        delete this->directChildren_;
+        delete this->objects_;
+
+        if (this->factory_)
+            delete this->factory_;
+
+        for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)
+            delete (it->second);
+        for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
+            delete (it->second);
+        for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)
+            delete (it->second);
+        for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
+            delete (it->second);
+    }
+
+    /**
+        @brief Returns an identifier by name and adds it if not available
+        @param name The name of the identifier as typeid().name() suggests
+        @param proposal A pointer to a newly created identifier for the case of non existance in the map
+        @return The identifier (unique instance)
+    */
+    Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal)
+    {
+        static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
+        std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name);
+
+        if (it != identifiers.end())
+        {
+            // There is already an entry: return it and delete the proposal
+            delete proposal;
+            return (*it).second;
+        }
+        else
+        {
+            // There is no entry: put the proposal into the map and return it
+            identifiers[name] = proposal;
+            return proposal;
+        }
+    }
+
+    /**
+        @brief Registers a class, which means that the name and the parents get stored.
+        @param parents A list, containing the Identifiers of all parents of the class
+        @param bRootClass True if the class is either an Interface or the BaseObject itself
+    */
+    void Identifier::initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass)
+    {
+        // Check if at least one object of the given type was created
+        if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy())
+        {
+            // If no: We have to store the informations and initialize the Identifier
+            COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl;
+            if (bRootClass)
+                this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.
+            else
+                this->initialize(parents);
+        }
+    }
+
+    /**
+        @brief Initializes the Identifier with a list containing all parents of the class the Identifier belongs to.
+        @param parents A list containing all parents
+    */
+    void Identifier::initialize(std::set<const Identifier*>* parents)
+    {
+        COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl;
+        this->bCreatedOneObject_ = true;
+
+        if (parents)
+        {
+            this->parents_ = (*parents);
+            this->directParents_ = (*parents);
+
+            // Iterate through all parents
+            for (std::set<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it)
+            {
+                // Tell the parent we're one of it's children
+                (*it)->getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);
+
+                // Erase all parents of our parent from our direct-parent-list
+                for (std::set<const Identifier*>::const_iterator it1 = (*it)->getParents().begin(); it1 != (*it)->getParents().end(); ++it1)
+                {
+                    // Search for the parent's parent in our direct-parent-list
+                    for (std::set<const Identifier*>::iterator it2 = this->directParents_.begin(); it2 != this->directParents_.end(); ++it2)
+                    {
+                        if ((*it1) == (*it2))
+                        {
+                            // We've found a non-direct parent in our list: Erase it
+                            this->directParents_.erase(it2);
+                            break;
+                        }
+                    }
+                }
+            }
+
+            // Now iterate through all direct parents
+            for (std::set<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
+            {
+                // Tell the parent we're one of it's direct children
+                (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);
+
+                // Create the super-function dependencies
+                (*it)->createSuperFunctionCaller();
+            }
+        }
+    }
+
+    /**
+        @brief Destroys all Identifiers. Called when exiting the program.
+    */
+    void Identifier::destroyAllIdentifiers()
+    {
+        for (std::map<std::string, Identifier*>::iterator it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it)
+            delete (it->second);
+    }
+
+    /**
+        @brief Sets the name of the class.
+        @param name The name
+    */
+    void Identifier::setName(const std::string& name)
+    {
+        if (!this->bSetName_)
+        {
+            this->name_ = name;
+            this->bSetName_ = true;
+            Identifier::getIdentifierMapIntern()[name] = this;
+            Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
+        }
+    }
+
+    /**
+        @brief Creates an object of the type the Identifier belongs to.
+        @return The new object
+    */
+    BaseObject* Identifier::fabricate(BaseObject* creator)
+    {
+        if (this->factory_)
+        {
+            return this->factory_->fabricate(creator); // We have to return a BaseObject, because we don't know the exact type.
+        }
+        else
+        {
+            COUT(1) << "An error occurred in Identifier.cc:" << std::endl;
+            COUT(1) << "Error: Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << std::endl;
+            COUT(1) << "Aborting..." << std::endl;
+            abort();
+            return NULL;
+        }
+    }
+
+    /**
+        @brief Sets the network ID to a new value and changes the entry in the Factory.
+        @param id The new network ID
+    */
+    void Identifier::setNetworkID(unsigned int id)
+    {
+        Factory::changeNetworkID(this, this->classID_, id);
+        this->classID_ = id;
+    }
+
+    /**
+        @brief Returns true, if the Identifier is at least of the given type.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isA(const Identifier* identifier) const
+    {
+        return (identifier == this || (this->parents_.find(identifier) != this->parents_.end()));
+    }
+
+    /**
+        @brief Returns true, if the Identifier is exactly of the given type.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isExactlyA(const Identifier* identifier) const
+    {
+        return (identifier == this);
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a child of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isChildOf(const Identifier* identifier) const
+    {
+        return (this->parents_.find(identifier) != this->parents_.end());
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a direct child of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isDirectChildOf(const Identifier* identifier) const
+    {
+        return (this->directParents_.find(identifier) != this->directParents_.end());
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a parent of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isParentOf(const Identifier* identifier) const
+    {
+        return (this->children_->find(identifier) != this->children_->end());
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a direct parent of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isDirectParentOf(const Identifier* identifier) const
+    {
+        return (this->directChildren_->find(identifier) != this->directChildren_->end());
+    }
+
+    /**
+        @brief Returns the map that stores all Identifiers.
+        @return The map
+    */
+    std::map<std::string, Identifier*>& Identifier::getIdentifierMapIntern()
+    {
+        static std::map<std::string, Identifier*> identifierMap;
+        return identifierMap;
+    }
+
+    /**
+        @brief Returns the map that stores all Identifiers.
+        @return The map
+    */
+    std::map<std::string, Identifier*>& Identifier::getLowercaseIdentifierMapIntern()
+    {
+        static std::map<std::string, Identifier*> lowercaseIdentifierMap;
+        return lowercaseIdentifierMap;
+    }
+
+    /**
+        @brief Adds the ConfigValueContainer of a variable, given by the string of its name.
+        @param varname The name of the variablee
+        @param container The container
+    */
+    void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
+    {
+        std::map<std::string, ConfigValueContainer*>::const_iterator it = this->configValues_.find(varname);
+        if (it != this->configValues_.end())
+        {
+            COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->bHasConfigValues_ = true;
+        this->configValues_[varname] = container;
+        this->configValues_LC_[getLowercase(varname)] = container;
+    }
+
+    /**
+        @brief Returns the ConfigValueContainer of a variable, given by the string of its name.
+        @param varname The name of the variable
+        @return The ConfigValueContainer
+    */
+    ConfigValueContainer* Identifier::getConfigValueContainer(const std::string& varname)
+    {
+        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname);
+        if (it != configValues_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns the ConfigValueContainer of a variable, given by the string of its name in lowercase.
+        @param varname The name of the variable in lowercase
+        @return The ConfigValueContainer
+    */
+    ConfigValueContainer* Identifier::getLowercaseConfigValueContainer(const std::string& varname)
+    {
+        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname);
+        if (it != configValues_LC_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new console command of this class.
+        @param executor The executor of the command
+        @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command
+        @return The executor of the command
+    */
+    ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());
+        if (it != this->consoleCommands_.end())
+        {
+            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->bHasConsoleCommands_ = true;
+        this->consoleCommands_[command->getName()] = command;
+        this->consoleCommands_LC_[getLowercase(command->getName())] = command;
+
+        if (bCreateShortcut)
+            CommandExecutor::addConsoleCommandShortcut(command);
+
+        return (*command);
+    }
+
+    /**
+        @brief Returns the executor of a console command with given name.
+        @brief name The name of the requested console command
+        @return The executor of the requested console command
+    */
+    ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);
+        if (it != this->consoleCommands_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns the executor of a console command with given name in lowercase.
+        @brief name The name of the requested console command in lowercae
+        @return The executor of the requested console command
+    */
+    ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);
+        if (it != this->consoleCommands_LC_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns a XMLPortParamContainer that loads a parameter of this class.
+        @param paramname The name of the parameter
+        @return The container
+    */
+    XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)
+    {
+        std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
+        if (it != this->xmlportParamContainers_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new XMLPortParamContainer that loads a parameter of this class.
+        @param paramname The name of the parameter
+        @param container The container
+    */
+    void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
+    {
+        std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
+        if (it != this->xmlportParamContainers_.end())
+        {
+            COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->xmlportParamContainers_[paramname] = container;
+    }
+
+    /**
+        @brief Returns a XMLPortObjectContainer that attaches an object to this class.
+        @param sectionname The name of the section that contains the attachable objects
+        @return The container
+    */
+    XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)
+    {
+        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
+        if (it != this->xmlportObjectContainers_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new XMLPortObjectContainer that attaches an object to this class.
+        @param sectionname The name of the section that contains the attachable objects
+        @param container The container
+    */
+    void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
+    {
+        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
+        if (it != this->xmlportObjectContainers_.end())
+        {
+            COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->xmlportObjectContainers_[sectionname] = container;
+    }
+
+    /**
+        @brief Returns a XMLPortEventContainer that attaches an event to this class.
+        @param sectionname The name of the section that contains the event
+        @return The container
+    */
+    XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname)
+    {
+        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
+        if (it != this->xmlportEventContainers_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new XMLPortEventContainer that attaches an event to this class.
+        @param sectionname The name of the section that contains the event
+        @param container The container
+    */
+    void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container)
+    {
+        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
+        if (it != this->xmlportEventContainers_.end())
+        {
+            COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->xmlportEventContainers_[eventname] = container;
+    }
+
+    /**
+        @brief Adds a construction callback functor that gets called every time an object is created.
+        @param functor Functor pointer to any function with no argument.
+    */
+    void Identifier::addConstructionCallback(Functor* functor)
+    {
+        for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
+        {
+            if (this->constructionCallbacks_[i] == functor)
+                return;
+        }
+        this->constructionCallbacks_.push_back(functor);
+        this->bHasConstructionCallback_ = true;
+    }
+
+    /**
+        @brief Removes a construction callback functor that gets called every time an object is created.
+        @param functor Functor pointer to any function with no argument.
+    */
+    void Identifier::removeConstructionCallback(Functor* functor)
+    {
+        for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
+        {
+            if (this->constructionCallbacks_[i] == functor)
+            {
+                this->constructionCallbacks_.erase(this->constructionCallbacks_.begin() + i);
+            }
+        }
+        if (constructionCallbacks_.empty())
+            this->bHasConstructionCallback_ = false;
+    }
+
+    /**
+        @brief Lists the names of all Identifiers in a std::set<const Identifier*>.
+        @param out The outstream
+        @param list The list (or set) of Identifiers
+        @return The outstream
+    */
+    std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list)
+    {
+        for (std::set<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it)
+            out << (*it)->getName() << " ";
+
+        return out;
+    }
+}
Index: /code/branches/physics/src/core/Identifier.h
===================================================================
--- /code/branches/physics/src/core/Identifier.h	(revision 2122)
+++ /code/branches/physics/src/core/Identifier.h	(revision 2122)
@@ -0,0 +1,629 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Identifier.h
+    @brief Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes, implementation of the ClassIdentifier and SubclassIdentifier classes.
+
+    The Identifier contains all needed informations about the class it belongs to:
+     - the name
+     - a list with all objects
+     - parents and children
+     - the factory (if available)
+     - the networkID that can be synchronised with the server
+     - all configurable variables (if available)
+
+    Every object has a pointer to the Identifier of its class. This allows the use isA(...),
+    isExactlyA(...), isChildOf(...) and isParentOf(...).
+
+    To create the class-hierarchy, the Identifier has some intern functions and variables.
+
+    Every Identifier is in fact a ClassIdentifier, but they are derived from Identifier.
+
+    SubclassIdentifier is a separated class, acting like an Identifier, but has a given class.
+    You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier.
+*/
+
+#ifndef _Identifier_H__
+#define _Identifier_H__
+
+#include "CorePrereqs.h"
+
+#include <set>
+#include <map>
+#include <vector>
+#include <string>
+#include <utility>
+#include <typeinfo>
+#include <stdlib.h>
+#include <cassert>
+
+#include "MetaObjectList.h"
+#include "Iterator.h"
+#include "Super.h"
+#include "Functor.h"
+#include "util/Debug.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###       Identifier        ###
+    // ###############################
+    //! The Identifier is used to identify the class of an object and to store informations about the class.
+    /**
+        The Identifier contains all needed informations about the class it belongs to:
+         - the name
+         - a list with all objects
+         - parents and children
+         - the factory (if available)
+         - the networkID that can be synchronised with the server
+         - all configurable variables (if available)
+
+        Every object has a pointer to the Identifier of its class. This allows the use isA(...),
+        isExactlyA(...), isChildOf(...) and isParentOf(...).
+
+        You can't directly create an Identifier, it's just the base-class for ClassIdentifier.
+    */
+    class _CoreExport Identifier
+    {
+        template <class T>
+        friend class SubclassIdentifier;
+
+        friend class Factory;
+
+        public:
+            /** @brief Sets the Factory. @param factory The factory to assign */
+            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
+
+            BaseObject* fabricate(BaseObject* creator);
+            bool isA(const Identifier* identifier) const;
+            bool isExactlyA(const Identifier* identifier) const;
+            bool isChildOf(const Identifier* identifier) const;
+            bool isDirectChildOf(const Identifier* identifier) const;
+            bool isParentOf(const Identifier* identifier) const;
+            bool isDirectParentOf(const Identifier* identifier) const;
+
+            /** @brief Returns true if the class can be loaded through XML. */
+            inline bool isLoadable() const { return this->bLoadable_; }
+            /** @brief Set the class to be loadable through XML or not. */
+            inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
+
+            /** @brief Returns the list of all existing objects of this class. @return The list */
+            inline ObjectListBase* getObjects() const
+                { return this->objects_; }
+
+            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
+            inline const std::string& getName() const { return this->name_; }
+            void setName(const std::string& name);
+
+            virtual void updateConfigValues(bool updateChildren = true) const = 0;
+
+            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
+            inline const std::set<const Identifier*>& getParents() const { return this->parents_; }
+            /** @brief Returns the begin-iterator of the parents-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); }
+            /** @brief Returns the end-iterator of the parents-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); }
+
+            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
+            inline const std::set<const Identifier*>& getChildren() const { return (*this->children_); }
+            /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); }
+            /** @brief Returns the end-iterator of the children-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); }
+
+            /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */
+            inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; }
+            /** @brief Returns the begin-iterator of the direct-parents-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); }
+            /** @brief Returns the end-iterator of the direct-parents-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); }
+
+            /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */
+            inline const std::set<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); }
+            /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); }
+            /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); }
+
+
+            /** @brief Returns the map that stores all Identifiers. @return The map */
+            static inline const std::map<std::string, Identifier*>& getIdentifierMap() { return Identifier::getIdentifierMapIntern(); }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapBegin() { return Identifier::getIdentifierMap().begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapEnd() { return Identifier::getIdentifierMap().end(); }
+
+            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
+            static inline const std::map<std::string, Identifier*>& getLowercaseIdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapEnd() { return Identifier::getLowercaseIdentifierMap().end(); }
+
+
+            /** @brief Returns the map that stores all config values. @return The const_iterator */
+            inline const std::map<std::string, ConfigValueContainer*>& getConfigValueMap() const { return this->configValues_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all config values. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapBegin() const { return this->configValues_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all config values. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapEnd() const { return this->configValues_.end(); }
+
+            /** @brief Returns the map that stores all config values with their names in lowercase. @return The const_iterator */
+            inline const std::map<std::string, ConfigValueContainer*>& getLowercaseConfigValueMap() const { return this->configValues_LC_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all config values with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapBegin() const { return this->configValues_LC_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all config values with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); }
+
+
+            /** @brief Returns the map that stores all console commands. @return The const_iterator */
+            inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandMap() const { return this->consoleCommands_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); }
+
+            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }
+
+            /** @brief Returns the map that stores all XMLPort params. @return The const_iterator */
+            inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort params. @return The const_iterator */
+            inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapBegin() const { return this->xmlportParamContainers_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all XMLPort params. @return The const_iterator */
+            inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapEnd() const { return this->xmlportParamContainers_.end(); }
+
+            /** @brief Returns the map that stores all XMLPort objects. @return The const_iterator */
+            inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortObjectMap() const { return this->xmlportObjectContainers_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort objects. @return The const_iterator */
+            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapBegin() const { return this->xmlportObjectContainers_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all XMLPort objects. @return The const_iterator */
+            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); }
+
+            /** @brief Returns the map that stores all XMLPort events. @return The const_iterator */
+            inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortEventMap() const { return this->xmlportEventContainers_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort events. @return The const_iterator */
+            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapBegin() const { return this->xmlportEventContainers_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all XMLPort events. @return The const_iterator */
+            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapEnd() const { return this->xmlportEventContainers_.end(); }
+
+            /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
+            inline bool hasConfigValues() const { return this->bHasConfigValues_; }
+            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
+            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
+            /** @brief Returns true if this class has at least one construction callback Functor registered. */
+            inline bool hasConstructionCallback() const { return this->bHasConstructionCallback_; }
+
+            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
+            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
+
+            /** @brief Returns the network ID to identify a class through the network. @return the network ID */
+            inline const unsigned int getNetworkID() const { return this->classID_; }
+
+            /** @brief Sets the network ID to a new value. @param id The new value */
+            void setNetworkID(unsigned int id);
+
+            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
+            ConfigValueContainer* getConfigValueContainer(const std::string& varname);
+            ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
+
+            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
+            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
+
+            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
+            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
+
+            void addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container);
+            XMLPortObjectContainer* getXMLPortEventContainer(const std::string& eventname);
+
+            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
+            ConsoleCommand* getConsoleCommand(const std::string& name) const;
+            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
+
+            void addConstructionCallback(Functor* functor);
+            void removeConstructionCallback(Functor* functor);
+
+            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
+
+        protected:
+            Identifier();
+            Identifier(const Identifier& identifier); // don't copy
+            virtual ~Identifier();
+
+            static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal);
+            virtual void createSuperFunctionCaller() const = 0;
+
+            /** @brief Returns the map that stores all Identifiers. @return The map */
+            static std::map<std::string, Identifier*>& getIdentifierMapIntern();
+            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
+            static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern();
+
+            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
+            inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); }
+            /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */
+            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
+
+            bool bHasConstructionCallback_;                                //!< True if at least one Functor is registered to get informed when an object of type T is created.
+            std::vector<Functor*> constructionCallbacks_;                  //!< All construction callback Functors of this class.
+
+            ObjectListBase* objects_;                                      //!< The list of all objects of this class
+
+        private:
+            /**
+                @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
+            */
+            inline static void startCreatingHierarchy()
+            {
+                hierarchyCreatingCounter_s++;
+                COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
+            }
+
+            /**
+                @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
+            */
+            inline static void stopCreatingHierarchy()
+            {
+                hierarchyCreatingCounter_s--;
+                COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
+            }
+
+            void initialize(std::set<const Identifier*>* parents);
+
+            static void destroyAllIdentifiers();
+
+            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
+            std::set<const Identifier*>* children_;                        //!< The children of the class the Identifier belongs to
+
+            std::set<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to
+            std::set<const Identifier*>* directChildren_;                  //!< The direct children of the class the Identifier belongs to
+
+            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
+            bool bSetName_;                                                //!< True if the name is set
+            bool bLoadable_;                                               //!< False = it's not permitted to load the object through XML
+            std::string name_;                                             //!< The name of the class the Identifier belongs to
+            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
+            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
+            unsigned int classID_;                                         //!< The network ID to identify a class through the network
+
+            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
+            std::map<std::string, ConfigValueContainer*> configValues_;    //!< A map to link the string of configurable variables with their ConfigValueContainer
+            std::map<std::string, ConfigValueContainer*> configValues_LC_; //!< A map to link the string of configurable variables with their ConfigValueContainer
+
+            bool bHasConsoleCommands_;                                     //!< True if this class has at least one assigned console command
+            std::map<std::string, ConsoleCommand*> consoleCommands_;       //!< All console commands of this class
+            std::map<std::string, ConsoleCommand*> consoleCommands_LC_;    //!< All console commands of this class with their names in lowercase
+
+            std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_;     //!< All loadable parameters
+            std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_;   //!< All attachable objects
+            std::map<std::string, XMLPortObjectContainer*> xmlportEventContainers_;    //!< All events
+    };
+
+    _CoreExport std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list);
+
+
+    // ###############################
+    // ###     ClassIdentifier     ###
+    // ###############################
+    //! The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables the Identifier cannot have.
+    /**
+        ClassIdentifier is a Singleton, which means that only one object of a given type T exists.
+        This makes it possible to store informations about a class, sharing them with all
+        objects of that class without defining static variables in every class.
+
+        To be really sure that not more than exactly one object exists (even with libraries),
+        ClassIdentifiers are stored in the Identifier Singleton.
+    */
+    template <class T>
+    class ClassIdentifier : public Identifier
+    {
+        #define SUPER_INTRUSIVE_DECLARATION_INCLUDE
+        #include "Super.h"
+
+        public:
+            static ClassIdentifier<T> *getIdentifier();
+            static ClassIdentifier<T> *getIdentifier(const std::string& name);
+            void addObject(T* object);
+            static bool isFirstCall();
+
+            void updateConfigValues(bool updateChildren = true) const;
+
+        private:
+            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
+            ClassIdentifier()
+            {
+                SuperFunctionInitialization<0, T>::initialize(this);
+            }
+            ~ClassIdentifier()
+            {
+                SuperFunctionDestruction<0, T>::destroy(this);
+            }
+
+            static ClassIdentifier<T>* classIdentifier_s;
+    };
+
+    template <class T>
+    ClassIdentifier<T>* ClassIdentifier<T>::classIdentifier_s;
+
+    /**
+        @brief Returns true if the function gets called the first time, false otherwise.
+        @return True if this function got called the first time.
+    */
+    template <class T>
+    bool ClassIdentifier<T>::isFirstCall()
+    {
+        static bool bFirstCall = true;
+
+        if (bFirstCall)
+        {
+            bFirstCall = false;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+        @brief Returns the only instance of this class.
+        @return The unique Identifier
+    */
+    template <class T>
+    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
+    {
+        // check if the static field has already been filled
+        if (ClassIdentifier<T>::isFirstCall())
+        {
+            // Get the name of the class
+            std::string name = typeid(T).name();
+
+            // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.
+            ClassIdentifier<T>* proposal = new ClassIdentifier<T>();
+
+            // Get the entry from the map
+            ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifierSingleton(name, proposal);
+
+            if (ClassIdentifier<T>::classIdentifier_s == proposal)
+            {
+                COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl;
+            }
+            else
+            {
+                COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl;
+            }
+        }
+
+        // Finally return the unique ClassIdentifier
+        return ClassIdentifier<T>::classIdentifier_s;
+    }
+
+    /**
+        @brief Does the same as getIdentifier() but sets the name if this wasn't done yet.
+        @param name The name of this Identifier
+        @return The Identifier
+    */
+    template <class T>
+    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)
+    {
+        ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
+        identifier->setName(name);
+        return identifier;
+    }
+
+    /**
+        @brief Adds an object of the given type to the ObjectList.
+        @param object The object to add
+    */
+    template <class T>
+    void ClassIdentifier<T>::addObject(T* object)
+    {
+        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
+        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
+        if (this->bHasConstructionCallback_)
+        {
+            // Call all registered callbacks that a new object of type T has been created.
+            // Do NOT deliver a T* pointer here because it's way too risky (object not yet fully created).
+            for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
+                (*constructionCallbacks_[i])();
+        }
+    }
+
+    /**
+        @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
+    */
+    template <class T>
+    void ClassIdentifier<T>::updateConfigValues(bool updateChildren) const
+    {
+        if (!this->hasConfigValues())
+            return;
+
+        for (ObjectListIterator<T> it = ObjectList<T>::begin(); it; ++it)
+            it->setConfigValues();
+
+        if (updateChildren)
+            for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
+                (*it)->updateConfigValues(false);
+    }
+
+
+    // ###############################
+    // ###   SubclassIdentifier    ###
+    // ###############################
+    //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
+    /**
+        You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>.
+        If you assign something else, the program aborts.
+        Because we know the minimum type, a dynamic_cast is done, which makes it easier to create a new object.
+    */
+    template <class T>
+    class SubclassIdentifier
+    {
+        public:
+            /**
+                @brief Constructor: Automaticaly assigns the Identifier of the given class.
+            */
+            SubclassIdentifier()
+            {
+                this->identifier_ = ClassIdentifier<T>::getIdentifier();
+            }
+
+            /**
+                @brief Copyconstructor: Assigns the given Identifier.
+                @param identifier The Identifier
+            */
+            SubclassIdentifier(Identifier* identifier)
+            {
+                this->operator=(identifier);
+            }
+
+            /**
+                @brief Overloading of the = operator: assigns the identifier and checks its type.
+                @param identifier The Identifier to assign
+                @return The SubclassIdentifier itself
+            */
+            SubclassIdentifier<T>& operator=(Identifier* identifier)
+            {
+                if (!identifier || !identifier->isA(ClassIdentifier<T>::getIdentifier()))
+                {
+                    COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
+                    if (identifier)
+                    {
+                        COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+                        COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
+                    }
+                    else
+                    {
+                        COUT(1) << "Error: Can't assign NULL identifier" << std::endl;
+                    }
+                }
+                else
+                {
+                    this->identifier_ = identifier;
+                }
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the * operator: returns the assigned identifier.
+            */
+            inline Identifier* operator*() const
+            {
+                return this->identifier_;
+            }
+
+            /**
+                @brief Overloading of the -> operator: returns the assigned identifier.
+            */
+            inline Identifier* operator->() const
+            {
+                return this->identifier_;
+            }
+
+            /**
+                @brief Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*.
+            */
+            inline operator Identifier*() const
+            {
+                return this->identifier_;
+            }
+
+            /**
+                @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
+                @return The new object
+            */
+            T* fabricate(BaseObject* creator) const
+            {
+                BaseObject* newObject = this->identifier_->fabricate(creator);
+
+                // Check if the creation was successful
+                if (newObject)
+                {
+                    return dynamic_cast<T*>(newObject);
+                }
+                else
+                {
+                    // Something went terribly wrong
+                    if (this->identifier_)
+                    {
+                        COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
+                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+                        COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
+                        COUT(1) << "Aborting..." << std::endl;
+                    }
+                    else
+                    {
+                        COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
+                        COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl;
+                        COUT(1) << "Aborting..." << std::endl;
+                    }
+
+                    assert(false);
+                    return 0;
+                }
+            }
+
+            /** @brief Returns the assigned identifier. @return The identifier */
+            inline Identifier* getIdentifier() const
+                { return this->identifier_; }
+
+//            /** @brief Returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */
+//            inline bool isA(const Identifier* identifier) const
+//                { return this->identifier_->isA(identifier); }
+//
+//            /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
+//            inline bool isExactlyA(const Identifier* identifier) const
+//                { return this->identifier_->isExactlyA(identifier); }
+//
+//            /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
+//            inline bool isChildOf(const Identifier* identifier) const
+//                { return this->identifier_->isChildOf(identifier); }
+//
+//            /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */
+//            inline bool isDirectChildOf(const Identifier* identifier) const
+//                { return this->identifier_->isDirectChildOf(identifier); }
+//
+//            /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
+//            inline bool isParentOf(const Identifier* identifier) const
+//                { return this->identifier_->isParentOf(identifier); }
+//
+//            /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */
+//            inline bool isDirectParentOf(const Identifier* identifier) const
+//                { return this->identifier_->isDirectParentOf(identifier); }
+
+        private:
+            Identifier* identifier_;            //!< The assigned identifier
+    };
+}
+
+#endif /* _Identifier_H__ */
Index: /code/branches/physics/src/core/Iterator.h
===================================================================
--- /code/branches/physics/src/core/Iterator.h	(revision 2122)
+++ /code/branches/physics/src/core/Iterator.h	(revision 2122)
@@ -0,0 +1,311 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Iterator.h
+    @brief Definition and implementation of the Iterator class.
+
+    The Iterator of a given class allows to iterate through an ObjectList. Objects in
+    this list are casted to the template argument of the Iterator.
+
+    Usage:
+    for (Iterator<myClass> it = anyidentifier->getObjects()->begin(); it != anyidentifier->getObjects()->end(); ++it)
+    {
+        it->someFunction(...);
+        myClass* myObject = *it;
+    }
+*/
+
+#ifndef _Iterator_H__
+#define _Iterator_H__
+
+#include "CorePrereqs.h"
+
+#include "ObjectListBase.h"
+#include "ObjectListIterator.h"
+#include "OrxonoxClass.h"
+
+namespace orxonox
+{
+    //! The Iterator allows to iterate through a given ObjectList
+    template <class T = OrxonoxClass>
+    class Iterator
+    {
+        public:
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to zero.
+            */
+            inline Iterator()
+            {
+                this->element_ = 0;
+                this->list_ = 0;
+            }
+
+            /**
+                @brief Constructor: Sets this element to the exported element.
+                @param exp The exported element
+            */
+            inline Iterator(const ObjectListBase::Export& exp)
+            {
+                this->element_ = exp.element_;
+                this->list_ = exp.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to the element of another Iterator.
+                @param other The other Iterator
+            */
+            inline Iterator(const Iterator<T>& other)
+            {
+                this->element_ = other.element_;
+                this->list_ = other.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to a given element
+                @param element The element
+            */
+            template <class O>
+            inline Iterator(ObjectListElement<O>* element)
+            {
+                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to the element an ObjectListIterator.
+                @param other The ObjectListIterator
+            */
+            template <class O>
+            inline Iterator(const ObjectListIterator<O>& other)
+            {
+                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Unregisters the Iterator from the ObjectList.
+            */
+            inline ~Iterator()
+            {
+                this->list_->unregisterIterator(this->iterator_);
+            }
+
+            /**
+                @brief Assigns an exported element.
+                @param exp The exported element
+            */
+            inline const Iterator<T>& operator=(const ObjectListBase::Export& exp)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = exp.element_;
+                this->list_ = exp.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+            }
+
+            /**
+                @brief Assigns the element of another Iterator.
+                @param other The other Iterator
+            */
+            inline const Iterator<T>& operator=(const Iterator<T>& other)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = other.element_;
+                this->list_ = other.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+            }
+
+            /**
+                @brief Assigns a given element.
+                @param element The element
+            */
+            template <class O>
+            inline const Iterator<T>& operator=(ObjectListElement<O>* element)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+                return *this;
+            }
+
+            /**
+                @brief Assigns the element of an ObjectListIterator.
+                @param other The ObjectListIterator
+            */
+            template <class O>
+            inline const Iterator<T>& operator=(const ObjectListIterator<O>& other)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+            }
+
+            /**
+                @brief Overloading of the ++it operator: Iterator points to the next object in the list.
+                @return The Iterator itself
+            */
+            inline const Iterator<T>& operator++()
+            {
+                if (this->element_)
+                    this->element_ = this->element_->next_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it++ operator: Iterator points to the next object in the list.
+                @return The Iterator itself
+            */
+            inline Iterator<T> operator++(int i)
+            {
+                Iterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = this->element_->next_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the --it operator: Iterator points to the previous object in the list.
+                @return The Iterator itself
+            */
+            inline const Iterator<T>& operator--()
+            {
+                if (this->element_)
+                    this->element_ = this->element_->prev_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it-- operator: Iterator points to the previous object in the list.
+                @return The Iterator itself
+            */
+            inline Iterator<T> operator--(int i)
+            {
+                Iterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = this->element_->prev_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the *it operator: returns the pointer to the object.
+                @return The object the Iterator points at
+            */
+            inline T* operator*() const
+            {
+                if (this->element_)
+                    return dynamic_cast<T*>(this->element_->objectBase_);
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the it-> operator: returns the pointer to the object.
+                @return The object the Iterator points at
+            */
+            inline T* operator->() const
+            {
+                if (this->element_)
+                    return dynamic_cast<T*>(this->element_->objectBase_);
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
+                @return True if the Iterator points to an existing object.
+            */
+            inline operator bool() const
+            {
+                return (this->element_ != 0);
+            }
+
+            /**
+                @brief Overloading of the == operator to compare with another Iterator.
+                @param compare The other Iterator
+                @return True if the iterators point to the same element
+            */
+            inline bool operator==(const Iterator<T>& compare) const
+            {
+                return (this->element_ == compare.element_);
+            }
+
+            /**
+                @brief Overloading of the != operator to compare with another Iterator.
+                @param compare The other Iterator
+                @return True if the iterators point to different elements
+            */
+            inline bool operator!=(const Iterator<T>& compare) const
+            {
+                return (this->element_ != compare.element_);
+            }
+
+            /**
+                @brief Increments the Iterator if it points at the given object.
+                @param object The object to compare with
+            */
+            inline void incrementIfEqual(OrxonoxClass* object)
+            {
+                if (this->element_ && this->element_->objectBase_ == object)
+                    this->operator++();
+            }
+
+        protected:
+            ObjectListBaseElement* element_;       //!< The element the Iterator points at
+            ObjectListBase* list_;                 //!< The list wherein the element is
+            std::list<void*>::iterator iterator_;  //!< The iterator in the notifying list of the ObjectList
+    };
+
+    typedef Iterator<OrxonoxClass> BaseIterator;
+}
+
+// Include ObjectList.h so the user only has to include one file: Iterator.h
+#include "ObjectList.h"
+
+#endif /* _Iterator_H__ */
Index: /code/branches/physics/src/core/Language.cc
===================================================================
--- /code/branches/physics/src/core/Language.cc	(revision 2122)
+++ /code/branches/physics/src/core/Language.cc	(revision 2122)
@@ -0,0 +1,330 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Language.cc
+    @brief Implementation of the Language and the LanguageEntry classes.
+*/
+
+#include "Language.h"
+
+#include <fstream>
+
+#include "Core.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###      LanguageEntry      ###
+    // ###############################
+    /**
+        @brief Constructor: Sets the default entry.
+        @param fallbackEntry The default entry
+    */
+    LanguageEntry::LanguageEntry(const std::string& fallbackEntry)
+    {
+        this->fallbackEntry_ = fallbackEntry;
+        this->localisedEntry_ = fallbackEntry; // Set the localisation to the fallback entry, for the case that no translation gets assigned
+        this->bLocalisationSet_ = false;
+    }
+
+    /**
+        @brief Sets the localisation of the entry.
+        @param localisation The localisation
+    */
+    void LanguageEntry::setLocalisation(const std::string& localisation)
+    {
+        // Check if the translation is more than just an empty string
+        if ((localisation != "") && (localisation.size() > 0))
+        {
+            this->localisedEntry_ = localisation;
+            this->bLocalisationSet_ = true;
+        }
+        else
+            this->localisedEntry_ = this->fallbackEntry_;
+    }
+
+    /**
+        @brief Sets the default entry.
+        @param fallbackEntry The default entry
+    */
+    void LanguageEntry::setDefault(const std::string& fallbackEntry)
+    {
+        // If the default entry changes and the translation wasn't set yet, use the new default entry as translation
+        if (!this->bLocalisationSet_)
+            this->localisedEntry_ = fallbackEntry;
+
+        this->fallbackEntry_ = fallbackEntry;
+    }
+
+    // ###############################
+    // ###        Language         ###
+    // ###############################
+    /**
+        @brief Constructor: Reads the default language file and sets some values.
+    */
+    Language::Language()
+    {
+        this->defaultLanguage_ = "default";
+        this->defaultLocalisation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!";
+
+        // Read the default language file to create all known LanguageEntry objects
+        this->readDefaultLanguageFile();
+    }
+
+    /**
+        @brief Destructor: Deletes all language entries.
+    */
+    Language::~Language()
+    {
+        for (std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
+            delete (it->second);
+    }
+
+    /**
+        @brief Returns a reference to the only existing instance of the Language class and calls the setConfigValues() function.
+        @return The reference to the only existing instance
+    */
+    Language& Language::getLanguage()
+    {
+        static Language instance = Language();
+        return instance;
+    }
+
+    /**
+        @brief Creates a new LanguageEntry with a given label and a given default entry.
+        @param label The label of the entry
+        @param entry The default entry
+        @return The created LanguageEntry object
+    */
+    LanguageEntry* Language::createEntry(const LanguageEntryLabel& label, const std::string& entry)
+    {
+        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
+
+        // Make sure we don't create a duplicate entry
+        if (it == this->languageEntries_.end())
+        {
+            LanguageEntry* newEntry = new LanguageEntry(entry);
+            newEntry->setLabel(label);
+            this->languageEntries_[label] = newEntry;
+            return newEntry;
+        }
+
+        COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << "!" << std::endl;
+        return it->second;
+    }
+
+    /**
+        @brief Adds a new LanguageEntry, if it's not already existing.
+        @param label The label of the entry
+        @param entry The default entry
+    */
+    void Language::addEntry(const LanguageEntryLabel& label, const std::string& entry)
+    {
+        COUT(5) << "Language: Called addEntry with\n  label: " << label << "\n  entry: " <<  entry << std::endl;
+        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
+        if (it == this->languageEntries_.end())
+        {
+            // The entry isn't available yet, meaning it's new, so create it
+            this->createEntry(label, entry);
+        }
+        else if (it->second->getDefault().compare(entry) == 0)
+        {
+            // The entry is available and the default string is the same, so return because everything is fine
+            return;
+        }
+        else
+        {
+            // The defined default entry is not the same as in the default language file - change it to the new entry
+            it->second->setDefault(entry);
+        }
+
+        // Write the default language file because either a new entry was created or an existing entry has changed
+        this->writeDefaultLanguageFile();
+
+    }
+
+    /**
+        @brief Returns the localisation of a given entry.
+        @param label The label of the entry
+        @return The localisation
+    */
+    const std::string& Language::getLocalisation(const LanguageEntryLabel& label) const
+    {
+        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
+        if (it != this->languageEntries_.end())
+            return it->second->getLocalisation();
+        else
+        {
+            // Uh, oh, an undefined entry was requested: return the default string
+            COUT(2) << "Warning: Language entry \"" << label << "\" not found!" << std::endl;
+            return this->defaultLocalisation_;
+        }
+    }
+
+    /**
+        @brief Creates the name of the language file out of the languages name.
+        @param language The name of the language
+        @return The filename
+    */
+    const std::string Language::getFilename(const std::string& language)
+    {
+        return std::string("translation_" + language + ".lang");
+    }
+
+    /**
+        @brief Reads the default language file and creates a LanguageEntry objects for every entry.
+    */
+    void Language::readDefaultLanguageFile()
+    {
+        COUT(4) << "Read default language file." << std::endl;
+
+        // This creates the file if it's not existing
+        std::ofstream createFile;
+        createFile.open(getFilename(this->defaultLanguage_).c_str(), std::fstream::app);
+        createFile.close();
+
+        // Open the file
+        std::ifstream file;
+        file.open(getFilename(this->defaultLanguage_).c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in Language.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open file " << getFilename(this->defaultLanguage_) << " to read the default language entries!" << std::endl;
+            return;
+        }
+
+        char line[1024];
+
+        // Iterate through the file and create the LanguageEntries
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            std::string lineString = std::string(line);
+
+            // Check if the line is empty
+            if ((lineString != "") && (lineString.size() > 0))
+            {
+                unsigned int pos = lineString.find('=');
+
+                // Check if the length is at least 3 and if there's an entry before and behind the =
+                if (pos > 0 && pos < (lineString.size() - 1) && lineString.size() >= 3)
+                    this->createEntry(lineString.substr(0, pos), lineString.substr(pos + 1));
+                else
+                {
+                    COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(this->defaultLanguage_) << std::endl;
+                }
+            }
+        }
+
+        file.close();
+    }
+
+    /**
+        @brief Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object.
+    */
+    void Language::readTranslatedLanguageFile()
+    {
+        COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
+
+        // Open the file
+        std::ifstream file;
+        file.open(getFilename(Core::getLanguage()).c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in Language.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open file " << getFilename(Core::getLanguage()) << " to read the translated language entries!" << std::endl;
+            Core::resetLanguage();
+            COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl;
+            return;
+        }
+
+        char line[1024];
+
+        // Iterate through the file and create the LanguageEntries
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            std::string lineString = std::string(line);
+
+            // Check if the line is empty
+            if ((lineString != "") && (lineString.size() > 0))
+            {
+                unsigned int pos = lineString.find('=');
+
+                // Check if the length is at least 3 and if there's an entry before and behind the =
+                if (pos > 0 && pos < (lineString.size() - 1) && lineString.size() >= 3)
+                {
+                    std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(lineString.substr(0, pos));
+
+                    // Check if the entry exists
+                    if (it != this->languageEntries_.end())
+                        it->second->setLocalisation(lineString.substr(pos + 1));
+                    else
+                        this->createEntry(lineString.substr(0, pos), this->defaultLocalisation_)->setLocalisation(lineString.substr(pos + 1));
+                }
+                else
+                {
+                    COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getLanguage()) << std::endl;
+                }
+            }
+        }
+
+        file.close();
+    }
+
+    /**
+        @brief Writes all default entries to the default language file.
+    */
+    void Language::writeDefaultLanguageFile() const
+    {
+        COUT(4) << "Language: Write default language file." << std::endl;
+
+        // Open the file
+        std::ofstream file;
+        file.open(getFilename(this->defaultLanguage_).c_str(), std::fstream::out);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in Language.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open file " << getFilename(this->defaultLanguage_) << " to write the default language entries!" << std::endl;
+            return;
+        }
+
+        // Iterate through the list an write the lines into the file
+        for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
+        {
+            file << (*it).second->getLabel() << "=" << (*it).second->getDefault() << std::endl;
+        }
+
+        file.close();
+    }
+}
Index: /code/branches/physics/src/core/Language.h
===================================================================
--- /code/branches/physics/src/core/Language.h	(revision 2122)
+++ /code/branches/physics/src/core/Language.h	(revision 2122)
@@ -0,0 +1,139 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Language.h
+    @brief Definition of the Language and the LanguageEntry class.
+
+    The Language class is used, to get a localisation of a string in the configured language.
+    The string is identified by another string, the label of the entry.
+    If the translation in the configured language isn't available, the default entry, defined in the code, is used.
+
+    Usage:
+     - Set the entry with the default string:
+       Language::getLanguage()->addEntry("label of the entry", "the string to translate");
+
+     - Get the localisation of the entry in the configured language:
+       std::cout << Language::getLanguage()->getLocalisation("name of the entry") << std::endl;
+*/
+
+#ifndef _Language_H__
+#define _Language_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+#include <string>
+
+#define AddLanguageEntry(label, fallbackstring) \
+    orxonox::Language::getLanguage().addEntry(label, fallbackstring)
+
+#define GetLocalisation(label) \
+    orxonox::Language::getLanguage().getLocalisation(label)
+
+
+namespace orxonox
+{
+    // ###############################
+    // ###      LanguageEntry      ###
+    // ###############################
+    //! The LanguageEntry class stores the default- and the translated string of a given entry in the language file.
+    class _CoreExport LanguageEntry
+    {
+        public:
+            explicit LanguageEntry(const std::string& fallbackEntry);
+            void setLocalisation(const std::string& localisation);
+            void setDefault(const std::string& fallbackEntry);
+
+            /**
+              @brief Returns the localised entry in the configured language.
+              @return The translated entry
+            */
+            inline const std::string& getLocalisation()
+                { return this->localisedEntry_; }
+
+            /**
+              @brief Returns the default entry.
+              @return The default entry
+            */
+            inline const std::string& getDefault()
+                { return this->fallbackEntry_; }
+
+            /**
+                @brief Sets the label of this entry.
+                @param label The label
+            */
+            inline void setLabel(const LanguageEntryLabel& label)
+                { this->label_ = label; }
+
+            /**
+                @brief Returns the label of this entry.
+                @return The label
+            */
+            inline const LanguageEntryLabel& getLabel() const
+                { return this->label_; }
+
+        private:
+            LanguageEntryLabel label_;              //!< The label of the entry
+            std::string fallbackEntry_;             //!< The default entry: Used, if no translation is available or no language configured
+            std::string localisedEntry_;            //!< The localised entry in the configured language
+            bool bLocalisationSet_;                 //!< True if the translation was set
+    };
+
+
+    // ###############################
+    // ###         Language        ###
+    // ###############################
+    //! The Language class manges the language files and entries and stores the LanguageEntry objects in a map.
+    class _CoreExport Language
+    {
+        friend class Core;
+
+        public:
+            static Language& getLanguage();
+            void addEntry(const LanguageEntryLabel& label, const std::string& entry);
+            const std::string& getLocalisation(const LanguageEntryLabel& label) const;
+
+        private:
+            Language();
+            Language(const Language& language);     // don't copy
+            virtual ~Language();
+
+            void readDefaultLanguageFile();
+            void readTranslatedLanguageFile();
+            void writeDefaultLanguageFile() const;
+            static const std::string getFilename(const std::string& language);
+            LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry);
+
+            std::string defaultLanguage_;                           //!< The default language
+            std::string defaultLocalisation_;                       //!< The returned string, if an entry unavailable entry is requested
+            std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their labels
+    };
+}
+
+#endif /* _Language_H__ */
Index: /code/branches/physics/src/core/Loader.cc
===================================================================
--- /code/branches/physics/src/core/Loader.cc	(revision 2122)
+++ /code/branches/physics/src/core/Loader.cc	(revision 2122)
@@ -0,0 +1,187 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Loader.h"
+#include "XMLFile.h"
+#include "BaseObject.h"
+#include "Identifier.h"
+#include "Iterator.h"
+#include "ObjectList.h"
+#include "CoreIncludes.h"
+#include "LuaBind.h"
+#include "Namespace.h"
+#include "util/Debug.h"
+
+#include "tinyxml/ticpp.h"
+
+namespace orxonox
+{
+    std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s;
+    ClassTreeMask Loader::currentMask_s;
+
+    bool Loader::open(const XMLFile* file, const ClassTreeMask& mask)
+    {
+        Loader::add(file, mask);
+        return Loader::load(file, mask);
+    }
+
+    void Loader::close()
+    {
+        Loader::unload();
+        Loader::files_s.clear();
+    }
+
+    void Loader::close(const XMLFile* file)
+    {
+        Loader::unload(file);
+        Loader::remove(file);
+    }
+
+    void Loader::add(const XMLFile* file, const ClassTreeMask& mask)
+    {
+        if (!file)
+            return;
+        Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));
+    }
+
+    void Loader::remove(const XMLFile* file)
+    {
+        if (!file)
+            return;
+        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
+        {
+            if ((*it).first == file)
+            {
+                Loader::files_s.erase(it);
+                break;
+            }
+        }
+    }
+
+    bool Loader::load(const ClassTreeMask& mask)
+    {
+        bool success = true;
+        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
+            if (!Loader::load((*it).first, (*it).second * mask))
+                success = false;
+
+        return success;
+    }
+
+    void Loader::unload(const ClassTreeMask& mask)
+    {
+        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); )
+        {
+            if (mask.isIncluded(it->getIdentifier()))
+                delete (*(it++));
+            else
+                ++it;
+        }
+    }
+
+    bool Loader::reload(const ClassTreeMask& mask)
+    {
+        Loader::unload(mask);
+        return Loader::load(mask);
+    }
+
+    bool Loader::load(const XMLFile* file, const ClassTreeMask& mask)
+    {
+        if (!file)
+            return false;
+
+        Loader::currentMask_s = file->getMask() * mask;
+
+        // let Lua work this out:
+        LuaBind* lua = LuaBind::getInstance();
+        lua->clearLuaOutput();
+        lua->loadFile(file->getFilename(), true);
+        lua->run();
+
+        try
+        {
+            COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl;
+            COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
+
+            //ticpp::Document xmlfile(file->getFilename());
+            //xmlfile.LoadFile();
+            //ticpp::Element myelement(*Script::getFileString());
+            ticpp::Document xmlfile;
+            //xmlfile.ToDocument();
+            xmlfile.Parse(lua->getLuaOutput(), true);
+
+            ticpp::Element rootElement;
+            rootElement.SetAttribute("name", "root");
+            rootElement.SetAttribute("bAutogenerated", true);
+
+            for (ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++)
+                rootElement.InsertEndChild(*child);
+
+            COUT(4) << "  creating root-namespace..." << std::endl;
+            Namespace* rootNamespace = new Namespace(0);
+            rootNamespace->setLoaderIndentation("    ");
+            rootNamespace->setFile(file);
+            rootNamespace->setNamespace(rootNamespace);
+            rootNamespace->setRoot(true);
+            rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
+
+            COUT(0) << "Finished loading " << file->getFilename() << "." << std::endl;
+
+            COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString("  ") << std::endl;
+
+            return true;
+        }
+        catch(ticpp::Exception& ex)
+        {
+            COUT(1) << std::endl;
+            COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
+            COUT(1) << ex.what() << std::endl;
+            COUT(1) << "Loading aborted." << std::endl;
+            return false;
+        }
+    }
+
+    void Loader::unload(const XMLFile* file, const ClassTreeMask& mask)
+    {
+        if (!file)
+            return;
+        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; )
+        {
+            if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier()))
+                delete (*(it++));
+            else
+                ++it;
+        }
+    }
+
+    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask)
+    {
+        Loader::unload(file, mask);
+        return Loader::load(file, mask);
+    }
+}
Index: /code/branches/physics/src/core/Loader.h
===================================================================
--- /code/branches/physics/src/core/Loader.h	(revision 2122)
+++ /code/branches/physics/src/core/Loader.h	(revision 2122)
@@ -0,0 +1,65 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Loader_H__
+#define _Loader_H__
+
+#include "CorePrereqs.h"
+
+#include <vector>
+
+#include "ClassTreeMask.h"
+
+namespace orxonox
+{
+    class _CoreExport Loader
+    {
+        public:
+            static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+            static void close();
+            static void close(const XMLFile* file);
+
+            static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+            static void remove(const XMLFile* file);
+
+            static bool load(const ClassTreeMask& mask = ClassTreeMask());
+            static void unload(const ClassTreeMask& mask = ClassTreeMask());
+            static bool reload(const ClassTreeMask& mask = ClassTreeMask());
+
+            static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+            static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+            static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+
+            static ClassTreeMask currentMask_s;
+
+        private:
+            static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s;
+    };
+}
+
+#endif /* _Loader_H__ */
Index: /code/branches/physics/src/core/LuaBind.cc
===================================================================
--- /code/branches/physics/src/core/LuaBind.cc	(revision 2122)
+++ /code/branches/physics/src/core/LuaBind.cc	(revision 2122)
@@ -0,0 +1,291 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "LuaBind.h"
+
+#include <fstream>
+#include <map>
+
+#include "lua/lua.hpp"
+#include "tolua/tolua++.h"
+#include "tolua/tolua_bind.h"
+#include "util/String.h"
+#include "CoreIncludes.h"
+
+namespace orxonox
+{
+  LuaBind* LuaBind::singletonRef = NULL;
+
+  LuaBind::LuaBind()
+  {
+    luaState_ = lua_open();
+    luaSource_ = "";
+#if LUA_VERSION_NUM == 501
+    luaL_openlibs(luaState_);
+#else
+    luaopen_base(luaState_);
+    luaopen_string(luaState_);
+    luaopen_table(luaState_);
+    luaopen_math(luaState_);
+    luaopen_io(luaState_);
+    luaopen_debug(luaState_);
+#endif
+    tolua_Core_open(luaState_);
+    output_ = "";
+    isRunning_ = false;
+  }
+
+  void LuaBind::luaPrint(std::string str)
+  {
+    output_ += str;
+//    COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
+    COUT(5) << str;
+  }
+
+  /**
+      @brief Loads the specified file line by line
+      @param filename The filename of the file
+      @param luaTags if true, the loaded file gets stripped off luaTags
+  */
+  void LuaBind::loadFile(std::string filename, bool luaTags)
+  {
+    output_ = "";
+    std::ifstream file;
+    file.open(filename.c_str(), std::fstream::in);
+
+    if (!file.is_open())
+    {
+      // some error msg
+    }
+
+    char line[1024];
+    std::string levelString = "";
+
+    while (file.good() && !file.eof())
+    {
+      file.getline(line, 1024);
+      levelString += line;
+      levelString += "\n";
+    }
+
+    file.close();
+    //std::string output;
+
+    if (luaTags) luaSource_ = replaceLuaTags(levelString);
+    COUT(5) << "ParsedSourceCode: " << luaSource_ << std::endl;
+  }
+
+  void LuaBind::loadString(std::string code)
+  {
+    luaSource_ = code;
+    output_ = "";
+  }
+
+#if LUA_VERSION_NUM != 501
+  const char * LuaBind::lua_Chunkreader(lua_State *L, void *data, size_t *size)
+  {
+    LoadS* ls = ((LoadS*)data);
+    if (ls->size == 0) return NULL;
+    *size = ls->size;
+    ls->size = 0;
+    return ls->s;
+  }
+#endif
+  void LuaBind::run()
+  {
+    if (!isRunning_)
+    {
+      isRunning_ = true;
+      int error = 0;
+      std::string init = "local scr = orxonox.LuaBind:getInstance()\nlocal debug = print\nprint = function(s)\nscr:luaPrint(s)\nend\ninclude = function(f)\nfile = assert(io.open(\"" + this->includePath_ + "\"..\"/\"..f))\ncontent = file:read(\"*a\")\nfile:close()\nsource = scr:replaceLuaTags(content)\nassert(loadstring(source))()\nend\n";
+      init += luaSource_;
+  #if LUA_VERSION_NUM == 501
+      error = luaL_loadstring(luaState_, init.c_str());
+  #else
+      LoadS ls;
+      ls.s = init.c_str();
+      ls.size = init.size();
+      error = lua_load(luaState_, &orxonox::LuaBind::lua_Chunkreader, &ls, init.c_str());
+  #endif
+      if (error == 0)
+      {
+        error = lua_pcall(luaState_, 0, 0, 0);
+      }
+      if (error != 0)
+      {
+        COUT(2) << "Error in Lua-script: " << lua_tostring(luaState_, -1) << std::endl;
+      }
+      isRunning_ = false;
+    }
+    else
+    {
+      COUT(2) << "Warning: Lua's run is called while running!" << std::endl;
+    }
+  }
+
+  std::string LuaBind::replaceLuaTags(const std::string& text)
+  {
+    // chreate map with all Lua tags
+    std::map<size_t, bool> luaTags;
+    {
+      size_t pos = 0;
+      while ((pos = text.find("<?lua", pos)) != std::string::npos)
+        luaTags[pos++] = true;
+    }
+    {
+      size_t pos = 0;
+      while ((pos = text.find("?>", pos)) != std::string::npos)
+        luaTags[pos++] = false;
+    }
+
+    // erase all tags from the map that are between two quotes
+    {
+      std::map<size_t, bool>::iterator it = luaTags.begin();
+      std::map<size_t, bool>::iterator it2 = it;
+      bool bBetweenQuotes = false;
+      size_t pos = 0;
+      while ((pos = getNextQuote(text, pos)) != std::string::npos)
+      {
+        while ((it != luaTags.end()) && (it->first < pos))
+        {
+          if (bBetweenQuotes) {
+            it2++;
+            if(it->second && !(it2->second) && it2->first < pos)
+              it = ++it2;
+            else
+              luaTags.erase(it++);
+          }
+          else
+            ++it;
+        }
+        bBetweenQuotes = !bBetweenQuotes;
+        pos++;
+      }
+    }
+
+    // check whether on every opening <?lua tag a closing ?> tag follows
+    {
+      bool expectedValue = true;
+      for (std::map<size_t, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)
+      {
+        if (it->second == expectedValue)
+          expectedValue = !expectedValue;
+        else
+        {
+          expectedValue = false;
+          break;
+        }
+      }
+      if (!expectedValue) {
+        COUT(2) << "Warning: Error in level file" << std::endl;
+        // todo: errorhandling
+        return "";
+      }
+    }
+
+    // cut the original string into pieces and put them together with print() instead of lua tags
+    std::string output;
+    {
+      std::map<size_t, bool>::iterator it = luaTags.begin();
+      bool bInPrintFunction = true;
+      size_t start = 0;
+      size_t end = 0;
+
+      do
+      {
+        if (it != luaTags.end())
+          end = (*(it++)).first;
+        else
+          end = std::string::npos;
+
+        unsigned int equalSignCounter = 0;
+
+        if (bInPrintFunction)
+        {
+          // count ['='[ and ]'='] and replace tags with print([[ and ]])
+          std::string temp = text.substr(start, end - start);
+          {
+            size_t pos = 0;
+            while ((pos = temp.find('[', pos)) != std::string::npos)
+            {
+              unsigned int tempCounter = 1;
+              size_t tempPos = pos++;
+              while(temp[++tempPos] == '=') {
+                tempCounter++;
+              }
+              if(temp[tempPos] != '[') {
+                tempCounter = 0;
+              }
+              else if(tempCounter == 0) {
+                tempCounter = 1;
+              }
+              if (tempCounter > equalSignCounter)
+                equalSignCounter = tempCounter;
+            }
+          }
+          {
+            size_t pos = 0;
+            while ((pos = temp.find(']', pos)) != std::string::npos)
+            {
+              unsigned int tempCounter = 1;
+              size_t tempPos = pos++;
+              while(temp[++tempPos] == '=') {
+                tempCounter++;
+              }
+              if(temp[tempPos] != ']') {
+                tempCounter = 0;
+              }
+              else if(tempCounter == 0) {
+                tempCounter = 1;
+              }
+              if (tempCounter > equalSignCounter)
+                equalSignCounter = tempCounter;
+            }
+          }
+          std::string equalSigns = "";
+          for(unsigned int i = 0; i < equalSignCounter; i++) {
+            equalSigns += "=";
+          }
+          output += "print([" + equalSigns + "[" + temp + "]" + equalSigns +"])";
+          start = end + 5;
+        }
+        else
+        {
+          output += text.substr(start, end - start);
+          start = end + 2;
+        }
+
+        bInPrintFunction = !bInPrintFunction;
+      }
+      while (end != std::string::npos);
+    }
+
+    return output;
+  }
+
+}
Index: /code/branches/physics/src/core/LuaBind.h
===================================================================
--- /code/branches/physics/src/core/LuaBind.h	(revision 2122)
+++ /code/branches/physics/src/core/LuaBind.h	(revision 2122)
@@ -0,0 +1,96 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Representation of an interface to lua
+ @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _LuaBind_H__
+#define _LuaBind_H__
+
+#include "CorePrereqs.h"
+
+extern "C" {
+#include <lua/lua.h>
+}
+
+#include <list>
+#include <string>
+
+namespace orxonox // tolua_export
+{ // tolua_export
+  class _CoreExport LuaBind
+  {
+  /*
+  class LuaBind { // tolua_export
+  */
+    struct LoadS {
+      const char *s;
+      size_t size;
+    };
+
+    public:
+      inline static LuaBind* getInstance() { if (!LuaBind::singletonRef) LuaBind::singletonRef = new LuaBind(); return LuaBind::singletonRef; } // tolua_export
+      inline ~LuaBind() { LuaBind::singletonRef = NULL; };
+
+    void loadFile(std::string filename, bool luaTags);
+    void loadString(std::string code);
+    //void init(lua_State *state_);
+    //void xmlToLua();
+    void run();
+    void luaPrint(std::string str); // tolua_export
+
+#if LUA_VERSION_NUM != 501
+    static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size);
+#endif
+
+    inline lua_State* getLuaState() { return luaState_; };
+    inline std::string getLuaOutput() { return output_; };
+    //inline std::string* getFileString() { return &fileString_; };
+    inline void clearLuaOutput() { output_ = ""; }
+
+    std::string replaceLuaTags(const std::string& text); // tolua_export
+
+    inline void setIncludePath(const std::string& includepath)
+        { this->includePath_ = includepath; }
+
+    private:
+      LuaBind();
+      static LuaBind* singletonRef;
+
+      std::string luaSource_;
+      std::string output_;
+      lua_State* luaState_;
+      bool isRunning_;
+      std::string includePath_;
+
+  }; // tolua_export
+} // tolua_export
+#endif /* _LuaBind_H__ */
Index: /code/branches/physics/src/core/MetaObjectList.cc
===================================================================
--- /code/branches/physics/src/core/MetaObjectList.cc	(revision 2122)
+++ /code/branches/physics/src/core/MetaObjectList.cc	(revision 2122)
@@ -0,0 +1,102 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MetaObjectList.cc
+    @brief Implementation of the MetaObjectList class.
+*/
+
+#include "MetaObjectList.h"
+#include "ObjectListBase.h"
+#include "Identifier.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  MetaObjectListElement  ###
+    // ###############################
+    /**
+        @brief Destructor: Removes the ObjectListBaseElement from the ObjectListBase by linking next_ and prev_ of the ObjectListBaseElement.
+    */
+    MetaObjectListElement::~MetaObjectListElement()
+    {
+        COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl;
+        this->list_->notifyIterators(this->element_->objectBase_);
+
+        if (this->element_->next_)
+            this->element_->next_->prev_ = this->element_->prev_;
+        else
+            this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
+
+        if (this->element_->prev_)
+            this->element_->prev_->next_ = this->element_->next_;
+        else
+            this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
+
+        delete this->element_;
+    }
+
+
+    // ###############################
+    // ###     MetaObjectList      ###
+    // ###############################
+    /**
+        @brief Constructor: Sets first_ to zero.
+    */
+    MetaObjectList::MetaObjectList()
+    {
+        this->first_ = 0;
+    }
+
+    /**
+        @brief Destructor: Removes all elements from the list, causing them to remove the stored ObjectListElement from the ObjectList.
+    */
+    MetaObjectList::~MetaObjectList()
+    {
+        MetaObjectListElement* temp;
+        while (this->first_)
+        {
+            temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+        }
+    }
+
+    /**
+        @brief Adds an ObjectList and an element of that list to the MetaObjectList.
+        @param list The ObjectList wherein the element is
+        @param element The element wherein the object is
+    */
+    void MetaObjectList::add(ObjectListBase* list, ObjectListBaseElement* element)
+    {
+        MetaObjectListElement* temp = this->first_;
+        this->first_ = new MetaObjectListElement(list, element);
+        this->first_->next_ = temp;
+    }
+}
Index: /code/branches/physics/src/core/MetaObjectList.h
===================================================================
--- /code/branches/physics/src/core/MetaObjectList.h	(revision 2122)
+++ /code/branches/physics/src/core/MetaObjectList.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MetaObjectList.h
+    @brief Definition of the MetaObjectList class.
+
+    The MetaObjectList is a single-linked list, containing all list-elements and their
+    lists wherein the object, owning the MetaObjectList, is registered.
+    This allows much faster deletion of objects because no iteration is needed.
+*/
+
+#ifndef _MetaObjectList_H__
+#define _MetaObjectList_H__
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  MetaObjectListElement  ###
+    // ###############################
+    //! The list-element of the MetaObjectList
+    class _CoreExport MetaObjectListElement
+    {
+        public:
+            /**
+                @brief Constructor: Creates the list-element with given list and element.
+            */
+            MetaObjectListElement(ObjectListBase* list, ObjectListBaseElement* element) : next_(0), element_(element), list_(list) {}
+            ~MetaObjectListElement();
+
+            MetaObjectListElement* next_;       //!< The next Element in the list
+            ObjectListBaseElement* element_;    //!< The list element, containing the object
+            ObjectListBase* list_;              //!< The list, containing the element
+    };
+
+
+    // ###############################
+    // ###     MetaObjectList      ###
+    // ###############################
+    //!  The MetaObjectList contains ObjectListBaseElements and their ObjectListBases.
+    /**
+        The MetaObjectList is a single-linked list, containing all list-elements and their
+        lists wherein the object that owns the MetaObjectList is registered.
+        This allows much faster deletion of objects because no iteration is needed.
+    */
+    class _CoreExport MetaObjectList
+    {
+        public:
+            MetaObjectList();
+            ~MetaObjectList();
+            void add(ObjectListBase* list, ObjectListBaseElement* element);
+
+            MetaObjectListElement* first_;      //!< The first element in the list
+    };
+}
+
+#endif /* _MetaObjectList_H__ */
Index: /code/branches/physics/src/core/Namespace.cc
===================================================================
--- /code/branches/physics/src/core/Namespace.cc	(revision 2122)
+++ /code/branches/physics/src/core/Namespace.cc	(revision 2122)
@@ -0,0 +1,179 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Namespace.h"
+#include "NamespaceNode.h"
+#include "CoreIncludes.h"
+#include "XMLPort.h"
+#include "util/SubString.h"
+
+namespace orxonox
+{
+    CreateFactory(Namespace);
+
+    Namespace::Namespace(BaseObject* creator) : BaseObject(creator),
+      bAutogeneratedFileRootNamespace_(false),
+      bRoot_(false),
+      operator_("or")
+    {
+        RegisterObject(Namespace);
+    }
+
+    Namespace::~Namespace()
+    {
+        if (this->bRoot_)
+            for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
+                delete (*it);
+    }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void Namespace::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Namespace, XMLPort, xmlelement, mode);
+
+        std::string name = this->getName();
+        size_t pos = 0;
+        while ((pos = name.find(',')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        while ((pos = name.find(';')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        while ((pos = name.find('\n')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        while ((pos = name.find('\t')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        SubString tokens(name, " ", "", false, '\\', true, '"', true, '\0', '\0', true, '\0');
+        if (this->bRoot_)
+        {
+            this->representingNamespaces_.insert(new NamespaceNode(this->getName()));
+        }
+        else
+        {
+            for (unsigned int i = 0; i < tokens.size(); i++)
+            {
+                for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)
+                {
+                    std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);
+                    this->representingNamespaces_.insert(temp.begin(), temp.end());
+                }
+            }
+        }
+
+        XMLPortParam(Namespace, "operator", setOperator, getOperator, xmlelement, mode);
+        XMLPortParam(Namespace, "bAutogenerated", setAutogenerated, isAutogenerated, xmlelement, mode);
+
+        if (this->bAutogeneratedFileRootNamespace_)
+        {
+            for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
+            {
+                (*it)->setRoot(true);
+                (*it)->setHidden(true);
+            }
+        }
+
+        XMLPortObjectExtended(Namespace, BaseObject, "", loadObjects, saveObjects, xmlelement, mode, true, false);
+    }
+
+    void Namespace::loadObjects(BaseObject* object)
+    {
+        object->setNamespace(this);
+    }
+
+    const BaseObject* Namespace::saveObjects(unsigned int index) const
+    {
+        return 0; // todo
+    }
+
+    bool Namespace::includes(const Namespace* ns) const
+    {
+        for (std::set<NamespaceNode*>::const_iterator it1 = this->representingNamespaces_.begin(); it1 != this->representingNamespaces_.end(); ++it1)
+        {
+            for (std::set<NamespaceNode*>::const_iterator it2 = ns->representingNamespaces_.begin(); it2 != ns->representingNamespaces_.end(); ++it2)
+            {
+                if ((*it1)->includes(*it2))
+                {
+                    if (this->operator_ == "or")
+                        return true;
+
+                    if (this->operator_ == "not")
+                        return false;
+                }
+                else
+                {
+                    if (this->operator_ == "and")
+                        return false;
+                }
+            }
+        }
+
+        if (this->operator_ == "or")
+            return false;
+        else if (this->operator_ == "and")
+            return true;
+        else if (this->operator_ == "not")
+            return true;
+
+        return false;
+    }
+
+    std::string Namespace::toString() const
+    {
+        std::string output;
+
+        int i = 0;
+        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+        {
+            if (i > 0)
+                output += " / ";
+
+            output += (*it)->toString();
+        }
+
+        return output;
+    }
+
+    std::string Namespace::toString(const std::string& indentation) const
+    {
+        std::string output;
+
+        int i = 0;
+        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+        {
+            if (i > 0)
+                output += "\n";
+
+            output += (*it)->toString(indentation);
+        }
+
+        return output;
+    }
+}
Index: /code/branches/physics/src/core/Namespace.h
===================================================================
--- /code/branches/physics/src/core/Namespace.h	(revision 2122)
+++ /code/branches/physics/src/core/Namespace.h	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Namespace_H__
+#define _Namespace_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+
+#include "XMLIncludes.h"
+#include "BaseObject.h"
+
+namespace orxonox
+{
+    class Namespace : public BaseObject
+    {
+        public:
+            Namespace(BaseObject* creator);
+            virtual ~Namespace();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void loadObjects(BaseObject* object);
+            const BaseObject* saveObjects(unsigned int index) const;
+
+            void setAutogenerated(bool bAutogenerated)
+                { this->bAutogeneratedFileRootNamespace_ = bAutogenerated; }
+            bool isAutogenerated() const
+                { return this->bAutogeneratedFileRootNamespace_; }
+
+            void setOperator(const std::string& op)
+                { this->operator_ = op; }
+            const std::string& getOperator() const
+                { return this->operator_; }
+
+            void setRoot(bool bRoot)
+                { this->bRoot_ = bRoot; }
+
+            bool includes(const Namespace* ns) const;
+            bool isIncludedIn(const Namespace* ns) const { return ns->includes(this); }
+
+            std::string toString() const;
+            std::string toString(const std::string& indentation) const;
+
+        private:
+            std::set<NamespaceNode*> representingNamespaces_;
+            bool bAutogeneratedFileRootNamespace_;
+            bool bRoot_;
+            std::string operator_;
+    };
+}
+
+#endif /* _Namespace_H__ */
Index: /code/branches/physics/src/core/NamespaceNode.cc
===================================================================
--- /code/branches/physics/src/core/NamespaceNode.cc	(revision 2122)
+++ /code/branches/physics/src/core/NamespaceNode.cc	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "NamespaceNode.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    NamespaceNode::NamespaceNode(const std::string& name, NamespaceNode* parent)
+    {
+        this->name_ = name;
+        this->parent_ = parent;
+        this->bRoot_ = false;
+        this->bHidden_ = false;
+    }
+
+    NamespaceNode::~NamespaceNode()
+    {
+        for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); )
+            delete ((*(it++)).second);
+    }
+
+    std::set<NamespaceNode*> NamespaceNode::getNodeRelative(const std::string& name)
+    {
+        std::set<NamespaceNode*> nodes;
+
+        if ((name.size() == 0) || (name == ""))
+        {
+            nodes.insert(this);
+        }
+        else
+        {
+            size_t pos = name.find("::");
+            std::string firstPart = name;
+            std::string secondPart;
+
+            if (pos != std::string::npos)
+            {
+                firstPart = name.substr(0, pos);
+                secondPart = name.substr(pos + 2, std::string::npos);
+            }
+
+            if (firstPart == "..")
+            {
+                if (this->bRoot_)
+                {
+                    COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
+                }
+                else if (!this->parent_)
+                {
+                    COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
+                }
+                else
+                {
+                    nodes = this->parent_->getNodeRelative(secondPart);
+                }
+            }
+            else if (name.find('@') != 0)
+            {
+                std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.find(firstPart);
+                if (it == this->subnodes_.end())
+                    it = this->subnodes_.insert(this->subnodes_.begin(), std::pair<std::string, NamespaceNode*>(firstPart, new NamespaceNode(firstPart, this)));
+
+                if ((*it).second->isHidden())
+                {
+                    COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl;
+                    nodes.insert(this);
+                }
+                else
+                {
+                    nodes = (*it).second->getNodeRelative(secondPart);
+                }
+            }
+            else
+            {
+                bool bFoundMatchingNamespace = false;
+
+                for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+                {
+                    if ((*it).first.find(firstPart) == ((*it).first.size() - firstPart.size()))
+                    {
+                        std::set<NamespaceNode*> temp2 = (*it).second->getNodeRelative(secondPart);
+                        nodes.insert(temp2.begin(), temp2.end());
+                        bFoundMatchingNamespace = true;
+                    }
+                }
+
+                if (!bFoundMatchingNamespace)
+                {
+                    COUT(2) << "Warning: No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
+                }
+            }
+        }
+
+        return nodes;
+    }
+
+    bool NamespaceNode::includes(const NamespaceNode* ns) const
+    {
+        if (ns == this)
+        {
+            return true;
+        }
+        else
+        {
+            for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+                if ((*it).second->includes(ns))
+                    return true;
+        }
+
+        return false;
+    }
+
+    std::string NamespaceNode::toString() const
+    {
+        std::string output = this->name_;
+
+        if (this->subnodes_.size() > 0)
+        {
+            output += " (";
+
+            int i = 0;
+            for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); i++, ++it)
+            {
+                if (i > 0)
+                    output += ", ";
+
+                output += (*it).second->toString();
+            }
+
+            output += ")";
+        }
+
+        return output;
+    }
+
+    std::string NamespaceNode::toString(const std::string& indentation) const
+    {
+        std::string output = (indentation + this->name_ + "\n");
+
+        for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+            output += (*it).second->toString(indentation + "  ");
+
+        return output;
+    }
+}
Index: /code/branches/physics/src/core/NamespaceNode.h
===================================================================
--- /code/branches/physics/src/core/NamespaceNode.h	(revision 2122)
+++ /code/branches/physics/src/core/NamespaceNode.h	(revision 2122)
@@ -0,0 +1,68 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _NamespaceNode_H__
+#define _NamespaceNode_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+#include <set>
+#include <string>
+
+namespace orxonox
+{
+    class NamespaceNode
+    {
+        public:
+            NamespaceNode(const std::string& name, NamespaceNode* parent = 0);
+            ~NamespaceNode();
+
+            std::set<NamespaceNode*> getNodeRelative(const std::string& name);
+
+            void setRoot(bool bRoot) { this->bRoot_ = bRoot; }
+            void setHidden(bool bHidden) { this->bHidden_ = bHidden; }
+
+            bool isRoot() const { return this->bRoot_; }
+            bool isHidden() const { return this->bHidden_; }
+
+            bool includes(const NamespaceNode*) const;
+
+            std::string toString() const;
+            std::string toString(const std::string& indentation) const;
+
+        private:
+            std::string name_;
+            NamespaceNode* parent_;
+            std::map<std::string, NamespaceNode*> subnodes_;
+            bool bHidden_;
+            bool bRoot_;
+    };
+}
+
+#endif /* _NamespaceNode_H__ */
Index: /code/branches/physics/src/core/ObjectList.h
===================================================================
--- /code/branches/physics/src/core/ObjectList.h	(revision 2122)
+++ /code/branches/physics/src/core/ObjectList.h	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ObjectList.h
+    @brief Definition and implementation of the ObjectList class.
+
+    The ObjectList is a wrapper of an ObjectListBase of a given class.
+    Use Iterator<class> to iterate through all objects of the class.
+*/
+
+#ifndef _ObjectList_H__
+#define _ObjectList_H__
+
+#include "CorePrereqs.h"
+
+#include "Identifier.h"
+#include "ObjectListIterator.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###       ObjectList        ###
+    // ###############################
+    //! The ObjectList contains all objects of the given class.
+    /**
+        Wraps the ObjectListBase of the corresponding Identifier.
+        Use ObjectListIterator<class> to iterate through all objects in the list.
+    */
+    template <class T>
+    class ObjectList
+    {
+        public:
+            typedef ObjectListIterator<T> iterator;
+
+            /** @brief Returns an Iterator to the first element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* begin()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->begin().element_); }
+
+            /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* end()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->end().element_); }
+
+            /** @brief Returns an Iterator to the last element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* rbegin()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin().element_); }
+
+            /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* rend()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rend().element_); }
+    };
+}
+
+#endif /* _ObjectList_H__ */
Index: /code/branches/physics/src/core/ObjectListBase.cc
===================================================================
--- /code/branches/physics/src/core/ObjectListBase.cc	(revision 2122)
+++ /code/branches/physics/src/core/ObjectListBase.cc	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ObjectListBase.cc
+    @brief Implementation of the ObjectListBase class.
+
+    The ObjectListBase is a double-linked list, used by Identifiers to store all objects of a given class.
+    Newly created objects are added through the RegisterObject-macro in its constructor.
+*/
+
+#include <set>
+
+#include "CorePrereqs.h"
+
+#include "ObjectListBase.h"
+#include "Identifier.h"
+#include "Iterator.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Sets default values.
+    */
+    ObjectListBase::ObjectListBase(Identifier* identifier)
+    {
+        this->identifier_ = identifier;
+        this->first_ = 0;
+        this->last_ = 0;
+    }
+
+    /**
+        @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.
+    */
+    ObjectListBase::~ObjectListBase()
+    {
+        ObjectListBaseElement* temp;
+        while (this->first_)
+        {
+            temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+        }
+    }
+
+    /**
+        @brief Increases all Iterators that currently point on the given element (because it gets removed).
+        @param element The element that gets removed
+    */
+    void ObjectListBase::notifyIterators(OrxonoxClass* object) const
+    {
+        for (std::list<void*>::const_iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)
+            ((Iterator<OrxonoxClass>*)(*it))->incrementIfEqual(object);
+        for (std::list<void*>::const_iterator it = this->objectListIterators_.begin(); it != this->objectListIterators_.end(); ++it)
+            ((ObjectListIterator<OrxonoxClass>*)(*it))->incrementIfEqual(object);
+    }
+
+    /**
+        @brief Adds a new object to the end of the list.
+        @param object The object to add
+        @return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object
+    */
+    ObjectListBaseElement* ObjectListBase::add(ObjectListBaseElement* element)
+    {
+        if (!this->last_)
+        {
+            // If the list is empty
+            this->last_ = element;
+            this->first_ = this->last_; // There's only one object in the list now
+        }
+        else
+        {
+            // If the list isn't empty
+            ObjectListBaseElement* temp = this->last_;
+            this->last_ = element;
+            this->last_->prev_ = temp;
+            temp->next_ = this->last_;
+        }
+
+        return this->last_;
+    }
+}
Index: /code/branches/physics/src/core/ObjectListBase.h
===================================================================
--- /code/branches/physics/src/core/ObjectListBase.h	(revision 2122)
+++ /code/branches/physics/src/core/ObjectListBase.h	(revision 2122)
@@ -0,0 +1,129 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ObjectListBase.h
+    @brief Definition of the ObjectListBase class.
+
+    The ObjectListBase is a double-linked list, used by Identifiers to store all objects of a given class.
+    Newly created objects are added through the RegisterObject-macro in its constructor.
+*/
+
+#ifndef _ObjectListBase_H__
+#define _ObjectListBase_H__
+
+#include <list>
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  ObjectListBaseElement  ###
+    // ###############################
+    //! The list-element of the ObjectListBase
+    class _CoreExport ObjectListBaseElement
+    {
+        public:
+            /**
+                @brief Constructor: Creates the list-element with an object.
+                @param object The object to store
+            */
+            ObjectListBaseElement(OrxonoxClass* objectBase) : next_(0), prev_(0), objectBase_(objectBase) {}
+
+            ObjectListBaseElement* next_;       //!< The next element in the list
+            ObjectListBaseElement* prev_;       //!< The previous element in the list
+            OrxonoxClass* objectBase_;
+    };
+
+
+    // ###############################
+    // ###    ObjectListElement    ###
+    // ###############################
+    //! The list-element that actually contains the object
+    template <class T>
+    class ObjectListElement : public ObjectListBaseElement
+    {
+        public:
+            ObjectListElement(T* object) : ObjectListBaseElement((OrxonoxClass*)object), object_(object) {}
+            T* object_;              //!< The object
+    };
+
+
+    // ###############################
+    // ###     ObjectListBase      ###
+    // ###############################
+    //! The ObjectListBase contains all objects of a given class.
+    /**
+        The ObjectListBase is used by Identifiers to store all objects of their given class.
+        Use ObjectList<T> to get the list of all T's and Iterator<T> to iterate through them.
+    */
+    class _CoreExport ObjectListBase
+    {
+        friend class MetaObjectListElement;
+
+        public:
+            ObjectListBase(Identifier* identifier);
+            ~ObjectListBase();
+
+            ObjectListBaseElement* add(ObjectListBaseElement* element);
+
+            struct Export
+            {
+                Export(ObjectListBase* list, ObjectListBaseElement* element) : list_(list), element_(element) {}
+                ObjectListBase* list_;
+                ObjectListBaseElement* element_;
+            };
+
+            /** @brief Returns a pointer to the first element in the list. @return The element */
+            inline Export begin() { return ObjectListBase::Export(this, this->first_); }
+            /** @brief Returns a pointer to the element after the last element in the list. @return The element */
+            inline Export end() { return ObjectListBase::Export(this, 0); }
+            /** @brief Returns a pointer to the last element in the list. @return The element */
+            inline Export rbegin() { return ObjectListBase::Export(this, this->last_); }
+            /** @brief Returns a pointer to the element in front of the first element in the list. @return The element */
+            inline Export rend() { return ObjectListBase::Export(this, 0); }
+
+            inline std::list<void*>::iterator registerIterator(void* iterator) { return this->iterators_.insert(this->iterators_.begin(), iterator); }
+            inline void unregisterIterator(const std::list<void*>::iterator& iterator) { this->iterators_.erase(iterator); }
+            inline std::list<void*>::iterator registerObjectListIterator(void* iterator) { return this->objectListIterators_.insert(this->objectListIterators_.begin(), iterator); }
+            inline void unregisterObjectListIterator(const std::list<void*>::iterator& iterator) { this->objectListIterators_.erase(iterator); }
+            void notifyIterators(OrxonoxClass* object) const;
+
+            inline Identifier* getIdentifier() const { return this->identifier_; }
+
+        private:
+            Identifier* identifier_;               //!< The Iterator owning this list
+            ObjectListBaseElement* first_;         //!< The first element in the list
+            ObjectListBaseElement* last_;          //!< The last element in the list
+            std::list<void*> iterators_;           //!< A list of Iterators pointing on an element in this list
+            std::list<void*> objectListIterators_; //!< A list of ObjectListIterators pointing on an element in this list
+    };
+}
+
+#endif /* _ObjectListBase_H__ */
Index: /code/branches/physics/src/core/ObjectListIterator.h
===================================================================
--- /code/branches/physics/src/core/ObjectListIterator.h	(revision 2122)
+++ /code/branches/physics/src/core/ObjectListIterator.h	(revision 2122)
@@ -0,0 +1,236 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Iterator.h
+    @brief Definition and implementation of the Iterator class.
+
+    The ObjectListIterator of a given class allows to iterate through the
+    ObjectList of this class, containing all objects of that type.
+    This is the only way to access the objects stored in an ObjectList.
+
+    Usage:
+    for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it)
+    {
+        it->someFunction(...);
+        myClass* myObject = *it;
+    }
+*/
+
+#ifndef _ObjectListIterator_H__
+#define _ObjectListIterator_H__
+
+#include "CorePrereqs.h"
+#include "ObjectListBase.h"
+
+namespace orxonox
+{
+    //! The Iterator allows to iterate through the ObjectList of a given class.
+    template <class T>
+    class ObjectListIterator
+    {
+        template <class I>
+        friend class Iterator;
+
+        public:
+            /**
+                @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero.
+            */
+            inline ObjectListIterator()
+            {
+                this->element_ = 0;
+                this->iterator_ = ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to a given element.
+                @param element The element to start with
+            */
+            inline ObjectListIterator(ObjectListElement<T>* element)
+            {
+                this->element_ = element;
+                this->iterator_ = ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to the element of another ObjectListIterator.
+                @param other The other ObjectListIterator
+            */
+            inline ObjectListIterator(const ObjectListIterator<T>& other)
+            {
+                this->element_ = other.element_;
+                this->iterator_ = ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
+            }
+
+            /**
+                @brief Unregisters the ObjectListIterator from the ObjectList.
+            */
+            inline ~ObjectListIterator()
+            {
+                ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterObjectListIterator(this->iterator_);
+            }
+
+            /**
+                @brief Assigns an ObjectListElement.
+                @param element The ObjectListElement
+            */
+            inline const ObjectListIterator<T>& operator=(ObjectListElement<T>* element)
+            {
+                this->element_ = element;
+                return (*this);
+            }
+
+            /**
+                @brief Assigns the element of another ObjectListIterator.
+                @param element The other ObjectListIterator
+            */
+            inline const ObjectListIterator<T>& operator=(const ObjectListIterator<T>& other)
+            {
+                this->element_ = other.element_;
+                return (*this);
+            }
+
+            /**
+                @brief Overloading of the ++it operator: ObjectListIterator points to the next object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline const ObjectListIterator<T>& operator++()
+            {
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->next_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it++ operator: ObjectListIterator points to the next object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline ObjectListIterator<T> operator++(int i)
+            {
+                ObjectListIterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->next_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the --it operator: ObjectListIterator points to the previous object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline const ObjectListIterator<T>& operator--()
+            {
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->prev_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it-- operator: ObjectListIterator points to the previous object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline ObjectListIterator<T> operator--(int i)
+            {
+                ObjectListIterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->prev_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the *it operator: returns the pointer to the object.
+                @return The object the ObjectListIterator points at
+            */
+            inline T* operator*() const
+            {
+                if (this->element_)
+                    return this->element_->object_;
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the it-> operator: returns the pointer to the object.
+                @return The object the ObjectListIterator points at
+            */
+            inline T* operator->() const
+            {
+                if (this->element_)
+                    return this->element_->object_;
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the typecast-operator to bool: returns true if the ObjectListIterator points to an existing object.
+                @return True if the ObjectListIterator points to an existing object.
+            */
+            inline operator bool() const
+            {
+                return (this->element_ != 0);
+            }
+
+            /**
+                @brief Overloading of the == operator to compare with another ObjectListIterator.
+                @param compare The other ObjectListIterator
+                @return True if the ObjectListIterator point to the same element
+            */
+            inline bool operator==(const ObjectListIterator<T>& compare) const
+            {
+                return (this->element_ == compare.element_);
+            }
+
+            /**
+                @brief Overloading of the != operator to compare with another ObjectListIterator.
+                @param compare The other ObjectListIterator
+                @return True if the ObjectListIterator point to different elements
+            */
+            inline bool operator!=(const ObjectListIterator<T>& compare) const
+            {
+                return (this->element_ != compare.element_);
+            }
+
+            /**
+                @brief Increments the ObjectListIterator if it points at the given object.
+                @param object The object to compare with
+            */
+            inline void incrementIfEqual(OrxonoxClass* object)
+            {
+                if (this->element_ && this->element_->objectBase_ == object)
+                    this->operator++();
+            }
+
+        private:
+            ObjectListElement<T>* element_;        //!< The element the Iterator points at
+            std::list<void*>::iterator iterator_;  //!< The iterator in the notifying list of the ObjectList
+    };
+}
+
+// Include ObjectList.h so the user only has to include one file: Iterator.h
+#include "ObjectList.h"
+
+#endif /* _ObjectListIterator_H__ */
Index: /code/branches/physics/src/core/OrxonoxClass.cc
===================================================================
--- /code/branches/physics/src/core/OrxonoxClass.cc	(revision 2122)
+++ /code/branches/physics/src/core/OrxonoxClass.cc	(revision 2122)
@@ -0,0 +1,136 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxonoxClass.cc
+    @brief Implementation of the OrxonoxClass Class.
+*/
+
+#include "OrxonoxClass.h"
+#include "MetaObjectList.h"
+#include "Identifier.h"
+
+namespace orxonox
+{
+    /** @brief Constructor: Sets the default values. */
+    OrxonoxClass::OrxonoxClass()
+    {
+        this->identifier_ = 0;
+        this->parents_ = 0;
+        this->metaList_ = new MetaObjectList();
+    }
+
+    /** @brief Destructor: Deletes, if existing, the list of the parents. */
+    OrxonoxClass::~OrxonoxClass()
+    {
+        delete this->metaList_;
+
+        // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
+        if (this->parents_)
+            delete this->parents_;
+    }
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const Identifier* identifier)
+        { return this->getIdentifier()->isA(identifier); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const Identifier* identifier)
+        { return this->getIdentifier()->isExactlyA(identifier); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const Identifier* identifier)
+        { return this->getIdentifier()->isChildOf(identifier); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const Identifier* identifier)
+        { return this->getIdentifier()->isDirectChildOf(identifier); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const Identifier* identifier)
+        { return this->getIdentifier()->isParentOf(identifier); }
+    /** @brief Returns true if the objects class is a direct parent of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const Identifier* identifier)
+        { return this->getIdentifier()->isDirectParentOf(identifier); }
+
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isA(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct parent of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
+
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isA(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct parent of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
+
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const OrxonoxClass* object)
+        { return this->getIdentifier()->isA(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const OrxonoxClass* object)
+        { return this->getIdentifier()->isExactlyA(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
+}
Index: /code/branches/physics/src/core/OrxonoxClass.h
===================================================================
--- /code/branches/physics/src/core/OrxonoxClass.h	(revision 2122)
+++ /code/branches/physics/src/core/OrxonoxClass.h	(revision 2122)
@@ -0,0 +1,112 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxonoxClass.h
+    @brief Declaration of the OrxonoxClass Class.
+
+    All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass.
+    It stores the Identifier and the MetaObjectList and has all needed functions to create and use the class-hierarchy.
+*/
+
+#ifndef _OrxonoxClass_H__
+#define _OrxonoxClass_H__
+
+#include "CorePrereqs.h"
+
+#include <set>
+#include <string>
+
+namespace orxonox
+{
+    //! The class all objects and interfaces of the game-logic (not the engine) are derived from.
+    /**
+        The BaseObject and Interfaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass.
+        OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList.
+    */
+    class _CoreExport OrxonoxClass
+    {
+        public:
+            OrxonoxClass();
+            virtual ~OrxonoxClass();
+
+            /** @brief Function to collect the SetConfigValue-macro calls. */
+            void setConfigValues() {};
+
+            /** @brief Returns the Identifier of the object. @return The Identifier */
+            inline Identifier* getIdentifier() const { return this->identifier_; }
+
+            /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
+            inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
+
+            /** @brief Returns the list of all parents of the object. @return The list */
+            inline std::set<const Identifier*>* getParents() const { return this->parents_; }
+
+            /** @brief Creates the parents-list. */
+            inline void createParents() { this->parents_ = new std::set<const Identifier*>(); }
+
+            /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */
+            inline MetaObjectList& getMetaList() { return (*this->metaList_); }
+
+
+            bool isA(const Identifier* identifier);
+            bool isExactlyA(const Identifier* identifier);
+            bool isChildOf(const Identifier* identifier);
+            bool isDirectChildOf(const Identifier* identifier);
+            bool isParentOf(const Identifier* identifier);
+            bool isDirectParentOf(const Identifier* identifier);
+
+            bool isA(const SubclassIdentifier<class B>* identifier);
+            bool isExactlyA(const SubclassIdentifier<class B>* identifier);
+            bool isChildOf(const SubclassIdentifier<class B>* identifier);
+            bool isDirectChildOf(const SubclassIdentifier<class B>* identifier);
+            bool isParentOf(const SubclassIdentifier<class B>* identifier);
+            bool isDirectParentOf(const SubclassIdentifier<class B>* identifier);
+
+            bool isA(const SubclassIdentifier<class B> identifier);
+            bool isExactlyA(const SubclassIdentifier<class B> identifier);
+            bool isChildOf(const SubclassIdentifier<class B> identifier);
+            bool isDirectChildOf(const SubclassIdentifier<class B> identifier);
+            bool isParentOf(const SubclassIdentifier<class B> identifier);
+            bool isDirectParentOf(const SubclassIdentifier<class B> identifier);
+
+            bool isA(const OrxonoxClass* object);
+            bool isExactlyA(const OrxonoxClass* object);
+            bool isChildOf(const OrxonoxClass* object);
+            bool isDirectChildOf(const OrxonoxClass* object);
+            bool isParentOf(const OrxonoxClass* object);
+            bool isDirectParentOf(const OrxonoxClass* object);
+
+        private:
+            Identifier* identifier_;                   //!< The Identifier of the object
+            std::set<const Identifier*>* parents_;     //!< List of all parents of the object
+            MetaObjectList* metaList_;                 //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
+    };
+}
+
+#endif /* _OrxonoxClass_H__ */
Index: /code/branches/physics/src/core/RootGameState.cc
===================================================================
--- /code/branches/physics/src/core/RootGameState.cc	(revision 2122)
+++ /code/branches/physics/src/core/RootGameState.cc	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "RootGameState.h"
+
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "Core.h"
+#include "Clock.h"
+#include "CommandLine.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(state, "gui").shortcut("s");
+
+    RootGameState::RootGameState(const std::string& name)
+        : GameState<GameStateBase>(name)
+        , stateRequest_("")
+    {
+    }
+
+    RootGameState::~RootGameState()
+    {
+    }
+
+    /**
+    @brief
+        Internal method that actually makes the state transition. Since it is internal,
+        the method can assume certain things to be granted (like 'this' is always active).
+    */
+    void RootGameState::makeTransition(GameStateBase* source, GameStateBase* destination)
+    {
+        if (source != 0)
+        {
+            // transition was not initiated by root itself
+            this->activeChild_ = 0;
+        }
+
+        if (destination == this)
+        {
+            // this marks the end of the game.
+            return;
+        }
+
+        // Check for 'destination' in the children map first
+        std::map<GameStateBase*, GameStateBase*>::const_iterator it
+            = this->grandchildrenToChildren_.find(destination);
+        if (it != this->grandchildrenToChildren_.end())
+        {
+            OrxAssert(dynamic_cast<GameStateBase*>(it->second) != 0,
+                "There was a mix with RootGameState and GameState, could not cast.");
+            GameStateBase* child = static_cast<GameStateBase*>(it->second);
+            // child state. Don't use 'state', might be a grandchild!
+            this->activeChild_ = child;
+            child->makeTransition(this, destination);
+        }
+        else
+        {
+            // root doesn't have a parent..
+            OrxAssert(false, "GameState '" + destination->getName() + "' not found in children list of Root.");
+        }
+    }
+
+    void RootGameState::gotoState(const std::string& name)
+    {
+        GameStateBase* request = getState(name);
+        if (request)
+        {
+            GameStateBase* current = getCurrentState();
+            if (current)
+            {
+                current->makeTransition(0, request);
+            }
+            else
+            {
+                // Root is not yet active. This is a violation.
+                ThrowException(GameState, "Activate Root before requesting a state.");
+            }
+        }
+        else
+        {
+            COUT(2) << "Warning: GameState '" << name << "' doesn't exist." << std::endl;
+        }
+    }
+
+    /**
+    @brief
+        Makes a state transition according to the state tree. You can choose any state
+        in the tree to do the call. The function finds the current state on its own.
+    @param state
+        The state to be entered, has to exist in the tree.
+    */
+    void RootGameState::requestState(const std::string& name)
+    {
+        this->stateRequest_ = name;
+    }
+
+    /**
+    @brief
+        Starts the game. The little 'while' denotes the main loop.
+        Whenever the root state is selected, the game ends.
+    @param name
+        State to start with (usually main menu or specified by command line)
+    */
+    void RootGameState::start()
+    {
+#ifdef NDEBUG
+        try
+        {
+#endif
+            // start global orxonox time
+            Clock clock;
+
+            // create the Core settings to configure the output level
+            Core::getInstance();
+
+            this->activate();
+
+            // get initial state from command line
+            gotoState(CommandLine::getValue("state"));
+
+            while (this->activeChild_)
+            {
+                clock.capture();
+
+                this->tick(clock);
+
+                if (this->stateRequest_ != "")
+                    gotoState(stateRequest_);
+            }
+
+            this->deactivate();
+#ifdef NDEBUG
+        }
+        // Note: These are all unhandled exceptions that should not have made its way here!
+        // almost complete game catch block to display the messages appropriately.
+        catch (std::exception& ex)
+        {
+            COUT(1) << ex.what() << std::endl;
+            COUT(1) << "Program aborted." << std::endl;
+        }
+        // anything that doesn't inherit from std::exception
+        catch (...)
+        {
+            COUT(1) << "An unidentifiable exception has occured. Program aborted." << std::endl;
+        }
+#endif
+    }
+}
Index: /code/branches/physics/src/core/RootGameState.h
===================================================================
--- /code/branches/physics/src/core/RootGameState.h	(revision 2122)
+++ /code/branches/physics/src/core/RootGameState.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _RootGameState_H__
+#define _RootGameState_H__
+
+#include "CorePrereqs.h"
+#include "GameState.h"
+
+namespace orxonox
+{
+    class _CoreExport RootGameState : public GameState<GameStateBase>
+    {
+    public:
+        RootGameState(const std::string& name);
+        ~RootGameState();
+
+        void requestState(const std::string& name);
+        void start();
+
+    private:
+        void makeTransition(GameStateBase* source, GameStateBase* destination);
+        void gotoState(const std::string& name);
+
+        std::string           stateRequest_;
+    };
+}
+
+#endif /* _RootGameState_H__ */
Index: /code/branches/physics/src/core/Shell.cc
===================================================================
--- /code/branches/physics/src/core/Shell.cc	(revision 2122)
+++ /code/branches/physics/src/core/Shell.cc	(revision 2122)
@@ -0,0 +1,393 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Shell.h"
+#include "CommandExecutor.h"
+#include "CoreIncludes.h"
+#include "ConfigValueIncludes.h"
+#include "Core.h"
+#include "ConsoleCommand.h"
+#include "util/OutputHandler.h"
+
+#define SHELL_UPDATE_LISTENERS(function) \
+    for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) \
+        (*(it++))->function()
+
+namespace orxonox
+{
+    SetConsoleCommand(Shell, clearShell, true);
+    SetConsoleCommand(Shell, history, true);
+
+    SetConsoleCommandShortcut(OutputHandler, log);
+    SetConsoleCommandShortcut(OutputHandler, error);
+    SetConsoleCommandShortcut(OutputHandler, warning);
+    SetConsoleCommandShortcut(OutputHandler, info);
+    SetConsoleCommandShortcut(OutputHandler, debug);
+
+    Shell* Shell::singletonRef_s = 0;
+
+    Shell::Shell()
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell);
+        Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1);
+
+        RegisterRootObject(Shell);
+
+        this->scrollPosition_ = 0;
+        this->maxHistoryLength_ = 100;
+        this->historyPosition_ = 0;
+        this->historyOffset_ = 0;
+        this->finishedLastLine_ = true;
+        this->bAddOutputLevel_ = false;
+
+        this->clearLines();
+
+        this->inputBuffer_ = new InputBuffer();
+        this->configureInputBuffer();
+
+        this->outputBuffer_.registerListener(this);
+        OutputHandler::getOutStream().setOutputBuffer(this->outputBuffer_);
+
+        this->setConfigValues();
+
+        Core::setSoftDebugLevel(OutputHandler::LD_Shell, level);
+    }
+
+    Shell::~Shell()
+    {
+        if (this->inputBuffer_)
+            delete this->inputBuffer_;
+        singletonRef_s = 0;
+    }
+
+    void Shell::setConfigValues()
+    {
+        SetConfigValue(maxHistoryLength_, 100).callback(this, &Shell::commandHistoryLengthChanged);
+        SetConfigValue(historyOffset_, 0).callback(this, &Shell::commandHistoryOffsetChanged);
+        SetConfigValueVector(commandHistory_, std::vector<std::string>());
+    }
+
+    void Shell::commandHistoryOffsetChanged()
+    {
+        if (this->historyOffset_ >= this->maxHistoryLength_)
+            this->historyOffset_ = 0;
+    }
+
+    void Shell::commandHistoryLengthChanged()
+    {
+        this->commandHistoryOffsetChanged();
+
+        while (this->commandHistory_.size() > this->maxHistoryLength_)
+        {
+            unsigned int index = this->commandHistory_.size() - 1;
+            this->commandHistory_.erase(this->commandHistory_.begin() + index);
+            ModifyConfigValue(commandHistory_, remove, index);
+        }
+    }
+
+    void Shell::configureInputBuffer()
+    {
+        this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
+        this->inputBuffer_->registerListener(this, &Shell::execute, '\r', false);
+        this->inputBuffer_->registerListener(this, &Shell::hintandcomplete, '\t', true);
+        this->inputBuffer_->registerListener(this, &Shell::backspace, '\b', true);
+        this->inputBuffer_->registerListener(this, &Shell::deletechar, KeyCode::Delete);
+        this->inputBuffer_->registerListener(this, &Shell::exit, (char)27, true);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_right, KeyCode::Right);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_left, KeyCode::Left);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_end, KeyCode::End);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_home, KeyCode::Home);
+        this->inputBuffer_->registerListener(this, &Shell::history_up, KeyCode::Up);
+        this->inputBuffer_->registerListener(this, &Shell::history_down, KeyCode::Down);
+        this->inputBuffer_->registerListener(this, &Shell::scroll_up, KeyCode::PageUp);
+        this->inputBuffer_->registerListener(this, &Shell::scroll_down, KeyCode::PageDown);
+    }
+
+    void Shell::clearShell()
+    {
+        Shell::getInstance().clearLines();
+    }
+
+    void Shell::history()
+    {
+        Shell& instance = Shell::getInstance();
+
+        for (int i = instance.historyOffset_; i < (int)instance.commandHistory_.size(); ++i)
+            instance.addLine(instance.commandHistory_[i], -1);
+        for (int i =  0; i < (int)instance.historyOffset_; ++i)
+            instance.addLine(instance.commandHistory_[i], -1);
+    }
+
+    void Shell::registerListener(ShellListener* listener)
+    {
+        this->listeners_.insert(this->listeners_.end(), listener);
+    }
+
+    void Shell::unregisterListener(ShellListener* listener)
+    {
+        for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+        {
+            if ((*it) == listener)
+                this->listeners_.erase(it++);
+            else
+                ++it;
+        }
+    }
+
+    void Shell::setCursorPosition(unsigned int cursor)
+    {
+        this->inputBuffer_->setCursorPosition(cursor);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::setInput(const std::string& input)
+    {
+        this->inputBuffer_->set(input);
+        this->inputChanged();
+    }
+
+    void Shell::addLine(const std::string& line, int level)
+    {
+        int original_level = OutputHandler::getOutStream().getOutputLevel();
+        OutputHandler::getOutStream().setOutputLevel(level);
+
+        if (!this->finishedLastLine_)
+            this->outputBuffer_ << std::endl;
+
+        this->outputBuffer_ << line << std::endl;
+        OutputHandler::getOutStream().setOutputLevel(original_level);
+    }
+
+    void Shell::clearLines()
+    {
+        this->lines_.clear();
+        this->scrollIterator_ = this->lines_.begin();
+
+        this->scrollPosition_ = 0;
+        this->finishedLastLine_ = true;
+
+        SHELL_UPDATE_LISTENERS(linesChanged);
+    }
+
+    std::list<std::string>::const_iterator Shell::getNewestLineIterator() const
+    {
+        if (this->scrollPosition_)
+            return this->scrollIterator_;
+        else
+            return this->lines_.begin();
+    }
+
+    std::list<std::string>::const_iterator Shell::getEndIterator() const
+    {
+        return this->lines_.end();
+    }
+
+    void Shell::addToHistory(const std::string& command)
+    {
+        ModifyConfigValue(commandHistory_, set, this->historyOffset_, command);
+        this->historyPosition_ = 0;
+        ModifyConfigValue(historyOffset_, set, (this->historyOffset_ + 1) % this->maxHistoryLength_);
+    }
+
+    std::string Shell::getFromHistory() const
+    {
+        unsigned int index = mod(((int)this->historyOffset_) - ((int)this->historyPosition_), this->maxHistoryLength_);
+        if (index < this->commandHistory_.size() && this->historyPosition_ != 0)
+            return this->commandHistory_[index];
+        else
+            return "";
+    }
+
+    void Shell::outputChanged()
+    {
+        std::string output;
+        bool newline;
+        do
+        {
+            newline = this->outputBuffer_.getLine(&output);
+
+            if (!newline && output == "")
+                break;
+
+            if (this->finishedLastLine_)
+            {
+                if (this->bAddOutputLevel_)
+                    output.insert(0, 1, (char)OutputHandler::getOutStream().getOutputLevel());
+
+                this->lines_.insert(this->lines_.begin(), output);
+
+                if (this->scrollPosition_)
+                    this->scrollPosition_++;
+                else
+                    this->scrollIterator_ = this->lines_.begin();
+
+                this->finishedLastLine_ = newline;
+
+                if (!this->scrollPosition_)
+                {
+                    SHELL_UPDATE_LISTENERS(lineAdded);
+                }
+            }
+            else
+            {
+                (*this->lines_.begin()) += output;
+                this->finishedLastLine_ = newline;
+                SHELL_UPDATE_LISTENERS(onlyLastLineChanged);
+            }
+
+        } while (newline);
+    }
+
+    void Shell::inputChanged()
+    {
+        SHELL_UPDATE_LISTENERS(inputChanged);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::execute()
+    {
+        this->addToHistory(this->inputBuffer_->get());
+        this->addLine(this->inputBuffer_->get(), 0);
+
+        if (!CommandExecutor::execute(this->inputBuffer_->get()))
+            this->addLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", 1);
+
+        this->clear();
+    }
+
+    void Shell::hintandcomplete()
+    {
+        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
+        this->addLine(CommandExecutor::hint(this->inputBuffer_->get()), -1);
+
+        this->inputChanged();
+    }
+
+    void Shell::backspace()
+    {
+        this->inputBuffer_->removeBehindCursor();
+        SHELL_UPDATE_LISTENERS(inputChanged);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::deletechar()
+    {
+        this->inputBuffer_->removeAtCursor();
+        SHELL_UPDATE_LISTENERS(inputChanged);
+    }
+
+    void Shell::clear()
+    {
+        this->inputBuffer_->clear();
+        this->historyPosition_ = 0;
+        SHELL_UPDATE_LISTENERS(inputChanged);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_right()
+    {
+        this->inputBuffer_->increaseCursor();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_left()
+    {
+        this->inputBuffer_->decreaseCursor();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_end()
+    {
+        this->inputBuffer_->setCursorToEnd();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_home()
+    {
+        this->inputBuffer_->setCursorToBegin();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::history_up()
+    {
+        if (this->historyPosition_ < this->commandHistory_.size())
+        {
+            this->historyPosition_++;
+            this->inputBuffer_->set(this->getFromHistory());
+        }
+    }
+
+    void Shell::history_down()
+    {
+        if (this->historyPosition_ > 0)
+        {
+            this->historyPosition_--;
+            this->inputBuffer_->set(this->getFromHistory());
+        }
+    }
+
+    void Shell::scroll_up()
+    {
+        if (this->scrollIterator_ != this->lines_.end())
+        {
+            ++this->scrollIterator_;
+            ++this->scrollPosition_;
+
+            SHELL_UPDATE_LISTENERS(linesChanged);
+        }
+    }
+
+    void Shell::scroll_down()
+    {
+        if (this->scrollIterator_ != this->lines_.begin())
+        {
+            --this->scrollIterator_;
+            --this->scrollPosition_;
+
+            SHELL_UPDATE_LISTENERS(linesChanged);
+        }
+    }
+
+    void Shell::exit()
+    {
+        if (this->inputBuffer_->getSize() > 0)
+        {
+            this->clear();
+            return;
+        }
+
+        this->clear();
+        this->scrollPosition_ = 0;
+        this->scrollIterator_ = this->lines_.begin();
+
+        SHELL_UPDATE_LISTENERS(exit);
+    }
+}
Index: /code/branches/physics/src/core/Shell.h
===================================================================
--- /code/branches/physics/src/core/Shell.h	(revision 2122)
+++ /code/branches/physics/src/core/Shell.h	(revision 2122)
@@ -0,0 +1,149 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Shell_H__
+#define _Shell_H__
+
+#include "CorePrereqs.h"
+
+#include <list>
+#include <vector>
+
+#include "OrxonoxClass.h"
+#include "input/InputBuffer.h"
+#include "util/OutputBuffer.h"
+
+namespace orxonox
+{
+    class _CoreExport ShellListener
+    {
+        friend class Shell;
+
+        public:
+            virtual ~ShellListener() {}
+
+        private:
+            virtual void linesChanged() {}
+            virtual void onlyLastLineChanged() {}
+            virtual void lineAdded() {}
+            virtual void inputChanged() {}
+            virtual void cursorChanged() {}
+            virtual void exit() {}
+    };
+
+    class _CoreExport Shell : virtual public OrxonoxClass, public OutputBufferListener
+    {
+        public:
+            Shell();
+            virtual ~Shell();
+
+            static Shell& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+            static void clearShell();
+            static void history();
+
+            virtual void setConfigValues();
+            void commandHistoryOffsetChanged();
+            void commandHistoryLengthChanged();
+
+            void registerListener(ShellListener* listener);
+            void unregisterListener(ShellListener* listener);
+
+            inline InputBuffer* getInputBuffer()
+                { return this->inputBuffer_; }
+            inline OutputBuffer& getOutputBuffer()
+                { return this->outputBuffer_; }
+
+            void setCursorPosition(unsigned int cursor);
+            inline unsigned int getCursorPosition() const
+                { return this->inputBuffer_->getCursorPosition(); }
+
+            void setInput(const std::string& input);
+
+            inline void clearInput()
+                { this->setInput(""); }
+            inline std::string getInput() const
+                { return this->inputBuffer_->get(); }
+
+            std::list<std::string>::const_iterator getNewestLineIterator() const;
+            std::list<std::string>::const_iterator getEndIterator() const;
+
+            void addLine(const std::string& line, int level = 0);
+            void clearLines();
+
+            inline unsigned int getNumLines() const
+                { return this->lines_.size(); }
+            inline unsigned int getScrollPosition() const
+                { return this->scrollPosition_; }
+
+            inline void addOutputLevel(bool bAddOutputLevel)
+                { this->bAddOutputLevel_ = bAddOutputLevel; }
+
+        private:
+            Shell(const Shell& other);
+
+            void configureInputBuffer();
+
+            void addToHistory(const std::string& command);
+            std::string getFromHistory() const;
+
+            virtual void outputChanged();
+            void inputChanged();
+            void execute();
+            void hintandcomplete();
+            void backspace();
+            void deletechar();
+            void clear();
+            void cursor_right();
+            void cursor_left();
+            void cursor_end();
+            void cursor_home();
+            void history_up();
+            void history_down();
+            void scroll_up();
+            void scroll_down();
+            void exit();
+
+            std::list<ShellListener*> listeners_;
+            InputBuffer* inputBuffer_;
+            OutputBuffer outputBuffer_;
+            bool finishedLastLine_;
+            std::list<std::string> lines_;
+            std::list<std::string>::const_iterator scrollIterator_;
+            unsigned int scrollPosition_;
+            std::vector<std::string> commandHistory_;
+            unsigned int maxHistoryLength_;
+            unsigned int historyPosition_;
+            unsigned int historyOffset_;
+            bool bAddOutputLevel_;
+
+            static Shell* singletonRef_s;
+    };
+}
+
+#endif /* _Shell_H__ */
Index: /code/branches/physics/src/core/Super.h
===================================================================
--- /code/branches/physics/src/core/Super.h	(revision 2122)
+++ /code/branches/physics/src/core/Super.h	(revision 2122)
@@ -0,0 +1,495 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Super.h
+    @brief Definition of all super-function related macros.
+
+    This file defines all macros needed to add a new "super-function".
+    If you add a super-function, you can call SUPER(myclass, functionname) inside your
+    code and the function of the parentclass gets called. This is comparable with
+    super.functionname() in Java or other languages.
+
+    This works only with virtual functions that return nothing (void) and belong to
+    classes that have an Identifier. Arguments however are supported.
+
+    To add a new super-function, you have process 4 steps:
+
+    1) Add a new SUPER macro
+       This allows you to call the super-function in your code.
+       Location: This file (Super.h), marked with --> HERE <-- comments (1/3)
+
+    2) Call the SUPER_FUNCTION_GLOBAL_DECLARATION_PART1/2 macros.
+       This defines some global classes and templates, needed to create and call the super-functions.
+       Location: This file (Super.h), marked with --> HERE <-- comments (2/3)
+
+    3) Call the SUPER_INTRUSIVE_DECLARATION macro.
+       This will be included into the declaration of ClassIdentifier<T>.
+       Location: This file (Super.h), marked with --> HERE <-- comments (3/3)
+
+    4) Call the SUPER_FUNCTION macro.
+       This defines a partially specialized template that will decide if a class is "super" to another class.
+       If the check returns true, a SuperFunctionCaller gets created, which will be used by the SUPER macro.
+       You have to add this into the header-file of the baseclass of the super-function (the class that first
+       implements the function), below the class declaration. You can't call it directly in this file, because
+       otherwise you had to include the headerfile right here, which would cause some ugly backdependencies,
+       include loops and slower compilation.
+       Dont forget to include Super.h in the header-file.
+       Location: The header-file of the baseclass (Baseclass.h), below the class declaration
+*/
+
+#ifndef _Super_H__
+#define _Super_H__
+
+#include <iostream>
+
+#include "CorePrereqs.h"
+
+#include "util/Debug.h"
+#include "XMLIncludes.h"
+#include "Event.h"
+
+///////////////////////
+// Macro definitions //
+///////////////////////
+
+//// Common macros ////
+
+    /**
+        @brief Declares a new super-function by creating a specialized template. Add this below the class declaration of the baseclass.
+        @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
+        @param baseclass The baseclass of the super-function (~the root)
+        @param functionname The name of the super-function
+        @param purevirtualbase "true" if the function is pure virtual in the baseclass, "false" if the function is implemented (without "")
+    */
+    #define SUPER_FUNCTION(functionnumber, baseclass, functionname, purevirtualbase) \
+        template <class T, int templatehack2> \
+        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2> \
+        { \
+            static void check() \
+            { \
+                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0); \
+                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check(); \
+            } \
+            \
+            static void apply(void* temp) {} \
+            static void apply(baseclass* temp) \
+            { \
+                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \
+                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \
+                { \
+                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
+                    { \
+                        COUT(5) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; \
+                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \
+                    } \
+                } \
+            } \
+        }; \
+        \
+        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase(functionnumber, baseclass)
+
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND0(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND1(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass) \
+        template <int templatehack2> \
+        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
+        { \
+            static void check() \
+            { \
+                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
+            } \
+        };
+
+
+    /*
+    //// Comments about the macro ////
+
+        // Partially specialized template (templatehack is now specialized too).
+        //
+        // This ensures the compiler takes THIS template if the header-file of the super-function
+        // is included. In any other case, the compiler just uses the fallback template which is
+        // defined in this file.
+        template <class T, templatehack2>
+        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2>
+        {
+            static void check()
+            {
+                // This call to the apply-function is the whole check. By calling the function with
+                // a T* pointer, the right function get's called.
+                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0);
+
+                // Go go the check for of next super-function (functionnumber + 1)
+                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check();
+            }
+
+            // This function gets called if T is not a child of the baseclass.
+            // The function does nothing.
+            static void apply(void* temp) {}
+
+            // This function gets called if T is a child of the baseclass and can therefore be converted.
+            // The function adds a SuperFunctionCaller to the Identifier of all subclasses of T.
+            static void apply(baseclass* temp)
+            {
+                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
+
+                // Iterate through all children
+                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)
+                {
+                    // Check if there's not already a caller
+                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
+                    {
+                        // Add the SuperFunctionCaller
+                        COUT(5) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl;
+                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;
+                    }
+                }
+            }
+        };
+        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase
+
+
+        // The following piece of code is only added if purevirtualbase = true
+
+        // Explicit specialization of the Condition template for the baseclass to avoid
+        // errors if the function is pure virtual in the baseclass.
+        template <int templatehack2> \
+        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
+        { \
+            // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)
+            static void check() \
+            { \
+                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
+            } \
+        };
+    */
+
+    // SUPER-macro: Calls Parent::functionname() where Parent is the direct parent of classname
+    #define SUPER(classname, functionname, ...) \
+        SUPER_##functionname(classname, functionname, __VA_ARGS__)
+
+    // helper macro: for functions without arguments
+    #define SUPER_NOARGS(classname, functionname) \
+        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)
+
+    // helper macro: for functions with arguments
+    #define SUPER_ARGS(classname, functionname, ...) \
+        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this, __VA_ARGS__)
+
+
+//// Function-specific macros ////
+
+    /*
+        Add a macro for each super-function
+
+        Example (no arguments):
+        #define SUPER_myfunction(classname, functionname, ...) \
+            SUPER_NOARGS(classname, functionname)
+
+        Example (with arguments):
+        #define SUPER_myfunction(classname, functionname, ...) \
+            SUPER_ARGS(classname, functionname, __VA_ARGS__)
+    */
+
+    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+    #define SUPER_XMLPort(classname, functionname, ...) \
+        SUPER_ARGS(classname, functionname, __VA_ARGS__)
+
+    #define SUPER_tick(classname, functionname, ...) \
+        SUPER_ARGS(classname, functionname, __VA_ARGS__)
+
+    #define SUPER_changedActivity(classname, functionname, ...) \
+        SUPER_NOARGS(classname, functionname)
+
+    #define SUPER_changedVisibility(classname, functionname, ...) \
+        SUPER_NOARGS(classname, functionname)
+
+    #define SUPER_processEvent(classname, functionname, ...) \
+        SUPER_ARGS(classname, functionname, __VA_ARGS__)
+    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+
+
+namespace orxonox
+{
+    /////////////////////////////////////////////////////////////////////////////////////////////////////
+    // This code gets included by Identifier.h and every other header file that needs a super-function //
+    /////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    //// Common code ////
+
+        // Base templates
+        /**
+            @brief Creates the SuperFunctionCaller if T is a child of the super-functions baseclass.
+        */
+        template <int functionnumber, class T, int templatehack1, int templatehack2>
+        struct SuperFunctionCondition
+        {
+            static void check() {}
+        };
+
+        /**
+            @brief Initializes the SuperFunctionCaller-pointer with zero.
+        */
+        template <int functionnumber, class T>
+        struct SuperFunctionInitialization
+        {
+            static void initialize(ClassIdentifier<T>* identifier) {}
+        };
+
+        /**
+            @brief Deletes the SuperFunctionCaller.
+        */
+        template <int functionnumber, class T>
+        struct SuperFunctionDestruction
+        {
+            static void destroy(ClassIdentifier<T>* identifier) {}
+        };
+
+
+    //// Function-specific code ////
+
+        /**
+            @brief Creates the needed objects and templates to call a super-function.
+            @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
+            @param functionname The name of the super-function
+            @param hasarguments "false" if the function doesn't take any arguments, "true" if it does (without "")
+            @param ... Variadic: If the function takes arguments, add them here with type and name. Example: int myvalue, float myothervalue
+        */
+        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(functionnumber, functionname, hasarguments, ...) \
+            template <class T, int templatehack1, int templatehack2> \
+            struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2> \
+            { \
+                static void check() \
+                { \
+                    SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check(); \
+                } \
+            }; \
+            \
+            template <class T> \
+            struct SuperFunctionInitialization<functionnumber, T> \
+            { \
+                static void initialize(ClassIdentifier<T>* identifier) \
+                { \
+                    identifier->superFunctionCaller_##functionname##_ = 0; \
+                    SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \
+                } \
+            }; \
+            \
+            template <class T> \
+            struct SuperFunctionDestruction<functionnumber, T> \
+            { \
+                static void destroy(ClassIdentifier<T>* identifier) \
+                { \
+                    if (identifier->superFunctionCaller_##functionname##_) \
+                        delete identifier->superFunctionCaller_##functionname##_; \
+                    SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier); \
+                } \
+            }; \
+            \
+            class _CoreExport SuperFunctionCaller_##functionname \
+            { \
+                public: \
+                    virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
+                    virtual ~SuperFunctionCaller_##functionname () {} \
+            }; \
+            \
+            template <class T> \
+            class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \
+            { \
+                public: \
+                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
+                    { \
+                        (dynamic_cast<T*>(object))->T:: functionname
+
+        /*
+            JUST ADD THE FUNCTION ARGUMENTS BETWEEN BOTH MACROS, ENCLOSED BY BRACKETS
+            EXAMPLE:
+
+              SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, myfunction, true, int myvalue, float myothervalue) <-- !!! DONT ADD A SEMICOLON HERE !!!
+                (myvalue, myothervalue)
+              SUPER_FUNCTION_GLOBAL_DECLARATION_PART2
+        */
+
+        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2 \
+                                                        ; \
+                    } \
+            };
+
+        #define SUPER_CALL_ARGUMENTSfalse(...) OrxonoxClass* object
+        #define SUPER_CALL_ARGUMENTS0(...)     OrxonoxClass* object
+        #define SUPER_CALL_ARGUMENTStrue(...) OrxonoxClass* object, __VA_ARGS__
+        #define SUPER_CALL_ARGUMENTS1(...)    OrxonoxClass* object, __VA_ARGS__
+
+
+    /*
+    //// COMMENTS ABOUT THE MACRO ////
+
+        // Partially specialized template (templatehack not yet specialized, this
+        // will be done by the real condition in the header-file of the super-function)
+        // Only used as fallback
+        template <class T, int templatehack1, int templatehack2>
+        struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2>
+        {
+            // If this function gets called, the header-file of the super function is not
+            // included, so this fallback template (templatehack not specialized) is used
+            static void check()
+            {
+                // Calls the condition-check of the next super-function (functionnumber + 1)
+                SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check();
+            }
+        };
+
+        // Initializes the SuperFunctionCaller-pointer with zero.
+        template <class T>
+        struct SuperFunctionInitialization<functionnumber, T>
+        {
+            static void initialize(ClassIdentifier<T>* identifier)
+            {
+                identifier->superFunctionCaller_##functionname##_ = 0;
+
+                // Calls the initialization of the next super-function (functionnumber + 1)
+                SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier);
+            }
+        };
+
+        // Deletes the SuperFunctionCaller.
+        template <class T>
+        struct SuperFunctionDestruction<functionnumber, T>
+        {
+            static void destroy(ClassIdentifier<T>* identifier)
+            {
+                if (identifier->superFunctionCaller_##functionname##_)
+                    delete identifier->superFunctionCaller_##functionname##_;
+
+                // Calls the destruction of the next super-function (functionnumber + 1)
+                SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier);
+            }
+        };
+
+        // Baseclass of the super-function caller. The real call will be done by a
+        // templatized subclass through the virtual () operator.
+        class _CoreExport SuperFunctionCaller_##functionname
+        {
+            public:
+                virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
+                virtual ~SuperFunctionCaller_##functionname () {}
+        };
+
+        // The real super-function caller: Calls T::functionname()
+        // T should be the parent, but this will be done by the spezialized condition template
+        template <class T>
+        class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname
+        {
+            public:
+                // @brief Calls the function.
+                // @param object The object to call the function on
+                // @param ... The arguments of the function
+                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
+                {
+                    (dynamic_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
+                }
+        }
+    */
+
+
+    //// Execute the code for each super-function ////
+
+        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, XMLPort, true, Element& xmlelement, XMLPort::Mode mode)
+            (xmlelement, mode)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(1, tick, true, float dt)
+            (dt)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(2, changedActivity, false)
+            ()
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(3, changedVisibility, false)
+            ()
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(4, processEvent, true, Event& event)
+            (event)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+
+}
+
+#else /* _Super_H__ */
+  #ifdef SUPER_INTRUSIVE_DECLARATION_INCLUDE
+
+//////////////////////////////////////////////////////////////////////////
+// This code gets included within the declaration of ClassIdentifier<T> //
+//////////////////////////////////////////////////////////////////////////
+
+//// Common code ////
+
+    private:
+
+        template <int functionnumber, class TT, int templatehack1, int templatehack2>
+        friend struct SuperFunctionCondition;
+
+        // Creates the super-function-callers by calling the first SuperFunctionCondition check
+        // This get's called within the initialization of an Identifier
+        virtual void createSuperFunctionCaller() const
+        {
+            SuperFunctionCondition<0, T, 0, 0>::check();
+        }
+
+
+//// Function-specific code ////
+
+    public:
+        /**
+            @brief Adds a pointer to the SuperFunctionCaller as a member of ClassIdentifier.
+            @param functionname The name of the super-function
+        */
+        #ifndef SUPER_INTRUSIVE_DECLARATION
+          #define SUPER_INTRUSIVE_DECLARATION(functionname) \
+            SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_
+        #endif
+
+
+//// Execute the code for each super-function ////
+
+    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+    SUPER_INTRUSIVE_DECLARATION(XMLPort);
+    SUPER_INTRUSIVE_DECLARATION(tick);
+    SUPER_INTRUSIVE_DECLARATION(changedActivity);
+    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
+    SUPER_INTRUSIVE_DECLARATION(processEvent);
+    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+
+
+    #undef SUPER_INTRUSIVE_DECLARATION_INCLUDE
+  #endif /* SUPER_INTRUSIVE_DECLARATION_INCLUDE */
+#endif /* _Super_H__ */
Index: /code/branches/physics/src/core/TclBind.cc
===================================================================
--- /code/branches/physics/src/core/TclBind.cc	(revision 2122)
+++ /code/branches/physics/src/core/TclBind.cc	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "TclBind.h"
+
+#include <iostream>
+#include <string>
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "TclThreadManager.h"
+#include "util/Debug.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcut(TclBind, tcl);
+    SetConsoleCommandShortcut(TclBind, bgerror);
+
+    TclBind* TclBind::singletonRef_s = 0;
+
+    TclBind::TclBind(const std::string& datapath)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+        this->interpreter_ = 0;
+        this->bSetTclLibPath_ = false;
+        this->setDataPath(datapath);
+    }
+
+    TclBind::~TclBind()
+    {
+        if (this->interpreter_)
+            delete this->interpreter_;
+        singletonRef_s = 0;
+    }
+
+    void TclBind::setDataPath(const std::string& datapath)
+    {
+        this->tclLibPath_ = datapath + "/tcl" + TCL_VERSION + "/";
+        this->bSetTclLibPath_ = true;
+
+        this->createTclInterpreter();
+    }
+
+    void TclBind::createTclInterpreter()
+    {
+        if (this->bSetTclLibPath_ && !this->interpreter_)
+        {
+            this->interpreter_ = new Tcl::interpreter(this->tclLibPath_);
+            this->interpreter_->def("orxonox::query", TclBind::tcl_query, Tcl::variadic());
+            this->interpreter_->def("orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
+            this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
+
+            try
+            {
+                this->interpreter_->eval("proc query args { orxonox::query $args }");
+                this->interpreter_->eval("proc crossquery {id args} { orxonox::crossquery 0 $id $args }");
+                this->interpreter_->eval("set id 0");
+                this->interpreter_->eval("rename exit tcl::exit; proc exit {} { execute exit }");
+                this->interpreter_->eval("redef_puts");
+            }
+            catch (Tcl::tcl_error const &e)
+            {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+            catch (std::exception const &e)
+            {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+        }
+    }
+
+    void TclBind::createNewTclInterpreter()
+    {
+        if (this->interpreter_)
+        {
+            delete this->interpreter_;
+            this->interpreter_ = 0;
+        }
+
+        this->createTclInterpreter();
+    }
+
+    std::string TclBind::tcl_query(Tcl::object const &args)
+    {
+        COUT(4) << "Tcl_query: " << args.get() << std::endl;
+
+        std::string command = stripEnclosingBraces(args.get());
+
+        if (!CommandExecutor::execute(command, false))
+        {
+            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
+        }
+
+        if (CommandExecutor::getLastEvaluation().hasReturnvalue())
+            return CommandExecutor::getLastEvaluation().getReturnvalue().getString();
+
+        return "";
+    }
+
+    void TclBind::tcl_execute(Tcl::object const &args)
+    {
+        COUT(4) << "Tcl_execute: " << args.get() << std::endl;
+        std::string command = stripEnclosingBraces(args.get());
+
+        if (!CommandExecutor::execute(command, false))
+        {
+            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
+        }
+    }
+
+    std::string TclBind::tcl(const std::string& tclcode)
+    {
+        if (TclBind::getInstance().interpreter_)
+        {
+            try
+            {
+                std::string output = TclBind::getInstance().interpreter_->eval(tclcode);
+                if (output != "")
+                {
+                    COUT(0) << "tcl> " << output << std::endl;
+                }
+                return output;
+            }
+            catch (Tcl::tcl_error const &e)
+            {   COUT(1) << "tcl> Error: " << e.what() << std::endl;   }
+            catch (std::exception const &e)
+            {   COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;   }
+        }
+
+        return "";
+    }
+
+    void TclBind::bgerror(std::string error)
+    {
+        COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
+    }
+
+    bool TclBind::eval(const std::string& tclcode)
+    {
+        try
+        {
+            TclBind::getInstance().interpreter_->eval(tclcode);
+            return true;
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;   }
+
+        return false;
+    }
+}
Index: /code/branches/physics/src/core/TclBind.h
===================================================================
--- /code/branches/physics/src/core/TclBind.h	(revision 2122)
+++ /code/branches/physics/src/core/TclBind.h	(revision 2122)
@@ -0,0 +1,71 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TclBind_H__
+#define _TclBind_H__
+
+#include "CorePrereqs.h"
+
+#include "cpptcl/CppTcl.h"
+
+namespace orxonox
+{
+    class _CoreExport TclBind
+    {
+        public:
+            TclBind(const std::string& datapath);
+            ~TclBind();
+
+            static TclBind& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+            static std::string tcl(const std::string& tclcode);
+            static void bgerror(std::string error);
+
+            void setDataPath(const std::string& datapath);
+            std::string getTclLibPath() const { return this->tclLibPath_; }
+            void createTclInterpreter();
+            void createNewTclInterpreter();
+            Tcl::interpreter* getTclInterpreter() const { return this->interpreter_; }
+
+            static std::string tcl_query(Tcl::object const &args);
+            static void tcl_execute(Tcl::object const &args);
+
+            static bool eval(const std::string& tclcode);
+
+        private:
+            TclBind(const TclBind& other);
+
+            Tcl::interpreter* interpreter_;
+            std::string tclLibPath_;
+            bool bSetTclLibPath_;
+
+            static TclBind* singletonRef_s;
+    };
+}
+
+#endif /* _TclBind_H__ */
Index: /code/branches/physics/src/core/TclThreadManager.cc
===================================================================
--- /code/branches/physics/src/core/TclThreadManager.cc	(revision 2122)
+++ /code/branches/physics/src/core/TclThreadManager.cc	(revision 2122)
@@ -0,0 +1,680 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "TclThreadManager.h"
+
+#include <iostream>
+#include <string>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+#include <OgreTimer.h>
+
+#include "CoreIncludes.h"
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "TclBind.h"
+#include "util/Debug.h"
+#include "util/Convert.h"
+
+
+namespace orxonox
+{
+    const unsigned int TCLTHREADMANAGER_MAX_QUEUE_LENGTH = 100;
+    const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f;
+
+    SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommandShortcutAlias(TclThreadManager, query,   "tclquery"  ).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, create,  false);
+    SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, query,   false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, status,  false);
+    SetConsoleCommand(TclThreadManager, dump,    false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, flush,   false).argumentCompleter(0, autocompletion::tclthreads());
+
+    TclThreadManager* TclThreadManager::singletonRef_s = 0;
+
+    TclThreadManager::TclThreadManager(Tcl::interpreter* interpreter)
+    {
+        RegisterRootObject(TclThreadManager);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->threadCounter_ = 0;
+        this->orxonoxInterpreterBundle_.id_ = 0;
+        this->orxonoxInterpreterBundle_.interpreter_ = interpreter;
+#if (BOOST_VERSION >= 103500)
+        this->threadID_ = boost::this_thread::get_id();
+#else
+        //
+#endif
+    }
+
+    TclThreadManager::~TclThreadManager()
+    {
+        unsigned int threadID;
+        {
+            boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+            if (this->interpreterBundles_.begin() == this->interpreterBundles_.end())
+                return;
+            else
+                threadID = this->interpreterBundles_.begin()->first;
+        }
+        this->destroy(threadID);
+
+        singletonRef_s = 0;
+    }
+
+    unsigned int TclThreadManager::create()
+    {
+        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        TclThreadManager::getInstance().threadCounter_++;
+        std::string name = getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().threadCounter_);
+
+        TclInterpreterBundle* bundle = new TclInterpreterBundle;
+        bundle->id_ = TclThreadManager::getInstance().threadCounter_;
+        bundle->interpreter_ = TclThreadManager::getInstance().createNewTclInterpreter(name);
+        bundle->interpreterName_ = name;
+        bundle->running_ = true;
+        bundle->finished_ = true;
+
+        TclThreadManager::getInstance().interpreterBundles_[TclThreadManager::getInstance().threadCounter_] = bundle;
+        COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().threadCounter_ << std::endl;
+        return TclThreadManager::getInstance().threadCounter_;
+    }
+
+    unsigned int TclThreadManager::createID(unsigned int threadID)
+    {
+        unsigned int temp = TclThreadManager::getInstance().threadCounter_;
+        TclThreadManager::getInstance().threadCounter_ = threadID - 1;
+        TclThreadManager::create();
+        TclThreadManager::getInstance().threadCounter_ = temp;
+        return threadID;
+    }
+
+    void TclThreadManager::destroy(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            {
+                boost::mutex::scoped_lock running_lock(bundle->runningMutex_);
+                bundle->running_ = false;
+            }
+            while (true)
+            {
+                {
+                    boost::mutex::scoped_lock finished_lock(bundle->finishedMutex_);
+                    if (bundle->finished_)
+                    {
+                        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+#if (BOOST_VERSION >= 103500)
+                        boost::mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
+#else
+                        boost::try_mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
+#endif
+                        try
+                        {
+                            while (!interpreter_lock.try_lock())
+                            {
+                                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
+#if (BOOST_VERSION >= 103500)
+                                boost::this_thread::yield();
+#else
+                                boost::thread::yield();
+#endif
+                            }
+                        } catch (...) {}
+                        delete bundle->interpreter_;
+                        delete bundle;
+                        TclThreadManager::getInstance().interpreterBundles_.erase(threadID);
+                        break;
+                    }
+                }
+
+                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
+#if (BOOST_VERSION >= 103500)
+                boost::this_thread::yield();
+#else
+                boost::thread::yield();
+#endif
+            }
+
+            COUT(0) << "Destroyed Tcl-interpreter with ID " << threadID << std::endl;
+        }
+    }
+
+    void TclThreadManager::execute(unsigned int threadID, const std::string& _command)
+    {
+        std::string command = stripEnclosingBraces(_command);
+
+        if (threadID == 0)
+            TclThreadManager::getInstance().pushCommandToQueue(command);
+        else
+            TclThreadManager::getInstance().pushCommandToQueue(threadID, command);
+    }
+
+    std::string TclThreadManager::query(unsigned int threadID, const std::string& command)
+    {
+        return TclThreadManager::getInstance().evalQuery(TclThreadManager::getInstance().orxonoxInterpreterBundle_.id_, threadID, command);
+    }
+
+    void TclThreadManager::status()
+    {
+        COUT(0) << "Thread ID" << '\t' << "Queue size" << '\t' << "State" << std::endl;
+
+        std::string output = "Orxonox";
+        output += "\t\t";
+        {
+            boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queueMutex_);
+            output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
+        }
+        output += "\t\t";
+        output += "busy";
+        COUT(0) << output << std::endl;
+
+        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = TclThreadManager::getInstance().interpreterBundles_.begin(); it != TclThreadManager::getInstance().interpreterBundles_.end(); ++it)
+        {
+            std::string output = getConvertedValue<unsigned int, std::string>((*it).first);
+            output += "\t\t";
+            {
+                boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_);
+                output += getConvertedValue<unsigned int, std::string>((*it).second->queue_.size());
+            }
+            output += "\t\t";
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
+#else
+                boost::try_mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
+#endif
+                if (interpreter_lock.try_lock())
+                    output += "ready";
+                else
+                    output += "busy";
+            }
+            COUT(0) << output << std::endl;
+        }
+    }
+
+    void TclThreadManager::dump(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = 0;
+        if (threadID == 0)
+        {
+            bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_;
+            COUT(0) << "Queue dump of Orxonox:" << std::endl;
+        }
+        else
+        {
+            if ((bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID)))
+            {
+                COUT(0) << "Queue dump of Tcl-thread " << threadID << ":" << std::endl;
+            }
+            else
+                return;
+        }
+
+        boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+        unsigned int index = 0;
+        for (std::list<std::string>::const_iterator it = bundle->queue_.begin(); it != bundle->queue_.end(); ++it)
+        {
+            index++;
+            COUT(0) << index << ": " << (*it) << std::endl;
+        }
+    }
+
+    void TclThreadManager::flush(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = 0;
+        if (threadID == 0)
+            bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_;
+        else
+            if (!(bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID)))
+                return;
+
+        boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+        bundle->queue_.clear();
+        if (threadID == 0)
+        {
+            COUT(0) << "Flushed queue of Orxonox Tcl-interpreter." << std::endl;
+        }
+        else
+        {
+            COUT(0) << "Flushed queue of Tcl-interpreter " << threadID << "." << std::endl;
+        }
+    }
+
+    void TclThreadManager::tcl_execute(Tcl::object const &args)
+    {
+        TclThreadManager::getInstance().pushCommandToQueue(stripEnclosingBraces(args.get()));
+    }
+
+    std::string TclThreadManager::tcl_query(int querierID, Tcl::object const &args)
+    {
+        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, stripEnclosingBraces(args.get()));
+    }
+
+    std::string TclThreadManager::tcl_crossquery(int querierID, int threadID, Tcl::object const &args)
+    {
+        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, stripEnclosingBraces(args.get()));
+    }
+
+    bool TclThreadManager::tcl_running(int threadID)
+    {
+        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle((unsigned int)threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock running_lock(bundle->runningMutex_);
+            return bundle->running_;
+        }
+        return false;
+    }
+
+    Tcl::interpreter* TclThreadManager::createNewTclInterpreter(const std::string& threadID)
+    {
+        Tcl::interpreter* i = 0;
+        i = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
+
+        try
+        {
+            i->def("orxonox::query", TclThreadManager::tcl_query, Tcl::variadic());
+            i->def("orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
+            i->def("orxonox::execute", TclThreadManager::tcl_execute, Tcl::variadic());
+            i->def("orxonox::running", TclThreadManager::tcl_running);
+
+            i->def("execute", TclThreadManager::tcl_execute, Tcl::variadic());
+            i->eval("proc query args { orxonox::query " + threadID + " $args }");
+            i->eval("proc crossquery {id args} { orxonox::crossquery " + threadID + " $id $args }");
+            i->eval("set id " + threadID);
+
+            i->eval("rename exit tcl::exit");
+            i->eval("proc exit {} { orxonox TclThreadManager destroy " + threadID + " }");
+
+            i->eval("redef_puts");
+
+//            i->eval("rename while tcl::while");
+//            i->eval("proc while {test command} { tcl::while {[uplevel 1 expr $test]} {uplevel 1 $command} }"); // (\"$test\" && [orxonox::running " + threadID + "]])
+//            i->eval("rename for tcl::for");
+//            i->eval("proc for {start test next command} { uplevel tcl::for \"$start\" \"$test\" \"$next\" \"$command\" }");
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl error while creating Tcl-interpreter (" << threadID << "): " << e.what() << std::endl;   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while creating Tcl-interpreter (" << threadID << "): " << e.what() << std::endl;   }
+
+        return i;
+    }
+
+    TclInterpreterBundle* TclThreadManager::getInterpreterBundle(unsigned int threadID)
+    {
+        boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+        std::map<unsigned int, TclInterpreterBundle*>::iterator it = this->interpreterBundles_.find(threadID);
+        if (it != this->interpreterBundles_.end())
+        {
+            return (*it).second;
+        }
+        else
+        {
+            this->error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + " existing.");
+            return 0;
+        }
+    }
+
+    std::string TclThreadManager::dumpList(const std::list<unsigned int>& list)
+    {
+        std::string output = "";
+        for (std::list<unsigned int>::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            if (it != list.begin())
+                output += " ";
+
+            output += getConvertedValue<unsigned int, std::string>(*it);
+        }
+        return output;
+    }
+
+    void TclThreadManager::error(const std::string& error)
+    {
+#if (BOOST_VERSION >= 103500)
+        if (boost::this_thread::get_id() != this->threadID_)
+#else
+        if (boost::thread() != this->threadID_)
+#endif
+        {
+            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::this_thread::yield();
+#else
+                boost::thread::yield();
+#endif
+                return;
+            }
+        }
+
+        this->forceCommandToFrontOfQueue("error " + error);
+    }
+
+    void TclThreadManager::debug(const std::string& error)
+    {
+#if (BOOST_VERSION >= 103500)
+        if (boost::this_thread::get_id() != this->threadID_)
+#else
+        if (boost::thread() != this->threadID_)
+#endif
+        {
+            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::this_thread::yield();
+#else
+                boost::thread::yield();
+#endif
+                return;
+            }
+        }
+
+        this->forceCommandToFrontOfQueue("debug " + error);
+    }
+
+    void TclThreadManager::pushCommandToQueue(const std::string& command)
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        while (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            this->fullQueueCondition_.wait(queue_lock);
+
+        this->orxonoxInterpreterBundle_.queue_.push_back(command);
+    }
+
+    void TclThreadManager::forceCommandToFrontOfQueue(const std::string& command)
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        this->orxonoxInterpreterBundle_.queue_.push_front(command);
+    }
+
+    std::string TclThreadManager::popCommandFromQueue()
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        std::string temp = this->orxonoxInterpreterBundle_.queue_.front();
+        this->orxonoxInterpreterBundle_.queue_.pop_front();
+        this->fullQueueCondition_.notify_one();
+        return temp;
+    }
+
+    bool TclThreadManager::queueIsEmpty()
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        return this->orxonoxInterpreterBundle_.queue_.empty();
+    }
+
+    void TclThreadManager::pushCommandToQueue(unsigned int threadID, const std::string& command)
+    {
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+            if (bundle->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
+                this->error("Error: Queue of Tcl-interpreter " + getConvertedValue<unsigned int, std::string>(threadID) + " is full, couldn't add command.");
+                return;
+            }
+
+            bundle->queue_.push_back(command);
+        }
+    }
+
+    std::string TclThreadManager::popCommandFromQueue(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+            std::string temp = bundle->queue_.front();
+            bundle->queue_.pop_front();
+            return temp;
+        }
+        return "";
+    }
+
+    bool TclThreadManager::queueIsEmpty(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+            return bundle->queue_.empty();
+        }
+        return true;
+    }
+
+    bool TclThreadManager::updateQueriersList(TclInterpreterBundle* querier, TclInterpreterBundle* target)
+    {
+        if (querier == target)
+            return false;
+
+        boost::mutex::scoped_lock queriers_lock(target->queriersMutex_);
+
+        {
+            boost::mutex::scoped_lock queriers_lock(querier->queriersMutex_);
+            target->queriers_.insert(target->queriers_.end(), querier->queriers_.begin(), querier->queriers_.end());
+        }
+
+        target->queriers_.insert(target->queriers_.end(), querier->id_);
+
+        if (std::find(target->queriers_.begin(), target->queriers_.end(), target->id_) != target->queriers_.end())
+        {
+            this->error("Error: Circular query (" + this->dumpList(target->queriers_) + " -> " + getConvertedValue<unsigned int, std::string>(target->id_) + "), couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target->id_) + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(querier->id_) + ".");
+            return false;
+        }
+
+        return true;
+    }
+
+    std::string TclThreadManager::evalQuery(unsigned int querierID, const std::string& command)
+    {
+        TclInterpreterBundle* querier = this->getInterpreterBundle(querierID);
+        std::string output = "";
+        if (querier)
+        {
+            if (this->updateQueriersList(querier, &this->orxonoxInterpreterBundle_))
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#else
+                boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#endif
+                this->orxonoxEvalCondition_.wait(interpreter_lock);
+
+                if (!CommandExecutor::execute(command, false))
+                    this->error("Error: Can't execute command \"" + command + "\"!");
+
+                if (CommandExecutor::getLastEvaluation().hasReturnvalue())
+                    output = CommandExecutor::getLastEvaluation().getReturnvalue().getString();
+            }
+
+            boost::mutex::scoped_lock queriers_lock(this->orxonoxInterpreterBundle_.queriersMutex_);
+            this->orxonoxInterpreterBundle_.queriers_.clear();
+        }
+        return output;
+    }
+
+    std::string TclThreadManager::evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command)
+    {
+        TclInterpreterBundle* target = 0;
+        if (threadID)
+            target = this->getInterpreterBundle(threadID);
+        else
+            target = &this->orxonoxInterpreterBundle_;
+
+        std::string output = "";
+        if (target)
+        {
+            TclInterpreterBundle* querier = 0;
+            if (querierID)
+                querier = this->getInterpreterBundle(querierID);
+            else
+                querier = &this->orxonoxInterpreterBundle_;
+
+            if (querier)
+            {
+                if (this->updateQueriersList(querier, target))
+                {
+#if (BOOST_VERSION >= 103500)
+                    boost::mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
+#else
+                    boost::try_mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
+#endif
+                    bool successfullyLocked = false;
+                    try
+                    {
+                        if (querierID == 0 || std::find(querier->queriers_.begin(), querier->queriers_.end(), (unsigned int)0) != querier->queriers_.end())
+                            successfullyLocked = interpreter_lock.try_lock();
+                        else
+                        {
+                            while (!interpreter_lock.try_lock())
+                            {
+#if (BOOST_VERSION >= 103500)
+                                boost::this_thread::yield();
+#else
+                                boost::thread::yield();
+#endif
+                            }
+
+                            successfullyLocked = true;
+                        }
+                    } catch (...) {}
+
+                    if (successfullyLocked)
+                    {
+                        this->debug("TclThread_query: " + command);
+                        try
+                        {   output = (std::string)target->interpreter_->eval(command);   }
+                        catch (Tcl::tcl_error const &e)
+                        {   this->error("Tcl error: " + (std::string)e.what());   }
+                        catch (std::exception const &e)
+                        {   this->error("Error while executing Tcl: " + (std::string)e.what());   }
+                    }
+                    else
+                    {
+                        this->error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + ", interpreter is busy right now.");
+                    }
+                }
+
+                boost::mutex::scoped_lock queriers_lock(target->queriersMutex_);
+                target->queriers_.clear();
+            }
+        }
+        return output;
+    }
+
+    void TclThreadManager::tick(float dt)
+    {
+        {
+            this->orxonoxEvalCondition_.notify_one();
+#if (BOOST_VERSION >= 103500)
+            boost::this_thread::yield();
+#else
+            boost::thread::yield();
+#endif
+        }
+
+        {
+            boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+            for (std::map<unsigned int, TclInterpreterBundle*>::iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
+            {
+                boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_);
+                if (!(*it).second->queue_.empty())
+                {
+                    std::string command = (*it).second->queue_.front();
+                    (*it).second->queue_.pop_front();
+                    {
+                        boost::mutex::scoped_lock finished_lock((*it).second->finishedMutex_);
+                        (*it).second->finished_ = false;
+                    }
+                    boost::thread(boost::bind(&tclThread, (*it).second, command));
+                }
+            }
+        }
+
+        {
+#if (BOOST_VERSION >= 103500)
+            boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#else
+            boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#endif
+            unsigned long maxtime = (unsigned long)(dt * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
+            Ogre::Timer timer;
+            while (!this->queueIsEmpty())
+            {
+                CommandExecutor::execute(this->popCommandFromQueue(), false);
+                if (timer.getMicroseconds() > maxtime)
+                    break;
+            }
+        }
+    }
+
+    std::list<unsigned int> TclThreadManager::getThreadList() const
+    {
+        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        std::list<unsigned int> threads;
+        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
+            threads.push_back((*it).first);
+        return threads;
+    }
+
+    void tclThread(TclInterpreterBundle* interpreterBundle, std::string command)
+    {
+        TclThreadManager::getInstance().debug("TclThread_execute: " + command);
+#if (BOOST_VERSION >= 103500)
+        boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
+#else
+        boost::try_mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
+#endif
+        try
+        {
+            interpreterBundle->interpreter_->eval(command);
+        }
+        catch (Tcl::tcl_error const &e)
+        {
+            TclThreadManager::getInstance().error("Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + ") error: " + e.what());
+        }
+        catch (std::exception const &e)
+        {
+            TclThreadManager::getInstance().error("Error while executing Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + "): " + e.what());
+        }
+
+        boost::mutex::scoped_lock finished_lock(interpreterBundle->finishedMutex_);
+        interpreterBundle->finished_ = true;
+        interpreterBundle->finishedCondition_.notify_all();
+    }
+}
Index: /code/branches/physics/src/core/TclThreadManager.h
===================================================================
--- /code/branches/physics/src/core/TclThreadManager.h	(revision 2122)
+++ /code/branches/physics/src/core/TclThreadManager.h	(revision 2122)
@@ -0,0 +1,140 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TclThreadManager_H__
+#define _TclThreadManager_H__
+
+#include "CorePrereqs.h"
+
+#include <queue>
+#include <map>
+#include <list>
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/thread/thread.hpp>
+
+#include "cpptcl/CppTcl.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    struct _CoreExport TclInterpreterBundle
+    {
+        unsigned int id_;
+
+        std::list<std::string> queue_;
+        boost::mutex queueMutex_;
+
+        Tcl::interpreter* interpreter_;
+        std::string interpreterName_;
+        boost::try_mutex interpreterMutex_;
+
+        std::list<unsigned int> queriers_;
+        boost::mutex queriersMutex_;
+
+        bool running_;
+        boost::mutex runningMutex_;
+
+        bool finished_;
+        boost::mutex finishedMutex_;
+        boost::condition finishedCondition_;
+    };
+
+    class _CoreExport TclThreadManager : public OrxonoxClass
+    {
+        friend class IRC;
+        friend class TclBind;
+
+        public:
+            TclThreadManager(Tcl::interpreter* interpreter);
+            ~TclThreadManager();
+
+            static TclThreadManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+            static unsigned int create();
+            static unsigned int createID(unsigned int threadID);
+            static void destroy(unsigned int threadID);
+            static void execute(unsigned int threadID, const std::string& command);
+            static std::string query(unsigned int threadID, const std::string& command);
+            static void status();
+            static void dump(unsigned int threadID);
+            static void flush(unsigned int threadID);
+
+            void error(const std::string& error);
+            void debug(const std::string& error);
+
+            virtual void tick(float dt);
+
+            std::list<unsigned int> getThreadList() const;
+
+        private:
+            TclThreadManager(const TclThreadManager& other);
+
+            static void tcl_execute(Tcl::object const &args);
+            static std::string tcl_query(int querierID, Tcl::object const &args);
+            static std::string tcl_crossquery(int querierID, int threadID, Tcl::object const &args);
+            static bool tcl_running(int threadID);
+
+            Tcl::interpreter* createNewTclInterpreter(const std::string& threadID);
+            TclInterpreterBundle* getInterpreterBundle(unsigned int threadID);
+            std::string dumpList(const std::list<unsigned int>& list);
+
+            void pushCommandToQueue(const std::string& command);
+            void forceCommandToFrontOfQueue(const std::string& command);
+            std::string popCommandFromQueue();
+            bool queueIsEmpty();
+
+            void pushCommandToQueue(unsigned int threadID, const std::string& command);
+            std::string popCommandFromQueue(unsigned int threadID);
+            bool queueIsEmpty(unsigned int threadID);
+
+            bool updateQueriersList(TclInterpreterBundle* querier, TclInterpreterBundle* target);
+
+            std::string evalQuery(unsigned int querierID, const std::string& command);
+            std::string evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command);
+
+            unsigned int threadCounter_;
+            TclInterpreterBundle orxonoxInterpreterBundle_;
+            std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;
+            boost::mutex bundlesMutex_;
+            boost::condition fullQueueCondition_;
+            boost::condition orxonoxEvalCondition_;
+#if (BOOST_VERSION >= 103500)
+            boost::thread::id threadID_;
+#else
+            boost::thread threadID_;
+#endif
+
+            static TclThreadManager* singletonRef_s;
+    };
+
+    _CoreExport void tclThread(TclInterpreterBundle* interpreterBundle, std::string command);
+}
+
+#endif /* _TclThreadManager_H__ */
Index: /code/branches/physics/src/core/Template.cc
===================================================================
--- /code/branches/physics/src/core/Template.cc	(revision 2122)
+++ /code/branches/physics/src/core/Template.cc	(revision 2122)
@@ -0,0 +1,163 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Template.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+#include "tinyxml/ticpp.h"
+
+namespace orxonox
+{
+    CreateFactory(Template);
+
+    Template::Template(BaseObject* creator) : BaseObject(creator), xmlelement_("")
+    {
+        RegisterObject(Template);
+
+        this->bIsLink_ = false;
+        this->bIsReturningXMLElement_ = false;
+        this->baseclassIdentifier_ = 0;
+    }
+
+    Template::~Template()
+    {
+        Template::getTemplateMap().erase(this->getName());
+    }
+
+    void Template::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Template, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Template, "link", setLink, getLink, xmlelement, mode);
+        XMLPortParam(Template, "baseclass", setBaseclass, getBaseclass, xmlelement, mode);
+
+        Element* element = xmlelement.FirstChildElement(false);
+        if (element)
+        {
+            TiXmlElement* tixmlelement = dynamic_cast<TiXmlElement*>(element->GetTiXmlPointer());
+            if (tixmlelement)
+                this->setXMLElement(*tixmlelement);
+        }
+    }
+
+    void Template::changedName()
+    {
+        if (this->getName() != "")
+        {
+            std::map<std::string, Template*>::iterator it;
+            it = Template::getTemplateMap().find(this->getOldName());
+            if (it != Template::getTemplateMap().end())
+                Template::getTemplateMap().erase(it);
+
+            it = Template::getTemplateMap().find(this->getName());
+            if (it != Template::getTemplateMap().end())
+                COUT(2) << "Warning: Template with name \"" << this->getName() << "\" already exists." << std::endl;
+            else
+                Template::getTemplateMap()[this->getName()] = this;
+        }
+    }
+
+    const TiXmlElement& Template::getXMLElement() const
+    {
+        if (this->bIsLink_)
+        {
+            Template* temp = Template::getTemplate(this->link_);
+            if (temp)
+            {
+                if (!temp->bIsReturningXMLElement_)
+                {
+                    this->bIsReturningXMLElement_ = true;
+                    const TiXmlElement& element = temp->getXMLElement();
+                    this->bIsReturningXMLElement_ = false;
+                    return element;
+                }
+                else
+                {
+                    COUT(2) << "Warning: Linking from " << this->getName() << " to " << this->link_ << " leads to an infinite loop. Returning own element." << std::endl;
+                }
+            }
+            else
+            {
+                COUT(2) << "Warning: " << this->link_ << " is not an existing Template name. Returning own element." << std::endl;
+            }
+        }
+
+        return this->xmlelement_;
+    }
+
+    void Template::setBaseclass(const std::string& baseclass)
+    {
+        this->baseclassIdentifier_ = ClassByString(baseclass);
+        if (this->baseclassIdentifier_)
+            this->baseclass_ = baseclass;
+    }
+
+    void Template::applyOn(BaseObject* object)
+    {
+        if (this->baseclassIdentifier_)
+        {
+            if (!object->isA(this->baseclassIdentifier_))
+            {
+                COUT(1) << "Error: Can't apply template (name: " << this->getName() << "), object (name: " << object->getName() << ", class: " << object->getIdentifier()->getName() << ") is not a " << this->baseclassIdentifier_->getName() << std::endl;
+                return;
+            }
+        }
+
+        COUT(4) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << std::endl;
+
+        Element temp = ((TiXmlElement*)&this->getXMLElement());
+        object->XMLPort(temp, XMLPort::LoadObject);
+    }
+
+    std::map<std::string, Template*>& Template::getTemplateMap()
+    {
+        static std::map<std::string, Template*> templateMap;
+        return templateMap;
+    }
+
+    Template* Template::getTemplate(const std::string& name)
+    {
+        std::map<std::string, Template*>::iterator it = Template::getTemplateMap().find(name);
+        if (it != Template::getTemplateMap().end())
+            return it->second;
+        else
+        {
+            COUT(2) << "Warning: Template with name " << name << " doesn't exist." << std::endl;
+            return 0;
+        }
+    }
+
+    void Template::apply(const std::string& name, BaseObject* object)
+    {
+        std::map<std::string, Template*>::iterator it = Template::getTemplateMap().find(name);
+        if (it != Template::getTemplateMap().end())
+            it->second->applyOn(object);
+    }
+}
Index: /code/branches/physics/src/core/Template.h
===================================================================
--- /code/branches/physics/src/core/Template.h	(revision 2122)
+++ /code/branches/physics/src/core/Template.h	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Template_H__
+#define _Template_H__
+
+#include <map>
+
+#include "CorePrereqs.h"
+
+#include "BaseObject.h"
+#include "tinyxml/tinyxml.h"
+
+namespace orxonox
+{
+    class _CoreExport Template : public BaseObject
+    {
+        public:
+            Template(BaseObject* creator);
+            virtual ~Template();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void changedName();
+
+            inline void setLink(const std::string& link)
+                { this->link_ = link; this->bIsLink_ = (link != ""); }
+            inline const std::string& getLink() const
+                { return this->link_; }
+
+            inline void setXMLElement(const TiXmlElement& xmlelement)
+                { this->xmlelement_ = xmlelement; }
+            const TiXmlElement& getXMLElement() const;
+
+            void setBaseclass(const std::string& baseclass);
+            inline const std::string& getBaseclass() const
+                { return this->baseclass_; }
+            inline Identifier* getBaseclassIdentifier() const
+                { return this->baseclassIdentifier_; }
+
+            void applyOn(BaseObject* object);
+
+            static std::map<std::string, Template*>& getTemplateMap();
+            static Template* getTemplate(const std::string& name);
+            static void apply(const std::string& name, BaseObject* object);
+
+        private:
+            TiXmlElement xmlelement_;
+            std::string link_;
+            std::string baseclass_;
+            Identifier* baseclassIdentifier_;
+            bool bIsLink_;
+            mutable bool bIsReturningXMLElement_;
+    };
+}
+
+#endif /* _Template_H__ */
Index: /code/branches/physics/src/core/XMLFile.h
===================================================================
--- /code/branches/physics/src/core/XMLFile.h	(revision 2122)
+++ /code/branches/physics/src/core/XMLFile.h	(revision 2122)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _XMLFile_H__
+#define _XMLFile_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+#include "ClassTreeMask.h"
+
+namespace orxonox
+{
+    class _CoreExport XMLFile
+    {
+        public:
+            XMLFile(const std::string& filename) : filename_(filename) {}
+            XMLFile(const std::string& filename, const ClassTreeMask& mask) : filename_(filename), mask_(mask) {};
+
+            const std::string& getFilename() const { return this->filename_; }
+            const ClassTreeMask& getMask() const { return this->mask_; }
+
+        private:
+            std::string filename_;
+            ClassTreeMask mask_;
+    };
+}
+
+#endif /* _XMLFile_H__ */
Index: /code/branches/physics/src/core/XMLIncludes.h
===================================================================
--- /code/branches/physics/src/core/XMLIncludes.h	(revision 2122)
+++ /code/branches/physics/src/core/XMLIncludes.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file XMLIncludes.h
+    @brief Forward declarations of some XML classes.
+*/
+
+#include "CorePrereqs.h"
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+class TiXmlString;
+class TiXmlOutStream;
+class TiXmlNode;
+class TiXmlHandle;
+class TiXmlDocument;
+class TiXmlElement;
+class TiXmlComment;
+class TiXmlUnknown;
+class TiXmlAttribute;
+class TiXmlText;
+class TiXmlDeclaration;
+class TiXmlParsingData;
+
+namespace ticpp
+{
+    class Document;
+    class Element;
+    class Declaration;
+    class StylesheetReference;
+    class Text;
+    class Comment;
+    class Attribute;
+}
+
+namespace orxonox
+{
+    typedef ticpp::Document Document;
+    typedef ticpp::Element Element;
+    typedef ticpp::Declaration Declaration;
+    typedef ticpp::StylesheetReference StylesheetReference;
+    typedef ticpp::Text Text;
+    typedef ticpp::Comment Comment;
+    typedef ticpp::Attribute Attribute;
+}
Index: /code/branches/physics/src/core/XMLNameListener.cc
===================================================================
--- /code/branches/physics/src/core/XMLNameListener.cc	(revision 2122)
+++ /code/branches/physics/src/core/XMLNameListener.cc	(revision 2122)
@@ -0,0 +1,38 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "XMLNameListener.h"
+#include "CoreIncludes.h"
+
+namespace orxonox
+{
+    XMLNameListener::XMLNameListener()
+    {
+        RegisterRootObject(XMLNameListener);
+    }
+}
Index: /code/branches/physics/src/core/XMLNameListener.h
===================================================================
--- /code/branches/physics/src/core/XMLNameListener.h	(revision 2122)
+++ /code/branches/physics/src/core/XMLNameListener.h	(revision 2122)
@@ -0,0 +1,47 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _XMLNameListener_H__
+#define _XMLNameListener_H__
+
+#include "CorePrereqs.h"
+#include "OrxonoxClass.h"
+
+namespace orxonox
+{
+    class _CoreExport XMLNameListener : virtual public OrxonoxClass
+    {
+        public:
+            XMLNameListener();
+            virtual ~XMLNameListener() {}
+
+            virtual void loadedNewXMLName(BaseObject* object) = 0;
+    };
+}
+
+#endif /* _XMLNameListener_H__ */
Index: /code/branches/physics/src/core/XMLPort.cc
===================================================================
--- /code/branches/physics/src/core/XMLPort.cc	(revision 2122)
+++ /code/branches/physics/src/core/XMLPort.cc	(revision 2122)
@@ -0,0 +1,44 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "XMLPort.h"
+#include "Language.h"
+#include "Loader.h"
+#include "Namespace.h"
+#include "CoreIncludes.h"
+
+namespace orxonox
+{
+    // ################################
+    // ###  XMLPortObjectContainer  ###
+    // ################################
+    bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier)
+    {
+        return ((!this->bApplyLoaderMask_) || identifier->isA(Class(Namespace)) || Loader::currentMask_s.isIncluded(identifier));
+    }
+}
Index: /code/branches/physics/src/core/XMLPort.h
===================================================================
--- /code/branches/physics/src/core/XMLPort.h	(revision 2122)
+++ /code/branches/physics/src/core/XMLPort.h	(revision 2122)
@@ -0,0 +1,574 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file XMLPort.h
+    @brief Declaration of the XMLPort helper classes and macros.
+
+    XMLPort is a virtual function of every BaseObject. Every object can change this function.
+    The XMLPort function gets called with an XMLElement, containing all attributes and
+    subclasses the object gets from the levelfile.
+
+    This file declares classes and macros to simplify XML-parsing.
+*/
+
+#ifndef _XMLPort_H__
+#define _XMLPort_H__
+
+#include "CorePrereqs.h"
+
+#include "util/Debug.h"
+#include "util/MultiType.h"
+#include "tinyxml/ticpp.h"
+#include "XMLIncludes.h"
+#include "Executor.h"
+#include "CoreIncludes.h"
+#include "BaseObject.h"
+
+// ------------
+// XMLPortParam
+
+/**
+    @brief Declares an XML attribute with a name, which will be set through load- and savefunctions.
+    @param classname The name of the class owning this param
+    @param paramname The name of the attribute
+    @param loadfunction A function to set the param in the object with a given value (~a set-function)
+    @param savefunction A function to get the value of the param from the object (~a get-function)
+    @param xmlelement The XMLElement, you get this from the XMLPort function
+    @param mode The mode (load or save), you get this from the XMLPort function
+
+    In the XML file, a param or attribute will be set like this:
+    <classname paramname="value" />
+
+    The macro will then call loadfunction(value) to set the given value (or call savefunction() to
+    write an existing value to an XML file).
+*/
+#define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
+/**
+    @brief This is the same as XMLPortParam, but you can set the template arguments needed to store the loadfunction.
+
+    Sometimes the name of the loadfunction is ambiguous (example: setPosition(Vector3) or
+    setPosition(float, float, float)). In this case, you can choose the right function by
+    telling the types of the functionparams. In our example, this would be either
+    > XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, Vector3);
+    or
+    > XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, float, float, float);
+    You don't have to use this, if there exist only one function with the given name.
+*/
+#define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
+
+// --------------------
+// XMLPortParamLoadOnly
+
+/**
+    @brief Declares an XML attribute with a name, which can be set through a loadfunction.
+
+    This is the same as XMLPortParam, but you don't need a savefunction (get-function). Therefore,
+    this param won't be saved in an XML file, but you can add the attribute manually an it will be
+    loaded.
+
+    This might be helpful in cases, when you have several options to set a value, for example the
+    rotation. You can set the rotation with a quaternion, but you could also use three angles.
+    When saving the object, only one of both options has to be saved; this is, where this macro helps.
+*/
+#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
+/**
+    @brief This is the same as XMLPortParamTemplate, but for load-only attributes (see XMLPortParamLoadOnly).
+*/
+#define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
+
+// ------------------
+// XMLPortParamExtern
+
+/**
+    @brief This is the same as XMLPortParam, but for attributes in an extern class.
+    @param classname The name of the class owning the object owning the attribute
+    @param externclass The name of the extern class (the objects class)
+    @param object The name of the object of the extern class (a member of the main class)
+    @param paramname The name of the attribute
+    @param loadfunction The function to set the attribute inside of the member object.
+    @param loadfunction The function to get the attribute from the member object
+
+    Sometimes you'll have a member object in your class, which has it's own load- and savefunctions.
+    With this macro, you can simply use them instead of writing your own functions.
+
+    @example
+    Your class is called SpaceShip and this class has an object (myPilot_) of class Pilot. Pilot has a name
+    and two functions, setName(name) and getName(). Now you want an attribute "pilotname" in your
+    SpaceShip class. Instead of writing wrapper functions, you can simply use the XMLPortParamExtern
+    macro:
+    > XMLPortParamExtern(SpaceShip, Pilot, myPilot_, "pilotname", setName, getName, xmlelement, mode);
+*/
+#define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
+/**
+    @brief This is the same as XMLPortParamTemplate, but for extern attributes (see XMLPortParamExtern).
+*/
+#define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
+
+// -------------------
+// XMLPortParamGeneric
+
+/**
+    @brief This is the generic XMLPort param macro, which is used by all six specialized macros above.
+*/
+#define XMLPortParamGeneric(containername, classname, objectclass, object, paramname, loadexecutor, saveexecutor, xmlelement, mode) \
+    orxonox::XMLPortClassParamContainer<objectclass>* containername = (orxonox::XMLPortClassParamContainer<objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortParamContainer(paramname)); \
+    if (!containername) \
+    { \
+        containername = new orxonox::XMLPortClassParamContainer<objectclass>(std::string(paramname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor); \
+        ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
+    } \
+    containername->port((BaseObject*)this, object, xmlelement, mode)
+
+// --------------------
+// XMLPortObjectExtended
+
+/**
+    @brief Declares a possible sub-object that can be added in the XML file.
+    @param classname The name of the class that uses this macro
+    @param objectclass The baseclass of objects that can be added
+    @param sectionname The name of the subsection in the XML file that encloses the sub-objects ("" means no subsection)
+    @param loadfunction The function to add a new object to the class
+    @param loadfunction The function to get all added objects from the class
+    @param xmlelement The XMLElement (recieved through the XMLPort function)
+    @param mode The mode (load/save) (received through the XMLPort function)
+    @param bApplyLoaderMask If this is true, an added sub-object only gets loaded if it's class is included in the Loaders ClassTreeMask (this is usually false)
+    @param bLoadBefore If this is true, the sub-cobject gets loaded (through XMLPort) BEFORE it gets added to the main class (this is usually true)
+
+    bApplyLoaderMask is usually false for the following reason:
+    If the loaders mask says, for example, "load only SpaceShips" and you added weapons to the
+    SpaceShips, then the Weapons will still be loaded (which is most probably what you want).
+    Of course, if there are "standalone" weapons in the level, they wont be loaded.
+
+    If bLoadBefore, an added object already has all attributes set (like it's name). This is most
+    likely the best option, so this is usually true.
+
+    @note
+    The load- and savefunctions have to follow an exactly defined protocol.
+    Loadfunction:
+      The loadfunction gets a pointer to the object.
+      > void loadfunction(objectclass* pointer);
+
+    Savefunction:
+      The savefunction gets an index, starting with 0. For every returnvalue != 0, the savefunction
+      gets called again, but with index + 1. It's the functions responsibility to do something smart
+      with the index and to return 0 if all objects were returned.
+      > objectclass* savefunction(unsigned int index) const;
+
+      Possible implementation:
+        objectclass* savefunction(unsigned int index) const
+        {
+          if (index < number_of_added_objects_)
+            return my_added_objects[index];
+          else
+            return 0;
+        }
+
+    @example
+    Possible usage of the macro:
+    > XMLPortObject(SpaceShip, Weapon, "weapons", addWeapon, getWeapon, xmlelement, mode, false, true);
+
+    Now you can add weapons through the XML file:
+    <SpaceShip someattribute="..." ...>
+      <weapons>
+        <Weapon someattribute="..." ... />
+        <Weapon someattribute="..." ... />
+        <Weapon someattribute="..." ... />
+      </weapons>
+    </SpaceShip>
+
+    Note that "weapons" is the subsection. This allows you to add more types of sub-objects. In our example,
+    you could add pilots, blinking lights or other stuff. If you don't want a subsection, just use "" (an
+    empty string). The you can add sub-objects directly into the mainclass.
+*/
+#define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
+/**
+    @brief This is the same as XMLPortObjectExtended, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
+*/
+#define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
+
+// -------------
+// XMLPortObject
+
+/**
+    @brief This is the same as XMLPortObjectExtended, but bApplyLoaderMask is false and bLoadBefore is true by default.
+*/
+#define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
+/**
+    @brief This is the same as XMLPortObject, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
+*/
+#define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
+
+// --------------------
+// XMLPortObjectGeneric
+
+/**
+    @brief Generic XMLPortObject macro, that gets called by all other XMLPortObject macros above.
+*/
+#define XMLPortObjectGeneric(containername, classname, objectclass, sectionname, loadexecutor, saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
+    orxonox::XMLPortClassObjectContainer<classname, objectclass>* containername = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortObjectContainer(sectionname)); \
+    if (!containername) \
+    { \
+        containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \
+        ClassIdentifier<classname>::getIdentifier()->addXMLPortObjectContainer(sectionname, containername); \
+    } \
+    containername->port(this, xmlelement, mode)
+
+
+namespace orxonox
+{
+    // ###############################
+    // ###  XMLPortParamContainer  ###
+    // ###############################
+    class _CoreExport XMLPortParamContainer
+    {
+    public:
+        enum ParseResult
+        {
+            PR_not_started,
+            PR_finished,
+            PR_waiting_for_default_values
+        };
+
+        public:
+            XMLPortParamContainer()
+                { this->parseResult_ = PR_not_started; }
+            virtual ~XMLPortParamContainer() {}
+
+            inline const std::string& getName() const
+                { return this->paramname_; }
+
+            virtual XMLPortParamContainer& description(const std::string description) = 0;
+            virtual const std::string& getDescription() = 0;
+
+            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) = 0;
+
+        protected:
+            std::string paramname_;
+            ParseResult parseResult_;
+            Identifier* identifier_;
+            BaseObject* owner_;
+    };
+
+    template <class T>
+    class XMLPortClassParamContainer : public XMLPortParamContainer
+    {
+        struct ParseParams
+        {
+            T* object;
+            Element* xmlelement;
+            XMLPort::Mode mode;
+        };
+
+        public:
+            XMLPortClassParamContainer(const std::string paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
+            {
+                this->paramname_ = paramname;
+                this->identifier_ = identifier;
+                this->loadexecutor_ = loadexecutor;
+                this->saveexecutor_ = saveexecutor;
+            }
+
+            XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode)
+            {
+                this->owner_ = owner;
+                this->parseParams_.object = object;
+                this->parseParams_.xmlelement = &xmlelement;
+                this->parseParams_.mode = mode;
+
+                if (mode == XMLPort::LoadObject)
+                {
+                    try
+                    {
+                        std::string attribute = xmlelement.GetAttribute(this->paramname_);
+                        if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet()))
+                        {
+                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
+                            if (this->loadexecutor_->parse(object, attribute, ","))
+                                this->parseResult_ = PR_finished;
+                            else
+                                this->parseResult_ = PR_waiting_for_default_values;
+                        }
+                        else
+                            this->parseResult_ = PR_waiting_for_default_values;
+                    }
+                    catch (ticpp::Exception& ex)
+                    {
+                        COUT(1) << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ":" << std::endl;
+                        COUT(1) << ex.what() << std::endl;
+                    }
+                }
+                else
+                {
+                    if (this->saveexecutor_)
+                    {
+//                        xmlelement.SetAttribute(this->paramname_, "...");
+                    }
+                }
+
+                return (*this);
+            }
+
+            XMLPortParamContainer& port(BaseObject* owner, const ParseParams& parseParams)
+            {
+                return this->port(owner, parseParams.object, *parseParams.xmlelement, parseParams.mode);
+            }
+
+            XMLPortParamContainer& portIfWaitingForDefaultValues(const ParseResult& result, const ParseParams& params)
+            {
+                if (result == PR_waiting_for_default_values)
+                    return this->port(this->owner_, params);
+                else
+                    return (*this);
+            }
+
+            virtual XMLPortParamContainer& description(const std::string description)
+                { this->loadexecutor_->setDescription(description); return (*this); }
+            virtual const std::string& getDescription()
+                { return this->loadexecutor_->getDescription(); }
+
+            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param)
+            {
+                if (!this->loadexecutor_->defaultValueSet(index))
+                    this->loadexecutor_->setDefaultValue(index, param);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1)
+            {
+                if (!this->loadexecutor_->defaultValueSet(0))
+                    this->loadexecutor_->setDefaultValues(param1);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)))
+                    this->loadexecutor_->setDefaultValues(param1, param2);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)))
+                    this->loadexecutor_->setDefaultValues(param1, param2, param3);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)))
+                    this->loadexecutor_->setDefaultValues(param1, param2, param3, param4);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4)))
+                    this->loadexecutor_->setDefaultValues(param1, param2, param3, param4, param5);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+
+        private:
+            ExecutorMember<T>* loadexecutor_;
+            ExecutorMember<T>* saveexecutor_;
+            ParseParams parseParams_;
+    };
+
+
+    // ################################
+    // ###  XMLPortObjectContainer  ###
+    // ################################
+    class _CoreExport XMLPortObjectContainer
+    {
+        public:
+            XMLPortObjectContainer()
+                { this->bApplyLoaderMask_ = false; }
+            virtual ~XMLPortObjectContainer() {}
+
+            inline const std::string& getName() const
+                { return this->sectionname_; }
+
+            virtual XMLPortObjectContainer& description(const std::string description) = 0;
+            virtual const std::string& getDescription() = 0;
+
+            bool identifierIsIncludedInLoaderMask(const Identifier* identifier);
+
+        protected:
+            std::string sectionname_;
+            bool bApplyLoaderMask_;
+            bool bLoadBefore_;
+            Identifier* identifier_;
+    };
+
+    template <class T, class O>
+    class XMLPortClassObjectContainer : public XMLPortObjectContainer
+    {
+        public:
+            XMLPortClassObjectContainer(const std::string sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
+            {
+                this->sectionname_ = sectionname;
+                this->identifier_ = identifier;
+                this->loadexecutor_ = loadexecutor;
+                this->saveexecutor_ = saveexecutor;
+                this->bApplyLoaderMask_ = bApplyLoaderMask;
+                this->bLoadBefore_ = bLoadBefore;
+            }
+
+            XMLPortObjectContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode)
+            {
+                if (mode == XMLPort::LoadObject)
+                {
+                    try
+                    {
+                        Element* xmlsubelement;
+                        if ((this->sectionname_ != "") && (this->sectionname_.size() > 0))
+                            xmlsubelement = xmlelement.FirstChildElement(this->sectionname_, false);
+                        else
+                            xmlsubelement = &xmlelement;
+
+                        if (xmlsubelement)
+                        {
+                            for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
+                            {
+                                Identifier* identifier = ClassByString(child->Value());
+                                if (identifier)
+                                {
+                                    if (identifier->isA(Class(O)))
+                                    {
+                                        if (identifier->isLoadable())
+                                        {
+                                            if (this->identifierIsIncludedInLoaderMask(identifier))
+                                            {
+                                                COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
+
+                                                BaseObject* newObject = identifier->fabricate((BaseObject*)object);
+                                                assert(newObject);
+                                                newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + "  ");
+
+                                                O* castedObject = dynamic_cast<O*>(newObject);
+                                                assert(castedObject);
+
+                                                if (this->bLoadBefore_)
+                                                {
+                                                    newObject->XMLPort(*child, XMLPort::LoadObject);
+                                                    COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
+                                                }
+                                                else
+                                                {
+                                                    COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
+                                                }
+
+                                                COUT(5) << ((BaseObject*)object)->getLoaderIndentation();
+                                                (*this->loadexecutor_)(object, castedObject);
+
+                                                if (!this->bLoadBefore_)
+                                                    newObject->XMLPort(*child, XMLPort::LoadObject);
+
+                                                COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
+                                            }
+                                        }
+                                        else
+                                        {
+                                            COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
+                                        }
+                                    }
+                                    else
+                                    {
+                                        COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << Class(O)->getName() << "'." << std::endl;
+                                    }
+                                }
+                                else
+                                {
+                                    if (this->sectionname_ != "")
+                                    {
+                                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
+                                    }
+                                    else
+                                    {
+                                        // It's probably just another subsection
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    catch (ticpp::Exception& ex)
+                    {
+                        COUT(1) << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getFilename() << ":" << std::endl;
+                        COUT(1) << ex.what() << std::endl;
+                    }
+                }
+                else
+                {
+                }
+
+                return (*this);
+            }
+
+            virtual XMLPortObjectContainer& description(const std::string description)
+                { this->loadexecutor_->setDescription(description); return (*this); }
+            virtual const std::string& getDescription()
+                { return this->loadexecutor_->getDescription(); }
+
+        private:
+            ExecutorMember<T>* loadexecutor_;
+            ExecutorMember<T>* saveexecutor_;
+    };
+}
+
+#endif /* _XMLPort_H__ */
Index: /code/branches/physics/src/core/input/Button.cc
===================================================================
--- /code/branches/physics/src/core/input/Button.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/Button.cc	(revision 2122)
@@ -0,0 +1,254 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the different input handlers.
+*/
+
+#include "Button.h"
+
+#include "util/Convert.h"
+#include "util/SubString.h"
+#include "util/String.h"
+#include "util/Debug.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandEvaluation.h"
+#include "core/CommandExecutor.h"
+#include "core/ConfigValueContainer.h"
+
+namespace orxonox
+{
+    /**
+    @note
+        bButtonThresholdUser_: We set it to true so that setConfigValues in KeyBinder sets the value
+        correctly the first time. It is then set to false first and changed later in Button::parse().
+    */
+    Button::Button()
+        : configContainer_(0)
+        , bButtonThresholdUser_(false)
+        , paramCommandBuffer_(0)
+    {
+        nCommands_[0]=0;
+        nCommands_[1]=0;
+        nCommands_[2]=0;
+        clear();
+    }
+
+    void Button::clear()
+    {
+        for (unsigned int j = 0; j < 3; j++)
+        {
+            if (nCommands_[j])
+            {
+                // delete all commands and the command pointer array
+                for (unsigned int i = 0; i < nCommands_[j]; i++)
+                    delete commands_[j][i];
+                delete[] commands_[j];
+                commands_[j] = 0;
+                nCommands_[j] = 0;
+            }
+            else
+            {
+                commands_[j] = 0;
+            }
+        }
+    }
+
+    void Button::readConfigValue(ConfigFileType configFile)
+    {
+        // create/get ConfigValueContainer
+        if (!configContainer_)
+        {
+            configContainer_ = new ConfigValueContainer(configFile, 0, groupName_, name_, "", name_);
+            configContainer_->callback(this, &Button::parse);
+        }
+        configContainer_->getValue(&bindingString_, this);
+    }
+
+    void Button::parse()
+    {
+        // delete all commands
+        clear();
+
+        if (isEmpty(bindingString_))
+            return;
+
+        // reset this to false first when parsing (was true before when parsing for the first time)
+        bButtonThresholdUser_ = false;
+
+        // use std::vector for a temporary dynamic array
+        std::vector<BaseCommand*> commands[3];
+
+        // separate the commands
+        SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
+            '\\', false, '"', false, '(', ')', false, '\0');
+
+        for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
+        {
+            if (commandStrings[iCommand] != "")
+            {
+                SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
+                    '\\', false, '"', false, '(', ')', false, '\0');
+
+                KeybindMode::Enum mode = KeybindMode::None;
+                float paramModifier = 1.0f;
+                std::string commandStr = "";
+
+                for (unsigned int iToken = 0; iToken < tokens.size(); ++iToken)
+                {
+                    std::string token = getLowercase(tokens[iToken]);
+
+                    if (token == "onpress")
+                        mode = KeybindMode::OnPress;
+                    else if (token == "onrelease")
+                        mode = KeybindMode::OnRelease;
+                    else if (token == "onhold")
+                        mode = KeybindMode::OnHold;
+                    else if (token == "buttonthreshold")
+                    {
+                        // for real axes, we can feed a ButtonThreshold argument
+                        ++iToken;
+                        if (iToken == tokens.size())
+                            continue;
+                        // may fail, but doesn't matter (default value already set)
+                        if (!convertValue(&buttonThreshold_, tokens[iToken + 1]))
+                            parseError("Could not parse 'ButtonThreshold' argument. \
+                                Switching to default value.", true);
+                        else
+                            this->bButtonThresholdUser_ = true;
+                    }
+                    else if (token == "scale")
+                    {
+                        ++iToken;
+                        if (iToken == tokens.size() || !convertValue(&paramModifier, tokens[iToken]))
+                            parseError("Could not parse 'scale' argument. Switching to default value.", true);
+                    }
+                    else
+                    {
+                        // no input related argument
+                        // we interpret everything from here as a command string
+                        while (iToken != tokens.size())
+                            commandStr += tokens[iToken++] + " ";
+                    }
+                }
+
+                if (commandStr == "")
+                {
+                    parseError("No command string given.", false);
+                    continue;
+                }
+
+                // evaluate the command
+                CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
+                if (!eval.isValid())
+                {
+                    parseError("Command evaluation failed.", true);
+                    continue;
+                }
+
+                // check for param command
+                int paramIndex = eval.getConsoleCommand()->getInputConfiguredParam_();
+                if (paramIndex >= 0)
+                {
+                    // parameter supported command
+                    ParamCommand* cmd = new ParamCommand();
+                    cmd->scale_ = paramModifier;
+
+                    // add command to the buffer if not yet existing
+                    for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer_->size(); iParamCmd++)
+                    {
+                        if ((*paramCommandBuffer_)[iParamCmd]->evaluation_.getConsoleCommand()
+                            == eval.getConsoleCommand())
+                        {
+                            // already in list
+                            cmd->paramCommand_ = (*paramCommandBuffer_)[iParamCmd];
+                            break;
+                        }
+                    }
+                    if (cmd->paramCommand_ == 0)
+                    {
+                        cmd->paramCommand_ = new BufferedParamCommand();
+                        paramCommandBuffer_->push_back(cmd->paramCommand_);
+                        cmd->paramCommand_->evaluation_ = eval;
+                        cmd->paramCommand_->paramIndex_ = paramIndex;
+                    }
+
+
+                    // we don't know whether this is an actual axis or just a button
+                    if (mode == KeybindMode::None)
+                    {
+                        if (!addParamCommand(cmd))
+                        {
+                            mode = eval.getConsoleCommand()->getKeybindMode();
+                            commands[mode].push_back(cmd);
+                        }
+                    }
+                }
+                else
+                {
+                    SimpleCommand* cmd = new SimpleCommand();
+                    cmd->evaluation_ = eval;
+
+                    if (mode == KeybindMode::None)
+                        mode = eval.getConsoleCommand()->getKeybindMode();
+
+                    commands[mode].push_back(cmd);
+                }
+            }
+        }
+
+        for (unsigned int j = 0; j < 3; j++)
+        {
+            nCommands_[j] = commands[j].size();
+            if (nCommands_[j])
+            {
+                commands_[j] = new BaseCommand*[nCommands_[j]];
+                for (unsigned int i = 0; i < commands[j].size(); i++)
+                    commands_[j][i] = commands[j][i];
+            }
+            else
+                commands_[j] = 0;
+        }
+    }
+
+    inline void Button::parseError(std::string message, bool serious)
+    {
+        if (serious)
+        {
+            COUT(2) << "Error while parsing binding for button/axis " << this->name_ << ". "
+                << message << std::endl;
+        }
+        else
+        {
+            COUT(3) << "Warning while parsing binding for button/axis " << this->name_ << ". "
+                << message << std::endl;
+        }
+    }
+}
Index: /code/branches/physics/src/core/input/Button.h
===================================================================
--- /code/branches/physics/src/core/input/Button.h	(revision 2122)
+++ /code/branches/physics/src/core/input/Button.h	(revision 2122)
@@ -0,0 +1,91 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Different definitions of input processing.
+*/
+
+#ifndef _Button_H__
+#define _Button_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <vector>
+#include "InputCommands.h"
+#include "core/ConfigFileManager.h"
+
+namespace orxonox
+{
+    class _CoreExport Button
+    {
+    public:
+        Button();
+        virtual ~Button() { clear(); }
+        virtual void clear();
+        virtual bool addParamCommand(ParamCommand* command) { return false; }
+        void parse();
+        void readConfigValue(ConfigFileType configFile);
+        bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
+
+        //! Container to allow for better configValue support
+        ConfigValueContainer* configContainer_;
+        //! The configured string value
+        std::string bindingString_;
+        //! Name of the trigger as strings
+        std::string name_;
+        //! Name of the group of input triggers
+        std::string groupName_;
+        //! Basic commands for OnPress, OnHold and OnRelease
+        BaseCommand** commands_[3];
+        //! Number of basic commands
+        unsigned int nCommands_[3];
+        //! Says how much it takes for an analog axis to trigger a button
+        //! Note: This variable is here to have only one parse() function.
+        float buttonThreshold_;
+        bool bButtonThresholdUser_;
+        //! Pointer to the list of parametrised commands
+        std::vector<BufferedParamCommand*>* paramCommandBuffer_;
+
+    private:
+        void parseError(std::string message, bool serious);
+    };
+
+    inline bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
+    {
+        // execute all the parsed commands in the string
+        for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)
+            commands_[mode][iCommand]->execute(abs, rel);
+        return true;
+    }
+
+}
+
+#endif /* _Button_H__ */
Index: /code/branches/physics/src/core/input/CalibratorCallback.cc
===================================================================
--- /code/branches/physics/src/core/input/CalibratorCallback.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/CalibratorCallback.cc	(revision 2122)
@@ -0,0 +1,47 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the different input handlers.
+*/
+
+#include "CalibratorCallback.h"
+#include "InputManager.h"
+
+namespace orxonox
+{
+    void CalibratorCallback::keyPressed(const orxonox::KeyEvent &evt)
+    {
+        if (evt.key == KeyCode::Return)
+        {
+            //InputManager::setInputState(InputManager::IS_NOCALIBRATE);
+        }
+    }
+}
Index: /code/branches/physics/src/core/input/CalibratorCallback.h
===================================================================
--- /code/branches/physics/src/core/input/CalibratorCallback.h	(revision 2122)
+++ /code/branches/physics/src/core/input/CalibratorCallback.h	(revision 2122)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Different definitions of input processing.
+*/
+
+#ifndef _CalibratorCallback_H__
+#define _CalibratorCallback_H__
+
+#include "core/CorePrereqs.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    class _CoreExport CalibratorCallback : public KeyHandler
+    {
+    public:
+        CalibratorCallback()  { }
+        ~CalibratorCallback() { }
+
+    private:
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt) { }
+        void keyHeld    (const KeyEvent& evt) { }
+
+        void tickInput(float dt) { }
+    };
+}
+
+#endif /* _CalibratorCallback_H__ */
Index: /code/branches/physics/src/core/input/ExtendedInputState.cc
===================================================================
--- /code/branches/physics/src/core/input/ExtendedInputState.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/ExtendedInputState.cc	(revision 2122)
@@ -0,0 +1,459 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the ExtendedInputState class.
+*/
+
+#include "ExtendedInputState.h"
+
+#include <assert.h>
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    using namespace InputDevice;
+
+    void ExtendedInputState::numberOfJoySticksChanged(unsigned int n)
+    {
+        unsigned int oldSize = joyStickHandlers_.size();
+        joyStickHandlers_.resize(n);
+
+        if (oldSize > n)
+        {
+            // we have to add all the handlers in joyStickHandlersAll_ to the joyStickHandlers_[>n]
+            for (unsigned int j = 0; j < joyStickHandlersAll_.size(); ++j)
+            {
+                for (unsigned int i = oldSize; i < n; ++i)
+                {
+                    joyStickHandlers_[i].push_back(joyStickHandlersAll_[j]);
+                }
+            }
+        }
+        update();
+    }
+
+    void ExtendedInputState::keyPressed(const KeyEvent& evt)
+    {
+        for (unsigned int i = 0; i < keyHandlers_.size(); i++)
+            keyHandlers_[i]->keyPressed(evt);
+    }
+
+    void ExtendedInputState::keyReleased(const KeyEvent& evt)
+    {
+        for (unsigned int i = 0; i < keyHandlers_.size(); i++)
+            keyHandlers_[i]->keyReleased(evt);
+    }
+
+    void ExtendedInputState::keyHeld(const KeyEvent& evt)
+    {
+        for (unsigned int i = 0; i < keyHandlers_.size(); i++)
+            keyHandlers_[i]->keyHeld(evt);
+    }
+
+
+    void ExtendedInputState::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseMoved(abs, rel, clippingSize);
+    }
+
+    void ExtendedInputState::mouseScrolled(int abs, int rel)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseScrolled(abs, rel);
+    }
+
+    void ExtendedInputState::mouseButtonPressed(MouseButtonCode::ByEnum id)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseButtonPressed(id);
+    }
+
+    void ExtendedInputState::mouseButtonReleased(MouseButtonCode::ByEnum id)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseButtonReleased(id);
+    }
+
+    void ExtendedInputState::mouseButtonHeld(MouseButtonCode::ByEnum id)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseButtonHeld(id);
+    }
+
+
+    void ExtendedInputState::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickAxisMoved(joyStickID, axis, value);
+    }
+
+    void ExtendedInputState::joyStickButtonPressed(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickButtonPressed(joyStickID, id);
+    }
+
+    void ExtendedInputState::joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickButtonReleased(joyStickID, id);
+    }
+
+    void ExtendedInputState::joyStickButtonHeld(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickButtonHeld(joyStickID, id);
+    }
+
+
+    /**
+    @brief
+        Adds a key handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addKeyHandler(KeyHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        // see whether the handler already is in the list
+        for (std::vector<KeyHandler*>::iterator it = keyHandlers_.begin(); it != keyHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        keyHandlers_.push_back(handler);
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a Key handler from the state.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeKeyHandler(KeyHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        for (std::vector<KeyHandler*>::iterator it = keyHandlers_.begin(); it != keyHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                keyHandlers_.erase(it);
+                update();
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+    @brief
+        Adds a mouse handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addMouseHandler(MouseHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        // see whether the handler already is in the list
+        for (std::vector<MouseHandler*>::iterator it = mouseHandlers_.begin(); it != mouseHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        mouseHandlers_.push_back(handler);
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a mouse handler from the state.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeMouseHandler(MouseHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        for (std::vector<MouseHandler*>::iterator it = mouseHandlers_.begin(); it != mouseHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                mouseHandlers_.erase(it);
+                update();
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @param joyStickID
+        ID of the joy stick
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID)
+    {
+        if (!handler || joyStickID >= joyStickHandlers_.size())
+            return false;
+
+        // see whether the handler already is in the list
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlers_[joyStickID].begin();
+            it != joyStickHandlers_[joyStickID].end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        joyStickHandlers_[joyStickID].push_back(handler);
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a joy stick handler from the state.
+    @param handler
+        Pointer to the handler.
+    @param joyStickID
+        ID of the joy stick
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID)
+    {
+        if (!handler || joyStickID >= joyStickHandlers_.size())
+            return false;
+
+        // remove it from the list of all-joystick handlers if present
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlersAll_.begin();
+            it != joyStickHandlersAll_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                joyStickHandlersAll_.erase(it);
+            }
+        }
+
+        // remove handler from the list of seperate lists of handlers
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlers_[joyStickID].begin();
+            it != joyStickHandlers_[joyStickID].end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                joyStickHandlers_[joyStickID].erase(it);
+                update();
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addJoyStickHandler(JoyStickHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        // see whether the handler already is in the big list
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlersAll_.begin();
+            it != joyStickHandlersAll_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        joyStickHandlersAll_.push_back(handler);
+        update();
+
+        // now, we have to add it to all the separate lists
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); ++iJoyStick)
+            addJoyStickHandler(handler, iJoyStick);
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a joy stick handler from the state.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeJoyStickHandler(JoyStickHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        bool success = false;
+        // remove from all lists in a loop (also removes it from the big list)
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); ++iJoyStick)
+            success |= removeJoyStickHandler(handler, iJoyStick);
+
+        return success;
+    }
+
+    /**
+    @brief
+        Adds a handler of any kind. dynamic_cast determines to which list it is added.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addHandler(InputHandler* handler)
+    {
+        bool success = false;
+
+        success |= addKeyHandler(dynamic_cast<KeyHandler*>(handler));
+        success |= addMouseHandler(dynamic_cast<MouseHandler*>(handler));
+        success |= addJoyStickHandler(dynamic_cast<JoyStickHandler*>(handler));
+
+        return success;
+    }
+
+    /**
+    @brief
+        Removes a handler from all lists.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeHandler(InputHandler* handler)
+    {
+        bool success = false;
+
+        success |= removeKeyHandler(dynamic_cast<KeyHandler*>(handler));
+        success |= removeMouseHandler(dynamic_cast<MouseHandler*>(handler));
+        success |= removeJoyStickHandler(dynamic_cast<JoyStickHandler*>(handler));
+
+        return success;
+    }
+
+    void ExtendedInputState::tickInput(float dt)
+    {
+        for (unsigned int i = 0; i < allHandlers_.size(); ++i)
+        {
+            allHandlers_[i]->tickInput(dt);
+        }
+    }
+
+    void ExtendedInputState::tickInput(float dt, unsigned int device)
+    {
+        switch (device)
+        {
+        case Keyboard:
+            for (unsigned int i = 0; i < keyHandlers_.size(); ++i)
+                keyHandlers_[i]->tickKey(dt);
+            break;
+
+        case Mouse:
+            for (unsigned int i = 0; i < mouseHandlers_.size(); ++i)
+                mouseHandlers_[i]->tickMouse(dt);
+            break;
+
+        default: // joy sticks
+            for (unsigned int i = 0; i < joyStickHandlers_[device - 2].size(); ++i)
+                joyStickHandlers_[device - 2][i]->tickJoyStick(dt, device - 2);
+            break;
+        }
+    }
+
+    void ExtendedInputState::update()
+    {
+        // we can use a set to have a list of unique pointers (an object can implement all 3 handlers)
+        std::set<InputHandler*> tempSet;
+        for (unsigned int iHandler = 0; iHandler < keyHandlers_.size(); iHandler++)
+            tempSet.insert(keyHandlers_[iHandler]);
+        for (unsigned int iHandler = 0; iHandler < mouseHandlers_.size(); iHandler++)
+            tempSet.insert(mouseHandlers_[iHandler]);
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); iJoyStick++)
+            for (unsigned int iHandler = 0; iHandler < joyStickHandlers_[iJoyStick].size(); iHandler++)
+                tempSet.insert(joyStickHandlers_[iJoyStick][iHandler]);
+
+        // copy the content of the map back to the actual vector
+        allHandlers_.clear();
+        for (std::set<InputHandler*>::const_iterator itHandler = tempSet.begin();
+            itHandler != tempSet.end(); itHandler++)
+            allHandlers_.push_back(*itHandler);
+
+        // update the deviceEnabled options
+        setInputDeviceEnabled(Keyboard, (keyHandlers_.size() != 0));
+        setInputDeviceEnabled(Mouse, (mouseHandlers_.size() != 0));
+        for (unsigned int i = 0; i < joyStickHandlers_.size(); ++i)
+            setInputDeviceEnabled(2 + i, (joyStickHandlers_[i].size() != 0));
+
+        this->bHandlersChanged_ = true;
+    }
+}
Index: /code/branches/physics/src/core/input/ExtendedInputState.h
===================================================================
--- /code/branches/physics/src/core/input/ExtendedInputState.h	(revision 2122)
+++ /code/branches/physics/src/core/input/ExtendedInputState.h	(revision 2122)
@@ -0,0 +1,100 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief 
+*/
+
+#ifndef _ExtendedInputState_H__
+#define _ExtendedInputState_H__
+
+#include "core/CorePrereqs.h"
+
+#include <vector>
+
+#include "InputInterfaces.h"
+#include "InputState.h"
+
+namespace orxonox
+{
+
+    class _CoreExport ExtendedInputState : public InputState
+    {
+        friend class InputManager;
+
+    public:
+        bool addKeyHandler        (KeyHandler* handler);
+        bool removeKeyHandler     (KeyHandler* handler);
+
+        bool addMouseHandler      (MouseHandler* handler);
+        bool removeMouseHandler   (MouseHandler* handler);
+
+        bool addJoyStickHandler   (JoyStickHandler* handler, unsigned int joyStickID);
+        bool removeJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID);
+        bool addJoyStickHandler   (JoyStickHandler* handler);
+        bool removeJoyStickHandler(JoyStickHandler* handler);
+
+        bool addHandler(InputHandler* handler);
+        bool removeHandler(InputHandler* handler);
+
+    private:
+        ExtendedInputState() { }
+        ~ExtendedInputState() { }
+
+        void tickInput(float dt);
+        void tickInput(float dt, unsigned int device);
+
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt);
+        void keyHeld    (const KeyEvent& evt);
+
+        void mouseButtonPressed (MouseButtonCode::ByEnum id);
+        void mouseButtonReleased(MouseButtonCode::ByEnum id);
+        void mouseButtonHeld    (MouseButtonCode::ByEnum id);
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
+        void mouseScrolled      (int abs, int rel);
+
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);        void updateTickables();
+
+        void numberOfJoySticksChanged(unsigned int n);
+        void update();
+
+        std::vector<KeyHandler*>                    keyHandlers_;
+        std::vector<MouseHandler*>                  mouseHandlers_;
+        std::vector<std::vector<JoyStickHandler*> > joyStickHandlers_;
+        std::vector<JoyStickHandler*>               joyStickHandlersAll_;
+
+        std::vector<InputHandler*> allHandlers_;
+    };
+}
+
+#endif /* _ExtendedInputState_H__ */
Index: /code/branches/physics/src/core/input/HalfAxis.cc
===================================================================
--- /code/branches/physics/src/core/input/HalfAxis.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/HalfAxis.cc	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the different input handlers.
+*/
+
+#include "HalfAxis.h"
+#include "core/CommandEvaluation.h"
+
+namespace orxonox
+{
+    void HalfAxis::clear()
+    {
+        Button::clear();
+        if (nParamCommands_)
+        {
+            // delete all commands and the command pointer array
+            for (unsigned int i = 0; i < nParamCommands_; i++)
+                delete paramCommands_[i];
+            delete[] paramCommands_;
+            nParamCommands_ = 0;
+        }
+        else
+        {
+            nParamCommands_ = 0; nParamCommands_ = 0;
+        }
+    }
+
+    bool HalfAxis::addParamCommand(ParamCommand* command)
+    {
+        ParamCommand** cmds = paramCommands_;
+        paramCommands_ = new ParamCommand*[++nParamCommands_];
+        unsigned int i;
+        for (i = 0; i < nParamCommands_ - 1; i++)
+            paramCommands_[i] = cmds[i];
+        paramCommands_[i] = command;
+        if (nParamCommands_ > 1)
+            delete[] cmds;
+        return true;
+    }
+}
Index: /code/branches/physics/src/core/input/HalfAxis.h
===================================================================
--- /code/branches/physics/src/core/input/HalfAxis.h	(revision 2122)
+++ /code/branches/physics/src/core/input/HalfAxis.h	(revision 2122)
@@ -0,0 +1,80 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Different definitions of input processing.
+*/
+
+#ifndef _HalfAxis_H__
+#define _HalfAxis_H__
+
+#include "core/CorePrereqs.h"
+#include "Button.h"
+#include "InputCommands.h"
+
+namespace orxonox
+{
+    class _CoreExport HalfAxis : public Button
+    {
+    public:
+        HalfAxis()
+            : relVal_(0.0f)
+            , absVal_(0.0f)
+            , paramCommands_(0)
+            , nParamCommands_(0)
+            , pressed_(false)
+            , hasChanged_(false)
+        { }
+        using Button::execute;
+        bool execute();
+        bool addParamCommand(ParamCommand* command);
+        void clear();
+
+        // axis related
+        float relVal_;
+        float absVal_;
+        ParamCommand** paramCommands_;
+        unsigned int nParamCommands_;
+
+        // button related
+        bool pressed_;
+        bool hasChanged_;
+    };
+
+    inline bool HalfAxis::execute()
+    {
+        bool success = true;
+        for (unsigned int i = 0; i < nParamCommands_; i++)
+            success = paramCommands_[i]->execute(absVal_, relVal_) && success;
+        return success;
+    }
+}
+
+#endif /* _HalfAxis_H__ */
Index: /code/branches/physics/src/core/input/InputBuffer.cc
===================================================================
--- /code/branches/physics/src/core/input/InputBuffer.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/InputBuffer.cc	(revision 2122)
@@ -0,0 +1,257 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#include "InputBuffer.h"
+
+#include <iostream>
+
+#include "util/Clipboard.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    InputBuffer::InputBuffer()
+    {
+        RegisterRootObject(InputBuffer);
+
+        this->buffer_ = "";
+        this->cursor_ = 0;
+        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
+                               ABCDEFGHIJKLMNOPQRSTUVWXYZ \
+                               äëïöüÄËÏÖÜáâàéêèíîìóôòúûù \
+                               0123456789 \
+                               \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#";
+
+        this->lastKey_ = KeyCode::Unassigned;
+        this->timeSinceKeyPressed_ = 0.0f;
+        this->timeSinceKeyRepeated_ = 0.0f;
+        this->keysToRepeat_ = 0;
+
+        setConfigValues();
+    }
+
+    InputBuffer::InputBuffer(const std::string allowedChars)
+    {
+        RegisterRootObject(InputBuffer);
+
+        this->allowedChars_ = allowedChars;
+        this->buffer_ = "";
+        this->cursor_ = 0;
+
+        this->lastKey_ = KeyCode::Unassigned;
+        this->timeSinceKeyPressed_ = 0.0f;
+        this->timeSinceKeyRepeated_ = 0.0f;
+        this->keysToRepeat_ = 0;
+
+        setConfigValues();
+    }
+
+    void InputBuffer::setConfigValues()
+    {
+        SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat deleay of the input buffer");
+        SetConfigValue(keyRepeatTime_, 0.022).description("Key repeat time of the input buffer");
+
+        if (keyRepeatDeleay_ < 0.0)
+        {
+            ResetConfigValue(keyRepeatDeleay_);
+        }
+        if (keyRepeatTime_ < 0.0)
+        {
+            ResetConfigValue(keyRepeatTime_);
+        }
+    }
+
+    void InputBuffer::set(const std::string& input, bool update)
+    {
+        this->clear(false);
+        this->insert(input, update);
+    }
+
+    void InputBuffer::insert(const std::string& input, bool update)
+    {
+        for (unsigned int i = 0; i < input.size(); ++i)
+        {
+            this->insert(input[i], false);
+
+            if (update)
+                this->updated(input[i], false);
+        }
+
+        if (update)
+            this->updated();
+    }
+
+    void InputBuffer::insert(const char& input, bool update)
+    {
+        if (this->charIsAllowed(input))
+        {
+            this->buffer_.insert(this->cursor_, 1, input);
+            ++this->cursor_;
+        }
+
+        if (update)
+            this->updated(input, true);
+    }
+
+    void InputBuffer::clear(bool update)
+    {
+        this->buffer_ = "";
+        this->cursor_ = 0;
+
+        if (update)
+            this->updated();
+    }
+
+    void InputBuffer::removeBehindCursor(bool update)
+    {
+        if (this->cursor_ > 0)
+        {
+            --this->cursor_;
+            this->buffer_.erase(this->cursor_, 1);
+
+            if (update)
+                this->updated();
+        }
+    }
+
+    void InputBuffer::removeAtCursor(bool update)
+    {
+        if (this->cursor_ < this->buffer_.size())
+        {
+            this->buffer_.erase(this->cursor_, 1);
+
+            if (update)
+                this->updated();
+        }
+    }
+
+    void InputBuffer::updated()
+    {
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->bListenToAllChanges_)
+                (*it)->callFunction();
+        }
+    }
+
+    void InputBuffer::updated(const char& update, bool bSingleInput)
+    {
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((!(*it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput))
+                (*it)->callFunction();
+        }
+    }
+
+    bool InputBuffer::charIsAllowed(const char& input)
+    {
+        if (this->allowedChars_ == "")
+            return true;
+        else
+            return (this->allowedChars_.find(input) != std::string::npos);
+    }
+
+
+    void InputBuffer::processKey(const KeyEvent &evt)
+    {
+        if (evt.isModifierDown(KeyboardModifier::Alt) && evt.key == KeyCode::Tab)
+            return;
+
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.key))
+                (*it)->callFunction();
+        }
+
+        if (evt.isModifierDown(KeyboardModifier::Ctrl))
+        {
+            if (evt.key == KeyCode::V)
+                this->insert(fromClipboard());
+            else if (evt.key == KeyCode::C)
+                toClipboard(this->buffer_);
+            else if (evt.key == KeyCode::X)
+            {
+                toClipboard(this->buffer_);
+                this->clear();
+            }
+        }
+        else if (evt.isModifierDown(KeyboardModifier::Shift))
+        {
+            if (evt.key == KeyCode::Insert)
+                this->insert(fromClipboard());
+            else if (evt.key == KeyCode::Delete)
+            {
+                toClipboard(this->buffer_);
+                this->clear();
+            }
+        }
+
+        this->insert((char)evt.text);
+    }
+
+    /**
+        @brief This tick() function is called by the InputManager if the InputBuffer is active.
+        @param dt Delta time
+    */
+    void InputBuffer::tickInput(float dt)
+    {
+        timeSinceKeyPressed_ += dt;
+        if (keysToRepeat_ < 10 && timeSinceKeyPressed_ > keyRepeatDeleay_)
+        {
+            // initial time out has gone by, start repeating keys
+            while (timeSinceKeyPressed_ - timeSinceKeyRepeated_ > keyRepeatTime_)
+            {
+                timeSinceKeyRepeated_ += keyRepeatTime_;
+                keysToRepeat_++;
+            }
+        }
+    }
+
+    void InputBuffer::keyPressed(const KeyEvent &evt)
+    {
+        lastKey_ = evt.key;
+        timeSinceKeyPressed_ = 0.0;
+        timeSinceKeyRepeated_ = keyRepeatDeleay_;
+        keysToRepeat_ = 0;
+
+        processKey(evt);
+    }
+
+    void InputBuffer::keyHeld(const KeyEvent& evt)
+    {
+        if (evt.key == lastKey_)
+        {
+            while (keysToRepeat_)
+            {
+                processKey(evt);
+                keysToRepeat_--;
+            }
+        }
+    }
+}
Index: /code/branches/physics/src/core/input/InputBuffer.h
===================================================================
--- /code/branches/physics/src/core/input/InputBuffer.h	(revision 2122)
+++ /code/branches/physics/src/core/input/InputBuffer.h	(revision 2122)
@@ -0,0 +1,190 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _InputBuffer_H__
+#define _InputBuffer_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+#include "core/OrxonoxClass.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    class BaseInputBufferListenerTuple
+    {
+    public:
+        BaseInputBufferListenerTuple(bool bListenToAllChanges, bool bOnlySingleInput,
+            bool trueKeyFalseChar, char _char, KeyCode::ByEnum key)
+            : bListenToAllChanges_(bListenToAllChanges), bOnlySingleInput_(bOnlySingleInput),
+              trueKeyFalseChar_(trueKeyFalseChar), char_(_char), key_(key)
+        { }
+        virtual ~BaseInputBufferListenerTuple() { }
+        virtual void callFunction() = 0;
+        bool bListenToAllChanges_;
+        bool bOnlySingleInput_;
+        bool trueKeyFalseChar_;
+        char char_;
+        KeyCode::ByEnum key_;
+    };
+
+    template <class T>
+    class InputBufferListenerTuple : public BaseInputBufferListenerTuple
+    {
+    public:
+        InputBufferListenerTuple(T* listener, void (T::*function)(), bool bListenToAllChanges,
+            bool bOnlySingleInput, bool trueKeyFalseChar, char _char, KeyCode::ByEnum key)
+            : BaseInputBufferListenerTuple(bListenToAllChanges, bOnlySingleInput, trueKeyFalseChar, _char, key),
+              listener_(listener), function_(function)
+        { }
+        virtual ~InputBufferListenerTuple() { }
+        void callFunction()
+        {
+            (listener_->*function_)();
+        }
+        T* listener_;
+        void (T::*function_)();
+    };
+
+    class _CoreExport InputBuffer : public KeyHandler, public OrxonoxClass
+    {
+        public:
+            InputBuffer();
+            InputBuffer(const std::string allowedChars);
+
+            void setConfigValues();
+
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), char _char, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, char _char, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), KeyCode::ByEnum key)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, KeyCode::ByEnum key)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+
+            template <class T>
+            void unregisterListener(T* listener)
+            {
+                for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+                {
+                    InputBufferListenerTuple<T>* refListener = dynamic_cast<InputBufferListenerTuple<T>*>(*it);
+                    if (refListener && refListener->listener_ == listener)
+                        this->listeners_.erase(it++);
+                    else
+                        it++;
+                }
+            }
+
+            void set(const std::string& input, bool update = true);
+            void insert(const std::string& input, bool update = true);
+            void insert(const char& input, bool update = true);
+            void clear(bool update = true);
+            void removeAtCursor(bool update = true);
+            void removeBehindCursor(bool update = true);
+
+            void updated();
+            void updated(const char& update, bool bSingleInput);
+
+            inline std::string get() const
+                { return this->buffer_; }
+            inline unsigned int getSize() const
+                { return this->buffer_.size(); }
+
+            inline unsigned int getCursorPosition() const
+                { return this->cursor_; }
+            inline void setCursorPosition(unsigned int cursor)
+                { if (cursor <= this->buffer_.size()) { this->cursor_ = cursor; } }
+            inline void setCursorToEnd()
+                { this->cursor_ = this->buffer_.size(); }
+            inline void setCursorToBegin()
+                { this->cursor_ = 0; }
+            inline void increaseCursor()
+                { if (this->cursor_ < this->buffer_.size()) { ++this->cursor_; } }
+            inline void decreaseCursor()
+                { if (this->cursor_ > 0) { --this->cursor_; } }
+
+        private:
+            bool charIsAllowed(const char& input);
+
+            void keyPressed (const KeyEvent& evt);
+            void keyReleased(const KeyEvent& evt) { }
+            void keyHeld    (const KeyEvent& evt);
+            void processKey (const KeyEvent &e);
+
+            void tickInput(float dt);
+            void tickKey(float dt) { }
+
+            std::string buffer_;
+            std::list<BaseInputBufferListenerTuple*> listeners_;
+            std::string allowedChars_;
+            unsigned int cursor_;
+
+            KeyCode::ByEnum lastKey_;
+            float timeSinceKeyPressed_;
+            float timeSinceKeyRepeated_;
+            int keysToRepeat_;
+
+            float keyRepeatDeleay_;
+            float keyRepeatTime_;
+    };
+}
+
+#endif /* _InputBuffer_H__ */
Index: /code/branches/physics/src/core/input/InputCommands.cc
===================================================================
--- /code/branches/physics/src/core/input/InputCommands.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/InputCommands.cc	(revision 2122)
@@ -0,0 +1,98 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the different input handlers.
+*/
+
+#include "InputCommands.h"
+#include "util/Math.h"
+#include "core/CommandExecutor.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  BufferedParamCommand   ###
+    // ###############################
+
+    /**
+    @brief
+        Executes a buffered command. This is used for commands with additional
+        parameters.
+    @return
+        True if command execution was successful or value was zero.
+    */
+    bool BufferedParamCommand::execute()
+    {
+        if (this->abs_ != 0.0f || this->rel_ != 0.0f)
+        {
+            evaluation_.setEvaluatedParameter(paramIndex_, Vector2(abs_, rel_));
+            // reset
+            rel_ = 0.0;
+            abs_ = 0.0;
+            return evaluation_.execute();
+        }
+        else
+            return true;
+    }
+
+    // ###############################
+    // #####    ParamCommand     #####
+    // ###############################
+
+    /**
+    @brief
+        Executes a parameter command. The commmand string is not directly executed,
+        but instead stored in a buffer list so that values can be combined.
+    @return
+        Always true.
+    */
+    bool ParamCommand::execute(float abs, float rel)
+    {
+        BufferedParamCommand& cmd = *paramCommand_;
+        // command has an additional parameter
+        if (rel != 0.0f)
+        {
+            // calculate relative movement.
+            // scale_ says how much one keystroke is
+            cmd.rel_ += scale_ * rel;
+        }
+
+        if (abs != 0.0f)
+        {
+            cmd.abs_ += scale_ * abs;
+            if (cmd.abs_ > 1.0)
+                cmd.abs_ = 1.0;
+            if (cmd.abs_ < -1.0)
+                cmd.abs_ = -1.0;
+        }
+        return true;
+    }
+}
Index: /code/branches/physics/src/core/input/InputCommands.h
===================================================================
--- /code/branches/physics/src/core/input/InputCommands.h	(revision 2122)
+++ /code/branches/physics/src/core/input/InputCommands.h	(revision 2122)
@@ -0,0 +1,92 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Different definitions of input processing.
+*/
+
+#ifndef _InputCommands_H__
+#define _InputCommands_H__
+
+#include "core/CorePrereqs.h"
+#include "core/CommandEvaluation.h"
+
+namespace orxonox
+{
+    class _CoreExport BufferedParamCommand
+    {
+    public:
+        BufferedParamCommand() : abs_(0.0f), rel_(0.0), paramIndex_(-1) { }
+        bool execute();
+
+        float abs_;
+        float rel_;
+        int paramIndex_;
+        CommandEvaluation evaluation_;
+    };
+
+    class _CoreExport BaseCommand
+    {
+    public:
+        virtual ~BaseCommand() { }
+        virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0;
+    };
+
+    class _CoreExport SimpleCommand : public BaseCommand
+    {
+    public:
+        bool execute(float abs = 1.0f, float rel = 1.0f);
+
+        CommandEvaluation evaluation_;
+    };
+
+    /**
+    @brief
+        Executes a simple command with no additional paramters.
+    @return 
+        True if command execution was successful, false otherwise.
+    */
+    inline bool SimpleCommand::execute(float abs, float rel)
+    {
+        return evaluation_.execute();
+    }
+
+    class _CoreExport ParamCommand : public BaseCommand
+    {
+    public:
+        ParamCommand() : scale_(1.0f), paramCommand_(0) { }
+        bool execute(float abs = 1.0f, float rel = 1.0f);
+
+        float scale_;
+        BufferedParamCommand* paramCommand_;
+    };
+}
+
+#endif /* _InputCommands_H__ */
Index: /code/branches/physics/src/core/input/InputInterfaces.h
===================================================================
--- /code/branches/physics/src/core/input/InputInterfaces.h	(revision 2122)
+++ /code/branches/physics/src/core/input/InputInterfaces.h	(revision 2122)
@@ -0,0 +1,556 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Declarations of various interface classes for the input management.
+*/
+
+#ifndef _InputInterfaces_H__
+#define _InputInterfaces_H__
+
+#include "core/CorePrereqs.h"
+
+#include "ois/OISKeyboard.h"
+#include "ois/OISMouse.h"
+#include "ois/OISJoyStick.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    namespace KeyCode
+    {
+        const unsigned int numberOfKeys = 0xEE; // 238
+
+        // note: KeyCode comments were directly copied from OISKeyboard.h
+        enum ByEnum
+        {
+            Unassigned    = OIS::KC_UNASSIGNED,
+            Escape        = OIS::KC_ESCAPE,
+            NumRow1       = OIS::KC_1,
+            NumRow2       = OIS::KC_2,
+            NumRow3       = OIS::KC_3,
+            NumRow4       = OIS::KC_4,
+            NumRow5       = OIS::KC_5,
+            NumRow6       = OIS::KC_6,
+            NumRow7       = OIS::KC_7,
+            NumRow8       = OIS::KC_8,
+            NumRow9       = OIS::KC_9,
+            NumRow0       = OIS::KC_0,
+            Minus         = OIS::KC_MINUS,           // - on main keyboard
+            Equals        = OIS::KC_EQUALS,
+            Back          = OIS::KC_BACK,            // backspace
+            Tab           = OIS::KC_TAB,
+            Q             = OIS::KC_Q,
+            W             = OIS::KC_W,
+            E             = OIS::KC_E,
+            R             = OIS::KC_R,
+            T             = OIS::KC_T,
+            Y             = OIS::KC_Y,
+            U             = OIS::KC_U,
+            I             = OIS::KC_I,
+            O             = OIS::KC_O,
+            P             = OIS::KC_P,
+            LeftBracket   = OIS::KC_LBRACKET,
+            RightBracket  = OIS::KC_RBRACKET,
+            Return        = OIS::KC_RETURN,          // Enter on main keyboard
+            LeftControl   = OIS::KC_LCONTROL,
+            A             = OIS::KC_A,
+            S             = OIS::KC_S,
+            D             = OIS::KC_D,
+            F             = OIS::KC_F,
+            G             = OIS::KC_G,
+            H             = OIS::KC_H,
+            J             = OIS::KC_J,
+            K             = OIS::KC_K,
+            L             = OIS::KC_L,
+            Semicolon     = OIS::KC_SEMICOLON,
+            Apostrophe    = OIS::KC_APOSTROPHE,
+            Grave         = OIS::KC_GRAVE,           // accent
+            LeftShift     = OIS::KC_LSHIFT,
+            Backslash     = OIS::KC_BACKSLASH,
+            Z             = OIS::KC_Z,
+            X             = OIS::KC_X,
+            C             = OIS::KC_C,
+            V             = OIS::KC_V,
+            B             = OIS::KC_B,
+            N             = OIS::KC_N,
+            M             = OIS::KC_M,
+            Comma         = OIS::KC_COMMA,
+            Period        = OIS::KC_PERIOD,          // . on main keyboard
+            Slash         = OIS::KC_SLASH,           // / on main keyboard
+            RightShift    = OIS::KC_RSHIFT,
+            Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
+            LeftAlt       = OIS::KC_LMENU,           // left Alt
+            Space         = OIS::KC_SPACE,
+            CapsLock      = OIS::KC_CAPITAL,
+            F1            = OIS::KC_F1,
+            F2            = OIS::KC_F2,
+            F3            = OIS::KC_F3,
+            F4            = OIS::KC_F4,
+            F5            = OIS::KC_F5,
+            F6            = OIS::KC_F6,
+            F7            = OIS::KC_F7,
+            F8            = OIS::KC_F8,
+            F9            = OIS::KC_F9,
+            F10           = OIS::KC_F10,
+            NumLock       = OIS::KC_NUMLOCK,
+            ScrollLock    = OIS::KC_SCROLL,          // Scroll Lock
+            Numpad7       = OIS::KC_NUMPAD7,
+            Numpad8       = OIS::KC_NUMPAD8,
+            Numpad9       = OIS::KC_NUMPAD9,
+            NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
+            Numpad4       = OIS::KC_NUMPAD4,
+            Numpad5       = OIS::KC_NUMPAD5,
+            Numpad6       = OIS::KC_NUMPAD6,
+            NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
+            Numpad1       = OIS::KC_NUMPAD1,
+            Numpad2       = OIS::KC_NUMPAD2,
+            Numpad3       = OIS::KC_NUMPAD3,
+            Numpad0       = OIS::KC_NUMPAD0,
+            NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
+            LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
+            F11           = OIS::KC_F11,
+            F12           = OIS::KC_F12,
+            F13           = OIS::KC_F13,             //                     (NEC PC98)
+            F14           = OIS::KC_F14,             //                     (NEC PC98)
+            F15           = OIS::KC_F15,             //                     (NEC PC98)
+            Kana          = OIS::KC_KANA,            // (Japanese keyboard)
+            ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
+            Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
+            NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
+            Yen           = OIS::KC_YEN,             // (Japanese keyboard)
+            ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
+            NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
+            PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
+            AT            = OIS::KC_AT,              //                     (NEC PC98)
+            Colon         = OIS::KC_COLON,           //                     (NEC PC98)
+            Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
+            Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
+            Stop          = OIS::KC_STOP,            //                     (NEC PC98)
+            AX            = OIS::KC_AX,              //                     (Japan AX)
+            Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
+            NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
+            NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
+            RightControl  = OIS::KC_RCONTROL,
+            Mute          = OIS::KC_MUTE,            // Mute
+            Calculator    = OIS::KC_CALCULATOR,      // Calculator
+            PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
+            MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
+            VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
+            VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
+            WebHome       = OIS::KC_WEBHOME,         // Web home
+            NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
+            Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
+            SystemRequest = OIS::KC_SYSRQ,
+            RightAlt      = OIS::KC_RMENU,           // right Alt
+            Pause         = OIS::KC_PAUSE,           // Pause
+            Home          = OIS::KC_HOME,            // Home on arrow keypad
+            Up            = OIS::KC_UP,              // UpArrow on arrow keypad
+            PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
+            Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
+            Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
+            End           = OIS::KC_END,             // End on arrow keypad
+            Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
+            PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
+            Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
+            Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
+            LeftWindows   = OIS::KC_LWIN,            // Left Windows key
+            RightWindows  = OIS::KC_RWIN,            // Right Windows key
+            Apps          = OIS::KC_APPS,            // AppMenu key
+            Power         = OIS::KC_POWER,           // System Power
+            Sleep         = OIS::KC_SLEEP,           // System Sleep
+            Wake          = OIS::KC_WAKE,            // System Wake
+            WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
+            WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
+            WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
+            WebStop       = OIS::KC_WEBSTOP,         // Web Stop
+            WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
+            WebBack       = OIS::KC_WEBBACK,         // Web Back
+            MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
+            Mail          = OIS::KC_MAIL,            // Mail
+            MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
+        };
+        
+        // Names as string. Has no real linkage!
+        const char* const ByString[] =
+        {
+            "Unassigned",
+            "Escape",
+            "NumRow1", "NumRow2", "NumRow3", "NumRow4", "NumRow5",
+            "NumRow6", "NumRow7", "NumRow8", "NumRow9", "NumRow0",
+            "Minus", "Equals", "Back", "Tab",
+            "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
+            "LeftBracket", "RightBracket",
+            "Return", "LeftControl",
+            "A", "S", "D", "F", "G", "H", "J", "K", "L",
+            "Semicolon", "Apostrophe", "Grave",
+            "LeftShift", "Backslash",
+            "Z", "X", "C", "V", "B", "N", "M",
+            "Comma", "Period", "Slash",
+            "RightShift",
+            "Multiply",
+            "LeftAlt",
+            "Space",
+            "CapsLock",
+            "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
+            "NumLock", "ScrollLock",
+            "Numpad7", "Numpad8", "Numpad9",
+            "NumpadSubtract",
+            "Numpad4", "Numpad5", "Numpad6",
+            "NumpadAdd",
+            "Numpad1", "Numpad2", "Numpad3", "Numpad0",
+            "NumpadPeriod",
+            "","",
+            "LessThan",
+            "F11", "F12",
+            "","","","","","","","","","","",
+            "F13", "F14", "F15",
+            "","","","","","","","","","",
+            "Kana",
+            "","",
+            "ABNT_C1",
+            "","","","","",
+            "Convert",
+            "",
+            "NoConvert",
+            "",
+            "Yen",
+            "ABNT_C2",
+            "","","","","","","","","","","","","","",
+            "NumpadEquals",
+            "","",
+            "PreviousTrack",
+            "AT",
+            "Colon", "Underline",
+            "Kanji",
+            "Stop",
+            "AX",
+            "Unlabeled",
+            "NextTrack",
+            "","",
+            "NumpadEnter",
+            "RightControl",
+            "","",
+            "Mute",
+            "Calculator",
+            "PlayPause",
+            "",
+            "MediaStop",
+            "","","","","","","","","",
+            "VolumeDown",
+            "",
+            "VolumeUp",
+            "",
+            "WebHome",
+            "NumpadComma",
+            "",
+            "Divide",
+            "",
+            "SystemRequest",
+            "RightAlt",
+            "","","","","","","","","","","","",
+            "Pause",
+            "",
+            "Home",
+            "UP",
+            "PageUp",
+            "",
+            "Left",
+            "",
+            "Right",
+            "",
+            "End", "Down", "PageDown", "Insert", "Delete",
+            "","","","","","","",
+            "LeftWindows", "RightWindows", "Apps",
+            "Power", "Sleep",
+            "","","",
+            "Wake",
+            "",
+            "WebSearch", "WebFavorites", "WebRefresh", "WebStop", "WebForward", "WebBack",
+            "MyComputer", "Mail", "MediaSelect"
+        };
+    }
+
+    namespace MouseButtonCode
+    {
+        const unsigned int numberOfButtons = 8;
+
+        enum ByEnum
+        {
+            Left    = OIS::MB_Left,
+            Right   = OIS::MB_Right,
+            Middle  = OIS::MB_Middle,
+            Button3 = OIS::MB_Button3,
+            Button4 = OIS::MB_Button4,
+            Button5 = OIS::MB_Button5,
+            Button6 = OIS::MB_Button6,
+            Button7 = OIS::MB_Button7,
+        };
+
+        // Names as string. Has no real linkage!
+        const char* const ByString[] =
+        {
+            "Left",
+            "Right",
+            "Middle",
+            "Button3",
+            "Button4",
+            "Button5",
+            "Button6",
+            "Button7",
+        };
+    }
+
+    namespace MouseAxisCode
+    {
+        const unsigned int numberOfAxes = 2;
+
+        enum ByEnum
+        {
+            X,
+            Y
+        };
+
+        // Names as string. Has no real linkage!
+        const char* const ByString[] =
+        {
+            "X",
+            "Y"
+        };
+    }
+
+    namespace JoyStickButtonCode
+    {
+        const unsigned int numberOfButtons = 64;
+
+        enum ByEnum
+        {
+            Button0       =  0, Button1       =  1, Button2       =  2, Button3       =  3,
+            Button4       =  4, Button5       =  5, Button6       =  6, Button7       =  7,
+            Button8       =  8, Button9       =  9, Button10      = 10, Button11      = 11,
+            Button12      = 12, Button13      = 13, Button14      = 14, Button15      = 15,
+            Button16      = 16, Button17      = 17, Button18      = 18, Button19      = 19,
+            Button20      = 20, Button21      = 21, Button22      = 22, Button23      = 23,
+            Button24      = 24, Button25      = 25, Button26      = 26, Button27      = 27,
+            Button28      = 28, Button29      = 29, Button30      = 30, Button31      = 31,
+
+            POV0North     = 32, POV0South     = 33, POV0East      = 34, POV0West      = 35,
+            POV0NorthEast = 36, POV0SouthEast = 37, POV0NorthWest = 38, POV0SouthWest = 39,
+
+            POV1North     = 40, POV1South     = 41, POV1East      = 42, POV1West      = 43,
+            POV1NorthEast = 44, POV1SouthEast = 45, POV1NorthWest = 46, POV1SouthWest = 47,
+
+            POV2North     = 48, POV2South     = 49, POV2East      = 50, POV2West      = 51,
+            POV2NorthEast = 52, POV2SouthEast = 53, POV2NorthWest = 54, POV2SouthWest = 55,
+
+            POV3North     = 56, POV3South     = 57, POV3East      = 58, POV3West      = 59,
+            POV3NorthEast = 60, POV3SouthEast = 61, POV3NorthWest = 62, POV3SouthWest = 63,
+        };
+
+        // Names as string. Has no real linkage!
+        const char* const ByString[] =
+        {
+            "Button0",       "Button1",       "Button2",       "Button3",
+            "Button4",       "Button5",       "Button6",       "Button7",
+            "Button8",       "Button9",       "Button10",      "Button11",
+            "Button12",      "Button13",      "Button14",      "Button15",
+            "Button16",      "Button17",      "Button18",      "Button19",
+            "Button20",      "Button21",      "Button22",      "Button23",
+            "Button24",      "Button25",      "Button26",      "Button27",
+            "Button28",      "Button29",      "Button30",      "Button31",
+            "POV0North",     "POV0South",     "POV0East",      "POV0West",
+            "POV0NorthEast", "POV0SouthEast", "POV0NorthWest", "POV0SouthWest",
+            "POV1North",     "POV1South",     "POV1East",      "POV1West",
+            "POV1NorthEast", "POV1SouthEast", "POV1NorthWest", "POV1SouthWest",
+            "POV2North",     "POV2South",     "POV2East",      "POV2West",
+            "POV2NorthEast", "POV2SouthEast", "POV2NorthWest", "POV2SouthWest",
+            "POV3North",     "POV3South",     "POV3East",      "POV3West",
+            "POV3NorthEast", "POV3SouthEast", "POV3NorthWest", "POV3SouthWest"
+        };
+    }
+
+    namespace JoyStickAxisCode
+    {
+        const unsigned int numberOfAxes = 24;
+
+        enum ByEnum
+        {
+            Slider0 =  0, Slider1 =  1, Slider2 =  2, Slider3 =  3,
+            Slider4 =  4, Slider5 =  5, Slider6 =  6, Slider7 =  7,
+            Axis0   =  8, Axis1   =  9, Axis2   = 10, Axis3   = 11,
+            Axis4   = 12, Axis5   = 13, Axis6   = 14, Axis7   = 15,
+            Axis8   = 16, Axis9   = 17, Axis10  = 18, Axis11  = 19,
+            Axis12  = 20, Axis13  = 21, Axis14  = 22, Axis15  = 23
+        };
+
+        // Names as string. Has no real linkage!
+        const char* const ByString[] =
+        {
+            "Slider0", "Slider1", "Slider2", "Slider3",
+            "Slider4", "Slider5", "Slider6", "Slider7",
+            "Axis0",   "Axis1",   "Axis2",   "Axis3",
+            "Axis4",   "Axis5",   "Axis6",   "Axis7",
+            "Axis8",   "Axis9",   "Axis10",  "Axis11",
+            "Axis12",  "Axis13",  "Axis14",  "Axis15"
+        };
+    }
+
+    namespace KeyboardModifier
+    {
+        enum Enum
+        {
+            Shift = 0x0000001,
+            Ctrl  = 0x0000010,
+            Alt   = 0x0000100
+        };
+    }
+    
+    namespace InputDevice
+    {
+        enum Enum
+        {
+            Keyboard,
+            Mouse,
+            JoyStick0,
+            JoyStick1,
+            JoyStick2,
+            JoyStick3
+            // note: No problem if there are more joy sticks. This enum is just for convenience.
+        };
+    }
+
+    struct _CoreExport Key
+    {
+        Key(const OIS::KeyEvent& evt) : key((KeyCode::ByEnum)evt.key), text(evt.text) { }
+        KeyCode::ByEnum key;
+        unsigned int text;
+    };
+
+    class _CoreExport KeyEvent
+    {
+    public:
+        KeyEvent(KeyCode::ByEnum key, unsigned int text) : key(key), text(text) { }
+        KeyEvent(const OIS::KeyEvent& evt, unsigned int mod)
+            : key((KeyCode::ByEnum)evt.key), text(evt.text), modifiers(mod) { }
+        KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
+        bool isModifierDown(KeyboardModifier::Enum modifier) const
+            { return (KeyboardModifier::Enum)modifier&modifiers; }
+
+        const KeyCode::ByEnum key;
+        unsigned int text;
+        unsigned int modifiers;
+    };
+
+
+    class _CoreExport InputHandler
+    {
+    public:
+        virtual ~InputHandler() { }
+        virtual void tickInput(float dt) = 0;
+    };
+
+    /**
+    @brief
+        Interface class used for key input listeners.
+    */
+    class _CoreExport KeyHandler : virtual public InputHandler
+    {
+    public:
+        virtual ~KeyHandler() { }
+        virtual void keyPressed (const KeyEvent& evt) = 0;
+        virtual void keyReleased(const KeyEvent& evt) = 0;
+        virtual void keyHeld    (const KeyEvent& evt) = 0;
+        virtual void tickKey    (float dt) = 0;
+    };
+
+    /**
+    @brief
+        Interface class used for mouse input listeners.
+    */
+    class _CoreExport MouseHandler : virtual public InputHandler
+    {
+    public:
+        virtual ~MouseHandler() { }
+        virtual void mouseButtonPressed (MouseButtonCode::ByEnum id) = 0;
+        virtual void mouseButtonReleased(MouseButtonCode::ByEnum id) = 0;
+        virtual void mouseButtonHeld    (MouseButtonCode::ByEnum id) = 0;
+        virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
+        virtual void mouseScrolled      (int abs, int rel)     = 0;
+        virtual void tickMouse          (float dt) = 0;
+    };
+
+
+    /**
+    @brief
+        Interface class used for joy stick input listeners.
+    */
+    class _CoreExport JoyStickHandler : virtual public InputHandler
+    {
+    public:
+        virtual ~JoyStickHandler() { }
+        virtual void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0;
+        virtual void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0;
+        virtual void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0;
+        virtual void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value) = 0;
+        virtual void tickJoyStick          (float dt, unsigned int joyStick) = 0;
+    };
+
+    class _CoreExport EmptyHandler : public KeyHandler, public MouseHandler, public JoyStickHandler
+    {
+        friend class InputManager;
+    private:
+        EmptyHandler() { }
+        EmptyHandler(EmptyHandler&);
+        virtual ~EmptyHandler() { }
+
+        void tickInput(float dt) { }
+        void tickJoyStick(float dt, unsigned int joyStick) { }
+        void tickMouse(float dt) { }
+        void tickKey(float dt) { }
+
+        void keyPressed (const KeyEvent& evt) { }
+        void keyReleased(const KeyEvent& evt) { }
+        void keyHeld    (const KeyEvent& evt) { }
+
+        void mouseButtonPressed (MouseButtonCode::ByEnum id) { }
+        void mouseButtonReleased(MouseButtonCode::ByEnum id) { }
+        void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) { }
+        void mouseScrolled      (int abs, int rel) { }
+
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) { }
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id) { }
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) { }
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value) { }
+    };
+
+}
+
+#endif /* _InputInterfaces_H__ */
Index: /code/branches/physics/src/core/input/InputManager.cc
===================================================================
--- /code/branches/physics/src/core/input/InputManager.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/InputManager.cc	(revision 2122)
@@ -0,0 +1,1404 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the InputManager that captures all the input from OIS
+    and redirects it to handlers.
+ */
+
+#include "InputManager.h"
+
+#include <climits>
+#include <cassert>
+
+#include "ois/OISException.h"
+#include "ois/OISInputManager.h"
+
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandLine.h"
+#include "util/Debug.h"
+
+#include "InputBuffer.h"
+#include "KeyBinder.h"
+#include "KeyDetector.h"
+#include "CalibratorCallback.h"
+#include "InputState.h"
+#include "SimpleInputState.h"
+#include "ExtendedInputState.h"
+#include "JoyStickDeviceNumberListener.h"
+
+namespace orxonox
+{
+    SetConsoleCommand(InputManager, calibrate, true);
+    SetConsoleCommand(InputManager, reload, false);
+    SetCommandLineSwitch(keyboard_no_grab);
+
+    std::string InputManager::bindingCommmandString_s = "";
+    EmptyHandler InputManager::EMPTY_HANDLER;
+    InputManager* InputManager::singletonRef_s = 0;
+
+    using namespace InputDevice;
+
+    /**
+    @brief
+        Defines the |= operator for easier use.
+    */
+    inline InputManager::InputManagerState operator|=(InputManager::InputManagerState& lval,
+                                                      InputManager::InputManagerState rval)
+    {
+        return (lval = (InputManager::InputManagerState)(lval | rval));
+    }
+
+    /**
+    @brief
+        Defines the &= operator for easier use.
+    */
+    inline InputManager::InputManagerState operator&=(InputManager::InputManagerState& lval, int rval)
+    {
+        return (lval = (InputManager::InputManagerState)(lval & rval));
+    }
+
+    // ############################################################
+    // #####                  Initialisation                  #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Constructor only sets member fields to initial zero values
+        and registers the class in the class hierarchy.
+    */
+    InputManager::InputManager()
+        : inputSystem_(0)
+        , keyboard_(0)
+        , mouse_(0)
+        , joySticksSize_(0)
+        , devicesNum_(0)
+        , windowHnd_(0)
+        , internalState_(Uninitialised)
+        , stateEmpty_(0)
+        , stateMaster_(0)
+        , keyDetector_(0)
+        , calibratorCallbackBuffer_(0)
+        , bCalibrating_(false)
+        , keyboardModifiers_(0)
+    {
+        RegisterRootObject(InputManager);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+    }
+
+    /**
+    @brief
+        Creates the OIS::InputMananger, the keyboard, the mouse and
+        the joysticks and assigns the key bindings.
+    @param windowHnd
+        The window handle of the render window
+    @param windowWidth
+        The width of the render window
+    @param windowHeight
+        The height of the render window
+    @param joyStickSupport
+        Whether or not to load the joy sticks as well
+    */
+    void InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight, bool joyStickSupport)
+    {
+        CCOUT(3) << "Initialising Input System..." << std::endl;
+
+        if (!(internalState_ & OISReady))
+        {
+            CCOUT(4) << "Initialising OIS components..." << std::endl;
+
+            // store handle internally so we can reload OIS
+            windowHnd_ = windowHnd;
+
+            OIS::ParamList paramList;
+            std::ostringstream windowHndStr;
+
+            // Fill parameter list
+            windowHndStr << (unsigned int)windowHnd_;
+            paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
+            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
+#if defined OIS_LINUX_PLATFORM
+            paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+            paramList.insert(std::make_pair(std::string("x11_mouse_grab"), "true"));
+            paramList.insert(std::make_pair(std::string("x11_mouse_hide"), "true"));
+            bool kbNoGrab;
+            CommandLine::getValue("keyboard_no_grab", &kbNoGrab);
+            if (kbNoGrab)
+                paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
+            else
+                paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("true")));
+#endif
+
+            inputSystem_ = OIS::InputManager::createInputSystem(paramList);
+            CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
+
+            _initialiseKeyboard();
+
+            _initialiseMouse();
+
+            if (joyStickSupport)
+                _initialiseJoySticks();
+            // Do this anyway to also inform everyone if a joystick was detached.
+            _configureNumberOfJoySticks();
+
+            // Set mouse/joystick region
+            if (mouse_)
+                setWindowExtents(windowWidth, windowHeight);
+
+            // clear all buffers
+            _clearBuffers();
+
+            // load joy stick calibration
+            setConfigValues();
+
+            internalState_ |= OISReady;
+
+            CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
+        }
+        else
+        {
+            CCOUT(2) << "Warning: OIS compoments already initialised, skipping" << std::endl;
+        }
+
+        if (!(internalState_ & InternalsReady))
+        {
+            CCOUT(4) << "Initialising InputStates components..." << std::endl;
+
+            // Lowest priority empty InputState
+            stateEmpty_ = createInputState<SimpleInputState>("empty", -1);
+            stateEmpty_->setHandler(&EMPTY_HANDLER);
+            activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
+
+            // Always active master InputState
+            stateMaster_ = new ExtendedInputState();
+            stateMaster_->setName("master");
+            stateMaster_->setNumOfJoySticks(joySticksSize_);
+
+            // KeyDetector to evaluate a pressed key's name
+            SimpleInputState* detector = createInputState<SimpleInputState>("detector", 101);
+            keyDetector_ = new KeyDetector();
+            detector->setHandler(keyDetector_);
+
+            // Joy stick calibration helper callback
+            SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", 100);
+            calibrator->setHandler(&EMPTY_HANDLER);
+            calibratorCallbackBuffer_ = new InputBuffer();
+            calibratorCallbackBuffer_->registerListener(this, &InputManager::_completeCalibration, '\r', true);
+            calibrator->setKeyHandler(calibratorCallbackBuffer_);
+
+            internalState_ |= InternalsReady;
+
+            CCOUT(4) << "Initialising InputStates complete." << std::endl;
+        }
+
+        _updateActiveStates();
+
+        CCOUT(3) << "Initialising complete." << std::endl;
+    }
+
+    /**
+    @brief
+        Creates a keyboard and sets the event handler.
+    @return
+        False if keyboard stays uninitialised, true otherwise.
+    */
+    void InputManager::_initialiseKeyboard()
+    {
+        if (keyboard_ != 0)
+        {
+            CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
+            return;
+        }
+        if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
+        {
+            keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
+            // register our listener in OIS.
+            keyboard_->setEventCallback(this);
+            // note: OIS will not detect keys that have already been down when the keyboard was created.
+            CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
+        }
+        else
+        {
+            ThrowException(InitialisationFailed, "No keyboard found!");
+        }
+    }
+
+    /**
+    @brief
+        Creates a mouse and sets the event handler.
+    @return
+        False if mouse stays uninitialised, true otherwise.
+    */
+    void InputManager::_initialiseMouse()
+    {
+        if (mouse_ != 0)
+        {
+            CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
+            return;
+        }
+        try
+        {
+            if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
+            {
+                mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
+                // register our listener in OIS.
+                mouse_->setEventCallback(this);
+                CCOUT(ORX_DEBUG) << "Created OIS mouse" << std::endl;
+            }
+            else
+            {
+                CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
+            }
+        }
+        catch (OIS::Exception ex)
+        {
+            CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
+                << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+            mouse_ = 0;
+        }
+    }
+
+    /**
+    @brief
+        Creates all joy sticks and sets the event handler.
+    @return
+        False joy stick stay uninitialised, true otherwise.
+    */
+    void InputManager::_initialiseJoySticks()
+    {
+        if (joySticksSize_ > 0)
+        {
+            CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
+            return;
+        }
+        if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
+        {
+            for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
+            {
+                try
+                {
+                    OIS::JoyStick* stig = static_cast<OIS::JoyStick*>
+                        (inputSystem_->createInputObject(OIS::OISJoyStick, true));
+                    CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
+                    joySticks_.push_back(stig);
+                    // register our listener in OIS.
+                    stig->setEventCallback(this);
+                }
+                catch (OIS::Exception ex)
+                {
+                    CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
+                        << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+                }
+            }
+        }
+        else
+        {
+            //CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
+        }
+    }
+
+    /**
+    @brief
+        Sets the size of all the different lists that are dependent on the number
+        of joy stick devices created.
+    @remarks
+        No matter whether there are a mouse and/or keyboard, they will always
+        occupy 2 places in the device number dependent lists.
+    */
+    void InputManager::_configureNumberOfJoySticks()
+    {
+        joySticksSize_ = joySticks_.size();
+        devicesNum_ = 2 + joySticksSize_;
+        joyStickButtonsDown_ .resize(joySticksSize_);
+        povStates_           .resize(joySticksSize_);
+        sliderStates_        .resize(joySticksSize_);
+        joySticksCalibration_.resize(joySticksSize_);
+
+        for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++)
+        {
+            // reset the calibration with default values
+            for (unsigned int i = 0; i < 24; i++)
+            {
+                joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f;
+                joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f;
+                joySticksCalibration_[iJoyStick].zeroStates[i] = 0;
+            }
+        }
+
+        // state management
+        activeStatesTop_.resize(devicesNum_);
+
+        // inform all states
+        for (std::map<int, InputState*>::const_iterator it = inputStatesByPriority_.begin();
+            it != inputStatesByPriority_.end(); ++it)
+        {
+            it->second->setNumOfJoySticks(joySticksSize_);
+        }
+        // inform master state
+        if (stateMaster_)
+            this->stateMaster_->setNumOfJoySticks(joySticksSize_);
+
+        // inform all JoyStick Device Number Listeners
+        for (ObjectList<JoyStickDeviceNumberListener>::iterator it = ObjectList<JoyStickDeviceNumberListener>::begin(); it; ++it)
+            it->JoyStickDeviceNumberChanged(joySticksSize_);
+
+    }
+
+    /**
+    @brief
+        Sets the configurable values.
+        This mainly concerns joy stick calibrations.
+    */
+    void InputManager::setConfigValues()
+    {
+        if (joySticksSize_ > 0)
+        {
+            std::vector<double> coeffPos;
+            std::vector<double> coeffNeg;
+            std::vector<int> zero;
+            coeffPos.resize(24);
+            coeffNeg.resize(24);
+            zero.resize(24);
+            for (unsigned int i = 0; i < 24; i++)
+            {
+                coeffPos[i] =  1.0f/32767.0f;
+                coeffNeg[i] =  1.0f/32768.0f;
+                zero[i]     =  0;
+            }
+
+            ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+            if (!cont)
+            {
+                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos);
+                getIdentifier()->addConfigValueContainer("CoeffPos", cont);
+            }
+            cont->getValue(&coeffPos, this);
+
+            cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+            if (!cont)
+            {
+                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg);
+                getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
+            }
+            cont->getValue(&coeffNeg, this);
+
+            cont = getIdentifier()->getConfigValueContainer("Zero");
+            if (!cont)
+            {
+                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero);
+                getIdentifier()->addConfigValueContainer("Zero", cont);
+            }
+            cont->getValue(&zero, this);
+
+            // copy values to our own variables
+            for (unsigned int i = 0; i < 24; i++)
+            {
+                joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i];
+                joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i];
+                joySticksCalibration_[0].zeroStates[i]    = zero[i];
+            }
+        }
+    }
+
+
+    // ############################################################
+    // #####                    Destruction                   #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Destroys all the created input devices and states.
+    */
+    InputManager::~InputManager()
+    {
+        if (internalState_ != Uninitialised)
+        {
+            try
+            {
+                CCOUT(3) << "Destroying ..." << std::endl;
+
+                // kick all active states 'nicely'
+                for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
+                    rit != activeStates_.rend(); ++rit)
+                {
+                    (*rit).second->onLeave();
+                }
+
+                // Destroy calibrator helper handler and state
+                delete keyDetector_;
+                requestDestroyState("calibrator");
+                // Destroy KeyDetector and state
+                delete calibratorCallbackBuffer_;
+                requestDestroyState("detector");
+                // destroy the empty InputState
+                _destroyState(this->stateEmpty_);
+                // destroy the master input state. This might trigger a memory leak
+                // because the user has forgotten to destroy the KeyBinder or any Handler!
+                delete stateMaster_;
+
+                // destroy all user InputStates
+                while (inputStatesByPriority_.size() > 0)
+                    _destroyState((*inputStatesByPriority_.rbegin()).second);
+
+                // destroy the devices
+                _destroyKeyboard();
+                _destroyMouse();
+                _destroyJoySticks();
+
+                OIS::InputManager::destroyInputSystem(inputSystem_);
+
+                CCOUT(3) << "Destroying done." << std::endl;
+            }
+            catch (OIS::Exception& ex)
+            {
+                CCOUT(1) << "An exception has occured while destroying:\n" << ex.what()
+                         << "This could lead to a possible memory/resource leak!" << std::endl;
+            }
+        }
+	singletonRef_s = 0;
+    }
+
+    /**
+    @brief
+        Destroys the keyboard and sets it to 0.
+    */
+    void InputManager::_destroyKeyboard()
+    {
+        assert(inputSystem_);
+        if (keyboard_)
+            inputSystem_->destroyInputObject(keyboard_);
+        keyboard_ = 0;
+        CCOUT(4) << "Keyboard destroyed." << std::endl;
+    }
+
+    /**
+    @brief
+        Destroys the mouse and sets it to 0.
+    */
+    void InputManager::_destroyMouse()
+    {
+        assert(inputSystem_);
+        if (mouse_)
+            inputSystem_->destroyInputObject(mouse_);
+        mouse_ = 0;
+        CCOUT(4) << "Mouse destroyed." << std::endl;
+    }
+
+    /**
+    @brief
+        Destroys all the joy sticks and resizes the lists to 0.
+    */
+    void InputManager::_destroyJoySticks()
+    {
+        if (joySticksSize_ > 0)
+        {
+            assert(inputSystem_);
+            for (unsigned int i = 0; i < joySticksSize_; i++)
+                if (joySticks_[i] != 0)
+                    inputSystem_->destroyInputObject(joySticks_[i]);
+
+            joySticks_.clear();
+            // don't use _configureNumberOfJoySticks(), might mess with registered handler if
+            // downgrading from 2 to 1 joystick
+            //_configureNumberOfJoySticks();
+            joySticksSize_ = 0;
+        }
+        CCOUT(4) << "Joy sticks destroyed." << std::endl;
+    }
+
+    /**
+    @brief
+        Removes and destroys an InputState.
+    @return
+        True if state was removed immediately, false if postponed.
+    */
+    void InputManager::_destroyState(InputState* state)
+    {
+        assert(state && !(this->internalState_ & Ticking));
+        std::map<int, InputState*>::iterator it = this->activeStates_.find(state->getPriority());
+        if (it != this->activeStates_.end())
+        {
+            this->activeStates_.erase(it);
+            _updateActiveStates();
+        }
+        inputStatesByPriority_.erase(state->getPriority());
+        inputStatesByName_.erase(state->getName());
+        delete state;
+    }
+
+    void InputManager::_clearBuffers()
+    {
+        keysDown_.clear();
+        keyboardModifiers_ = 0;
+        mouseButtonsDown_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; ++i)
+        {
+            joyStickButtonsDown_[i].clear();
+            for (int j = 0; j < 4; ++j)
+            {
+                sliderStates_[i].sliderStates[j].x = 0;
+                sliderStates_[i].sliderStates[j].y = 0;
+                povStates_[i][j] = 0;
+            }
+        }
+    }
+
+
+    // ############################################################
+    // #####                     Reloading                    #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Public interface. Only reloads immediately if the call stack doesn't
+        include the tick() method.
+    @param joyStickSupport
+        Whether or not to initialise joy sticks as well.
+    */
+    void InputManager::reloadInputSystem(bool joyStickSupport)
+    {
+        if (internalState_ & Ticking)
+        {
+            // We cannot destroy OIS right now, because reload was probably
+            // caused by a user clicking on a GUI item. The backtrace would then
+            // include an OIS method. So it would be a very bad thing to destroy it..
+            internalState_ |= ReloadRequest;
+            // Misuse of internalState_: We can easily store the joyStickSupport bool.
+            // use Uninitialised as 0 value in order to make use of the overloaded |= operator
+            internalState_ |= joyStickSupport ? JoyStickSupport : Uninitialised;
+        }
+        else if (internalState_ & OISReady)
+        {
+            _reload(joyStickSupport);
+        }
+        else
+        {
+            CCOUT(2) << "Warning: Cannot reload OIS. May not yet be initialised or"
+                     << "joy sticks are currently calibrating." << std::endl;
+        }
+    }
+
+    /**
+    @brief
+        Internal reload method. Destroys the OIS devices and loads them again.
+    */
+    void InputManager::_reload(bool joyStickSupport)
+    {
+        try
+        {
+            CCOUT(3) << "Reloading ..." << std::endl;
+
+            // Save mouse clipping size
+            int mouseWidth  = mouse_->getMouseState().width;
+            int mouseHeight = mouse_->getMouseState().height;
+
+            internalState_ &= ~OISReady;
+
+            // destroy the devices
+            _destroyKeyboard();
+            _destroyMouse();
+            _destroyJoySticks();
+
+            OIS::InputManager::destroyInputSystem(inputSystem_);
+            inputSystem_ = 0;
+
+            // clear all buffers containing input information
+            _clearBuffers();
+
+            initialise(windowHnd_, mouseWidth, mouseHeight, joyStickSupport);
+
+            CCOUT(3) << "Reloading done." << std::endl;
+        }
+        catch (OIS::Exception& ex)
+        {
+            CCOUT(1) << "An exception has occured while reloading:\n" << ex.what() << std::endl;
+        }
+    }
+
+    // ############################################################
+    // #####                  Runtime Methods                 #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Updates the InputManager. Tick is called by the Core class.
+    @param dt
+        Delta time
+    */
+    void InputManager::tick(float dt)
+    {
+        if (internalState_ == Uninitialised)
+            return;
+        else if (internalState_ & ReloadRequest)
+        {
+            _reload(internalState_ & JoyStickSupport);
+            internalState_ &= ~ReloadRequest;
+            internalState_ &= ~JoyStickSupport;
+        }
+
+        // check for states to leave
+        for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin();
+            rit != stateLeaveRequests_.rend(); ++rit)
+        {
+            (*rit)->onLeave();
+            // just to be sure that the state actually is registered
+            assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
+
+            activeStates_.erase((*rit)->getPriority());
+            _updateActiveStates();
+        }
+        stateLeaveRequests_.clear();
+
+        // check for states to enter
+        for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin();
+            rit != stateEnterRequests_.rend(); ++rit)
+        {
+            // just to be sure that the state actually is registered
+            assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
+
+            activeStates_[(*rit)->getPriority()] = (*rit);
+            _updateActiveStates();
+            (*rit)->onEnter();
+        }
+        stateEnterRequests_.clear();
+
+        // check for states to destroy
+        for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin();
+            rit != stateDestroyRequests_.rend(); ++rit)
+        {
+            _destroyState((*rit));
+        }
+        stateDestroyRequests_.clear();
+
+        // check whether a state has changed its EMPTY_HANDLER situation
+        bool bUpdateRequired = false;
+        for (std::map<int, InputState*>::iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
+        {
+            if (it->second->handlersChanged())
+            {
+                it->second->resetHandlersChanged();
+                bUpdateRequired = true;
+            }
+        }
+        if (bUpdateRequired)
+            _updateActiveStates();
+
+        // mark that we capture and distribute input
+        internalState_ |= Ticking;
+
+        // Capture all the input. This calls the event handlers in InputManager.
+        if (keyboard_)
+            keyboard_->capture();
+        if (mouse_)
+            mouse_->capture();
+        for (unsigned  int i = 0; i < joySticksSize_; i++)
+            joySticks_[i]->capture();
+
+        if (!bCalibrating_)
+        {
+            // call all the handlers for the held key events
+            for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+            {
+                KeyEvent kEvt(keysDown_[iKey], keyboardModifiers_);
+                activeStatesTop_[Keyboard]->keyHeld(kEvt);
+                stateMaster_->keyHeld(kEvt);
+            }
+
+            // call all the handlers for the held mouse button events
+            for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+            {
+                activeStatesTop_[Mouse]->mouseButtonHeld(mouseButtonsDown_[iButton]);
+                stateMaster_->mouseButtonHeld(mouseButtonsDown_[iButton]);
+            }
+
+            // call all the handlers for the held joy stick button events
+            for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
+                for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
+                {
+                    activeStatesTop_[JoyStick0 + iJoyStick]
+                        ->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
+                    stateMaster_->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
+                }
+
+            // tick the handlers for each active handler
+            for (unsigned int i = 0; i < devicesNum_; ++i)
+            {
+                activeStatesTop_[i]->tickInput(dt, i);
+                if (stateMaster_->isInputDeviceEnabled(i))
+                    stateMaster_->tickInput(dt, i);
+            }
+
+            // tick the handler with a general tick afterwards
+            for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
+                activeStatesTicked_[i]->tickInput(dt);
+            stateMaster_->tickInput(dt);
+        }
+
+        internalState_ &= ~Ticking;
+    }
+
+    /**
+    @brief
+        Updates the currently active states (according to activeStates_) for each device.
+        Also, a list of all active states (no duplicates!) is compiled for the general tick.
+    */
+    void InputManager::_updateActiveStates()
+    {
+        for (std::map<int, InputState*>::const_iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
+            for (unsigned int i = 0; i < devicesNum_; ++i)
+                if (it->second->isInputDeviceEnabled(i))
+                    activeStatesTop_[i] = it->second;
+
+        // update tickables (every state will only appear once)
+        // Using a std::set to avoid duplicates
+        std::set<InputState*> tempSet;
+        for (unsigned int i = 0; i < devicesNum_; ++i)
+            tempSet.insert(activeStatesTop_[i]);
+
+        // copy the content of the set back to the actual vector
+        activeStatesTicked_.clear();
+        for (std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)
+            activeStatesTicked_.push_back(*it);
+
+        this->mouseButtonsDown_.clear();
+    }
+
+    /**
+    @brief
+        Processes the accumultated data for the joy stick calibration.
+    */
+    void InputManager::_completeCalibration()
+    {
+        for (unsigned int i = 0; i < 24; i++)
+        {
+            // positive coefficient
+            if (marginalsMax_[i] == INT_MIN)
+                marginalsMax_[i] =  32767;
+            // coefficients
+            if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i])
+            {
+                joySticksCalibration_[0].positiveCoeff[i]
+                    = 1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]);
+            }
+            else
+                joySticksCalibration_[0].positiveCoeff[i] =  1.0f;
+
+            // config value
+            ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+            assert(cont);
+            cont->set(i, joySticksCalibration_[0].positiveCoeff[i]);
+
+            // negative coefficient
+            if (marginalsMin_[i] == INT_MAX)
+                marginalsMin_[i] = -32768;
+            // coefficients
+            if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i])
+            {
+                joySticksCalibration_[0].negativeCoeff[i] = -1.0f
+                    / (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]);
+            }
+            else
+                joySticksCalibration_[0].negativeCoeff[i] =  1.0f;
+            // config value
+            cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+            assert(cont);
+            cont->set(i, joySticksCalibration_[0].negativeCoeff[i]);
+
+            // zero states
+            if (i < 8)
+            {
+                if (!(i & 1))
+                    joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX;
+                else
+                    joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY;
+            }
+            else
+            {
+                if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size())
+                    joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs;
+                else
+                    joySticksCalibration_[0].zeroStates[i] = 0;
+            }
+            // config value
+            cont = getIdentifier()->getConfigValueContainer("Zero");
+            assert(cont);
+            cont->set(i, joySticksCalibration_[0].zeroStates[i]);
+        }
+
+        // restore old input state
+        requestLeaveState("calibrator");
+        bCalibrating_ = false;
+    }
+
+    void InputManager::clearBuffers()
+    {
+        this->keysDown_.clear();
+        this->mouseButtonsDown_.clear();
+        for (unsigned int i = 0; i < this->joySticksSize_; ++i)
+            this->joyStickButtonsDown_[i].clear();
+    }
+
+
+    // ############################################################
+    // #####                    OIS events                    #####
+    // ##########                                        ##########
+    // ############################################################
+
+    // ###### Key Events ######
+
+    /**
+    @brief
+        Event handler for the keyPressed Event.
+    @param e
+        Event information
+    */
+    bool InputManager::keyPressed(const OIS::KeyEvent &e)
+    {
+        // check whether the key already is in the list (can happen when focus was lost)
+        unsigned int iKey = 0;
+        while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::ByEnum)e.key)
+            iKey++;
+        if (iKey == keysDown_.size())
+            keysDown_.push_back(Key(e));
+        else
+        {
+            // This happens when XAutoRepeat is set under linux. The KeyPressed event gets then sent
+            // continuously.
+            return true;
+        }
+
+        // update modifiers
+        if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+            keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
+        if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+            keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
+        if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+            keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
+
+        KeyEvent kEvt(e, keyboardModifiers_);
+        activeStatesTop_[Keyboard]->keyPressed(kEvt);
+        stateMaster_->keyPressed(kEvt);
+
+        return true;
+    }
+
+    /**
+    @brief
+        Event handler for the keyReleased Event.
+    @param e
+        Event information
+    */
+    bool InputManager::keyReleased(const OIS::KeyEvent &e)
+    {
+        // remove the key from the keysDown_ list
+        for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+        {
+            if (keysDown_[iKey].key == (KeyCode::ByEnum)e.key)
+            {
+                keysDown_.erase(keysDown_.begin() + iKey);
+                break;
+            }
+        }
+
+        // update modifiers
+        if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+            keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
+        if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+            keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
+        if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+            keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
+
+        KeyEvent kEvt(e, keyboardModifiers_);
+        activeStatesTop_[Keyboard]->keyReleased(kEvt);
+        stateMaster_->keyReleased(kEvt);
+
+        return true;
+    }
+
+
+    // ###### Mouse Events ######
+
+    /**
+    @brief
+        Event handler for the mouseMoved Event.
+    @param e
+        Event information
+    */
+    bool InputManager::mouseMoved(const OIS::MouseEvent &e)
+    {
+        // check for actual moved event
+        if (e.state.X.rel != 0 || e.state.Y.rel != 0)
+        {
+            IntVector2 abs(e.state.X.abs, e.state.Y.abs);
+            IntVector2 rel(e.state.X.rel, e.state.Y.rel);
+            IntVector2 clippingSize(e.state.width, e.state.height);
+            activeStatesTop_[Mouse]->mouseMoved(abs, rel, clippingSize);
+            stateMaster_->mouseMoved(abs, rel, clippingSize);
+        }
+
+        // check for mouse scrolled event
+        if (e.state.Z.rel != 0)
+        {
+            activeStatesTop_[Mouse]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+            stateMaster_->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+        }
+
+        return true;
+    }
+
+    /**
+    @brief
+        Event handler for the mousePressed Event.
+    @param e
+        Event information
+    @param id
+        The ID of the mouse button
+    */
+    bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+    {
+        // check whether the button already is in the list (can happen when focus was lost)
+        unsigned int iButton = 0;
+        while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButtonCode::ByEnum)id)
+            iButton++;
+        if (iButton == mouseButtonsDown_.size())
+            mouseButtonsDown_.push_back((MouseButtonCode::ByEnum)id);
+
+        activeStatesTop_[Mouse]->mouseButtonPressed((MouseButtonCode::ByEnum)id);
+        stateMaster_->mouseButtonPressed((MouseButtonCode::ByEnum)id);
+
+        return true;
+    }
+
+    /**
+    @brief
+        Event handler for the mouseReleased Event.
+    @param e
+        Event information
+    @param id
+        The ID of the mouse button
+    */
+    bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+    {
+        // remove the button from the keysDown_ list
+        for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+        {
+            if (mouseButtonsDown_[iButton] == (MouseButtonCode::ByEnum)id)
+            {
+                mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
+                break;
+            }
+        }
+
+        activeStatesTop_[Mouse]->mouseButtonReleased((MouseButtonCode::ByEnum)id);
+        stateMaster_->mouseButtonReleased((MouseButtonCode::ByEnum)id);
+
+        return true;
+    }
+
+
+    // ###### Joy Stick Events ######
+
+    /**
+    @brief
+        Returns the joy stick ID (orxonox) according to a OIS::JoyStickEvent
+    */
+    inline unsigned int InputManager::_getJoystick(const OIS::JoyStickEvent& arg)
+    {
+        // use the device to identify which one called the method
+        OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+        unsigned int iJoyStick = 0;
+        while (joySticks_[iJoyStick] != joyStick)
+            iJoyStick++;
+        // assert: Unknown joystick fired an event.
+        assert(iJoyStick != joySticksSize_);
+        return iJoyStick;
+    }
+
+    bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // check whether the button already is in the list (can happen when focus was lost)
+        std::vector<JoyStickButtonCode::ByEnum>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+        unsigned int iButton = 0;
+        while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
+            iButton++;
+        if (iButton == buttonsDown.size())
+            buttonsDown.push_back((JoyStickButtonCode::ByEnum)button);
+
+        activeStatesTop_[2 + iJoyStick]->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
+        stateMaster_->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
+
+        return true;
+    }
+
+    bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // remove the button from the joyStickButtonsDown_ list
+        std::vector<JoyStickButtonCode::ByEnum>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+        for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
+        {
+            if (buttonsDown[iButton] == button)
+            {
+                buttonsDown.erase(buttonsDown.begin() + iButton);
+                break;
+            }
+        }
+
+        activeStatesTop_[2 + iJoyStick]->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
+        stateMaster_->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
+
+        return true;
+    }
+
+    /**
+    @brief
+        Calls the states for a particular axis with our enumeration.
+        Used by OIS sliders and OIS axes.
+    */
+    void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value)
+    {
+        if (bCalibrating_)
+        {
+            if (value > marginalsMax_[axis])
+                marginalsMax_[axis] = value;
+            if (value < marginalsMin_[axis])
+                marginalsMin_[axis] = value;
+        }
+        else
+        {
+            float fValue = value - joySticksCalibration_[iJoyStick].zeroStates[axis];
+            if (fValue > 0.0f)
+                fValue *= joySticksCalibration_[iJoyStick].positiveCoeff[axis];
+            else
+                fValue *= joySticksCalibration_[iJoyStick].negativeCoeff[axis];
+
+            activeStatesTop_[2 + iJoyStick]->joyStickAxisMoved(iJoyStick, axis, fValue);
+            stateMaster_->joyStickAxisMoved(iJoyStick, axis, fValue);
+        }
+    }
+
+    bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // keep in mind that the first 8 axes are reserved for the sliders
+        _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
+
+        return true;
+    }
+
+    bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
+            _fireAxis(iJoyStick, id * 2, arg.state.mSliders[id].abX);
+        else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
+            _fireAxis(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
+
+        return true;
+    }
+
+    bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // translate the POV into 8 simple buttons
+
+        int lastState = povStates_[iJoyStick][id];
+        if (lastState & OIS::Pov::North)
+            buttonReleased(arg, 32 + id * 4 + 0);
+        if (lastState & OIS::Pov::South)
+            buttonReleased(arg, 32 + id * 4 + 1);
+        if (lastState & OIS::Pov::East)
+            buttonReleased(arg, 32 + id * 4 + 2);
+        if (lastState & OIS::Pov::West)
+            buttonReleased(arg, 32 + id * 4 + 3);
+
+        povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
+
+        int currentState = povStates_[iJoyStick][id];
+        if (currentState & OIS::Pov::North)
+            buttonPressed(arg, 32 + id * 4 + 0);
+        if (currentState & OIS::Pov::South)
+            buttonPressed(arg, 32 + id * 4 + 1);
+        if (currentState & OIS::Pov::East)
+            buttonPressed(arg, 32 + id * 4 + 2);
+        if (currentState & OIS::Pov::West)
+            buttonPressed(arg, 32 + id * 4 + 3);
+
+        return true;
+    }
+
+
+    // ############################################################
+    // #####         Other Public Interface Methods           #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Adjusts the mouse window metrics.
+        This method has to be called every time the size of the window changes.
+    @param width
+        The new width of the render window
+    @param^height
+        The new height of the render window
+    */
+    void InputManager::setWindowExtents(const int width, const int height)
+    {
+        if (mouse_)
+        {
+            // Set mouse region (if window resizes, we should alter this to reflect as well)
+            mouse_->getMouseState().width  = width;
+            mouse_->getMouseState().height = height;
+        }
+    }
+
+    /**
+    @brief
+        Sets the the name of the command used by the KeyDetector as callback.
+    @param command
+        Command name as string
+    */
+    void InputManager::setKeyDetectorCallback(const std::string& command)
+    {
+        this->keyDetector_->setCallbackCommand(command);
+    }
+
+    // ###### InputStates ######
+
+    /**
+    @brief
+        Adds a new key handler.
+    @param handler
+        Pointer to the handler object.
+    @param name
+        Unique name of the handler.
+    @param priority
+        Unique integer number. Higher means more prioritised.
+    @return
+        True if added, false if name or priority already existed.
+    */
+    bool InputManager::_configureInputState(InputState* state, const std::string& name, int priority)
+    {
+        if (name == "")
+            return false;
+        if (!state)
+            return false;
+        if (inputStatesByName_.find(name) == inputStatesByName_.end())
+        {
+            if (inputStatesByPriority_.find(priority)
+                == inputStatesByPriority_.end())
+            {
+                inputStatesByName_[name] = state;
+                inputStatesByPriority_[priority] = state;
+                state->setNumOfJoySticks(numberOfJoySticks());
+                state->setName(name);
+                state->setPriority(priority);
+                return true;
+            }
+            else
+            {
+                COUT(2) << "Warning: Could not add an InputState with the same priority '"
+                    << priority << "'." << std::endl;
+                return false;
+            }
+        }
+        else
+        {
+            COUT(2) << "Warning: Could not add an InputState with the same name '" << name << "'." << std::endl;
+            return false;
+        }
+    }
+
+    /**
+    @brief
+        Removes and destroys an input state internally.
+    @param name
+        Name of the handler.
+    @return
+        True if removal was successful, false if name was not found.
+    @remarks
+        You can't remove the internal states "empty", "calibrator" and "detector".
+        The removal process is being postponed if InputManager::tick() is currently running.
+    */
+    bool InputManager::requestDestroyState(const std::string& name)
+    {
+        if (name == "empty")
+        {
+            COUT(2) << "InputManager: Removing the empty state is not allowed!" << std::endl;
+            return false;
+        }
+        std::map<std::string, InputState*>::iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+        {
+            if (activeStates_.find(it->second->getPriority()) != activeStates_.end())
+            {
+                // The state is still active. We have to postpone
+                stateLeaveRequests_.insert(it->second);
+                stateDestroyRequests_.insert(it->second);
+            }
+            else if (this->internalState_ & Ticking)
+            {
+                // cannot remove state while ticking
+                stateDestroyRequests_.insert(it->second);
+            }
+            else
+                _destroyState(it->second);
+
+            return true;
+        }
+        return false;
+    }
+
+    /**
+    @brief
+        Returns the pointer to the requested InputState.
+    @param name
+        Unique name of the state.
+    @return
+        Pointer to the instance, 0 if name was not found.
+    */
+    InputState* InputManager::getState(const std::string& name)
+    {
+        std::map<std::string, InputState*>::iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+            return it->second;
+        else
+            return 0;
+    }
+
+    /**
+    @brief
+        Returns the current input state (there might be others active too!)
+    @return
+        The current highest prioritised active input state.
+    */
+    InputState* InputManager::getCurrentState()
+    {
+        return (*activeStates_.rbegin()).second;
+    }
+
+    /**
+    @brief
+        Activates a specific input state.
+        It might not be really activated if the priority is too low!
+    @param name
+        Unique name of the state.
+    @return
+        False if name was not found, true otherwise.
+    */
+    bool InputManager::requestEnterState(const std::string& name)
+    {
+        // get pointer from the map with all stored handlers
+        std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+        {
+            // exists
+            if (activeStates_.find(it->second->getPriority()) == activeStates_.end())
+            {
+                // not active
+                if (stateDestroyRequests_.find(it->second) == stateDestroyRequests_.end())
+                {
+                    // not scheduled for destruction
+                    // set prevents a state being added multiple times
+                    stateEnterRequests_.insert(it->second);
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+    @brief
+        Deactivates a specific input state.
+    @param name
+        Unique name of the state.
+    @return
+        False if name was not found, true otherwise.
+    */
+    bool InputManager::requestLeaveState(const std::string& name)
+    {
+        // get pointer from the map with all stored handlers
+        std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+        {
+            // exists
+            if (activeStates_.find(it->second->getPriority()) != activeStates_.end())
+            {
+                // active
+                stateLeaveRequests_.insert(it->second);
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    // ############################################################
+    // #####                Console Commands                  #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Starts joy stick calibration.
+    */
+    void InputManager::calibrate()
+    {
+        getInstance().bCalibrating_ = true;
+        getInstance().requestEnterState("calibrator");
+    }
+
+    /**
+    @brief
+        Reloads the input system
+    */
+    void InputManager::reload(bool joyStickSupport)
+    {
+        getInstance().reloadInputSystem(joyStickSupport);
+    }
+}
Index: /code/branches/physics/src/core/input/InputManager.h
===================================================================
--- /code/branches/physics/src/core/input/InputManager.h	(revision 2122)
+++ /code/branches/physics/src/core/input/InputManager.h	(revision 2122)
@@ -0,0 +1,258 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of a little Input handler that distributes everything
+    coming from OIS.
+*/
+
+#ifndef _InputManager_H__
+#define _InputManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <vector>
+#include <stack>
+#include "util/Math.h"
+#include "core/OrxonoxClass.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Helper class to realise a vector<int[4]>
+    */
+    class POVStates
+    {
+    public:
+        int& operator[](unsigned int index) { return povStates[index]; }
+        int povStates[4];
+    };
+
+    /**
+    @brief
+        Helper class to realise a vector< {int[4], int[4]} >
+    */
+    class SliderStates
+    {
+    public:
+        IntVector2 sliderStates[4];
+    };
+
+    struct JoyStickCalibration
+    {
+        int zeroStates[24];
+        float positiveCoeff[24];
+        float negativeCoeff[24];
+    };
+
+    /**
+    @brief
+        Captures and distributes mouse and keyboard input.
+    */
+    class _CoreExport InputManager
+        : public OrxonoxClass,
+        public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
+    {
+        // --> setConfigValues is private
+        friend class ClassIdentifier<InputManager>;
+
+    public:
+        enum InputManagerState
+        {
+            Uninitialised    = 0x00,
+            OISReady         = 0x01,
+            InternalsReady   = 0x02,
+            Ticking          = 0x04,
+            Calibrating      = 0x08,
+            ReloadRequest    = 0x10,
+            JoyStickSupport  = 0x20 // used with ReloadRequest to store a bool
+        };
+
+        InputManager ();
+        ~InputManager();
+
+        void initialise(size_t windowHnd, int windowWidth, int windowHeight, bool joyStickSupport = true);
+
+        void reloadInputSystem(bool joyStickSupport = true);
+
+        void clearBuffers();
+
+        unsigned int  numberOfKeyboards() { return keyboard_ ? 1 : 0; }
+        unsigned int  numberOfMice()      { return mouse_    ? 1 : 0; }
+        unsigned int  numberOfJoySticks() { return joySticksSize_; }
+
+        void setWindowExtents(const int width, const int height);
+        void setKeyDetectorCallback(const std::string& command);
+
+        template <class T>
+        T* createInputState(const std::string& name, int priority);
+
+        InputState* getState       (const std::string& name);
+        InputState* getCurrentState();
+        ExtendedInputState* getMasterInputState() { return this->stateMaster_; }
+        bool requestDestroyState   (const std::string& name);
+        bool requestEnterState     (const std::string& name);
+        bool requestLeaveState     (const std::string& name);
+
+        void tick(float dt);
+
+        static InputManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; }
+        static InputManager* getInstancePtr() { return singletonRef_s; }
+
+        // console commands
+        static void calibrate();
+        static void reload(bool joyStickSupport = true);
+
+    public: // variables
+        static EmptyHandler                 EMPTY_HANDLER;
+
+    private: // functions
+        // don't mess with a Singleton
+        InputManager (const InputManager&);
+
+        // Intenal methods
+        void _initialiseKeyboard();
+        void _initialiseMouse();
+        void _initialiseJoySticks();
+        void _configureNumberOfJoySticks();
+
+        void _destroyKeyboard();
+        void _destroyMouse();
+        void _destroyJoySticks();
+        void _destroyState(InputState* state);
+        void _clearBuffers();
+
+        void _reload(bool joyStickSupport);
+
+        void _completeCalibration();
+
+        void _fireAxis(unsigned int iJoyStick, int axis, int value);
+        unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
+
+        void _updateActiveStates();
+        bool _configureInputState(InputState* state, const std::string& name, int priority);
+
+        // input events
+        bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+        bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+        bool mouseMoved    (const OIS::MouseEvent    &arg);
+        bool keyPressed    (const OIS::KeyEvent      &arg);
+        bool keyReleased   (const OIS::KeyEvent      &arg);
+        bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+        bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+        bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+        bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+        bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+        // don't remove that! Or else add OIS as dependency library to orxonox.
+        bool vector3Moved  (const OIS::JoyStickEvent &arg, int id) { return true; }
+
+        void setConfigValues();
+
+    private: // variables
+        OIS::InputManager*                  inputSystem_;          //!< OIS input manager
+        OIS::Keyboard*                      keyboard_;             //!< OIS mouse
+        OIS::Mouse*                         mouse_;                //!< OIS keyboard
+        std::vector<OIS::JoyStick*>         joySticks_;            //!< OIS joy sticks
+        unsigned int                        joySticksSize_;
+        unsigned int                        devicesNum_;
+        size_t                              windowHnd_;            //!< Render window handle
+        InputManagerState                   internalState_;        //!< Current internal state
+
+        // some internally handled states and handlers
+        SimpleInputState*                   stateEmpty_;
+        ExtendedInputState*                 stateMaster_;          //!< Always active master input state
+        KeyDetector*                        keyDetector_;        //!< KeyDetector instance
+        InputBuffer*                        calibratorCallbackBuffer_;
+
+        std::map<std::string, InputState*>  inputStatesByName_;
+        std::map<int, InputState*>          inputStatesByPriority_;
+
+        std::set<InputState*>               stateEnterRequests_;   //!< Request to enter a new state
+        std::set<InputState*>               stateLeaveRequests_;   //!< Request to leave a running state
+        std::set<InputState*>               stateDestroyRequests_; //!< Request to destroy a state
+
+        std::map<int, InputState*>          activeStates_;
+        std::vector<InputState*>            activeStatesTop_;      //!< Current input states for joy stick events.
+        std::vector<InputState*>            activeStatesTicked_;   //!< Current input states for joy stick events.
+
+        // joystick calibration
+        //std::vector<int> marginalsMaxConfig_;
+        //std::vector<int> marginalsMinConfig_;
+        int                                 marginalsMax_[24];
+        int                                 marginalsMin_[24];
+        bool                                bCalibrated_;
+        bool                                bCalibrating_;
+
+        unsigned int                        keyboardModifiers_;    //!< Bit mask representing keyboard modifiers.
+        std::vector<POVStates>              povStates_;            //!< Keeps track of the joy stick POV states.
+        std::vector<SliderStates>           sliderStates_;         //!< Keeps track of the possibly two slider axes.
+        std::vector<JoyStickCalibration>    joySticksCalibration_; 
+
+        std::vector<Key>                    keysDown_;
+        std::vector<MouseButtonCode::ByEnum>      mouseButtonsDown_;
+        std::vector<std::vector<JoyStickButtonCode::ByEnum> >  joyStickButtonsDown_;
+
+        static std::string                  bindingCommmandString_s;
+        static InputManager*                singletonRef_s;
+    };
+
+    /**
+    @brief
+        Creates a new InputState by type, name and priority.
+        
+        You will have to use this method because the
+        c'tors and d'tors are private.
+    @remarks
+        The InputManager will take care of the state completely. That also
+        means it gets deleted when the InputManager is destroyed!
+    @param name
+        Name of the InputState when referenced as string
+    @param priority
+        Priority matters when multiple states are active. You can specify any
+        number, but 1 - 99 is preferred (99 means high).
+    */
+    template <class T>
+    T* InputManager::createInputState(const std::string& name, int priority)
+    {
+        T* state = new T;
+        if (_configureInputState(state, name, priority))
+            return state;
+        else
+        {
+            delete state;
+            return 0;
+        }
+    }
+}
+
+#endif /* _InputManager_H__ */
Index: /code/branches/physics/src/core/input/InputState.h
===================================================================
--- /code/branches/physics/src/core/input/InputState.h	(revision 2122)
+++ /code/branches/physics/src/core/input/InputState.h	(revision 2122)
@@ -0,0 +1,122 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief 
+*/
+
+#ifndef _InputState_H__
+#define _InputState_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <vector>
+#include "core/Executor.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    class _CoreExport InputState
+    {
+        friend class InputManager;
+
+    public:
+        const std::string& getName() const { return name_; }
+        int getPriority()            const { return priority_; }
+
+        bool isInputDeviceEnabled(unsigned int device)
+        {
+            if (device < bInputDeviceEnabled_.size())
+                return bInputDeviceEnabled_[device];
+            else
+                return false;
+        }
+
+        bool handlersChanged() { return this->bHandlersChanged_; }
+        void resetHandlersChanged() { bHandlersChanged_ = false; }
+
+        virtual void onEnter() { if (executorOnEnter_) (*executorOnEnter_)(); }
+        virtual void onLeave() { if (executorOnLeave_) (*executorOnLeave_)(); }
+
+        virtual void registerOnEnter(Executor* executor)      { executorOnEnter_ = executor; }
+        virtual void unRegisterOnEnter()                      { executorOnEnter_ = 0; }
+        virtual void registerOnLeave(Executor* executor)      { executorOnLeave_ = executor; }
+        virtual void unRegisterOnLeave()                      { executorOnLeave_ = 0; }
+
+        virtual void tickInput(float dt, unsigned int device) = 0;
+        virtual void tickInput(float dt) = 0;
+
+        virtual void keyPressed (const KeyEvent& evt) = 0;
+        virtual void keyReleased(const KeyEvent& evt) = 0;
+        virtual void keyHeld    (const KeyEvent& evt) = 0;
+
+        virtual void mouseButtonPressed (MouseButtonCode::ByEnum id) = 0;
+        virtual void mouseButtonReleased(MouseButtonCode::ByEnum id) = 0;
+        virtual void mouseButtonHeld    (MouseButtonCode::ByEnum id) = 0;
+        virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
+        virtual void mouseScrolled      (int abs, int rel) = 0;
+
+        virtual void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0;
+        virtual void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0;
+        virtual void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0;
+        virtual void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value) = 0;
+
+    protected:
+        InputState() : bHandlersChanged_(false), priority_(0), executorOnEnter_(0), executorOnLeave_(0) { }
+        virtual ~InputState() { }
+
+        virtual void numberOfJoySticksChanged(unsigned int n) = 0;
+        void setInputDeviceEnabled(unsigned int device, bool bEnabled)
+        {
+            if (device < bInputDeviceEnabled_.size())
+                bInputDeviceEnabled_[device] = bEnabled;
+        }
+
+        bool bHandlersChanged_;
+
+    private:
+        void setNumOfJoySticks(unsigned int n)
+        {
+            bInputDeviceEnabled_.resize(n + 2);
+            numberOfJoySticksChanged(n);
+        }
+        void setName(const std::string& name)  { name_ = name; }
+        void setPriority(int priority)         { priority_ = priority; }
+
+        std::string                                 name_;
+        int                                         priority_;
+        std::vector<bool>                           bInputDeviceEnabled_;
+
+        Executor*                                   executorOnEnter_;
+        Executor*                                   executorOnLeave_;
+    };
+}
+
+#endif /* _InputState_H__ */
Index: /code/branches/physics/src/core/input/JoyStickDeviceNumberListener.cc
===================================================================
--- /code/branches/physics/src/core/input/JoyStickDeviceNumberListener.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/JoyStickDeviceNumberListener.cc	(revision 2122)
@@ -0,0 +1,44 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the JoyStickDeviceNumberListener class.
+*/
+
+#include "JoyStickDeviceNumberListener.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    JoyStickDeviceNumberListener::JoyStickDeviceNumberListener()
+    {
+        RegisterObject(JoyStickDeviceNumberListener);
+    }
+}
Index: /code/branches/physics/src/core/input/JoyStickDeviceNumberListener.h
===================================================================
--- /code/branches/physics/src/core/input/JoyStickDeviceNumberListener.h	(revision 2122)
+++ /code/branches/physics/src/core/input/JoyStickDeviceNumberListener.h	(revision 2122)
@@ -0,0 +1,52 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief 
+*/
+
+#ifndef _JoyStickDeviceNumberListener_H__
+#define _JoyStickDeviceNumberListener_H__
+
+#include "core/CorePrereqs.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class _CoreExport JoyStickDeviceNumberListener : virtual public OrxonoxClass
+    {
+    public:
+        JoyStickDeviceNumberListener();
+        virtual ~JoyStickDeviceNumberListener() { }
+
+        virtual void JoyStickDeviceNumberChanged(unsigned int value) = 0;
+    };
+}
+
+#endif /* _JoyStickDeviceNumberListener_H__ */
Index: /code/branches/physics/src/core/input/KeyBinder.cc
===================================================================
--- /code/branches/physics/src/core/input/KeyBinder.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/KeyBinder.cc	(revision 2122)
@@ -0,0 +1,522 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the different input handlers.
+ */
+
+#include "KeyBinder.h"
+#include <fstream>
+#include <string>
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigFileManager.h"
+#include "InputCommands.h"
+#include "InputManager.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Constructor that does as little as necessary.
+    */
+    KeyBinder::KeyBinder()
+        : numberOfJoySticks_(0)
+        , deriveTime_(0.0f)
+    {
+        mouseRelative_[0] = 0;
+        mouseRelative_[1] = 0;
+        mousePosition_[0] = 0;
+        mousePosition_[1] = 0;
+
+        RegisterRootObject(KeyBinder);
+
+        // intialise all buttons and half axes to avoid creating everything with 'new'
+        // keys
+        for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
+        {
+            std::string keyname = KeyCode::ByString[i];
+            if (!keyname.empty())
+            {
+                keys_[i].name_ = std::string("Key") + keyname;
+            }
+            else
+            {
+                // some keys have name "" because the code is not occupied by OIS
+                // Use "Key_" plus the number as name to put it at the end of the config file section
+                std::string number = convertToString(i);
+                if (i < 100)
+                    number.insert(0, "0");
+                keys_[i].name_ = std::string("Key_") + number;
+            }
+            keys_[i].paramCommandBuffer_ = &paramCommandBuffer_;
+            keys_[i].groupName_ = "Keys";
+        }
+        // mouse buttons plus 4 mouse wheel buttons only 'generated' by KeyBinder
+        const char* const mouseWheelNames[] = { "Wheel1Down", "Wheel1Up", "Wheel2Down", "Wheel2Up" };
+        for (unsigned int i = 0; i < numberOfMouseButtons_; i++)
+        {
+            std::string nameSuffix;
+            if (i < MouseButtonCode::numberOfButtons)
+                nameSuffix = MouseButtonCode::ByString[i];
+            else
+                nameSuffix = mouseWheelNames[i - MouseButtonCode::numberOfButtons];
+            mouseButtons_[i].name_ = std::string("Mouse") + nameSuffix;
+            mouseButtons_[i].paramCommandBuffer_ = &paramCommandBuffer_;
+            mouseButtons_[i].groupName_ = "MouseButtons";
+        }
+        // mouse axes
+        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
+        {
+            mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i >> 1];
+            if (i & 1)
+                mouseAxes_[i].name_ += "Pos";
+            else
+                mouseAxes_[i].name_ += "Neg";
+            mouseAxes_[i].paramCommandBuffer_ = &paramCommandBuffer_;
+            mouseAxes_[i].groupName_ = "MouseAxes";
+        }
+
+        // Get a new ConfigFileType from the ConfigFileManager
+        this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
+
+        // initialise joy sticks separatly to allow for reloading
+        numberOfJoySticks_ = InputManager::getInstance().numberOfJoySticks();
+        initialiseJoyStickBindings();
+
+        // collect all Buttons and HalfAxes
+        compilePointerLists();
+
+        // set them here to use allHalfAxes_
+        setConfigValues();
+    }
+
+    /**
+    @brief
+        Destructor
+    */
+    KeyBinder::~KeyBinder()
+    {
+        // almost no destructors required because most of the arrays are static.
+        clearBindings(); // does some destruction work
+    }
+
+    /**
+    @brief
+        Loader for the key bindings, managed by config values.
+    */
+    void KeyBinder::setConfigValues()
+    {
+        SetConfigValue(analogThreshold_, 0.05f)
+            .description("Threshold for analog axes until which the state is 0.");
+        SetConfigValue(bFilterAnalogNoise_, false)
+            .description("Specifies whether to filter small analog values like joy stick fluctuations.");
+        SetConfigValue(mouseSensitivity_, 1.0f)
+            .description("Mouse sensitivity.");
+        SetConfigValue(bDeriveMouseInput_, false)
+            .description("Whether or not to derive moues movement for the absolute value.");
+        SetConfigValue(derivePeriod_, 0.05f)
+            .description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
+        SetConfigValue(mouseSensitivityDerived_, 1.0f)
+            .description("Mouse sensitivity if mouse input is derived.");
+        SetConfigValue(mouseWheelStepSize_, 120)
+            .description("Equals one step of the mousewheel.");
+        SetConfigValue(buttonThreshold_, 0.80f)
+            .description("Threshold for analog axes until which the button is not pressed.")
+            .callback(this, &KeyBinder::buttonThresholdChanged);
+    }
+
+    void KeyBinder::buttonThresholdChanged()
+    {
+        for (unsigned int i = 0; i < allHalfAxes_.size(); i++)
+            if (!allHalfAxes_[i]->bButtonThresholdUser_)
+                allHalfAxes_[i]->buttonThreshold_ = this->buttonThreshold_;
+    }
+
+    void KeyBinder::JoyStickDeviceNumberChanged(unsigned int value)
+    {
+        unsigned int oldValue = numberOfJoySticks_;
+        numberOfJoySticks_ = value;
+
+        // initialise joy stick bindings
+        initialiseJoyStickBindings();
+
+        // collect all Buttons and HalfAxes again
+        compilePointerLists();
+
+        // load the bindings if required
+        if (configFile_ != ConfigFileType::NoType)
+        {
+            for (unsigned int iDev = oldValue; iDev < numberOfJoySticks_; ++iDev)
+            {
+                for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i)
+                    joyStickButtons_[iDev][i].readConfigValue(this->configFile_);
+                for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i)
+                    joyStickAxes_[iDev][i].readConfigValue(this->configFile_);
+            }
+        }
+
+        // Set the button threshold for potential new axes
+        buttonThresholdChanged();
+    }
+
+    void KeyBinder::initialiseJoyStickBindings()
+    {
+        this->joyStickAxes_.resize(numberOfJoySticks_);
+        this->joyStickButtons_.resize(numberOfJoySticks_);
+
+        // reinitialise all joy stick binings (doesn't overwrite the old ones)
+        for (unsigned int iDev = 0; iDev < numberOfJoySticks_; iDev++)
+        {
+            std::string deviceNumber = convertToString(iDev);
+            // joy stick buttons
+            for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
+            {
+                joyStickButtons_[iDev][i].name_ = std::string("JoyStick") + deviceNumber + JoyStickButtonCode::ByString[i];
+                joyStickButtons_[iDev][i].paramCommandBuffer_ = &paramCommandBuffer_;
+                joyStickButtons_[iDev][i].groupName_ = std::string("JoyStick") + deviceNumber + "Buttons";
+            }
+            // joy stick axes
+            for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
+            {
+                joyStickAxes_[iDev][i].name_ = std::string("JoyStick") + deviceNumber + JoyStickAxisCode::ByString[i >> 1];
+                if (i & 1)
+                    joyStickAxes_[iDev][i].name_ += "Pos";
+                else
+                    joyStickAxes_[iDev][i].name_ += "Neg";
+                joyStickAxes_[iDev][i].paramCommandBuffer_ = &paramCommandBuffer_;
+                joyStickAxes_[iDev][i].groupName_ = std::string("JoyStick") + deviceNumber + "Axes";
+            }
+        }
+    }
+
+    void KeyBinder::compilePointerLists()
+    {
+        allButtons_.clear();
+        allHalfAxes_.clear();
+
+        for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
+            allButtons_[keys_[i].name_] = keys_ + i;
+        for (unsigned int i = 0; i < numberOfMouseButtons_; i++)
+            allButtons_[mouseButtons_[i].name_] = mouseButtons_ + i;
+        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
+        {
+            allButtons_[mouseAxes_[i].name_] = mouseAxes_ + i;
+            allHalfAxes_.push_back(mouseAxes_ + i);
+        }
+        for (unsigned int iDev = 0; iDev < numberOfJoySticks_; iDev++)
+        {
+            for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
+                allButtons_[joyStickButtons_[iDev][i].name_] = &(joyStickButtons_[iDev][i]);
+            for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
+            {
+                allButtons_[joyStickAxes_[iDev][i].name_] = &(joyStickAxes_[iDev][i]);
+                allHalfAxes_.push_back(&(joyStickAxes_[iDev][i]));
+            }
+        }
+    }
+
+    /**
+    @brief
+        Loads the key and button bindings.
+    @return
+        True if loading succeeded.
+    */
+    void KeyBinder::loadBindings(const std::string& filename, const std::string& defaultFilename)
+    {
+        COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
+
+        if (filename.empty())
+            return;
+
+        // get bindings from default file if filename doesn't exist.
+        std::ifstream infile;
+        infile.open(filename.c_str());
+        if (!infile)
+        {
+            ConfigFileManager::getInstance().setFilename(this->configFile_, defaultFilename);
+            ConfigFileManager::getInstance().saveAs(this->configFile_, filename);
+        }
+        else
+            infile.close();
+        ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
+
+        // Parse bindings and create the ConfigValueContainers if necessary
+        clearBindings();
+        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
+            it->second->readConfigValue(this->configFile_);
+
+        COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
+    }
+
+    bool KeyBinder::setBinding(const std::string& binding, const std::string& name, bool bTemporary)
+    {
+        std::map<std::string, Button*>::iterator it = allButtons_.find(name);
+        if (it != allButtons_.end())
+        {
+            if (bTemporary)
+                it->second->configContainer_->tset(binding);
+            else
+                it->second->configContainer_->set(binding);
+            it->second->configContainer_->getValue(&(it->second->bindingString_), it->second);
+            return true;
+        }
+        else
+        {
+            COUT(2) << "Could not find key/button/axis with name '" << name << "'." << std::endl;
+            return false;
+        }
+    }
+
+    /**
+    @brief
+        Overwrites all bindings with ""
+    */
+    void KeyBinder::clearBindings()
+    {
+        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
+            it->second->clear();
+
+        for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+            delete paramCommandBuffer_[i];
+        paramCommandBuffer_.clear();
+    }
+
+    void KeyBinder::resetJoyStickAxes()
+    {
+        for (unsigned int iDev = 0; iDev < numberOfJoySticks_; ++iDev)
+        {
+            for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
+            {
+                joyStickAxes_[iDev][i].absVal_ = 0.0f;
+                joyStickAxes_[iDev][i].relVal_ = 0.0f;
+            }
+        }
+    }
+
+    void KeyBinder::tickMouse(float dt)
+    {
+        if (bDeriveMouseInput_)
+        {
+            // only update when derive dt has passed
+            if (deriveTime_ > derivePeriod_)
+            {
+                for (int i = 0; i < 2; i++)
+                {
+                    if (mouseRelative_[i] > 0)
+                    {
+                        mouseAxes_[2*i + 0].absVal_
+                            =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+                        mouseAxes_[2*i + 1].absVal_ = 0.0f;
+                    }
+                    else if (mouseRelative_[i] < 0)
+                    {
+                        mouseAxes_[2*i + 0].absVal_ = 0.0f;
+                        mouseAxes_[2*i + 1].absVal_
+                            = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+                    }
+                    else
+                    {
+                        mouseAxes_[2*i + 0].absVal_ = 0.0f;
+                        mouseAxes_[2*i + 1].absVal_ = 0.0f;
+                    }
+                    mouseRelative_[i] = 0;
+                    mouseAxes_[2*i + 0].hasChanged_ = true;
+                    mouseAxes_[2*i + 1].hasChanged_ = true;
+                }
+                deriveTime_ = 0.0f;
+            }
+            else
+                deriveTime_ += dt;
+        }
+
+        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
+        {
+            // Why dividing relative value by dt? The reason lies in the simple fact, that when you
+            // press a button that has relative movement, that value has to be multiplied by dt to be
+            // frame rate independant. This can easily (and only) be done in tickInput(float).
+            // Hence we need to divide by dt here for the mouse to compensate, because the relative
+            // move movements have nothing to do with dt.
+            if (dt != 0.0f)
+            {
+                // just ignore if dt == 0.0 because we have multiplied by 0.0 anyway..
+                mouseAxes_[i].relVal_ /= dt;
+            }
+
+            tickHalfAxis(mouseAxes_[i]);
+        }
+    }
+
+    void KeyBinder::tickJoyStick(float dt, unsigned int joyStick)
+    {
+        for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
+        {
+            tickHalfAxis(joyStickAxes_[joyStick][i]);
+        }
+    }
+
+    void KeyBinder::tickHalfAxis(HalfAxis& halfAxis)
+    {
+        // button mode
+        // TODO: optimize out all the half axes that don't act as a button at the moment
+        if (halfAxis.hasChanged_)
+        {
+            if (!halfAxis.pressed_ && halfAxis.absVal_ > halfAxis.buttonThreshold_)
+            {
+                // key pressed event
+                halfAxis.pressed_ = true;
+                if (halfAxis.nCommands_[KeybindMode::OnPress])
+                    halfAxis.execute(KeybindMode::OnPress);
+            }
+            else if (halfAxis.pressed_ && halfAxis.absVal_ < halfAxis.buttonThreshold_)
+            {
+                // key released event
+                halfAxis.pressed_ = false;
+                if (halfAxis.nCommands_[KeybindMode::OnRelease])
+                    halfAxis.execute(KeybindMode::OnRelease);
+            }
+            halfAxis.hasChanged_ = false;
+        }
+
+        if (halfAxis.pressed_)
+        {
+            // key held event
+            if (halfAxis.nCommands_[KeybindMode::OnHold])
+                halfAxis.execute(KeybindMode::OnHold);
+        }
+
+        // these are the actually useful axis bindings for analog input
+        if (!bFilterAnalogNoise_ || halfAxis.relVal_ > analogThreshold_ || halfAxis.absVal_ > analogThreshold_)
+        {
+            halfAxis.execute();
+        }
+    }
+
+    /**
+    @brief
+        Event handler for the mouseMoved Event.
+    @param e
+        Mouse state information
+    */
+    void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize)
+    {
+        // y axis of mouse input is inverted
+        int rel[] = { rel_.x, -rel_.y };
+
+        if (bDeriveMouseInput_)
+        {
+            mouseRelative_[0] += rel[0];
+            mouseRelative_[1] += rel[1];
+        }
+        else
+        {
+            for (int i = 0; i < 2; i++)
+            {
+                if (rel[i]) // performance opt. if rel[i] == 0
+                {
+                    // write absolute values
+                    mouseAxes_[2*i + 0].hasChanged_ = true;
+                    mouseAxes_[2*i + 1].hasChanged_ = true;
+                    mousePosition_[i] += rel[i];
+
+                    // clip absolute position
+                    if (mousePosition_[i] > mouseClippingSize_)
+                        mousePosition_[i] =  mouseClippingSize_;
+                    if (mousePosition_[i] < -mouseClippingSize_)
+                        mousePosition_[i] = -mouseClippingSize_;
+
+                    if (mousePosition_[i] >= 0)
+                    {
+                        mouseAxes_[2*i + 0].absVal_ =   mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
+                        mouseAxes_[2*i + 1].absVal_ =  0.0f;
+                    }
+                    else
+                    {
+                        mouseAxes_[2*i + 0].absVal_ =  0.0f;
+                        mouseAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
+                    }
+                }
+            }
+        }
+
+        // relative
+        for (int i = 0; i < 2; i++)
+        {
+            if (rel[i] > 0)
+                mouseAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
+            else
+                mouseAxes_[1 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
+        }
+    }
+
+    /**
+    @brief Event handler for the mouseScrolled Event.
+    @param e Mouse state information
+    */
+    void KeyBinder::mouseScrolled(int abs, int rel)
+    {
+        if (rel > 0)
+            for (int i = 0; i < rel/mouseWheelStepSize_; i++)
+                mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
+        else
+            for (int i = 0; i < -rel/mouseWheelStepSize_; i++)
+                mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
+    }
+
+    void KeyBinder::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
+    {
+        int i = axis * 2;
+        if (value >= 0)
+        {
+            joyStickAxes_[joyStickID][i].absVal_ = value;
+            joyStickAxes_[joyStickID][i].relVal_ = value;
+            joyStickAxes_[joyStickID][i].hasChanged_ = true;
+            if (joyStickAxes_[joyStickID][i + 1].absVal_ > 0.0f)
+            {
+                joyStickAxes_[joyStickID][i + 1].absVal_ = -0.0f;
+                joyStickAxes_[joyStickID][i + 1].relVal_ = -0.0f;
+                joyStickAxes_[joyStickID][i + 1].hasChanged_ = true;
+            }
+        }
+        else
+        {
+            joyStickAxes_[joyStickID][i + 1].absVal_ = -value;
+            joyStickAxes_[joyStickID][i + 1].relVal_ = -value;
+            joyStickAxes_[joyStickID][i + 1].hasChanged_ = true;
+            if (joyStickAxes_[joyStickID][i].absVal_ > 0.0f)
+            {
+                joyStickAxes_[joyStickID][i].absVal_ = -0.0f;
+                joyStickAxes_[joyStickID][i].relVal_ = -0.0f;
+                joyStickAxes_[joyStickID][i].hasChanged_ = true;
+            }
+        }
+    }
+}
Index: /code/branches/physics/src/core/input/KeyBinder.h
===================================================================
--- /code/branches/physics/src/core/input/KeyBinder.h	(revision 2122)
+++ /code/branches/physics/src/core/input/KeyBinder.h	(revision 2122)
@@ -0,0 +1,216 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Different definitions of input processing.
+*/
+
+#ifndef _KeyBinder_H__
+#define _KeyBinder_H__
+
+#include "core/CorePrereqs.h"
+
+#include <vector>
+#include "InputInterfaces.h"
+#include "Button.h"
+#include "HalfAxis.h"
+#include "InputCommands.h"
+#include "JoyStickDeviceNumberListener.h"
+#include "core/ConfigFileManager.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Handles mouse, keyboard and joy stick input while in the actual game mode.
+        Manages the key bindings.
+    */
+    class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler,
+                                  public JoyStickDeviceNumberListener
+    {
+    public:
+        KeyBinder ();
+        virtual ~KeyBinder();
+
+        void loadBindings(const std::string& filename, const std::string& defaultFilename);
+        void clearBindings();
+        bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
+        void setConfigValues();
+        void resetJoyStickAxes();
+
+    protected: // functions
+        void tickInput(float dt);
+        void tickKey(float dt) { }
+        void tickMouse(float dt);
+        void tickJoyStick(float dt, unsigned int joyStick);
+        // internal
+        void tickHalfAxis(HalfAxis& halfAxis);
+
+        void buttonThresholdChanged();
+        // from JoyStickDeviceNumberListener interface
+        virtual void JoyStickDeviceNumberChanged(unsigned int value);
+        void initialiseJoyStickBindings();
+        void compilePointerLists();
+
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt);
+        void keyHeld    (const KeyEvent& evt);
+
+        void mouseButtonPressed (MouseButtonCode::ByEnum id);
+        void mouseButtonReleased(MouseButtonCode::ByEnum id);
+        void mouseButtonHeld    (MouseButtonCode::ByEnum id);
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
+        void mouseScrolled      (int abs, int rel);
+
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);
+
+    protected: // variables
+        //! Currently active joy sticks
+        unsigned int numberOfJoySticks_;
+
+        //! Actual key bindings for keys on the keyboard
+        Button keys_            [KeyCode::numberOfKeys];
+        //! Number of mouse buttons in KeyBinder (+4)
+        static const unsigned int numberOfMouseButtons_ = MouseButtonCode::numberOfButtons + 4;
+        //! Actual key bindings for mouse buttons including the wheel(s)
+        Button mouseButtons_    [numberOfMouseButtons_];
+        //! Actual key bindings for mouse axes
+        HalfAxis mouseAxes_     [MouseAxisCode::numberOfAxes * 2];
+
+        //! Helper class to use something like std:vector<Button[64]>
+        struct JoyStickButtonVector
+        {
+            Button& operator[](unsigned int index) { return buttons[index]; }
+            Button buttons[JoyStickButtonCode::numberOfButtons];
+        };
+        //! Actual key bindings for joy stick buttons
+        std::vector<JoyStickButtonVector> joyStickButtons_;
+        //! Helper class to use something like std:vector<HalfAxis[48]>
+        struct JoyStickAxisVector
+        {
+            HalfAxis& operator[](unsigned int index) { return halfAxes[index]; }
+            HalfAxis halfAxes[JoyStickAxisCode::numberOfAxes * 2];
+        };
+        //! Actual key bindings for joy stick axes (and sliders)
+        std::vector<JoyStickAxisVector> joyStickAxes_;
+
+        //! Pointer map with all Buttons, including half axes
+        std::map<std::string, Button*> allButtons_;
+        //! Pointer list with all half axes
+        std::vector<HalfAxis*> allHalfAxes_;
+
+        /**
+        @brief
+            Commands that have additional parameters (axes) are executed at the end of
+            the tick() so that all values can be buffered for single execution.
+        */
+        std::vector<BufferedParamCommand*> paramCommandBuffer_;
+
+        //! Keeps track of the absolute mouse value (incl. scroll wheel)
+        int mousePosition_[2];
+        //! Used to derive mouse input if requested
+        int mouseRelative_[2];
+        float deriveTime_;
+
+        //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
+        ConfigFileType configFile_;
+
+    private:
+        //##### ConfigValues #####
+        //! Whether to filter small value analog input
+        bool bFilterAnalogNoise_;
+        //! Threshold for analog triggers until which the state is 0.
+        float analogThreshold_;
+        //! Threshold for analog triggers until which the button is not pressed.
+        float buttonThreshold_;
+        //! Derive mouse input for absolute values?
+        bool bDeriveMouseInput_;
+        //! Accuracy of the mouse input deriver. The higher the more precise, but laggier.
+        float derivePeriod_;
+        //! mouse sensitivity
+        float mouseSensitivity_;
+        //! mouse sensitivity if mouse input is derived
+        float mouseSensitivityDerived_;
+        //! Equals one step of the mousewheel
+        int mouseWheelStepSize_;
+
+        //##### Constant config variables #####
+        // Use some value at about 1000. This can be configured with mouseSensitivity_ anyway.
+        static const int mouseClippingSize_ = 1024;
+    };
+
+    inline void KeyBinder::keyPressed (const KeyEvent& evt)
+    { keys_[evt.key].execute(KeybindMode::OnPress); }
+
+    inline void KeyBinder::keyReleased(const KeyEvent& evt)
+    { keys_[evt.key].execute(KeybindMode::OnRelease); }
+
+    inline void KeyBinder::keyHeld    (const KeyEvent& evt)
+    { keys_[evt.key].execute(KeybindMode::OnHold); }
+
+
+    inline void KeyBinder::mouseButtonPressed (MouseButtonCode::ByEnum id)
+    { mouseButtons_[id].execute(KeybindMode::OnPress); }
+
+    inline void KeyBinder::mouseButtonReleased(MouseButtonCode::ByEnum id)
+    { mouseButtons_[id].execute(KeybindMode::OnRelease); }
+
+    inline void KeyBinder::mouseButtonHeld    (MouseButtonCode::ByEnum id)
+    { mouseButtons_[id].execute(KeybindMode::OnHold); }
+
+
+    inline void KeyBinder::joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    { joyStickButtons_[joyStickID][id].execute(KeybindMode::OnPress); }
+
+    inline void KeyBinder::joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    { joyStickButtons_[joyStickID][id].execute(KeybindMode::OnRelease); }
+
+    inline void KeyBinder::joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    { joyStickButtons_[joyStickID][id].execute(KeybindMode::OnHold); }
+
+    inline void KeyBinder::tickInput(float dt)
+    {
+        // execute all buffered bindings (additional parameter)
+        for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+        {
+            paramCommandBuffer_[i]->rel_ *= dt;
+            paramCommandBuffer_[i]->execute();
+        }
+
+        // always reset the relative movement of the mouse
+        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
+            mouseAxes_[i].relVal_ = 0.0f;
+    }
+}
+
+#endif /* _KeyBinder_H__ */
Index: /code/branches/physics/src/core/input/KeyDetector.cc
===================================================================
--- /code/branches/physics/src/core/input/KeyDetector.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/KeyDetector.cc	(revision 2122)
@@ -0,0 +1,82 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the different input handlers.
+*/
+
+#include "KeyDetector.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/CommandExecutor.h"
+#include "core/CommandEvaluation.h"
+#include "InputCommands.h"
+#include "Button.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Constructor
+    */
+    KeyDetector::KeyDetector()
+    {
+        RegisterObject(KeyDetector);
+    }
+
+    /**
+    @brief
+        Destructor
+    */
+    KeyDetector::~KeyDetector()
+    {
+    }
+
+    /**
+    @brief
+        Assigns all the buttons 'command' plus the button's name.
+    */
+    void KeyDetector::setCallbackCommand(const std::string& command)
+    {
+        callbackCommand_ = command;
+        clearBindings();
+        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
+        {
+            it->second->bindingString_ = callbackCommand_ + it->second->name_;
+            it->second->parse();
+        }
+    }
+
+    void KeyDetector::JoyStickDeviceNumberChanged(unsigned int value)
+    {
+        KeyBinder::JoyStickDeviceNumberChanged(value);
+        setCallbackCommand(callbackCommand_);
+    }
+}
Index: /code/branches/physics/src/core/input/KeyDetector.h
===================================================================
--- /code/branches/physics/src/core/input/KeyDetector.h	(revision 2122)
+++ /code/branches/physics/src/core/input/KeyDetector.h	(revision 2122)
@@ -0,0 +1,57 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Different definitions of input processing.
+*/
+
+#ifndef _KeyDetector_H__
+#define _KeyDetector_H__
+
+#include "core/CorePrereqs.h"
+
+#include "KeyBinder.h"
+
+namespace orxonox
+{
+    class _CoreExport KeyDetector : public KeyBinder
+    {
+    public:
+        KeyDetector();
+        ~KeyDetector();
+        void setCallbackCommand(const std::string& command);
+        void JoyStickDeviceNumberChanged(unsigned int value);
+
+    private:
+        std::string callbackCommand_;
+    };
+}
+
+#endif /* _KeyDetector_H__ */
Index: /code/branches/physics/src/core/input/SimpleInputState.cc
===================================================================
--- /code/branches/physics/src/core/input/SimpleInputState.cc	(revision 2122)
+++ /code/branches/physics/src/core/input/SimpleInputState.cc	(revision 2122)
@@ -0,0 +1,150 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the SimpleInputState class.
+*/
+
+#include "SimpleInputState.h"
+
+namespace orxonox
+{
+    SimpleInputState::SimpleInputState()
+        : keyHandler_(0)
+        , mouseHandler_(0)
+        , joyStickHandlerAll_(0)
+    {
+    }
+
+    void SimpleInputState::numberOfJoySticksChanged(unsigned int n)
+    {
+        unsigned int oldSize = joyStickHandler_.size();
+        joyStickHandler_.resize(n);
+
+        if (n > oldSize)
+        {
+            // we have to add the handler in joyStickHandlerAll_ to the joyStickHandler_[>n]
+            for (unsigned int i = oldSize; i < n; ++i)
+            {
+                joyStickHandler_[i] = joyStickHandlerAll_;
+            }
+        }
+        update();
+    }
+
+    void SimpleInputState::keyPressed(const KeyEvent& evt)
+    {
+        if (keyHandler_)
+            keyHandler_->keyPressed(evt);
+    }
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @param joyStickID
+        ID of the joy stick
+    @return
+        True if added, false otherwise.
+    */
+    bool SimpleInputState::setJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID)
+    {
+        if (joyStickID >= joyStickHandler_.size())
+            return false;
+
+        joyStickHandler_[joyStickID] = handler;
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool SimpleInputState::setJoyStickHandler(JoyStickHandler* handler)
+    {
+        if (handler == joyStickHandlerAll_)
+            return false;
+
+        joyStickHandlerAll_ = handler;
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandler_.size(); ++iJoyStick)
+            setJoyStickHandler(handler, iJoyStick);
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Adds a handler of any kind. dynamic_cast determines to which list it is added.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool SimpleInputState::setHandler(InputHandler* handler)
+    {
+        setKeyHandler(dynamic_cast<KeyHandler*>(handler));
+        setMouseHandler(dynamic_cast<MouseHandler*>(handler));
+        return setJoyStickHandler(dynamic_cast<JoyStickHandler*>(handler));
+    }
+
+    void SimpleInputState::update()
+    {
+        // we can use a set to have a list of unique pointers (an object can implement all 3 handlers)
+        std::set<InputHandler*> tempSet;
+        if (keyHandler_)
+            tempSet.insert(keyHandler_);
+        if (mouseHandler_)
+            tempSet.insert(mouseHandler_);
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandler_.size(); iJoyStick++)
+            if (joyStickHandler_[iJoyStick])
+                tempSet.insert(joyStickHandler_[iJoyStick]);
+
+        // copy the content of the map back to the actual vector
+        allHandlers_.clear();
+        for (std::set<InputHandler*>::const_iterator itHandler = tempSet.begin();
+            itHandler != tempSet.end(); itHandler++)
+            allHandlers_.push_back(*itHandler);
+
+        // update the deviceEnabled options
+        setInputDeviceEnabled(InputDevice::Keyboard, (keyHandler_ != 0));
+        setInputDeviceEnabled(InputDevice::Mouse, (mouseHandler_ != 0));
+        for (unsigned int i = 0; i < joyStickHandler_.size(); ++i)
+            setInputDeviceEnabled(2 + i, (joyStickHandler_[i] != 0));
+
+        // inform InputManager that there might be changes in EMPTY_HANDLER situation
+        bHandlersChanged_ = true;
+    }
+}
Index: /code/branches/physics/src/core/input/SimpleInputState.h
===================================================================
--- /code/branches/physics/src/core/input/SimpleInputState.h	(revision 2122)
+++ /code/branches/physics/src/core/input/SimpleInputState.h	(revision 2122)
@@ -0,0 +1,189 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief 
+*/
+
+#ifndef _SimpleInputState_H__
+#define _SimpleInputState_H__
+
+#include "core/CorePrereqs.h"
+
+#include <vector>
+#include <cassert>
+#include "InputInterfaces.h"
+#include "InputState.h"
+
+namespace orxonox
+{
+    class _CoreExport SimpleInputState : public InputState
+    {
+        friend class InputManager;
+
+    public:
+        void setKeyHandler        (KeyHandler* handler) { keyHandler_ = handler; update(); }
+        void setMouseHandler      (MouseHandler* handler) { mouseHandler_ = handler; update(); }
+        bool setJoyStickHandler   (JoyStickHandler* handler, unsigned int joyStickID);
+        bool setJoyStickHandler   (JoyStickHandler* handler);
+        bool setHandler(InputHandler* handler);
+
+    private:
+        SimpleInputState();
+        ~SimpleInputState() { }
+
+        void tickInput(float dt);
+        void tickInput(float dt, unsigned int device);
+
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt);
+        void keyHeld    (const KeyEvent& evt);
+
+        void mouseButtonPressed (MouseButtonCode::ByEnum id);
+        void mouseButtonReleased(MouseButtonCode::ByEnum id);
+        void mouseButtonHeld    (MouseButtonCode::ByEnum id);
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
+        void mouseScrolled      (int abs, int rel);
+
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);
+
+        void update();
+        void numberOfJoySticksChanged(unsigned int n);
+
+        KeyHandler*                   keyHandler_;
+        MouseHandler*                 mouseHandler_;
+        std::vector<JoyStickHandler*> joyStickHandler_;
+        JoyStickHandler*              joyStickHandlerAll_;
+        std::vector<InputHandler*>    allHandlers_;
+    };
+
+    inline void SimpleInputState::tickInput(float dt)
+    {
+        for (unsigned int i = 0; i < allHandlers_.size(); ++i)
+        {
+            allHandlers_[i]->tickInput(dt);
+        }
+    }
+
+    inline void SimpleInputState::tickInput(float dt, unsigned int device)
+    {
+        switch (device)
+        {
+        case InputDevice::Keyboard:
+            if (keyHandler_)
+                keyHandler_->tickKey(dt);
+            break;
+
+        case InputDevice::Mouse:
+            if (mouseHandler_)
+                mouseHandler_->tickMouse(dt);
+            break;
+
+        default: // joy sticks
+            if (joyStickHandler_[device - 2])
+                joyStickHandler_[device - 2]->tickJoyStick(dt, device - 2);
+            break;
+        }
+    }
+
+    inline void SimpleInputState::keyReleased(const KeyEvent& evt)
+    {
+        if (keyHandler_)
+            keyHandler_->keyReleased(evt);
+    }
+
+    inline void SimpleInputState::keyHeld(const KeyEvent& evt)
+    {
+        if (keyHandler_)
+            keyHandler_->keyHeld(evt);
+    }
+
+    inline void SimpleInputState::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseMoved(abs, rel, clippingSize);
+    }
+
+    inline void SimpleInputState::mouseScrolled(int abs, int rel)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseScrolled(abs, rel);
+    }
+
+    inline void SimpleInputState::mouseButtonPressed(MouseButtonCode::ByEnum id)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseButtonPressed(id);
+    }
+
+    inline void SimpleInputState::mouseButtonReleased(MouseButtonCode::ByEnum id)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseButtonReleased(id);
+    }
+
+    inline void SimpleInputState::mouseButtonHeld(MouseButtonCode::ByEnum id)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseButtonHeld(id);
+    }
+
+    inline void SimpleInputState::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickAxisMoved(joyStickID, axis, value);
+    }
+
+    inline void SimpleInputState::joyStickButtonPressed(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickButtonPressed(joyStickID, id);
+    }
+
+    inline void SimpleInputState::joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickButtonReleased(joyStickID, id);
+    }
+
+    inline void SimpleInputState::joyStickButtonHeld(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickButtonHeld(joyStickID, id);
+    }
+}
+
+#endif /* _SimpleInputState_H__ */
Index: /code/branches/physics/src/core/tolua/tolua.pkg
===================================================================
--- /code/branches/physics/src/core/tolua/tolua.pkg	(revision 2122)
+++ /code/branches/physics/src/core/tolua/tolua.pkg	(revision 2122)
@@ -0,0 +1,2 @@
+$cfile "../../src/core/LuaBind.h"
+$cfile "../../src/core/CommandExecutor.h"
Index: /code/branches/physics/src/cpptcl/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/cpptcl/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/cpptcl/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,5 @@
+ADD_LIBRARY(cpptcl_orxonox SHARED CppTcl.cc)
+
+TARGET_LINK_LIBRARIES(cpptcl_orxonox
+  ${TCL_LIBRARY}
+)
Index: /code/branches/physics/src/cpptcl/CREDITS
===================================================================
--- /code/branches/physics/src/cpptcl/CREDITS	(revision 2122)
+++ /code/branches/physics/src/cpptcl/CREDITS	(revision 2122)
@@ -0,0 +1,11 @@
+I would like to thank you very much for your contributions:
+
+---
+Alexey Pakhunov provided patches with various bugfixes and enhancements.
+His patches were used in the 1.1.2 release.
+
+---
+Christoph Pesch provided a small patch for the g++ 3.2 compiler.
+
+After the 1.1.0 release, Christoph provided also a patch for newer g++ 3.4.3.
+(included in 1.1.1)
Index: /code/branches/physics/src/cpptcl/CppTcl.cc
===================================================================
--- /code/branches/physics/src/cpptcl/CppTcl.cc	(revision 2122)
+++ /code/branches/physics/src/cpptcl/CppTcl.cc	(revision 2122)
@@ -0,0 +1,1099 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+#include "CppTcl.h"
+#include <map>
+#include <sstream>
+#include <iterator>
+
+
+using namespace Tcl;
+using namespace Tcl::details;
+using namespace std;
+using namespace boost;
+
+
+result::result(Tcl_Interp *interp) : interp_(interp) {}
+
+result::operator bool() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     int val, cc;
+     cc = Tcl_GetBooleanFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return static_cast<bool>(val);
+}
+
+result::operator double() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     double val;
+     int cc = Tcl_GetDoubleFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator int() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     int val, cc;
+     cc = Tcl_GetIntFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator long() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     long val;
+     int cc;
+     cc = Tcl_GetLongFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator string() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+     return Tcl_GetString(obj);
+}
+
+result::operator object() const
+{
+     return object(Tcl_GetObjResult(interp_));
+}
+
+
+void details::set_result(Tcl_Interp *interp, bool b)
+{
+     Tcl_SetObjResult(interp, Tcl_NewBooleanObj(b));
+}
+
+void details::set_result(Tcl_Interp *interp, int i)
+{
+     Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
+}
+
+void details::set_result(Tcl_Interp *interp, long i)
+{
+     Tcl_SetObjResult(interp, Tcl_NewLongObj(i));
+}
+
+void details::set_result(Tcl_Interp *interp, double d)
+{
+     Tcl_SetObjResult(interp, Tcl_NewDoubleObj(d));
+}
+
+void details::set_result(Tcl_Interp *interp, string const &s)
+{
+     Tcl_SetObjResult(interp,
+          Tcl_NewStringObj(s.data(), static_cast<int>(s.size())));
+}
+
+void details::set_result(Tcl_Interp *interp, void *p)
+{
+     ostringstream ss;
+     ss << 'p' << p;
+     string s(ss.str());
+
+     Tcl_SetObjResult(interp,
+          Tcl_NewStringObj(s.data(), static_cast<int>(s.size())));
+}
+
+void details::set_result(Tcl_Interp *interp, object const &o)
+{
+     Tcl_SetObjResult(interp, o.get_object());
+}
+
+
+void details::check_params_no(int objc, int required)
+{
+     if (objc < required)
+     {
+          throw tcl_error("Too few arguments.");
+     }
+}
+
+object details::get_var_params(Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[],
+     int from, policies const &pol)
+{
+     object o;
+     if (pol.variadic_)
+     {
+          check_params_no(objc, from);
+          o.assign(objv + from, objv + objc);
+     }
+     else
+     {
+          check_params_no(objc, from + 1);
+          o.assign(objv[from]);
+     }
+
+     o.set_interp(interp);
+
+     return o;
+}
+
+
+namespace // anonymous
+{
+
+// map of polymorphic callbacks
+typedef map<string, shared_ptr<callback_base> > callback_interp_map;
+typedef map<Tcl_Interp *, callback_interp_map> callback_map;
+
+callback_map callbacks;
+callback_map constructors;
+
+// map of call policies
+typedef map<string, policies> policies_interp_map;
+typedef map<Tcl_Interp *, policies_interp_map> policies_map;
+
+policies_map call_policies;
+
+// map of object handlers
+typedef map<string, shared_ptr<class_handler_base> > class_interp_map;
+typedef map<Tcl_Interp *, class_interp_map> class_handlers_map;
+
+class_handlers_map class_handlers;
+
+
+// helper for finding call policies - returns true when found
+bool find_policies(Tcl_Interp *interp, string const &cmdName,
+     policies_interp_map::iterator &piti)
+{
+     policies_map::iterator pit = call_policies.find(interp);
+     if (pit == call_policies.end())
+     {
+          return false;
+     }
+
+     piti = pit->second.find(cmdName);
+     return piti != pit->second.end();
+}
+
+extern "C"
+int object_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[]);
+
+// helper function for post-processing call policies
+// for both free functions (isMethod == false)
+// and class methods (isMethod == true)
+void post_process_policies(Tcl_Interp *interp, policies &pol,
+     Tcl_Obj * CONST objv[], bool isMethod)
+{
+     // check if it is a factory
+     if (!pol.factory_.empty())
+     {
+          class_handlers_map::iterator it = class_handlers.find(interp);
+          if (it == class_handlers.end())
+          {
+               throw tcl_error(
+                    "Factory was registered for unknown class.");
+          }
+
+          class_interp_map::iterator oit = it->second.find(pol.factory_);
+          if (oit == it->second.end())
+          {
+               throw tcl_error(
+                    "Factory was registered for unknown class.");
+          }
+
+          class_handler_base *chb = oit->second.get();
+
+          // register a new command for the object returned
+          // by this factory function
+          // if everything went OK, the result is the address of the
+          // new object in the 'pXXX' form
+          // - the new command will be created with this name
+
+          Tcl_CreateObjCommand(interp,
+               Tcl_GetString(Tcl_GetObjResult(interp)),
+               object_handler, static_cast<ClientData>(chb), 0);
+     }
+
+     // process all declared sinks
+     // - unregister all object commands that envelopes the pointers
+     for (vector<int>::iterator s = pol.sinks_.begin();
+          s != pol.sinks_.end(); ++s)
+     {
+          if (isMethod == false)
+          {
+               // example: if there is a declared sink at parameter 3,
+               // and the Tcl command was:
+               // % fun par1 par2 PAR3 par4
+               // then the index 3 correctly points into the objv array
+
+               int index = *s;
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[index]));
+          }
+          else
+          {
+               // example: if there is a declared sink at parameter 3,
+               // and the Tcl command was:
+               // % $p method par1 par2 PAR3 par4
+               // then the index 3 needs to be incremented
+               // in order correctly point into the 4th index of objv array
+
+               int index = *s + 1;
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[index]));
+          }
+     }
+}
+
+// actual functions handling various callbacks
+
+// generic callback handler
+extern "C"
+int callback_handler(ClientData, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     callback_map::iterator it = callbacks.find(interp);
+     if (it == callbacks.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong interpreter?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     string cmdName(Tcl_GetString(objv[0]));
+     callback_interp_map::iterator iti = it->second.find(cmdName);
+     if (iti == it->second.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong cmd name?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_map::iterator pit = call_policies.find(interp);
+     if (pit == call_policies.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_interp_map::iterator piti;
+     if (find_policies(interp, cmdName, piti) == false)
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies &pol = piti->second;
+
+     try
+     {
+          iti->second->invoke(interp, objc, objv, pol);
+
+          post_process_policies(interp, pol, objv, false);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+// generic "object" command handler
+extern "C"
+int object_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     // here, client data points to the singleton object
+     // which is responsible for managing commands for
+     // objects of a given type
+
+     class_handler_base *chb = reinterpret_cast<class_handler_base*>(cd);
+
+     // the command name has the form 'pXXX' where XXX is the address
+     // of the "this" object
+
+     string const str(Tcl_GetString(objv[0]));
+     istringstream ss(str);
+     char dummy;
+     void *p;
+     ss >> dummy >> p;
+
+     try
+     {
+          string methodName(Tcl_GetString(objv[1]));
+          policies &pol = chb->get_policies(methodName);
+
+          chb->invoke(p, interp, objc, objv, pol);
+
+          post_process_policies(interp, pol, objv, true);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+// generic "constructor" command
+extern "C"
+int constructor_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     // here, client data points to the singleton object
+     // which is responsible for managing commands for
+     // objects of a given type
+
+     class_handler_base *chb = reinterpret_cast<class_handler_base*>(cd);
+
+     callback_map::iterator it = constructors.find(interp);
+     if (it == constructors.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong interpreter?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     string className(Tcl_GetString(objv[0]));
+     callback_interp_map::iterator iti = it->second.find(className);
+     if (iti == it->second.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong class name?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_interp_map::iterator piti;
+     if (find_policies(interp, className, piti) == false)
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies &pol = piti->second;
+
+     try
+     {
+          iti->second->invoke(interp, objc, objv, pol);
+
+          // if everything went OK, the result is the address of the
+          // new object in the 'pXXX' form
+          // - we can create a new command with this name
+
+          Tcl_CreateObjCommand(interp,
+               Tcl_GetString(Tcl_GetObjResult(interp)),
+               object_handler, static_cast<ClientData>(chb), 0);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+} // namespace anonymous
+
+Tcl::details::no_init_type Tcl::no_init;
+
+
+policies & policies::factory(string const &name)
+{
+     factory_ = name;
+     return *this;
+}
+
+policies & policies::sink(int index)
+{
+     sinks_.push_back(index);
+     return *this;
+}
+
+policies & policies::variadic()
+{
+     variadic_ = true;
+     return *this;
+}
+
+policies Tcl::factory(string const &name)
+{
+     return policies().factory(name);
+}
+
+policies Tcl::sink(int index)
+{
+     return policies().sink(index);
+}
+
+policies Tcl::variadic()
+{
+     return policies().variadic();
+}
+
+
+class_handler_base::class_handler_base()
+{
+     // default policies for the -delete command
+     policies_["-delete"] = policies();
+}
+
+void class_handler_base::register_method(string const &name,
+     shared_ptr<object_cmd_base> ocb, policies const &p)
+{
+     methods_[name] = ocb;
+     policies_[name] = p;
+}
+
+policies & class_handler_base::get_policies(string const &name)
+{
+     policies_map_type::iterator it = policies_.find(name);
+     if (it == policies_.end())
+     {
+          throw tcl_error("Trying to use non-existent policy: " + name);
+     }
+
+     return it->second;
+}
+
+
+object::object()
+     : interp_(0)
+{
+     obj_ = Tcl_NewObj();
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(bool b)
+     : interp_(0)
+{
+     obj_ = Tcl_NewBooleanObj(b);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(char const *buf, size_t size)
+     : interp_(0)
+{
+     obj_ = Tcl_NewByteArrayObj(
+          reinterpret_cast<unsigned char const *>(buf),
+          static_cast<int>(size));
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(double d)
+     : interp_(0)
+{
+     obj_ = Tcl_NewDoubleObj(d);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(int i)
+     : interp_(0)
+{
+     obj_ = Tcl_NewIntObj(i);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(long l)
+     : interp_(0)
+{
+     obj_ = Tcl_NewLongObj(l);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(char const *s)
+     : interp_(0)
+{
+     obj_ = Tcl_NewStringObj(s, -1);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(string const &s)
+     : interp_(0)
+{
+     obj_ = Tcl_NewStringObj(s.data(), static_cast<int>(s.size()));
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(Tcl_Obj *o, bool shared)
+     : interp_(0)
+{
+     init(o, shared);
+}
+
+object::object(object const &other, bool shared)
+     : interp_(other.get_interp())
+{
+     init(other.obj_, shared);
+}
+
+void object::init(Tcl_Obj *o, bool shared)
+{
+     if (shared)
+     {
+          obj_ = o;
+     }
+     else
+     {
+          obj_ = Tcl_DuplicateObj(o);
+     }
+     Tcl_IncrRefCount(obj_);
+}
+
+object::~object()
+{
+     Tcl_DecrRefCount(obj_);
+}
+
+object & object::assign(bool b)
+{
+     Tcl_SetBooleanObj(obj_, b);
+     return *this;
+}
+
+object & object::resize(size_t size)
+{
+     Tcl_SetByteArrayLength(obj_, static_cast<int>(size));
+     return *this;
+}
+
+object & object::assign(char const *buf, size_t size)
+{
+     Tcl_SetByteArrayObj(obj_,
+          reinterpret_cast<unsigned char const *>(buf),
+          static_cast<int>(size));
+     return *this;
+}
+
+object & object::assign(double d)
+{
+     Tcl_SetDoubleObj(obj_, d);
+     return *this;
+}
+
+object & object::assign(int i)
+{
+     Tcl_SetIntObj(obj_, i);
+     return *this;
+}
+
+object & object::assign(long l)
+{
+     Tcl_SetLongObj(obj_, l);
+     return *this;
+}
+
+object & object::assign(char const *s)
+{
+     Tcl_SetStringObj(obj_, s, -1);
+     return *this;
+}
+
+object & object::assign(string const &s)
+{
+     Tcl_SetStringObj(obj_, s.data(), static_cast<int>(s.size()));
+     return *this;
+}
+
+object & object::assign(object const &other)
+{
+     object(other).swap(*this);
+     return *this;
+}
+
+object & object::assign(Tcl_Obj *o)
+{
+     object(o).swap(*this);
+     return *this;
+}
+
+object & object::swap(object &other)
+{
+     std::swap(obj_, other.obj_);
+     std::swap(interp_, other.interp_);
+     return *this;
+}
+
+template <>
+bool object::get<bool>(interpreter &i) const
+{
+     int retVal;
+     int res = Tcl_GetBooleanFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return static_cast<bool>(retVal);
+}
+
+template <>
+vector<char> object::get<vector<char> >(interpreter &) const
+{
+     size_t size;
+     char const *buf = get(size);
+     return vector<char>(buf, buf + size);
+}
+
+template <>
+double object::get<double>(interpreter &i) const
+{
+     double retVal;
+     int res = Tcl_GetDoubleFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+int object::get<int>(interpreter &i) const
+{
+     int retVal;
+
+     int res = Tcl_GetIntFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+long object::get<long>(interpreter &i) const
+{
+     long retVal;
+     int res = Tcl_GetLongFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+char const * object::get<char const *>(interpreter &) const
+{
+     return get();
+}
+
+template <>
+string object::get<string>(interpreter &) const
+{
+     int len;
+     char const *buf = Tcl_GetStringFromObj(obj_, &len);
+     return string(buf, buf + len);
+}
+
+char const * object::get() const
+{
+     return Tcl_GetString(obj_);
+}
+
+char const * object::get(size_t &size) const
+{
+     int len;
+     unsigned char *buf = Tcl_GetByteArrayFromObj(obj_, &len);
+     size = len;
+     return const_cast<char const *>(reinterpret_cast<char *>(buf));
+}
+
+size_t object::length(interpreter &i) const
+{
+     int len;
+     int res = Tcl_ListObjLength(i.get(), obj_, &len);
+
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return static_cast<size_t>(len);
+}
+
+object object::at(interpreter &i, size_t index) const
+{
+     Tcl_Obj *o;
+     int res = Tcl_ListObjIndex(i.get(), obj_, static_cast<int>(index), &o);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+     if (o == NULL)
+     {
+          throw tcl_error("Index out of range.");
+     }
+
+     return object(o);
+}
+
+object & object::append(interpreter &i, object const &o)
+{
+     int res = Tcl_ListObjAppendElement(i.get(), obj_, o.obj_);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::append_list(interpreter &i, object const &o)
+{
+     int res = Tcl_ListObjAppendList(i.get(), obj_, o.obj_);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::replace(interpreter &i, size_t index, size_t count,
+     object const &o)
+{
+     int res = Tcl_ListObjReplace(i.get(), obj_,
+          static_cast<int>(index), static_cast<int>(count),
+          1, &(o.obj_));
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::replace_list(interpreter &i, size_t index, size_t count,
+     object const &o)
+{
+     int objc;
+     Tcl_Obj **objv;
+
+     int res = Tcl_ListObjGetElements(i.get(), o.obj_, &objc, &objv);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     res = Tcl_ListObjReplace(i.get(), obj_,
+          static_cast<int>(index), static_cast<int>(count),
+          objc, objv);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+void object::set_interp(Tcl_Interp *interp)
+{
+     interp_ = interp;
+}
+
+Tcl_Interp * object::get_interp() const
+{
+     return interp_;
+}
+
+
+interpreter::interpreter()
+{
+     interp_ =  Tcl_CreateInterp();
+     owner_ = true;
+}
+
+interpreter::interpreter(string const &libpath)
+{
+     interp_ =  Tcl_CreateInterp();
+     owner_ = true;
+
+     try
+     {
+        this->eval("set tcl_library " + libpath);
+        Tcl_Init(this->interp_);
+     } catch (...) {}
+}
+
+interpreter::interpreter(Tcl_Interp *interp, bool owner)
+{
+     interp_ =  interp;
+     owner_ = owner;
+}
+
+interpreter::~interpreter()
+{
+     if (owner_)
+     {
+          // clear all callback info belonging to this interpreter
+          clear_definitions(interp_);
+
+          Tcl_DeleteInterp(interp_);
+     }
+}
+
+void interpreter::make_safe()
+{
+     int cc = Tcl_MakeSafe(interp_);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+result interpreter::eval(string const &script)
+{
+     int cc = Tcl_Eval(interp_, script.c_str());
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return result(interp_);
+}
+
+result interpreter::eval(istream &s)
+{
+     string str(
+          istreambuf_iterator<char>(s.rdbuf()),
+          istreambuf_iterator<char>()
+     );
+     return eval(str);
+}
+
+result interpreter::eval(object const &o)
+{
+     int cc = Tcl_EvalObjEx(interp_, o.get_object(), 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return result(interp_);
+}
+
+void interpreter::pkg_provide(string const &name, string const &version)
+{
+     int cc = Tcl_PkgProvide(interp_, name.c_str(), version.c_str());
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+void interpreter::create_alias(string const &cmd,
+     interpreter &targetInterp, string const &targetCmd)
+{
+     int cc = Tcl_CreateAlias(interp_, cmd.c_str(),
+          targetInterp.interp_, targetCmd.c_str(), 0, 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+void interpreter::clear_definitions(Tcl_Interp *interp)
+{
+     // delete all callbacks that were registered for given interpreter
+
+     {
+          // TODO: why could this probably be necessary? map::find of empty map
+          // shouldn't be a problem.
+          if (callbacks.size() == 0)
+            return;
+          callback_map::iterator it = callbacks.find(interp);
+          if (it == callbacks.end())
+          {
+               // no callbacks defined for this interpreter
+               return;
+          }
+
+          callback_interp_map &imap = it->second;
+          for (callback_interp_map::iterator it2 = imap.begin();
+               it2 != imap.end(); ++it2)
+          {
+               Tcl_DeleteCommand(interp, it2->first.c_str());
+          }
+
+          callbacks.erase(interp);
+     }
+
+     // delete all constructors
+
+     {
+          callback_map::iterator it = constructors.find(interp);
+          if (it == constructors.end())
+          {
+               // no callbacks defined for this interpreter
+               return;
+          }
+
+          callback_interp_map &imap = it->second;
+          for (callback_interp_map::iterator it2 = imap.begin();
+               it2 != imap.end(); ++it2)
+          {
+               Tcl_DeleteCommand(interp, it2->first.c_str());
+          }
+
+          callbacks.erase(interp);
+     }
+
+     // delete all call policies
+
+     call_policies.erase(interp);
+
+     // delete all object handlers
+     // (we have to assume that all living objects were destroyed,
+     // otherwise Bad Things will happen)
+
+     class_handlers.erase(interp);
+}
+
+void interpreter::add_function(string const &name,
+     shared_ptr<callback_base> cb, policies const &p)
+{
+     Tcl_CreateObjCommand(interp_, name.c_str(),
+          callback_handler, 0, 0);
+
+     callbacks[interp_][name] = cb;
+     call_policies[interp_][name] = p;
+}
+
+void interpreter::add_class(string const &name,
+     shared_ptr<class_handler_base> chb)
+{
+     class_handlers[interp_][name] = chb;
+}
+
+void interpreter::add_constructor(string const &name,
+     shared_ptr<class_handler_base> chb, shared_ptr<callback_base> cb,
+     policies const &p)
+{
+     Tcl_CreateObjCommand(interp_, name.c_str(),
+          constructor_handler, static_cast<ClientData>(chb.get()), 0);
+
+     constructors[interp_][name] = cb;
+     call_policies[interp_][name] = p;
+}
+
+
+int tcl_cast<int>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     int res;
+     int cc = Tcl_GetIntFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+long tcl_cast<long>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     long res;
+     int cc = Tcl_GetLongFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+bool tcl_cast<bool>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     int res;
+     int cc = Tcl_GetBooleanFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res != 0;
+}
+
+double tcl_cast<double>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     double res;
+     int cc = Tcl_GetDoubleFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+string tcl_cast<string>::from(Tcl_Interp *, Tcl_Obj *obj)
+{
+     return Tcl_GetString(obj);
+}
+
+char const * tcl_cast<char const *>::from(Tcl_Interp *, Tcl_Obj *obj)
+{
+     return Tcl_GetString(obj);
+}
+
+object tcl_cast<object>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     object o(obj);
+     o.set_interp(interp);
+
+     return o;
+}
Index: /code/branches/physics/src/cpptcl/CppTcl.h
===================================================================
--- /code/branches/physics/src/cpptcl/CppTcl.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/CppTcl.h	(revision 2122)
@@ -0,0 +1,871 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+#ifndef CPPTCL_INCLUDED
+#define CPPTCL_INCLUDED
+
+#include <tcl.h>
+#include <string>
+#include <stdexcept>
+#include <sstream>
+#include <map>
+#include <vector>
+#include <boost/shared_ptr.hpp>
+#include <boost/bind.hpp>
+
+
+namespace Tcl
+{
+
+// exception class used for reporting all Tcl errors
+
+class tcl_error : public std::runtime_error
+{
+public:
+     explicit tcl_error(std::string const &msg)
+          : std::runtime_error(msg) {}
+     explicit tcl_error(Tcl_Interp *interp)
+          : std::runtime_error(Tcl_GetString(Tcl_GetObjResult(interp))) {}
+};
+
+// call policies
+
+struct policies
+{
+     policies() : variadic_(false) {}
+
+     policies & factory(std::string const &name);
+
+     // note: this is additive
+     policies & sink(int index);
+
+     policies & variadic();
+
+     std::string factory_;
+     std::vector<int> sinks_;
+     bool variadic_;
+};
+
+// syntax short-cuts
+policies factory(std::string const &name);
+policies sink(int index);
+policies variadic();
+
+
+class interpreter;
+class object;
+
+namespace details
+{
+
+// wrapper for the evaluation result
+class result
+{
+public:
+     result(Tcl_Interp *interp);
+
+     operator bool() const;
+     operator double() const;
+     operator int() const;
+     operator long() const;
+     operator std::string() const;
+     operator object() const;
+
+private:
+     Tcl_Interp *interp_;
+};
+
+// helper functions used to set the result value
+
+void set_result(Tcl_Interp *interp, bool b);
+void set_result(Tcl_Interp *interp, int i);
+void set_result(Tcl_Interp *interp, long i);
+void set_result(Tcl_Interp *interp, double d);
+void set_result(Tcl_Interp *interp, std::string const &s);
+void set_result(Tcl_Interp *interp, void *p);
+void set_result(Tcl_Interp *interp, object const &o);
+
+// helper functor for converting Tcl objects to the given type
+#include "details/conversions.h"
+
+// dispatchers able to capture (or ignore) the result
+#include "details/dispatchers.h"
+
+// helper for checking for required number of parameters
+// (throws tcl_error when not met)
+void check_params_no(int objc, int required);
+
+// helper for gathering optional params in variadic functions
+object get_var_params(Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[],
+     int from, policies const &pol);
+
+// the callback_base is used to store callback handlers in a polynorphic map
+class callback_base
+{
+public:
+     virtual ~callback_base() {}
+
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol) = 0;
+};
+
+
+// base class for object command handlers
+// and for class handlers
+class object_cmd_base
+{
+public:
+     // destructor not needed, but exists to shut up the compiler warnings
+     virtual ~object_cmd_base() {}
+
+     virtual void invoke(void *p, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol) = 0;
+};
+
+// base class for all class handlers, still abstract
+class class_handler_base : public object_cmd_base
+{
+public:
+     typedef std::map<std::string, policies> policies_map_type;
+
+     class_handler_base();
+
+     void register_method(std::string const &name,
+          boost::shared_ptr<object_cmd_base> ocb, policies const &p);
+
+     policies & get_policies(std::string const &name);
+
+protected:
+     typedef std::map<
+          std::string,
+          boost::shared_ptr<object_cmd_base>
+          > method_map_type;
+
+     // a map of methods for the given class
+     method_map_type methods_;
+
+     policies_map_type policies_;
+};
+
+// class handler - responsible for executing class methods
+template <class C>
+class class_handler : public class_handler_base
+{
+public:
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C * p = static_cast<C*>(pv);
+
+          if (objc < 2)
+          {
+               throw tcl_error("Too few arguments.");
+          }
+
+          std::string methodName(Tcl_GetString(objv[1]));
+
+          if (methodName == "-delete")
+          {
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
+               delete p;
+               return;
+          }
+
+          // dispatch on the method name
+
+          method_map_type::iterator it = methods_.find(methodName);
+          if (it == methods_.end())
+          {
+               throw tcl_error("Method " + methodName + " not found.");
+          }
+
+          it->second->invoke(pv, interp, objc, objv, pol);
+     }
+};
+
+
+// factory functions for creating class objects
+#include "details/constructors.h"
+
+// actual callback envelopes
+#include "details/callbacks.h"
+
+// actual method envelopes
+#include "details/methods.h"
+
+// helper meta function for figuring appropriate constructor callback
+#include "details/metahelpers.h"
+
+
+// this class is used to provide the "def" interface for defining
+// class member functions
+
+template <class C>
+class class_definer
+{
+public:
+     class_definer(boost::shared_ptr<class_handler<C> > ch) : ch_(ch) {}
+
+     template <typename R>
+     class_definer & def(std::string const &name, R (C::*f)(),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method0<C, R>(f)), p);
+          return *this;
+     }
+
+     template <typename R>
+     class_definer & def(std::string const &name, R (C::*f)() const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method0<C, R>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1>
+     class_definer & def(std::string const &name, R (C::*f)(T1),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method1<C, R, T1>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1>
+     class_definer & def(std::string const &name, R (C::*f)(T1) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method1<C, R, T1>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method2<C, R, T1, T2>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method2<C, R, T1, T2>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method3<C, R, T1, T2, T3>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method3<C, R, T1, T2, T3>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3, T4),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method4<C, R, T1, T2, T3, T4>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method4<C, R, T1, T2, T3, T4>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5), policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method5<C, R, T1, T2, T3, T4, T5>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5) const, policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method5<C, R, T1, T2, T3, T4, T5>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6), policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method6<C, R, T1, T2, T3, T4, T5, T6>(f)),
+               p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method6<C, R, T1, T2, T3, T4, T5, T6>(f)),
+               p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method7<C, R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method7<C, R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method8<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method8<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method9<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method9<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+          return *this;
+     }
+
+private:
+     boost::shared_ptr<class_handler<C> > ch_;
+};
+
+} // namespace details
+
+
+// init type for defining class constructors
+template <typename T1 = void, typename T2 = void, typename T3 = void,
+          typename T4 = void, typename T5 = void, typename T6 = void,
+          typename T7 = void, typename T8 = void, typename T9 = void>
+class init {};
+
+// no_init type and object - to define classes without constructors
+namespace details
+{
+     struct no_init_type {};
+} // namespace details
+extern details::no_init_type no_init;
+
+
+// interpreter wrapper
+class interpreter
+{
+public:
+     interpreter();
+     interpreter(std::string const &libpath);
+     interpreter(Tcl_Interp *, bool owner = true);
+     ~interpreter();
+
+     void make_safe();
+
+     Tcl_Interp * get() const { return interp_; }
+
+     // free function definitions
+
+     template <typename R>
+     void def(std::string const &name, R (*f)(),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback0<R>(f)), p);
+     }
+
+     template <typename R, typename T1>
+     void def(std::string const &name, R (*f)(T1),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback1<R, T1>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2>
+     void def(std::string const &name, R (*f)(T1, T2),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback2<R, T1, T2>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     void def(std::string const &name, R (*f)(T1, T2, T3),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback3<R, T1, T2, T3>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback4<R, T1, T2, T3, T4>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback5<R, T1, T2, T3, T4, T5>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback6<R, T1, T2, T3, T4, T5, T6>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6, T7),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback7<R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7, typename T8>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6, T7, T8),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback8<R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7, typename T8,
+          typename T9>
+     void def(std::string const &name,
+          R (*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback9<R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+     }
+
+
+     // class definitions
+
+     template <class C>
+     details::class_definer<C> class_(std::string const &name)
+     {
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          add_constructor(name, ch,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback0<C*>(&details::construct<
+                         C, void, void, void, void, void, void, void,
+                         void, void>::doit)));
+
+          return details::class_definer<C>(ch);
+     }
+
+     template <class C, typename T1, typename T2, typename T3, typename T4,
+               typename T5, typename T6, typename T7, typename T8,
+               typename T9>
+     details::class_definer<C> class_(std::string const &name,
+          init<T1, T2, T3, T4, T5, T6, T7, T8, T9> const &,
+          policies const &p = policies())
+     {
+          typedef typename details::get_callback_type_for_construct<
+               C, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
+               callback_type;
+
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          add_constructor(name, ch,
+               boost::shared_ptr<details::callback_base>(
+                    new callback_type(&details::construct<
+                         C, T1, T2, T3, T4, T5, T6, T7, T8, T9>::doit)), p);
+
+          return details::class_definer<C>(ch);
+     }
+
+     template <class C>
+     details::class_definer<C> class_(
+          std::string const &name, details::no_init_type const &)
+     {
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          return details::class_definer<C>(ch);
+     }
+
+     // free script evaluation
+     details::result eval(std::string const &script);
+     details::result eval(std::istream &s);
+
+     details::result eval(object const &o);
+
+     // the InputIterator should give object& or Tcl_Obj* when dereferenced
+     template <class InputIterator>
+     details::result eval(InputIterator first, InputIterator last);
+
+     // create alias from the *this interpreter to the target interpreter
+     void create_alias(std::string const &cmd,
+          interpreter &targetInterp, std::string const &targetCmd);
+
+     // register a package info (useful when defining packages)
+     void pkg_provide(std::string const &name, std::string const &version);
+
+     // helper for cleaning up callbacks in non-managed interpreters
+     static void clear_definitions(Tcl_Interp *);
+
+private:
+
+     // copy not supported
+     interpreter(const interpreter &);
+     void operator=(const interpreter &);
+
+     void add_function(std::string const &name,
+          boost::shared_ptr<details::callback_base> cb,
+          policies const &p = policies());
+
+     void add_class(std::string const &name,
+          boost::shared_ptr<details::class_handler_base> chb);
+
+     void add_constructor(std::string const &name,
+          boost::shared_ptr<details::class_handler_base> chb,
+          boost::shared_ptr<details::callback_base> cb,
+          policies const &p = policies());
+
+     Tcl_Interp *interp_;
+     bool owner_;
+};
+
+
+// object wrapper
+class object
+{
+public:
+
+     // constructors
+
+     object();
+
+     explicit object(bool b);
+     object(char const *buf, size_t size); // byte array
+     explicit object(double b);
+     explicit object(int i);
+
+     // list creation
+     // the InputIterator should give object& or Tcl_Obj* when dereferenced
+     template <class InputIterator>
+     object(InputIterator first, InputIterator last)
+          : interp_(0)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          obj_ = Tcl_NewListObj(static_cast<int>(v.size()),
+               v.empty() ? NULL : &v[0]);
+          Tcl_IncrRefCount(obj_);
+     }
+
+     explicit object(long i);
+     explicit object(char const *s);        // string construction
+     explicit object(std::string const &s); // string construction
+
+     explicit object(Tcl_Obj *o, bool shared = false);
+
+     object(object const &other, bool shared = false);
+     ~object();
+
+     // assignment
+
+     object & assign(bool b);
+     object & resize(size_t size);                  // byte array resize
+     object & assign(char const *buf, size_t size); // byte array assignment
+     object & assign(double d);
+     object & assign(int i);
+
+     // list assignment
+     // the InputIterator should give Tcl_Obj* or object& when dereferenced
+     template <class InputIterator>
+     object & assign(InputIterator first, InputIterator last)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          Tcl_SetListObj(obj_, static_cast<int>(v.size()),
+               v.empty() ? NULL : &v[0]);
+          return *this;
+     }
+
+     object & assign(long l);
+     object & assign(char const *s);        // string assignment
+     object & assign(std::string const &s); // string assignment
+     object & assign(object const &o);
+     object & assign(Tcl_Obj *o);
+
+     object & operator=(bool b)               { return assign(b); }
+     object & operator=(double d)             { return assign(d); }
+     object & operator=(int i)                { return assign(i); }
+     object & operator=(long l)               { return assign(l); }
+     object & operator=(char const *s)        { return assign(s); }
+     object & operator=(std::string const &s) { return assign(s); }
+
+     object & operator=(object const &o)      { return assign(o); }
+     object & swap(object &other);
+
+     // (logically) non-modifying members
+
+     template <typename T>
+     T get(interpreter &i) const;
+
+     char const * get() const;             // string get
+     char const * get(size_t &size) const; // byte array get
+
+     size_t length(interpreter &i) const;  // returns list length
+     object at(interpreter &i, size_t index) const;
+
+     Tcl_Obj * get_object() const { return obj_; }
+
+     // modifying members
+
+     object & append(interpreter &i, object const &o);
+     object & append_list(interpreter &i, object const &o);
+
+     // list replace
+     // the InputIterator should give Tcl_Obj* or object& when dereferenced
+     template <class InputIterator>
+     object & replace(interpreter &i, size_t index, size_t count,
+          InputIterator first, InputIterator last)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          int res = Tcl_ListObjReplace(i.get(), obj_,
+               static_cast<int>(index), static_cast<int>(count),
+               static_cast<int>(v.size()), v.empty() ? NULL : &v[0]);
+          if (res != TCL_OK)
+          {
+               throw tcl_error(i.get());
+          }
+
+          return *this;
+     }
+
+     object & replace(interpreter &i, size_t index, size_t count,
+          object const &o);
+     object & replace_list(interpreter &i, size_t index, size_t count,
+          object const &o);
+
+     // helper functions for piggy-backing interpreter info
+     void set_interp(Tcl_Interp *interp);
+     Tcl_Interp * get_interp() const;
+
+     // helper function, also used from interpreter::eval
+     template <class InputIterator>
+     static void fill_vector(std::vector<Tcl_Obj*> &v,
+          InputIterator first, InputIterator last)
+     {
+          for (; first != last; ++first)
+          {
+               object o(*first, true);
+               v.push_back(o.obj_);
+          }
+     }
+
+private:
+
+     // helper function used from copy constructors
+     void init(Tcl_Obj *o, bool shared);
+
+     Tcl_Obj *obj_;
+     Tcl_Interp *interp_;
+};
+
+// available specializations for object::get
+template <> bool         object::get<bool>(interpreter &i) const;
+template <> double       object::get<double>(interpreter &i) const;
+template <> int          object::get<int>(interpreter &i) const;
+template <> long         object::get<long>(interpreter &i) const;
+template <> char const * object::get<char const *>(interpreter &i) const;
+template <> std::string  object::get<std::string>(interpreter &i) const;
+template <>
+std::vector<char> object::get<std::vector<char> >(interpreter &i) const;
+
+// the InputIterator should give object& or Tcl_Obj* when dereferenced
+template <class InputIterator>
+details::result interpreter::eval(InputIterator first, InputIterator last)
+{
+     std::vector<Tcl_Obj*> v;
+     object::fill_vector(v, first, last);
+     int cc = Tcl_EvalObjv(interp_,
+          static_cast<int>(v.size()), v.empty() ? NULL : &v[0], 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return details::result(interp_);
+}
+
+namespace details
+{
+
+// additional callback envelopes for variadic functions
+#include "details/callbacks_v.h"
+
+// additional method envelopes for variadic methods
+#include "details/methods_v.h"
+
+} // namespace details
+
+} // namespace Tcl
+
+
+// macro for defining loadable module entry point
+// - used for extending Tcl interpreter
+
+#define CPPTCL_MODULE(name, i) void name##_cpptcl_Init(Tcl::interpreter &i); \
+     extern "C" int name##_Init(Tcl_Interp *interp) \
+     { \
+          Tcl::interpreter i(interp, false); \
+          name##_cpptcl_Init(i); \
+          return TCL_OK; \
+     } \
+     void name##_cpptcl_Init(Tcl::interpreter &i)
+
+
+#endif // CPPTCL_INCLUDED
Index: /code/branches/physics/src/cpptcl/LICENSE
===================================================================
--- /code/branches/physics/src/cpptcl/LICENSE	(revision 2122)
+++ /code/branches/physics/src/cpptcl/LICENSE	(revision 2122)
@@ -0,0 +1,39 @@
+Each source file contains the following notice:
+
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+The above is the shortest license I have found.
+I have copied this wording from one of the source files of the Boost library.
+
+Just to explain the above terms:
+
+1. The library is free (like in "freedom").
+
+2. You can use it for any purpose you wish. You can even sell it.
+
+3. You can modify the source files. If you do this, please feel free to add
+   your own copyright notices wherever you want, if you want.
+   You may also add more restrictive license terms.
+   You only have to keep the above notice unchanged in all source files.
+
+4. You can combine this library or its modified version with other software.
+   The license claims nothing that would affect the resulting work.
+   See point 3. if you need to make any modifications.
+
+5. You can compile this library or its modified version to the binary form.
+   The license does not affect the compiled result in any way.
+   In particular, you do not need to (but you still can) display the above
+   copyright notice to the final user, and you do not need to (but you still
+   can) inform the final user that your product was prepared with the help
+   of this library.
+
+6. Do not sue me for my (and your) mistakes and errors.
+
+As you see, this license is very permissive.
Index: /code/branches/physics/src/cpptcl/README
===================================================================
--- /code/branches/physics/src/cpptcl/README	(revision 2122)
+++ /code/branches/physics/src/cpptcl/README	(revision 2122)
@@ -0,0 +1,32 @@
+C++/Tcl - a C++ library for interoperability between C++ and Tcl.
+
+Copyright (C) 2004-2006, Maciej Sobczak
+
+---
+
+You should see the following directories here:
+
+- doc      - contains a short documentation for the library
+- examples - some simple examples to show C++/Tcl basics
+- test     - tests used for development - use them for regression testing
+             if you want to modify the library
+- details  - some additional code used by the library (not for client use)
+
+In addition, the following files may be of interest to you:
+
+- README   - this file
+- LICENSE  - explanation of the license terms
+- CHANGES  - the history of changes
+
+
+The C++/Tcl itself consists of these files:
+- cpptcl.h   - to be included in your own files
+- cpptcl.cc  - to be compiled and linked with your code
+
+
+In order to compile the tests and the examples you may need to change the
+compiler options to fit your particular environment (different paths to the
+Tcl headers and libs, another compiler, etc.)
+
+
+Anyway - have fun! :-)
Index: /code/branches/physics/src/cpptcl/details/callbacks.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/callbacks.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/callbacks.h	(revision 2122)
@@ -0,0 +1,273 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <typename R>
+class callback0 : public callback_base
+{
+     typedef R (*functor_type)();
+     
+public:
+     callback0(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int, Tcl_Obj * CONST [],
+          policies const &)
+     {
+          dispatch<R>::do_dispatch(interp, f_);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1>
+class callback1 : public callback_base
+{
+     typedef R (*functor_type)(T1);
+     
+public:
+     callback1(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 2);
+          
+          dispatch<R>::template do_dispatch<T1>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2>
+class callback2 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2);
+     
+public:
+     callback2(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 3);
+          
+          dispatch<R>::template do_dispatch<T1, T2>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3>
+class callback3 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3);
+     
+public:
+     callback3(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 4);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4>
+class callback4 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4);
+     
+public:
+     callback4(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 5);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5>
+class callback5 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5);
+     
+public:
+     callback5(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 6);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6>
+class callback6 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6);
+     
+public:
+     callback6(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 7);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7>
+class callback7 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7);
+     
+public:
+     callback7(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 8);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8>
+class callback8 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     
+public:
+     callback8(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 9);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8, typename T9>
+class callback9 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     
+public:
+     callback9(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 10);
+          
+          dispatch<R>::template do_dispatch<
+               T1, T2, T3, T4, T5, T6, T7, T8, T9>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]),
+               tcl_cast<T9>::from(interp, objv[9]));
+     }
+
+private:
+     functor_type f_;
+};
Index: /code/branches/physics/src/cpptcl/details/callbacks_v.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/callbacks_v.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/callbacks_v.h	(revision 2122)
@@ -0,0 +1,267 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <typename R>
+class callback1<R, object const &> : public callback_base
+{
+     typedef object const & T1;
+     typedef R (*functor_type)(T1);
+     enum { var_start = 1 };
+     
+public:
+     callback1(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t1 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1>(interp, f_,
+               t1);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1>
+class callback2<R, T1, object const &> : public callback_base
+{
+     typedef object const & T2;
+     typedef R (*functor_type)(T1, T2);
+     enum { var_start = 2 };
+     
+public:
+     callback2(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t2 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               t2);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2>
+class callback3<R, T1, T2, object const &> : public callback_base
+{
+     typedef object const & T3;
+     typedef R (*functor_type)(T1, T2, T3);
+     enum { var_start = 3 };
+     
+public:
+     callback3(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t3 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               t3);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3>
+class callback4<R, T1, T2, T3, object const &> : public callback_base
+{
+     typedef object const & T4;
+     typedef R (*functor_type)(T1, T2, T3, T4);
+     enum { var_start = 4 };
+     
+public:
+     callback4(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t4 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               t4);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4>
+class callback5<R, T1, T2, T3, T4, object const &> : public callback_base
+{
+     typedef object const & T5;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5);
+     enum { var_start = 5 };
+     
+public:
+     callback5(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t5 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               t5);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5>
+class callback6<R, T1, T2, T3, T4, T5, object const &> : public callback_base
+{
+     typedef object const & T6;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6);
+     enum { var_start = 6 };
+     
+public:
+     callback6(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t6 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               t6);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6>
+class callback7<R, T1, T2, T3, T4, T5, T6, object const &>
+     : public callback_base
+{
+     typedef object const & T7;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7);
+     enum { var_start = 7 };
+     
+public:
+     callback7(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t7 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               t7);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7>
+class callback8<R, T1, T2, T3, T4, T5, T6, T7, object const &>
+     : public callback_base
+{
+     typedef object const & T8;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     enum { var_start = 8 };
+     
+public:
+     callback8(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t8 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               t8);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8>
+class callback9<R, T1, T2, T3, T4, T5, T6, T7, T8, object const &>
+     : public callback_base
+{
+     typedef object const & T9;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     enum { var_start = 9 };
+     
+public:
+     callback9(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t9 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<
+               T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]),
+               t9);
+     }
+
+private:
+     functor_type f_;
+};
Index: /code/branches/physics/src/cpptcl/details/constructors.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/constructors.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/constructors.h	(revision 2122)
@@ -0,0 +1,88 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+struct construct
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7,
+          T8 t8, T9 t9)
+     { return new C(t1, t2, t3, t4, t5, t6, t7, t8, t9); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+struct construct<C, T1, T2, T3, T4, T5, T6, T7, T8, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     { return new C(t1, t2, t3, t4, t5, t6, t7, t8); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+struct construct<C, T1, T2, T3, T4, T5, T6, T7, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     { return new C(t1, t2, t3, t4, t5, t6, t7); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+struct construct<C, T1, T2, T3, T4, T5, T6, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     { return new C(t1, t2, t3, t4, t5, t6); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+struct construct<C, T1, T2, T3, T4, T5, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     { return new C(t1, t2, t3, t4, t5); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4>
+struct construct<C, T1, T2, T3, T4, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4)
+     { return new C(t1, t2, t3, t4); }
+};
+
+template <class C, typename T1, typename T2, typename T3>
+struct construct<C, T1, T2, T3, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3)
+     { return new C(t1, t2, t3); }
+};
+
+template <class C, typename T1, typename T2>
+struct construct<C, T1, T2, void, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2)
+     { return new C(t1, t2); }
+};
+
+template <class C, typename T1>
+struct construct<C, T1, void, void, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1)
+     { return new C(t1); }
+};
+
+template <class C>
+struct construct<C, void, void, void, void, void,
+                 void, void, void, void>
+{
+     static C * doit()
+     { return new C(); }
+};
Index: /code/branches/physics/src/cpptcl/details/conversions.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/conversions.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/conversions.h	(revision 2122)
@@ -0,0 +1,101 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+// helper functor for converting Tcl objects to the given type
+// (it is a struct instead of function,
+// because I need to partially specialize it)
+
+template <typename T>
+struct tcl_cast;
+
+template <typename T>
+struct tcl_cast<T*>
+{
+     static T * from(Tcl_Interp *, Tcl_Obj *obj)
+     {
+          std::string s(Tcl_GetString(obj));
+          if (s.size() == 0)
+          {
+               throw tcl_error("Expected pointer value, got empty string.");
+          }
+
+          if (s[0] != 'p')
+          {
+               throw tcl_error("Expected pointer value.");
+          }
+
+          std::istringstream ss(s);
+          char dummy;
+          void *p;
+          ss >> dummy >> p;
+
+          return static_cast<T*>(p);
+     }
+};
+
+// the following partial specialization is to strip reference
+// (it returns a temporary object of the underlying type, which
+// can be bound to the const-ref parameter of the actual function)
+
+template <typename T>
+struct tcl_cast<T const &>
+{
+     static T from(Tcl_Interp *interp, Tcl_Obj *obj)
+     {
+          return tcl_cast<T>::from(interp, obj);
+     }
+};
+
+
+// the following specializations are implemented
+
+template <>
+struct tcl_cast<int>
+{
+     static int from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<long>
+{
+     static long from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<bool>
+{
+     static bool from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<double>
+{
+     static double from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<std::string>
+{
+     static std::string from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<char const *>
+{
+     static char const * from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<object>
+{
+     static object from(Tcl_Interp *, Tcl_Obj *);
+};
Index: /code/branches/physics/src/cpptcl/details/dispatchers.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/dispatchers.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/dispatchers.h	(revision 2122)
@@ -0,0 +1,181 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+// the dispatch class is used to execute the callback functor and to
+// capture its return value
+// further dispatch<void> specialization ignores the res
+
+template <typename R>
+struct dispatch
+{
+     template <class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f)
+     {
+          R res = f();
+          set_result(interp, res);
+     }
+
+     template <typename T1, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f, T1 t1)
+     {
+          R res = f(t1);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f, T1 t1, T2 t2)
+     {
+          R res = f(t1, t2);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3)
+     {
+          R res = f(t1, t2, t3);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4)
+     {
+          R res = f(t1, t2, t3, t4);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     {
+          R res = f(t1, t2, t3, t4, t5);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7, t8);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7, t8, t9);
+          set_result(interp, res);
+     }
+};
+
+template <>
+struct dispatch<void>
+{
+     template <class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f)
+     {
+          f();
+     }
+
+     template <typename T1, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f, T1 t1)
+     {
+          f(t1);
+     }
+
+     template <typename T1, typename T2, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f, T1 t1, T2 t2)
+     {
+          f(t1, t2);
+     }
+
+     template <typename T1, typename T2, typename T3, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3)
+     {
+          f(t1, t2, t3);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4)
+     {
+          f(t1, t2, t3, t4);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     {
+          f(t1, t2, t3, t4, t5);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     {
+          f(t1, t2, t3, t4, t5, t6);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7, t8);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7, t8, t9);
+     }
+};
Index: /code/branches/physics/src/cpptcl/details/metahelpers.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/metahelpers.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/metahelpers.h	(revision 2122)
@@ -0,0 +1,86 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8,
+          typename T9>
+struct get_callback_type_for_construct
+{
+     typedef callback9<C*, T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, T7, T8, void>
+{
+     typedef callback8<C*, T1, T2, T3, T4, T5, T6, T7, T8> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, T7, void, void>
+{
+     typedef callback7<C*, T1, T2, T3, T4, T5, T6, T7> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, void, void, void>
+{
+     typedef callback6<C*, T1, T2, T3, T4, T5, T6> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, void, void, void, void>
+{
+     typedef callback5<C*, T1, T2, T3, T4, T5> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, void, void, void, void, void>
+{
+     typedef callback4<C*, T1, T2, T3, T4> type;
+};
+
+template <class C, typename T1, typename T2, typename T3>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, void, void, void, void, void, void>
+{
+     typedef callback3<C*, T1, T2, T3> type;
+};
+
+template <class C, typename T1, typename T2>
+struct get_callback_type_for_construct<
+     C, T1, T2, void, void, void, void, void, void, void>
+{
+     typedef callback2<C*, T1, T2> type;
+};
+
+template <class C, typename T1>
+struct get_callback_type_for_construct<
+     C, T1, void, void, void, void, void, void, void, void>
+{
+     typedef callback1<C*, T1> type;
+};
+
+template <class C>
+struct get_callback_type_for_construct<
+     C, void, void, void, void, void, void, void, void, void>
+{
+     typedef callback0<C*> type;
+};
Index: /code/branches/physics/src/cpptcl/details/methods.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/methods.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/methods.h	(revision 2122)
@@ -0,0 +1,452 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename R>
+class method0 : public object_cmd_base
+{
+     typedef R (C::*mem_type)();
+     typedef R (C::*cmem_type)() const;
+     
+public:
+     method0(mem_type f) : f_(f), cmem_(false) {}
+     method0(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int, Tcl_Obj * CONST [], policies const &)
+     {
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::do_dispatch(interp, boost::bind(cf_, p));
+          }
+          else
+          {
+               dispatch<R>::do_dispatch(interp, boost::bind(f_, p));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1>
+class method1 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1);
+     typedef R (C::*cmem_type)(T1) const;
+     
+public:
+     method1(mem_type f) : f_(f), cmem_(false) {}
+     method1(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 3);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(cf_, p, _1),
+                    tcl_cast<T1>::from(interp, objv[2]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(f_, p, _1),
+                    tcl_cast<T1>::from(interp, objv[2]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2>
+class method2 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2);
+     typedef R (C::*cmem_type)(T1, T2) const;
+     
+public:
+     method2(mem_type f) : f_(f), cmem_(false) {}
+     method2(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 4);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(cf_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(f_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3>
+class method3 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3);
+     typedef R (C::*cmem_type)(T1, T2, T3) const;
+     
+public:
+     method3(mem_type f) : f_(f), cmem_(false) {}
+     method3(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 5);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(cf_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(f_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4>
+class method4 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4) const;
+     
+public:
+     method4(mem_type f) : f_(f), cmem_(false) {}
+     method4(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 6);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5>
+class method5 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5) const;
+     
+public:
+     method5(mem_type f) : f_(f), cmem_(false) {}
+     method5(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 7);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6>
+class method6 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6) const;
+     
+public:
+     method6(mem_type f) : f_(f), cmem_(false) {}
+     method6(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 8);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7>
+class method7 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7) const;
+     
+public:
+     method7(mem_type f) : f_(f), cmem_(false) {}
+     method7(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 9);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8>
+class method8 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8) const;
+     
+public:
+     method8(mem_type f) : f_(f), cmem_(false) {}
+     method8(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 10);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8,
+     typename T9>
+class method9 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const;
+     
+public:
+     method9(mem_type f) : f_(f), cmem_(false) {}
+     method9(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 11);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    tcl_cast<T9>::from(interp, objv[10]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    tcl_cast<T9>::from(interp, objv[10]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
Index: /code/branches/physics/src/cpptcl/details/methods_v.h
===================================================================
--- /code/branches/physics/src/cpptcl/details/methods_v.h	(revision 2122)
+++ /code/branches/physics/src/cpptcl/details/methods_v.h	(revision 2122)
@@ -0,0 +1,451 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename R>
+class method1<C, R, object const &> : public object_cmd_base
+{
+     typedef object const & T1;
+     typedef R (C::*mem_type)(T1);
+     typedef R (C::*cmem_type)(T1) const;
+     enum { var_start = 2 };
+     
+public:
+     method1(mem_type f) : f_(f), cmem_(false) {}
+     method1(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t1 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(cf_, p, _1),
+                    t1);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(f_, p, _1),
+                    t1);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1>
+class method2<C, R, T1, object const &> : public object_cmd_base
+{
+     typedef object const & T2;
+     typedef R (C::*mem_type)(T1, T2);
+     typedef R (C::*cmem_type)(T1, T2) const;
+     enum { var_start = 3 };
+     
+public:
+     method2(mem_type f) : f_(f), cmem_(false) {}
+     method2(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t2 = get_var_params(interp, objc, objv, var_start, pol);
+          
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(cf_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    t2);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(f_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    t2);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2>
+class method3<C, R, T1, T2, object const &> : public object_cmd_base
+{
+     typedef object const & T3;
+     typedef R (C::*mem_type)(T1, T2, T3);
+     typedef R (C::*cmem_type)(T1, T2, T3) const;
+     enum { var_start = 4 };
+     
+public:
+     method3(mem_type f) : f_(f), cmem_(false) {}
+     method3(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t3 = get_var_params(interp, objc, objv, var_start, pol);
+          
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(cf_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    t3);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(f_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    t3);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3>
+class method4<C, R, T1, T2, T3, object const &> : public object_cmd_base
+{
+     typedef object const & T4;
+     typedef R (C::*mem_type)(T1, T2, T3, T4);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4) const;
+     enum { var_start = 5 };
+     
+public:
+     method4(mem_type f) : f_(f), cmem_(false) {}
+     method4(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t4 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    t4);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    t4);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4>
+class method5<C, R, T1, T2, T3, T4, object const &> : public object_cmd_base
+{
+     typedef object const & T5;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5) const;
+     enum { var_start = 6 };
+     
+public:
+     method5(mem_type f) : f_(f), cmem_(false) {}
+     method5(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t5 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    t5);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    t5);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5>
+class method6<C, R, T1, T2, T3, T4, T5, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T6;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6) const;
+     enum { var_start = 7 };
+     
+public:
+     method6(mem_type f) : f_(f), cmem_(false) {}
+     method6(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t6 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    t6);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    t6);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6>
+class method7<C, R, T1, T2, T3, T4, T5, T6, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T7;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7) const;
+     enum { var_start = 8 };
+     
+public:
+     method7(mem_type f) : f_(f), cmem_(false) {}
+     method7(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t7 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    t7);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    t7);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7>
+class method8<C, R, T1, T2, T3, T4, T5, T6, T7, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T8;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8) const;
+     enum { var_start = 9 };
+     
+public:
+     method8(mem_type f) : f_(f), cmem_(false) {}
+     method8(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t8 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    t8);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    t8);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8>
+class method9<C, R, T1, T2, T3, T4, T5, T6, T7, T8, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T9;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const;
+     enum { var_start = 10 };
+     
+public:
+     method9(mem_type f) : f_(f), cmem_(false) {}
+     method9(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t9 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    t9);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    t9);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
Index: /code/branches/physics/src/lua/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/lua/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/lua/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,35 @@
+INCLUDE_DIRECTORIES(.)
+
+SET( LUA_SRC_FILES
+  lapi.c
+  lauxlib.c
+  lbaselib.c
+  lcode.c
+  ldblib.c
+  ldebug.c
+  ldo.c
+  ldump.c
+  lfunc.c
+  lgc.c
+  linit.c
+  liolib.c
+  llex.c
+  lmathlib.c
+  lmem.c
+  loadlib.c
+  lobject.c
+  lopcodes.c
+  loslib.c
+  lparser.c
+  lstate.c
+  lstring.c
+  lstrlib.c
+  ltable.c
+  ltablib.c
+  ltm.c
+  lundump.c
+  lvm.c
+  lzio.c
+)
+
+ADD_LIBRARY( lua_orxonox SHARED ${LUA_SRC_FILES} )
Index: /code/branches/physics/src/lua/COPYRIGHT
===================================================================
--- /code/branches/physics/src/lua/COPYRIGHT	(revision 2122)
+++ /code/branches/physics/src/lua/COPYRIGHT	(revision 2122)
@@ -0,0 +1,34 @@
+Lua License
+-----------
+
+Lua is licensed under the terms of the MIT license reproduced below.
+This means that Lua is free software and can be used for both academic
+and commercial purposes at absolutely no cost.
+
+For details and rationale, see http://www.lua.org/license.html .
+
+===============================================================================
+
+Copyright (C) 1994-2008 Lua.org, PUC-Rio.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+===============================================================================
+
+(end of COPYRIGHT)
Index: /code/branches/physics/src/lua/README
===================================================================
--- /code/branches/physics/src/lua/README	(revision 2122)
+++ /code/branches/physics/src/lua/README	(revision 2122)
@@ -0,0 +1,28 @@
+README for Lua 5.1
+
+* What is Lua?
+  ------------
+  Lua is a powerful, light-weight programming language designed for extending
+  applications. Lua is also frequently used as a general-purpose, stand-alone
+  language. Lua is free software.
+
+  For complete information, visit Lua's web site at http://www.lua.org/ .
+  For an executive summary, see http://www.lua.org/about.html .
+
+  Lua has been used in many different projects around the world.
+  For a short list, see http://www.lua.org/uses.html .
+
+* Availability
+  ------------
+  Lua is freely available for both academic and commercial purposes.
+  See COPYRIGHT and http://www.lua.org/license.html for details.
+  Lua can be downloaded at http://www.lua.org/download.html .
+
+* Origin
+  ------
+  Lua is developed at Lua.org, a laboratory of the Department of Computer
+  Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro
+  in Brazil).
+  For more information about the authors, see http://www.lua.org/authors.html .
+
+(end of README)
Index: /code/branches/physics/src/lua/lapi.c
===================================================================
--- /code/branches/physics/src/lua/lapi.c	(revision 2122)
+++ /code/branches/physics/src/lua/lapi.c	(revision 2122)
@@ -0,0 +1,1085 @@
+/*
+** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $
+** Lua API
+** See Copyright Notice in lua.h
+*/
+
+
+#include <assert.h>
+#include <math.h>
+#include <stdarg.h>
+#include <string.h>
+
+#define lapi_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lapi.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lundump.h"
+#include "lvm.h"
+
+
+
+const char lua_ident[] =
+  "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
+  "$Authors: " LUA_AUTHORS " $\n"
+  "$URL: www.lua.org $\n";
+
+
+
+#define api_checknelems(L, n)	api_check(L, (n) <= (L->top - L->base))
+
+#define api_checkvalidindex(L, i)	api_check(L, (i) != luaO_nilobject)
+
+#define api_incr_top(L)   {api_check(L, L->top < L->ci->top); L->top++;}
+
+
+
+static TValue *index2adr (lua_State *L, int idx) {
+  if (idx > 0) {
+    TValue *o = L->base + (idx - 1);
+    api_check(L, idx <= L->ci->top - L->base);
+    if (o >= L->top) return cast(TValue *, luaO_nilobject);
+    else return o;
+  }
+  else if (idx > LUA_REGISTRYINDEX) {
+    api_check(L, idx != 0 && -idx <= L->top - L->base);
+    return L->top + idx;
+  }
+  else switch (idx) {  /* pseudo-indices */
+    case LUA_REGISTRYINDEX: return registry(L);
+    case LUA_ENVIRONINDEX: {
+      Closure *func = curr_func(L);
+      sethvalue(L, &L->env, func->c.env);
+      return &L->env;
+    }
+    case LUA_GLOBALSINDEX: return gt(L);
+    default: {
+      Closure *func = curr_func(L);
+      idx = LUA_GLOBALSINDEX - idx;
+      return (idx <= func->c.nupvalues)
+                ? &func->c.upvalue[idx-1]
+                : cast(TValue *, luaO_nilobject);
+    }
+  }
+}
+
+
+static Table *getcurrenv (lua_State *L) {
+  if (L->ci == L->base_ci)  /* no enclosing function? */
+    return hvalue(gt(L));  /* use global table as environment */
+  else {
+    Closure *func = curr_func(L);
+    return func->c.env;
+  }
+}
+
+
+void luaA_pushobject (lua_State *L, const TValue *o) {
+  setobj2s(L, L->top, o);
+  api_incr_top(L);
+}
+
+
+LUA_API int lua_checkstack (lua_State *L, int size) {
+  int res;
+  lua_lock(L);
+  if ((L->top - L->base + size) > LUAI_MAXCSTACK)
+    res = 0;  /* stack overflow */
+  else {
+    luaD_checkstack(L, size);
+    if (L->ci->top < L->top + size)
+      L->ci->top = L->top + size;
+    res = 1;
+  }
+  lua_unlock(L);
+  return res;
+}
+
+
+LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
+  int i;
+  if (from == to) return;
+  lua_lock(to);
+  api_checknelems(from, n);
+  api_check(from, G(from) == G(to));
+  api_check(from, to->ci->top - to->top >= n);
+  from->top -= n;
+  for (i = 0; i < n; i++) {
+    setobj2s(to, to->top++, from->top + i);
+  }
+  lua_unlock(to);
+}
+
+
+LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
+  to->nCcalls = from->nCcalls;
+}
+
+
+LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
+  lua_CFunction old;
+  lua_lock(L);
+  old = G(L)->panic;
+  G(L)->panic = panicf;
+  lua_unlock(L);
+  return old;
+}
+
+
+LUA_API lua_State *lua_newthread (lua_State *L) {
+  lua_State *L1;
+  lua_lock(L);
+  luaC_checkGC(L);
+  L1 = luaE_newthread(L);
+  setthvalue(L, L->top, L1);
+  api_incr_top(L);
+  lua_unlock(L);
+  luai_userstatethread(L, L1);
+  return L1;
+}
+
+
+
+/*
+** basic stack manipulation
+*/
+
+
+LUA_API int lua_gettop (lua_State *L) {
+  return cast_int(L->top - L->base);
+}
+
+
+LUA_API void lua_settop (lua_State *L, int idx) {
+  lua_lock(L);
+  if (idx >= 0) {
+    api_check(L, idx <= L->stack_last - L->base);
+    while (L->top < L->base + idx)
+      setnilvalue(L->top++);
+    L->top = L->base + idx;
+  }
+  else {
+    api_check(L, -(idx+1) <= (L->top - L->base));
+    L->top += idx+1;  /* `subtract' index (index is negative) */
+  }
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_remove (lua_State *L, int idx) {
+  StkId p;
+  lua_lock(L);
+  p = index2adr(L, idx);
+  api_checkvalidindex(L, p);
+  while (++p < L->top) setobjs2s(L, p-1, p);
+  L->top--;
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_insert (lua_State *L, int idx) {
+  StkId p;
+  StkId q;
+  lua_lock(L);
+  p = index2adr(L, idx);
+  api_checkvalidindex(L, p);
+  for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
+  setobjs2s(L, p, L->top);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_replace (lua_State *L, int idx) {
+  StkId o;
+  lua_lock(L);
+  /* explicit test for incompatible code */
+  if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
+    luaG_runerror(L, "no calling environment");
+  api_checknelems(L, 1);
+  o = index2adr(L, idx);
+  api_checkvalidindex(L, o);
+  if (idx == LUA_ENVIRONINDEX) {
+    Closure *func = curr_func(L);
+    api_check(L, ttistable(L->top - 1)); 
+    func->c.env = hvalue(L->top - 1);
+    luaC_barrier(L, func, L->top - 1);
+  }
+  else {
+    setobj(L, o, L->top - 1);
+    if (idx < LUA_GLOBALSINDEX)  /* function upvalue? */
+      luaC_barrier(L, curr_func(L), L->top - 1);
+  }
+  L->top--;
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_pushvalue (lua_State *L, int idx) {
+  lua_lock(L);
+  setobj2s(L, L->top, index2adr(L, idx));
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+
+/*
+** access functions (stack -> C)
+*/
+
+
+LUA_API int lua_type (lua_State *L, int idx) {
+  StkId o = index2adr(L, idx);
+  return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
+}
+
+
+LUA_API const char *lua_typename (lua_State *L, int t) {
+  UNUSED(L);
+  return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+}
+
+
+LUA_API int lua_iscfunction (lua_State *L, int idx) {
+  StkId o = index2adr(L, idx);
+  return iscfunction(o);
+}
+
+
+LUA_API int lua_isnumber (lua_State *L, int idx) {
+  TValue n;
+  const TValue *o = index2adr(L, idx);
+  return tonumber(o, &n);
+}
+
+
+LUA_API int lua_isstring (lua_State *L, int idx) {
+  int t = lua_type(L, idx);
+  return (t == LUA_TSTRING || t == LUA_TNUMBER);
+}
+
+
+LUA_API int lua_isuserdata (lua_State *L, int idx) {
+  const TValue *o = index2adr(L, idx);
+  return (ttisuserdata(o) || ttislightuserdata(o));
+}
+
+
+LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
+  StkId o1 = index2adr(L, index1);
+  StkId o2 = index2adr(L, index2);
+  return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
+         : luaO_rawequalObj(o1, o2);
+}
+
+
+LUA_API int lua_equal (lua_State *L, int index1, int index2) {
+  StkId o1, o2;
+  int i;
+  lua_lock(L);  /* may call tag method */
+  o1 = index2adr(L, index1);
+  o2 = index2adr(L, index2);
+  i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2);
+  lua_unlock(L);
+  return i;
+}
+
+
+LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
+  StkId o1, o2;
+  int i;
+  lua_lock(L);  /* may call tag method */
+  o1 = index2adr(L, index1);
+  o2 = index2adr(L, index2);
+  i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
+       : luaV_lessthan(L, o1, o2);
+  lua_unlock(L);
+  return i;
+}
+
+
+
+LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
+  TValue n;
+  const TValue *o = index2adr(L, idx);
+  if (tonumber(o, &n))
+    return nvalue(o);
+  else
+    return 0;
+}
+
+
+LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
+  TValue n;
+  const TValue *o = index2adr(L, idx);
+  if (tonumber(o, &n)) {
+    lua_Integer res;
+    lua_Number num = nvalue(o);
+    lua_number2integer(res, num);
+    return res;
+  }
+  else
+    return 0;
+}
+
+
+LUA_API int lua_toboolean (lua_State *L, int idx) {
+  const TValue *o = index2adr(L, idx);
+  return !l_isfalse(o);
+}
+
+
+LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
+  StkId o = index2adr(L, idx);
+  if (!ttisstring(o)) {
+    lua_lock(L);  /* `luaV_tostring' may create a new string */
+    if (!luaV_tostring(L, o)) {  /* conversion failed? */
+      if (len != NULL) *len = 0;
+      lua_unlock(L);
+      return NULL;
+    }
+    luaC_checkGC(L);
+    o = index2adr(L, idx);  /* previous call may reallocate the stack */
+    lua_unlock(L);
+  }
+  if (len != NULL) *len = tsvalue(o)->len;
+  return svalue(o);
+}
+
+
+LUA_API size_t lua_objlen (lua_State *L, int idx) {
+  StkId o = index2adr(L, idx);
+  switch (ttype(o)) {
+    case LUA_TSTRING: return tsvalue(o)->len;
+    case LUA_TUSERDATA: return uvalue(o)->len;
+    case LUA_TTABLE: return luaH_getn(hvalue(o));
+    case LUA_TNUMBER: {
+      size_t l;
+      lua_lock(L);  /* `luaV_tostring' may create a new string */
+      l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
+      lua_unlock(L);
+      return l;
+    }
+    default: return 0;
+  }
+}
+
+
+LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
+  StkId o = index2adr(L, idx);
+  return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
+}
+
+
+LUA_API void *lua_touserdata (lua_State *L, int idx) {
+  StkId o = index2adr(L, idx);
+  switch (ttype(o)) {
+    case LUA_TUSERDATA: return (rawuvalue(o) + 1);
+    case LUA_TLIGHTUSERDATA: return pvalue(o);
+    default: return NULL;
+  }
+}
+
+
+LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
+  StkId o = index2adr(L, idx);
+  return (!ttisthread(o)) ? NULL : thvalue(o);
+}
+
+
+LUA_API const void *lua_topointer (lua_State *L, int idx) {
+  StkId o = index2adr(L, idx);
+  switch (ttype(o)) {
+    case LUA_TTABLE: return hvalue(o);
+    case LUA_TFUNCTION: return clvalue(o);
+    case LUA_TTHREAD: return thvalue(o);
+    case LUA_TUSERDATA:
+    case LUA_TLIGHTUSERDATA:
+      return lua_touserdata(L, idx);
+    default: return NULL;
+  }
+}
+
+
+
+/*
+** push functions (C -> stack)
+*/
+
+
+LUA_API void lua_pushnil (lua_State *L) {
+  lua_lock(L);
+  setnilvalue(L->top);
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
+  lua_lock(L);
+  setnvalue(L->top, n);
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
+  lua_lock(L);
+  setnvalue(L->top, cast_num(n));
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
+  lua_lock(L);
+  luaC_checkGC(L);
+  setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_pushstring (lua_State *L, const char *s) {
+  if (s == NULL)
+    lua_pushnil(L);
+  else
+    lua_pushlstring(L, s, strlen(s));
+}
+
+
+LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
+                                      va_list argp) {
+  const char *ret;
+  lua_lock(L);
+  luaC_checkGC(L);
+  ret = luaO_pushvfstring(L, fmt, argp);
+  lua_unlock(L);
+  return ret;
+}
+
+
+LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
+  const char *ret;
+  va_list argp;
+  lua_lock(L);
+  luaC_checkGC(L);
+  va_start(argp, fmt);
+  ret = luaO_pushvfstring(L, fmt, argp);
+  va_end(argp);
+  lua_unlock(L);
+  return ret;
+}
+
+
+LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
+  Closure *cl;
+  lua_lock(L);
+  luaC_checkGC(L);
+  api_checknelems(L, n);
+  cl = luaF_newCclosure(L, n, getcurrenv(L));
+  cl->c.f = fn;
+  L->top -= n;
+  while (n--)
+    setobj2n(L, &cl->c.upvalue[n], L->top+n);
+  setclvalue(L, L->top, cl);
+  lua_assert(iswhite(obj2gco(cl)));
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_pushboolean (lua_State *L, int b) {
+  lua_lock(L);
+  setbvalue(L->top, (b != 0));  /* ensure that true is 1 */
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
+  lua_lock(L);
+  setpvalue(L->top, p);
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API int lua_pushthread (lua_State *L) {
+  lua_lock(L);
+  setthvalue(L, L->top, L);
+  api_incr_top(L);
+  lua_unlock(L);
+  return (G(L)->mainthread == L);
+}
+
+
+
+/*
+** get functions (Lua -> stack)
+*/
+
+
+LUA_API void lua_gettable (lua_State *L, int idx) {
+  StkId t;
+  lua_lock(L);
+  t = index2adr(L, idx);
+  api_checkvalidindex(L, t);
+  luaV_gettable(L, t, L->top - 1, L->top - 1);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
+  StkId t;
+  TValue key;
+  lua_lock(L);
+  t = index2adr(L, idx);
+  api_checkvalidindex(L, t);
+  setsvalue(L, &key, luaS_new(L, k));
+  luaV_gettable(L, t, &key, L->top);
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_rawget (lua_State *L, int idx) {
+  StkId t;
+  lua_lock(L);
+  t = index2adr(L, idx);
+  api_check(L, ttistable(t));
+  setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
+  StkId o;
+  lua_lock(L);
+  o = index2adr(L, idx);
+  api_check(L, ttistable(o));
+  setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
+  lua_lock(L);
+  luaC_checkGC(L);
+  sethvalue(L, L->top, luaH_new(L, narray, nrec));
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+LUA_API int lua_getmetatable (lua_State *L, int objindex) {
+  const TValue *obj;
+  Table *mt = NULL;
+  int res;
+  lua_lock(L);
+  obj = index2adr(L, objindex);
+  switch (ttype(obj)) {
+    case LUA_TTABLE:
+      mt = hvalue(obj)->metatable;
+      break;
+    case LUA_TUSERDATA:
+      mt = uvalue(obj)->metatable;
+      break;
+    default:
+      mt = G(L)->mt[ttype(obj)];
+      break;
+  }
+  if (mt == NULL)
+    res = 0;
+  else {
+    sethvalue(L, L->top, mt);
+    api_incr_top(L);
+    res = 1;
+  }
+  lua_unlock(L);
+  return res;
+}
+
+
+LUA_API void lua_getfenv (lua_State *L, int idx) {
+  StkId o;
+  lua_lock(L);
+  o = index2adr(L, idx);
+  api_checkvalidindex(L, o);
+  switch (ttype(o)) {
+    case LUA_TFUNCTION:
+      sethvalue(L, L->top, clvalue(o)->c.env);
+      break;
+    case LUA_TUSERDATA:
+      sethvalue(L, L->top, uvalue(o)->env);
+      break;
+    case LUA_TTHREAD:
+      setobj2s(L, L->top,  gt(thvalue(o)));
+      break;
+    default:
+      setnilvalue(L->top);
+      break;
+  }
+  api_incr_top(L);
+  lua_unlock(L);
+}
+
+
+/*
+** set functions (stack -> Lua)
+*/
+
+
+LUA_API void lua_settable (lua_State *L, int idx) {
+  StkId t;
+  lua_lock(L);
+  api_checknelems(L, 2);
+  t = index2adr(L, idx);
+  api_checkvalidindex(L, t);
+  luaV_settable(L, t, L->top - 2, L->top - 1);
+  L->top -= 2;  /* pop index and value */
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
+  StkId t;
+  TValue key;
+  lua_lock(L);
+  api_checknelems(L, 1);
+  t = index2adr(L, idx);
+  api_checkvalidindex(L, t);
+  setsvalue(L, &key, luaS_new(L, k));
+  luaV_settable(L, t, &key, L->top - 1);
+  L->top--;  /* pop value */
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_rawset (lua_State *L, int idx) {
+  StkId t;
+  lua_lock(L);
+  api_checknelems(L, 2);
+  t = index2adr(L, idx);
+  api_check(L, ttistable(t));
+  setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
+  luaC_barriert(L, hvalue(t), L->top-1);
+  L->top -= 2;
+  lua_unlock(L);
+}
+
+
+LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
+  StkId o;
+  lua_lock(L);
+  api_checknelems(L, 1);
+  o = index2adr(L, idx);
+  api_check(L, ttistable(o));
+  setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
+  luaC_barriert(L, hvalue(o), L->top-1);
+  L->top--;
+  lua_unlock(L);
+}
+
+
+LUA_API int lua_setmetatable (lua_State *L, int objindex) {
+  TValue *obj;
+  Table *mt;
+  lua_lock(L);
+  api_checknelems(L, 1);
+  obj = index2adr(L, objindex);
+  api_checkvalidindex(L, obj);
+  if (ttisnil(L->top - 1))
+    mt = NULL;
+  else {
+    api_check(L, ttistable(L->top - 1));
+    mt = hvalue(L->top - 1);
+  }
+  switch (ttype(obj)) {
+    case LUA_TTABLE: {
+      hvalue(obj)->metatable = mt;
+      if (mt)
+        luaC_objbarriert(L, hvalue(obj), mt);
+      break;
+    }
+    case LUA_TUSERDATA: {
+      uvalue(obj)->metatable = mt;
+      if (mt)
+        luaC_objbarrier(L, rawuvalue(obj), mt);
+      break;
+    }
+    default: {
+      G(L)->mt[ttype(obj)] = mt;
+      break;
+    }
+  }
+  L->top--;
+  lua_unlock(L);
+  return 1;
+}
+
+
+LUA_API int lua_setfenv (lua_State *L, int idx) {
+  StkId o;
+  int res = 1;
+  lua_lock(L);
+  api_checknelems(L, 1);
+  o = index2adr(L, idx);
+  api_checkvalidindex(L, o);
+  api_check(L, ttistable(L->top - 1));
+  switch (ttype(o)) {
+    case LUA_TFUNCTION:
+      clvalue(o)->c.env = hvalue(L->top - 1);
+      break;
+    case LUA_TUSERDATA:
+      uvalue(o)->env = hvalue(L->top - 1);
+      break;
+    case LUA_TTHREAD:
+      sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
+      break;
+    default:
+      res = 0;
+      break;
+  }
+  if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
+  L->top--;
+  lua_unlock(L);
+  return res;
+}
+
+
+/*
+** `load' and `call' functions (run Lua code)
+*/
+
+
+#define adjustresults(L,nres) \
+    { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }
+
+
+#define checkresults(L,na,nr) \
+     api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
+	
+
+LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
+  StkId func;
+  lua_lock(L);
+  api_checknelems(L, nargs+1);
+  checkresults(L, nargs, nresults);
+  func = L->top - (nargs+1);
+  luaD_call(L, func, nresults);
+  adjustresults(L, nresults);
+  lua_unlock(L);
+}
+
+
+
+/*
+** Execute a protected call.
+*/
+struct CallS {  /* data to `f_call' */
+  StkId func;
+  int nresults;
+};
+
+
+static void f_call (lua_State *L, void *ud) {
+  struct CallS *c = cast(struct CallS *, ud);
+  luaD_call(L, c->func, c->nresults);
+}
+
+
+
+LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
+  struct CallS c;
+  int status;
+  ptrdiff_t func;
+  lua_lock(L);
+  api_checknelems(L, nargs+1);
+  checkresults(L, nargs, nresults);
+  if (errfunc == 0)
+    func = 0;
+  else {
+    StkId o = index2adr(L, errfunc);
+    api_checkvalidindex(L, o);
+    func = savestack(L, o);
+  }
+  c.func = L->top - (nargs+1);  /* function to be called */
+  c.nresults = nresults;
+  status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
+  adjustresults(L, nresults);
+  lua_unlock(L);
+  return status;
+}
+
+
+/*
+** Execute a protected C call.
+*/
+struct CCallS {  /* data to `f_Ccall' */
+  lua_CFunction func;
+  void *ud;
+};
+
+
+static void f_Ccall (lua_State *L, void *ud) {
+  struct CCallS *c = cast(struct CCallS *, ud);
+  Closure *cl;
+  cl = luaF_newCclosure(L, 0, getcurrenv(L));
+  cl->c.f = c->func;
+  setclvalue(L, L->top, cl);  /* push function */
+  api_incr_top(L);
+  setpvalue(L->top, c->ud);  /* push only argument */
+  api_incr_top(L);
+  luaD_call(L, L->top - 2, 0);
+}
+
+
+LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
+  struct CCallS c;
+  int status;
+  lua_lock(L);
+  c.func = func;
+  c.ud = ud;
+  status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0);
+  lua_unlock(L);
+  return status;
+}
+
+
+LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
+                      const char *chunkname) {
+  ZIO z;
+  int status;
+  lua_lock(L);
+  if (!chunkname) chunkname = "?";
+  luaZ_init(L, &z, reader, data);
+  status = luaD_protectedparser(L, &z, chunkname);
+  lua_unlock(L);
+  return status;
+}
+
+
+LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
+  int status;
+  TValue *o;
+  lua_lock(L);
+  api_checknelems(L, 1);
+  o = L->top - 1;
+  if (isLfunction(o))
+    status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
+  else
+    status = 1;
+  lua_unlock(L);
+  return status;
+}
+
+
+LUA_API int  lua_status (lua_State *L) {
+  return L->status;
+}
+
+
+/*
+** Garbage-collection function
+*/
+
+LUA_API int lua_gc (lua_State *L, int what, int data) {
+  int res = 0;
+  global_State *g;
+  lua_lock(L);
+  g = G(L);
+  switch (what) {
+    case LUA_GCSTOP: {
+      g->GCthreshold = MAX_LUMEM;
+      break;
+    }
+    case LUA_GCRESTART: {
+      g->GCthreshold = g->totalbytes;
+      break;
+    }
+    case LUA_GCCOLLECT: {
+      luaC_fullgc(L);
+      break;
+    }
+    case LUA_GCCOUNT: {
+      /* GC values are expressed in Kbytes: #bytes/2^10 */
+      res = cast_int(g->totalbytes >> 10);
+      break;
+    }
+    case LUA_GCCOUNTB: {
+      res = cast_int(g->totalbytes & 0x3ff);
+      break;
+    }
+    case LUA_GCSTEP: {
+      lu_mem a = (cast(lu_mem, data) << 10);
+      if (a <= g->totalbytes)
+        g->GCthreshold = g->totalbytes - a;
+      else
+        g->GCthreshold = 0;
+      while (g->GCthreshold <= g->totalbytes)
+        luaC_step(L);
+      if (g->gcstate == GCSpause)  /* end of cycle? */
+        res = 1;  /* signal it */
+      break;
+    }
+    case LUA_GCSETPAUSE: {
+      res = g->gcpause;
+      g->gcpause = data;
+      break;
+    }
+    case LUA_GCSETSTEPMUL: {
+      res = g->gcstepmul;
+      g->gcstepmul = data;
+      break;
+    }
+    default: res = -1;  /* invalid option */
+  }
+  lua_unlock(L);
+  return res;
+}
+
+
+
+/*
+** miscellaneous functions
+*/
+
+
+LUA_API int lua_error (lua_State *L) {
+  lua_lock(L);
+  api_checknelems(L, 1);
+  luaG_errormsg(L);
+  lua_unlock(L);
+  return 0;  /* to avoid warnings */
+}
+
+
+LUA_API int lua_next (lua_State *L, int idx) {
+  StkId t;
+  int more;
+  lua_lock(L);
+  t = index2adr(L, idx);
+  api_check(L, ttistable(t));
+  more = luaH_next(L, hvalue(t), L->top - 1);
+  if (more) {
+    api_incr_top(L);
+  }
+  else  /* no more elements */
+    L->top -= 1;  /* remove key */
+  lua_unlock(L);
+  return more;
+}
+
+
+LUA_API void lua_concat (lua_State *L, int n) {
+  lua_lock(L);
+  api_checknelems(L, n);
+  if (n >= 2) {
+    luaC_checkGC(L);
+    luaV_concat(L, n, cast_int(L->top - L->base) - 1);
+    L->top -= (n-1);
+  }
+  else if (n == 0) {  /* push empty string */
+    setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
+    api_incr_top(L);
+  }
+  /* else n == 1; nothing to do */
+  lua_unlock(L);
+}
+
+
+LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
+  lua_Alloc f;
+  lua_lock(L);
+  if (ud) *ud = G(L)->ud;
+  f = G(L)->frealloc;
+  lua_unlock(L);
+  return f;
+}
+
+
+LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
+  lua_lock(L);
+  G(L)->ud = ud;
+  G(L)->frealloc = f;
+  lua_unlock(L);
+}
+
+
+LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
+  Udata *u;
+  lua_lock(L);
+  luaC_checkGC(L);
+  u = luaS_newudata(L, size, getcurrenv(L));
+  setuvalue(L, L->top, u);
+  api_incr_top(L);
+  lua_unlock(L);
+  return u + 1;
+}
+
+
+
+
+static const char *aux_upvalue (StkId fi, int n, TValue **val) {
+  Closure *f;
+  if (!ttisfunction(fi)) return NULL;
+  f = clvalue(fi);
+  if (f->c.isC) {
+    if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
+    *val = &f->c.upvalue[n-1];
+    return "";
+  }
+  else {
+    Proto *p = f->l.p;
+    if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
+    *val = f->l.upvals[n-1]->v;
+    return getstr(p->upvalues[n-1]);
+  }
+}
+
+
+LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
+  const char *name;
+  TValue *val;
+  lua_lock(L);
+  name = aux_upvalue(index2adr(L, funcindex), n, &val);
+  if (name) {
+    setobj2s(L, L->top, val);
+    api_incr_top(L);
+  }
+  lua_unlock(L);
+  return name;
+}
+
+
+LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
+  const char *name;
+  TValue *val;
+  StkId fi;
+  lua_lock(L);
+  fi = index2adr(L, funcindex);
+  api_checknelems(L, 1);
+  name = aux_upvalue(fi, n, &val);
+  if (name) {
+    L->top--;
+    setobj(L, val, L->top);
+    luaC_barrier(L, clvalue(fi), L->top);
+  }
+  lua_unlock(L);
+  return name;
+}
+
Index: /code/branches/physics/src/lua/lapi.h
===================================================================
--- /code/branches/physics/src/lua/lapi.h	(revision 2122)
+++ /code/branches/physics/src/lua/lapi.h	(revision 2122)
@@ -0,0 +1,16 @@
+/*
+** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
+** Auxiliary functions from Lua API
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lapi_h
+#define lapi_h
+
+
+#include "lobject.h"
+
+
+LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
+
+#endif
Index: /code/branches/physics/src/lua/lauxlib.c
===================================================================
--- /code/branches/physics/src/lua/lauxlib.c	(revision 2122)
+++ /code/branches/physics/src/lua/lauxlib.c	(revision 2122)
@@ -0,0 +1,652 @@
+/*
+** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
+** Auxiliary functions for building Lua libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* This file uses only the official API of Lua.
+** Any function declared here could be written as an application function.
+*/
+
+#define lauxlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+
+
+#define FREELIST_REF	0	/* free list of references */
+
+
+/* convert a stack index to positive */
+#define abs_index(L, i)		((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
+					lua_gettop(L) + (i) + 1)
+
+
+/*
+** {======================================================
+** Error-report functions
+** =======================================================
+*/
+
+
+LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
+  lua_Debug ar;
+  if (!lua_getstack(L, 0, &ar))  /* no stack frame? */
+    return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
+  lua_getinfo(L, "n", &ar);
+  if (strcmp(ar.namewhat, "method") == 0) {
+    narg--;  /* do not count `self' */
+    if (narg == 0)  /* error is in the self argument itself? */
+      return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
+                           ar.name, extramsg);
+  }
+  if (ar.name == NULL)
+    ar.name = "?";
+  return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
+                        narg, ar.name, extramsg);
+}
+
+
+LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
+  const char *msg = lua_pushfstring(L, "%s expected, got %s",
+                                    tname, luaL_typename(L, narg));
+  return luaL_argerror(L, narg, msg);
+}
+
+
+static void tag_error (lua_State *L, int narg, int tag) {
+  luaL_typerror(L, narg, lua_typename(L, tag));
+}
+
+
+LUALIB_API void luaL_where (lua_State *L, int level) {
+  lua_Debug ar;
+  if (lua_getstack(L, level, &ar)) {  /* check function at level */
+    lua_getinfo(L, "Sl", &ar);  /* get info about it */
+    if (ar.currentline > 0) {  /* is there info? */
+      lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline);
+      return;
+    }
+  }
+  lua_pushliteral(L, "");  /* else, no information available... */
+}
+
+
+LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
+  va_list argp;
+  va_start(argp, fmt);
+  luaL_where(L, 1);
+  lua_pushvfstring(L, fmt, argp);
+  va_end(argp);
+  lua_concat(L, 2);
+  return lua_error(L);
+}
+
+/* }====================================================== */
+
+
+LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
+                                 const char *const lst[]) {
+  const char *name = (def) ? luaL_optstring(L, narg, def) :
+                             luaL_checkstring(L, narg);
+  int i;
+  for (i=0; lst[i]; i++)
+    if (strcmp(lst[i], name) == 0)
+      return i;
+  return luaL_argerror(L, narg,
+                       lua_pushfstring(L, "invalid option " LUA_QS, name));
+}
+
+
+LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
+  lua_getfield(L, LUA_REGISTRYINDEX, tname);  /* get registry.name */
+  if (!lua_isnil(L, -1))  /* name already in use? */
+    return 0;  /* leave previous value on top, but return 0 */
+  lua_pop(L, 1);
+  lua_newtable(L);  /* create metatable */
+  lua_pushvalue(L, -1);
+  lua_setfield(L, LUA_REGISTRYINDEX, tname);  /* registry.name = metatable */
+  return 1;
+}
+
+
+LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
+  void *p = lua_touserdata(L, ud);
+  if (p != NULL) {  /* value is a userdata? */
+    if (lua_getmetatable(L, ud)) {  /* does it have a metatable? */
+      lua_getfield(L, LUA_REGISTRYINDEX, tname);  /* get correct metatable */
+      if (lua_rawequal(L, -1, -2)) {  /* does it have the correct mt? */
+        lua_pop(L, 2);  /* remove both metatables */
+        return p;
+      }
+    }
+  }
+  luaL_typerror(L, ud, tname);  /* else error */
+  return NULL;  /* to avoid warnings */
+}
+
+
+LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
+  if (!lua_checkstack(L, space))
+    luaL_error(L, "stack overflow (%s)", mes);
+}
+
+
+LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
+  if (lua_type(L, narg) != t)
+    tag_error(L, narg, t);
+}
+
+
+LUALIB_API void luaL_checkany (lua_State *L, int narg) {
+  if (lua_type(L, narg) == LUA_TNONE)
+    luaL_argerror(L, narg, "value expected");
+}
+
+
+LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
+  const char *s = lua_tolstring(L, narg, len);
+  if (!s) tag_error(L, narg, LUA_TSTRING);
+  return s;
+}
+
+
+LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
+                                        const char *def, size_t *len) {
+  if (lua_isnoneornil(L, narg)) {
+    if (len)
+      *len = (def ? strlen(def) : 0);
+    return def;
+  }
+  else return luaL_checklstring(L, narg, len);
+}
+
+
+LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
+  lua_Number d = lua_tonumber(L, narg);
+  if (d == 0 && !lua_isnumber(L, narg))  /* avoid extra test when d is not 0 */
+    tag_error(L, narg, LUA_TNUMBER);
+  return d;
+}
+
+
+LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
+  return luaL_opt(L, luaL_checknumber, narg, def);
+}
+
+
+LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
+  lua_Integer d = lua_tointeger(L, narg);
+  if (d == 0 && !lua_isnumber(L, narg))  /* avoid extra test when d is not 0 */
+    tag_error(L, narg, LUA_TNUMBER);
+  return d;
+}
+
+
+LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
+                                                      lua_Integer def) {
+  return luaL_opt(L, luaL_checkinteger, narg, def);
+}
+
+
+LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
+  if (!lua_getmetatable(L, obj))  /* no metatable? */
+    return 0;
+  lua_pushstring(L, event);
+  lua_rawget(L, -2);
+  if (lua_isnil(L, -1)) {
+    lua_pop(L, 2);  /* remove metatable and metafield */
+    return 0;
+  }
+  else {
+    lua_remove(L, -2);  /* remove only metatable */
+    return 1;
+  }
+}
+
+
+LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
+  obj = abs_index(L, obj);
+  if (!luaL_getmetafield(L, obj, event))  /* no metafield? */
+    return 0;
+  lua_pushvalue(L, obj);
+  lua_call(L, 1, 1);
+  return 1;
+}
+
+
+LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
+                                const luaL_Reg *l) {
+  luaI_openlib(L, libname, l, 0);
+}
+
+
+static int libsize (const luaL_Reg *l) {
+  int size = 0;
+  for (; l->name; l++) size++;
+  return size;
+}
+
+
+LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
+                              const luaL_Reg *l, int nup) {
+  if (libname) {
+    int size = libsize(l);
+    /* check whether lib already exists */
+    luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
+    lua_getfield(L, -1, libname);  /* get _LOADED[libname] */
+    if (!lua_istable(L, -1)) {  /* not found? */
+      lua_pop(L, 1);  /* remove previous result */
+      /* try global variable (and create one if it does not exist) */
+      if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL)
+        luaL_error(L, "name conflict for module " LUA_QS, libname);
+      lua_pushvalue(L, -1);
+      lua_setfield(L, -3, libname);  /* _LOADED[libname] = new table */
+    }
+    lua_remove(L, -2);  /* remove _LOADED table */
+    lua_insert(L, -(nup+1));  /* move library table to below upvalues */
+  }
+  for (; l->name; l++) {
+    int i;
+    for (i=0; i<nup; i++)  /* copy upvalues to the top */
+      lua_pushvalue(L, -nup);
+    lua_pushcclosure(L, l->func, nup);
+    lua_setfield(L, -(nup+2), l->name);
+  }
+  lua_pop(L, nup);  /* remove upvalues */
+}
+
+
+
+/*
+** {======================================================
+** getn-setn: size for arrays
+** =======================================================
+*/
+
+#if defined(LUA_COMPAT_GETN)
+
+static int checkint (lua_State *L, int topop) {
+  int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
+  lua_pop(L, topop);
+  return n;
+}
+
+
+static void getsizes (lua_State *L) {
+  lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
+  if (lua_isnil(L, -1)) {  /* no `size' table? */
+    lua_pop(L, 1);  /* remove nil */
+    lua_newtable(L);  /* create it */
+    lua_pushvalue(L, -1);  /* `size' will be its own metatable */
+    lua_setmetatable(L, -2);
+    lua_pushliteral(L, "kv");
+    lua_setfield(L, -2, "__mode");  /* metatable(N).__mode = "kv" */
+    lua_pushvalue(L, -1);
+    lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");  /* store in register */
+  }
+}
+
+
+LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
+  t = abs_index(L, t);
+  lua_pushliteral(L, "n");
+  lua_rawget(L, t);
+  if (checkint(L, 1) >= 0) {  /* is there a numeric field `n'? */
+    lua_pushliteral(L, "n");  /* use it */
+    lua_pushinteger(L, n);
+    lua_rawset(L, t);
+  }
+  else {  /* use `sizes' */
+    getsizes(L);
+    lua_pushvalue(L, t);
+    lua_pushinteger(L, n);
+    lua_rawset(L, -3);  /* sizes[t] = n */
+    lua_pop(L, 1);  /* remove `sizes' */
+  }
+}
+
+
+LUALIB_API int luaL_getn (lua_State *L, int t) {
+  int n;
+  t = abs_index(L, t);
+  lua_pushliteral(L, "n");  /* try t.n */
+  lua_rawget(L, t);
+  if ((n = checkint(L, 1)) >= 0) return n;
+  getsizes(L);  /* else try sizes[t] */
+  lua_pushvalue(L, t);
+  lua_rawget(L, -2);
+  if ((n = checkint(L, 2)) >= 0) return n;
+  return (int)lua_objlen(L, t);
+}
+
+#endif
+
+/* }====================================================== */
+
+
+
+LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
+                                                               const char *r) {
+  const char *wild;
+  size_t l = strlen(p);
+  luaL_Buffer b;
+  luaL_buffinit(L, &b);
+  while ((wild = strstr(s, p)) != NULL) {
+    luaL_addlstring(&b, s, wild - s);  /* push prefix */
+    luaL_addstring(&b, r);  /* push replacement in place of pattern */
+    s = wild + l;  /* continue after `p' */
+  }
+  luaL_addstring(&b, s);  /* push last suffix */
+  luaL_pushresult(&b);
+  return lua_tostring(L, -1);
+}
+
+
+LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
+                                       const char *fname, int szhint) {
+  const char *e;
+  lua_pushvalue(L, idx);
+  do {
+    e = strchr(fname, '.');
+    if (e == NULL) e = fname + strlen(fname);
+    lua_pushlstring(L, fname, e - fname);
+    lua_rawget(L, -2);
+    if (lua_isnil(L, -1)) {  /* no such field? */
+      lua_pop(L, 1);  /* remove this nil */
+      lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
+      lua_pushlstring(L, fname, e - fname);
+      lua_pushvalue(L, -2);
+      lua_settable(L, -4);  /* set new table into field */
+    }
+    else if (!lua_istable(L, -1)) {  /* field has a non-table value? */
+      lua_pop(L, 2);  /* remove table and value */
+      return fname;  /* return problematic part of the name */
+    }
+    lua_remove(L, -2);  /* remove previous table */
+    fname = e + 1;
+  } while (*e == '.');
+  return NULL;
+}
+
+
+
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+
+#define bufflen(B)	((B)->p - (B)->buffer)
+#define bufffree(B)	((size_t)(LUAL_BUFFERSIZE - bufflen(B)))
+
+#define LIMIT	(LUA_MINSTACK/2)
+
+
+static int emptybuffer (luaL_Buffer *B) {
+  size_t l = bufflen(B);
+  if (l == 0) return 0;  /* put nothing on stack */
+  else {
+    lua_pushlstring(B->L, B->buffer, l);
+    B->p = B->buffer;
+    B->lvl++;
+    return 1;
+  }
+}
+
+
+static void adjuststack (luaL_Buffer *B) {
+  if (B->lvl > 1) {
+    lua_State *L = B->L;
+    int toget = 1;  /* number of levels to concat */
+    size_t toplen = lua_strlen(L, -1);
+    do {
+      size_t l = lua_strlen(L, -(toget+1));
+      if (B->lvl - toget + 1 >= LIMIT || toplen > l) {
+        toplen += l;
+        toget++;
+      }
+      else break;
+    } while (toget < B->lvl);
+    lua_concat(L, toget);
+    B->lvl = B->lvl - toget + 1;
+  }
+}
+
+
+LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
+  if (emptybuffer(B))
+    adjuststack(B);
+  return B->buffer;
+}
+
+
+LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
+  while (l--)
+    luaL_addchar(B, *s++);
+}
+
+
+LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
+  luaL_addlstring(B, s, strlen(s));
+}
+
+
+LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
+  emptybuffer(B);
+  lua_concat(B->L, B->lvl);
+  B->lvl = 1;
+}
+
+
+LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
+  lua_State *L = B->L;
+  size_t vl;
+  const char *s = lua_tolstring(L, -1, &vl);
+  if (vl <= bufffree(B)) {  /* fit into buffer? */
+    memcpy(B->p, s, vl);  /* put it there */
+    B->p += vl;
+    lua_pop(L, 1);  /* remove from stack */
+  }
+  else {
+    if (emptybuffer(B))
+      lua_insert(L, -2);  /* put buffer before new value */
+    B->lvl++;  /* add new value into B stack */
+    adjuststack(B);
+  }
+}
+
+
+LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
+  B->L = L;
+  B->p = B->buffer;
+  B->lvl = 0;
+}
+
+/* }====================================================== */
+
+
+LUALIB_API int luaL_ref (lua_State *L, int t) {
+  int ref;
+  t = abs_index(L, t);
+  if (lua_isnil(L, -1)) {
+    lua_pop(L, 1);  /* remove from stack */
+    return LUA_REFNIL;  /* `nil' has a unique fixed reference */
+  }
+  lua_rawgeti(L, t, FREELIST_REF);  /* get first free element */
+  ref = (int)lua_tointeger(L, -1);  /* ref = t[FREELIST_REF] */
+  lua_pop(L, 1);  /* remove it from stack */
+  if (ref != 0) {  /* any free element? */
+    lua_rawgeti(L, t, ref);  /* remove it from list */
+    lua_rawseti(L, t, FREELIST_REF);  /* (t[FREELIST_REF] = t[ref]) */
+  }
+  else {  /* no free elements */
+    ref = (int)lua_objlen(L, t);
+    ref++;  /* create new reference */
+  }
+  lua_rawseti(L, t, ref);
+  return ref;
+}
+
+
+LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
+  if (ref >= 0) {
+    t = abs_index(L, t);
+    lua_rawgeti(L, t, FREELIST_REF);
+    lua_rawseti(L, t, ref);  /* t[ref] = t[FREELIST_REF] */
+    lua_pushinteger(L, ref);
+    lua_rawseti(L, t, FREELIST_REF);  /* t[FREELIST_REF] = ref */
+  }
+}
+
+
+
+/*
+** {======================================================
+** Load functions
+** =======================================================
+*/
+
+typedef struct LoadF {
+  int extraline;
+  FILE *f;
+  char buff[LUAL_BUFFERSIZE];
+} LoadF;
+
+
+static const char *getF (lua_State *L, void *ud, size_t *size) {
+  LoadF *lf = (LoadF *)ud;
+  (void)L;
+  if (lf->extraline) {
+    lf->extraline = 0;
+    *size = 1;
+    return "\n";
+  }
+  if (feof(lf->f)) return NULL;
+  *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
+  return (*size > 0) ? lf->buff : NULL;
+}
+
+
+static int errfile (lua_State *L, const char *what, int fnameindex) {
+  const char *serr = strerror(errno);
+  const char *filename = lua_tostring(L, fnameindex) + 1;
+  lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
+  lua_remove(L, fnameindex);
+  return LUA_ERRFILE;
+}
+
+
+LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
+  LoadF lf;
+  int status, readstatus;
+  int c;
+  int fnameindex = lua_gettop(L) + 1;  /* index of filename on the stack */
+  lf.extraline = 0;
+  if (filename == NULL) {
+    lua_pushliteral(L, "=stdin");
+    lf.f = stdin;
+  }
+  else {
+    lua_pushfstring(L, "@%s", filename);
+    lf.f = fopen(filename, "r");
+    if (lf.f == NULL) return errfile(L, "open", fnameindex);
+  }
+  c = getc(lf.f);
+  if (c == '#') {  /* Unix exec. file? */
+    lf.extraline = 1;
+    while ((c = getc(lf.f)) != EOF && c != '\n') ;  /* skip first line */
+    if (c == '\n') c = getc(lf.f);
+  }
+  if (c == LUA_SIGNATURE[0] && filename) {  /* binary file? */
+    lf.f = freopen(filename, "rb", lf.f);  /* reopen in binary mode */
+    if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
+    /* skip eventual `#!...' */
+   while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
+    lf.extraline = 0;
+  }
+  ungetc(c, lf.f);
+  status = lua_load(L, getF, &lf, lua_tostring(L, -1));
+  readstatus = ferror(lf.f);
+  if (filename) fclose(lf.f);  /* close file (even in case of errors) */
+  if (readstatus) {
+    lua_settop(L, fnameindex);  /* ignore results from `lua_load' */
+    return errfile(L, "read", fnameindex);
+  }
+  lua_remove(L, fnameindex);
+  return status;
+}
+
+
+typedef struct LoadS {
+  const char *s;
+  size_t size;
+} LoadS;
+
+
+static const char *getS (lua_State *L, void *ud, size_t *size) {
+  LoadS *ls = (LoadS *)ud;
+  (void)L;
+  if (ls->size == 0) return NULL;
+  *size = ls->size;
+  ls->size = 0;
+  return ls->s;
+}
+
+
+LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
+                                const char *name) {
+  LoadS ls;
+  ls.s = buff;
+  ls.size = size;
+  return lua_load(L, getS, &ls, name);
+}
+
+
+LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
+  return luaL_loadbuffer(L, s, strlen(s), s);
+}
+
+
+
+/* }====================================================== */
+
+
+static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
+  (void)ud;
+  (void)osize;
+  if (nsize == 0) {
+    free(ptr);
+    return NULL;
+  }
+  else
+    return realloc(ptr, nsize);
+}
+
+
+static int panic (lua_State *L) {
+  (void)L;  /* to avoid warnings */
+  fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
+                   lua_tostring(L, -1));
+  return 0;
+}
+
+
+LUALIB_API lua_State *luaL_newstate (void) {
+  lua_State *L = lua_newstate(l_alloc, NULL);
+  if (L) lua_atpanic(L, &panic);
+  return L;
+}
+
Index: /code/branches/physics/src/lua/lauxlib.h
===================================================================
--- /code/branches/physics/src/lua/lauxlib.h	(revision 2122)
+++ /code/branches/physics/src/lua/lauxlib.h	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
+** Auxiliary functions for building Lua libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lauxlib_h
+#define lauxlib_h
+
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "lua.h"
+
+
+#if defined(LUA_COMPAT_GETN)
+LUALIB_API int (luaL_getn) (lua_State *L, int t);
+LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
+#else
+#define luaL_getn(L,i)          ((int)lua_objlen(L, i))
+#define luaL_setn(L,i,j)        ((void)0)  /* no op! */
+#endif
+
+#if defined(LUA_COMPAT_OPENLIB)
+#define luaI_openlib	luaL_openlib
+#endif
+
+
+/* extra error code for `luaL_load' */
+#define LUA_ERRFILE     (LUA_ERRERR+1)
+
+
+typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+
+
+
+LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
+                                const luaL_Reg *l, int nup);
+LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
+                                const luaL_Reg *l);
+LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
+LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
+LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
+                                                          size_t *l);
+LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
+                                          const char *def, size_t *l);
+LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
+LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
+
+LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
+LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
+                                          lua_Integer def);
+
+LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
+LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
+
+LUALIB_API int   (luaL_newmetatable) (lua_State *L, const char *tname);
+LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
+
+LUALIB_API void (luaL_where) (lua_State *L, int lvl);
+LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
+
+LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
+                                   const char *const lst[]);
+
+LUALIB_API int (luaL_ref) (lua_State *L, int t);
+LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
+LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
+                                  const char *name);
+LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+
+LUALIB_API lua_State *(luaL_newstate) (void);
+
+
+LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
+                                                  const char *r);
+
+LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
+                                         const char *fname, int szhint);
+
+
+
+
+/*
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define luaL_argcheck(L, cond,numarg,extramsg)	\
+		((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
+#define luaL_checkstring(L,n)	(luaL_checklstring(L, (n), NULL))
+#define luaL_optstring(L,n,d)	(luaL_optlstring(L, (n), (d), NULL))
+#define luaL_checkint(L,n)	((int)luaL_checkinteger(L, (n)))
+#define luaL_optint(L,n,d)	((int)luaL_optinteger(L, (n), (d)))
+#define luaL_checklong(L,n)	((long)luaL_checkinteger(L, (n)))
+#define luaL_optlong(L,n,d)	((long)luaL_optinteger(L, (n), (d)))
+
+#define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
+
+#define luaL_dofile(L, fn) \
+	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_dostring(L, s) \
+	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
+
+#define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
+
+/*
+** {======================================================
+** Generic Buffer manipulation
+** =======================================================
+*/
+
+
+
+typedef struct luaL_Buffer {
+  char *p;			/* current position in buffer */
+  int lvl;  /* number of strings in the stack (level) */
+  lua_State *L;
+  char buffer[LUAL_BUFFERSIZE];
+} luaL_Buffer;
+
+#define luaL_addchar(B,c) \
+  ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
+   (*(B)->p++ = (char)(c)))
+
+/* compatibility only */
+#define luaL_putchar(B,c)	luaL_addchar(B,c)
+
+#define luaL_addsize(B,n)	((B)->p += (n))
+
+LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
+LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
+LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
+LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
+LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
+
+
+/* }====================================================== */
+
+
+/* compatibility with ref system */
+
+/* pre-defined references */
+#define LUA_NOREF       (-2)
+#define LUA_REFNIL      (-1)
+
+#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
+      (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
+
+#define lua_unref(L,ref)        luaL_unref(L, LUA_REGISTRYINDEX, (ref))
+
+#define lua_getref(L,ref)       lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
+
+
+#define luaL_reg	luaL_Reg
+
+#endif
+
+
Index: /code/branches/physics/src/lua/lbaselib.c
===================================================================
--- /code/branches/physics/src/lua/lbaselib.c	(revision 2122)
+++ /code/branches/physics/src/lua/lbaselib.c	(revision 2122)
@@ -0,0 +1,651 @@
+/*
+** $Id: lbaselib.c,v 1.191.1.4 2008/01/20 13:53:22 roberto Exp $
+** Basic library
+** See Copyright Notice in lua.h
+*/
+
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define lbaselib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+
+
+/*
+** If your system does not support `stdout', you can just remove this function.
+** If you need, you can define your own `print' function, following this
+** model but changing `fputs' to put the strings at a proper place
+** (a console window or a log file, for instance).
+*/
+static int luaB_print (lua_State *L) {
+  int n = lua_gettop(L);  /* number of arguments */
+  int i;
+  lua_getglobal(L, "tostring");
+  for (i=1; i<=n; i++) {
+    const char *s;
+    lua_pushvalue(L, -1);  /* function to be called */
+    lua_pushvalue(L, i);   /* value to print */
+    lua_call(L, 1, 1);
+    s = lua_tostring(L, -1);  /* get result */
+    if (s == NULL)
+      return luaL_error(L, LUA_QL("tostring") " must return a string to "
+                           LUA_QL("print"));
+    if (i>1) fputs("\t", stdout);
+    fputs(s, stdout);
+    lua_pop(L, 1);  /* pop result */
+  }
+  fputs("\n", stdout);
+  return 0;
+}
+
+
+static int luaB_tonumber (lua_State *L) {
+  int base = luaL_optint(L, 2, 10);
+  if (base == 10) {  /* standard conversion */
+    luaL_checkany(L, 1);
+    if (lua_isnumber(L, 1)) {
+      lua_pushnumber(L, lua_tonumber(L, 1));
+      return 1;
+    }
+  }
+  else {
+    const char *s1 = luaL_checkstring(L, 1);
+    char *s2;
+    unsigned long n;
+    luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
+    n = strtoul(s1, &s2, base);
+    if (s1 != s2) {  /* at least one valid digit? */
+      while (isspace((unsigned char)(*s2))) s2++;  /* skip trailing spaces */
+      if (*s2 == '\0') {  /* no invalid trailing characters? */
+        lua_pushnumber(L, (lua_Number)n);
+        return 1;
+      }
+    }
+  }
+  lua_pushnil(L);  /* else not a number */
+  return 1;
+}
+
+
+static int luaB_error (lua_State *L) {
+  int level = luaL_optint(L, 2, 1);
+  lua_settop(L, 1);
+  if (lua_isstring(L, 1) && level > 0) {  /* add extra information? */
+    luaL_where(L, level);
+    lua_pushvalue(L, 1);
+    lua_concat(L, 2);
+  }
+  return lua_error(L);
+}
+
+
+static int luaB_getmetatable (lua_State *L) {
+  luaL_checkany(L, 1);
+  if (!lua_getmetatable(L, 1)) {
+    lua_pushnil(L);
+    return 1;  /* no metatable */
+  }
+  luaL_getmetafield(L, 1, "__metatable");
+  return 1;  /* returns either __metatable field (if present) or metatable */
+}
+
+
+static int luaB_setmetatable (lua_State *L) {
+  int t = lua_type(L, 2);
+  luaL_checktype(L, 1, LUA_TTABLE);
+  luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
+                    "nil or table expected");
+  if (luaL_getmetafield(L, 1, "__metatable"))
+    luaL_error(L, "cannot change a protected metatable");
+  lua_settop(L, 2);
+  lua_setmetatable(L, 1);
+  return 1;
+}
+
+
+static void getfunc (lua_State *L, int opt) {
+  if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
+  else {
+    lua_Debug ar;
+    int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
+    luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
+    if (lua_getstack(L, level, &ar) == 0)
+      luaL_argerror(L, 1, "invalid level");
+    lua_getinfo(L, "f", &ar);
+    if (lua_isnil(L, -1))
+      luaL_error(L, "no function environment for tail call at level %d",
+                    level);
+  }
+}
+
+
+static int luaB_getfenv (lua_State *L) {
+  getfunc(L, 1);
+  if (lua_iscfunction(L, -1))  /* is a C function? */
+    lua_pushvalue(L, LUA_GLOBALSINDEX);  /* return the thread's global env. */
+  else
+    lua_getfenv(L, -1);
+  return 1;
+}
+
+
+static int luaB_setfenv (lua_State *L) {
+  luaL_checktype(L, 2, LUA_TTABLE);
+  getfunc(L, 0);
+  lua_pushvalue(L, 2);
+  if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
+    /* change environment of current thread */
+    lua_pushthread(L);
+    lua_insert(L, -2);
+    lua_setfenv(L, -2);
+    return 0;
+  }
+  else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
+    luaL_error(L,
+          LUA_QL("setfenv") " cannot change environment of given object");
+  return 1;
+}
+
+
+static int luaB_rawequal (lua_State *L) {
+  luaL_checkany(L, 1);
+  luaL_checkany(L, 2);
+  lua_pushboolean(L, lua_rawequal(L, 1, 2));
+  return 1;
+}
+
+
+static int luaB_rawget (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+  luaL_checkany(L, 2);
+  lua_settop(L, 2);
+  lua_rawget(L, 1);
+  return 1;
+}
+
+static int luaB_rawset (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+  luaL_checkany(L, 2);
+  luaL_checkany(L, 3);
+  lua_settop(L, 3);
+  lua_rawset(L, 1);
+  return 1;
+}
+
+
+static int luaB_gcinfo (lua_State *L) {
+  lua_pushinteger(L, lua_getgccount(L));
+  return 1;
+}
+
+
+static int luaB_collectgarbage (lua_State *L) {
+  static const char *const opts[] = {"stop", "restart", "collect",
+    "count", "step", "setpause", "setstepmul", NULL};
+  static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
+    LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL};
+  int o = luaL_checkoption(L, 1, "collect", opts);
+  int ex = luaL_optint(L, 2, 0);
+  int res = lua_gc(L, optsnum[o], ex);
+  switch (optsnum[o]) {
+    case LUA_GCCOUNT: {
+      int b = lua_gc(L, LUA_GCCOUNTB, 0);
+      lua_pushnumber(L, res + ((lua_Number)b/1024));
+      return 1;
+    }
+    case LUA_GCSTEP: {
+      lua_pushboolean(L, res);
+      return 1;
+    }
+    default: {
+      lua_pushnumber(L, res);
+      return 1;
+    }
+  }
+}
+
+
+static int luaB_type (lua_State *L) {
+  luaL_checkany(L, 1);
+  lua_pushstring(L, luaL_typename(L, 1));
+  return 1;
+}
+
+
+static int luaB_next (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+  lua_settop(L, 2);  /* create a 2nd argument if there isn't one */
+  if (lua_next(L, 1))
+    return 2;
+  else {
+    lua_pushnil(L);
+    return 1;
+  }
+}
+
+
+static int luaB_pairs (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+  lua_pushvalue(L, lua_upvalueindex(1));  /* return generator, */
+  lua_pushvalue(L, 1);  /* state, */
+  lua_pushnil(L);  /* and initial value */
+  return 3;
+}
+
+
+static int ipairsaux (lua_State *L) {
+  int i = luaL_checkint(L, 2);
+  luaL_checktype(L, 1, LUA_TTABLE);
+  i++;  /* next value */
+  lua_pushinteger(L, i);
+  lua_rawgeti(L, 1, i);
+  return (lua_isnil(L, -1)) ? 0 : 2;
+}
+
+
+static int luaB_ipairs (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+  lua_pushvalue(L, lua_upvalueindex(1));  /* return generator, */
+  lua_pushvalue(L, 1);  /* state, */
+  lua_pushinteger(L, 0);  /* and initial value */
+  return 3;
+}
+
+
+static int load_aux (lua_State *L, int status) {
+  if (status == 0)  /* OK? */
+    return 1;
+  else {
+    lua_pushnil(L);
+    lua_insert(L, -2);  /* put before error message */
+    return 2;  /* return nil plus error message */
+  }
+}
+
+
+static int luaB_loadstring (lua_State *L) {
+  size_t l;
+  const char *s = luaL_checklstring(L, 1, &l);
+  const char *chunkname = luaL_optstring(L, 2, s);
+  return load_aux(L, luaL_loadbuffer(L, s, l, chunkname));
+}
+
+
+static int luaB_loadfile (lua_State *L) {
+  const char *fname = luaL_optstring(L, 1, NULL);
+  return load_aux(L, luaL_loadfile(L, fname));
+}
+
+
+/*
+** Reader for generic `load' function: `lua_load' uses the
+** stack for internal stuff, so the reader cannot change the
+** stack top. Instead, it keeps its resulting string in a
+** reserved slot inside the stack.
+*/
+static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
+  (void)ud;  /* to avoid warnings */
+  luaL_checkstack(L, 2, "too many nested functions");
+  lua_pushvalue(L, 1);  /* get function */
+  lua_call(L, 0, 1);  /* call it */
+  if (lua_isnil(L, -1)) {
+    *size = 0;
+    return NULL;
+  }
+  else if (lua_isstring(L, -1)) {
+    lua_replace(L, 3);  /* save string in a reserved stack slot */
+    return lua_tolstring(L, 3, size);
+  }
+  else luaL_error(L, "reader function must return a string");
+  return NULL;  /* to avoid warnings */
+}
+
+
+static int luaB_load (lua_State *L) {
+  int status;
+  const char *cname = luaL_optstring(L, 2, "=(load)");
+  luaL_checktype(L, 1, LUA_TFUNCTION);
+  lua_settop(L, 3);  /* function, eventual name, plus one reserved slot */
+  status = lua_load(L, generic_reader, NULL, cname);
+  return load_aux(L, status);
+}
+
+
+static int luaB_dofile (lua_State *L) {
+  const char *fname = luaL_optstring(L, 1, NULL);
+  int n = lua_gettop(L);
+  if (luaL_loadfile(L, fname) != 0) lua_error(L);
+  lua_call(L, 0, LUA_MULTRET);
+  return lua_gettop(L) - n;
+}
+
+
+static int luaB_assert (lua_State *L) {
+  luaL_checkany(L, 1);
+  if (!lua_toboolean(L, 1))
+    return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
+  return lua_gettop(L);
+}
+
+
+static int luaB_unpack (lua_State *L) {
+  int i, e, n;
+  luaL_checktype(L, 1, LUA_TTABLE);
+  i = luaL_optint(L, 2, 1);
+  e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
+  n = e - i + 1;  /* number of elements */
+  if (n <= 0) return 0;  /* empty range */
+  luaL_checkstack(L, n, "table too big to unpack");
+  for (; i<=e; i++)  /* push arg[i...e] */
+    lua_rawgeti(L, 1, i);
+  return n;
+}
+
+
+static int luaB_select (lua_State *L) {
+  int n = lua_gettop(L);
+  if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
+    lua_pushinteger(L, n-1);
+    return 1;
+  }
+  else {
+    int i = luaL_checkint(L, 1);
+    if (i < 0) i = n + i;
+    else if (i > n) i = n;
+    luaL_argcheck(L, 1 <= i, 1, "index out of range");
+    return n - i;
+  }
+}
+
+
+static int luaB_pcall (lua_State *L) {
+  int status;
+  luaL_checkany(L, 1);
+  status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
+  lua_pushboolean(L, (status == 0));
+  lua_insert(L, 1);
+  return lua_gettop(L);  /* return status + all results */
+}
+
+
+static int luaB_xpcall (lua_State *L) {
+  int status;
+  luaL_checkany(L, 2);
+  lua_settop(L, 2);
+  lua_insert(L, 1);  /* put error function under function to be called */
+  status = lua_pcall(L, 0, LUA_MULTRET, 1);
+  lua_pushboolean(L, (status == 0));
+  lua_replace(L, 1);
+  return lua_gettop(L);  /* return status + all results */
+}
+
+
+static int luaB_tostring (lua_State *L) {
+  luaL_checkany(L, 1);
+  if (luaL_callmeta(L, 1, "__tostring"))  /* is there a metafield? */
+    return 1;  /* use its value */
+  switch (lua_type(L, 1)) {
+    case LUA_TNUMBER:
+      lua_pushstring(L, lua_tostring(L, 1));
+      break;
+    case LUA_TSTRING:
+      lua_pushvalue(L, 1);
+      break;
+    case LUA_TBOOLEAN:
+      lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false"));
+      break;
+    case LUA_TNIL:
+      lua_pushliteral(L, "nil");
+      break;
+    default:
+      lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1));
+      break;
+  }
+  return 1;
+}
+
+
+static int luaB_newproxy (lua_State *L) {
+  lua_settop(L, 1);
+  lua_newuserdata(L, 0);  /* create proxy */
+  if (lua_toboolean(L, 1) == 0)
+    return 1;  /* no metatable */
+  else if (lua_isboolean(L, 1)) {
+    lua_newtable(L);  /* create a new metatable `m' ... */
+    lua_pushvalue(L, -1);  /* ... and mark `m' as a valid metatable */
+    lua_pushboolean(L, 1);
+    lua_rawset(L, lua_upvalueindex(1));  /* weaktable[m] = true */
+  }
+  else {
+    int validproxy = 0;  /* to check if weaktable[metatable(u)] == true */
+    if (lua_getmetatable(L, 1)) {
+      lua_rawget(L, lua_upvalueindex(1));
+      validproxy = lua_toboolean(L, -1);
+      lua_pop(L, 1);  /* remove value */
+    }
+    luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
+    lua_getmetatable(L, 1);  /* metatable is valid; get it */
+  }
+  lua_setmetatable(L, 2);
+  return 1;
+}
+
+
+static const luaL_Reg base_funcs[] = {
+  {"assert", luaB_assert},
+  {"collectgarbage", luaB_collectgarbage},
+  {"dofile", luaB_dofile},
+  {"error", luaB_error},
+  {"gcinfo", luaB_gcinfo},
+  {"getfenv", luaB_getfenv},
+  {"getmetatable", luaB_getmetatable},
+  {"loadfile", luaB_loadfile},
+  {"load", luaB_load},
+  {"loadstring", luaB_loadstring},
+  {"next", luaB_next},
+  {"pcall", luaB_pcall},
+  {"print", luaB_print},
+  {"rawequal", luaB_rawequal},
+  {"rawget", luaB_rawget},
+  {"rawset", luaB_rawset},
+  {"select", luaB_select},
+  {"setfenv", luaB_setfenv},
+  {"setmetatable", luaB_setmetatable},
+  {"tonumber", luaB_tonumber},
+  {"tostring", luaB_tostring},
+  {"type", luaB_type},
+  {"unpack", luaB_unpack},
+  {"xpcall", luaB_xpcall},
+  {NULL, NULL}
+};
+
+
+/*
+** {======================================================
+** Coroutine library
+** =======================================================
+*/
+
+#define CO_RUN	0	/* running */
+#define CO_SUS	1	/* suspended */
+#define CO_NOR	2	/* 'normal' (it resumed another coroutine) */
+#define CO_DEAD	3
+
+static const char *const statnames[] =
+    {"running", "suspended", "normal", "dead"};
+
+static int costatus (lua_State *L, lua_State *co) {
+  if (L == co) return CO_RUN;
+  switch (lua_status(co)) {
+    case LUA_YIELD:
+      return CO_SUS;
+    case 0: {
+      lua_Debug ar;
+      if (lua_getstack(co, 0, &ar) > 0)  /* does it have frames? */
+        return CO_NOR;  /* it is running */
+      else if (lua_gettop(co) == 0)
+          return CO_DEAD;
+      else
+        return CO_SUS;  /* initial state */
+    }
+    default:  /* some error occured */
+      return CO_DEAD;
+  }
+}
+
+
+static int luaB_costatus (lua_State *L) {
+  lua_State *co = lua_tothread(L, 1);
+  luaL_argcheck(L, co, 1, "coroutine expected");
+  lua_pushstring(L, statnames[costatus(L, co)]);
+  return 1;
+}
+
+
+static int auxresume (lua_State *L, lua_State *co, int narg) {
+  int status = costatus(L, co);
+  if (!lua_checkstack(co, narg))
+    luaL_error(L, "too many arguments to resume");
+  if (status != CO_SUS) {
+    lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
+    return -1;  /* error flag */
+  }
+  lua_xmove(L, co, narg);
+  lua_setlevel(L, co);
+  status = lua_resume(co, narg);
+  if (status == 0 || status == LUA_YIELD) {
+    int nres = lua_gettop(co);
+    if (!lua_checkstack(L, nres))
+      luaL_error(L, "too many results to resume");
+    lua_xmove(co, L, nres);  /* move yielded values */
+    return nres;
+  }
+  else {
+    lua_xmove(co, L, 1);  /* move error message */
+    return -1;  /* error flag */
+  }
+}
+
+
+static int luaB_coresume (lua_State *L) {
+  lua_State *co = lua_tothread(L, 1);
+  int r;
+  luaL_argcheck(L, co, 1, "coroutine expected");
+  r = auxresume(L, co, lua_gettop(L) - 1);
+  if (r < 0) {
+    lua_pushboolean(L, 0);
+    lua_insert(L, -2);
+    return 2;  /* return false + error message */
+  }
+  else {
+    lua_pushboolean(L, 1);
+    lua_insert(L, -(r + 1));
+    return r + 1;  /* return true + `resume' returns */
+  }
+}
+
+
+static int luaB_auxwrap (lua_State *L) {
+  lua_State *co = lua_tothread(L, lua_upvalueindex(1));
+  int r = auxresume(L, co, lua_gettop(L));
+  if (r < 0) {
+    if (lua_isstring(L, -1)) {  /* error object is a string? */
+      luaL_where(L, 1);  /* add extra info */
+      lua_insert(L, -2);
+      lua_concat(L, 2);
+    }
+    lua_error(L);  /* propagate error */
+  }
+  return r;
+}
+
+
+static int luaB_cocreate (lua_State *L) {
+  lua_State *NL = lua_newthread(L);
+  luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
+    "Lua function expected");
+  lua_pushvalue(L, 1);  /* move function to top */
+  lua_xmove(L, NL, 1);  /* move function from L to NL */
+  return 1;
+}
+
+
+static int luaB_cowrap (lua_State *L) {
+  luaB_cocreate(L);
+  lua_pushcclosure(L, luaB_auxwrap, 1);
+  return 1;
+}
+
+
+static int luaB_yield (lua_State *L) {
+  return lua_yield(L, lua_gettop(L));
+}
+
+
+static int luaB_corunning (lua_State *L) {
+  if (lua_pushthread(L))
+    lua_pushnil(L);  /* main thread is not a coroutine */
+  return 1;
+}
+
+
+static const luaL_Reg co_funcs[] = {
+  {"create", luaB_cocreate},
+  {"resume", luaB_coresume},
+  {"running", luaB_corunning},
+  {"status", luaB_costatus},
+  {"wrap", luaB_cowrap},
+  {"yield", luaB_yield},
+  {NULL, NULL}
+};
+
+/* }====================================================== */
+
+
+static void auxopen (lua_State *L, const char *name,
+                     lua_CFunction f, lua_CFunction u) {
+  lua_pushcfunction(L, u);
+  lua_pushcclosure(L, f, 1);
+  lua_setfield(L, -2, name);
+}
+
+
+static void base_open (lua_State *L) {
+  /* set global _G */
+  lua_pushvalue(L, LUA_GLOBALSINDEX);
+  lua_setglobal(L, "_G");
+  /* open lib into global table */
+  luaL_register(L, "_G", base_funcs);
+  lua_pushliteral(L, LUA_VERSION);
+  lua_setglobal(L, "_VERSION");  /* set global _VERSION */
+  /* `ipairs' and `pairs' need auxliliary functions as upvalues */
+  auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
+  auxopen(L, "pairs", luaB_pairs, luaB_next);
+  /* `newproxy' needs a weaktable as upvalue */
+  lua_createtable(L, 0, 1);  /* new table `w' */
+  lua_pushvalue(L, -1);  /* `w' will be its own metatable */
+  lua_setmetatable(L, -2);
+  lua_pushliteral(L, "kv");
+  lua_setfield(L, -2, "__mode");  /* metatable(w).__mode = "kv" */
+  lua_pushcclosure(L, luaB_newproxy, 1);
+  lua_setglobal(L, "newproxy");  /* set global `newproxy' */
+}
+
+
+LUALIB_API int luaopen_base (lua_State *L) {
+  base_open(L);
+  luaL_register(L, LUA_COLIBNAME, co_funcs);
+  return 2;
+}
+
Index: /code/branches/physics/src/lua/lcode.c
===================================================================
--- /code/branches/physics/src/lua/lcode.c	(revision 2122)
+++ /code/branches/physics/src/lua/lcode.c	(revision 2122)
@@ -0,0 +1,839 @@
+/*
+** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
+** Code generator for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stdlib.h>
+
+#define lcode_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lcode.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lgc.h"
+#include "llex.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lparser.h"
+#include "ltable.h"
+
+
+#define hasjumps(e)	((e)->t != (e)->f)
+
+
+static int isnumeral(expdesc *e) {
+  return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
+}
+
+
+void luaK_nil (FuncState *fs, int from, int n) {
+  Instruction *previous;
+  if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
+    if (fs->pc == 0) {  /* function start? */
+      if (from >= fs->nactvar)
+        return;  /* positions are already clean */
+    }
+    else {
+      previous = &fs->f->code[fs->pc-1];
+      if (GET_OPCODE(*previous) == OP_LOADNIL) {
+        int pfrom = GETARG_A(*previous);
+        int pto = GETARG_B(*previous);
+        if (pfrom <= from && from <= pto+1) {  /* can connect both? */
+          if (from+n-1 > pto)
+            SETARG_B(*previous, from+n-1);
+          return;
+        }
+      }
+    }
+  }
+  luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0);  /* else no optimization */
+}
+
+
+int luaK_jump (FuncState *fs) {
+  int jpc = fs->jpc;  /* save list of jumps to here */
+  int j;
+  fs->jpc = NO_JUMP;
+  j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
+  luaK_concat(fs, &j, jpc);  /* keep them on hold */
+  return j;
+}
+
+
+void luaK_ret (FuncState *fs, int first, int nret) {
+  luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
+}
+
+
+static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
+  luaK_codeABC(fs, op, A, B, C);
+  return luaK_jump(fs);
+}
+
+
+static void fixjump (FuncState *fs, int pc, int dest) {
+  Instruction *jmp = &fs->f->code[pc];
+  int offset = dest-(pc+1);
+  lua_assert(dest != NO_JUMP);
+  if (abs(offset) > MAXARG_sBx)
+    luaX_syntaxerror(fs->ls, "control structure too long");
+  SETARG_sBx(*jmp, offset);
+}
+
+
+/*
+** returns current `pc' and marks it as a jump target (to avoid wrong
+** optimizations with consecutive instructions not in the same basic block).
+*/
+int luaK_getlabel (FuncState *fs) {
+  fs->lasttarget = fs->pc;
+  return fs->pc;
+}
+
+
+static int getjump (FuncState *fs, int pc) {
+  int offset = GETARG_sBx(fs->f->code[pc]);
+  if (offset == NO_JUMP)  /* point to itself represents end of list */
+    return NO_JUMP;  /* end of list */
+  else
+    return (pc+1)+offset;  /* turn offset into absolute position */
+}
+
+
+static Instruction *getjumpcontrol (FuncState *fs, int pc) {
+  Instruction *pi = &fs->f->code[pc];
+  if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
+    return pi-1;
+  else
+    return pi;
+}
+
+
+/*
+** check whether list has any jump that do not produce a value
+** (or produce an inverted value)
+*/
+static int need_value (FuncState *fs, int list) {
+  for (; list != NO_JUMP; list = getjump(fs, list)) {
+    Instruction i = *getjumpcontrol(fs, list);
+    if (GET_OPCODE(i) != OP_TESTSET) return 1;
+  }
+  return 0;  /* not found */
+}
+
+
+static int patchtestreg (FuncState *fs, int node, int reg) {
+  Instruction *i = getjumpcontrol(fs, node);
+  if (GET_OPCODE(*i) != OP_TESTSET)
+    return 0;  /* cannot patch other instructions */
+  if (reg != NO_REG && reg != GETARG_B(*i))
+    SETARG_A(*i, reg);
+  else  /* no register to put value or register already has the value */
+    *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
+
+  return 1;
+}
+
+
+static void removevalues (FuncState *fs, int list) {
+  for (; list != NO_JUMP; list = getjump(fs, list))
+      patchtestreg(fs, list, NO_REG);
+}
+
+
+static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
+                          int dtarget) {
+  while (list != NO_JUMP) {
+    int next = getjump(fs, list);
+    if (patchtestreg(fs, list, reg))
+      fixjump(fs, list, vtarget);
+    else
+      fixjump(fs, list, dtarget);  /* jump to default target */
+    list = next;
+  }
+}
+
+
+static void dischargejpc (FuncState *fs) {
+  patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
+  fs->jpc = NO_JUMP;
+}
+
+
+void luaK_patchlist (FuncState *fs, int list, int target) {
+  if (target == fs->pc)
+    luaK_patchtohere(fs, list);
+  else {
+    lua_assert(target < fs->pc);
+    patchlistaux(fs, list, target, NO_REG, target);
+  }
+}
+
+
+void luaK_patchtohere (FuncState *fs, int list) {
+  luaK_getlabel(fs);
+  luaK_concat(fs, &fs->jpc, list);
+}
+
+
+void luaK_concat (FuncState *fs, int *l1, int l2) {
+  if (l2 == NO_JUMP) return;
+  else if (*l1 == NO_JUMP)
+    *l1 = l2;
+  else {
+    int list = *l1;
+    int next;
+    while ((next = getjump(fs, list)) != NO_JUMP)  /* find last element */
+      list = next;
+    fixjump(fs, list, l2);
+  }
+}
+
+
+void luaK_checkstack (FuncState *fs, int n) {
+  int newstack = fs->freereg + n;
+  if (newstack > fs->f->maxstacksize) {
+    if (newstack >= MAXSTACK)
+      luaX_syntaxerror(fs->ls, "function or expression too complex");
+    fs->f->maxstacksize = cast_byte(newstack);
+  }
+}
+
+
+void luaK_reserveregs (FuncState *fs, int n) {
+  luaK_checkstack(fs, n);
+  fs->freereg += n;
+}
+
+
+static void freereg (FuncState *fs, int reg) {
+  if (!ISK(reg) && reg >= fs->nactvar) {
+    fs->freereg--;
+    lua_assert(reg == fs->freereg);
+  }
+}
+
+
+static void freeexp (FuncState *fs, expdesc *e) {
+  if (e->k == VNONRELOC)
+    freereg(fs, e->u.s.info);
+}
+
+
+static int addk (FuncState *fs, TValue *k, TValue *v) {
+  lua_State *L = fs->L;
+  TValue *idx = luaH_set(L, fs->h, k);
+  Proto *f = fs->f;
+  int oldsize = f->sizek;
+  if (ttisnumber(idx)) {
+    lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
+    return cast_int(nvalue(idx));
+  }
+  else {  /* constant not found; create a new entry */
+    setnvalue(idx, cast_num(fs->nk));
+    luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
+                    MAXARG_Bx, "constant table overflow");
+    while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
+    setobj(L, &f->k[fs->nk], v);
+    luaC_barrier(L, f, v);
+    return fs->nk++;
+  }
+}
+
+
+int luaK_stringK (FuncState *fs, TString *s) {
+  TValue o;
+  setsvalue(fs->L, &o, s);
+  return addk(fs, &o, &o);
+}
+
+
+int luaK_numberK (FuncState *fs, lua_Number r) {
+  TValue o;
+  setnvalue(&o, r);
+  return addk(fs, &o, &o);
+}
+
+
+static int boolK (FuncState *fs, int b) {
+  TValue o;
+  setbvalue(&o, b);
+  return addk(fs, &o, &o);
+}
+
+
+static int nilK (FuncState *fs) {
+  TValue k, v;
+  setnilvalue(&v);
+  /* cannot use nil as key; instead use table itself to represent nil */
+  sethvalue(fs->L, &k, fs->h);
+  return addk(fs, &k, &v);
+}
+
+
+void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
+  if (e->k == VCALL) {  /* expression is an open function call? */
+    SETARG_C(getcode(fs, e), nresults+1);
+  }
+  else if (e->k == VVARARG) {
+    SETARG_B(getcode(fs, e), nresults+1);
+    SETARG_A(getcode(fs, e), fs->freereg);
+    luaK_reserveregs(fs, 1);
+  }
+}
+
+
+void luaK_setoneret (FuncState *fs, expdesc *e) {
+  if (e->k == VCALL) {  /* expression is an open function call? */
+    e->k = VNONRELOC;
+    e->u.s.info = GETARG_A(getcode(fs, e));
+  }
+  else if (e->k == VVARARG) {
+    SETARG_B(getcode(fs, e), 2);
+    e->k = VRELOCABLE;  /* can relocate its simple result */
+  }
+}
+
+
+void luaK_dischargevars (FuncState *fs, expdesc *e) {
+  switch (e->k) {
+    case VLOCAL: {
+      e->k = VNONRELOC;
+      break;
+    }
+    case VUPVAL: {
+      e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
+      e->k = VRELOCABLE;
+      break;
+    }
+    case VGLOBAL: {
+      e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
+      e->k = VRELOCABLE;
+      break;
+    }
+    case VINDEXED: {
+      freereg(fs, e->u.s.aux);
+      freereg(fs, e->u.s.info);
+      e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
+      e->k = VRELOCABLE;
+      break;
+    }
+    case VVARARG:
+    case VCALL: {
+      luaK_setoneret(fs, e);
+      break;
+    }
+    default: break;  /* there is one value available (somewhere) */
+  }
+}
+
+
+static int code_label (FuncState *fs, int A, int b, int jump) {
+  luaK_getlabel(fs);  /* those instructions may be jump targets */
+  return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
+}
+
+
+static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
+  luaK_dischargevars(fs, e);
+  switch (e->k) {
+    case VNIL: {
+      luaK_nil(fs, reg, 1);
+      break;
+    }
+    case VFALSE:  case VTRUE: {
+      luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
+      break;
+    }
+    case VK: {
+      luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
+      break;
+    }
+    case VKNUM: {
+      luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
+      break;
+    }
+    case VRELOCABLE: {
+      Instruction *pc = &getcode(fs, e);
+      SETARG_A(*pc, reg);
+      break;
+    }
+    case VNONRELOC: {
+      if (reg != e->u.s.info)
+        luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0);
+      break;
+    }
+    default: {
+      lua_assert(e->k == VVOID || e->k == VJMP);
+      return;  /* nothing to do... */
+    }
+  }
+  e->u.s.info = reg;
+  e->k = VNONRELOC;
+}
+
+
+static void discharge2anyreg (FuncState *fs, expdesc *e) {
+  if (e->k != VNONRELOC) {
+    luaK_reserveregs(fs, 1);
+    discharge2reg(fs, e, fs->freereg-1);
+  }
+}
+
+
+static void exp2reg (FuncState *fs, expdesc *e, int reg) {
+  discharge2reg(fs, e, reg);
+  if (e->k == VJMP)
+    luaK_concat(fs, &e->t, e->u.s.info);  /* put this jump in `t' list */
+  if (hasjumps(e)) {
+    int final;  /* position after whole expression */
+    int p_f = NO_JUMP;  /* position of an eventual LOAD false */
+    int p_t = NO_JUMP;  /* position of an eventual LOAD true */
+    if (need_value(fs, e->t) || need_value(fs, e->f)) {
+      int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
+      p_f = code_label(fs, reg, 0, 1);
+      p_t = code_label(fs, reg, 1, 0);
+      luaK_patchtohere(fs, fj);
+    }
+    final = luaK_getlabel(fs);
+    patchlistaux(fs, e->f, final, reg, p_f);
+    patchlistaux(fs, e->t, final, reg, p_t);
+  }
+  e->f = e->t = NO_JUMP;
+  e->u.s.info = reg;
+  e->k = VNONRELOC;
+}
+
+
+void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
+  luaK_dischargevars(fs, e);
+  freeexp(fs, e);
+  luaK_reserveregs(fs, 1);
+  exp2reg(fs, e, fs->freereg - 1);
+}
+
+
+int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
+  luaK_dischargevars(fs, e);
+  if (e->k == VNONRELOC) {
+    if (!hasjumps(e)) return e->u.s.info;  /* exp is already in a register */
+    if (e->u.s.info >= fs->nactvar) {  /* reg. is not a local? */
+      exp2reg(fs, e, e->u.s.info);  /* put value on it */
+      return e->u.s.info;
+    }
+  }
+  luaK_exp2nextreg(fs, e);  /* default */
+  return e->u.s.info;
+}
+
+
+void luaK_exp2val (FuncState *fs, expdesc *e) {
+  if (hasjumps(e))
+    luaK_exp2anyreg(fs, e);
+  else
+    luaK_dischargevars(fs, e);
+}
+
+
+int luaK_exp2RK (FuncState *fs, expdesc *e) {
+  luaK_exp2val(fs, e);
+  switch (e->k) {
+    case VKNUM:
+    case VTRUE:
+    case VFALSE:
+    case VNIL: {
+      if (fs->nk <= MAXINDEXRK) {  /* constant fit in RK operand? */
+        e->u.s.info = (e->k == VNIL)  ? nilK(fs) :
+                      (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
+                                        boolK(fs, (e->k == VTRUE));
+        e->k = VK;
+        return RKASK(e->u.s.info);
+      }
+      else break;
+    }
+    case VK: {
+      if (e->u.s.info <= MAXINDEXRK)  /* constant fit in argC? */
+        return RKASK(e->u.s.info);
+      else break;
+    }
+    default: break;
+  }
+  /* not a constant in the right range: put it in a register */
+  return luaK_exp2anyreg(fs, e);
+}
+
+
+void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
+  switch (var->k) {
+    case VLOCAL: {
+      freeexp(fs, ex);
+      exp2reg(fs, ex, var->u.s.info);
+      return;
+    }
+    case VUPVAL: {
+      int e = luaK_exp2anyreg(fs, ex);
+      luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0);
+      break;
+    }
+    case VGLOBAL: {
+      int e = luaK_exp2anyreg(fs, ex);
+      luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info);
+      break;
+    }
+    case VINDEXED: {
+      int e = luaK_exp2RK(fs, ex);
+      luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e);
+      break;
+    }
+    default: {
+      lua_assert(0);  /* invalid var kind to store */
+      break;
+    }
+  }
+  freeexp(fs, ex);
+}
+
+
+void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
+  int func;
+  luaK_exp2anyreg(fs, e);
+  freeexp(fs, e);
+  func = fs->freereg;
+  luaK_reserveregs(fs, 2);
+  luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key));
+  freeexp(fs, key);
+  e->u.s.info = func;
+  e->k = VNONRELOC;
+}
+
+
+static void invertjump (FuncState *fs, expdesc *e) {
+  Instruction *pc = getjumpcontrol(fs, e->u.s.info);
+  lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
+                                           GET_OPCODE(*pc) != OP_TEST);
+  SETARG_A(*pc, !(GETARG_A(*pc)));
+}
+
+
+static int jumponcond (FuncState *fs, expdesc *e, int cond) {
+  if (e->k == VRELOCABLE) {
+    Instruction ie = getcode(fs, e);
+    if (GET_OPCODE(ie) == OP_NOT) {
+      fs->pc--;  /* remove previous OP_NOT */
+      return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
+    }
+    /* else go through */
+  }
+  discharge2anyreg(fs, e);
+  freeexp(fs, e);
+  return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond);
+}
+
+
+void luaK_goiftrue (FuncState *fs, expdesc *e) {
+  int pc;  /* pc of last jump */
+  luaK_dischargevars(fs, e);
+  switch (e->k) {
+    case VK: case VKNUM: case VTRUE: {
+      pc = NO_JUMP;  /* always true; do nothing */
+      break;
+    }
+    case VFALSE: {
+      pc = luaK_jump(fs);  /* always jump */
+      break;
+    }
+    case VJMP: {
+      invertjump(fs, e);
+      pc = e->u.s.info;
+      break;
+    }
+    default: {
+      pc = jumponcond(fs, e, 0);
+      break;
+    }
+  }
+  luaK_concat(fs, &e->f, pc);  /* insert last jump in `f' list */
+  luaK_patchtohere(fs, e->t);
+  e->t = NO_JUMP;
+}
+
+
+static void luaK_goiffalse (FuncState *fs, expdesc *e) {
+  int pc;  /* pc of last jump */
+  luaK_dischargevars(fs, e);
+  switch (e->k) {
+    case VNIL: case VFALSE: {
+      pc = NO_JUMP;  /* always false; do nothing */
+      break;
+    }
+    case VTRUE: {
+      pc = luaK_jump(fs);  /* always jump */
+      break;
+    }
+    case VJMP: {
+      pc = e->u.s.info;
+      break;
+    }
+    default: {
+      pc = jumponcond(fs, e, 1);
+      break;
+    }
+  }
+  luaK_concat(fs, &e->t, pc);  /* insert last jump in `t' list */
+  luaK_patchtohere(fs, e->f);
+  e->f = NO_JUMP;
+}
+
+
+static void codenot (FuncState *fs, expdesc *e) {
+  luaK_dischargevars(fs, e);
+  switch (e->k) {
+    case VNIL: case VFALSE: {
+      e->k = VTRUE;
+      break;
+    }
+    case VK: case VKNUM: case VTRUE: {
+      e->k = VFALSE;
+      break;
+    }
+    case VJMP: {
+      invertjump(fs, e);
+      break;
+    }
+    case VRELOCABLE:
+    case VNONRELOC: {
+      discharge2anyreg(fs, e);
+      freeexp(fs, e);
+      e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0);
+      e->k = VRELOCABLE;
+      break;
+    }
+    default: {
+      lua_assert(0);  /* cannot happen */
+      break;
+    }
+  }
+  /* interchange true and false lists */
+  { int temp = e->f; e->f = e->t; e->t = temp; }
+  removevalues(fs, e->f);
+  removevalues(fs, e->t);
+}
+
+
+void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
+  t->u.s.aux = luaK_exp2RK(fs, k);
+  t->k = VINDEXED;
+}
+
+
+static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
+  lua_Number v1, v2, r;
+  if (!isnumeral(e1) || !isnumeral(e2)) return 0;
+  v1 = e1->u.nval;
+  v2 = e2->u.nval;
+  switch (op) {
+    case OP_ADD: r = luai_numadd(v1, v2); break;
+    case OP_SUB: r = luai_numsub(v1, v2); break;
+    case OP_MUL: r = luai_nummul(v1, v2); break;
+    case OP_DIV:
+      if (v2 == 0) return 0;  /* do not attempt to divide by 0 */
+      r = luai_numdiv(v1, v2); break;
+    case OP_MOD:
+      if (v2 == 0) return 0;  /* do not attempt to divide by 0 */
+      r = luai_nummod(v1, v2); break;
+    case OP_POW: r = luai_numpow(v1, v2); break;
+    case OP_UNM: r = luai_numunm(v1); break;
+    case OP_LEN: return 0;  /* no constant folding for 'len' */
+    default: lua_assert(0); r = 0; break;
+  }
+  if (luai_numisnan(r)) return 0;  /* do not attempt to produce NaN */
+  e1->u.nval = r;
+  return 1;
+}
+
+
+static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
+  if (constfolding(op, e1, e2))
+    return;
+  else {
+    int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
+    int o1 = luaK_exp2RK(fs, e1);
+    if (o1 > o2) {
+      freeexp(fs, e1);
+      freeexp(fs, e2);
+    }
+    else {
+      freeexp(fs, e2);
+      freeexp(fs, e1);
+    }
+    e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
+    e1->k = VRELOCABLE;
+  }
+}
+
+
+static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
+                                                          expdesc *e2) {
+  int o1 = luaK_exp2RK(fs, e1);
+  int o2 = luaK_exp2RK(fs, e2);
+  freeexp(fs, e2);
+  freeexp(fs, e1);
+  if (cond == 0 && op != OP_EQ) {
+    int temp;  /* exchange args to replace by `<' or `<=' */
+    temp = o1; o1 = o2; o2 = temp;  /* o1 <==> o2 */
+    cond = 1;
+  }
+  e1->u.s.info = condjump(fs, op, cond, o1, o2);
+  e1->k = VJMP;
+}
+
+
+void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
+  expdesc e2;
+  e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
+  switch (op) {
+    case OPR_MINUS: {
+      if (!isnumeral(e))
+        luaK_exp2anyreg(fs, e);  /* cannot operate on non-numeric constants */
+      codearith(fs, OP_UNM, e, &e2);
+      break;
+    }
+    case OPR_NOT: codenot(fs, e); break;
+    case OPR_LEN: {
+      luaK_exp2anyreg(fs, e);  /* cannot operate on constants */
+      codearith(fs, OP_LEN, e, &e2);
+      break;
+    }
+    default: lua_assert(0);
+  }
+}
+
+
+void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
+  switch (op) {
+    case OPR_AND: {
+      luaK_goiftrue(fs, v);
+      break;
+    }
+    case OPR_OR: {
+      luaK_goiffalse(fs, v);
+      break;
+    }
+    case OPR_CONCAT: {
+      luaK_exp2nextreg(fs, v);  /* operand must be on the `stack' */
+      break;
+    }
+    case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
+    case OPR_MOD: case OPR_POW: {
+      if (!isnumeral(v)) luaK_exp2RK(fs, v);
+      break;
+    }
+    default: {
+      luaK_exp2RK(fs, v);
+      break;
+    }
+  }
+}
+
+
+void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
+  switch (op) {
+    case OPR_AND: {
+      lua_assert(e1->t == NO_JUMP);  /* list must be closed */
+      luaK_dischargevars(fs, e2);
+      luaK_concat(fs, &e2->f, e1->f);
+      *e1 = *e2;
+      break;
+    }
+    case OPR_OR: {
+      lua_assert(e1->f == NO_JUMP);  /* list must be closed */
+      luaK_dischargevars(fs, e2);
+      luaK_concat(fs, &e2->t, e1->t);
+      *e1 = *e2;
+      break;
+    }
+    case OPR_CONCAT: {
+      luaK_exp2val(fs, e2);
+      if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
+        lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
+        freeexp(fs, e1);
+        SETARG_B(getcode(fs, e2), e1->u.s.info);
+        e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
+      }
+      else {
+        luaK_exp2nextreg(fs, e2);  /* operand must be on the 'stack' */
+        codearith(fs, OP_CONCAT, e1, e2);
+      }
+      break;
+    }
+    case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
+    case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
+    case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
+    case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
+    case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
+    case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
+    case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
+    case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
+    case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
+    case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
+    case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
+    case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
+    default: lua_assert(0);
+  }
+}
+
+
+void luaK_fixline (FuncState *fs, int line) {
+  fs->f->lineinfo[fs->pc - 1] = line;
+}
+
+
+static int luaK_code (FuncState *fs, Instruction i, int line) {
+  Proto *f = fs->f;
+  dischargejpc(fs);  /* `pc' will change */
+  /* put new instruction in code array */
+  luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
+                  MAX_INT, "code size overflow");
+  f->code[fs->pc] = i;
+  /* save corresponding line information */
+  luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
+                  MAX_INT, "code size overflow");
+  f->lineinfo[fs->pc] = line;
+  return fs->pc++;
+}
+
+
+int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
+  lua_assert(getOpMode(o) == iABC);
+  lua_assert(getBMode(o) != OpArgN || b == 0);
+  lua_assert(getCMode(o) != OpArgN || c == 0);
+  return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline);
+}
+
+
+int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
+  lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
+  lua_assert(getCMode(o) == OpArgN);
+  return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
+}
+
+
+void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
+  int c =  (nelems - 1)/LFIELDS_PER_FLUSH + 1;
+  int b = (tostore == LUA_MULTRET) ? 0 : tostore;
+  lua_assert(tostore != 0);
+  if (c <= MAXARG_C)
+    luaK_codeABC(fs, OP_SETLIST, base, b, c);
+  else {
+    luaK_codeABC(fs, OP_SETLIST, base, b, 0);
+    luaK_code(fs, cast(Instruction, c), fs->ls->lastline);
+  }
+  fs->freereg = base + 1;  /* free registers with list values */
+}
+
Index: /code/branches/physics/src/lua/lcode.h
===================================================================
--- /code/branches/physics/src/lua/lcode.h	(revision 2122)
+++ /code/branches/physics/src/lua/lcode.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
+** Code generator for Lua
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lcode_h
+#define lcode_h
+
+#include "llex.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lparser.h"
+
+
+/*
+** Marks the end of a patch list. It is an invalid value both as an absolute
+** address, and as a list link (would link an element to itself).
+*/
+#define NO_JUMP (-1)
+
+
+/*
+** grep "ORDER OPR" if you change these enums
+*/
+typedef enum BinOpr {
+  OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
+  OPR_CONCAT,
+  OPR_NE, OPR_EQ,
+  OPR_LT, OPR_LE, OPR_GT, OPR_GE,
+  OPR_AND, OPR_OR,
+  OPR_NOBINOPR
+} BinOpr;
+
+
+typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
+
+
+#define getcode(fs,e)	((fs)->f->code[(e)->u.s.info])
+
+#define luaK_codeAsBx(fs,o,A,sBx)	luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
+
+#define luaK_setmultret(fs,e)	luaK_setreturns(fs, e, LUA_MULTRET)
+
+LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
+LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
+LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
+LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
+LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
+LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
+LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
+LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r);
+LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
+LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
+LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
+LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
+LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
+LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
+LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
+LUAI_FUNC int luaK_jump (FuncState *fs);
+LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
+LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
+LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
+LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
+LUAI_FUNC int luaK_getlabel (FuncState *fs);
+LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
+LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
+LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
+LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
+
+
+#endif
Index: /code/branches/physics/src/lua/ldblib.c
===================================================================
--- /code/branches/physics/src/lua/ldblib.c	(revision 2122)
+++ /code/branches/physics/src/lua/ldblib.c	(revision 2122)
@@ -0,0 +1,397 @@
+/*
+** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
+** Interface from Lua to its debug API
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ldblib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+
+static int db_getregistry (lua_State *L) {
+  lua_pushvalue(L, LUA_REGISTRYINDEX);
+  return 1;
+}
+
+
+static int db_getmetatable (lua_State *L) {
+  luaL_checkany(L, 1);
+  if (!lua_getmetatable(L, 1)) {
+    lua_pushnil(L);  /* no metatable */
+  }
+  return 1;
+}
+
+
+static int db_setmetatable (lua_State *L) {
+  int t = lua_type(L, 2);
+  luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
+                    "nil or table expected");
+  lua_settop(L, 2);
+  lua_pushboolean(L, lua_setmetatable(L, 1));
+  return 1;
+}
+
+
+static int db_getfenv (lua_State *L) {
+  lua_getfenv(L, 1);
+  return 1;
+}
+
+
+static int db_setfenv (lua_State *L) {
+  luaL_checktype(L, 2, LUA_TTABLE);
+  lua_settop(L, 2);
+  if (lua_setfenv(L, 1) == 0)
+    luaL_error(L, LUA_QL("setfenv")
+                  " cannot change environment of given object");
+  return 1;
+}
+
+
+static void settabss (lua_State *L, const char *i, const char *v) {
+  lua_pushstring(L, v);
+  lua_setfield(L, -2, i);
+}
+
+
+static void settabsi (lua_State *L, const char *i, int v) {
+  lua_pushinteger(L, v);
+  lua_setfield(L, -2, i);
+}
+
+
+static lua_State *getthread (lua_State *L, int *arg) {
+  if (lua_isthread(L, 1)) {
+    *arg = 1;
+    return lua_tothread(L, 1);
+  }
+  else {
+    *arg = 0;
+    return L;
+  }
+}
+
+
+static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
+  if (L == L1) {
+    lua_pushvalue(L, -2);
+    lua_remove(L, -3);
+  }
+  else
+    lua_xmove(L1, L, 1);
+  lua_setfield(L, -2, fname);
+}
+
+
+static int db_getinfo (lua_State *L) {
+  lua_Debug ar;
+  int arg;
+  lua_State *L1 = getthread(L, &arg);
+  const char *options = luaL_optstring(L, arg+2, "flnSu");
+  if (lua_isnumber(L, arg+1)) {
+    if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) {
+      lua_pushnil(L);  /* level out of range */
+      return 1;
+    }
+  }
+  else if (lua_isfunction(L, arg+1)) {
+    lua_pushfstring(L, ">%s", options);
+    options = lua_tostring(L, -1);
+    lua_pushvalue(L, arg+1);
+    lua_xmove(L, L1, 1);
+  }
+  else
+    return luaL_argerror(L, arg+1, "function or level expected");
+  if (!lua_getinfo(L1, options, &ar))
+    return luaL_argerror(L, arg+2, "invalid option");
+  lua_createtable(L, 0, 2);
+  if (strchr(options, 'S')) {
+    settabss(L, "source", ar.source);
+    settabss(L, "short_src", ar.short_src);
+    settabsi(L, "linedefined", ar.linedefined);
+    settabsi(L, "lastlinedefined", ar.lastlinedefined);
+    settabss(L, "what", ar.what);
+  }
+  if (strchr(options, 'l'))
+    settabsi(L, "currentline", ar.currentline);
+  if (strchr(options, 'u'))
+    settabsi(L, "nups", ar.nups);
+  if (strchr(options, 'n')) {
+    settabss(L, "name", ar.name);
+    settabss(L, "namewhat", ar.namewhat);
+  }
+  if (strchr(options, 'L'))
+    treatstackoption(L, L1, "activelines");
+  if (strchr(options, 'f'))
+    treatstackoption(L, L1, "func");
+  return 1;  /* return table */
+}
+    
+
+static int db_getlocal (lua_State *L) {
+  int arg;
+  lua_State *L1 = getthread(L, &arg);
+  lua_Debug ar;
+  const char *name;
+  if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar))  /* out of range? */
+    return luaL_argerror(L, arg+1, "level out of range");
+  name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2));
+  if (name) {
+    lua_xmove(L1, L, 1);
+    lua_pushstring(L, name);
+    lua_pushvalue(L, -2);
+    return 2;
+  }
+  else {
+    lua_pushnil(L);
+    return 1;
+  }
+}
+
+
+static int db_setlocal (lua_State *L) {
+  int arg;
+  lua_State *L1 = getthread(L, &arg);
+  lua_Debug ar;
+  if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar))  /* out of range? */
+    return luaL_argerror(L, arg+1, "level out of range");
+  luaL_checkany(L, arg+3);
+  lua_settop(L, arg+3);
+  lua_xmove(L, L1, 1);
+  lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2)));
+  return 1;
+}
+
+
+static int auxupvalue (lua_State *L, int get) {
+  const char *name;
+  int n = luaL_checkint(L, 2);
+  luaL_checktype(L, 1, LUA_TFUNCTION);
+  if (lua_iscfunction(L, 1)) return 0;  /* cannot touch C upvalues from Lua */
+  name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
+  if (name == NULL) return 0;
+  lua_pushstring(L, name);
+  lua_insert(L, -(get+1));
+  return get + 1;
+}
+
+
+static int db_getupvalue (lua_State *L) {
+  return auxupvalue(L, 1);
+}
+
+
+static int db_setupvalue (lua_State *L) {
+  luaL_checkany(L, 3);
+  return auxupvalue(L, 0);
+}
+
+
+
+static const char KEY_HOOK = 'h';
+
+
+static void hookf (lua_State *L, lua_Debug *ar) {
+  static const char *const hooknames[] =
+    {"call", "return", "line", "count", "tail return"};
+  lua_pushlightuserdata(L, (void *)&KEY_HOOK);
+  lua_rawget(L, LUA_REGISTRYINDEX);
+  lua_pushlightuserdata(L, L);
+  lua_rawget(L, -2);
+  if (lua_isfunction(L, -1)) {
+    lua_pushstring(L, hooknames[(int)ar->event]);
+    if (ar->currentline >= 0)
+      lua_pushinteger(L, ar->currentline);
+    else lua_pushnil(L);
+    lua_assert(lua_getinfo(L, "lS", ar));
+    lua_call(L, 2, 0);
+  }
+}
+
+
+static int makemask (const char *smask, int count) {
+  int mask = 0;
+  if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
+  if (strchr(smask, 'r')) mask |= LUA_MASKRET;
+  if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
+  if (count > 0) mask |= LUA_MASKCOUNT;
+  return mask;
+}
+
+
+static char *unmakemask (int mask, char *smask) {
+  int i = 0;
+  if (mask & LUA_MASKCALL) smask[i++] = 'c';
+  if (mask & LUA_MASKRET) smask[i++] = 'r';
+  if (mask & LUA_MASKLINE) smask[i++] = 'l';
+  smask[i] = '\0';
+  return smask;
+}
+
+
+static void gethooktable (lua_State *L) {
+  lua_pushlightuserdata(L, (void *)&KEY_HOOK);
+  lua_rawget(L, LUA_REGISTRYINDEX);
+  if (!lua_istable(L, -1)) {
+    lua_pop(L, 1);
+    lua_createtable(L, 0, 1);
+    lua_pushlightuserdata(L, (void *)&KEY_HOOK);
+    lua_pushvalue(L, -2);
+    lua_rawset(L, LUA_REGISTRYINDEX);
+  }
+}
+
+
+static int db_sethook (lua_State *L) {
+  int arg, mask, count;
+  lua_Hook func;
+  lua_State *L1 = getthread(L, &arg);
+  if (lua_isnoneornil(L, arg+1)) {
+    lua_settop(L, arg+1);
+    func = NULL; mask = 0; count = 0;  /* turn off hooks */
+  }
+  else {
+    const char *smask = luaL_checkstring(L, arg+2);
+    luaL_checktype(L, arg+1, LUA_TFUNCTION);
+    count = luaL_optint(L, arg+3, 0);
+    func = hookf; mask = makemask(smask, count);
+  }
+  gethooktable(L);
+  lua_pushlightuserdata(L, L1);
+  lua_pushvalue(L, arg+1);
+  lua_rawset(L, -3);  /* set new hook */
+  lua_pop(L, 1);  /* remove hook table */
+  lua_sethook(L1, func, mask, count);  /* set hooks */
+  return 0;
+}
+
+
+static int db_gethook (lua_State *L) {
+  int arg;
+  lua_State *L1 = getthread(L, &arg);
+  char buff[5];
+  int mask = lua_gethookmask(L1);
+  lua_Hook hook = lua_gethook(L1);
+  if (hook != NULL && hook != hookf)  /* external hook? */
+    lua_pushliteral(L, "external hook");
+  else {
+    gethooktable(L);
+    lua_pushlightuserdata(L, L1);
+    lua_rawget(L, -2);   /* get hook */
+    lua_remove(L, -2);  /* remove hook table */
+  }
+  lua_pushstring(L, unmakemask(mask, buff));
+  lua_pushinteger(L, lua_gethookcount(L1));
+  return 3;
+}
+
+
+static int db_debug (lua_State *L) {
+  for (;;) {
+    char buffer[250];
+    fputs("lua_debug> ", stderr);
+    if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
+        strcmp(buffer, "cont\n") == 0)
+      return 0;
+    if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
+        lua_pcall(L, 0, 0, 0)) {
+      fputs(lua_tostring(L, -1), stderr);
+      fputs("\n", stderr);
+    }
+    lua_settop(L, 0);  /* remove eventual returns */
+  }
+}
+
+
+#define LEVELS1	12	/* size of the first part of the stack */
+#define LEVELS2	10	/* size of the second part of the stack */
+
+static int db_errorfb (lua_State *L) {
+  int level;
+  int firstpart = 1;  /* still before eventual `...' */
+  int arg;
+  lua_State *L1 = getthread(L, &arg);
+  lua_Debug ar;
+  if (lua_isnumber(L, arg+2)) {
+    level = (int)lua_tointeger(L, arg+2);
+    lua_pop(L, 1);
+  }
+  else
+    level = (L == L1) ? 1 : 0;  /* level 0 may be this own function */
+  if (lua_gettop(L) == arg)
+    lua_pushliteral(L, "");
+  else if (!lua_isstring(L, arg+1)) return 1;  /* message is not a string */
+  else lua_pushliteral(L, "\n");
+  lua_pushliteral(L, "stack traceback:");
+  while (lua_getstack(L1, level++, &ar)) {
+    if (level > LEVELS1 && firstpart) {
+      /* no more than `LEVELS2' more levels? */
+      if (!lua_getstack(L1, level+LEVELS2, &ar))
+        level--;  /* keep going */
+      else {
+        lua_pushliteral(L, "\n\t...");  /* too many levels */
+        while (lua_getstack(L1, level+LEVELS2, &ar))  /* find last levels */
+          level++;
+      }
+      firstpart = 0;
+      continue;
+    }
+    lua_pushliteral(L, "\n\t");
+    lua_getinfo(L1, "Snl", &ar);
+    lua_pushfstring(L, "%s:", ar.short_src);
+    if (ar.currentline > 0)
+      lua_pushfstring(L, "%d:", ar.currentline);
+    if (*ar.namewhat != '\0')  /* is there a name? */
+        lua_pushfstring(L, " in function " LUA_QS, ar.name);
+    else {
+      if (*ar.what == 'm')  /* main? */
+        lua_pushfstring(L, " in main chunk");
+      else if (*ar.what == 'C' || *ar.what == 't')
+        lua_pushliteral(L, " ?");  /* C function or tail call */
+      else
+        lua_pushfstring(L, " in function <%s:%d>",
+                           ar.short_src, ar.linedefined);
+    }
+    lua_concat(L, lua_gettop(L) - arg);
+  }
+  lua_concat(L, lua_gettop(L) - arg);
+  return 1;
+}
+
+
+static const luaL_Reg dblib[] = {
+  {"debug", db_debug},
+  {"getfenv", db_getfenv},
+  {"gethook", db_gethook},
+  {"getinfo", db_getinfo},
+  {"getlocal", db_getlocal},
+  {"getregistry", db_getregistry},
+  {"getmetatable", db_getmetatable},
+  {"getupvalue", db_getupvalue},
+  {"setfenv", db_setfenv},
+  {"sethook", db_sethook},
+  {"setlocal", db_setlocal},
+  {"setmetatable", db_setmetatable},
+  {"setupvalue", db_setupvalue},
+  {"traceback", db_errorfb},
+  {NULL, NULL}
+};
+
+
+LUALIB_API int luaopen_debug (lua_State *L) {
+  luaL_register(L, LUA_DBLIBNAME, dblib);
+  return 1;
+}
+
Index: /code/branches/physics/src/lua/ldebug.c
===================================================================
--- /code/branches/physics/src/lua/ldebug.c	(revision 2122)
+++ /code/branches/physics/src/lua/ldebug.c	(revision 2122)
@@ -0,0 +1,622 @@
+/*
+** $Id: ldebug.c,v 2.29.1.3 2007/12/28 15:32:23 roberto Exp $
+** Debug Interface
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+
+
+#define ldebug_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lapi.h"
+#include "lcode.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lvm.h"
+
+
+
+static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
+
+
+static int currentpc (lua_State *L, CallInfo *ci) {
+  if (!isLua(ci)) return -1;  /* function is not a Lua function? */
+  if (ci == L->ci)
+    ci->savedpc = L->savedpc;
+  return pcRel(ci->savedpc, ci_func(ci)->l.p);
+}
+
+
+static int currentline (lua_State *L, CallInfo *ci) {
+  int pc = currentpc(L, ci);
+  if (pc < 0)
+    return -1;  /* only active lua functions have current-line information */
+  else
+    return getline(ci_func(ci)->l.p, pc);
+}
+
+
+/*
+** this function can be called asynchronous (e.g. during a signal)
+*/
+LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
+  if (func == NULL || mask == 0) {  /* turn off hooks? */
+    mask = 0;
+    func = NULL;
+  }
+  L->hook = func;
+  L->basehookcount = count;
+  resethookcount(L);
+  L->hookmask = cast_byte(mask);
+  return 1;
+}
+
+
+LUA_API lua_Hook lua_gethook (lua_State *L) {
+  return L->hook;
+}
+
+
+LUA_API int lua_gethookmask (lua_State *L) {
+  return L->hookmask;
+}
+
+
+LUA_API int lua_gethookcount (lua_State *L) {
+  return L->basehookcount;
+}
+
+
+LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
+  int status;
+  CallInfo *ci;
+  lua_lock(L);
+  for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) {
+    level--;
+    if (f_isLua(ci))  /* Lua function? */
+      level -= ci->tailcalls;  /* skip lost tail calls */
+  }
+  if (level == 0 && ci > L->base_ci) {  /* level found? */
+    status = 1;
+    ar->i_ci = cast_int(ci - L->base_ci);
+  }
+  else if (level < 0) {  /* level is of a lost tail call? */
+    status = 1;
+    ar->i_ci = 0;
+  }
+  else status = 0;  /* no such level */
+  lua_unlock(L);
+  return status;
+}
+
+
+static Proto *getluaproto (CallInfo *ci) {
+  return (isLua(ci) ? ci_func(ci)->l.p : NULL);
+}
+
+
+static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
+  const char *name;
+  Proto *fp = getluaproto(ci);
+  if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
+    return name;  /* is a local variable in a Lua function */
+  else {
+    StkId limit = (ci == L->ci) ? L->top : (ci+1)->func;
+    if (limit - ci->base >= n && n > 0)  /* is 'n' inside 'ci' stack? */
+      return "(*temporary)";
+    else
+      return NULL;
+  }
+}
+
+
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
+  CallInfo *ci = L->base_ci + ar->i_ci;
+  const char *name = findlocal(L, ci, n);
+  lua_lock(L);
+  if (name)
+      luaA_pushobject(L, ci->base + (n - 1));
+  lua_unlock(L);
+  return name;
+}
+
+
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
+  CallInfo *ci = L->base_ci + ar->i_ci;
+  const char *name = findlocal(L, ci, n);
+  lua_lock(L);
+  if (name)
+      setobjs2s(L, ci->base + (n - 1), L->top - 1);
+  L->top--;  /* pop value */
+  lua_unlock(L);
+  return name;
+}
+
+
+static void funcinfo (lua_Debug *ar, Closure *cl) {
+  if (cl->c.isC) {
+    ar->source = "=[C]";
+    ar->linedefined = -1;
+    ar->lastlinedefined = -1;
+    ar->what = "C";
+  }
+  else {
+    ar->source = getstr(cl->l.p->source);
+    ar->linedefined = cl->l.p->linedefined;
+    ar->lastlinedefined = cl->l.p->lastlinedefined;
+    ar->what = (ar->linedefined == 0) ? "main" : "Lua";
+  }
+  luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
+}
+
+
+static void info_tailcall (lua_Debug *ar) {
+  ar->name = ar->namewhat = "";
+  ar->what = "tail";
+  ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
+  ar->source = "=(tail call)";
+  luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
+  ar->nups = 0;
+}
+
+
+static void collectvalidlines (lua_State *L, Closure *f) {
+  if (f == NULL || f->c.isC) {
+    setnilvalue(L->top);
+  }
+  else {
+    Table *t = luaH_new(L, 0, 0);
+    int *lineinfo = f->l.p->lineinfo;
+    int i;
+    for (i=0; i<f->l.p->sizelineinfo; i++)
+      setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
+    sethvalue(L, L->top, t); 
+  }
+  incr_top(L);
+}
+
+
+static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
+                    Closure *f, CallInfo *ci) {
+  int status = 1;
+  if (f == NULL) {
+    info_tailcall(ar);
+    return status;
+  }
+  for (; *what; what++) {
+    switch (*what) {
+      case 'S': {
+        funcinfo(ar, f);
+        break;
+      }
+      case 'l': {
+        ar->currentline = (ci) ? currentline(L, ci) : -1;
+        break;
+      }
+      case 'u': {
+        ar->nups = f->c.nupvalues;
+        break;
+      }
+      case 'n': {
+        ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
+        if (ar->namewhat == NULL) {
+          ar->namewhat = "";  /* not found */
+          ar->name = NULL;
+        }
+        break;
+      }
+      case 'L':
+      case 'f':  /* handled by lua_getinfo */
+        break;
+      default: status = 0;  /* invalid option */
+    }
+  }
+  return status;
+}
+
+
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
+  int status;
+  Closure *f = NULL;
+  CallInfo *ci = NULL;
+  lua_lock(L);
+  if (*what == '>') {
+    StkId func = L->top - 1;
+    luai_apicheck(L, ttisfunction(func));
+    what++;  /* skip the '>' */
+    f = clvalue(func);
+    L->top--;  /* pop function */
+  }
+  else if (ar->i_ci != 0) {  /* no tail call? */
+    ci = L->base_ci + ar->i_ci;
+    lua_assert(ttisfunction(ci->func));
+    f = clvalue(ci->func);
+  }
+  status = auxgetinfo(L, what, ar, f, ci);
+  if (strchr(what, 'f')) {
+    if (f == NULL) setnilvalue(L->top);
+    else setclvalue(L, L->top, f);
+    incr_top(L);
+  }
+  if (strchr(what, 'L'))
+    collectvalidlines(L, f);
+  lua_unlock(L);
+  return status;
+}
+
+
+/*
+** {======================================================
+** Symbolic Execution and code checker
+** =======================================================
+*/
+
+#define check(x)		if (!(x)) return 0;
+
+#define checkjump(pt,pc)	check(0 <= pc && pc < pt->sizecode)
+
+#define checkreg(pt,reg)	check((reg) < (pt)->maxstacksize)
+
+
+
+static int precheck (const Proto *pt) {
+  check(pt->maxstacksize <= MAXSTACK);
+  lua_assert(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
+  lua_assert(!(pt->is_vararg & VARARG_NEEDSARG) ||
+              (pt->is_vararg & VARARG_HASARG));
+  check(pt->sizeupvalues <= pt->nups);
+  check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
+  check(GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
+  return 1;
+}
+
+
+#define checkopenop(pt,pc)	luaG_checkopenop((pt)->code[(pc)+1])
+
+int luaG_checkopenop (Instruction i) {
+  switch (GET_OPCODE(i)) {
+    case OP_CALL:
+    case OP_TAILCALL:
+    case OP_RETURN:
+    case OP_SETLIST: {
+      check(GETARG_B(i) == 0);
+      return 1;
+    }
+    default: return 0;  /* invalid instruction after an open call */
+  }
+}
+
+
+static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
+  switch (mode) {
+    case OpArgN: check(r == 0); break;
+    case OpArgU: break;
+    case OpArgR: checkreg(pt, r); break;
+    case OpArgK:
+      check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize);
+      break;
+  }
+  return 1;
+}
+
+
+static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
+  int pc;
+  int last;  /* stores position of last instruction that changed `reg' */
+  last = pt->sizecode-1;  /* points to final return (a `neutral' instruction) */
+  check(precheck(pt));
+  for (pc = 0; pc < lastpc; pc++) {
+    Instruction i = pt->code[pc];
+    OpCode op = GET_OPCODE(i);
+    int a = GETARG_A(i);
+    int b = 0;
+    int c = 0;
+    check(op < NUM_OPCODES);
+    checkreg(pt, a);
+    switch (getOpMode(op)) {
+      case iABC: {
+        b = GETARG_B(i);
+        c = GETARG_C(i);
+        check(checkArgMode(pt, b, getBMode(op)));
+        check(checkArgMode(pt, c, getCMode(op)));
+        break;
+      }
+      case iABx: {
+        b = GETARG_Bx(i);
+        if (getBMode(op) == OpArgK) check(b < pt->sizek);
+        break;
+      }
+      case iAsBx: {
+        b = GETARG_sBx(i);
+        if (getBMode(op) == OpArgR) {
+          int dest = pc+1+b;
+          check(0 <= dest && dest < pt->sizecode);
+          if (dest > 0) {
+            /* cannot jump to a setlist count */
+            Instruction d = pt->code[dest-1];
+            check(!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0));
+          }
+        }
+        break;
+      }
+    }
+    if (testAMode(op)) {
+      if (a == reg) last = pc;  /* change register `a' */
+    }
+    if (testTMode(op)) {
+      check(pc+2 < pt->sizecode);  /* check skip */
+      check(GET_OPCODE(pt->code[pc+1]) == OP_JMP);
+    }
+    switch (op) {
+      case OP_LOADBOOL: {
+        check(c == 0 || pc+2 < pt->sizecode);  /* check its jump */
+        break;
+      }
+      case OP_LOADNIL: {
+        if (a <= reg && reg <= b)
+          last = pc;  /* set registers from `a' to `b' */
+        break;
+      }
+      case OP_GETUPVAL:
+      case OP_SETUPVAL: {
+        check(b < pt->nups);
+        break;
+      }
+      case OP_GETGLOBAL:
+      case OP_SETGLOBAL: {
+        check(ttisstring(&pt->k[b]));
+        break;
+      }
+      case OP_SELF: {
+        checkreg(pt, a+1);
+        if (reg == a+1) last = pc;
+        break;
+      }
+      case OP_CONCAT: {
+        check(b < c);  /* at least two operands */
+        break;
+      }
+      case OP_TFORLOOP: {
+        check(c >= 1);  /* at least one result (control variable) */
+        checkreg(pt, a+2+c);  /* space for results */
+        if (reg >= a+2) last = pc;  /* affect all regs above its base */
+        break;
+      }
+      case OP_FORLOOP:
+      case OP_FORPREP:
+        checkreg(pt, a+3);
+        /* go through */
+      case OP_JMP: {
+        int dest = pc+1+b;
+        /* not full check and jump is forward and do not skip `lastpc'? */
+        if (reg != NO_REG && pc < dest && dest <= lastpc)
+          pc += b;  /* do the jump */
+        break;
+      }
+      case OP_CALL:
+      case OP_TAILCALL: {
+        if (b != 0) {
+          checkreg(pt, a+b-1);
+        }
+        c--;  /* c = num. returns */
+        if (c == LUA_MULTRET) {
+          check(checkopenop(pt, pc));
+        }
+        else if (c != 0)
+          checkreg(pt, a+c-1);
+        if (reg >= a) last = pc;  /* affect all registers above base */
+        break;
+      }
+      case OP_RETURN: {
+        b--;  /* b = num. returns */
+        if (b > 0) checkreg(pt, a+b-1);
+        break;
+      }
+      case OP_SETLIST: {
+        if (b > 0) checkreg(pt, a + b);
+        if (c == 0) pc++;
+        break;
+      }
+      case OP_CLOSURE: {
+        int nup, j;
+        check(b < pt->sizep);
+        nup = pt->p[b]->nups;
+        check(pc + nup < pt->sizecode);
+        for (j = 1; j <= nup; j++) {
+          OpCode op1 = GET_OPCODE(pt->code[pc + j]);
+          check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
+        }
+        if (reg != NO_REG)  /* tracing? */
+          pc += nup;  /* do not 'execute' these pseudo-instructions */
+        break;
+      }
+      case OP_VARARG: {
+        check((pt->is_vararg & VARARG_ISVARARG) &&
+             !(pt->is_vararg & VARARG_NEEDSARG));
+        b--;
+        if (b == LUA_MULTRET) check(checkopenop(pt, pc));
+        checkreg(pt, a+b-1);
+        break;
+      }
+      default: break;
+    }
+  }
+  return pt->code[last];
+}
+
+#undef check
+#undef checkjump
+#undef checkreg
+
+/* }====================================================== */
+
+
+int luaG_checkcode (const Proto *pt) {
+  return (symbexec(pt, pt->sizecode, NO_REG) != 0);
+}
+
+
+static const char *kname (Proto *p, int c) {
+  if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
+    return svalue(&p->k[INDEXK(c)]);
+  else
+    return "?";
+}
+
+
+static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
+                               const char **name) {
+  if (isLua(ci)) {  /* a Lua function? */
+    Proto *p = ci_func(ci)->l.p;
+    int pc = currentpc(L, ci);
+    Instruction i;
+    *name = luaF_getlocalname(p, stackpos+1, pc);
+    if (*name)  /* is a local? */
+      return "local";
+    i = symbexec(p, pc, stackpos);  /* try symbolic execution */
+    lua_assert(pc != -1);
+    switch (GET_OPCODE(i)) {
+      case OP_GETGLOBAL: {
+        int g = GETARG_Bx(i);  /* global index */
+        lua_assert(ttisstring(&p->k[g]));
+        *name = svalue(&p->k[g]);
+        return "global";
+      }
+      case OP_MOVE: {
+        int a = GETARG_A(i);
+        int b = GETARG_B(i);  /* move from `b' to `a' */
+        if (b < a)
+          return getobjname(L, ci, b, name);  /* get name for `b' */
+        break;
+      }
+      case OP_GETTABLE: {
+        int k = GETARG_C(i);  /* key index */
+        *name = kname(p, k);
+        return "field";
+      }
+      case OP_GETUPVAL: {
+        int u = GETARG_B(i);  /* upvalue index */
+        *name = p->upvalues ? getstr(p->upvalues[u]) : "?";
+        return "upvalue";
+      }
+      case OP_SELF: {
+        int k = GETARG_C(i);  /* key index */
+        *name = kname(p, k);
+        return "method";
+      }
+      default: break;
+    }
+  }
+  return NULL;  /* no useful name found */
+}
+
+
+static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
+  Instruction i;
+  if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
+    return NULL;  /* calling function is not Lua (or is unknown) */
+  ci--;  /* calling function */
+  i = ci_func(ci)->l.p->code[currentpc(L, ci)];
+  if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
+      GET_OPCODE(i) == OP_TFORLOOP)
+    return getobjname(L, ci, GETARG_A(i), name);
+  else
+    return NULL;  /* no useful name can be found */
+}
+
+
+/* only ANSI way to check whether a pointer points to an array */
+static int isinstack (CallInfo *ci, const TValue *o) {
+  StkId p;
+  for (p = ci->base; p < ci->top; p++)
+    if (o == p) return 1;
+  return 0;
+}
+
+
+void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
+  const char *name = NULL;
+  const char *t = luaT_typenames[ttype(o)];
+  const char *kind = (isinstack(L->ci, o)) ?
+                         getobjname(L, L->ci, cast_int(o - L->base), &name) :
+                         NULL;
+  if (kind)
+    luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
+                op, kind, name, t);
+  else
+    luaG_runerror(L, "attempt to %s a %s value", op, t);
+}
+
+
+void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
+  if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
+  lua_assert(!ttisstring(p1) && !ttisnumber(p1));
+  luaG_typeerror(L, p1, "concatenate");
+}
+
+
+void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
+  TValue temp;
+  if (luaV_tonumber(p1, &temp) == NULL)
+    p2 = p1;  /* first operand is wrong */
+  luaG_typeerror(L, p2, "perform arithmetic on");
+}
+
+
+int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
+  const char *t1 = luaT_typenames[ttype(p1)];
+  const char *t2 = luaT_typenames[ttype(p2)];
+  if (t1[2] == t2[2])
+    luaG_runerror(L, "attempt to compare two %s values", t1);
+  else
+    luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
+  return 0;
+}
+
+
+static void addinfo (lua_State *L, const char *msg) {
+  CallInfo *ci = L->ci;
+  if (isLua(ci)) {  /* is Lua code? */
+    char buff[LUA_IDSIZE];  /* add file:line information */
+    int line = currentline(L, ci);
+    luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE);
+    luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
+  }
+}
+
+
+void luaG_errormsg (lua_State *L) {
+  if (L->errfunc != 0) {  /* is there an error handling function? */
+    StkId errfunc = restorestack(L, L->errfunc);
+    if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
+    setobjs2s(L, L->top, L->top - 1);  /* move argument */
+    setobjs2s(L, L->top - 1, errfunc);  /* push function */
+    incr_top(L);
+    luaD_call(L, L->top - 2, 1);  /* call it */
+  }
+  luaD_throw(L, LUA_ERRRUN);
+}
+
+
+void luaG_runerror (lua_State *L, const char *fmt, ...) {
+  va_list argp;
+  va_start(argp, fmt);
+  addinfo(L, luaO_pushvfstring(L, fmt, argp));
+  va_end(argp);
+  luaG_errormsg(L);
+}
+
Index: /code/branches/physics/src/lua/ldebug.h
===================================================================
--- /code/branches/physics/src/lua/ldebug.h	(revision 2122)
+++ /code/branches/physics/src/lua/ldebug.h	(revision 2122)
@@ -0,0 +1,33 @@
+/*
+** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
+** Auxiliary functions from Debug Interface module
+** See Copyright Notice in lua.h
+*/
+
+#ifndef ldebug_h
+#define ldebug_h
+
+
+#include "lstate.h"
+
+
+#define pcRel(pc, p)	(cast(int, (pc) - (p)->code) - 1)
+
+#define getline(f,pc)	(((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
+
+#define resethookcount(L)	(L->hookcount = L->basehookcount)
+
+
+LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
+                                             const char *opname);
+LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
+LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
+                                              const TValue *p2);
+LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
+                                             const TValue *p2);
+LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
+LUAI_FUNC void luaG_errormsg (lua_State *L);
+LUAI_FUNC int luaG_checkcode (const Proto *pt);
+LUAI_FUNC int luaG_checkopenop (Instruction i);
+
+#endif
Index: /code/branches/physics/src/lua/ldo.c
===================================================================
--- /code/branches/physics/src/lua/ldo.c	(revision 2122)
+++ /code/branches/physics/src/lua/ldo.c	(revision 2122)
@@ -0,0 +1,518 @@
+/*
+** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
+** Stack and Call structure of Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#include <setjmp.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ldo_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lparser.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lundump.h"
+#include "lvm.h"
+#include "lzio.h"
+
+
+
+
+/*
+** {======================================================
+** Error-recovery functions
+** =======================================================
+*/
+
+
+/* chain list of long jump buffers */
+struct lua_longjmp {
+  struct lua_longjmp *previous;
+  luai_jmpbuf b;
+  volatile int status;  /* error code */
+};
+
+
+void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
+  switch (errcode) {
+    case LUA_ERRMEM: {
+      setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG));
+      break;
+    }
+    case LUA_ERRERR: {
+      setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
+      break;
+    }
+    case LUA_ERRSYNTAX:
+    case LUA_ERRRUN: {
+      setobjs2s(L, oldtop, L->top - 1);  /* error message on current top */
+      break;
+    }
+  }
+  L->top = oldtop + 1;
+}
+
+
+static void restore_stack_limit (lua_State *L) {
+  lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
+  if (L->size_ci > LUAI_MAXCALLS) {  /* there was an overflow? */
+    int inuse = cast_int(L->ci - L->base_ci);
+    if (inuse + 1 < LUAI_MAXCALLS)  /* can `undo' overflow? */
+      luaD_reallocCI(L, LUAI_MAXCALLS);
+  }
+}
+
+
+static void resetstack (lua_State *L, int status) {
+  L->ci = L->base_ci;
+  L->base = L->ci->base;
+  luaF_close(L, L->base);  /* close eventual pending closures */
+  luaD_seterrorobj(L, status, L->base);
+  L->nCcalls = L->baseCcalls;
+  L->allowhook = 1;
+  restore_stack_limit(L);
+  L->errfunc = 0;
+  L->errorJmp = NULL;
+}
+
+
+void luaD_throw (lua_State *L, int errcode) {
+  if (L->errorJmp) {
+    L->errorJmp->status = errcode;
+    LUAI_THROW(L, L->errorJmp);
+  }
+  else {
+    L->status = cast_byte(errcode);
+    if (G(L)->panic) {
+      resetstack(L, errcode);
+      lua_unlock(L);
+      G(L)->panic(L);
+    }
+    exit(EXIT_FAILURE);
+  }
+}
+
+
+int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
+  struct lua_longjmp lj;
+  lj.status = 0;
+  lj.previous = L->errorJmp;  /* chain new error handler */
+  L->errorJmp = &lj;
+  LUAI_TRY(L, &lj,
+    (*f)(L, ud);
+  );
+  L->errorJmp = lj.previous;  /* restore old error handler */
+  return lj.status;
+}
+
+/* }====================================================== */
+
+
+static void correctstack (lua_State *L, TValue *oldstack) {
+  CallInfo *ci;
+  GCObject *up;
+  L->top = (L->top - oldstack) + L->stack;
+  for (up = L->openupval; up != NULL; up = up->gch.next)
+    gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
+  for (ci = L->base_ci; ci <= L->ci; ci++) {
+    ci->top = (ci->top - oldstack) + L->stack;
+    ci->base = (ci->base - oldstack) + L->stack;
+    ci->func = (ci->func - oldstack) + L->stack;
+  }
+  L->base = (L->base - oldstack) + L->stack;
+}
+
+
+void luaD_reallocstack (lua_State *L, int newsize) {
+  TValue *oldstack = L->stack;
+  int realsize = newsize + 1 + EXTRA_STACK;
+  lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
+  luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
+  L->stacksize = realsize;
+  L->stack_last = L->stack+newsize;
+  correctstack(L, oldstack);
+}
+
+
+void luaD_reallocCI (lua_State *L, int newsize) {
+  CallInfo *oldci = L->base_ci;
+  luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
+  L->size_ci = newsize;
+  L->ci = (L->ci - oldci) + L->base_ci;
+  L->end_ci = L->base_ci + L->size_ci - 1;
+}
+
+
+void luaD_growstack (lua_State *L, int n) {
+  if (n <= L->stacksize)  /* double size is enough? */
+    luaD_reallocstack(L, 2*L->stacksize);
+  else
+    luaD_reallocstack(L, L->stacksize + n);
+}
+
+
+static CallInfo *growCI (lua_State *L) {
+  if (L->size_ci > LUAI_MAXCALLS)  /* overflow while handling overflow? */
+    luaD_throw(L, LUA_ERRERR);
+  else {
+    luaD_reallocCI(L, 2*L->size_ci);
+    if (L->size_ci > LUAI_MAXCALLS)
+      luaG_runerror(L, "stack overflow");
+  }
+  return ++L->ci;
+}
+
+
+void luaD_callhook (lua_State *L, int event, int line) {
+  lua_Hook hook = L->hook;
+  if (hook && L->allowhook) {
+    ptrdiff_t top = savestack(L, L->top);
+    ptrdiff_t ci_top = savestack(L, L->ci->top);
+    lua_Debug ar;
+    ar.event = event;
+    ar.currentline = line;
+    if (event == LUA_HOOKTAILRET)
+      ar.i_ci = 0;  /* tail call; no debug information about it */
+    else
+      ar.i_ci = cast_int(L->ci - L->base_ci);
+    luaD_checkstack(L, LUA_MINSTACK);  /* ensure minimum stack size */
+    L->ci->top = L->top + LUA_MINSTACK;
+    lua_assert(L->ci->top <= L->stack_last);
+    L->allowhook = 0;  /* cannot call hooks inside a hook */
+    lua_unlock(L);
+    (*hook)(L, &ar);
+    lua_lock(L);
+    lua_assert(!L->allowhook);
+    L->allowhook = 1;
+    L->ci->top = restorestack(L, ci_top);
+    L->top = restorestack(L, top);
+  }
+}
+
+
+static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
+  int i;
+  int nfixargs = p->numparams;
+  Table *htab = NULL;
+  StkId base, fixed;
+  for (; actual < nfixargs; ++actual)
+    setnilvalue(L->top++);
+#if defined(LUA_COMPAT_VARARG)
+  if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */
+    int nvar = actual - nfixargs;  /* number of extra arguments */
+    lua_assert(p->is_vararg & VARARG_HASARG);
+    luaC_checkGC(L);
+    htab = luaH_new(L, nvar, 1);  /* create `arg' table */
+    for (i=0; i<nvar; i++)  /* put extra arguments into `arg' table */
+      setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
+    /* store counter in field `n' */
+    setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
+  }
+#endif
+  /* move fixed parameters to final position */
+  fixed = L->top - actual;  /* first fixed argument */
+  base = L->top;  /* final position of first argument */
+  for (i=0; i<nfixargs; i++) {
+    setobjs2s(L, L->top++, fixed+i);
+    setnilvalue(fixed+i);
+  }
+  /* add `arg' parameter */
+  if (htab) {
+    sethvalue(L, L->top++, htab);
+    lua_assert(iswhite(obj2gco(htab)));
+  }
+  return base;
+}
+
+
+static StkId tryfuncTM (lua_State *L, StkId func) {
+  const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
+  StkId p;
+  ptrdiff_t funcr = savestack(L, func);
+  if (!ttisfunction(tm))
+    luaG_typeerror(L, func, "call");
+  /* Open a hole inside the stack at `func' */
+  for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
+  incr_top(L);
+  func = restorestack(L, funcr);  /* previous call may change stack */
+  setobj2s(L, func, tm);  /* tag method is the new function to be called */
+  return func;
+}
+
+
+
+#define inc_ci(L) \
+  ((L->ci == L->end_ci) ? growCI(L) : \
+   (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
+
+
+int luaD_precall (lua_State *L, StkId func, int nresults) {
+  LClosure *cl;
+  ptrdiff_t funcr;
+  if (!ttisfunction(func)) /* `func' is not a function? */
+    func = tryfuncTM(L, func);  /* check the `function' tag method */
+  funcr = savestack(L, func);
+  cl = &clvalue(func)->l;
+  L->ci->savedpc = L->savedpc;
+  if (!cl->isC) {  /* Lua function? prepare its call */
+    CallInfo *ci;
+    StkId st, base;
+    Proto *p = cl->p;
+    luaD_checkstack(L, p->maxstacksize);
+    func = restorestack(L, funcr);
+    if (!p->is_vararg) {  /* no varargs? */
+      base = func + 1;
+      if (L->top > base + p->numparams)
+        L->top = base + p->numparams;
+    }
+    else {  /* vararg function */
+      int nargs = cast_int(L->top - func) - 1;
+      base = adjust_varargs(L, p, nargs);
+      func = restorestack(L, funcr);  /* previous call may change the stack */
+    }
+    ci = inc_ci(L);  /* now `enter' new function */
+    ci->func = func;
+    L->base = ci->base = base;
+    ci->top = L->base + p->maxstacksize;
+    lua_assert(ci->top <= L->stack_last);
+    L->savedpc = p->code;  /* starting point */
+    ci->tailcalls = 0;
+    ci->nresults = nresults;
+    for (st = L->top; st < ci->top; st++)
+      setnilvalue(st);
+    L->top = ci->top;
+    if (L->hookmask & LUA_MASKCALL) {
+      L->savedpc++;  /* hooks assume 'pc' is already incremented */
+      luaD_callhook(L, LUA_HOOKCALL, -1);
+      L->savedpc--;  /* correct 'pc' */
+    }
+    return PCRLUA;
+  }
+  else {  /* if is a C function, call it */
+    CallInfo *ci;
+    int n;
+    luaD_checkstack(L, LUA_MINSTACK);  /* ensure minimum stack size */
+    ci = inc_ci(L);  /* now `enter' new function */
+    ci->func = restorestack(L, funcr);
+    L->base = ci->base = ci->func + 1;
+    ci->top = L->top + LUA_MINSTACK;
+    lua_assert(ci->top <= L->stack_last);
+    ci->nresults = nresults;
+    if (L->hookmask & LUA_MASKCALL)
+      luaD_callhook(L, LUA_HOOKCALL, -1);
+    lua_unlock(L);
+    n = (*curr_func(L)->c.f)(L);  /* do the actual call */
+    lua_lock(L);
+    if (n < 0)  /* yielding? */
+      return PCRYIELD;
+    else {
+      luaD_poscall(L, L->top - n);
+      return PCRC;
+    }
+  }
+}
+
+
+static StkId callrethooks (lua_State *L, StkId firstResult) {
+  ptrdiff_t fr = savestack(L, firstResult);  /* next call may change stack */
+  luaD_callhook(L, LUA_HOOKRET, -1);
+  if (f_isLua(L->ci)) {  /* Lua function? */
+    while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
+      luaD_callhook(L, LUA_HOOKTAILRET, -1);
+  }
+  return restorestack(L, fr);
+}
+
+
+int luaD_poscall (lua_State *L, StkId firstResult) {
+  StkId res;
+  int wanted, i;
+  CallInfo *ci;
+  if (L->hookmask & LUA_MASKRET)
+    firstResult = callrethooks(L, firstResult);
+  ci = L->ci--;
+  res = ci->func;  /* res == final position of 1st result */
+  wanted = ci->nresults;
+  L->base = (ci - 1)->base;  /* restore base */
+  L->savedpc = (ci - 1)->savedpc;  /* restore savedpc */
+  /* move results to correct place */
+  for (i = wanted; i != 0 && firstResult < L->top; i--)
+    setobjs2s(L, res++, firstResult++);
+  while (i-- > 0)
+    setnilvalue(res++);
+  L->top = res;
+  return (wanted - LUA_MULTRET);  /* 0 iff wanted == LUA_MULTRET */
+}
+
+
+/*
+** Call a function (C or Lua). The function to be called is at *func.
+** The arguments are on the stack, right after the function.
+** When returns, all the results are on the stack, starting at the original
+** function position.
+*/ 
+void luaD_call (lua_State *L, StkId func, int nResults) {
+  if (++L->nCcalls >= LUAI_MAXCCALLS) {
+    if (L->nCcalls == LUAI_MAXCCALLS)
+      luaG_runerror(L, "C stack overflow");
+    else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
+      luaD_throw(L, LUA_ERRERR);  /* error while handing stack error */
+  }
+  if (luaD_precall(L, func, nResults) == PCRLUA)  /* is a Lua function? */
+    luaV_execute(L, 1);  /* call it */
+  L->nCcalls--;
+  luaC_checkGC(L);
+}
+
+
+static void resume (lua_State *L, void *ud) {
+  StkId firstArg = cast(StkId, ud);
+  CallInfo *ci = L->ci;
+  if (L->status == 0) {  /* start coroutine? */
+    lua_assert(ci == L->base_ci && firstArg > L->base);
+    if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA)
+      return;
+  }
+  else {  /* resuming from previous yield */
+    lua_assert(L->status == LUA_YIELD);
+    L->status = 0;
+    if (!f_isLua(ci)) {  /* `common' yield? */
+      /* finish interrupted execution of `OP_CALL' */
+      lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
+                 GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL);
+      if (luaD_poscall(L, firstArg))  /* complete it... */
+        L->top = L->ci->top;  /* and correct top if not multiple results */
+    }
+    else  /* yielded inside a hook: just continue its execution */
+      L->base = L->ci->base;
+  }
+  luaV_execute(L, cast_int(L->ci - L->base_ci));
+}
+
+
+static int resume_error (lua_State *L, const char *msg) {
+  L->top = L->ci->base;
+  setsvalue2s(L, L->top, luaS_new(L, msg));
+  incr_top(L);
+  lua_unlock(L);
+  return LUA_ERRRUN;
+}
+
+
+LUA_API int lua_resume (lua_State *L, int nargs) {
+  int status;
+  lua_lock(L);
+  if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
+      return resume_error(L, "cannot resume non-suspended coroutine");
+  if (L->nCcalls >= LUAI_MAXCCALLS)
+    return resume_error(L, "C stack overflow");
+  luai_userstateresume(L, nargs);
+  lua_assert(L->errfunc == 0);
+  L->baseCcalls = ++L->nCcalls;
+  status = luaD_rawrunprotected(L, resume, L->top - nargs);
+  if (status != 0) {  /* error? */
+    L->status = cast_byte(status);  /* mark thread as `dead' */
+    luaD_seterrorobj(L, status, L->top);
+    L->ci->top = L->top;
+  }
+  else {
+    lua_assert(L->nCcalls == L->baseCcalls);
+    status = L->status;
+  }
+  --L->nCcalls;
+  lua_unlock(L);
+  return status;
+}
+
+
+LUA_API int lua_yield (lua_State *L, int nresults) {
+  luai_userstateyield(L, nresults);
+  lua_lock(L);
+  if (L->nCcalls > L->baseCcalls)
+    luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
+  L->base = L->top - nresults;  /* protect stack slots below */
+  L->status = LUA_YIELD;
+  lua_unlock(L);
+  return -1;
+}
+
+
+int luaD_pcall (lua_State *L, Pfunc func, void *u,
+                ptrdiff_t old_top, ptrdiff_t ef) {
+  int status;
+  unsigned short oldnCcalls = L->nCcalls;
+  ptrdiff_t old_ci = saveci(L, L->ci);
+  lu_byte old_allowhooks = L->allowhook;
+  ptrdiff_t old_errfunc = L->errfunc;
+  L->errfunc = ef;
+  status = luaD_rawrunprotected(L, func, u);
+  if (status != 0) {  /* an error occurred? */
+    StkId oldtop = restorestack(L, old_top);
+    luaF_close(L, oldtop);  /* close eventual pending closures */
+    luaD_seterrorobj(L, status, oldtop);
+    L->nCcalls = oldnCcalls;
+    L->ci = restoreci(L, old_ci);
+    L->base = L->ci->base;
+    L->savedpc = L->ci->savedpc;
+    L->allowhook = old_allowhooks;
+    restore_stack_limit(L);
+  }
+  L->errfunc = old_errfunc;
+  return status;
+}
+
+
+
+/*
+** Execute a protected parser.
+*/
+struct SParser {  /* data to `f_parser' */
+  ZIO *z;
+  Mbuffer buff;  /* buffer to be used by the scanner */
+  const char *name;
+};
+
+static void f_parser (lua_State *L, void *ud) {
+  int i;
+  Proto *tf;
+  Closure *cl;
+  struct SParser *p = cast(struct SParser *, ud);
+  int c = luaZ_lookahead(p->z);
+  luaC_checkGC(L);
+  tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
+                                                             &p->buff, p->name);
+  cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
+  cl->l.p = tf;
+  for (i = 0; i < tf->nups; i++)  /* initialize eventual upvalues */
+    cl->l.upvals[i] = luaF_newupval(L);
+  setclvalue(L, L->top, cl);
+  incr_top(L);
+}
+
+
+int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
+  struct SParser p;
+  int status;
+  p.z = z; p.name = name;
+  luaZ_initbuffer(L, &p.buff);
+  status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
+  luaZ_freebuffer(L, &p.buff);
+  return status;
+}
+
+
Index: /code/branches/physics/src/lua/ldo.h
===================================================================
--- /code/branches/physics/src/lua/ldo.h	(revision 2122)
+++ /code/branches/physics/src/lua/ldo.h	(revision 2122)
@@ -0,0 +1,57 @@
+/*
+** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
+** Stack and Call structure of Lua
+** See Copyright Notice in lua.h
+*/
+
+#ifndef ldo_h
+#define ldo_h
+
+
+#include "lobject.h"
+#include "lstate.h"
+#include "lzio.h"
+
+
+#define luaD_checkstack(L,n)	\
+  if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
+    luaD_growstack(L, n); \
+  else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
+
+
+#define incr_top(L) {luaD_checkstack(L,1); L->top++;}
+
+#define savestack(L,p)		((char *)(p) - (char *)L->stack)
+#define restorestack(L,n)	((TValue *)((char *)L->stack + (n)))
+
+#define saveci(L,p)		((char *)(p) - (char *)L->base_ci)
+#define restoreci(L,n)		((CallInfo *)((char *)L->base_ci + (n)))
+
+
+/* results from luaD_precall */
+#define PCRLUA		0	/* initiated a call to a Lua function */
+#define PCRC		1	/* did a call to a C function */
+#define PCRYIELD	2	/* C funtion yielded */
+
+
+/* type of protected functions, to be ran by `runprotected' */
+typedef void (*Pfunc) (lua_State *L, void *ud);
+
+LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
+LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
+LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
+LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
+LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
+                                        ptrdiff_t oldtop, ptrdiff_t ef);
+LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
+LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
+LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
+LUAI_FUNC void luaD_growstack (lua_State *L, int n);
+
+LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
+LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
+
+LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
+
+#endif
+
Index: /code/branches/physics/src/lua/ldump.c
===================================================================
--- /code/branches/physics/src/lua/ldump.c	(revision 2122)
+++ /code/branches/physics/src/lua/ldump.c	(revision 2122)
@@ -0,0 +1,164 @@
+/*
+** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
+** save precompiled Lua chunks
+** See Copyright Notice in lua.h
+*/
+
+#include <stddef.h>
+
+#define ldump_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lobject.h"
+#include "lstate.h"
+#include "lundump.h"
+
+typedef struct {
+ lua_State* L;
+ lua_Writer writer;
+ void* data;
+ int strip;
+ int status;
+} DumpState;
+
+#define DumpMem(b,n,size,D)	DumpBlock(b,(n)*(size),D)
+#define DumpVar(x,D)	 	DumpMem(&x,1,sizeof(x),D)
+
+static void DumpBlock(const void* b, size_t size, DumpState* D)
+{
+ if (D->status==0)
+ {
+  lua_unlock(D->L);
+  D->status=(*D->writer)(D->L,b,size,D->data);
+  lua_lock(D->L);
+ }
+}
+
+static void DumpChar(int y, DumpState* D)
+{
+ char x=(char)y;
+ DumpVar(x,D);
+}
+
+static void DumpInt(int x, DumpState* D)
+{
+ DumpVar(x,D);
+}
+
+static void DumpNumber(lua_Number x, DumpState* D)
+{
+ DumpVar(x,D);
+}
+
+static void DumpVector(const void* b, int n, size_t size, DumpState* D)
+{
+ DumpInt(n,D);
+ DumpMem(b,n,size,D);
+}
+
+static void DumpString(const TString* s, DumpState* D)
+{
+ if (s==NULL || getstr(s)==NULL)
+ {
+  size_t size=0;
+  DumpVar(size,D);
+ }
+ else
+ {
+  size_t size=s->tsv.len+1;		/* include trailing '\0' */
+  DumpVar(size,D);
+  DumpBlock(getstr(s),size,D);
+ }
+}
+
+#define DumpCode(f,D)	 DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
+
+static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
+
+static void DumpConstants(const Proto* f, DumpState* D)
+{
+ int i,n=f->sizek;
+ DumpInt(n,D);
+ for (i=0; i<n; i++)
+ {
+  const TValue* o=&f->k[i];
+  DumpChar(ttype(o),D);
+  switch (ttype(o))
+  {
+   case LUA_TNIL:
+	break;
+   case LUA_TBOOLEAN:
+	DumpChar(bvalue(o),D);
+	break;
+   case LUA_TNUMBER:
+	DumpNumber(nvalue(o),D);
+	break;
+   case LUA_TSTRING:
+	DumpString(rawtsvalue(o),D);
+	break;
+   default:
+	lua_assert(0);			/* cannot happen */
+	break;
+  }
+ }
+ n=f->sizep;
+ DumpInt(n,D);
+ for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
+}
+
+static void DumpDebug(const Proto* f, DumpState* D)
+{
+ int i,n;
+ n= (D->strip) ? 0 : f->sizelineinfo;
+ DumpVector(f->lineinfo,n,sizeof(int),D);
+ n= (D->strip) ? 0 : f->sizelocvars;
+ DumpInt(n,D);
+ for (i=0; i<n; i++)
+ {
+  DumpString(f->locvars[i].varname,D);
+  DumpInt(f->locvars[i].startpc,D);
+  DumpInt(f->locvars[i].endpc,D);
+ }
+ n= (D->strip) ? 0 : f->sizeupvalues;
+ DumpInt(n,D);
+ for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
+}
+
+static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
+{
+ DumpString((f->source==p || D->strip) ? NULL : f->source,D);
+ DumpInt(f->linedefined,D);
+ DumpInt(f->lastlinedefined,D);
+ DumpChar(f->nups,D);
+ DumpChar(f->numparams,D);
+ DumpChar(f->is_vararg,D);
+ DumpChar(f->maxstacksize,D);
+ DumpCode(f,D);
+ DumpConstants(f,D);
+ DumpDebug(f,D);
+}
+
+static void DumpHeader(DumpState* D)
+{
+ char h[LUAC_HEADERSIZE];
+ luaU_header(h);
+ DumpBlock(h,LUAC_HEADERSIZE,D);
+}
+
+/*
+** dump Lua function as precompiled chunk
+*/
+int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
+{
+ DumpState D;
+ D.L=L;
+ D.writer=w;
+ D.data=data;
+ D.strip=strip;
+ D.status=0;
+ DumpHeader(&D);
+ DumpFunction(f,NULL,&D);
+ return D.status;
+}
Index: /code/branches/physics/src/lua/lfunc.c
===================================================================
--- /code/branches/physics/src/lua/lfunc.c	(revision 2122)
+++ /code/branches/physics/src/lua/lfunc.c	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
+** Auxiliary functions to manipulate prototypes and closures
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stddef.h>
+
+#define lfunc_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+
+
+
+Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
+  Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
+  luaC_link(L, obj2gco(c), LUA_TFUNCTION);
+  c->c.isC = 1;
+  c->c.env = e;
+  c->c.nupvalues = cast_byte(nelems);
+  return c;
+}
+
+
+Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
+  Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
+  luaC_link(L, obj2gco(c), LUA_TFUNCTION);
+  c->l.isC = 0;
+  c->l.env = e;
+  c->l.nupvalues = cast_byte(nelems);
+  while (nelems--) c->l.upvals[nelems] = NULL;
+  return c;
+}
+
+
+UpVal *luaF_newupval (lua_State *L) {
+  UpVal *uv = luaM_new(L, UpVal);
+  luaC_link(L, obj2gco(uv), LUA_TUPVAL);
+  uv->v = &uv->u.value;
+  setnilvalue(uv->v);
+  return uv;
+}
+
+
+UpVal *luaF_findupval (lua_State *L, StkId level) {
+  global_State *g = G(L);
+  GCObject **pp = &L->openupval;
+  UpVal *p;
+  UpVal *uv;
+  while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
+    lua_assert(p->v != &p->u.value);
+    if (p->v == level) {  /* found a corresponding upvalue? */
+      if (isdead(g, obj2gco(p)))  /* is it dead? */
+        changewhite(obj2gco(p));  /* ressurect it */
+      return p;
+    }
+    pp = &p->next;
+  }
+  uv = luaM_new(L, UpVal);  /* not found: create a new one */
+  uv->tt = LUA_TUPVAL;
+  uv->marked = luaC_white(g);
+  uv->v = level;  /* current value lives in the stack */
+  uv->next = *pp;  /* chain it in the proper position */
+  *pp = obj2gco(uv);
+  uv->u.l.prev = &g->uvhead;  /* double link it in `uvhead' list */
+  uv->u.l.next = g->uvhead.u.l.next;
+  uv->u.l.next->u.l.prev = uv;
+  g->uvhead.u.l.next = uv;
+  lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
+  return uv;
+}
+
+
+static void unlinkupval (UpVal *uv) {
+  lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
+  uv->u.l.next->u.l.prev = uv->u.l.prev;  /* remove from `uvhead' list */
+  uv->u.l.prev->u.l.next = uv->u.l.next;
+}
+
+
+void luaF_freeupval (lua_State *L, UpVal *uv) {
+  if (uv->v != &uv->u.value)  /* is it open? */
+    unlinkupval(uv);  /* remove from open list */
+  luaM_free(L, uv);  /* free upvalue */
+}
+
+
+void luaF_close (lua_State *L, StkId level) {
+  UpVal *uv;
+  global_State *g = G(L);
+  while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
+    GCObject *o = obj2gco(uv);
+    lua_assert(!isblack(o) && uv->v != &uv->u.value);
+    L->openupval = uv->next;  /* remove from `open' list */
+    if (isdead(g, o))
+      luaF_freeupval(L, uv);  /* free upvalue */
+    else {
+      unlinkupval(uv);
+      setobj(L, &uv->u.value, uv->v);
+      uv->v = &uv->u.value;  /* now current value lives here */
+      luaC_linkupval(L, uv);  /* link upvalue into `gcroot' list */
+    }
+  }
+}
+
+
+Proto *luaF_newproto (lua_State *L) {
+  Proto *f = luaM_new(L, Proto);
+  luaC_link(L, obj2gco(f), LUA_TPROTO);
+  f->k = NULL;
+  f->sizek = 0;
+  f->p = NULL;
+  f->sizep = 0;
+  f->code = NULL;
+  f->sizecode = 0;
+  f->sizelineinfo = 0;
+  f->sizeupvalues = 0;
+  f->nups = 0;
+  f->upvalues = NULL;
+  f->numparams = 0;
+  f->is_vararg = 0;
+  f->maxstacksize = 0;
+  f->lineinfo = NULL;
+  f->sizelocvars = 0;
+  f->locvars = NULL;
+  f->linedefined = 0;
+  f->lastlinedefined = 0;
+  f->source = NULL;
+  return f;
+}
+
+
+void luaF_freeproto (lua_State *L, Proto *f) {
+  luaM_freearray(L, f->code, f->sizecode, Instruction);
+  luaM_freearray(L, f->p, f->sizep, Proto *);
+  luaM_freearray(L, f->k, f->sizek, TValue);
+  luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
+  luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
+  luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
+  luaM_free(L, f);
+}
+
+
+void luaF_freeclosure (lua_State *L, Closure *c) {
+  int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
+                          sizeLclosure(c->l.nupvalues);
+  luaM_freemem(L, c, size);
+}
+
+
+/*
+** Look for n-th local variable at line `line' in function `func'.
+** Returns NULL if not found.
+*/
+const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
+  int i;
+  for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
+    if (pc < f->locvars[i].endpc) {  /* is variable active? */
+      local_number--;
+      if (local_number == 0)
+        return getstr(f->locvars[i].varname);
+    }
+  }
+  return NULL;  /* not found */
+}
+
Index: /code/branches/physics/src/lua/lfunc.h
===================================================================
--- /code/branches/physics/src/lua/lfunc.h	(revision 2122)
+++ /code/branches/physics/src/lua/lfunc.h	(revision 2122)
@@ -0,0 +1,34 @@
+/*
+** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
+** Auxiliary functions to manipulate prototypes and closures
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lfunc_h
+#define lfunc_h
+
+
+#include "lobject.h"
+
+
+#define sizeCclosure(n)	(cast(int, sizeof(CClosure)) + \
+                         cast(int, sizeof(TValue)*((n)-1)))
+
+#define sizeLclosure(n)	(cast(int, sizeof(LClosure)) + \
+                         cast(int, sizeof(TValue *)*((n)-1)))
+
+
+LUAI_FUNC Proto *luaF_newproto (lua_State *L);
+LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
+LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
+LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
+LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
+LUAI_FUNC void luaF_close (lua_State *L, StkId level);
+LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
+LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
+LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
+LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
+                                         int pc);
+
+
+#endif
Index: /code/branches/physics/src/lua/lgc.c
===================================================================
--- /code/branches/physics/src/lua/lgc.c	(revision 2122)
+++ /code/branches/physics/src/lua/lgc.c	(revision 2122)
@@ -0,0 +1,711 @@
+/*
+** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
+** Garbage Collector
+** See Copyright Notice in lua.h
+*/
+
+#include <string.h>
+
+#define lgc_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+
+
+#define GCSTEPSIZE	1024u
+#define GCSWEEPMAX	40
+#define GCSWEEPCOST	10
+#define GCFINALIZECOST	100
+
+
+#define maskmarks	cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
+
+#define makewhite(g,x)	\
+   ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))
+
+#define white2gray(x)	reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
+#define black2gray(x)	resetbit((x)->gch.marked, BLACKBIT)
+
+#define stringmark(s)	reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
+
+
+#define isfinalized(u)		testbit((u)->marked, FINALIZEDBIT)
+#define markfinalized(u)	l_setbit((u)->marked, FINALIZEDBIT)
+
+
+#define KEYWEAK         bitmask(KEYWEAKBIT)
+#define VALUEWEAK       bitmask(VALUEWEAKBIT)
+
+
+
+#define markvalue(g,o) { checkconsistency(o); \
+  if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); }
+
+#define markobject(g,t) { if (iswhite(obj2gco(t))) \
+		reallymarkobject(g, obj2gco(t)); }
+
+
+#define setthreshold(g)  (g->GCthreshold = (g->estimate/100) * g->gcpause)
+
+
+static void removeentry (Node *n) {
+  lua_assert(ttisnil(gval(n)));
+  if (iscollectable(gkey(n)))
+    setttype(gkey(n), LUA_TDEADKEY);  /* dead key; remove it */
+}
+
+
+static void reallymarkobject (global_State *g, GCObject *o) {
+  lua_assert(iswhite(o) && !isdead(g, o));
+  white2gray(o);
+  switch (o->gch.tt) {
+    case LUA_TSTRING: {
+      return;
+    }
+    case LUA_TUSERDATA: {
+      Table *mt = gco2u(o)->metatable;
+      gray2black(o);  /* udata are never gray */
+      if (mt) markobject(g, mt);
+      markobject(g, gco2u(o)->env);
+      return;
+    }
+    case LUA_TUPVAL: {
+      UpVal *uv = gco2uv(o);
+      markvalue(g, uv->v);
+      if (uv->v == &uv->u.value)  /* closed? */
+        gray2black(o);  /* open upvalues are never black */
+      return;
+    }
+    case LUA_TFUNCTION: {
+      gco2cl(o)->c.gclist = g->gray;
+      g->gray = o;
+      break;
+    }
+    case LUA_TTABLE: {
+      gco2h(o)->gclist = g->gray;
+      g->gray = o;
+      break;
+    }
+    case LUA_TTHREAD: {
+      gco2th(o)->gclist = g->gray;
+      g->gray = o;
+      break;
+    }
+    case LUA_TPROTO: {
+      gco2p(o)->gclist = g->gray;
+      g->gray = o;
+      break;
+    }
+    default: lua_assert(0);
+  }
+}
+
+
+static void marktmu (global_State *g) {
+  GCObject *u = g->tmudata;
+  if (u) {
+    do {
+      u = u->gch.next;
+      makewhite(g, u);  /* may be marked, if left from previous GC */
+      reallymarkobject(g, u);
+    } while (u != g->tmudata);
+  }
+}
+
+
+/* move `dead' udata that need finalization to list `tmudata' */
+size_t luaC_separateudata (lua_State *L, int all) {
+  global_State *g = G(L);
+  size_t deadmem = 0;
+  GCObject **p = &g->mainthread->next;
+  GCObject *curr;
+  while ((curr = *p) != NULL) {
+    if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
+      p = &curr->gch.next;  /* don't bother with them */
+    else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
+      markfinalized(gco2u(curr));  /* don't need finalization */
+      p = &curr->gch.next;
+    }
+    else {  /* must call its gc method */
+      deadmem += sizeudata(gco2u(curr));
+      markfinalized(gco2u(curr));
+      *p = curr->gch.next;
+      /* link `curr' at the end of `tmudata' list */
+      if (g->tmudata == NULL)  /* list is empty? */
+        g->tmudata = curr->gch.next = curr;  /* creates a circular list */
+      else {
+        curr->gch.next = g->tmudata->gch.next;
+        g->tmudata->gch.next = curr;
+        g->tmudata = curr;
+      }
+    }
+  }
+  return deadmem;
+}
+
+
+static int traversetable (global_State *g, Table *h) {
+  int i;
+  int weakkey = 0;
+  int weakvalue = 0;
+  const TValue *mode;
+  if (h->metatable)
+    markobject(g, h->metatable);
+  mode = gfasttm(g, h->metatable, TM_MODE);
+  if (mode && ttisstring(mode)) {  /* is there a weak mode? */
+    weakkey = (strchr(svalue(mode), 'k') != NULL);
+    weakvalue = (strchr(svalue(mode), 'v') != NULL);
+    if (weakkey || weakvalue) {  /* is really weak? */
+      h->marked &= ~(KEYWEAK | VALUEWEAK);  /* clear bits */
+      h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
+                             (weakvalue << VALUEWEAKBIT));
+      h->gclist = g->weak;  /* must be cleared after GC, ... */
+      g->weak = obj2gco(h);  /* ... so put in the appropriate list */
+    }
+  }
+  if (weakkey && weakvalue) return 1;
+  if (!weakvalue) {
+    i = h->sizearray;
+    while (i--)
+      markvalue(g, &h->array[i]);
+  }
+  i = sizenode(h);
+  while (i--) {
+    Node *n = gnode(h, i);
+    lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n)));
+    if (ttisnil(gval(n)))
+      removeentry(n);  /* remove empty entries */
+    else {
+      lua_assert(!ttisnil(gkey(n)));
+      if (!weakkey) markvalue(g, gkey(n));
+      if (!weakvalue) markvalue(g, gval(n));
+    }
+  }
+  return weakkey || weakvalue;
+}
+
+
+/*
+** All marks are conditional because a GC may happen while the
+** prototype is still being created
+*/
+static void traverseproto (global_State *g, Proto *f) {
+  int i;
+  if (f->source) stringmark(f->source);
+  for (i=0; i<f->sizek; i++)  /* mark literals */
+    markvalue(g, &f->k[i]);
+  for (i=0; i<f->sizeupvalues; i++) {  /* mark upvalue names */
+    if (f->upvalues[i])
+      stringmark(f->upvalues[i]);
+  }
+  for (i=0; i<f->sizep; i++) {  /* mark nested protos */
+    if (f->p[i])
+      markobject(g, f->p[i]);
+  }
+  for (i=0; i<f->sizelocvars; i++) {  /* mark local-variable names */
+    if (f->locvars[i].varname)
+      stringmark(f->locvars[i].varname);
+  }
+}
+
+
+
+static void traverseclosure (global_State *g, Closure *cl) {
+  markobject(g, cl->c.env);
+  if (cl->c.isC) {
+    int i;
+    for (i=0; i<cl->c.nupvalues; i++)  /* mark its upvalues */
+      markvalue(g, &cl->c.upvalue[i]);
+  }
+  else {
+    int i;
+    lua_assert(cl->l.nupvalues == cl->l.p->nups);
+    markobject(g, cl->l.p);
+    for (i=0; i<cl->l.nupvalues; i++)  /* mark its upvalues */
+      markobject(g, cl->l.upvals[i]);
+  }
+}
+
+
+static void checkstacksizes (lua_State *L, StkId max) {
+  int ci_used = cast_int(L->ci - L->base_ci);  /* number of `ci' in use */
+  int s_used = cast_int(max - L->stack);  /* part of stack in use */
+  if (L->size_ci > LUAI_MAXCALLS)  /* handling overflow? */
+    return;  /* do not touch the stacks */
+  if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
+    luaD_reallocCI(L, L->size_ci/2);  /* still big enough... */
+  condhardstacktests(luaD_reallocCI(L, ci_used + 1));
+  if (4*s_used < L->stacksize &&
+      2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
+    luaD_reallocstack(L, L->stacksize/2);  /* still big enough... */
+  condhardstacktests(luaD_reallocstack(L, s_used));
+}
+
+
+static void traversestack (global_State *g, lua_State *l) {
+  StkId o, lim;
+  CallInfo *ci;
+  markvalue(g, gt(l));
+  lim = l->top;
+  for (ci = l->base_ci; ci <= l->ci; ci++) {
+    lua_assert(ci->top <= l->stack_last);
+    if (lim < ci->top) lim = ci->top;
+  }
+  for (o = l->stack; o < l->top; o++)
+    markvalue(g, o);
+  for (; o <= lim; o++)
+    setnilvalue(o);
+  checkstacksizes(l, lim);
+}
+
+
+/*
+** traverse one gray object, turning it to black.
+** Returns `quantity' traversed.
+*/
+static l_mem propagatemark (global_State *g) {
+  GCObject *o = g->gray;
+  lua_assert(isgray(o));
+  gray2black(o);
+  switch (o->gch.tt) {
+    case LUA_TTABLE: {
+      Table *h = gco2h(o);
+      g->gray = h->gclist;
+      if (traversetable(g, h))  /* table is weak? */
+        black2gray(o);  /* keep it gray */
+      return sizeof(Table) + sizeof(TValue) * h->sizearray +
+                             sizeof(Node) * sizenode(h);
+    }
+    case LUA_TFUNCTION: {
+      Closure *cl = gco2cl(o);
+      g->gray = cl->c.gclist;
+      traverseclosure(g, cl);
+      return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
+                           sizeLclosure(cl->l.nupvalues);
+    }
+    case LUA_TTHREAD: {
+      lua_State *th = gco2th(o);
+      g->gray = th->gclist;
+      th->gclist = g->grayagain;
+      g->grayagain = o;
+      black2gray(o);
+      traversestack(g, th);
+      return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
+                                 sizeof(CallInfo) * th->size_ci;
+    }
+    case LUA_TPROTO: {
+      Proto *p = gco2p(o);
+      g->gray = p->gclist;
+      traverseproto(g, p);
+      return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
+                             sizeof(Proto *) * p->sizep +
+                             sizeof(TValue) * p->sizek + 
+                             sizeof(int) * p->sizelineinfo +
+                             sizeof(LocVar) * p->sizelocvars +
+                             sizeof(TString *) * p->sizeupvalues;
+    }
+    default: lua_assert(0); return 0;
+  }
+}
+
+
+static size_t propagateall (global_State *g) {
+  size_t m = 0;
+  while (g->gray) m += propagatemark(g);
+  return m;
+}
+
+
+/*
+** The next function tells whether a key or value can be cleared from
+** a weak table. Non-collectable objects are never removed from weak
+** tables. Strings behave as `values', so are never removed too. for
+** other objects: if really collected, cannot keep them; for userdata
+** being finalized, keep them in keys, but not in values
+*/
+static int iscleared (const TValue *o, int iskey) {
+  if (!iscollectable(o)) return 0;
+  if (ttisstring(o)) {
+    stringmark(rawtsvalue(o));  /* strings are `values', so are never weak */
+    return 0;
+  }
+  return iswhite(gcvalue(o)) ||
+    (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o))));
+}
+
+
+/*
+** clear collected entries from weaktables
+*/
+static void cleartable (GCObject *l) {
+  while (l) {
+    Table *h = gco2h(l);
+    int i = h->sizearray;
+    lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
+               testbit(h->marked, KEYWEAKBIT));
+    if (testbit(h->marked, VALUEWEAKBIT)) {
+      while (i--) {
+        TValue *o = &h->array[i];
+        if (iscleared(o, 0))  /* value was collected? */
+          setnilvalue(o);  /* remove value */
+      }
+    }
+    i = sizenode(h);
+    while (i--) {
+      Node *n = gnode(h, i);
+      if (!ttisnil(gval(n)) &&  /* non-empty entry? */
+          (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
+        setnilvalue(gval(n));  /* remove value ... */
+        removeentry(n);  /* remove entry from table */
+      }
+    }
+    l = h->gclist;
+  }
+}
+
+
+static void freeobj (lua_State *L, GCObject *o) {
+  switch (o->gch.tt) {
+    case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
+    case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
+    case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
+    case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
+    case LUA_TTHREAD: {
+      lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
+      luaE_freethread(L, gco2th(o));
+      break;
+    }
+    case LUA_TSTRING: {
+      G(L)->strt.nuse--;
+      luaM_freemem(L, o, sizestring(gco2ts(o)));
+      break;
+    }
+    case LUA_TUSERDATA: {
+      luaM_freemem(L, o, sizeudata(gco2u(o)));
+      break;
+    }
+    default: lua_assert(0);
+  }
+}
+
+
+
+#define sweepwholelist(L,p)	sweeplist(L,p,MAX_LUMEM)
+
+
+static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
+  GCObject *curr;
+  global_State *g = G(L);
+  int deadmask = otherwhite(g);
+  while ((curr = *p) != NULL && count-- > 0) {
+    if (curr->gch.tt == LUA_TTHREAD)  /* sweep open upvalues of each thread */
+      sweepwholelist(L, &gco2th(curr)->openupval);
+    if ((curr->gch.marked ^ WHITEBITS) & deadmask) {  /* not dead? */
+      lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT));
+      makewhite(g, curr);  /* make it white (for next cycle) */
+      p = &curr->gch.next;
+    }
+    else {  /* must erase `curr' */
+      lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT));
+      *p = curr->gch.next;
+      if (curr == g->rootgc)  /* is the first element of the list? */
+        g->rootgc = curr->gch.next;  /* adjust first */
+      freeobj(L, curr);
+    }
+  }
+  return p;
+}
+
+
+static void checkSizes (lua_State *L) {
+  global_State *g = G(L);
+  /* check size of string hash */
+  if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
+      g->strt.size > MINSTRTABSIZE*2)
+    luaS_resize(L, g->strt.size/2);  /* table is too big */
+  /* check size of buffer */
+  if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) {  /* buffer too big? */
+    size_t newsize = luaZ_sizebuffer(&g->buff) / 2;
+    luaZ_resizebuffer(L, &g->buff, newsize);
+  }
+}
+
+
+static void GCTM (lua_State *L) {
+  global_State *g = G(L);
+  GCObject *o = g->tmudata->gch.next;  /* get first element */
+  Udata *udata = rawgco2u(o);
+  const TValue *tm;
+  /* remove udata from `tmudata' */
+  if (o == g->tmudata)  /* last element? */
+    g->tmudata = NULL;
+  else
+    g->tmudata->gch.next = udata->uv.next;
+  udata->uv.next = g->mainthread->next;  /* return it to `root' list */
+  g->mainthread->next = o;
+  makewhite(g, o);
+  tm = fasttm(L, udata->uv.metatable, TM_GC);
+  if (tm != NULL) {
+    lu_byte oldah = L->allowhook;
+    lu_mem oldt = g->GCthreshold;
+    L->allowhook = 0;  /* stop debug hooks during GC tag method */
+    g->GCthreshold = 2*g->totalbytes;  /* avoid GC steps */
+    setobj2s(L, L->top, tm);
+    setuvalue(L, L->top+1, udata);
+    L->top += 2;
+    luaD_call(L, L->top - 2, 0);
+    L->allowhook = oldah;  /* restore hooks */
+    g->GCthreshold = oldt;  /* restore threshold */
+  }
+}
+
+
+/*
+** Call all GC tag methods
+*/
+void luaC_callGCTM (lua_State *L) {
+  while (G(L)->tmudata)
+    GCTM(L);
+}
+
+
+void luaC_freeall (lua_State *L) {
+  global_State *g = G(L);
+  int i;
+  g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT);  /* mask to collect all elements */
+  sweepwholelist(L, &g->rootgc);
+  for (i = 0; i < g->strt.size; i++)  /* free all string lists */
+    sweepwholelist(L, &g->strt.hash[i]);
+}
+
+
+static void markmt (global_State *g) {
+  int i;
+  for (i=0; i<NUM_TAGS; i++)
+    if (g->mt[i]) markobject(g, g->mt[i]);
+}
+
+
+/* mark root set */
+static void markroot (lua_State *L) {
+  global_State *g = G(L);
+  g->gray = NULL;
+  g->grayagain = NULL;
+  g->weak = NULL;
+  markobject(g, g->mainthread);
+  /* make global table be traversed before main stack */
+  markvalue(g, gt(g->mainthread));
+  markvalue(g, registry(L));
+  markmt(g);
+  g->gcstate = GCSpropagate;
+}
+
+
+static void remarkupvals (global_State *g) {
+  UpVal *uv;
+  for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
+    lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
+    if (isgray(obj2gco(uv)))
+      markvalue(g, uv->v);
+  }
+}
+
+
+static void atomic (lua_State *L) {
+  global_State *g = G(L);
+  size_t udsize;  /* total size of userdata to be finalized */
+  /* remark occasional upvalues of (maybe) dead threads */
+  remarkupvals(g);
+  /* traverse objects cautch by write barrier and by 'remarkupvals' */
+  propagateall(g);
+  /* remark weak tables */
+  g->gray = g->weak;
+  g->weak = NULL;
+  lua_assert(!iswhite(obj2gco(g->mainthread)));
+  markobject(g, L);  /* mark running thread */
+  markmt(g);  /* mark basic metatables (again) */
+  propagateall(g);
+  /* remark gray again */
+  g->gray = g->grayagain;
+  g->grayagain = NULL;
+  propagateall(g);
+  udsize = luaC_separateudata(L, 0);  /* separate userdata to be finalized */
+  marktmu(g);  /* mark `preserved' userdata */
+  udsize += propagateall(g);  /* remark, to propagate `preserveness' */
+  cleartable(g->weak);  /* remove collected objects from weak tables */
+  /* flip current white */
+  g->currentwhite = cast_byte(otherwhite(g));
+  g->sweepstrgc = 0;
+  g->sweepgc = &g->rootgc;
+  g->gcstate = GCSsweepstring;
+  g->estimate = g->totalbytes - udsize;  /* first estimate */
+}
+
+
+static l_mem singlestep (lua_State *L) {
+  global_State *g = G(L);
+  /*lua_checkmemory(L);*/
+  switch (g->gcstate) {
+    case GCSpause: {
+      markroot(L);  /* start a new collection */
+      return 0;
+    }
+    case GCSpropagate: {
+      if (g->gray)
+        return propagatemark(g);
+      else {  /* no more `gray' objects */
+        atomic(L);  /* finish mark phase */
+        return 0;
+      }
+    }
+    case GCSsweepstring: {
+      lu_mem old = g->totalbytes;
+      sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
+      if (g->sweepstrgc >= g->strt.size)  /* nothing more to sweep? */
+        g->gcstate = GCSsweep;  /* end sweep-string phase */
+      lua_assert(old >= g->totalbytes);
+      g->estimate -= old - g->totalbytes;
+      return GCSWEEPCOST;
+    }
+    case GCSsweep: {
+      lu_mem old = g->totalbytes;
+      g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
+      if (*g->sweepgc == NULL) {  /* nothing more to sweep? */
+        checkSizes(L);
+        g->gcstate = GCSfinalize;  /* end sweep phase */
+      }
+      lua_assert(old >= g->totalbytes);
+      g->estimate -= old - g->totalbytes;
+      return GCSWEEPMAX*GCSWEEPCOST;
+    }
+    case GCSfinalize: {
+      if (g->tmudata) {
+        GCTM(L);
+        if (g->estimate > GCFINALIZECOST)
+          g->estimate -= GCFINALIZECOST;
+        return GCFINALIZECOST;
+      }
+      else {
+        g->gcstate = GCSpause;  /* end collection */
+        g->gcdept = 0;
+        return 0;
+      }
+    }
+    default: lua_assert(0); return 0;
+  }
+}
+
+
+void luaC_step (lua_State *L) {
+  global_State *g = G(L);
+  l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul;
+  if (lim == 0)
+    lim = (MAX_LUMEM-1)/2;  /* no limit */
+  g->gcdept += g->totalbytes - g->GCthreshold;
+  do {
+    lim -= singlestep(L);
+    if (g->gcstate == GCSpause)
+      break;
+  } while (lim > 0);
+  if (g->gcstate != GCSpause) {
+    if (g->gcdept < GCSTEPSIZE)
+      g->GCthreshold = g->totalbytes + GCSTEPSIZE;  /* - lim/g->gcstepmul;*/
+    else {
+      g->gcdept -= GCSTEPSIZE;
+      g->GCthreshold = g->totalbytes;
+    }
+  }
+  else {
+    lua_assert(g->totalbytes >= g->estimate);
+    setthreshold(g);
+  }
+}
+
+
+void luaC_fullgc (lua_State *L) {
+  global_State *g = G(L);
+  if (g->gcstate <= GCSpropagate) {
+    /* reset sweep marks to sweep all elements (returning them to white) */
+    g->sweepstrgc = 0;
+    g->sweepgc = &g->rootgc;
+    /* reset other collector lists */
+    g->gray = NULL;
+    g->grayagain = NULL;
+    g->weak = NULL;
+    g->gcstate = GCSsweepstring;
+  }
+  lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate);
+  /* finish any pending sweep phase */
+  while (g->gcstate != GCSfinalize) {
+    lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep);
+    singlestep(L);
+  }
+  markroot(L);
+  while (g->gcstate != GCSpause) {
+    singlestep(L);
+  }
+  setthreshold(g);
+}
+
+
+void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
+  global_State *g = G(L);
+  lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
+  lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
+  lua_assert(ttype(&o->gch) != LUA_TTABLE);
+  /* must keep invariant? */
+  if (g->gcstate == GCSpropagate)
+    reallymarkobject(g, v);  /* restore invariant */
+  else  /* don't mind */
+    makewhite(g, o);  /* mark as white just to avoid other barriers */
+}
+
+
+void luaC_barrierback (lua_State *L, Table *t) {
+  global_State *g = G(L);
+  GCObject *o = obj2gco(t);
+  lua_assert(isblack(o) && !isdead(g, o));
+  lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
+  black2gray(o);  /* make table gray (again) */
+  t->gclist = g->grayagain;
+  g->grayagain = o;
+}
+
+
+void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
+  global_State *g = G(L);
+  o->gch.next = g->rootgc;
+  g->rootgc = o;
+  o->gch.marked = luaC_white(g);
+  o->gch.tt = tt;
+}
+
+
+void luaC_linkupval (lua_State *L, UpVal *uv) {
+  global_State *g = G(L);
+  GCObject *o = obj2gco(uv);
+  o->gch.next = g->rootgc;  /* link upvalue into `rootgc' list */
+  g->rootgc = o;
+  if (isgray(o)) { 
+    if (g->gcstate == GCSpropagate) {
+      gray2black(o);  /* closed upvalues need barrier */
+      luaC_barrier(L, uv, uv->v);
+    }
+    else {  /* sweep phase: sweep it (turning it into white) */
+      makewhite(g, o);
+      lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
+    }
+  }
+}
+
Index: /code/branches/physics/src/lua/lgc.h
===================================================================
--- /code/branches/physics/src/lua/lgc.h	(revision 2122)
+++ /code/branches/physics/src/lua/lgc.h	(revision 2122)
@@ -0,0 +1,110 @@
+/*
+** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
+** Garbage Collector
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lgc_h
+#define lgc_h
+
+
+#include "lobject.h"
+
+
+/*
+** Possible states of the Garbage Collector
+*/
+#define GCSpause	0
+#define GCSpropagate	1
+#define GCSsweepstring	2
+#define GCSsweep	3
+#define GCSfinalize	4
+
+
+/*
+** some userful bit tricks
+*/
+#define resetbits(x,m)	((x) &= cast(lu_byte, ~(m)))
+#define setbits(x,m)	((x) |= (m))
+#define testbits(x,m)	((x) & (m))
+#define bitmask(b)	(1<<(b))
+#define bit2mask(b1,b2)	(bitmask(b1) | bitmask(b2))
+#define l_setbit(x,b)	setbits(x, bitmask(b))
+#define resetbit(x,b)	resetbits(x, bitmask(b))
+#define testbit(x,b)	testbits(x, bitmask(b))
+#define set2bits(x,b1,b2)	setbits(x, (bit2mask(b1, b2)))
+#define reset2bits(x,b1,b2)	resetbits(x, (bit2mask(b1, b2)))
+#define test2bits(x,b1,b2)	testbits(x, (bit2mask(b1, b2)))
+
+
+
+/*
+** Layout for bit use in `marked' field:
+** bit 0 - object is white (type 0)
+** bit 1 - object is white (type 1)
+** bit 2 - object is black
+** bit 3 - for userdata: has been finalized
+** bit 3 - for tables: has weak keys
+** bit 4 - for tables: has weak values
+** bit 5 - object is fixed (should not be collected)
+** bit 6 - object is "super" fixed (only the main thread)
+*/
+
+
+#define WHITE0BIT	0
+#define WHITE1BIT	1
+#define BLACKBIT	2
+#define FINALIZEDBIT	3
+#define KEYWEAKBIT	3
+#define VALUEWEAKBIT	4
+#define FIXEDBIT	5
+#define SFIXEDBIT	6
+#define WHITEBITS	bit2mask(WHITE0BIT, WHITE1BIT)
+
+
+#define iswhite(x)      test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
+#define isblack(x)      testbit((x)->gch.marked, BLACKBIT)
+#define isgray(x)	(!isblack(x) && !iswhite(x))
+
+#define otherwhite(g)	(g->currentwhite ^ WHITEBITS)
+#define isdead(g,v)	((v)->gch.marked & otherwhite(g) & WHITEBITS)
+
+#define changewhite(x)	((x)->gch.marked ^= WHITEBITS)
+#define gray2black(x)	l_setbit((x)->gch.marked, BLACKBIT)
+
+#define valiswhite(x)	(iscollectable(x) && iswhite(gcvalue(x)))
+
+#define luaC_white(g)	cast(lu_byte, (g)->currentwhite & WHITEBITS)
+
+
+#define luaC_checkGC(L) { \
+  condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
+  if (G(L)->totalbytes >= G(L)->GCthreshold) \
+	luaC_step(L); }
+
+
+#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p)))  \
+	luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
+
+#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t)))  \
+	luaC_barrierback(L,t); }
+
+#define luaC_objbarrier(L,p,o)  \
+	{ if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
+		luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
+
+#define luaC_objbarriert(L,t,o)  \
+   { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
+
+LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
+LUAI_FUNC void luaC_callGCTM (lua_State *L);
+LUAI_FUNC void luaC_freeall (lua_State *L);
+LUAI_FUNC void luaC_step (lua_State *L);
+LUAI_FUNC void luaC_fullgc (lua_State *L);
+LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
+LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
+LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
+LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
+
+
+#endif
Index: /code/branches/physics/src/lua/linit.c
===================================================================
--- /code/branches/physics/src/lua/linit.c	(revision 2122)
+++ /code/branches/physics/src/lua/linit.c	(revision 2122)
@@ -0,0 +1,38 @@
+/*
+** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
+** Initialization of libraries for lua.c
+** See Copyright Notice in lua.h
+*/
+
+
+#define linit_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lualib.h"
+#include "lauxlib.h"
+
+
+static const luaL_Reg lualibs[] = {
+  {"", luaopen_base},
+  {LUA_LOADLIBNAME, luaopen_package},
+  {LUA_TABLIBNAME, luaopen_table},
+  {LUA_IOLIBNAME, luaopen_io},
+  {LUA_OSLIBNAME, luaopen_os},
+  {LUA_STRLIBNAME, luaopen_string},
+  {LUA_MATHLIBNAME, luaopen_math},
+  {LUA_DBLIBNAME, luaopen_debug},
+  {NULL, NULL}
+};
+
+
+LUALIB_API void luaL_openlibs (lua_State *L) {
+  const luaL_Reg *lib = lualibs;
+  for (; lib->func; lib++) {
+    lua_pushcfunction(L, lib->func);
+    lua_pushstring(L, lib->name);
+    lua_call(L, 1, 0);
+  }
+}
+
Index: /code/branches/physics/src/lua/liolib.c
===================================================================
--- /code/branches/physics/src/lua/liolib.c	(revision 2122)
+++ /code/branches/physics/src/lua/liolib.c	(revision 2122)
@@ -0,0 +1,553 @@
+/*
+** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
+** Standard I/O (and system) library
+** See Copyright Notice in lua.h
+*/
+
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define liolib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+
+#define IO_INPUT	1
+#define IO_OUTPUT	2
+
+
+static const char *const fnames[] = {"input", "output"};
+
+
+static int pushresult (lua_State *L, int i, const char *filename) {
+  int en = errno;  /* calls to Lua API may change this value */
+  if (i) {
+    lua_pushboolean(L, 1);
+    return 1;
+  }
+  else {
+    lua_pushnil(L);
+    if (filename)
+      lua_pushfstring(L, "%s: %s", filename, strerror(en));
+    else
+      lua_pushfstring(L, "%s", strerror(en));
+    lua_pushinteger(L, en);
+    return 3;
+  }
+}
+
+
+static void fileerror (lua_State *L, int arg, const char *filename) {
+  lua_pushfstring(L, "%s: %s", filename, strerror(errno));
+  luaL_argerror(L, arg, lua_tostring(L, -1));
+}
+
+
+#define tofilep(L)	((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+
+
+static int io_type (lua_State *L) {
+  void *ud;
+  luaL_checkany(L, 1);
+  ud = lua_touserdata(L, 1);
+  lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE);
+  if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1))
+    lua_pushnil(L);  /* not a file */
+  else if (*((FILE **)ud) == NULL)
+    lua_pushliteral(L, "closed file");
+  else
+    lua_pushliteral(L, "file");
+  return 1;
+}
+
+
+static FILE *tofile (lua_State *L) {
+  FILE **f = tofilep(L);
+  if (*f == NULL)
+    luaL_error(L, "attempt to use a closed file");
+  return *f;
+}
+
+
+
+/*
+** When creating file handles, always creates a `closed' file handle
+** before opening the actual file; so, if there is a memory error, the
+** file is not left opened.
+*/
+static FILE **newfile (lua_State *L) {
+  FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
+  *pf = NULL;  /* file handle is currently `closed' */
+  luaL_getmetatable(L, LUA_FILEHANDLE);
+  lua_setmetatable(L, -2);
+  return pf;
+}
+
+
+/*
+** function to (not) close the standard files stdin, stdout, and stderr
+*/
+static int io_noclose (lua_State *L) {
+  lua_pushnil(L);
+  lua_pushliteral(L, "cannot close standard file");
+  return 2;
+}
+
+
+/*
+** function to close 'popen' files
+*/
+static int io_pclose (lua_State *L) {
+  FILE **p = tofilep(L);
+  int ok = lua_pclose(L, *p);
+  *p = NULL;
+  return pushresult(L, ok, NULL);
+}
+
+
+/*
+** function to close regular files
+*/
+static int io_fclose (lua_State *L) {
+  FILE **p = tofilep(L);
+  int ok = (fclose(*p) == 0);
+  *p = NULL;
+  return pushresult(L, ok, NULL);
+}
+
+
+static int aux_close (lua_State *L) {
+  lua_getfenv(L, 1);
+  lua_getfield(L, -1, "__close");
+  return (lua_tocfunction(L, -1))(L);
+}
+
+
+static int io_close (lua_State *L) {
+  if (lua_isnone(L, 1))
+    lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT);
+  tofile(L);  /* make sure argument is a file */
+  return aux_close(L);
+}
+
+
+static int io_gc (lua_State *L) {
+  FILE *f = *tofilep(L);
+  /* ignore closed files */
+  if (f != NULL)
+    aux_close(L);
+  return 0;
+}
+
+
+static int io_tostring (lua_State *L) {
+  FILE *f = *tofilep(L);
+  if (f == NULL)
+    lua_pushliteral(L, "file (closed)");
+  else
+    lua_pushfstring(L, "file (%p)", f);
+  return 1;
+}
+
+
+static int io_open (lua_State *L) {
+  const char *filename = luaL_checkstring(L, 1);
+  const char *mode = luaL_optstring(L, 2, "r");
+  FILE **pf = newfile(L);
+  *pf = fopen(filename, mode);
+  return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
+}
+
+
+/*
+** this function has a separated environment, which defines the
+** correct __close for 'popen' files
+*/
+static int io_popen (lua_State *L) {
+  const char *filename = luaL_checkstring(L, 1);
+  const char *mode = luaL_optstring(L, 2, "r");
+  FILE **pf = newfile(L);
+  *pf = lua_popen(L, filename, mode);
+  return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
+}
+
+
+static int io_tmpfile (lua_State *L) {
+  FILE **pf = newfile(L);
+  *pf = tmpfile();
+  return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
+}
+
+
+static FILE *getiofile (lua_State *L, int findex) {
+  FILE *f;
+  lua_rawgeti(L, LUA_ENVIRONINDEX, findex);
+  f = *(FILE **)lua_touserdata(L, -1);
+  if (f == NULL)
+    luaL_error(L, "standard %s file is closed", fnames[findex - 1]);
+  return f;
+}
+
+
+static int g_iofile (lua_State *L, int f, const char *mode) {
+  if (!lua_isnoneornil(L, 1)) {
+    const char *filename = lua_tostring(L, 1);
+    if (filename) {
+      FILE **pf = newfile(L);
+      *pf = fopen(filename, mode);
+      if (*pf == NULL)
+        fileerror(L, 1, filename);
+    }
+    else {
+      tofile(L);  /* check that it's a valid file handle */
+      lua_pushvalue(L, 1);
+    }
+    lua_rawseti(L, LUA_ENVIRONINDEX, f);
+  }
+  /* return current value */
+  lua_rawgeti(L, LUA_ENVIRONINDEX, f);
+  return 1;
+}
+
+
+static int io_input (lua_State *L) {
+  return g_iofile(L, IO_INPUT, "r");
+}
+
+
+static int io_output (lua_State *L) {
+  return g_iofile(L, IO_OUTPUT, "w");
+}
+
+
+static int io_readline (lua_State *L);
+
+
+static void aux_lines (lua_State *L, int idx, int toclose) {
+  lua_pushvalue(L, idx);
+  lua_pushboolean(L, toclose);  /* close/not close file when finished */
+  lua_pushcclosure(L, io_readline, 2);
+}
+
+
+static int f_lines (lua_State *L) {
+  tofile(L);  /* check that it's a valid file handle */
+  aux_lines(L, 1, 0);
+  return 1;
+}
+
+
+static int io_lines (lua_State *L) {
+  if (lua_isnoneornil(L, 1)) {  /* no arguments? */
+    /* will iterate over default input */
+    lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT);
+    return f_lines(L);
+  }
+  else {
+    const char *filename = luaL_checkstring(L, 1);
+    FILE **pf = newfile(L);
+    *pf = fopen(filename, "r");
+    if (*pf == NULL)
+      fileerror(L, 1, filename);
+    aux_lines(L, lua_gettop(L), 1);
+    return 1;
+  }
+}
+
+
+/*
+** {======================================================
+** READ
+** =======================================================
+*/
+
+
+static int read_number (lua_State *L, FILE *f) {
+  lua_Number d;
+  if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
+    lua_pushnumber(L, d);
+    return 1;
+  }
+  else return 0;  /* read fails */
+}
+
+
+static int test_eof (lua_State *L, FILE *f) {
+  int c = getc(f);
+  ungetc(c, f);
+  lua_pushlstring(L, NULL, 0);
+  return (c != EOF);
+}
+
+
+static int read_line (lua_State *L, FILE *f) {
+  luaL_Buffer b;
+  luaL_buffinit(L, &b);
+  for (;;) {
+    size_t l;
+    char *p = luaL_prepbuffer(&b);
+    if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) {  /* eof? */
+      luaL_pushresult(&b);  /* close buffer */
+      return (lua_objlen(L, -1) > 0);  /* check whether read something */
+    }
+    l = strlen(p);
+    if (l == 0 || p[l-1] != '\n')
+      luaL_addsize(&b, l);
+    else {
+      luaL_addsize(&b, l - 1);  /* do not include `eol' */
+      luaL_pushresult(&b);  /* close buffer */
+      return 1;  /* read at least an `eol' */
+    }
+  }
+}
+
+
+static int read_chars (lua_State *L, FILE *f, size_t n) {
+  size_t rlen;  /* how much to read */
+  size_t nr;  /* number of chars actually read */
+  luaL_Buffer b;
+  luaL_buffinit(L, &b);
+  rlen = LUAL_BUFFERSIZE;  /* try to read that much each time */
+  do {
+    char *p = luaL_prepbuffer(&b);
+    if (rlen > n) rlen = n;  /* cannot read more than asked */
+    nr = fread(p, sizeof(char), rlen, f);
+    luaL_addsize(&b, nr);
+    n -= nr;  /* still have to read `n' chars */
+  } while (n > 0 && nr == rlen);  /* until end of count or eof */
+  luaL_pushresult(&b);  /* close buffer */
+  return (n == 0 || lua_objlen(L, -1) > 0);
+}
+
+
+static int g_read (lua_State *L, FILE *f, int first) {
+  int nargs = lua_gettop(L) - 1;
+  int success;
+  int n;
+  clearerr(f);
+  if (nargs == 0) {  /* no arguments? */
+    success = read_line(L, f);
+    n = first+1;  /* to return 1 result */
+  }
+  else {  /* ensure stack space for all results and for auxlib's buffer */
+    luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
+    success = 1;
+    for (n = first; nargs-- && success; n++) {
+      if (lua_type(L, n) == LUA_TNUMBER) {
+        size_t l = (size_t)lua_tointeger(L, n);
+        success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
+      }
+      else {
+        const char *p = lua_tostring(L, n);
+        luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
+        switch (p[1]) {
+          case 'n':  /* number */
+            success = read_number(L, f);
+            break;
+          case 'l':  /* line */
+            success = read_line(L, f);
+            break;
+          case 'a':  /* file */
+            read_chars(L, f, ~((size_t)0));  /* read MAX_SIZE_T chars */
+            success = 1; /* always success */
+            break;
+          default:
+            return luaL_argerror(L, n, "invalid format");
+        }
+      }
+    }
+  }
+  if (ferror(f))
+    return pushresult(L, 0, NULL);
+  if (!success) {
+    lua_pop(L, 1);  /* remove last result */
+    lua_pushnil(L);  /* push nil instead */
+  }
+  return n - first;
+}
+
+
+static int io_read (lua_State *L) {
+  return g_read(L, getiofile(L, IO_INPUT), 1);
+}
+
+
+static int f_read (lua_State *L) {
+  return g_read(L, tofile(L), 2);
+}
+
+
+static int io_readline (lua_State *L) {
+  FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
+  int sucess;
+  if (f == NULL)  /* file is already closed? */
+    luaL_error(L, "file is already closed");
+  sucess = read_line(L, f);
+  if (ferror(f))
+    return luaL_error(L, "%s", strerror(errno));
+  if (sucess) return 1;
+  else {  /* EOF */
+    if (lua_toboolean(L, lua_upvalueindex(2))) {  /* generator created file? */
+      lua_settop(L, 0);
+      lua_pushvalue(L, lua_upvalueindex(1));
+      aux_close(L);  /* close it */
+    }
+    return 0;
+  }
+}
+
+/* }====================================================== */
+
+
+static int g_write (lua_State *L, FILE *f, int arg) {
+  int nargs = lua_gettop(L) - 1;
+  int status = 1;
+  for (; nargs--; arg++) {
+    if (lua_type(L, arg) == LUA_TNUMBER) {
+      /* optimization: could be done exactly as for strings */
+      status = status &&
+          fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
+    }
+    else {
+      size_t l;
+      const char *s = luaL_checklstring(L, arg, &l);
+      status = status && (fwrite(s, sizeof(char), l, f) == l);
+    }
+  }
+  return pushresult(L, status, NULL);
+}
+
+
+static int io_write (lua_State *L) {
+  return g_write(L, getiofile(L, IO_OUTPUT), 1);
+}
+
+
+static int f_write (lua_State *L) {
+  return g_write(L, tofile(L), 2);
+}
+
+
+static int f_seek (lua_State *L) {
+  static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
+  static const char *const modenames[] = {"set", "cur", "end", NULL};
+  FILE *f = tofile(L);
+  int op = luaL_checkoption(L, 2, "cur", modenames);
+  long offset = luaL_optlong(L, 3, 0);
+  op = fseek(f, offset, mode[op]);
+  if (op)
+    return pushresult(L, 0, NULL);  /* error */
+  else {
+    lua_pushinteger(L, ftell(f));
+    return 1;
+  }
+}
+
+
+static int f_setvbuf (lua_State *L) {
+  static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
+  static const char *const modenames[] = {"no", "full", "line", NULL};
+  FILE *f = tofile(L);
+  int op = luaL_checkoption(L, 2, NULL, modenames);
+  lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
+  int res = setvbuf(f, NULL, mode[op], sz);
+  return pushresult(L, res == 0, NULL);
+}
+
+
+
+static int io_flush (lua_State *L) {
+  return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL);
+}
+
+
+static int f_flush (lua_State *L) {
+  return pushresult(L, fflush(tofile(L)) == 0, NULL);
+}
+
+
+static const luaL_Reg iolib[] = {
+  {"close", io_close},
+  {"flush", io_flush},
+  {"input", io_input},
+  {"lines", io_lines},
+  {"open", io_open},
+  {"output", io_output},
+  {"popen", io_popen},
+  {"read", io_read},
+  {"tmpfile", io_tmpfile},
+  {"type", io_type},
+  {"write", io_write},
+  {NULL, NULL}
+};
+
+
+static const luaL_Reg flib[] = {
+  {"close", io_close},
+  {"flush", f_flush},
+  {"lines", f_lines},
+  {"read", f_read},
+  {"seek", f_seek},
+  {"setvbuf", f_setvbuf},
+  {"write", f_write},
+  {"__gc", io_gc},
+  {"__tostring", io_tostring},
+  {NULL, NULL}
+};
+
+
+static void createmeta (lua_State *L) {
+  luaL_newmetatable(L, LUA_FILEHANDLE);  /* create metatable for file handles */
+  lua_pushvalue(L, -1);  /* push metatable */
+  lua_setfield(L, -2, "__index");  /* metatable.__index = metatable */
+  luaL_register(L, NULL, flib);  /* file methods */
+}
+
+
+static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) {
+  *newfile(L) = f;
+  if (k > 0) {
+    lua_pushvalue(L, -1);
+    lua_rawseti(L, LUA_ENVIRONINDEX, k);
+  }
+  lua_pushvalue(L, -2);  /* copy environment */
+  lua_setfenv(L, -2);  /* set it */
+  lua_setfield(L, -3, fname);
+}
+
+
+static void newfenv (lua_State *L, lua_CFunction cls) {
+  lua_createtable(L, 0, 1);
+  lua_pushcfunction(L, cls);
+  lua_setfield(L, -2, "__close");
+}
+
+
+LUALIB_API int luaopen_io (lua_State *L) {
+  createmeta(L);
+  /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
+  newfenv(L, io_fclose);
+  lua_replace(L, LUA_ENVIRONINDEX);
+  /* open library */
+  luaL_register(L, LUA_IOLIBNAME, iolib);
+  /* create (and set) default files */
+  newfenv(L, io_noclose);  /* close function for default files */
+  createstdfile(L, stdin, IO_INPUT, "stdin");
+  createstdfile(L, stdout, IO_OUTPUT, "stdout");
+  createstdfile(L, stderr, 0, "stderr");
+  lua_pop(L, 1);  /* pop environment for default files */
+  lua_getfield(L, -1, "popen");
+  newfenv(L, io_pclose);  /* create environment for 'popen' */
+  lua_setfenv(L, -2);  /* set fenv for 'popen' */
+  lua_pop(L, 1);  /* pop 'popen' */
+  return 1;
+}
+
Index: /code/branches/physics/src/lua/llex.c
===================================================================
--- /code/branches/physics/src/lua/llex.c	(revision 2122)
+++ /code/branches/physics/src/lua/llex.c	(revision 2122)
@@ -0,0 +1,461 @@
+/*
+** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
+** Lexical Analyzer
+** See Copyright Notice in lua.h
+*/
+
+
+#include <ctype.h>
+#include <locale.h>
+#include <string.h>
+
+#define llex_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldo.h"
+#include "llex.h"
+#include "lobject.h"
+#include "lparser.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "lzio.h"
+
+
+
+#define next(ls) (ls->current = zgetc(ls->z))
+
+
+
+
+#define currIsNewline(ls)	(ls->current == '\n' || ls->current == '\r')
+
+
+/* ORDER RESERVED */
+const char *const luaX_tokens [] = {
+    "and", "break", "do", "else", "elseif",
+    "end", "false", "for", "function", "if",
+    "in", "local", "nil", "not", "or", "repeat",
+    "return", "then", "true", "until", "while",
+    "..", "...", "==", ">=", "<=", "~=",
+    "<number>", "<name>", "<string>", "<eof>",
+    NULL
+};
+
+
+#define save_and_next(ls) (save(ls, ls->current), next(ls))
+
+
+static void save (LexState *ls, int c) {
+  Mbuffer *b = ls->buff;
+  if (b->n + 1 > b->buffsize) {
+    size_t newsize;
+    if (b->buffsize >= MAX_SIZET/2)
+      luaX_lexerror(ls, "lexical element too long", 0);
+    newsize = b->buffsize * 2;
+    luaZ_resizebuffer(ls->L, b, newsize);
+  }
+  b->buffer[b->n++] = cast(char, c);
+}
+
+
+void luaX_init (lua_State *L) {
+  int i;
+  for (i=0; i<NUM_RESERVED; i++) {
+    TString *ts = luaS_new(L, luaX_tokens[i]);
+    luaS_fix(ts);  /* reserved words are never collected */
+    lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN);
+    ts->tsv.reserved = cast_byte(i+1);  /* reserved word */
+  }
+}
+
+
+#define MAXSRC          80
+
+
+const char *luaX_token2str (LexState *ls, int token) {
+  if (token < FIRST_RESERVED) {
+    lua_assert(token == cast(unsigned char, token));
+    return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
+                              luaO_pushfstring(ls->L, "%c", token);
+  }
+  else
+    return luaX_tokens[token-FIRST_RESERVED];
+}
+
+
+static const char *txtToken (LexState *ls, int token) {
+  switch (token) {
+    case TK_NAME:
+    case TK_STRING:
+    case TK_NUMBER:
+      save(ls, '\0');
+      return luaZ_buffer(ls->buff);
+    default:
+      return luaX_token2str(ls, token);
+  }
+}
+
+
+void luaX_lexerror (LexState *ls, const char *msg, int token) {
+  char buff[MAXSRC];
+  luaO_chunkid(buff, getstr(ls->source), MAXSRC);
+  msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
+  if (token)
+    luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
+  luaD_throw(ls->L, LUA_ERRSYNTAX);
+}
+
+
+void luaX_syntaxerror (LexState *ls, const char *msg) {
+  luaX_lexerror(ls, msg, ls->t.token);
+}
+
+
+TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
+  lua_State *L = ls->L;
+  TString *ts = luaS_newlstr(L, str, l);
+  TValue *o = luaH_setstr(L, ls->fs->h, ts);  /* entry for `str' */
+  if (ttisnil(o))
+    setbvalue(o, 1);  /* make sure `str' will not be collected */
+  return ts;
+}
+
+
+static void inclinenumber (LexState *ls) {
+  int old = ls->current;
+  lua_assert(currIsNewline(ls));
+  next(ls);  /* skip `\n' or `\r' */
+  if (currIsNewline(ls) && ls->current != old)
+    next(ls);  /* skip `\n\r' or `\r\n' */
+  if (++ls->linenumber >= MAX_INT)
+    luaX_syntaxerror(ls, "chunk has too many lines");
+}
+
+
+void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
+  ls->decpoint = '.';
+  ls->L = L;
+  ls->lookahead.token = TK_EOS;  /* no look-ahead token */
+  ls->z = z;
+  ls->fs = NULL;
+  ls->linenumber = 1;
+  ls->lastline = 1;
+  ls->source = source;
+  luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER);  /* initialize buffer */
+  next(ls);  /* read first char */
+}
+
+
+
+/*
+** =======================================================
+** LEXICAL ANALYZER
+** =======================================================
+*/
+
+
+
+static int check_next (LexState *ls, const char *set) {
+  if (!strchr(set, ls->current))
+    return 0;
+  save_and_next(ls);
+  return 1;
+}
+
+
+static void buffreplace (LexState *ls, char from, char to) {
+  size_t n = luaZ_bufflen(ls->buff);
+  char *p = luaZ_buffer(ls->buff);
+  while (n--)
+    if (p[n] == from) p[n] = to;
+}
+
+
+static void trydecpoint (LexState *ls, SemInfo *seminfo) {
+  /* format error: try to update decimal point separator */
+  struct lconv *cv = localeconv();
+  char old = ls->decpoint;
+  ls->decpoint = (cv ? cv->decimal_point[0] : '.');
+  buffreplace(ls, old, ls->decpoint);  /* try updated decimal separator */
+  if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
+    /* format error with correct decimal point: no more options */
+    buffreplace(ls, ls->decpoint, '.');  /* undo change (for error message) */
+    luaX_lexerror(ls, "malformed number", TK_NUMBER);
+  }
+}
+
+
+/* LUA_NUMBER */
+static void read_numeral (LexState *ls, SemInfo *seminfo) {
+  lua_assert(isdigit(ls->current));
+  do {
+    save_and_next(ls);
+  } while (isdigit(ls->current) || ls->current == '.');
+  if (check_next(ls, "Ee"))  /* `E'? */
+    check_next(ls, "+-");  /* optional exponent sign */
+  while (isalnum(ls->current) || ls->current == '_')
+    save_and_next(ls);
+  save(ls, '\0');
+  buffreplace(ls, '.', ls->decpoint);  /* follow locale for decimal point */
+  if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r))  /* format error? */
+    trydecpoint(ls, seminfo); /* try to update decimal point separator */
+}
+
+
+static int skip_sep (LexState *ls) {
+  int count = 0;
+  int s = ls->current;
+  lua_assert(s == '[' || s == ']');
+  save_and_next(ls);
+  while (ls->current == '=') {
+    save_and_next(ls);
+    count++;
+  }
+  return (ls->current == s) ? count : (-count) - 1;
+}
+
+
+static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
+  int cont = 0;
+  (void)(cont);  /* avoid warnings when `cont' is not used */
+  save_and_next(ls);  /* skip 2nd `[' */
+  if (currIsNewline(ls))  /* string starts with a newline? */
+    inclinenumber(ls);  /* skip it */
+  for (;;) {
+    switch (ls->current) {
+      case EOZ:
+        luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
+                                   "unfinished long comment", TK_EOS);
+        break;  /* to avoid warnings */
+#if defined(LUA_COMPAT_LSTR)
+      case '[': {
+        if (skip_sep(ls) == sep) {
+          save_and_next(ls);  /* skip 2nd `[' */
+          cont++;
+#if LUA_COMPAT_LSTR == 1
+          if (sep == 0)
+            luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
+#endif
+        }
+        break;
+      }
+#endif
+      case ']': {
+        if (skip_sep(ls) == sep) {
+          save_and_next(ls);  /* skip 2nd `]' */
+#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
+          cont--;
+          if (sep == 0 && cont >= 0) break;
+#endif
+          goto endloop;
+        }
+        break;
+      }
+      case '\n':
+      case '\r': {
+        save(ls, '\n');
+        inclinenumber(ls);
+        if (!seminfo) luaZ_resetbuffer(ls->buff);  /* avoid wasting space */
+        break;
+      }
+      default: {
+        if (seminfo) save_and_next(ls);
+        else next(ls);
+      }
+    }
+  } endloop:
+  if (seminfo)
+    seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
+                                     luaZ_bufflen(ls->buff) - 2*(2 + sep));
+}
+
+
+static void read_string (LexState *ls, int del, SemInfo *seminfo) {
+  save_and_next(ls);
+  while (ls->current != del) {
+    switch (ls->current) {
+      case EOZ:
+        luaX_lexerror(ls, "unfinished string", TK_EOS);
+        continue;  /* to avoid warnings */
+      case '\n':
+      case '\r':
+        luaX_lexerror(ls, "unfinished string", TK_STRING);
+        continue;  /* to avoid warnings */
+      case '\\': {
+        int c;
+        next(ls);  /* do not save the `\' */
+        switch (ls->current) {
+          case 'a': c = '\a'; break;
+          case 'b': c = '\b'; break;
+          case 'f': c = '\f'; break;
+          case 'n': c = '\n'; break;
+          case 'r': c = '\r'; break;
+          case 't': c = '\t'; break;
+          case 'v': c = '\v'; break;
+          case '\n':  /* go through */
+          case '\r': save(ls, '\n'); inclinenumber(ls); continue;
+          case EOZ: continue;  /* will raise an error next loop */
+          default: {
+            if (!isdigit(ls->current))
+              save_and_next(ls);  /* handles \\, \", \', and \? */
+            else {  /* \xxx */
+              int i = 0;
+              c = 0;
+              do {
+                c = 10*c + (ls->current-'0');
+                next(ls);
+              } while (++i<3 && isdigit(ls->current));
+              if (c > UCHAR_MAX)
+                luaX_lexerror(ls, "escape sequence too large", TK_STRING);
+              save(ls, c);
+            }
+            continue;
+          }
+        }
+        save(ls, c);
+        next(ls);
+        continue;
+      }
+      default:
+        save_and_next(ls);
+    }
+  }
+  save_and_next(ls);  /* skip delimiter */
+  seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
+                                   luaZ_bufflen(ls->buff) - 2);
+}
+
+
+static int llex (LexState *ls, SemInfo *seminfo) {
+  luaZ_resetbuffer(ls->buff);
+  for (;;) {
+    switch (ls->current) {
+      case '\n':
+      case '\r': {
+        inclinenumber(ls);
+        continue;
+      }
+      case '-': {
+        next(ls);
+        if (ls->current != '-') return '-';
+        /* else is a comment */
+        next(ls);
+        if (ls->current == '[') {
+          int sep = skip_sep(ls);
+          luaZ_resetbuffer(ls->buff);  /* `skip_sep' may dirty the buffer */
+          if (sep >= 0) {
+            read_long_string(ls, NULL, sep);  /* long comment */
+            luaZ_resetbuffer(ls->buff);
+            continue;
+          }
+        }
+        /* else short comment */
+        while (!currIsNewline(ls) && ls->current != EOZ)
+          next(ls);
+        continue;
+      }
+      case '[': {
+        int sep = skip_sep(ls);
+        if (sep >= 0) {
+          read_long_string(ls, seminfo, sep);
+          return TK_STRING;
+        }
+        else if (sep == -1) return '[';
+        else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
+      }
+      case '=': {
+        next(ls);
+        if (ls->current != '=') return '=';
+        else { next(ls); return TK_EQ; }
+      }
+      case '<': {
+        next(ls);
+        if (ls->current != '=') return '<';
+        else { next(ls); return TK_LE; }
+      }
+      case '>': {
+        next(ls);
+        if (ls->current != '=') return '>';
+        else { next(ls); return TK_GE; }
+      }
+      case '~': {
+        next(ls);
+        if (ls->current != '=') return '~';
+        else { next(ls); return TK_NE; }
+      }
+      case '"':
+      case '\'': {
+        read_string(ls, ls->current, seminfo);
+        return TK_STRING;
+      }
+      case '.': {
+        save_and_next(ls);
+        if (check_next(ls, ".")) {
+          if (check_next(ls, "."))
+            return TK_DOTS;   /* ... */
+          else return TK_CONCAT;   /* .. */
+        }
+        else if (!isdigit(ls->current)) return '.';
+        else {
+          read_numeral(ls, seminfo);
+          return TK_NUMBER;
+        }
+      }
+      case EOZ: {
+        return TK_EOS;
+      }
+      default: {
+        if (isspace(ls->current)) {
+          lua_assert(!currIsNewline(ls));
+          next(ls);
+          continue;
+        }
+        else if (isdigit(ls->current)) {
+          read_numeral(ls, seminfo);
+          return TK_NUMBER;
+        }
+        else if (isalpha(ls->current) || ls->current == '_') {
+          /* identifier or reserved word */
+          TString *ts;
+          do {
+            save_and_next(ls);
+          } while (isalnum(ls->current) || ls->current == '_');
+          ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
+                                  luaZ_bufflen(ls->buff));
+          if (ts->tsv.reserved > 0)  /* reserved word? */
+            return ts->tsv.reserved - 1 + FIRST_RESERVED;
+          else {
+            seminfo->ts = ts;
+            return TK_NAME;
+          }
+        }
+        else {
+          int c = ls->current;
+          next(ls);
+          return c;  /* single-char tokens (+ - / ...) */
+        }
+      }
+    }
+  }
+}
+
+
+void luaX_next (LexState *ls) {
+  ls->lastline = ls->linenumber;
+  if (ls->lookahead.token != TK_EOS) {  /* is there a look-ahead token? */
+    ls->t = ls->lookahead;  /* use this one */
+    ls->lookahead.token = TK_EOS;  /* and discharge it */
+  }
+  else
+    ls->t.token = llex(ls, &ls->t.seminfo);  /* read next token */
+}
+
+
+void luaX_lookahead (LexState *ls) {
+  lua_assert(ls->lookahead.token == TK_EOS);
+  ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
+}
+
Index: /code/branches/physics/src/lua/llex.h
===================================================================
--- /code/branches/physics/src/lua/llex.h	(revision 2122)
+++ /code/branches/physics/src/lua/llex.h	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
+** Lexical Analyzer
+** See Copyright Notice in lua.h
+*/
+
+#ifndef llex_h
+#define llex_h
+
+#include "lobject.h"
+#include "lzio.h"
+
+
+#define FIRST_RESERVED	257
+
+/* maximum length of a reserved word */
+#define TOKEN_LEN	(sizeof("function")/sizeof(char))
+
+
+/*
+* WARNING: if you change the order of this enumeration,
+* grep "ORDER RESERVED"
+*/
+enum RESERVED {
+  /* terminal symbols denoted by reserved words */
+  TK_AND = FIRST_RESERVED, TK_BREAK,
+  TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
+  TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
+  TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
+  /* other terminal symbols */
+  TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
+  TK_NAME, TK_STRING, TK_EOS
+};
+
+/* number of reserved words */
+#define NUM_RESERVED	(cast(int, TK_WHILE-FIRST_RESERVED+1))
+
+
+/* array with token `names' */
+LUAI_DATA const char *const luaX_tokens [];
+
+
+typedef union {
+  lua_Number r;
+  TString *ts;
+} SemInfo;  /* semantics information */
+
+
+typedef struct Token {
+  int token;
+  SemInfo seminfo;
+} Token;
+
+
+typedef struct LexState {
+  int current;  /* current character (charint) */
+  int linenumber;  /* input line counter */
+  int lastline;  /* line of last token `consumed' */
+  Token t;  /* current token */
+  Token lookahead;  /* look ahead token */
+  struct FuncState *fs;  /* `FuncState' is private to the parser */
+  struct lua_State *L;
+  ZIO *z;  /* input stream */
+  Mbuffer *buff;  /* buffer for tokens */
+  TString *source;  /* current source name */
+  char decpoint;  /* locale decimal point */
+} LexState;
+
+
+LUAI_FUNC void luaX_init (lua_State *L);
+LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
+                              TString *source);
+LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
+LUAI_FUNC void luaX_next (LexState *ls);
+LUAI_FUNC void luaX_lookahead (LexState *ls);
+LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
+LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
+LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
+
+
+#endif
Index: /code/branches/physics/src/lua/llimits.h
===================================================================
--- /code/branches/physics/src/lua/llimits.h	(revision 2122)
+++ /code/branches/physics/src/lua/llimits.h	(revision 2122)
@@ -0,0 +1,128 @@
+/*
+** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
+** Limits, basic types, and some other `installation-dependent' definitions
+** See Copyright Notice in lua.h
+*/
+
+#ifndef llimits_h
+#define llimits_h
+
+
+#include <limits.h>
+#include <stddef.h>
+
+
+#include "lua.h"
+
+
+typedef LUAI_UINT32 lu_int32;
+
+typedef LUAI_UMEM lu_mem;
+
+typedef LUAI_MEM l_mem;
+
+
+
+/* chars used as small naturals (so that `char' is reserved for characters) */
+typedef unsigned char lu_byte;
+
+
+#define MAX_SIZET	((size_t)(~(size_t)0)-2)
+
+#define MAX_LUMEM	((lu_mem)(~(lu_mem)0)-2)
+
+
+#define MAX_INT (INT_MAX-2)  /* maximum value of an int (-2 for safety) */
+
+/*
+** conversion of pointer to integer
+** this is for hashing only; there is no problem if the integer
+** cannot hold the whole pointer value
+*/
+#define IntPoint(p)  ((unsigned int)(lu_mem)(p))
+
+
+
+/* type to ensure maximum alignment */
+typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
+
+
+/* result of a `usual argument conversion' over lua_Number */
+typedef LUAI_UACNUMBER l_uacNumber;
+
+
+/* internal assertions for in-house debugging */
+#ifdef lua_assert
+
+#define check_exp(c,e)		(lua_assert(c), (e))
+#define api_check(l,e)		lua_assert(e)
+
+#else
+
+#define lua_assert(c)		((void)0)
+#define check_exp(c,e)		(e)
+#define api_check		luai_apicheck
+
+#endif
+
+
+#ifndef UNUSED
+#define UNUSED(x)	((void)(x))	/* to avoid warnings */
+#endif
+
+
+#ifndef cast
+#define cast(t, exp)	((t)(exp))
+#endif
+
+#define cast_byte(i)	cast(lu_byte, (i))
+#define cast_num(i)	cast(lua_Number, (i))
+#define cast_int(i)	cast(int, (i))
+
+
+
+/*
+** type for virtual-machine instructions
+** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
+*/
+typedef lu_int32 Instruction;
+
+
+
+/* maximum stack for a Lua function */
+#define MAXSTACK	250
+
+
+
+/* minimum size for the string table (must be power of 2) */
+#ifndef MINSTRTABSIZE
+#define MINSTRTABSIZE	32
+#endif
+
+
+/* minimum size for string buffer */
+#ifndef LUA_MINBUFFER
+#define LUA_MINBUFFER	32
+#endif
+
+
+#ifndef lua_lock
+#define lua_lock(L)     ((void) 0) 
+#define lua_unlock(L)   ((void) 0)
+#endif
+
+#ifndef luai_threadyield
+#define luai_threadyield(L)     {lua_unlock(L); lua_lock(L);}
+#endif
+
+
+/*
+** macro to control inclusion of some hard tests on stack reallocation
+*/ 
+#ifndef HARDSTACKTESTS
+#define condhardstacktests(x)	((void)0)
+#else
+#define condhardstacktests(x)	x
+#endif
+
+#endif
Index: /code/branches/physics/src/lua/lmathlib.c
===================================================================
--- /code/branches/physics/src/lua/lmathlib.c	(revision 2122)
+++ /code/branches/physics/src/lua/lmathlib.c	(revision 2122)
@@ -0,0 +1,263 @@
+/*
+** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $
+** Standard mathematical library
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stdlib.h>
+#include <math.h>
+
+#define lmathlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+#undef PI
+#define PI (3.14159265358979323846)
+#define RADIANS_PER_DEGREE (PI/180.0)
+
+
+
+static int math_abs (lua_State *L) {
+  lua_pushnumber(L, fabs(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_sin (lua_State *L) {
+  lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_sinh (lua_State *L) {
+  lua_pushnumber(L, sinh(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_cos (lua_State *L) {
+  lua_pushnumber(L, cos(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_cosh (lua_State *L) {
+  lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_tan (lua_State *L) {
+  lua_pushnumber(L, tan(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_tanh (lua_State *L) {
+  lua_pushnumber(L, tanh(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_asin (lua_State *L) {
+  lua_pushnumber(L, asin(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_acos (lua_State *L) {
+  lua_pushnumber(L, acos(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_atan (lua_State *L) {
+  lua_pushnumber(L, atan(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_atan2 (lua_State *L) {
+  lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+  return 1;
+}
+
+static int math_ceil (lua_State *L) {
+  lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_floor (lua_State *L) {
+  lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_fmod (lua_State *L) {
+  lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+  return 1;
+}
+
+static int math_modf (lua_State *L) {
+  double ip;
+  double fp = modf(luaL_checknumber(L, 1), &ip);
+  lua_pushnumber(L, ip);
+  lua_pushnumber(L, fp);
+  return 2;
+}
+
+static int math_sqrt (lua_State *L) {
+  lua_pushnumber(L, sqrt(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_pow (lua_State *L) {
+  lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+  return 1;
+}
+
+static int math_log (lua_State *L) {
+  lua_pushnumber(L, log(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_log10 (lua_State *L) {
+  lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_exp (lua_State *L) {
+  lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
+  return 1;
+}
+
+static int math_deg (lua_State *L) {
+  lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE);
+  return 1;
+}
+
+static int math_rad (lua_State *L) {
+  lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE);
+  return 1;
+}
+
+static int math_frexp (lua_State *L) {
+  int e;
+  lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
+  lua_pushinteger(L, e);
+  return 2;
+}
+
+static int math_ldexp (lua_State *L) {
+  lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
+  return 1;
+}
+
+
+
+static int math_min (lua_State *L) {
+  int n = lua_gettop(L);  /* number of arguments */
+  lua_Number dmin = luaL_checknumber(L, 1);
+  int i;
+  for (i=2; i<=n; i++) {
+    lua_Number d = luaL_checknumber(L, i);
+    if (d < dmin)
+      dmin = d;
+  }
+  lua_pushnumber(L, dmin);
+  return 1;
+}
+
+
+static int math_max (lua_State *L) {
+  int n = lua_gettop(L);  /* number of arguments */
+  lua_Number dmax = luaL_checknumber(L, 1);
+  int i;
+  for (i=2; i<=n; i++) {
+    lua_Number d = luaL_checknumber(L, i);
+    if (d > dmax)
+      dmax = d;
+  }
+  lua_pushnumber(L, dmax);
+  return 1;
+}
+
+
+static int math_random (lua_State *L) {
+  /* the `%' avoids the (rare) case of r==1, and is needed also because on
+     some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
+  lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
+  switch (lua_gettop(L)) {  /* check number of arguments */
+    case 0: {  /* no arguments */
+      lua_pushnumber(L, r);  /* Number between 0 and 1 */
+      break;
+    }
+    case 1: {  /* only upper limit */
+      int u = luaL_checkint(L, 1);
+      luaL_argcheck(L, 1<=u, 1, "interval is empty");
+      lua_pushnumber(L, floor(r*u)+1);  /* int between 1 and `u' */
+      break;
+    }
+    case 2: {  /* lower and upper limits */
+      int l = luaL_checkint(L, 1);
+      int u = luaL_checkint(L, 2);
+      luaL_argcheck(L, l<=u, 2, "interval is empty");
+      lua_pushnumber(L, floor(r*(u-l+1))+l);  /* int between `l' and `u' */
+      break;
+    }
+    default: return luaL_error(L, "wrong number of arguments");
+  }
+  return 1;
+}
+
+
+static int math_randomseed (lua_State *L) {
+  srand(luaL_checkint(L, 1));
+  return 0;
+}
+
+
+static const luaL_Reg mathlib[] = {
+  {"abs",   math_abs},
+  {"acos",  math_acos},
+  {"asin",  math_asin},
+  {"atan2", math_atan2},
+  {"atan",  math_atan},
+  {"ceil",  math_ceil},
+  {"cosh",   math_cosh},
+  {"cos",   math_cos},
+  {"deg",   math_deg},
+  {"exp",   math_exp},
+  {"floor", math_floor},
+  {"fmod",   math_fmod},
+  {"frexp", math_frexp},
+  {"ldexp", math_ldexp},
+  {"log10", math_log10},
+  {"log",   math_log},
+  {"max",   math_max},
+  {"min",   math_min},
+  {"modf",   math_modf},
+  {"pow",   math_pow},
+  {"rad",   math_rad},
+  {"random",     math_random},
+  {"randomseed", math_randomseed},
+  {"sinh",   math_sinh},
+  {"sin",   math_sin},
+  {"sqrt",  math_sqrt},
+  {"tanh",   math_tanh},
+  {"tan",   math_tan},
+  {NULL, NULL}
+};
+
+
+/*
+** Open math library
+*/
+LUALIB_API int luaopen_math (lua_State *L) {
+  luaL_register(L, LUA_MATHLIBNAME, mathlib);
+  lua_pushnumber(L, PI);
+  lua_setfield(L, -2, "pi");
+  lua_pushnumber(L, HUGE_VAL);
+  lua_setfield(L, -2, "huge");
+#if defined(LUA_COMPAT_MOD)
+  lua_getfield(L, -1, "fmod");
+  lua_setfield(L, -2, "mod");
+#endif
+  return 1;
+}
+
Index: /code/branches/physics/src/lua/lmem.c
===================================================================
--- /code/branches/physics/src/lua/lmem.c	(revision 2122)
+++ /code/branches/physics/src/lua/lmem.c	(revision 2122)
@@ -0,0 +1,86 @@
+/*
+** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
+** Interface to Memory Manager
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stddef.h>
+
+#define lmem_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+
+
+
+/*
+** About the realloc function:
+** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
+** (`osize' is the old size, `nsize' is the new size)
+**
+** Lua ensures that (ptr == NULL) iff (osize == 0).
+**
+** * frealloc(ud, NULL, 0, x) creates a new block of size `x'
+**
+** * frealloc(ud, p, x, 0) frees the block `p'
+** (in this specific case, frealloc must return NULL).
+** particularly, frealloc(ud, NULL, 0, 0) does nothing
+** (which is equivalent to free(NULL) in ANSI C)
+**
+** frealloc returns NULL if it cannot create or reallocate the area
+** (any reallocation to an equal or smaller size cannot fail!)
+*/
+
+
+
+#define MINSIZEARRAY	4
+
+
+void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
+                     int limit, const char *errormsg) {
+  void *newblock;
+  int newsize;
+  if (*size >= limit/2) {  /* cannot double it? */
+    if (*size >= limit)  /* cannot grow even a little? */
+      luaG_runerror(L, errormsg);
+    newsize = limit;  /* still have at least one free place */
+  }
+  else {
+    newsize = (*size)*2;
+    if (newsize < MINSIZEARRAY)
+      newsize = MINSIZEARRAY;  /* minimum size */
+  }
+  newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
+  *size = newsize;  /* update only when everything else is OK */
+  return newblock;
+}
+
+
+void *luaM_toobig (lua_State *L) {
+  luaG_runerror(L, "memory allocation error: block too big");
+  return NULL;  /* to avoid warnings */
+}
+
+
+
+/*
+** generic allocation routine.
+*/
+void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
+  global_State *g = G(L);
+  lua_assert((osize == 0) == (block == NULL));
+  block = (*g->frealloc)(g->ud, block, osize, nsize);
+  if (block == NULL && nsize > 0)
+    luaD_throw(L, LUA_ERRMEM);
+  lua_assert((nsize == 0) == (block == NULL));
+  g->totalbytes = (g->totalbytes - osize) + nsize;
+  return block;
+}
+
Index: /code/branches/physics/src/lua/lmem.h
===================================================================
--- /code/branches/physics/src/lua/lmem.h	(revision 2122)
+++ /code/branches/physics/src/lua/lmem.h	(revision 2122)
@@ -0,0 +1,49 @@
+/*
+** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
+** Interface to Memory Manager
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lmem_h
+#define lmem_h
+
+
+#include <stddef.h>
+
+#include "llimits.h"
+#include "lua.h"
+
+#define MEMERRMSG	"not enough memory"
+
+
+#define luaM_reallocv(L,b,on,n,e) \
+	((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ?  /* +1 to avoid warnings */ \
+		luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
+		luaM_toobig(L))
+
+#define luaM_freemem(L, b, s)	luaM_realloc_(L, (b), (s), 0)
+#define luaM_free(L, b)		luaM_realloc_(L, (b), sizeof(*(b)), 0)
+#define luaM_freearray(L, b, n, t)   luaM_reallocv(L, (b), n, 0, sizeof(t))
+
+#define luaM_malloc(L,t)	luaM_realloc_(L, NULL, 0, (t))
+#define luaM_new(L,t)		cast(t *, luaM_malloc(L, sizeof(t)))
+#define luaM_newvector(L,n,t) \
+		cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
+
+#define luaM_growvector(L,v,nelems,size,t,limit,e) \
+          if ((nelems)+1 > (size)) \
+            ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
+
+#define luaM_reallocvector(L, v,oldn,n,t) \
+   ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
+
+
+LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
+                                                          size_t size);
+LUAI_FUNC void *luaM_toobig (lua_State *L);
+LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
+                               size_t size_elem, int limit,
+                               const char *errormsg);
+
+#endif
+
Index: /code/branches/physics/src/lua/loadlib.c
===================================================================
--- /code/branches/physics/src/lua/loadlib.c	(revision 2122)
+++ /code/branches/physics/src/lua/loadlib.c	(revision 2122)
@@ -0,0 +1,664 @@
+/*
+** $Id: loadlib.c,v 1.52.1.2 2007/12/28 14:58:43 roberto Exp $
+** Dynamic library loader for Lua
+** See Copyright Notice in lua.h
+**
+** This module contains an implementation of loadlib for Unix systems
+** that have dlfcn, an implementation for Darwin (Mac OS X), an
+** implementation for Windows, and a stub for other systems.
+*/
+
+
+#include <stdlib.h>
+#include <string.h>
+
+
+#define loadlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/* prefix for open functions in C libraries */
+#define LUA_POF		"luaopen_"
+
+/* separator for open functions in C libraries */
+#define LUA_OFSEP	"_"
+
+
+#define LIBPREFIX	"LOADLIB: "
+
+#define POF		LUA_POF
+#define LIB_FAIL	"open"
+
+
+/* error codes for ll_loadfunc */
+#define ERRLIB		1
+#define ERRFUNC		2
+
+#define setprogdir(L)		((void)0)
+
+
+static void ll_unloadlib (void *lib);
+static void *ll_load (lua_State *L, const char *path);
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym);
+
+
+
+#if defined(LUA_DL_DLOPEN)
+/*
+** {========================================================================
+** This is an implementation of loadlib based on the dlfcn interface.
+** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD,
+** NetBSD, AIX 4.2, HPUX 11, and  probably most other Unix flavors, at least
+** as an emulation layer on top of native functions.
+** =========================================================================
+*/
+
+#include <dlfcn.h>
+
+static void ll_unloadlib (void *lib) {
+  dlclose(lib);
+}
+
+
+static void *ll_load (lua_State *L, const char *path) {
+  void *lib = dlopen(path, RTLD_NOW);
+  if (lib == NULL) lua_pushstring(L, dlerror());
+  return lib;
+}
+
+
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
+  lua_CFunction f = (lua_CFunction)dlsym(lib, sym);
+  if (f == NULL) lua_pushstring(L, dlerror());
+  return f;
+}
+
+/* }====================================================== */
+
+
+
+#elif defined(LUA_DL_DLL)
+/*
+** {======================================================================
+** This is an implementation of loadlib for Windows using native functions.
+** =======================================================================
+*/
+
+#include <windows.h>
+
+
+#undef setprogdir
+
+static void setprogdir (lua_State *L) {
+  char buff[MAX_PATH + 1];
+  char *lb;
+  DWORD nsize = sizeof(buff)/sizeof(char);
+  DWORD n = GetModuleFileNameA(NULL, buff, nsize);
+  if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
+    luaL_error(L, "unable to get ModuleFileName");
+  else {
+    *lb = '\0';
+    luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff);
+    lua_remove(L, -2);  /* remove original string */
+  }
+}
+
+
+static void pusherror (lua_State *L) {
+  int error = GetLastError();
+  char buffer[128];
+  if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
+      NULL, error, 0, buffer, sizeof(buffer), NULL))
+    lua_pushstring(L, buffer);
+  else
+    lua_pushfstring(L, "system error %d\n", error);
+}
+
+static void ll_unloadlib (void *lib) {
+  FreeLibrary((HINSTANCE)lib);
+}
+
+
+static void *ll_load (lua_State *L, const char *path) {
+  HINSTANCE lib = LoadLibraryA(path);
+  if (lib == NULL) pusherror(L);
+  return lib;
+}
+
+
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
+  lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym);
+  if (f == NULL) pusherror(L);
+  return f;
+}
+
+/* }====================================================== */
+
+
+
+#elif defined(LUA_DL_DYLD)
+/*
+** {======================================================================
+** Native Mac OS X / Darwin Implementation
+** =======================================================================
+*/
+
+#include <mach-o/dyld.h>
+
+
+/* Mac appends a `_' before C function names */
+#undef POF
+#define POF	"_" LUA_POF
+
+
+static void pusherror (lua_State *L) {
+  const char *err_str;
+  const char *err_file;
+  NSLinkEditErrors err;
+  int err_num;
+  NSLinkEditError(&err, &err_num, &err_file, &err_str);
+  lua_pushstring(L, err_str);
+}
+
+
+static const char *errorfromcode (NSObjectFileImageReturnCode ret) {
+  switch (ret) {
+    case NSObjectFileImageInappropriateFile:
+      return "file is not a bundle";
+    case NSObjectFileImageArch:
+      return "library is for wrong CPU type";
+    case NSObjectFileImageFormat:
+      return "bad format";
+    case NSObjectFileImageAccess:
+      return "cannot access file";
+    case NSObjectFileImageFailure:
+    default:
+      return "unable to load library";
+  }
+}
+
+
+static void ll_unloadlib (void *lib) {
+  NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES);
+}
+
+
+static void *ll_load (lua_State *L, const char *path) {
+  NSObjectFileImage img;
+  NSObjectFileImageReturnCode ret;
+  /* this would be a rare case, but prevents crashing if it happens */
+  if(!_dyld_present()) {
+    lua_pushliteral(L, "dyld not present");
+    return NULL;
+  }
+  ret = NSCreateObjectFileImageFromFile(path, &img);
+  if (ret == NSObjectFileImageSuccess) {
+    NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE |
+                       NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+    NSDestroyObjectFileImage(img);
+    if (mod == NULL) pusherror(L);
+    return mod;
+  }
+  lua_pushstring(L, errorfromcode(ret));
+  return NULL;
+}
+
+
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
+  NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym);
+  if (nss == NULL) {
+    lua_pushfstring(L, "symbol " LUA_QS " not found", sym);
+    return NULL;
+  }
+  return (lua_CFunction)NSAddressOfSymbol(nss);
+}
+
+/* }====================================================== */
+
+
+
+#else
+/*
+** {======================================================
+** Fallback for other systems
+** =======================================================
+*/
+
+#undef LIB_FAIL
+#define LIB_FAIL	"absent"
+
+
+#define DLMSG	"dynamic libraries not enabled; check your Lua installation"
+
+
+static void ll_unloadlib (void *lib) {
+  (void)lib;  /* to avoid warnings */
+}
+
+
+static void *ll_load (lua_State *L, const char *path) {
+  (void)path;  /* to avoid warnings */
+  lua_pushliteral(L, DLMSG);
+  return NULL;
+}
+
+
+static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
+  (void)lib; (void)sym;  /* to avoid warnings */
+  lua_pushliteral(L, DLMSG);
+  return NULL;
+}
+
+/* }====================================================== */
+#endif
+
+
+
+static void **ll_register (lua_State *L, const char *path) {
+  void **plib;
+  lua_pushfstring(L, "%s%s", LIBPREFIX, path);
+  lua_gettable(L, LUA_REGISTRYINDEX);  /* check library in registry? */
+  if (!lua_isnil(L, -1))  /* is there an entry? */
+    plib = (void **)lua_touserdata(L, -1);
+  else {  /* no entry yet; create one */
+    lua_pop(L, 1);
+    plib = (void **)lua_newuserdata(L, sizeof(const void *));
+    *plib = NULL;
+    luaL_getmetatable(L, "_LOADLIB");
+    lua_setmetatable(L, -2);
+    lua_pushfstring(L, "%s%s", LIBPREFIX, path);
+    lua_pushvalue(L, -2);
+    lua_settable(L, LUA_REGISTRYINDEX);
+  }
+  return plib;
+}
+
+
+/*
+** __gc tag method: calls library's `ll_unloadlib' function with the lib
+** handle
+*/
+static int gctm (lua_State *L) {
+  void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB");
+  if (*lib) ll_unloadlib(*lib);
+  *lib = NULL;  /* mark library as closed */
+  return 0;
+}
+
+
+static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
+  void **reg = ll_register(L, path);
+  if (*reg == NULL) *reg = ll_load(L, path);
+  if (*reg == NULL)
+    return ERRLIB;  /* unable to load library */
+  else {
+    lua_CFunction f = ll_sym(L, *reg, sym);
+    if (f == NULL)
+      return ERRFUNC;  /* unable to find function */
+    lua_pushcfunction(L, f);
+    return 0;  /* return function */
+  }
+}
+
+
+static int ll_loadlib (lua_State *L) {
+  const char *path = luaL_checkstring(L, 1);
+  const char *init = luaL_checkstring(L, 2);
+  int stat = ll_loadfunc(L, path, init);
+  if (stat == 0)  /* no errors? */
+    return 1;  /* return the loaded function */
+  else {  /* error; error message is on stack top */
+    lua_pushnil(L);
+    lua_insert(L, -2);
+    lua_pushstring(L, (stat == ERRLIB) ?  LIB_FAIL : "init");
+    return 3;  /* return nil, error message, and where */
+  }
+}
+
+
+
+/*
+** {======================================================
+** 'require' function
+** =======================================================
+*/
+
+
+static int readable (const char *filename) {
+  FILE *f = fopen(filename, "r");  /* try to open file */
+  if (f == NULL) return 0;  /* open failed */
+  fclose(f);
+  return 1;
+}
+
+
+static const char *pushnexttemplate (lua_State *L, const char *path) {
+  const char *l;
+  while (*path == *LUA_PATHSEP) path++;  /* skip separators */
+  if (*path == '\0') return NULL;  /* no more templates */
+  l = strchr(path, *LUA_PATHSEP);  /* find next separator */
+  if (l == NULL) l = path + strlen(path);
+  lua_pushlstring(L, path, l - path);  /* template */
+  return l;
+}
+
+
+static const char *findfile (lua_State *L, const char *name,
+                                           const char *pname) {
+  const char *path;
+  name = luaL_gsub(L, name, ".", LUA_DIRSEP);
+  lua_getfield(L, LUA_ENVIRONINDEX, pname);
+  path = lua_tostring(L, -1);
+  if (path == NULL)
+    luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
+  lua_pushliteral(L, "");  /* error accumulator */
+  while ((path = pushnexttemplate(L, path)) != NULL) {
+    const char *filename;
+    filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
+    lua_remove(L, -2);  /* remove path template */
+    if (readable(filename))  /* does file exist and is readable? */
+      return filename;  /* return that file name */
+    lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
+    lua_remove(L, -2);  /* remove file name */
+    lua_concat(L, 2);  /* add entry to possible error message */
+  }
+  return NULL;  /* not found */
+}
+
+
+static void loaderror (lua_State *L, const char *filename) {
+  luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s",
+                lua_tostring(L, 1), filename, lua_tostring(L, -1));
+}
+
+
+static int loader_Lua (lua_State *L) {
+  const char *filename;
+  const char *name = luaL_checkstring(L, 1);
+  filename = findfile(L, name, "path");
+  if (filename == NULL) return 1;  /* library not found in this path */
+  if (luaL_loadfile(L, filename) != 0)
+    loaderror(L, filename);
+  return 1;  /* library loaded successfully */
+}
+
+
+static const char *mkfuncname (lua_State *L, const char *modname) {
+  const char *funcname;
+  const char *mark = strchr(modname, *LUA_IGMARK);
+  if (mark) modname = mark + 1;
+  funcname = luaL_gsub(L, modname, ".", LUA_OFSEP);
+  funcname = lua_pushfstring(L, POF"%s", funcname);
+  lua_remove(L, -2);  /* remove 'gsub' result */
+  return funcname;
+}
+
+
+static int loader_C (lua_State *L) {
+  const char *funcname;
+  const char *name = luaL_checkstring(L, 1);
+  const char *filename = findfile(L, name, "cpath");
+  if (filename == NULL) return 1;  /* library not found in this path */
+  funcname = mkfuncname(L, name);
+  if (ll_loadfunc(L, filename, funcname) != 0)
+    loaderror(L, filename);
+  return 1;  /* library loaded successfully */
+}
+
+
+static int loader_Croot (lua_State *L) {
+  const char *funcname;
+  const char *filename;
+  const char *name = luaL_checkstring(L, 1);
+  const char *p = strchr(name, '.');
+  int stat;
+  if (p == NULL) return 0;  /* is root */
+  lua_pushlstring(L, name, p - name);
+  filename = findfile(L, lua_tostring(L, -1), "cpath");
+  if (filename == NULL) return 1;  /* root not found */
+  funcname = mkfuncname(L, name);
+  if ((stat = ll_loadfunc(L, filename, funcname)) != 0) {
+    if (stat != ERRFUNC) loaderror(L, filename);  /* real error */
+    lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
+                       name, filename);
+    return 1;  /* function not found */
+  }
+  return 1;
+}
+
+
+static int loader_preload (lua_State *L) {
+  const char *name = luaL_checkstring(L, 1);
+  lua_getfield(L, LUA_ENVIRONINDEX, "preload");
+  if (!lua_istable(L, -1))
+    luaL_error(L, LUA_QL("package.preload") " must be a table");
+  lua_getfield(L, -1, name);
+  if (lua_isnil(L, -1))  /* not found? */
+    lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
+  return 1;
+}
+
+
+static const int sentinel_ = 0;
+#define sentinel	((void *)&sentinel_)
+
+
+static int ll_require (lua_State *L) {
+  const char *name = luaL_checkstring(L, 1);
+  int i;
+  lua_settop(L, 1);  /* _LOADED table will be at index 2 */
+  lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
+  lua_getfield(L, 2, name);
+  if (lua_toboolean(L, -1)) {  /* is it there? */
+    if (lua_touserdata(L, -1) == sentinel)  /* check loops */
+      luaL_error(L, "loop or previous error loading module " LUA_QS, name);
+    return 1;  /* package is already loaded */
+  }
+  /* else must load it; iterate over available loaders */
+  lua_getfield(L, LUA_ENVIRONINDEX, "loaders");
+  if (!lua_istable(L, -1))
+    luaL_error(L, LUA_QL("package.loaders") " must be a table");
+  lua_pushliteral(L, "");  /* error message accumulator */
+  for (i=1; ; i++) {
+    lua_rawgeti(L, -2, i);  /* get a loader */
+    if (lua_isnil(L, -1))
+      luaL_error(L, "module " LUA_QS " not found:%s",
+                    name, lua_tostring(L, -2));
+    lua_pushstring(L, name);
+    lua_call(L, 1, 1);  /* call it */
+    if (lua_isfunction(L, -1))  /* did it find module? */
+      break;  /* module loaded successfully */
+    else if (lua_isstring(L, -1))  /* loader returned error message? */
+      lua_concat(L, 2);  /* accumulate it */
+    else
+      lua_pop(L, 1);
+  }
+  lua_pushlightuserdata(L, sentinel);
+  lua_setfield(L, 2, name);  /* _LOADED[name] = sentinel */
+  lua_pushstring(L, name);  /* pass name as argument to module */
+  lua_call(L, 1, 1);  /* run loaded module */
+  if (!lua_isnil(L, -1))  /* non-nil return? */
+    lua_setfield(L, 2, name);  /* _LOADED[name] = returned value */
+  lua_getfield(L, 2, name);
+  if (lua_touserdata(L, -1) == sentinel) {   /* module did not set a value? */
+    lua_pushboolean(L, 1);  /* use true as result */
+    lua_pushvalue(L, -1);  /* extra copy to be returned */
+    lua_setfield(L, 2, name);  /* _LOADED[name] = true */
+  }
+  return 1;
+}
+
+/* }====================================================== */
+
+
+
+/*
+** {======================================================
+** 'module' function
+** =======================================================
+*/
+  
+
+static void setfenv (lua_State *L) {
+  lua_Debug ar;
+  lua_getstack(L, 1, &ar);
+  lua_getinfo(L, "f", &ar);
+  lua_pushvalue(L, -2);
+  lua_setfenv(L, -2);
+  lua_pop(L, 1);
+}
+
+
+static void dooptions (lua_State *L, int n) {
+  int i;
+  for (i = 2; i <= n; i++) {
+    lua_pushvalue(L, i);  /* get option (a function) */
+    lua_pushvalue(L, -2);  /* module */
+    lua_call(L, 1, 0);
+  }
+}
+
+
+static void modinit (lua_State *L, const char *modname) {
+  const char *dot;
+  lua_pushvalue(L, -1);
+  lua_setfield(L, -2, "_M");  /* module._M = module */
+  lua_pushstring(L, modname);
+  lua_setfield(L, -2, "_NAME");
+  dot = strrchr(modname, '.');  /* look for last dot in module name */
+  if (dot == NULL) dot = modname;
+  else dot++;
+  /* set _PACKAGE as package name (full module name minus last part) */
+  lua_pushlstring(L, modname, dot - modname);
+  lua_setfield(L, -2, "_PACKAGE");
+}
+
+
+static int ll_module (lua_State *L) {
+  const char *modname = luaL_checkstring(L, 1);
+  int loaded = lua_gettop(L) + 1;  /* index of _LOADED table */
+  lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
+  lua_getfield(L, loaded, modname);  /* get _LOADED[modname] */
+  if (!lua_istable(L, -1)) {  /* not found? */
+    lua_pop(L, 1);  /* remove previous result */
+    /* try global variable (and create one if it does not exist) */
+    if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL)
+      return luaL_error(L, "name conflict for module " LUA_QS, modname);
+    lua_pushvalue(L, -1);
+    lua_setfield(L, loaded, modname);  /* _LOADED[modname] = new table */
+  }
+  /* check whether table already has a _NAME field */
+  lua_getfield(L, -1, "_NAME");
+  if (!lua_isnil(L, -1))  /* is table an initialized module? */
+    lua_pop(L, 1);
+  else {  /* no; initialize it */
+    lua_pop(L, 1);
+    modinit(L, modname);
+  }
+  lua_pushvalue(L, -1);
+  setfenv(L);
+  dooptions(L, loaded - 1);
+  return 0;
+}
+
+
+static int ll_seeall (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+  if (!lua_getmetatable(L, 1)) {
+    lua_createtable(L, 0, 1); /* create new metatable */
+    lua_pushvalue(L, -1);
+    lua_setmetatable(L, 1);
+  }
+  lua_pushvalue(L, LUA_GLOBALSINDEX);
+  lua_setfield(L, -2, "__index");  /* mt.__index = _G */
+  return 0;
+}
+
+
+/* }====================================================== */
+
+
+
+/* auxiliary mark (for internal use) */
+#define AUXMARK		"\1"
+
+static void setpath (lua_State *L, const char *fieldname, const char *envname,
+                                   const char *def) {
+  const char *path = getenv(envname);
+  if (path == NULL)  /* no environment variable? */
+    lua_pushstring(L, def);  /* use default */
+  else {
+    /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
+    path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP,
+                              LUA_PATHSEP AUXMARK LUA_PATHSEP);
+    luaL_gsub(L, path, AUXMARK, def);
+    lua_remove(L, -2);
+  }
+  setprogdir(L);
+  lua_setfield(L, -2, fieldname);
+}
+
+
+static const luaL_Reg pk_funcs[] = {
+  {"loadlib", ll_loadlib},
+  {"seeall", ll_seeall},
+  {NULL, NULL}
+};
+
+
+static const luaL_Reg ll_funcs[] = {
+  {"module", ll_module},
+  {"require", ll_require},
+  {NULL, NULL}
+};
+
+
+static const lua_CFunction loaders[] =
+  {loader_preload, loader_Lua, loader_C, loader_Croot, NULL};
+
+
+LUALIB_API int luaopen_package (lua_State *L) {
+  int i;
+  /* create new type _LOADLIB */
+  luaL_newmetatable(L, "_LOADLIB");
+  lua_pushcfunction(L, gctm);
+  lua_setfield(L, -2, "__gc");
+  /* create `package' table */
+  luaL_register(L, LUA_LOADLIBNAME, pk_funcs);
+#if defined(LUA_COMPAT_LOADLIB) 
+  lua_getfield(L, -1, "loadlib");
+  lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
+#endif
+  lua_pushvalue(L, -1);
+  lua_replace(L, LUA_ENVIRONINDEX);
+  /* create `loaders' table */
+  lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1);
+  /* fill it with pre-defined loaders */
+  for (i=0; loaders[i] != NULL; i++) {
+    lua_pushcfunction(L, loaders[i]);
+    lua_rawseti(L, -2, i+1);
+  }
+  lua_setfield(L, -2, "loaders");  /* put it in field `loaders' */
+  setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT);  /* set field `path' */
+  setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
+  /* store config information */
+  lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
+                     LUA_EXECDIR "\n" LUA_IGMARK);
+  lua_setfield(L, -2, "config");
+  /* set field `loaded' */
+  luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2);
+  lua_setfield(L, -2, "loaded");
+  /* set field `preload' */
+  lua_newtable(L);
+  lua_setfield(L, -2, "preload");
+  lua_pushvalue(L, LUA_GLOBALSINDEX);
+  luaL_register(L, NULL, ll_funcs);  /* open lib into global table */
+  lua_pop(L, 1);
+  return 1;  /* return 'package' table */
+}
+
Index: /code/branches/physics/src/lua/lobject.c
===================================================================
--- /code/branches/physics/src/lua/lobject.c	(revision 2122)
+++ /code/branches/physics/src/lua/lobject.c	(revision 2122)
@@ -0,0 +1,214 @@
+/*
+** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
+** Some generic functions over Lua objects
+** See Copyright Notice in lua.h
+*/
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define lobject_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldo.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "lvm.h"
+
+
+
+const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
+
+
+/*
+** converts an integer to a "floating point byte", represented as
+** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
+** eeeee != 0 and (xxx) otherwise.
+*/
+int luaO_int2fb (unsigned int x) {
+  int e = 0;  /* expoent */
+  while (x >= 16) {
+    x = (x+1) >> 1;
+    e++;
+  }
+  if (x < 8) return x;
+  else return ((e+1) << 3) | (cast_int(x) - 8);
+}
+
+
+/* converts back */
+int luaO_fb2int (int x) {
+  int e = (x >> 3) & 31;
+  if (e == 0) return x;
+  else return ((x & 7)+8) << (e - 1);
+}
+
+
+int luaO_log2 (unsigned int x) {
+  static const lu_byte log_2[256] = {
+    0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+    6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
+  };
+  int l = -1;
+  while (x >= 256) { l += 8; x >>= 8; }
+  return l + log_2[x];
+
+}
+
+
+int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
+  if (ttype(t1) != ttype(t2)) return 0;
+  else switch (ttype(t1)) {
+    case LUA_TNIL:
+      return 1;
+    case LUA_TNUMBER:
+      return luai_numeq(nvalue(t1), nvalue(t2));
+    case LUA_TBOOLEAN:
+      return bvalue(t1) == bvalue(t2);  /* boolean true must be 1 !! */
+    case LUA_TLIGHTUSERDATA:
+      return pvalue(t1) == pvalue(t2);
+    default:
+      lua_assert(iscollectable(t1));
+      return gcvalue(t1) == gcvalue(t2);
+  }
+}
+
+
+int luaO_str2d (const char *s, lua_Number *result) {
+  char *endptr;
+  *result = lua_str2number(s, &endptr);
+  if (endptr == s) return 0;  /* conversion failed */
+  if (*endptr == 'x' || *endptr == 'X')  /* maybe an hexadecimal constant? */
+    *result = cast_num(strtoul(s, &endptr, 16));
+  if (*endptr == '\0') return 1;  /* most common case */
+  while (isspace(cast(unsigned char, *endptr))) endptr++;
+  if (*endptr != '\0') return 0;  /* invalid trailing characters? */
+  return 1;
+}
+
+
+
+static void pushstr (lua_State *L, const char *str) {
+  setsvalue2s(L, L->top, luaS_new(L, str));
+  incr_top(L);
+}
+
+
+/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
+const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
+  int n = 1;
+  pushstr(L, "");
+  for (;;) {
+    const char *e = strchr(fmt, '%');
+    if (e == NULL) break;
+    setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
+    incr_top(L);
+    switch (*(e+1)) {
+      case 's': {
+        const char *s = va_arg(argp, char *);
+        if (s == NULL) s = "(null)";
+        pushstr(L, s);
+        break;
+      }
+      case 'c': {
+        char buff[2];
+        buff[0] = cast(char, va_arg(argp, int));
+        buff[1] = '\0';
+        pushstr(L, buff);
+        break;
+      }
+      case 'd': {
+        setnvalue(L->top, cast_num(va_arg(argp, int)));
+        incr_top(L);
+        break;
+      }
+      case 'f': {
+        setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
+        incr_top(L);
+        break;
+      }
+      case 'p': {
+        char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
+        sprintf(buff, "%p", va_arg(argp, void *));
+        pushstr(L, buff);
+        break;
+      }
+      case '%': {
+        pushstr(L, "%");
+        break;
+      }
+      default: {
+        char buff[3];
+        buff[0] = '%';
+        buff[1] = *(e+1);
+        buff[2] = '\0';
+        pushstr(L, buff);
+        break;
+      }
+    }
+    n += 2;
+    fmt = e+2;
+  }
+  pushstr(L, fmt);
+  luaV_concat(L, n+1, cast_int(L->top - L->base) - 1);
+  L->top -= n;
+  return svalue(L->top - 1);
+}
+
+
+const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
+  const char *msg;
+  va_list argp;
+  va_start(argp, fmt);
+  msg = luaO_pushvfstring(L, fmt, argp);
+  va_end(argp);
+  return msg;
+}
+
+
+void luaO_chunkid (char *out, const char *source, size_t bufflen) {
+  if (*source == '=') {
+    strncpy(out, source+1, bufflen);  /* remove first char */
+    out[bufflen-1] = '\0';  /* ensures null termination */
+  }
+  else {  /* out = "source", or "...source" */
+    if (*source == '@') {
+      size_t l;
+      source++;  /* skip the `@' */
+      bufflen -= sizeof(" '...' ");
+      l = strlen(source);
+      strcpy(out, "");
+      if (l > bufflen) {
+        source += (l-bufflen);  /* get last part of file name */
+        strcat(out, "...");
+      }
+      strcat(out, source);
+    }
+    else {  /* out = [string "string"] */
+      size_t len = strcspn(source, "\n\r");  /* stop at first newline */
+      bufflen -= sizeof(" [string \"...\"] ");
+      if (len > bufflen) len = bufflen;
+      strcpy(out, "[string \"");
+      if (source[len] != '\0') {  /* must truncate? */
+        strncat(out, source, len);
+        strcat(out, "...");
+      }
+      else
+        strcat(out, source);
+      strcat(out, "\"]");
+    }
+  }
+}
Index: /code/branches/physics/src/lua/lobject.h
===================================================================
--- /code/branches/physics/src/lua/lobject.h	(revision 2122)
+++ /code/branches/physics/src/lua/lobject.h	(revision 2122)
@@ -0,0 +1,381 @@
+/*
+** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
+** Type definitions for Lua objects
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lobject_h
+#define lobject_h
+
+
+#include <stdarg.h>
+
+
+#include "llimits.h"
+#include "lua.h"
+
+
+/* tags for values visible from Lua */
+#define LAST_TAG	LUA_TTHREAD
+
+#define NUM_TAGS	(LAST_TAG+1)
+
+
+/*
+** Extra tags for non-values
+*/
+#define LUA_TPROTO	(LAST_TAG+1)
+#define LUA_TUPVAL	(LAST_TAG+2)
+#define LUA_TDEADKEY	(LAST_TAG+3)
+
+
+/*
+** Union of all collectable objects
+*/
+typedef union GCObject GCObject;
+
+
+/*
+** Common Header for all collectable objects (in macro form, to be
+** included in other objects)
+*/
+#define CommonHeader	GCObject *next; lu_byte tt; lu_byte marked
+
+
+/*
+** Common header in struct form
+*/
+typedef struct GCheader {
+  CommonHeader;
+} GCheader;
+
+
+
+
+/*
+** Union of all Lua values
+*/
+typedef union {
+  GCObject *gc;
+  void *p;
+  lua_Number n;
+  int b;
+} Value;
+
+
+/*
+** Tagged Values
+*/
+
+#define TValuefields	Value value; int tt
+
+typedef struct lua_TValue {
+  TValuefields;
+} TValue;
+
+
+/* Macros to test type */
+#define ttisnil(o)	(ttype(o) == LUA_TNIL)
+#define ttisnumber(o)	(ttype(o) == LUA_TNUMBER)
+#define ttisstring(o)	(ttype(o) == LUA_TSTRING)
+#define ttistable(o)	(ttype(o) == LUA_TTABLE)
+#define ttisfunction(o)	(ttype(o) == LUA_TFUNCTION)
+#define ttisboolean(o)	(ttype(o) == LUA_TBOOLEAN)
+#define ttisuserdata(o)	(ttype(o) == LUA_TUSERDATA)
+#define ttisthread(o)	(ttype(o) == LUA_TTHREAD)
+#define ttislightuserdata(o)	(ttype(o) == LUA_TLIGHTUSERDATA)
+
+/* Macros to access values */
+#define ttype(o)	((o)->tt)
+#define gcvalue(o)	check_exp(iscollectable(o), (o)->value.gc)
+#define pvalue(o)	check_exp(ttislightuserdata(o), (o)->value.p)
+#define nvalue(o)	check_exp(ttisnumber(o), (o)->value.n)
+#define rawtsvalue(o)	check_exp(ttisstring(o), &(o)->value.gc->ts)
+#define tsvalue(o)	(&rawtsvalue(o)->tsv)
+#define rawuvalue(o)	check_exp(ttisuserdata(o), &(o)->value.gc->u)
+#define uvalue(o)	(&rawuvalue(o)->uv)
+#define clvalue(o)	check_exp(ttisfunction(o), &(o)->value.gc->cl)
+#define hvalue(o)	check_exp(ttistable(o), &(o)->value.gc->h)
+#define bvalue(o)	check_exp(ttisboolean(o), (o)->value.b)
+#define thvalue(o)	check_exp(ttisthread(o), &(o)->value.gc->th)
+
+#define l_isfalse(o)	(ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
+
+/*
+** for internal debug only
+*/
+#define checkconsistency(obj) \
+  lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
+
+#define checkliveness(g,obj) \
+  lua_assert(!iscollectable(obj) || \
+  ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
+
+
+/* Macros to set values */
+#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
+
+#define setnvalue(obj,x) \
+  { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
+
+#define setpvalue(obj,x) \
+  { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
+
+#define setbvalue(obj,x) \
+  { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
+
+#define setsvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
+    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
+    checkliveness(G(L),i_o); }
+
+#define setuvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
+    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
+    checkliveness(G(L),i_o); }
+
+#define setthvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
+    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
+    checkliveness(G(L),i_o); }
+
+#define setclvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
+    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
+    checkliveness(G(L),i_o); }
+
+#define sethvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
+    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
+    checkliveness(G(L),i_o); }
+
+#define setptvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
+    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
+    checkliveness(G(L),i_o); }
+
+
+
+
+#define setobj(L,obj1,obj2) \
+  { const TValue *o2=(obj2); TValue *o1=(obj1); \
+    o1->value = o2->value; o1->tt=o2->tt; \
+    checkliveness(G(L),o1); }
+
+
+/*
+** different types of sets, according to destination
+*/
+
+/* from stack to (same) stack */
+#define setobjs2s	setobj
+/* to stack (not from same stack) */
+#define setobj2s	setobj
+#define setsvalue2s	setsvalue
+#define sethvalue2s	sethvalue
+#define setptvalue2s	setptvalue
+/* from table to same table */
+#define setobjt2t	setobj
+/* to table */
+#define setobj2t	setobj
+/* to new object */
+#define setobj2n	setobj
+#define setsvalue2n	setsvalue
+
+#define setttype(obj, tt) (ttype(obj) = (tt))
+
+
+#define iscollectable(o)	(ttype(o) >= LUA_TSTRING)
+
+
+
+typedef TValue *StkId;  /* index to stack elements */
+
+
+/*
+** String headers for string table
+*/
+typedef union TString {
+  L_Umaxalign dummy;  /* ensures maximum alignment for strings */
+  struct {
+    CommonHeader;
+    lu_byte reserved;
+    unsigned int hash;
+    size_t len;
+  } tsv;
+} TString;
+
+
+#define getstr(ts)	cast(const char *, (ts) + 1)
+#define svalue(o)       getstr(tsvalue(o))
+
+
+
+typedef union Udata {
+  L_Umaxalign dummy;  /* ensures maximum alignment for `local' udata */
+  struct {
+    CommonHeader;
+    struct Table *metatable;
+    struct Table *env;
+    size_t len;
+  } uv;
+} Udata;
+
+
+
+
+/*
+** Function Prototypes
+*/
+typedef struct Proto {
+  CommonHeader;
+  TValue *k;  /* constants used by the function */
+  Instruction *code;
+  struct Proto **p;  /* functions defined inside the function */
+  int *lineinfo;  /* map from opcodes to source lines */
+  struct LocVar *locvars;  /* information about local variables */
+  TString **upvalues;  /* upvalue names */
+  TString  *source;
+  int sizeupvalues;
+  int sizek;  /* size of `k' */
+  int sizecode;
+  int sizelineinfo;
+  int sizep;  /* size of `p' */
+  int sizelocvars;
+  int linedefined;
+  int lastlinedefined;
+  GCObject *gclist;
+  lu_byte nups;  /* number of upvalues */
+  lu_byte numparams;
+  lu_byte is_vararg;
+  lu_byte maxstacksize;
+} Proto;
+
+
+/* masks for new-style vararg */
+#define VARARG_HASARG		1
+#define VARARG_ISVARARG		2
+#define VARARG_NEEDSARG		4
+
+
+typedef struct LocVar {
+  TString *varname;
+  int startpc;  /* first point where variable is active */
+  int endpc;    /* first point where variable is dead */
+} LocVar;
+
+
+
+/*
+** Upvalues
+*/
+
+typedef struct UpVal {
+  CommonHeader;
+  TValue *v;  /* points to stack or to its own value */
+  union {
+    TValue value;  /* the value (when closed) */
+    struct {  /* double linked list (when open) */
+      struct UpVal *prev;
+      struct UpVal *next;
+    } l;
+  } u;
+} UpVal;
+
+
+/*
+** Closures
+*/
+
+#define ClosureHeader \
+	CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
+	struct Table *env
+
+typedef struct CClosure {
+  ClosureHeader;
+  lua_CFunction f;
+  TValue upvalue[1];
+} CClosure;
+
+
+typedef struct LClosure {
+  ClosureHeader;
+  struct Proto *p;
+  UpVal *upvals[1];
+} LClosure;
+
+
+typedef union Closure {
+  CClosure c;
+  LClosure l;
+} Closure;
+
+
+#define iscfunction(o)	(ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
+#define isLfunction(o)	(ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
+
+
+/*
+** Tables
+*/
+
+typedef union TKey {
+  struct {
+    TValuefields;
+    struct Node *next;  /* for chaining */
+  } nk;
+  TValue tvk;
+} TKey;
+
+
+typedef struct Node {
+  TValue i_val;
+  TKey i_key;
+} Node;
+
+
+typedef struct Table {
+  CommonHeader;
+  lu_byte flags;  /* 1<<p means tagmethod(p) is not present */ 
+  lu_byte lsizenode;  /* log2 of size of `node' array */
+  struct Table *metatable;
+  TValue *array;  /* array part */
+  Node *node;
+  Node *lastfree;  /* any free position is before this position */
+  GCObject *gclist;
+  int sizearray;  /* size of `array' array */
+} Table;
+
+
+
+/*
+** `module' operation for hashing (size is always a power of 2)
+*/
+#define lmod(s,size) \
+	(check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
+
+
+#define twoto(x)	(1<<(x))
+#define sizenode(t)	(twoto((t)->lsizenode))
+
+
+#define luaO_nilobject		(&luaO_nilobject_)
+
+LUAI_DATA const TValue luaO_nilobject_;
+
+#define ceillog2(x)	(luaO_log2((x)-1) + 1)
+
+LUAI_FUNC int luaO_log2 (unsigned int x);
+LUAI_FUNC int luaO_int2fb (unsigned int x);
+LUAI_FUNC int luaO_fb2int (int x);
+LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
+LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
+LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
+                                                       va_list argp);
+LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
+LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
+
+
+#endif
+
Index: /code/branches/physics/src/lua/lopcodes.c
===================================================================
--- /code/branches/physics/src/lua/lopcodes.c	(revision 2122)
+++ /code/branches/physics/src/lua/lopcodes.c	(revision 2122)
@@ -0,0 +1,102 @@
+/*
+** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
+** See Copyright Notice in lua.h
+*/
+
+
+#define lopcodes_c
+#define LUA_CORE
+
+
+#include "lopcodes.h"
+
+
+/* ORDER OP */
+
+const char *const luaP_opnames[NUM_OPCODES+1] = {
+  "MOVE",
+  "LOADK",
+  "LOADBOOL",
+  "LOADNIL",
+  "GETUPVAL",
+  "GETGLOBAL",
+  "GETTABLE",
+  "SETGLOBAL",
+  "SETUPVAL",
+  "SETTABLE",
+  "NEWTABLE",
+  "SELF",
+  "ADD",
+  "SUB",
+  "MUL",
+  "DIV",
+  "MOD",
+  "POW",
+  "UNM",
+  "NOT",
+  "LEN",
+  "CONCAT",
+  "JMP",
+  "EQ",
+  "LT",
+  "LE",
+  "TEST",
+  "TESTSET",
+  "CALL",
+  "TAILCALL",
+  "RETURN",
+  "FORLOOP",
+  "FORPREP",
+  "TFORLOOP",
+  "SETLIST",
+  "CLOSE",
+  "CLOSURE",
+  "VARARG",
+  NULL
+};
+
+
+#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
+
+const lu_byte luaP_opmodes[NUM_OPCODES] = {
+/*       T  A    B       C     mode		   opcode	*/
+  opmode(0, 1, OpArgR, OpArgN, iABC) 		/* OP_MOVE */
+ ,opmode(0, 1, OpArgK, OpArgN, iABx)		/* OP_LOADK */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_LOADBOOL */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_LOADNIL */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC)		/* OP_GETUPVAL */
+ ,opmode(0, 1, OpArgK, OpArgN, iABx)		/* OP_GETGLOBAL */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC)		/* OP_GETTABLE */
+ ,opmode(0, 0, OpArgK, OpArgN, iABx)		/* OP_SETGLOBAL */
+ ,opmode(0, 0, OpArgU, OpArgN, iABC)		/* OP_SETUPVAL */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC)		/* OP_SETTABLE */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_NEWTABLE */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC)		/* OP_SELF */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_ADD */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_SUB */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_MUL */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_DIV */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_MOD */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_POW */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_UNM */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_NOT */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_LEN */
+ ,opmode(0, 1, OpArgR, OpArgR, iABC)		/* OP_CONCAT */
+ ,opmode(0, 0, OpArgR, OpArgN, iAsBx)		/* OP_JMP */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC)		/* OP_EQ */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC)		/* OP_LT */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC)		/* OP_LE */
+ ,opmode(1, 1, OpArgR, OpArgU, iABC)		/* OP_TEST */
+ ,opmode(1, 1, OpArgR, OpArgU, iABC)		/* OP_TESTSET */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_CALL */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_TAILCALL */
+ ,opmode(0, 0, OpArgU, OpArgN, iABC)		/* OP_RETURN */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx)		/* OP_FORLOOP */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx)		/* OP_FORPREP */
+ ,opmode(1, 0, OpArgN, OpArgU, iABC)		/* OP_TFORLOOP */
+ ,opmode(0, 0, OpArgU, OpArgU, iABC)		/* OP_SETLIST */
+ ,opmode(0, 0, OpArgN, OpArgN, iABC)		/* OP_CLOSE */
+ ,opmode(0, 1, OpArgU, OpArgN, iABx)		/* OP_CLOSURE */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC)		/* OP_VARARG */
+};
+
Index: /code/branches/physics/src/lua/lopcodes.h
===================================================================
--- /code/branches/physics/src/lua/lopcodes.h	(revision 2122)
+++ /code/branches/physics/src/lua/lopcodes.h	(revision 2122)
@@ -0,0 +1,268 @@
+/*
+** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
+** Opcodes for Lua virtual machine
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lopcodes_h
+#define lopcodes_h
+
+#include "llimits.h"
+
+
+/*===========================================================================
+  We assume that instructions are unsigned numbers.
+  All instructions have an opcode in the first 6 bits.
+  Instructions can have the following fields:
+	`A' : 8 bits
+	`B' : 9 bits
+	`C' : 9 bits
+	`Bx' : 18 bits (`B' and `C' together)
+	`sBx' : signed Bx
+
+  A signed argument is represented in excess K; that is, the number
+  value is the unsigned value minus K. K is exactly the maximum value
+  for that argument (so that -max is represented by 0, and +max is
+  represented by 2*max), which is half the maximum for the corresponding
+  unsigned argument.
+===========================================================================*/
+
+
+enum OpMode {iABC, iABx, iAsBx};  /* basic instruction format */
+
+
+/*
+** size and position of opcode arguments.
+*/
+#define SIZE_C		9
+#define SIZE_B		9
+#define SIZE_Bx		(SIZE_C + SIZE_B)
+#define SIZE_A		8
+
+#define SIZE_OP		6
+
+#define POS_OP		0
+#define POS_A		(POS_OP + SIZE_OP)
+#define POS_C		(POS_A + SIZE_A)
+#define POS_B		(POS_C + SIZE_C)
+#define POS_Bx		POS_C
+
+
+/*
+** limits for opcode arguments.
+** we use (signed) int to manipulate most arguments,
+** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
+*/
+#if SIZE_Bx < LUAI_BITSINT-1
+#define MAXARG_Bx        ((1<<SIZE_Bx)-1)
+#define MAXARG_sBx        (MAXARG_Bx>>1)         /* `sBx' is signed */
+#else
+#define MAXARG_Bx        MAX_INT
+#define MAXARG_sBx        MAX_INT
+#endif
+
+
+#define MAXARG_A        ((1<<SIZE_A)-1)
+#define MAXARG_B        ((1<<SIZE_B)-1)
+#define MAXARG_C        ((1<<SIZE_C)-1)
+
+
+/* creates a mask with `n' 1 bits at position `p' */
+#define MASK1(n,p)	((~((~(Instruction)0)<<n))<<p)
+
+/* creates a mask with `n' 0 bits at position `p' */
+#define MASK0(n,p)	(~MASK1(n,p))
+
+/*
+** the following macros help to manipulate instructions
+*/
+
+#define GET_OPCODE(i)	(cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
+#define SET_OPCODE(i,o)	((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
+		((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
+
+#define GETARG_A(i)	(cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
+#define SETARG_A(i,u)	((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
+		((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))
+
+#define GETARG_B(i)	(cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
+#define SETARG_B(i,b)	((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
+		((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))
+
+#define GETARG_C(i)	(cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
+#define SETARG_C(i,b)	((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
+		((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))
+
+#define GETARG_Bx(i)	(cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
+#define SETARG_Bx(i,b)	((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
+		((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))
+
+#define GETARG_sBx(i)	(GETARG_Bx(i)-MAXARG_sBx)
+#define SETARG_sBx(i,b)	SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
+
+
+#define CREATE_ABC(o,a,b,c)	((cast(Instruction, o)<<POS_OP) \
+			| (cast(Instruction, a)<<POS_A) \
+			| (cast(Instruction, b)<<POS_B) \
+			| (cast(Instruction, c)<<POS_C))
+
+#define CREATE_ABx(o,a,bc)	((cast(Instruction, o)<<POS_OP) \
+			| (cast(Instruction, a)<<POS_A) \
+			| (cast(Instruction, bc)<<POS_Bx))
+
+
+/*
+** Macros to operate RK indices
+*/
+
+/* this bit 1 means constant (0 means register) */
+#define BITRK		(1 << (SIZE_B - 1))
+
+/* test whether value is a constant */
+#define ISK(x)		((x) & BITRK)
+
+/* gets the index of the constant */
+#define INDEXK(r)	((int)(r) & ~BITRK)
+
+#define MAXINDEXRK	(BITRK - 1)
+
+/* code a constant index as a RK value */
+#define RKASK(x)	((x) | BITRK)
+
+
+/*
+** invalid register that fits in 8 bits
+*/
+#define NO_REG		MAXARG_A
+
+
+/*
+** R(x) - register
+** Kst(x) - constant (in constant table)
+** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
+*/
+
+
+/*
+** grep "ORDER OP" if you change these enums
+*/
+
+typedef enum {
+/*----------------------------------------------------------------------
+name		args	description
+------------------------------------------------------------------------*/
+OP_MOVE,/*	A B	R(A) := R(B)					*/
+OP_LOADK,/*	A Bx	R(A) := Kst(Bx)					*/
+OP_LOADBOOL,/*	A B C	R(A) := (Bool)B; if (C) pc++			*/
+OP_LOADNIL,/*	A B	R(A) := ... := R(B) := nil			*/
+OP_GETUPVAL,/*	A B	R(A) := UpValue[B]				*/
+
+OP_GETGLOBAL,/*	A Bx	R(A) := Gbl[Kst(Bx)]				*/
+OP_GETTABLE,/*	A B C	R(A) := R(B)[RK(C)]				*/
+
+OP_SETGLOBAL,/*	A Bx	Gbl[Kst(Bx)] := R(A)				*/
+OP_SETUPVAL,/*	A B	UpValue[B] := R(A)				*/
+OP_SETTABLE,/*	A B C	R(A)[RK(B)] := RK(C)				*/
+
+OP_NEWTABLE,/*	A B C	R(A) := {} (size = B,C)				*/
+
+OP_SELF,/*	A B C	R(A+1) := R(B); R(A) := R(B)[RK(C)]		*/
+
+OP_ADD,/*	A B C	R(A) := RK(B) + RK(C)				*/
+OP_SUB,/*	A B C	R(A) := RK(B) - RK(C)				*/
+OP_MUL,/*	A B C	R(A) := RK(B) * RK(C)				*/
+OP_DIV,/*	A B C	R(A) := RK(B) / RK(C)				*/
+OP_MOD,/*	A B C	R(A) := RK(B) % RK(C)				*/
+OP_POW,/*	A B C	R(A) := RK(B) ^ RK(C)				*/
+OP_UNM,/*	A B	R(A) := -R(B)					*/
+OP_NOT,/*	A B	R(A) := not R(B)				*/
+OP_LEN,/*	A B	R(A) := length of R(B)				*/
+
+OP_CONCAT,/*	A B C	R(A) := R(B).. ... ..R(C)			*/
+
+OP_JMP,/*	sBx	pc+=sBx					*/
+
+OP_EQ,/*	A B C	if ((RK(B) == RK(C)) ~= A) then pc++		*/
+OP_LT,/*	A B C	if ((RK(B) <  RK(C)) ~= A) then pc++  		*/
+OP_LE,/*	A B C	if ((RK(B) <= RK(C)) ~= A) then pc++  		*/
+
+OP_TEST,/*	A C	if not (R(A) <=> C) then pc++			*/ 
+OP_TESTSET,/*	A B C	if (R(B) <=> C) then R(A) := R(B) else pc++	*/ 
+
+OP_CALL,/*	A B C	R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
+OP_TAILCALL,/*	A B C	return R(A)(R(A+1), ... ,R(A+B-1))		*/
+OP_RETURN,/*	A B	return R(A), ... ,R(A+B-2)	(see note)	*/
+
+OP_FORLOOP,/*	A sBx	R(A)+=R(A+2);
+			if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
+OP_FORPREP,/*	A sBx	R(A)-=R(A+2); pc+=sBx				*/
+
+OP_TFORLOOP,/*	A C	R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); 
+                        if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++	*/ 
+OP_SETLIST,/*	A B C	R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B	*/
+
+OP_CLOSE,/*	A 	close all variables in the stack up to (>=) R(A)*/
+OP_CLOSURE,/*	A Bx	R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n))	*/
+
+OP_VARARG/*	A B	R(A), R(A+1), ..., R(A+B-1) = vararg		*/
+} OpCode;
+
+
+#define NUM_OPCODES	(cast(int, OP_VARARG) + 1)
+
+
+
+/*===========================================================================
+  Notes:
+  (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
+      and can be 0: OP_CALL then sets `top' to last_result+1, so
+      next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'.
+
+  (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
+      set top (like in OP_CALL with C == 0).
+
+  (*) In OP_RETURN, if (B == 0) then return up to `top'
+
+  (*) In OP_SETLIST, if (B == 0) then B = `top';
+      if (C == 0) then next `instruction' is real C
+
+  (*) For comparisons, A specifies what condition the test should accept
+      (true or false).
+
+  (*) All `skips' (pc++) assume that next instruction is a jump
+===========================================================================*/
+
+
+/*
+** masks for instruction properties. The format is:
+** bits 0-1: op mode
+** bits 2-3: C arg mode
+** bits 4-5: B arg mode
+** bit 6: instruction set register A
+** bit 7: operator is a test
+*/  
+
+enum OpArgMask {
+  OpArgN,  /* argument is not used */
+  OpArgU,  /* argument is used */
+  OpArgR,  /* argument is a register or a jump offset */
+  OpArgK   /* argument is a constant or register/constant */
+};
+
+LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
+
+#define getOpMode(m)	(cast(enum OpMode, luaP_opmodes[m] & 3))
+#define getBMode(m)	(cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
+#define getCMode(m)	(cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
+#define testAMode(m)	(luaP_opmodes[m] & (1 << 6))
+#define testTMode(m)	(luaP_opmodes[m] & (1 << 7))
+
+
+LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1];  /* opcode names */
+
+
+/* number of list items to accumulate before a SETLIST instruction */
+#define LFIELDS_PER_FLUSH	50
+
+
+#endif
Index: /code/branches/physics/src/lua/loslib.c
===================================================================
--- /code/branches/physics/src/lua/loslib.c	(revision 2122)
+++ /code/branches/physics/src/lua/loslib.c	(revision 2122)
@@ -0,0 +1,243 @@
+/*
+** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
+** Standard Operating System library
+** See Copyright Notice in lua.h
+*/
+
+
+#include <errno.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#define loslib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+static int os_pushresult (lua_State *L, int i, const char *filename) {
+  int en = errno;  /* calls to Lua API may change this value */
+  if (i) {
+    lua_pushboolean(L, 1);
+    return 1;
+  }
+  else {
+    lua_pushnil(L);
+    lua_pushfstring(L, "%s: %s", filename, strerror(en));
+    lua_pushinteger(L, en);
+    return 3;
+  }
+}
+
+
+static int os_execute (lua_State *L) {
+  lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
+  return 1;
+}
+
+
+static int os_remove (lua_State *L) {
+  const char *filename = luaL_checkstring(L, 1);
+  return os_pushresult(L, remove(filename) == 0, filename);
+}
+
+
+static int os_rename (lua_State *L) {
+  const char *fromname = luaL_checkstring(L, 1);
+  const char *toname = luaL_checkstring(L, 2);
+  return os_pushresult(L, rename(fromname, toname) == 0, fromname);
+}
+
+
+static int os_tmpname (lua_State *L) {
+  char buff[LUA_TMPNAMBUFSIZE];
+  int err;
+  lua_tmpnam(buff, err);
+  if (err)
+    return luaL_error(L, "unable to generate a unique filename");
+  lua_pushstring(L, buff);
+  return 1;
+}
+
+
+static int os_getenv (lua_State *L) {
+  lua_pushstring(L, getenv(luaL_checkstring(L, 1)));  /* if NULL push nil */
+  return 1;
+}
+
+
+static int os_clock (lua_State *L) {
+  lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
+  return 1;
+}
+
+
+/*
+** {======================================================
+** Time/Date operations
+** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S,
+**   wday=%w+1, yday=%j, isdst=? }
+** =======================================================
+*/
+
+static void setfield (lua_State *L, const char *key, int value) {
+  lua_pushinteger(L, value);
+  lua_setfield(L, -2, key);
+}
+
+static void setboolfield (lua_State *L, const char *key, int value) {
+  if (value < 0)  /* undefined? */
+    return;  /* does not set field */
+  lua_pushboolean(L, value);
+  lua_setfield(L, -2, key);
+}
+
+static int getboolfield (lua_State *L, const char *key) {
+  int res;
+  lua_getfield(L, -1, key);
+  res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1);
+  lua_pop(L, 1);
+  return res;
+}
+
+
+static int getfield (lua_State *L, const char *key, int d) {
+  int res;
+  lua_getfield(L, -1, key);
+  if (lua_isnumber(L, -1))
+    res = (int)lua_tointeger(L, -1);
+  else {
+    if (d < 0)
+      return luaL_error(L, "field " LUA_QS " missing in date table", key);
+    res = d;
+  }
+  lua_pop(L, 1);
+  return res;
+}
+
+
+static int os_date (lua_State *L) {
+  const char *s = luaL_optstring(L, 1, "%c");
+  time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
+  struct tm *stm;
+  if (*s == '!') {  /* UTC? */
+    stm = gmtime(&t);
+    s++;  /* skip `!' */
+  }
+  else
+    stm = localtime(&t);
+  if (stm == NULL)  /* invalid date? */
+    lua_pushnil(L);
+  else if (strcmp(s, "*t") == 0) {
+    lua_createtable(L, 0, 9);  /* 9 = number of fields */
+    setfield(L, "sec", stm->tm_sec);
+    setfield(L, "min", stm->tm_min);
+    setfield(L, "hour", stm->tm_hour);
+    setfield(L, "day", stm->tm_mday);
+    setfield(L, "month", stm->tm_mon+1);
+    setfield(L, "year", stm->tm_year+1900);
+    setfield(L, "wday", stm->tm_wday+1);
+    setfield(L, "yday", stm->tm_yday+1);
+    setboolfield(L, "isdst", stm->tm_isdst);
+  }
+  else {
+    char cc[3];
+    luaL_Buffer b;
+    cc[0] = '%'; cc[2] = '\0';
+    luaL_buffinit(L, &b);
+    for (; *s; s++) {
+      if (*s != '%' || *(s + 1) == '\0')  /* no conversion specifier? */
+        luaL_addchar(&b, *s);
+      else {
+        size_t reslen;
+        char buff[200];  /* should be big enough for any conversion result */
+        cc[1] = *(++s);
+        reslen = strftime(buff, sizeof(buff), cc, stm);
+        luaL_addlstring(&b, buff, reslen);
+      }
+    }
+    luaL_pushresult(&b);
+  }
+  return 1;
+}
+
+
+static int os_time (lua_State *L) {
+  time_t t;
+  if (lua_isnoneornil(L, 1))  /* called without args? */
+    t = time(NULL);  /* get current time */
+  else {
+    struct tm ts;
+    luaL_checktype(L, 1, LUA_TTABLE);
+    lua_settop(L, 1);  /* make sure table is at the top */
+    ts.tm_sec = getfield(L, "sec", 0);
+    ts.tm_min = getfield(L, "min", 0);
+    ts.tm_hour = getfield(L, "hour", 12);
+    ts.tm_mday = getfield(L, "day", -1);
+    ts.tm_mon = getfield(L, "month", -1) - 1;
+    ts.tm_year = getfield(L, "year", -1) - 1900;
+    ts.tm_isdst = getboolfield(L, "isdst");
+    t = mktime(&ts);
+  }
+  if (t == (time_t)(-1))
+    lua_pushnil(L);
+  else
+    lua_pushnumber(L, (lua_Number)t);
+  return 1;
+}
+
+
+static int os_difftime (lua_State *L) {
+  lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
+                             (time_t)(luaL_optnumber(L, 2, 0))));
+  return 1;
+}
+
+/* }====================================================== */
+
+
+static int os_setlocale (lua_State *L) {
+  static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
+                      LC_NUMERIC, LC_TIME};
+  static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
+     "numeric", "time", NULL};
+  const char *l = luaL_optstring(L, 1, NULL);
+  int op = luaL_checkoption(L, 2, "all", catnames);
+  lua_pushstring(L, setlocale(cat[op], l));
+  return 1;
+}
+
+
+static int os_exit (lua_State *L) {
+  exit(luaL_optint(L, 1, EXIT_SUCCESS));
+}
+
+static const luaL_Reg syslib[] = {
+  {"clock",     os_clock},
+  {"date",      os_date},
+  {"difftime",  os_difftime},
+  {"execute",   os_execute},
+  {"exit",      os_exit},
+  {"getenv",    os_getenv},
+  {"remove",    os_remove},
+  {"rename",    os_rename},
+  {"setlocale", os_setlocale},
+  {"time",      os_time},
+  {"tmpname",   os_tmpname},
+  {NULL, NULL}
+};
+
+/* }====================================================== */
+
+
+
+LUALIB_API int luaopen_os (lua_State *L) {
+  luaL_register(L, LUA_OSLIBNAME, syslib);
+  return 1;
+}
+
Index: /code/branches/physics/src/lua/lparser.c
===================================================================
--- /code/branches/physics/src/lua/lparser.c	(revision 2122)
+++ /code/branches/physics/src/lua/lparser.c	(revision 2122)
@@ -0,0 +1,1339 @@
+/*
+** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
+** Lua Parser
+** See Copyright Notice in lua.h
+*/
+
+
+#include <string.h>
+
+#define lparser_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lcode.h"
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "llex.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lparser.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+
+
+
+#define hasmultret(k)		((k) == VCALL || (k) == VVARARG)
+
+#define getlocvar(fs, i)	((fs)->f->locvars[(fs)->actvar[i]])
+
+#define luaY_checklimit(fs,v,l,m)	if ((v)>(l)) errorlimit(fs,l,m)
+
+
+/*
+** nodes for block list (list of active blocks)
+*/
+typedef struct BlockCnt {
+  struct BlockCnt *previous;  /* chain */
+  int breaklist;  /* list of jumps out of this loop */
+  lu_byte nactvar;  /* # active locals outside the breakable structure */
+  lu_byte upval;  /* true if some variable in the block is an upvalue */
+  lu_byte isbreakable;  /* true if `block' is a loop */
+} BlockCnt;
+
+
+
+/*
+** prototypes for recursive non-terminal functions
+*/
+static void chunk (LexState *ls);
+static void expr (LexState *ls, expdesc *v);
+
+
+static void anchor_token (LexState *ls) {
+  if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
+    TString *ts = ls->t.seminfo.ts;
+    luaX_newstring(ls, getstr(ts), ts->tsv.len);
+  }
+}
+
+
+static void error_expected (LexState *ls, int token) {
+  luaX_syntaxerror(ls,
+      luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
+}
+
+
+static void errorlimit (FuncState *fs, int limit, const char *what) {
+  const char *msg = (fs->f->linedefined == 0) ?
+    luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
+    luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
+                            fs->f->linedefined, limit, what);
+  luaX_lexerror(fs->ls, msg, 0);
+}
+
+
+static int testnext (LexState *ls, int c) {
+  if (ls->t.token == c) {
+    luaX_next(ls);
+    return 1;
+  }
+  else return 0;
+}
+
+
+static void check (LexState *ls, int c) {
+  if (ls->t.token != c)
+    error_expected(ls, c);
+}
+
+static void checknext (LexState *ls, int c) {
+  check(ls, c);
+  luaX_next(ls);
+}
+
+
+#define check_condition(ls,c,msg)	{ if (!(c)) luaX_syntaxerror(ls, msg); }
+
+
+
+static void check_match (LexState *ls, int what, int who, int where) {
+  if (!testnext(ls, what)) {
+    if (where == ls->linenumber)
+      error_expected(ls, what);
+    else {
+      luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
+             LUA_QS " expected (to close " LUA_QS " at line %d)",
+              luaX_token2str(ls, what), luaX_token2str(ls, who), where));
+    }
+  }
+}
+
+
+static TString *str_checkname (LexState *ls) {
+  TString *ts;
+  check(ls, TK_NAME);
+  ts = ls->t.seminfo.ts;
+  luaX_next(ls);
+  return ts;
+}
+
+
+static void init_exp (expdesc *e, expkind k, int i) {
+  e->f = e->t = NO_JUMP;
+  e->k = k;
+  e->u.s.info = i;
+}
+
+
+static void codestring (LexState *ls, expdesc *e, TString *s) {
+  init_exp(e, VK, luaK_stringK(ls->fs, s));
+}
+
+
+static void checkname(LexState *ls, expdesc *e) {
+  codestring(ls, e, str_checkname(ls));
+}
+
+
+static int registerlocalvar (LexState *ls, TString *varname) {
+  FuncState *fs = ls->fs;
+  Proto *f = fs->f;
+  int oldsize = f->sizelocvars;
+  luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
+                  LocVar, SHRT_MAX, "too many local variables");
+  while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
+  f->locvars[fs->nlocvars].varname = varname;
+  luaC_objbarrier(ls->L, f, varname);
+  return fs->nlocvars++;
+}
+
+
+#define new_localvarliteral(ls,v,n) \
+  new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
+
+
+static void new_localvar (LexState *ls, TString *name, int n) {
+  FuncState *fs = ls->fs;
+  luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables");
+  fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
+}
+
+
+static void adjustlocalvars (LexState *ls, int nvars) {
+  FuncState *fs = ls->fs;
+  fs->nactvar = cast_byte(fs->nactvar + nvars);
+  for (; nvars; nvars--) {
+    getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc;
+  }
+}
+
+
+static void removevars (LexState *ls, int tolevel) {
+  FuncState *fs = ls->fs;
+  while (fs->nactvar > tolevel)
+    getlocvar(fs, --fs->nactvar).endpc = fs->pc;
+}
+
+
+static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
+  int i;
+  Proto *f = fs->f;
+  int oldsize = f->sizeupvalues;
+  for (i=0; i<f->nups; i++) {
+    if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) {
+      lua_assert(f->upvalues[i] == name);
+      return i;
+    }
+  }
+  /* new one */
+  luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues");
+  luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues,
+                  TString *, MAX_INT, "");
+  while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL;
+  f->upvalues[f->nups] = name;
+  luaC_objbarrier(fs->L, f, name);
+  lua_assert(v->k == VLOCAL || v->k == VUPVAL);
+  fs->upvalues[f->nups].k = cast_byte(v->k);
+  fs->upvalues[f->nups].info = cast_byte(v->u.s.info);
+  return f->nups++;
+}
+
+
+static int searchvar (FuncState *fs, TString *n) {
+  int i;
+  for (i=fs->nactvar-1; i >= 0; i--) {
+    if (n == getlocvar(fs, i).varname)
+      return i;
+  }
+  return -1;  /* not found */
+}
+
+
+static void markupval (FuncState *fs, int level) {
+  BlockCnt *bl = fs->bl;
+  while (bl && bl->nactvar > level) bl = bl->previous;
+  if (bl) bl->upval = 1;
+}
+
+
+static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
+  if (fs == NULL) {  /* no more levels? */
+    init_exp(var, VGLOBAL, NO_REG);  /* default is global variable */
+    return VGLOBAL;
+  }
+  else {
+    int v = searchvar(fs, n);  /* look up at current level */
+    if (v >= 0) {
+      init_exp(var, VLOCAL, v);
+      if (!base)
+        markupval(fs, v);  /* local will be used as an upval */
+      return VLOCAL;
+    }
+    else {  /* not found at current level; try upper one */
+      if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
+        return VGLOBAL;
+      var->u.s.info = indexupvalue(fs, n, var);  /* else was LOCAL or UPVAL */
+      var->k = VUPVAL;  /* upvalue in this level */
+      return VUPVAL;
+    }
+  }
+}
+
+
+static void singlevar (LexState *ls, expdesc *var) {
+  TString *varname = str_checkname(ls);
+  FuncState *fs = ls->fs;
+  if (singlevaraux(fs, varname, var, 1) == VGLOBAL)
+    var->u.s.info = luaK_stringK(fs, varname);  /* info points to global name */
+}
+
+
+static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
+  FuncState *fs = ls->fs;
+  int extra = nvars - nexps;
+  if (hasmultret(e->k)) {
+    extra++;  /* includes call itself */
+    if (extra < 0) extra = 0;
+    luaK_setreturns(fs, e, extra);  /* last exp. provides the difference */
+    if (extra > 1) luaK_reserveregs(fs, extra-1);
+  }
+  else {
+    if (e->k != VVOID) luaK_exp2nextreg(fs, e);  /* close last expression */
+    if (extra > 0) {
+      int reg = fs->freereg;
+      luaK_reserveregs(fs, extra);
+      luaK_nil(fs, reg, extra);
+    }
+  }
+}
+
+
+static void enterlevel (LexState *ls) {
+  if (++ls->L->nCcalls > LUAI_MAXCCALLS)
+	luaX_lexerror(ls, "chunk has too many syntax levels", 0);
+}
+
+
+#define leavelevel(ls)	((ls)->L->nCcalls--)
+
+
+static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
+  bl->breaklist = NO_JUMP;
+  bl->isbreakable = isbreakable;
+  bl->nactvar = fs->nactvar;
+  bl->upval = 0;
+  bl->previous = fs->bl;
+  fs->bl = bl;
+  lua_assert(fs->freereg == fs->nactvar);
+}
+
+
+static void leaveblock (FuncState *fs) {
+  BlockCnt *bl = fs->bl;
+  fs->bl = bl->previous;
+  removevars(fs->ls, bl->nactvar);
+  if (bl->upval)
+    luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
+  /* a block either controls scope or breaks (never both) */
+  lua_assert(!bl->isbreakable || !bl->upval);
+  lua_assert(bl->nactvar == fs->nactvar);
+  fs->freereg = fs->nactvar;  /* free registers */
+  luaK_patchtohere(fs, bl->breaklist);
+}
+
+
+static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
+  FuncState *fs = ls->fs;
+  Proto *f = fs->f;
+  int oldsize = f->sizep;
+  int i;
+  luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
+                  MAXARG_Bx, "constant table overflow");
+  while (oldsize < f->sizep) f->p[oldsize++] = NULL;
+  f->p[fs->np++] = func->f;
+  luaC_objbarrier(ls->L, f, func->f);
+  init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1));
+  for (i=0; i<func->f->nups; i++) {
+    OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
+    luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0);
+  }
+}
+
+
+static void open_func (LexState *ls, FuncState *fs) {
+  lua_State *L = ls->L;
+  Proto *f = luaF_newproto(L);
+  fs->f = f;
+  fs->prev = ls->fs;  /* linked list of funcstates */
+  fs->ls = ls;
+  fs->L = L;
+  ls->fs = fs;
+  fs->pc = 0;
+  fs->lasttarget = -1;
+  fs->jpc = NO_JUMP;
+  fs->freereg = 0;
+  fs->nk = 0;
+  fs->np = 0;
+  fs->nlocvars = 0;
+  fs->nactvar = 0;
+  fs->bl = NULL;
+  f->source = ls->source;
+  f->maxstacksize = 2;  /* registers 0/1 are always valid */
+  fs->h = luaH_new(L, 0, 0);
+  /* anchor table of constants and prototype (to avoid being collected) */
+  sethvalue2s(L, L->top, fs->h);
+  incr_top(L);
+  setptvalue2s(L, L->top, f);
+  incr_top(L);
+}
+
+
+static void close_func (LexState *ls) {
+  lua_State *L = ls->L;
+  FuncState *fs = ls->fs;
+  Proto *f = fs->f;
+  removevars(ls, 0);
+  luaK_ret(fs, 0, 0);  /* final return */
+  luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
+  f->sizecode = fs->pc;
+  luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
+  f->sizelineinfo = fs->pc;
+  luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue);
+  f->sizek = fs->nk;
+  luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
+  f->sizep = fs->np;
+  luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar);
+  f->sizelocvars = fs->nlocvars;
+  luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *);
+  f->sizeupvalues = f->nups;
+  lua_assert(luaG_checkcode(f));
+  lua_assert(fs->bl == NULL);
+  ls->fs = fs->prev;
+  L->top -= 2;  /* remove table and prototype from the stack */
+  /* last token read was anchored in defunct function; must reanchor it */
+  if (fs) anchor_token(ls);
+}
+
+
+Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
+  struct LexState lexstate;
+  struct FuncState funcstate;
+  lexstate.buff = buff;
+  luaX_setinput(L, &lexstate, z, luaS_new(L, name));
+  open_func(&lexstate, &funcstate);
+  funcstate.f->is_vararg = VARARG_ISVARARG;  /* main func. is always vararg */
+  luaX_next(&lexstate);  /* read first token */
+  chunk(&lexstate);
+  check(&lexstate, TK_EOS);
+  close_func(&lexstate);
+  lua_assert(funcstate.prev == NULL);
+  lua_assert(funcstate.f->nups == 0);
+  lua_assert(lexstate.fs == NULL);
+  return funcstate.f;
+}
+
+
+
+/*============================================================*/
+/* GRAMMAR RULES */
+/*============================================================*/
+
+
+static void field (LexState *ls, expdesc *v) {
+  /* field -> ['.' | ':'] NAME */
+  FuncState *fs = ls->fs;
+  expdesc key;
+  luaK_exp2anyreg(fs, v);
+  luaX_next(ls);  /* skip the dot or colon */
+  checkname(ls, &key);
+  luaK_indexed(fs, v, &key);
+}
+
+
+static void yindex (LexState *ls, expdesc *v) {
+  /* index -> '[' expr ']' */
+  luaX_next(ls);  /* skip the '[' */
+  expr(ls, v);
+  luaK_exp2val(ls->fs, v);
+  checknext(ls, ']');
+}
+
+
+/*
+** {======================================================================
+** Rules for Constructors
+** =======================================================================
+*/
+
+
+struct ConsControl {
+  expdesc v;  /* last list item read */
+  expdesc *t;  /* table descriptor */
+  int nh;  /* total number of `record' elements */
+  int na;  /* total number of array elements */
+  int tostore;  /* number of array elements pending to be stored */
+};
+
+
+static void recfield (LexState *ls, struct ConsControl *cc) {
+  /* recfield -> (NAME | `['exp1`]') = exp1 */
+  FuncState *fs = ls->fs;
+  int reg = ls->fs->freereg;
+  expdesc key, val;
+  int rkkey;
+  if (ls->t.token == TK_NAME) {
+    luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
+    checkname(ls, &key);
+  }
+  else  /* ls->t.token == '[' */
+    yindex(ls, &key);
+  cc->nh++;
+  checknext(ls, '=');
+  rkkey = luaK_exp2RK(fs, &key);
+  expr(ls, &val);
+  luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
+  fs->freereg = reg;  /* free registers */
+}
+
+
+static void closelistfield (FuncState *fs, struct ConsControl *cc) {
+  if (cc->v.k == VVOID) return;  /* there is no list item */
+  luaK_exp2nextreg(fs, &cc->v);
+  cc->v.k = VVOID;
+  if (cc->tostore == LFIELDS_PER_FLUSH) {
+    luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore);  /* flush */
+    cc->tostore = 0;  /* no more items pending */
+  }
+}
+
+
+static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
+  if (cc->tostore == 0) return;
+  if (hasmultret(cc->v.k)) {
+    luaK_setmultret(fs, &cc->v);
+    luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET);
+    cc->na--;  /* do not count last expression (unknown number of elements) */
+  }
+  else {
+    if (cc->v.k != VVOID)
+      luaK_exp2nextreg(fs, &cc->v);
+    luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore);
+  }
+}
+
+
+static void listfield (LexState *ls, struct ConsControl *cc) {
+  expr(ls, &cc->v);
+  luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
+  cc->na++;
+  cc->tostore++;
+}
+
+
+static void constructor (LexState *ls, expdesc *t) {
+  /* constructor -> ?? */
+  FuncState *fs = ls->fs;
+  int line = ls->linenumber;
+  int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
+  struct ConsControl cc;
+  cc.na = cc.nh = cc.tostore = 0;
+  cc.t = t;
+  init_exp(t, VRELOCABLE, pc);
+  init_exp(&cc.v, VVOID, 0);  /* no value (yet) */
+  luaK_exp2nextreg(ls->fs, t);  /* fix it at stack top (for gc) */
+  checknext(ls, '{');
+  do {
+    lua_assert(cc.v.k == VVOID || cc.tostore > 0);
+    if (ls->t.token == '}') break;
+    closelistfield(fs, &cc);
+    switch(ls->t.token) {
+      case TK_NAME: {  /* may be listfields or recfields */
+        luaX_lookahead(ls);
+        if (ls->lookahead.token != '=')  /* expression? */
+          listfield(ls, &cc);
+        else
+          recfield(ls, &cc);
+        break;
+      }
+      case '[': {  /* constructor_item -> recfield */
+        recfield(ls, &cc);
+        break;
+      }
+      default: {  /* constructor_part -> listfield */
+        listfield(ls, &cc);
+        break;
+      }
+    }
+  } while (testnext(ls, ',') || testnext(ls, ';'));
+  check_match(ls, '}', '{', line);
+  lastlistfield(fs, &cc);
+  SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
+  SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh));  /* set initial table size */
+}
+
+/* }====================================================================== */
+
+
+
+static void parlist (LexState *ls) {
+  /* parlist -> [ param { `,' param } ] */
+  FuncState *fs = ls->fs;
+  Proto *f = fs->f;
+  int nparams = 0;
+  f->is_vararg = 0;
+  if (ls->t.token != ')') {  /* is `parlist' not empty? */
+    do {
+      switch (ls->t.token) {
+        case TK_NAME: {  /* param -> NAME */
+          new_localvar(ls, str_checkname(ls), nparams++);
+          break;
+        }
+        case TK_DOTS: {  /* param -> `...' */
+          luaX_next(ls);
+#if defined(LUA_COMPAT_VARARG)
+          /* use `arg' as default name */
+          new_localvarliteral(ls, "arg", nparams++);
+          f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG;
+#endif
+          f->is_vararg |= VARARG_ISVARARG;
+          break;
+        }
+        default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
+      }
+    } while (!f->is_vararg && testnext(ls, ','));
+  }
+  adjustlocalvars(ls, nparams);
+  f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG));
+  luaK_reserveregs(fs, fs->nactvar);  /* reserve register for parameters */
+}
+
+
+static void body (LexState *ls, expdesc *e, int needself, int line) {
+  /* body ->  `(' parlist `)' chunk END */
+  FuncState new_fs;
+  open_func(ls, &new_fs);
+  new_fs.f->linedefined = line;
+  checknext(ls, '(');
+  if (needself) {
+    new_localvarliteral(ls, "self", 0);
+    adjustlocalvars(ls, 1);
+  }
+  parlist(ls);
+  checknext(ls, ')');
+  chunk(ls);
+  new_fs.f->lastlinedefined = ls->linenumber;
+  check_match(ls, TK_END, TK_FUNCTION, line);
+  close_func(ls);
+  pushclosure(ls, &new_fs, e);
+}
+
+
+static int explist1 (LexState *ls, expdesc *v) {
+  /* explist1 -> expr { `,' expr } */
+  int n = 1;  /* at least one expression */
+  expr(ls, v);
+  while (testnext(ls, ',')) {
+    luaK_exp2nextreg(ls->fs, v);
+    expr(ls, v);
+    n++;
+  }
+  return n;
+}
+
+
+static void funcargs (LexState *ls, expdesc *f) {
+  FuncState *fs = ls->fs;
+  expdesc args;
+  int base, nparams;
+  int line = ls->linenumber;
+  switch (ls->t.token) {
+    case '(': {  /* funcargs -> `(' [ explist1 ] `)' */
+      if (line != ls->lastline)
+        luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
+      luaX_next(ls);
+      if (ls->t.token == ')')  /* arg list is empty? */
+        args.k = VVOID;
+      else {
+        explist1(ls, &args);
+        luaK_setmultret(fs, &args);
+      }
+      check_match(ls, ')', '(', line);
+      break;
+    }
+    case '{': {  /* funcargs -> constructor */
+      constructor(ls, &args);
+      break;
+    }
+    case TK_STRING: {  /* funcargs -> STRING */
+      codestring(ls, &args, ls->t.seminfo.ts);
+      luaX_next(ls);  /* must use `seminfo' before `next' */
+      break;
+    }
+    default: {
+      luaX_syntaxerror(ls, "function arguments expected");
+      return;
+    }
+  }
+  lua_assert(f->k == VNONRELOC);
+  base = f->u.s.info;  /* base register for call */
+  if (hasmultret(args.k))
+    nparams = LUA_MULTRET;  /* open call */
+  else {
+    if (args.k != VVOID)
+      luaK_exp2nextreg(fs, &args);  /* close last argument */
+    nparams = fs->freereg - (base+1);
+  }
+  init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
+  luaK_fixline(fs, line);
+  fs->freereg = base+1;  /* call remove function and arguments and leaves
+                            (unless changed) one result */
+}
+
+
+
+
+/*
+** {======================================================================
+** Expression parsing
+** =======================================================================
+*/
+
+
+static void prefixexp (LexState *ls, expdesc *v) {
+  /* prefixexp -> NAME | '(' expr ')' */
+  switch (ls->t.token) {
+    case '(': {
+      int line = ls->linenumber;
+      luaX_next(ls);
+      expr(ls, v);
+      check_match(ls, ')', '(', line);
+      luaK_dischargevars(ls->fs, v);
+      return;
+    }
+    case TK_NAME: {
+      singlevar(ls, v);
+      return;
+    }
+    default: {
+      luaX_syntaxerror(ls, "unexpected symbol");
+      return;
+    }
+  }
+}
+
+
+static void primaryexp (LexState *ls, expdesc *v) {
+  /* primaryexp ->
+        prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
+  FuncState *fs = ls->fs;
+  prefixexp(ls, v);
+  for (;;) {
+    switch (ls->t.token) {
+      case '.': {  /* field */
+        field(ls, v);
+        break;
+      }
+      case '[': {  /* `[' exp1 `]' */
+        expdesc key;
+        luaK_exp2anyreg(fs, v);
+        yindex(ls, &key);
+        luaK_indexed(fs, v, &key);
+        break;
+      }
+      case ':': {  /* `:' NAME funcargs */
+        expdesc key;
+        luaX_next(ls);
+        checkname(ls, &key);
+        luaK_self(fs, v, &key);
+        funcargs(ls, v);
+        break;
+      }
+      case '(': case TK_STRING: case '{': {  /* funcargs */
+        luaK_exp2nextreg(fs, v);
+        funcargs(ls, v);
+        break;
+      }
+      default: return;
+    }
+  }
+}
+
+
+static void simpleexp (LexState *ls, expdesc *v) {
+  /* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
+                  constructor | FUNCTION body | primaryexp */
+  switch (ls->t.token) {
+    case TK_NUMBER: {
+      init_exp(v, VKNUM, 0);
+      v->u.nval = ls->t.seminfo.r;
+      break;
+    }
+    case TK_STRING: {
+      codestring(ls, v, ls->t.seminfo.ts);
+      break;
+    }
+    case TK_NIL: {
+      init_exp(v, VNIL, 0);
+      break;
+    }
+    case TK_TRUE: {
+      init_exp(v, VTRUE, 0);
+      break;
+    }
+    case TK_FALSE: {
+      init_exp(v, VFALSE, 0);
+      break;
+    }
+    case TK_DOTS: {  /* vararg */
+      FuncState *fs = ls->fs;
+      check_condition(ls, fs->f->is_vararg,
+                      "cannot use " LUA_QL("...") " outside a vararg function");
+      fs->f->is_vararg &= ~VARARG_NEEDSARG;  /* don't need 'arg' */
+      init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
+      break;
+    }
+    case '{': {  /* constructor */
+      constructor(ls, v);
+      return;
+    }
+    case TK_FUNCTION: {
+      luaX_next(ls);
+      body(ls, v, 0, ls->linenumber);
+      return;
+    }
+    default: {
+      primaryexp(ls, v);
+      return;
+    }
+  }
+  luaX_next(ls);
+}
+
+
+static UnOpr getunopr (int op) {
+  switch (op) {
+    case TK_NOT: return OPR_NOT;
+    case '-': return OPR_MINUS;
+    case '#': return OPR_LEN;
+    default: return OPR_NOUNOPR;
+  }
+}
+
+
+static BinOpr getbinopr (int op) {
+  switch (op) {
+    case '+': return OPR_ADD;
+    case '-': return OPR_SUB;
+    case '*': return OPR_MUL;
+    case '/': return OPR_DIV;
+    case '%': return OPR_MOD;
+    case '^': return OPR_POW;
+    case TK_CONCAT: return OPR_CONCAT;
+    case TK_NE: return OPR_NE;
+    case TK_EQ: return OPR_EQ;
+    case '<': return OPR_LT;
+    case TK_LE: return OPR_LE;
+    case '>': return OPR_GT;
+    case TK_GE: return OPR_GE;
+    case TK_AND: return OPR_AND;
+    case TK_OR: return OPR_OR;
+    default: return OPR_NOBINOPR;
+  }
+}
+
+
+static const struct {
+  lu_byte left;  /* left priority for each binary operator */
+  lu_byte right; /* right priority */
+} priority[] = {  /* ORDER OPR */
+   {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7},  /* `+' `-' `/' `%' */
+   {10, 9}, {5, 4},                 /* power and concat (right associative) */
+   {3, 3}, {3, 3},                  /* equality and inequality */
+   {3, 3}, {3, 3}, {3, 3}, {3, 3},  /* order */
+   {2, 2}, {1, 1}                   /* logical (and/or) */
+};
+
+#define UNARY_PRIORITY	8  /* priority for unary operators */
+
+
+/*
+** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
+** where `binop' is any binary operator with a priority higher than `limit'
+*/
+static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
+  BinOpr op;
+  UnOpr uop;
+  enterlevel(ls);
+  uop = getunopr(ls->t.token);
+  if (uop != OPR_NOUNOPR) {
+    luaX_next(ls);
+    subexpr(ls, v, UNARY_PRIORITY);
+    luaK_prefix(ls->fs, uop, v);
+  }
+  else simpleexp(ls, v);
+  /* expand while operators have priorities higher than `limit' */
+  op = getbinopr(ls->t.token);
+  while (op != OPR_NOBINOPR && priority[op].left > limit) {
+    expdesc v2;
+    BinOpr nextop;
+    luaX_next(ls);
+    luaK_infix(ls->fs, op, v);
+    /* read sub-expression with higher priority */
+    nextop = subexpr(ls, &v2, priority[op].right);
+    luaK_posfix(ls->fs, op, v, &v2);
+    op = nextop;
+  }
+  leavelevel(ls);
+  return op;  /* return first untreated operator */
+}
+
+
+static void expr (LexState *ls, expdesc *v) {
+  subexpr(ls, v, 0);
+}
+
+/* }==================================================================== */
+
+
+
+/*
+** {======================================================================
+** Rules for Statements
+** =======================================================================
+*/
+
+
+static int block_follow (int token) {
+  switch (token) {
+    case TK_ELSE: case TK_ELSEIF: case TK_END:
+    case TK_UNTIL: case TK_EOS:
+      return 1;
+    default: return 0;
+  }
+}
+
+
+static void block (LexState *ls) {
+  /* block -> chunk */
+  FuncState *fs = ls->fs;
+  BlockCnt bl;
+  enterblock(fs, &bl, 0);
+  chunk(ls);
+  lua_assert(bl.breaklist == NO_JUMP);
+  leaveblock(fs);
+}
+
+
+/*
+** structure to chain all variables in the left-hand side of an
+** assignment
+*/
+struct LHS_assign {
+  struct LHS_assign *prev;
+  expdesc v;  /* variable (global, local, upvalue, or indexed) */
+};
+
+
+/*
+** check whether, in an assignment to a local variable, the local variable
+** is needed in a previous assignment (to a table). If so, save original
+** local value in a safe place and use this safe copy in the previous
+** assignment.
+*/
+static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
+  FuncState *fs = ls->fs;
+  int extra = fs->freereg;  /* eventual position to save local variable */
+  int conflict = 0;
+  for (; lh; lh = lh->prev) {
+    if (lh->v.k == VINDEXED) {
+      if (lh->v.u.s.info == v->u.s.info) {  /* conflict? */
+        conflict = 1;
+        lh->v.u.s.info = extra;  /* previous assignment will use safe copy */
+      }
+      if (lh->v.u.s.aux == v->u.s.info) {  /* conflict? */
+        conflict = 1;
+        lh->v.u.s.aux = extra;  /* previous assignment will use safe copy */
+      }
+    }
+  }
+  if (conflict) {
+    luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0);  /* make copy */
+    luaK_reserveregs(fs, 1);
+  }
+}
+
+
+static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
+  expdesc e;
+  check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
+                      "syntax error");
+  if (testnext(ls, ',')) {  /* assignment -> `,' primaryexp assignment */
+    struct LHS_assign nv;
+    nv.prev = lh;
+    primaryexp(ls, &nv.v);
+    if (nv.v.k == VLOCAL)
+      check_conflict(ls, lh, &nv.v);
+    luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
+                    "variables in assignment");
+    assignment(ls, &nv, nvars+1);
+  }
+  else {  /* assignment -> `=' explist1 */
+    int nexps;
+    checknext(ls, '=');
+    nexps = explist1(ls, &e);
+    if (nexps != nvars) {
+      adjust_assign(ls, nvars, nexps, &e);
+      if (nexps > nvars)
+        ls->fs->freereg -= nexps - nvars;  /* remove extra values */
+    }
+    else {
+      luaK_setoneret(ls->fs, &e);  /* close last expression */
+      luaK_storevar(ls->fs, &lh->v, &e);
+      return;  /* avoid default */
+    }
+  }
+  init_exp(&e, VNONRELOC, ls->fs->freereg-1);  /* default assignment */
+  luaK_storevar(ls->fs, &lh->v, &e);
+}
+
+
+static int cond (LexState *ls) {
+  /* cond -> exp */
+  expdesc v;
+  expr(ls, &v);  /* read condition */
+  if (v.k == VNIL) v.k = VFALSE;  /* `falses' are all equal here */
+  luaK_goiftrue(ls->fs, &v);
+  return v.f;
+}
+
+
+static void breakstat (LexState *ls) {
+  FuncState *fs = ls->fs;
+  BlockCnt *bl = fs->bl;
+  int upval = 0;
+  while (bl && !bl->isbreakable) {
+    upval |= bl->upval;
+    bl = bl->previous;
+  }
+  if (!bl)
+    luaX_syntaxerror(ls, "no loop to break");
+  if (upval)
+    luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
+  luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
+}
+
+
+static void whilestat (LexState *ls, int line) {
+  /* whilestat -> WHILE cond DO block END */
+  FuncState *fs = ls->fs;
+  int whileinit;
+  int condexit;
+  BlockCnt bl;
+  luaX_next(ls);  /* skip WHILE */
+  whileinit = luaK_getlabel(fs);
+  condexit = cond(ls);
+  enterblock(fs, &bl, 1);
+  checknext(ls, TK_DO);
+  block(ls);
+  luaK_patchlist(fs, luaK_jump(fs), whileinit);
+  check_match(ls, TK_END, TK_WHILE, line);
+  leaveblock(fs);
+  luaK_patchtohere(fs, condexit);  /* false conditions finish the loop */
+}
+
+
+static void repeatstat (LexState *ls, int line) {
+  /* repeatstat -> REPEAT block UNTIL cond */
+  int condexit;
+  FuncState *fs = ls->fs;
+  int repeat_init = luaK_getlabel(fs);
+  BlockCnt bl1, bl2;
+  enterblock(fs, &bl1, 1);  /* loop block */
+  enterblock(fs, &bl2, 0);  /* scope block */
+  luaX_next(ls);  /* skip REPEAT */
+  chunk(ls);
+  check_match(ls, TK_UNTIL, TK_REPEAT, line);
+  condexit = cond(ls);  /* read condition (inside scope block) */
+  if (!bl2.upval) {  /* no upvalues? */
+    leaveblock(fs);  /* finish scope */
+    luaK_patchlist(ls->fs, condexit, repeat_init);  /* close the loop */
+  }
+  else {  /* complete semantics when there are upvalues */
+    breakstat(ls);  /* if condition then break */
+    luaK_patchtohere(ls->fs, condexit);  /* else... */
+    leaveblock(fs);  /* finish scope... */
+    luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init);  /* and repeat */
+  }
+  leaveblock(fs);  /* finish loop */
+}
+
+
+static int exp1 (LexState *ls) {
+  expdesc e;
+  int k;
+  expr(ls, &e);
+  k = e.k;
+  luaK_exp2nextreg(ls->fs, &e);
+  return k;
+}
+
+
+static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
+  /* forbody -> DO block */
+  BlockCnt bl;
+  FuncState *fs = ls->fs;
+  int prep, endfor;
+  adjustlocalvars(ls, 3);  /* control variables */
+  checknext(ls, TK_DO);
+  prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
+  enterblock(fs, &bl, 0);  /* scope for declared variables */
+  adjustlocalvars(ls, nvars);
+  luaK_reserveregs(fs, nvars);
+  block(ls);
+  leaveblock(fs);  /* end of scope for declared variables */
+  luaK_patchtohere(fs, prep);
+  endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) :
+                     luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars);
+  luaK_fixline(fs, line);  /* pretend that `OP_FOR' starts the loop */
+  luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1);
+}
+
+
+static void fornum (LexState *ls, TString *varname, int line) {
+  /* fornum -> NAME = exp1,exp1[,exp1] forbody */
+  FuncState *fs = ls->fs;
+  int base = fs->freereg;
+  new_localvarliteral(ls, "(for index)", 0);
+  new_localvarliteral(ls, "(for limit)", 1);
+  new_localvarliteral(ls, "(for step)", 2);
+  new_localvar(ls, varname, 3);
+  checknext(ls, '=');
+  exp1(ls);  /* initial value */
+  checknext(ls, ',');
+  exp1(ls);  /* limit */
+  if (testnext(ls, ','))
+    exp1(ls);  /* optional step */
+  else {  /* default step = 1 */
+    luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
+    luaK_reserveregs(fs, 1);
+  }
+  forbody(ls, base, line, 1, 1);
+}
+
+
+static void forlist (LexState *ls, TString *indexname) {
+  /* forlist -> NAME {,NAME} IN explist1 forbody */
+  FuncState *fs = ls->fs;
+  expdesc e;
+  int nvars = 0;
+  int line;
+  int base = fs->freereg;
+  /* create control variables */
+  new_localvarliteral(ls, "(for generator)", nvars++);
+  new_localvarliteral(ls, "(for state)", nvars++);
+  new_localvarliteral(ls, "(for control)", nvars++);
+  /* create declared variables */
+  new_localvar(ls, indexname, nvars++);
+  while (testnext(ls, ','))
+    new_localvar(ls, str_checkname(ls), nvars++);
+  checknext(ls, TK_IN);
+  line = ls->linenumber;
+  adjust_assign(ls, 3, explist1(ls, &e), &e);
+  luaK_checkstack(fs, 3);  /* extra space to call generator */
+  forbody(ls, base, line, nvars - 3, 0);
+}
+
+
+static void forstat (LexState *ls, int line) {
+  /* forstat -> FOR (fornum | forlist) END */
+  FuncState *fs = ls->fs;
+  TString *varname;
+  BlockCnt bl;
+  enterblock(fs, &bl, 1);  /* scope for loop and control variables */
+  luaX_next(ls);  /* skip `for' */
+  varname = str_checkname(ls);  /* first variable name */
+  switch (ls->t.token) {
+    case '=': fornum(ls, varname, line); break;
+    case ',': case TK_IN: forlist(ls, varname); break;
+    default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
+  }
+  check_match(ls, TK_END, TK_FOR, line);
+  leaveblock(fs);  /* loop scope (`break' jumps to this point) */
+}
+
+
+static int test_then_block (LexState *ls) {
+  /* test_then_block -> [IF | ELSEIF] cond THEN block */
+  int condexit;
+  luaX_next(ls);  /* skip IF or ELSEIF */
+  condexit = cond(ls);
+  checknext(ls, TK_THEN);
+  block(ls);  /* `then' part */
+  return condexit;
+}
+
+
+static void ifstat (LexState *ls, int line) {
+  /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
+  FuncState *fs = ls->fs;
+  int flist;
+  int escapelist = NO_JUMP;
+  flist = test_then_block(ls);  /* IF cond THEN block */
+  while (ls->t.token == TK_ELSEIF) {
+    luaK_concat(fs, &escapelist, luaK_jump(fs));
+    luaK_patchtohere(fs, flist);
+    flist = test_then_block(ls);  /* ELSEIF cond THEN block */
+  }
+  if (ls->t.token == TK_ELSE) {
+    luaK_concat(fs, &escapelist, luaK_jump(fs));
+    luaK_patchtohere(fs, flist);
+    luaX_next(ls);  /* skip ELSE (after patch, for correct line info) */
+    block(ls);  /* `else' part */
+  }
+  else
+    luaK_concat(fs, &escapelist, flist);
+  luaK_patchtohere(fs, escapelist);
+  check_match(ls, TK_END, TK_IF, line);
+}
+
+
+static void localfunc (LexState *ls) {
+  expdesc v, b;
+  FuncState *fs = ls->fs;
+  new_localvar(ls, str_checkname(ls), 0);
+  init_exp(&v, VLOCAL, fs->freereg);
+  luaK_reserveregs(fs, 1);
+  adjustlocalvars(ls, 1);
+  body(ls, &b, 0, ls->linenumber);
+  luaK_storevar(fs, &v, &b);
+  /* debug information will only see the variable after this point! */
+  getlocvar(fs, fs->nactvar - 1).startpc = fs->pc;
+}
+
+
+static void localstat (LexState *ls) {
+  /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
+  int nvars = 0;
+  int nexps;
+  expdesc e;
+  do {
+    new_localvar(ls, str_checkname(ls), nvars++);
+  } while (testnext(ls, ','));
+  if (testnext(ls, '='))
+    nexps = explist1(ls, &e);
+  else {
+    e.k = VVOID;
+    nexps = 0;
+  }
+  adjust_assign(ls, nvars, nexps, &e);
+  adjustlocalvars(ls, nvars);
+}
+
+
+static int funcname (LexState *ls, expdesc *v) {
+  /* funcname -> NAME {field} [`:' NAME] */
+  int needself = 0;
+  singlevar(ls, v);
+  while (ls->t.token == '.')
+    field(ls, v);
+  if (ls->t.token == ':') {
+    needself = 1;
+    field(ls, v);
+  }
+  return needself;
+}
+
+
+static void funcstat (LexState *ls, int line) {
+  /* funcstat -> FUNCTION funcname body */
+  int needself;
+  expdesc v, b;
+  luaX_next(ls);  /* skip FUNCTION */
+  needself = funcname(ls, &v);
+  body(ls, &b, needself, line);
+  luaK_storevar(ls->fs, &v, &b);
+  luaK_fixline(ls->fs, line);  /* definition `happens' in the first line */
+}
+
+
+static void exprstat (LexState *ls) {
+  /* stat -> func | assignment */
+  FuncState *fs = ls->fs;
+  struct LHS_assign v;
+  primaryexp(ls, &v.v);
+  if (v.v.k == VCALL)  /* stat -> func */
+    SETARG_C(getcode(fs, &v.v), 1);  /* call statement uses no results */
+  else {  /* stat -> assignment */
+    v.prev = NULL;
+    assignment(ls, &v, 1);
+  }
+}
+
+
+static void retstat (LexState *ls) {
+  /* stat -> RETURN explist */
+  FuncState *fs = ls->fs;
+  expdesc e;
+  int first, nret;  /* registers with returned values */
+  luaX_next(ls);  /* skip RETURN */
+  if (block_follow(ls->t.token) || ls->t.token == ';')
+    first = nret = 0;  /* return no values */
+  else {
+    nret = explist1(ls, &e);  /* optional return values */
+    if (hasmultret(e.k)) {
+      luaK_setmultret(fs, &e);
+      if (e.k == VCALL && nret == 1) {  /* tail call? */
+        SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
+        lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
+      }
+      first = fs->nactvar;
+      nret = LUA_MULTRET;  /* return all values */
+    }
+    else {
+      if (nret == 1)  /* only one single value? */
+        first = luaK_exp2anyreg(fs, &e);
+      else {
+        luaK_exp2nextreg(fs, &e);  /* values must go to the `stack' */
+        first = fs->nactvar;  /* return all `active' values */
+        lua_assert(nret == fs->freereg - first);
+      }
+    }
+  }
+  luaK_ret(fs, first, nret);
+}
+
+
+static int statement (LexState *ls) {
+  int line = ls->linenumber;  /* may be needed for error messages */
+  switch (ls->t.token) {
+    case TK_IF: {  /* stat -> ifstat */
+      ifstat(ls, line);
+      return 0;
+    }
+    case TK_WHILE: {  /* stat -> whilestat */
+      whilestat(ls, line);
+      return 0;
+    }
+    case TK_DO: {  /* stat -> DO block END */
+      luaX_next(ls);  /* skip DO */
+      block(ls);
+      check_match(ls, TK_END, TK_DO, line);
+      return 0;
+    }
+    case TK_FOR: {  /* stat -> forstat */
+      forstat(ls, line);
+      return 0;
+    }
+    case TK_REPEAT: {  /* stat -> repeatstat */
+      repeatstat(ls, line);
+      return 0;
+    }
+    case TK_FUNCTION: {
+      funcstat(ls, line);  /* stat -> funcstat */
+      return 0;
+    }
+    case TK_LOCAL: {  /* stat -> localstat */
+      luaX_next(ls);  /* skip LOCAL */
+      if (testnext(ls, TK_FUNCTION))  /* local function? */
+        localfunc(ls);
+      else
+        localstat(ls);
+      return 0;
+    }
+    case TK_RETURN: {  /* stat -> retstat */
+      retstat(ls);
+      return 1;  /* must be last statement */
+    }
+    case TK_BREAK: {  /* stat -> breakstat */
+      luaX_next(ls);  /* skip BREAK */
+      breakstat(ls);
+      return 1;  /* must be last statement */
+    }
+    default: {
+      exprstat(ls);
+      return 0;  /* to avoid warnings */
+    }
+  }
+}
+
+
+static void chunk (LexState *ls) {
+  /* chunk -> { stat [`;'] } */
+  int islast = 0;
+  enterlevel(ls);
+  while (!islast && !block_follow(ls->t.token)) {
+    islast = statement(ls);
+    testnext(ls, ';');
+    lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
+               ls->fs->freereg >= ls->fs->nactvar);
+    ls->fs->freereg = ls->fs->nactvar;  /* free registers */
+  }
+  leavelevel(ls);
+}
+
+/* }====================================================================== */
Index: /code/branches/physics/src/lua/lparser.h
===================================================================
--- /code/branches/physics/src/lua/lparser.h	(revision 2122)
+++ /code/branches/physics/src/lua/lparser.h	(revision 2122)
@@ -0,0 +1,82 @@
+/*
+** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
+** Lua Parser
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lparser_h
+#define lparser_h
+
+#include "llimits.h"
+#include "lobject.h"
+#include "lzio.h"
+
+
+/*
+** Expression descriptor
+*/
+
+typedef enum {
+  VVOID,	/* no value */
+  VNIL,
+  VTRUE,
+  VFALSE,
+  VK,		/* info = index of constant in `k' */
+  VKNUM,	/* nval = numerical value */
+  VLOCAL,	/* info = local register */
+  VUPVAL,       /* info = index of upvalue in `upvalues' */
+  VGLOBAL,	/* info = index of table; aux = index of global name in `k' */
+  VINDEXED,	/* info = table register; aux = index register (or `k') */
+  VJMP,		/* info = instruction pc */
+  VRELOCABLE,	/* info = instruction pc */
+  VNONRELOC,	/* info = result register */
+  VCALL,	/* info = instruction pc */
+  VVARARG	/* info = instruction pc */
+} expkind;
+
+typedef struct expdesc {
+  expkind k;
+  union {
+    struct { int info, aux; } s;
+    lua_Number nval;
+  } u;
+  int t;  /* patch list of `exit when true' */
+  int f;  /* patch list of `exit when false' */
+} expdesc;
+
+
+typedef struct upvaldesc {
+  lu_byte k;
+  lu_byte info;
+} upvaldesc;
+
+
+struct BlockCnt;  /* defined in lparser.c */
+
+
+/* state needed to generate code for a given function */
+typedef struct FuncState {
+  Proto *f;  /* current function header */
+  Table *h;  /* table to find (and reuse) elements in `k' */
+  struct FuncState *prev;  /* enclosing function */
+  struct LexState *ls;  /* lexical state */
+  struct lua_State *L;  /* copy of the Lua state */
+  struct BlockCnt *bl;  /* chain of current blocks */
+  int pc;  /* next position to code (equivalent to `ncode') */
+  int lasttarget;   /* `pc' of last `jump target' */
+  int jpc;  /* list of pending jumps to `pc' */
+  int freereg;  /* first free register */
+  int nk;  /* number of elements in `k' */
+  int np;  /* number of elements in `p' */
+  short nlocvars;  /* number of elements in `locvars' */
+  lu_byte nactvar;  /* number of active local variables */
+  upvaldesc upvalues[LUAI_MAXUPVALUES];  /* upvalues */
+  unsigned short actvar[LUAI_MAXVARS];  /* declared-variable stack */
+} FuncState;
+
+
+LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
+                                            const char *name);
+
+
+#endif
Index: /code/branches/physics/src/lua/lstate.c
===================================================================
--- /code/branches/physics/src/lua/lstate.c	(revision 2122)
+++ /code/branches/physics/src/lua/lstate.c	(revision 2122)
@@ -0,0 +1,214 @@
+/*
+** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
+** Global State
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stddef.h>
+
+#define lstate_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "llex.h"
+#include "lmem.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+
+
+#define state_size(x)	(sizeof(x) + LUAI_EXTRASPACE)
+#define fromstate(l)	(cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
+#define tostate(l)   (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
+
+
+/*
+** Main thread combines a thread state and the global state
+*/
+typedef struct LG {
+  lua_State l;
+  global_State g;
+} LG;
+  
+
+
+static void stack_init (lua_State *L1, lua_State *L) {
+  /* initialize CallInfo array */
+  L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
+  L1->ci = L1->base_ci;
+  L1->size_ci = BASIC_CI_SIZE;
+  L1->end_ci = L1->base_ci + L1->size_ci - 1;
+  /* initialize stack array */
+  L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue);
+  L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
+  L1->top = L1->stack;
+  L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
+  /* initialize first ci */
+  L1->ci->func = L1->top;
+  setnilvalue(L1->top++);  /* `function' entry for this `ci' */
+  L1->base = L1->ci->base = L1->top;
+  L1->ci->top = L1->top + LUA_MINSTACK;
+}
+
+
+static void freestack (lua_State *L, lua_State *L1) {
+  luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
+  luaM_freearray(L, L1->stack, L1->stacksize, TValue);
+}
+
+
+/*
+** open parts that may cause memory-allocation errors
+*/
+static void f_luaopen (lua_State *L, void *ud) {
+  global_State *g = G(L);
+  UNUSED(ud);
+  stack_init(L, L);  /* init stack */
+  sethvalue(L, gt(L), luaH_new(L, 0, 2));  /* table of globals */
+  sethvalue(L, registry(L), luaH_new(L, 0, 2));  /* registry */
+  luaS_resize(L, MINSTRTABSIZE);  /* initial size of string table */
+  luaT_init(L);
+  luaX_init(L);
+  luaS_fix(luaS_newliteral(L, MEMERRMSG));
+  g->GCthreshold = 4*g->totalbytes;
+}
+
+
+static void preinit_state (lua_State *L, global_State *g) {
+  G(L) = g;
+  L->stack = NULL;
+  L->stacksize = 0;
+  L->errorJmp = NULL;
+  L->hook = NULL;
+  L->hookmask = 0;
+  L->basehookcount = 0;
+  L->allowhook = 1;
+  resethookcount(L);
+  L->openupval = NULL;
+  L->size_ci = 0;
+  L->nCcalls = L->baseCcalls = 0;
+  L->status = 0;
+  L->base_ci = L->ci = NULL;
+  L->savedpc = NULL;
+  L->errfunc = 0;
+  setnilvalue(gt(L));
+}
+
+
+static void close_state (lua_State *L) {
+  global_State *g = G(L);
+  luaF_close(L, L->stack);  /* close all upvalues for this thread */
+  luaC_freeall(L);  /* collect all objects */
+  lua_assert(g->rootgc == obj2gco(L));
+  lua_assert(g->strt.nuse == 0);
+  luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
+  luaZ_freebuffer(L, &g->buff);
+  freestack(L, L);
+  lua_assert(g->totalbytes == sizeof(LG));
+  (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0);
+}
+
+
+lua_State *luaE_newthread (lua_State *L) {
+  lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
+  luaC_link(L, obj2gco(L1), LUA_TTHREAD);
+  preinit_state(L1, G(L));
+  stack_init(L1, L);  /* init stack */
+  setobj2n(L, gt(L1), gt(L));  /* share table of globals */
+  L1->hookmask = L->hookmask;
+  L1->basehookcount = L->basehookcount;
+  L1->hook = L->hook;
+  resethookcount(L1);
+  lua_assert(iswhite(obj2gco(L1)));
+  return L1;
+}
+
+
+void luaE_freethread (lua_State *L, lua_State *L1) {
+  luaF_close(L1, L1->stack);  /* close all upvalues for this thread */
+  lua_assert(L1->openupval == NULL);
+  luai_userstatefree(L1);
+  freestack(L, L1);
+  luaM_freemem(L, fromstate(L1), state_size(lua_State));
+}
+
+
+LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
+  int i;
+  lua_State *L;
+  global_State *g;
+  void *l = (*f)(ud, NULL, 0, state_size(LG));
+  if (l == NULL) return NULL;
+  L = tostate(l);
+  g = &((LG *)L)->g;
+  L->next = NULL;
+  L->tt = LUA_TTHREAD;
+  g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
+  L->marked = luaC_white(g);
+  set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
+  preinit_state(L, g);
+  g->frealloc = f;
+  g->ud = ud;
+  g->mainthread = L;
+  g->uvhead.u.l.prev = &g->uvhead;
+  g->uvhead.u.l.next = &g->uvhead;
+  g->GCthreshold = 0;  /* mark it as unfinished state */
+  g->strt.size = 0;
+  g->strt.nuse = 0;
+  g->strt.hash = NULL;
+  setnilvalue(registry(L));
+  luaZ_initbuffer(L, &g->buff);
+  g->panic = NULL;
+  g->gcstate = GCSpause;
+  g->rootgc = obj2gco(L);
+  g->sweepstrgc = 0;
+  g->sweepgc = &g->rootgc;
+  g->gray = NULL;
+  g->grayagain = NULL;
+  g->weak = NULL;
+  g->tmudata = NULL;
+  g->totalbytes = sizeof(LG);
+  g->gcpause = LUAI_GCPAUSE;
+  g->gcstepmul = LUAI_GCMUL;
+  g->gcdept = 0;
+  for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
+  if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
+    /* memory allocation error: free partial state */
+    close_state(L);
+    L = NULL;
+  }
+  else
+    luai_userstateopen(L);
+  return L;
+}
+
+
+static void callallgcTM (lua_State *L, void *ud) {
+  UNUSED(ud);
+  luaC_callGCTM(L);  /* call GC metamethods for all udata */
+}
+
+
+LUA_API void lua_close (lua_State *L) {
+  L = G(L)->mainthread;  /* only the main thread can be closed */
+  lua_lock(L);
+  luaF_close(L, L->stack);  /* close all upvalues for this thread */
+  luaC_separateudata(L, 1);  /* separate udata that have GC metamethods */
+  L->errfunc = 0;  /* no error function during GC metamethods */
+  do {  /* repeat until no more errors */
+    L->ci = L->base_ci;
+    L->base = L->top = L->ci->base;
+    L->nCcalls = L->baseCcalls = 0;
+  } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
+  lua_assert(G(L)->tmudata == NULL);
+  luai_userstateclose(L);
+  close_state(L);
+}
+
Index: /code/branches/physics/src/lua/lstate.h
===================================================================
--- /code/branches/physics/src/lua/lstate.h	(revision 2122)
+++ /code/branches/physics/src/lua/lstate.h	(revision 2122)
@@ -0,0 +1,169 @@
+/*
+** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
+** Global State
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lstate_h
+#define lstate_h
+
+#include "lua.h"
+
+#include "lobject.h"
+#include "ltm.h"
+#include "lzio.h"
+
+
+
+struct lua_longjmp;  /* defined in ldo.c */
+
+
+/* table of globals */
+#define gt(L)	(&L->l_gt)
+
+/* registry */
+#define registry(L)	(&G(L)->l_registry)
+
+
+/* extra stack space to handle TM calls and some other extras */
+#define EXTRA_STACK   5
+
+
+#define BASIC_CI_SIZE           8
+
+#define BASIC_STACK_SIZE        (2*LUA_MINSTACK)
+
+
+
+typedef struct stringtable {
+  GCObject **hash;
+  lu_int32 nuse;  /* number of elements */
+  int size;
+} stringtable;
+
+
+/*
+** informations about a call
+*/
+typedef struct CallInfo {
+  StkId base;  /* base for this function */
+  StkId func;  /* function index in the stack */
+  StkId	top;  /* top for this function */
+  const Instruction *savedpc;
+  int nresults;  /* expected number of results from this function */
+  int tailcalls;  /* number of tail calls lost under this entry */
+} CallInfo;
+
+
+
+#define curr_func(L)	(clvalue(L->ci->func))
+#define ci_func(ci)	(clvalue((ci)->func))
+#define f_isLua(ci)	(!ci_func(ci)->c.isC)
+#define isLua(ci)	(ttisfunction((ci)->func) && f_isLua(ci))
+
+
+/*
+** `global state', shared by all threads of this state
+*/
+typedef struct global_State {
+  stringtable strt;  /* hash table for strings */
+  lua_Alloc frealloc;  /* function to reallocate memory */
+  void *ud;         /* auxiliary data to `frealloc' */
+  lu_byte currentwhite;
+  lu_byte gcstate;  /* state of garbage collector */
+  int sweepstrgc;  /* position of sweep in `strt' */
+  GCObject *rootgc;  /* list of all collectable objects */
+  GCObject **sweepgc;  /* position of sweep in `rootgc' */
+  GCObject *gray;  /* list of gray objects */
+  GCObject *grayagain;  /* list of objects to be traversed atomically */
+  GCObject *weak;  /* list of weak tables (to be cleared) */
+  GCObject *tmudata;  /* last element of list of userdata to be GC */
+  Mbuffer buff;  /* temporary buffer for string concatentation */
+  lu_mem GCthreshold;
+  lu_mem totalbytes;  /* number of bytes currently allocated */
+  lu_mem estimate;  /* an estimate of number of bytes actually in use */
+  lu_mem gcdept;  /* how much GC is `behind schedule' */
+  int gcpause;  /* size of pause between successive GCs */
+  int gcstepmul;  /* GC `granularity' */
+  lua_CFunction panic;  /* to be called in unprotected errors */
+  TValue l_registry;
+  struct lua_State *mainthread;
+  UpVal uvhead;  /* head of double-linked list of all open upvalues */
+  struct Table *mt[NUM_TAGS];  /* metatables for basic types */
+  TString *tmname[TM_N];  /* array with tag-method names */
+} global_State;
+
+
+/*
+** `per thread' state
+*/
+struct lua_State {
+  CommonHeader;
+  lu_byte status;
+  StkId top;  /* first free slot in the stack */
+  StkId base;  /* base of current function */
+  global_State *l_G;
+  CallInfo *ci;  /* call info for current function */
+  const Instruction *savedpc;  /* `savedpc' of current function */
+  StkId stack_last;  /* last free slot in the stack */
+  StkId stack;  /* stack base */
+  CallInfo *end_ci;  /* points after end of ci array*/
+  CallInfo *base_ci;  /* array of CallInfo's */
+  int stacksize;
+  int size_ci;  /* size of array `base_ci' */
+  unsigned short nCcalls;  /* number of nested C calls */
+  unsigned short baseCcalls;  /* nested C calls when resuming coroutine */
+  lu_byte hookmask;
+  lu_byte allowhook;
+  int basehookcount;
+  int hookcount;
+  lua_Hook hook;
+  TValue l_gt;  /* table of globals */
+  TValue env;  /* temporary place for environments */
+  GCObject *openupval;  /* list of open upvalues in this stack */
+  GCObject *gclist;
+  struct lua_longjmp *errorJmp;  /* current error recover point */
+  ptrdiff_t errfunc;  /* current error handling function (stack index) */
+};
+
+
+#define G(L)	(L->l_G)
+
+
+/*
+** Union of all collectable objects
+*/
+union GCObject {
+  GCheader gch;
+  union TString ts;
+  union Udata u;
+  union Closure cl;
+  struct Table h;
+  struct Proto p;
+  struct UpVal uv;
+  struct lua_State th;  /* thread */
+};
+
+
+/* macros to convert a GCObject into a specific value */
+#define rawgco2ts(o)	check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
+#define gco2ts(o)	(&rawgco2ts(o)->tsv)
+#define rawgco2u(o)	check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
+#define gco2u(o)	(&rawgco2u(o)->uv)
+#define gco2cl(o)	check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
+#define gco2h(o)	check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
+#define gco2p(o)	check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
+#define gco2uv(o)	check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
+#define ngcotouv(o) \
+	check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
+#define gco2th(o)	check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
+
+/* macro to convert any Lua object into a GCObject */
+#define obj2gco(v)	(cast(GCObject *, (v)))
+
+
+LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
+LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
+
+#endif
+
Index: /code/branches/physics/src/lua/lstring.c
===================================================================
--- /code/branches/physics/src/lua/lstring.c	(revision 2122)
+++ /code/branches/physics/src/lua/lstring.c	(revision 2122)
@@ -0,0 +1,111 @@
+/*
+** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
+** String table (keeps all strings handled by Lua)
+** See Copyright Notice in lua.h
+*/
+
+
+#include <string.h>
+
+#define lstring_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+
+
+
+void luaS_resize (lua_State *L, int newsize) {
+  GCObject **newhash;
+  stringtable *tb;
+  int i;
+  if (G(L)->gcstate == GCSsweepstring)
+    return;  /* cannot resize during GC traverse */
+  newhash = luaM_newvector(L, newsize, GCObject *);
+  tb = &G(L)->strt;
+  for (i=0; i<newsize; i++) newhash[i] = NULL;
+  /* rehash */
+  for (i=0; i<tb->size; i++) {
+    GCObject *p = tb->hash[i];
+    while (p) {  /* for each node in the list */
+      GCObject *next = p->gch.next;  /* save next */
+      unsigned int h = gco2ts(p)->hash;
+      int h1 = lmod(h, newsize);  /* new position */
+      lua_assert(cast_int(h%newsize) == lmod(h, newsize));
+      p->gch.next = newhash[h1];  /* chain it */
+      newhash[h1] = p;
+      p = next;
+    }
+  }
+  luaM_freearray(L, tb->hash, tb->size, TString *);
+  tb->size = newsize;
+  tb->hash = newhash;
+}
+
+
+static TString *newlstr (lua_State *L, const char *str, size_t l,
+                                       unsigned int h) {
+  TString *ts;
+  stringtable *tb;
+  if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
+    luaM_toobig(L);
+  ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
+  ts->tsv.len = l;
+  ts->tsv.hash = h;
+  ts->tsv.marked = luaC_white(G(L));
+  ts->tsv.tt = LUA_TSTRING;
+  ts->tsv.reserved = 0;
+  memcpy(ts+1, str, l*sizeof(char));
+  ((char *)(ts+1))[l] = '\0';  /* ending 0 */
+  tb = &G(L)->strt;
+  h = lmod(h, tb->size);
+  ts->tsv.next = tb->hash[h];  /* chain new entry */
+  tb->hash[h] = obj2gco(ts);
+  tb->nuse++;
+  if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
+    luaS_resize(L, tb->size*2);  /* too crowded */
+  return ts;
+}
+
+
+TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
+  GCObject *o;
+  unsigned int h = cast(unsigned int, l);  /* seed */
+  size_t step = (l>>5)+1;  /* if string is too long, don't hash all its chars */
+  size_t l1;
+  for (l1=l; l1>=step; l1-=step)  /* compute hash */
+    h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
+  for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
+       o != NULL;
+       o = o->gch.next) {
+    TString *ts = rawgco2ts(o);
+    if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
+      /* string may be dead */
+      if (isdead(G(L), o)) changewhite(o);
+      return ts;
+    }
+  }
+  return newlstr(L, str, l, h);  /* not found */
+}
+
+
+Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
+  Udata *u;
+  if (s > MAX_SIZET - sizeof(Udata))
+    luaM_toobig(L);
+  u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata)));
+  u->uv.marked = luaC_white(G(L));  /* is not finalized */
+  u->uv.tt = LUA_TUSERDATA;
+  u->uv.len = s;
+  u->uv.metatable = NULL;
+  u->uv.env = e;
+  /* chain it on udata list (after main thread) */
+  u->uv.next = G(L)->mainthread->next;
+  G(L)->mainthread->next = obj2gco(u);
+  return u;
+}
+
Index: /code/branches/physics/src/lua/lstring.h
===================================================================
--- /code/branches/physics/src/lua/lstring.h	(revision 2122)
+++ /code/branches/physics/src/lua/lstring.h	(revision 2122)
@@ -0,0 +1,31 @@
+/*
+** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
+** String table (keep all strings handled by Lua)
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lstring_h
+#define lstring_h
+
+
+#include "lgc.h"
+#include "lobject.h"
+#include "lstate.h"
+
+
+#define sizestring(s)	(sizeof(union TString)+((s)->len+1)*sizeof(char))
+
+#define sizeudata(u)	(sizeof(union Udata)+(u)->len)
+
+#define luaS_new(L, s)	(luaS_newlstr(L, s, strlen(s)))
+#define luaS_newliteral(L, s)	(luaS_newlstr(L, "" s, \
+                                 (sizeof(s)/sizeof(char))-1))
+
+#define luaS_fix(s)	l_setbit((s)->tsv.marked, FIXEDBIT)
+
+LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
+LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
+LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+
+
+#endif
Index: /code/branches/physics/src/lua/lstrlib.c
===================================================================
--- /code/branches/physics/src/lua/lstrlib.c	(revision 2122)
+++ /code/branches/physics/src/lua/lstrlib.c	(revision 2122)
@@ -0,0 +1,868 @@
+/*
+** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $
+** Standard library for string operations and pattern-matching
+** See Copyright Notice in lua.h
+*/
+
+
+#include <ctype.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define lstrlib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/* macro to `unsign' a character */
+#define uchar(c)        ((unsigned char)(c))
+
+
+
+static int str_len (lua_State *L) {
+  size_t l;
+  luaL_checklstring(L, 1, &l);
+  lua_pushinteger(L, l);
+  return 1;
+}
+
+
+static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
+  /* relative string position: negative means back from end */
+  return (pos>=0) ? pos : (ptrdiff_t)len+pos+1;
+}
+
+
+static int str_sub (lua_State *L) {
+  size_t l;
+  const char *s = luaL_checklstring(L, 1, &l);
+  ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
+  ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
+  if (start < 1) start = 1;
+  if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
+  if (start <= end)
+    lua_pushlstring(L, s+start-1, end-start+1);
+  else lua_pushliteral(L, "");
+  return 1;
+}
+
+
+static int str_reverse (lua_State *L) {
+  size_t l;
+  luaL_Buffer b;
+  const char *s = luaL_checklstring(L, 1, &l);
+  luaL_buffinit(L, &b);
+  while (l--) luaL_addchar(&b, s[l]);
+  luaL_pushresult(&b);
+  return 1;
+}
+
+
+static int str_lower (lua_State *L) {
+  size_t l;
+  size_t i;
+  luaL_Buffer b;
+  const char *s = luaL_checklstring(L, 1, &l);
+  luaL_buffinit(L, &b);
+  for (i=0; i<l; i++)
+    luaL_addchar(&b, tolower(uchar(s[i])));
+  luaL_pushresult(&b);
+  return 1;
+}
+
+
+static int str_upper (lua_State *L) {
+  size_t l;
+  size_t i;
+  luaL_Buffer b;
+  const char *s = luaL_checklstring(L, 1, &l);
+  luaL_buffinit(L, &b);
+  for (i=0; i<l; i++)
+    luaL_addchar(&b, toupper(uchar(s[i])));
+  luaL_pushresult(&b);
+  return 1;
+}
+
+static int str_rep (lua_State *L) {
+  size_t l;
+  luaL_Buffer b;
+  const char *s = luaL_checklstring(L, 1, &l);
+  int n = luaL_checkint(L, 2);
+  luaL_buffinit(L, &b);
+  while (n-- > 0)
+    luaL_addlstring(&b, s, l);
+  luaL_pushresult(&b);
+  return 1;
+}
+
+
+static int str_byte (lua_State *L) {
+  size_t l;
+  const char *s = luaL_checklstring(L, 1, &l);
+  ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
+  ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
+  int n, i;
+  if (posi <= 0) posi = 1;
+  if ((size_t)pose > l) pose = l;
+  if (posi > pose) return 0;  /* empty interval; return no values */
+  n = (int)(pose -  posi + 1);
+  if (posi + n <= pose)  /* overflow? */
+    luaL_error(L, "string slice too long");
+  luaL_checkstack(L, n, "string slice too long");
+  for (i=0; i<n; i++)
+    lua_pushinteger(L, uchar(s[posi+i-1]));
+  return n;
+}
+
+
+static int str_char (lua_State *L) {
+  int n = lua_gettop(L);  /* number of arguments */
+  int i;
+  luaL_Buffer b;
+  luaL_buffinit(L, &b);
+  for (i=1; i<=n; i++) {
+    int c = luaL_checkint(L, i);
+    luaL_argcheck(L, uchar(c) == c, i, "invalid value");
+    luaL_addchar(&b, uchar(c));
+  }
+  luaL_pushresult(&b);
+  return 1;
+}
+
+
+static int writer (lua_State *L, const void* b, size_t size, void* B) {
+  (void)L;
+  luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
+  return 0;
+}
+
+
+static int str_dump (lua_State *L) {
+  luaL_Buffer b;
+  luaL_checktype(L, 1, LUA_TFUNCTION);
+  lua_settop(L, 1);
+  luaL_buffinit(L,&b);
+  if (lua_dump(L, writer, &b) != 0)
+    luaL_error(L, "unable to dump given function");
+  luaL_pushresult(&b);
+  return 1;
+}
+
+
+
+/*
+** {======================================================
+** PATTERN MATCHING
+** =======================================================
+*/
+
+
+#define CAP_UNFINISHED	(-1)
+#define CAP_POSITION	(-2)
+
+typedef struct MatchState {
+  const char *src_init;  /* init of source string */
+  const char *src_end;  /* end (`\0') of source string */
+  lua_State *L;
+  int level;  /* total number of captures (finished or unfinished) */
+  struct {
+    const char *init;
+    ptrdiff_t len;
+  } capture[LUA_MAXCAPTURES];
+} MatchState;
+
+
+#define L_ESC		'%'
+#define SPECIALS	"^$*+?.([%-"
+
+
+static int check_capture (MatchState *ms, int l) {
+  l -= '1';
+  if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
+    return luaL_error(ms->L, "invalid capture index");
+  return l;
+}
+
+
+static int capture_to_close (MatchState *ms) {
+  int level = ms->level;
+  for (level--; level>=0; level--)
+    if (ms->capture[level].len == CAP_UNFINISHED) return level;
+  return luaL_error(ms->L, "invalid pattern capture");
+}
+
+
+static const char *classend (MatchState *ms, const char *p) {
+  switch (*p++) {
+    case L_ESC: {
+      if (*p == '\0')
+        luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
+      return p+1;
+    }
+    case '[': {
+      if (*p == '^') p++;
+      do {  /* look for a `]' */
+        if (*p == '\0')
+          luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
+        if (*(p++) == L_ESC && *p != '\0')
+          p++;  /* skip escapes (e.g. `%]') */
+      } while (*p != ']');
+      return p+1;
+    }
+    default: {
+      return p;
+    }
+  }
+}
+
+
+static int match_class (int c, int cl) {
+  int res;
+  switch (tolower(cl)) {
+    case 'a' : res = isalpha(c); break;
+    case 'c' : res = iscntrl(c); break;
+    case 'd' : res = isdigit(c); break;
+    case 'l' : res = islower(c); break;
+    case 'p' : res = ispunct(c); break;
+    case 's' : res = isspace(c); break;
+    case 'u' : res = isupper(c); break;
+    case 'w' : res = isalnum(c); break;
+    case 'x' : res = isxdigit(c); break;
+    case 'z' : res = (c == 0); break;
+    default: return (cl == c);
+  }
+  return (islower(cl) ? res : !res);
+}
+
+
+static int matchbracketclass (int c, const char *p, const char *ec) {
+  int sig = 1;
+  if (*(p+1) == '^') {
+    sig = 0;
+    p++;  /* skip the `^' */
+  }
+  while (++p < ec) {
+    if (*p == L_ESC) {
+      p++;
+      if (match_class(c, uchar(*p)))
+        return sig;
+    }
+    else if ((*(p+1) == '-') && (p+2 < ec)) {
+      p+=2;
+      if (uchar(*(p-2)) <= c && c <= uchar(*p))
+        return sig;
+    }
+    else if (uchar(*p) == c) return sig;
+  }
+  return !sig;
+}
+
+
+static int singlematch (int c, const char *p, const char *ep) {
+  switch (*p) {
+    case '.': return 1;  /* matches any char */
+    case L_ESC: return match_class(c, uchar(*(p+1)));
+    case '[': return matchbracketclass(c, p, ep-1);
+    default:  return (uchar(*p) == c);
+  }
+}
+
+
+static const char *match (MatchState *ms, const char *s, const char *p);
+
+
+static const char *matchbalance (MatchState *ms, const char *s,
+                                   const char *p) {
+  if (*p == 0 || *(p+1) == 0)
+    luaL_error(ms->L, "unbalanced pattern");
+  if (*s != *p) return NULL;
+  else {
+    int b = *p;
+    int e = *(p+1);
+    int cont = 1;
+    while (++s < ms->src_end) {
+      if (*s == e) {
+        if (--cont == 0) return s+1;
+      }
+      else if (*s == b) cont++;
+    }
+  }
+  return NULL;  /* string ends out of balance */
+}
+
+
+static const char *max_expand (MatchState *ms, const char *s,
+                                 const char *p, const char *ep) {
+  ptrdiff_t i = 0;  /* counts maximum expand for item */
+  while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
+    i++;
+  /* keeps trying to match with the maximum repetitions */
+  while (i>=0) {
+    const char *res = match(ms, (s+i), ep+1);
+    if (res) return res;
+    i--;  /* else didn't match; reduce 1 repetition to try again */
+  }
+  return NULL;
+}
+
+
+static const char *min_expand (MatchState *ms, const char *s,
+                                 const char *p, const char *ep) {
+  for (;;) {
+    const char *res = match(ms, s, ep+1);
+    if (res != NULL)
+      return res;
+    else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
+      s++;  /* try with one more repetition */
+    else return NULL;
+  }
+}
+
+
+static const char *start_capture (MatchState *ms, const char *s,
+                                    const char *p, int what) {
+  const char *res;
+  int level = ms->level;
+  if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
+  ms->capture[level].init = s;
+  ms->capture[level].len = what;
+  ms->level = level+1;
+  if ((res=match(ms, s, p)) == NULL)  /* match failed? */
+    ms->level--;  /* undo capture */
+  return res;
+}
+
+
+static const char *end_capture (MatchState *ms, const char *s,
+                                  const char *p) {
+  int l = capture_to_close(ms);
+  const char *res;
+  ms->capture[l].len = s - ms->capture[l].init;  /* close capture */
+  if ((res = match(ms, s, p)) == NULL)  /* match failed? */
+    ms->capture[l].len = CAP_UNFINISHED;  /* undo capture */
+  return res;
+}
+
+
+static const char *match_capture (MatchState *ms, const char *s, int l) {
+  size_t len;
+  l = check_capture(ms, l);
+  len = ms->capture[l].len;
+  if ((size_t)(ms->src_end-s) >= len &&
+      memcmp(ms->capture[l].init, s, len) == 0)
+    return s+len;
+  else return NULL;
+}
+
+
+static const char *match (MatchState *ms, const char *s, const char *p) {
+  init: /* using goto's to optimize tail recursion */
+  switch (*p) {
+    case '(': {  /* start capture */
+      if (*(p+1) == ')')  /* position capture? */
+        return start_capture(ms, s, p+2, CAP_POSITION);
+      else
+        return start_capture(ms, s, p+1, CAP_UNFINISHED);
+    }
+    case ')': {  /* end capture */
+      return end_capture(ms, s, p+1);
+    }
+    case L_ESC: {
+      switch (*(p+1)) {
+        case 'b': {  /* balanced string? */
+          s = matchbalance(ms, s, p+2);
+          if (s == NULL) return NULL;
+          p+=4; goto init;  /* else return match(ms, s, p+4); */
+        }
+        case 'f': {  /* frontier? */
+          const char *ep; char previous;
+          p += 2;
+          if (*p != '[')
+            luaL_error(ms->L, "missing " LUA_QL("[") " after "
+                               LUA_QL("%%f") " in pattern");
+          ep = classend(ms, p);  /* points to what is next */
+          previous = (s == ms->src_init) ? '\0' : *(s-1);
+          if (matchbracketclass(uchar(previous), p, ep-1) ||
+             !matchbracketclass(uchar(*s), p, ep-1)) return NULL;
+          p=ep; goto init;  /* else return match(ms, s, ep); */
+        }
+        default: {
+          if (isdigit(uchar(*(p+1)))) {  /* capture results (%0-%9)? */
+            s = match_capture(ms, s, uchar(*(p+1)));
+            if (s == NULL) return NULL;
+            p+=2; goto init;  /* else return match(ms, s, p+2) */
+          }
+          goto dflt;  /* case default */
+        }
+      }
+    }
+    case '\0': {  /* end of pattern */
+      return s;  /* match succeeded */
+    }
+    case '$': {
+      if (*(p+1) == '\0')  /* is the `$' the last char in pattern? */
+        return (s == ms->src_end) ? s : NULL;  /* check end of string */
+      else goto dflt;
+    }
+    default: dflt: {  /* it is a pattern item */
+      const char *ep = classend(ms, p);  /* points to what is next */
+      int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
+      switch (*ep) {
+        case '?': {  /* optional */
+          const char *res;
+          if (m && ((res=match(ms, s+1, ep+1)) != NULL))
+            return res;
+          p=ep+1; goto init;  /* else return match(ms, s, ep+1); */
+        }
+        case '*': {  /* 0 or more repetitions */
+          return max_expand(ms, s, p, ep);
+        }
+        case '+': {  /* 1 or more repetitions */
+          return (m ? max_expand(ms, s+1, p, ep) : NULL);
+        }
+        case '-': {  /* 0 or more repetitions (minimum) */
+          return min_expand(ms, s, p, ep);
+        }
+        default: {
+          if (!m) return NULL;
+          s++; p=ep; goto init;  /* else return match(ms, s+1, ep); */
+        }
+      }
+    }
+  }
+}
+
+
+
+static const char *lmemfind (const char *s1, size_t l1,
+                               const char *s2, size_t l2) {
+  if (l2 == 0) return s1;  /* empty strings are everywhere */
+  else if (l2 > l1) return NULL;  /* avoids a negative `l1' */
+  else {
+    const char *init;  /* to search for a `*s2' inside `s1' */
+    l2--;  /* 1st char will be checked by `memchr' */
+    l1 = l1-l2;  /* `s2' cannot be found after that */
+    while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
+      init++;   /* 1st char is already checked */
+      if (memcmp(init, s2+1, l2) == 0)
+        return init-1;
+      else {  /* correct `l1' and `s1' to try again */
+        l1 -= init-s1;
+        s1 = init;
+      }
+    }
+    return NULL;  /* not found */
+  }
+}
+
+
+static void push_onecapture (MatchState *ms, int i, const char *s,
+                                                    const char *e) {
+  if (i >= ms->level) {
+    if (i == 0)  /* ms->level == 0, too */
+      lua_pushlstring(ms->L, s, e - s);  /* add whole match */
+    else
+      luaL_error(ms->L, "invalid capture index");
+  }
+  else {
+    ptrdiff_t l = ms->capture[i].len;
+    if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
+    if (l == CAP_POSITION)
+      lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
+    else
+      lua_pushlstring(ms->L, ms->capture[i].init, l);
+  }
+}
+
+
+static int push_captures (MatchState *ms, const char *s, const char *e) {
+  int i;
+  int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
+  luaL_checkstack(ms->L, nlevels, "too many captures");
+  for (i = 0; i < nlevels; i++)
+    push_onecapture(ms, i, s, e);
+  return nlevels;  /* number of strings pushed */
+}
+
+
+static int str_find_aux (lua_State *L, int find) {
+  size_t l1, l2;
+  const char *s = luaL_checklstring(L, 1, &l1);
+  const char *p = luaL_checklstring(L, 2, &l2);
+  ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
+  if (init < 0) init = 0;
+  else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
+  if (find && (lua_toboolean(L, 4) ||  /* explicit request? */
+      strpbrk(p, SPECIALS) == NULL)) {  /* or no special characters? */
+    /* do a plain search */
+    const char *s2 = lmemfind(s+init, l1-init, p, l2);
+    if (s2) {
+      lua_pushinteger(L, s2-s+1);
+      lua_pushinteger(L, s2-s+l2);
+      return 2;
+    }
+  }
+  else {
+    MatchState ms;
+    int anchor = (*p == '^') ? (p++, 1) : 0;
+    const char *s1=s+init;
+    ms.L = L;
+    ms.src_init = s;
+    ms.src_end = s+l1;
+    do {
+      const char *res;
+      ms.level = 0;
+      if ((res=match(&ms, s1, p)) != NULL) {
+        if (find) {
+          lua_pushinteger(L, s1-s+1);  /* start */
+          lua_pushinteger(L, res-s);   /* end */
+          return push_captures(&ms, NULL, 0) + 2;
+        }
+        else
+          return push_captures(&ms, s1, res);
+      }
+    } while (s1++ < ms.src_end && !anchor);
+  }
+  lua_pushnil(L);  /* not found */
+  return 1;
+}
+
+
+static int str_find (lua_State *L) {
+  return str_find_aux(L, 1);
+}
+
+
+static int str_match (lua_State *L) {
+  return str_find_aux(L, 0);
+}
+
+
+static int gmatch_aux (lua_State *L) {
+  MatchState ms;
+  size_t ls;
+  const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
+  const char *p = lua_tostring(L, lua_upvalueindex(2));
+  const char *src;
+  ms.L = L;
+  ms.src_init = s;
+  ms.src_end = s+ls;
+  for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
+       src <= ms.src_end;
+       src++) {
+    const char *e;
+    ms.level = 0;
+    if ((e = match(&ms, src, p)) != NULL) {
+      lua_Integer newstart = e-s;
+      if (e == src) newstart++;  /* empty match? go at least one position */
+      lua_pushinteger(L, newstart);
+      lua_replace(L, lua_upvalueindex(3));
+      return push_captures(&ms, src, e);
+    }
+  }
+  return 0;  /* not found */
+}
+
+
+static int gmatch (lua_State *L) {
+  luaL_checkstring(L, 1);
+  luaL_checkstring(L, 2);
+  lua_settop(L, 2);
+  lua_pushinteger(L, 0);
+  lua_pushcclosure(L, gmatch_aux, 3);
+  return 1;
+}
+
+
+static int gfind_nodef (lua_State *L) {
+  return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
+                       LUA_QL("string.gmatch"));
+}
+
+
+static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
+                                                   const char *e) {
+  size_t l, i;
+  const char *news = lua_tolstring(ms->L, 3, &l);
+  for (i = 0; i < l; i++) {
+    if (news[i] != L_ESC)
+      luaL_addchar(b, news[i]);
+    else {
+      i++;  /* skip ESC */
+      if (!isdigit(uchar(news[i])))
+        luaL_addchar(b, news[i]);
+      else if (news[i] == '0')
+          luaL_addlstring(b, s, e - s);
+      else {
+        push_onecapture(ms, news[i] - '1', s, e);
+        luaL_addvalue(b);  /* add capture to accumulated result */
+      }
+    }
+  }
+}
+
+
+static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
+                                                       const char *e) {
+  lua_State *L = ms->L;
+  switch (lua_type(L, 3)) {
+    case LUA_TNUMBER:
+    case LUA_TSTRING: {
+      add_s(ms, b, s, e);
+      return;
+    }
+    case LUA_TFUNCTION: {
+      int n;
+      lua_pushvalue(L, 3);
+      n = push_captures(ms, s, e);
+      lua_call(L, n, 1);
+      break;
+    }
+    case LUA_TTABLE: {
+      push_onecapture(ms, 0, s, e);
+      lua_gettable(L, 3);
+      break;
+    }
+  }
+  if (!lua_toboolean(L, -1)) {  /* nil or false? */
+    lua_pop(L, 1);
+    lua_pushlstring(L, s, e - s);  /* keep original text */
+  }
+  else if (!lua_isstring(L, -1))
+    luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); 
+  luaL_addvalue(b);  /* add result to accumulator */
+}
+
+
+static int str_gsub (lua_State *L) {
+  size_t srcl;
+  const char *src = luaL_checklstring(L, 1, &srcl);
+  const char *p = luaL_checkstring(L, 2);
+  int  tr = lua_type(L, 3);
+  int max_s = luaL_optint(L, 4, srcl+1);
+  int anchor = (*p == '^') ? (p++, 1) : 0;
+  int n = 0;
+  MatchState ms;
+  luaL_Buffer b;
+  luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
+                   tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
+                      "string/function/table expected");
+  luaL_buffinit(L, &b);
+  ms.L = L;
+  ms.src_init = src;
+  ms.src_end = src+srcl;
+  while (n < max_s) {
+    const char *e;
+    ms.level = 0;
+    e = match(&ms, src, p);
+    if (e) {
+      n++;
+      add_value(&ms, &b, src, e);
+    }
+    if (e && e>src) /* non empty match? */
+      src = e;  /* skip it */
+    else if (src < ms.src_end)
+      luaL_addchar(&b, *src++);
+    else break;
+    if (anchor) break;
+  }
+  luaL_addlstring(&b, src, ms.src_end-src);
+  luaL_pushresult(&b);
+  lua_pushinteger(L, n);  /* number of substitutions */
+  return 2;
+}
+
+/* }====================================================== */
+
+
+/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */
+#define MAX_ITEM	512
+/* valid flags in a format specification */
+#define FLAGS	"-+ #0"
+/*
+** maximum size of each format specification (such as '%-099.99d')
+** (+10 accounts for %99.99x plus margin of error)
+*/
+#define MAX_FORMAT	(sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
+
+
+static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
+  size_t l;
+  const char *s = luaL_checklstring(L, arg, &l);
+  luaL_addchar(b, '"');
+  while (l--) {
+    switch (*s) {
+      case '"': case '\\': case '\n': {
+        luaL_addchar(b, '\\');
+        luaL_addchar(b, *s);
+        break;
+      }
+      case '\r': {
+        luaL_addlstring(b, "\\r", 2);
+        break;
+      }
+      case '\0': {
+        luaL_addlstring(b, "\\000", 4);
+        break;
+      }
+      default: {
+        luaL_addchar(b, *s);
+        break;
+      }
+    }
+    s++;
+  }
+  luaL_addchar(b, '"');
+}
+
+static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
+  const char *p = strfrmt;
+  while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++;  /* skip flags */
+  if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
+    luaL_error(L, "invalid format (repeated flags)");
+  if (isdigit(uchar(*p))) p++;  /* skip width */
+  if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
+  if (*p == '.') {
+    p++;
+    if (isdigit(uchar(*p))) p++;  /* skip precision */
+    if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
+  }
+  if (isdigit(uchar(*p)))
+    luaL_error(L, "invalid format (width or precision too long)");
+  *(form++) = '%';
+  strncpy(form, strfrmt, p - strfrmt + 1);
+  form += p - strfrmt + 1;
+  *form = '\0';
+  return p;
+}
+
+
+static void addintlen (char *form) {
+  size_t l = strlen(form);
+  char spec = form[l - 1];
+  strcpy(form + l - 1, LUA_INTFRMLEN);
+  form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
+  form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
+}
+
+
+static int str_format (lua_State *L) {
+  int arg = 1;
+  size_t sfl;
+  const char *strfrmt = luaL_checklstring(L, arg, &sfl);
+  const char *strfrmt_end = strfrmt+sfl;
+  luaL_Buffer b;
+  luaL_buffinit(L, &b);
+  while (strfrmt < strfrmt_end) {
+    if (*strfrmt != L_ESC)
+      luaL_addchar(&b, *strfrmt++);
+    else if (*++strfrmt == L_ESC)
+      luaL_addchar(&b, *strfrmt++);  /* %% */
+    else { /* format item */
+      char form[MAX_FORMAT];  /* to store the format (`%...') */
+      char buff[MAX_ITEM];  /* to store the formatted item */
+      arg++;
+      strfrmt = scanformat(L, strfrmt, form);
+      switch (*strfrmt++) {
+        case 'c': {
+          sprintf(buff, form, (int)luaL_checknumber(L, arg));
+          break;
+        }
+        case 'd':  case 'i': {
+          addintlen(form);
+          sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
+          break;
+        }
+        case 'o':  case 'u':  case 'x':  case 'X': {
+          addintlen(form);
+          sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
+          break;
+        }
+        case 'e':  case 'E': case 'f':
+        case 'g': case 'G': {
+          sprintf(buff, form, (double)luaL_checknumber(L, arg));
+          break;
+        }
+        case 'q': {
+          addquoted(L, &b, arg);
+          continue;  /* skip the 'addsize' at the end */
+        }
+        case 's': {
+          size_t l;
+          const char *s = luaL_checklstring(L, arg, &l);
+          if (!strchr(form, '.') && l >= 100) {
+            /* no precision and string is too long to be formatted;
+               keep original string */
+            lua_pushvalue(L, arg);
+            luaL_addvalue(&b);
+            continue;  /* skip the `addsize' at the end */
+          }
+          else {
+            sprintf(buff, form, s);
+            break;
+          }
+        }
+        default: {  /* also treat cases `pnLlh' */
+          return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
+                               LUA_QL("format"), *(strfrmt - 1));
+        }
+      }
+      luaL_addlstring(&b, buff, strlen(buff));
+    }
+  }
+  luaL_pushresult(&b);
+  return 1;
+}
+
+
+static const luaL_Reg strlib[] = {
+  {"byte", str_byte},
+  {"char", str_char},
+  {"dump", str_dump},
+  {"find", str_find},
+  {"format", str_format},
+  {"gfind", gfind_nodef},
+  {"gmatch", gmatch},
+  {"gsub", str_gsub},
+  {"len", str_len},
+  {"lower", str_lower},
+  {"match", str_match},
+  {"rep", str_rep},
+  {"reverse", str_reverse},
+  {"sub", str_sub},
+  {"upper", str_upper},
+  {NULL, NULL}
+};
+
+
+static void createmetatable (lua_State *L) {
+  lua_createtable(L, 0, 1);  /* create metatable for strings */
+  lua_pushliteral(L, "");  /* dummy string */
+  lua_pushvalue(L, -2);
+  lua_setmetatable(L, -2);  /* set string metatable */
+  lua_pop(L, 1);  /* pop dummy string */
+  lua_pushvalue(L, -2);  /* string library... */
+  lua_setfield(L, -2, "__index");  /* ...is the __index metamethod */
+  lua_pop(L, 1);  /* pop metatable */
+}
+
+
+/*
+** Open string library
+*/
+LUALIB_API int luaopen_string (lua_State *L) {
+  luaL_register(L, LUA_STRLIBNAME, strlib);
+#if defined(LUA_COMPAT_GFIND)
+  lua_getfield(L, -1, "gmatch");
+  lua_setfield(L, -2, "gfind");
+#endif
+  createmetatable(L);
+  return 1;
+}
+
Index: /code/branches/physics/src/lua/ltable.c
===================================================================
--- /code/branches/physics/src/lua/ltable.c	(revision 2122)
+++ /code/branches/physics/src/lua/ltable.c	(revision 2122)
@@ -0,0 +1,588 @@
+/*
+** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
+** Lua tables (hash)
+** See Copyright Notice in lua.h
+*/
+
+
+/*
+** Implementation of tables (aka arrays, objects, or hash tables).
+** Tables keep its elements in two parts: an array part and a hash part.
+** Non-negative integer keys are all candidates to be kept in the array
+** part. The actual size of the array is the largest `n' such that at
+** least half the slots between 0 and n are in use.
+** Hash uses a mix of chained scatter table with Brent's variation.
+** A main invariant of these tables is that, if an element is not
+** in its main position (i.e. the `original' position that its hash gives
+** to it), then the colliding element is in its own main position.
+** Hence even when the load factor reaches 100%, performance remains good.
+*/
+
+#include <math.h>
+#include <string.h>
+
+#define ltable_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lgc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstate.h"
+#include "ltable.h"
+
+
+/*
+** max size of array part is 2^MAXBITS
+*/
+#if LUAI_BITSINT > 26
+#define MAXBITS		26
+#else
+#define MAXBITS		(LUAI_BITSINT-2)
+#endif
+
+#define MAXASIZE	(1 << MAXBITS)
+
+
+#define hashpow2(t,n)      (gnode(t, lmod((n), sizenode(t))))
+  
+#define hashstr(t,str)  hashpow2(t, (str)->tsv.hash)
+#define hashboolean(t,p)        hashpow2(t, p)
+
+
+/*
+** for some types, it is better to avoid modulus by power of 2, as
+** they tend to have many 2 factors.
+*/
+#define hashmod(t,n)	(gnode(t, ((n) % ((sizenode(t)-1)|1))))
+
+
+#define hashpointer(t,p)	hashmod(t, IntPoint(p))
+
+
+/*
+** number of ints inside a lua_Number
+*/
+#define numints		cast_int(sizeof(lua_Number)/sizeof(int))
+
+
+
+#define dummynode		(&dummynode_)
+
+static const Node dummynode_ = {
+  {{NULL}, LUA_TNIL},  /* value */
+  {{{NULL}, LUA_TNIL, NULL}}  /* key */
+};
+
+
+/*
+** hash for lua_Numbers
+*/
+static Node *hashnum (const Table *t, lua_Number n) {
+  unsigned int a[numints];
+  int i;
+  if (luai_numeq(n, 0))  /* avoid problems with -0 */
+    return gnode(t, 0);
+  memcpy(a, &n, sizeof(a));
+  for (i = 1; i < numints; i++) a[0] += a[i];
+  return hashmod(t, a[0]);
+}
+
+
+
+/*
+** returns the `main' position of an element in a table (that is, the index
+** of its hash value)
+*/
+static Node *mainposition (const Table *t, const TValue *key) {
+  switch (ttype(key)) {
+    case LUA_TNUMBER:
+      return hashnum(t, nvalue(key));
+    case LUA_TSTRING:
+      return hashstr(t, rawtsvalue(key));
+    case LUA_TBOOLEAN:
+      return hashboolean(t, bvalue(key));
+    case LUA_TLIGHTUSERDATA:
+      return hashpointer(t, pvalue(key));
+    default:
+      return hashpointer(t, gcvalue(key));
+  }
+}
+
+
+/*
+** returns the index for `key' if `key' is an appropriate key to live in
+** the array part of the table, -1 otherwise.
+*/
+static int arrayindex (const TValue *key) {
+  if (ttisnumber(key)) {
+    lua_Number n = nvalue(key);
+    int k;
+    lua_number2int(k, n);
+    if (luai_numeq(cast_num(k), n))
+      return k;
+  }
+  return -1;  /* `key' did not match some condition */
+}
+
+
+/*
+** returns the index of a `key' for table traversals. First goes all
+** elements in the array part, then elements in the hash part. The
+** beginning of a traversal is signalled by -1.
+*/
+static int findindex (lua_State *L, Table *t, StkId key) {
+  int i;
+  if (ttisnil(key)) return -1;  /* first iteration */
+  i = arrayindex(key);
+  if (0 < i && i <= t->sizearray)  /* is `key' inside array part? */
+    return i-1;  /* yes; that's the index (corrected to C) */
+  else {
+    Node *n = mainposition(t, key);
+    do {  /* check whether `key' is somewhere in the chain */
+      /* key may be dead already, but it is ok to use it in `next' */
+      if (luaO_rawequalObj(key2tval(n), key) ||
+            (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
+             gcvalue(gkey(n)) == gcvalue(key))) {
+        i = cast_int(n - gnode(t, 0));  /* key index in hash table */
+        /* hash elements are numbered after array ones */
+        return i + t->sizearray;
+      }
+      else n = gnext(n);
+    } while (n);
+    luaG_runerror(L, "invalid key to " LUA_QL("next"));  /* key not found */
+    return 0;  /* to avoid warnings */
+  }
+}
+
+
+int luaH_next (lua_State *L, Table *t, StkId key) {
+  int i = findindex(L, t, key);  /* find original element */
+  for (i++; i < t->sizearray; i++) {  /* try first array part */
+    if (!ttisnil(&t->array[i])) {  /* a non-nil value? */
+      setnvalue(key, cast_num(i+1));
+      setobj2s(L, key+1, &t->array[i]);
+      return 1;
+    }
+  }
+  for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
+    if (!ttisnil(gval(gnode(t, i)))) {  /* a non-nil value? */
+      setobj2s(L, key, key2tval(gnode(t, i)));
+      setobj2s(L, key+1, gval(gnode(t, i)));
+      return 1;
+    }
+  }
+  return 0;  /* no more elements */
+}
+
+
+/*
+** {=============================================================
+** Rehash
+** ==============================================================
+*/
+
+
+static int computesizes (int nums[], int *narray) {
+  int i;
+  int twotoi;  /* 2^i */
+  int a = 0;  /* number of elements smaller than 2^i */
+  int na = 0;  /* number of elements to go to array part */
+  int n = 0;  /* optimal size for array part */
+  for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
+    if (nums[i] > 0) {
+      a += nums[i];
+      if (a > twotoi/2) {  /* more than half elements present? */
+        n = twotoi;  /* optimal size (till now) */
+        na = a;  /* all elements smaller than n will go to array part */
+      }
+    }
+    if (a == *narray) break;  /* all elements already counted */
+  }
+  *narray = n;
+  lua_assert(*narray/2 <= na && na <= *narray);
+  return na;
+}
+
+
+static int countint (const TValue *key, int *nums) {
+  int k = arrayindex(key);
+  if (0 < k && k <= MAXASIZE) {  /* is `key' an appropriate array index? */
+    nums[ceillog2(k)]++;  /* count as such */
+    return 1;
+  }
+  else
+    return 0;
+}
+
+
+static int numusearray (const Table *t, int *nums) {
+  int lg;
+  int ttlg;  /* 2^lg */
+  int ause = 0;  /* summation of `nums' */
+  int i = 1;  /* count to traverse all array keys */
+  for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) {  /* for each slice */
+    int lc = 0;  /* counter */
+    int lim = ttlg;
+    if (lim > t->sizearray) {
+      lim = t->sizearray;  /* adjust upper limit */
+      if (i > lim)
+        break;  /* no more elements to count */
+    }
+    /* count elements in range (2^(lg-1), 2^lg] */
+    for (; i <= lim; i++) {
+      if (!ttisnil(&t->array[i-1]))
+        lc++;
+    }
+    nums[lg] += lc;
+    ause += lc;
+  }
+  return ause;
+}
+
+
+static int numusehash (const Table *t, int *nums, int *pnasize) {
+  int totaluse = 0;  /* total number of elements */
+  int ause = 0;  /* summation of `nums' */
+  int i = sizenode(t);
+  while (i--) {
+    Node *n = &t->node[i];
+    if (!ttisnil(gval(n))) {
+      ause += countint(key2tval(n), nums);
+      totaluse++;
+    }
+  }
+  *pnasize += ause;
+  return totaluse;
+}
+
+
+static void setarrayvector (lua_State *L, Table *t, int size) {
+  int i;
+  luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
+  for (i=t->sizearray; i<size; i++)
+     setnilvalue(&t->array[i]);
+  t->sizearray = size;
+}
+
+
+static void setnodevector (lua_State *L, Table *t, int size) {
+  int lsize;
+  if (size == 0) {  /* no elements to hash part? */
+    t->node = cast(Node *, dummynode);  /* use common `dummynode' */
+    lsize = 0;
+  }
+  else {
+    int i;
+    lsize = ceillog2(size);
+    if (lsize > MAXBITS)
+      luaG_runerror(L, "table overflow");
+    size = twoto(lsize);
+    t->node = luaM_newvector(L, size, Node);
+    for (i=0; i<size; i++) {
+      Node *n = gnode(t, i);
+      gnext(n) = NULL;
+      setnilvalue(gkey(n));
+      setnilvalue(gval(n));
+    }
+  }
+  t->lsizenode = cast_byte(lsize);
+  t->lastfree = gnode(t, size);  /* all positions are free */
+}
+
+
+static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
+  int i;
+  int oldasize = t->sizearray;
+  int oldhsize = t->lsizenode;
+  Node *nold = t->node;  /* save old hash ... */
+  if (nasize > oldasize)  /* array part must grow? */
+    setarrayvector(L, t, nasize);
+  /* create new hash part with appropriate size */
+  setnodevector(L, t, nhsize);  
+  if (nasize < oldasize) {  /* array part must shrink? */
+    t->sizearray = nasize;
+    /* re-insert elements from vanishing slice */
+    for (i=nasize; i<oldasize; i++) {
+      if (!ttisnil(&t->array[i]))
+        setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
+    }
+    /* shrink array */
+    luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
+  }
+  /* re-insert elements from hash part */
+  for (i = twoto(oldhsize) - 1; i >= 0; i--) {
+    Node *old = nold+i;
+    if (!ttisnil(gval(old)))
+      setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old));
+  }
+  if (nold != dummynode)
+    luaM_freearray(L, nold, twoto(oldhsize), Node);  /* free old array */
+}
+
+
+void luaH_resizearray (lua_State *L, Table *t, int nasize) {
+  int nsize = (t->node == dummynode) ? 0 : sizenode(t);
+  resize(L, t, nasize, nsize);
+}
+
+
+static void rehash (lua_State *L, Table *t, const TValue *ek) {
+  int nasize, na;
+  int nums[MAXBITS+1];  /* nums[i] = number of keys between 2^(i-1) and 2^i */
+  int i;
+  int totaluse;
+  for (i=0; i<=MAXBITS; i++) nums[i] = 0;  /* reset counts */
+  nasize = numusearray(t, nums);  /* count keys in array part */
+  totaluse = nasize;  /* all those keys are integer keys */
+  totaluse += numusehash(t, nums, &nasize);  /* count keys in hash part */
+  /* count extra key */
+  nasize += countint(ek, nums);
+  totaluse++;
+  /* compute new size for array part */
+  na = computesizes(nums, &nasize);
+  /* resize the table to new computed sizes */
+  resize(L, t, nasize, totaluse - na);
+}
+
+
+
+/*
+** }=============================================================
+*/
+
+
+Table *luaH_new (lua_State *L, int narray, int nhash) {
+  Table *t = luaM_new(L, Table);
+  luaC_link(L, obj2gco(t), LUA_TTABLE);
+  t->metatable = NULL;
+  t->flags = cast_byte(~0);
+  /* temporary values (kept only if some malloc fails) */
+  t->array = NULL;
+  t->sizearray = 0;
+  t->lsizenode = 0;
+  t->node = cast(Node *, dummynode);
+  setarrayvector(L, t, narray);
+  setnodevector(L, t, nhash);
+  return t;
+}
+
+
+void luaH_free (lua_State *L, Table *t) {
+  if (t->node != dummynode)
+    luaM_freearray(L, t->node, sizenode(t), Node);
+  luaM_freearray(L, t->array, t->sizearray, TValue);
+  luaM_free(L, t);
+}
+
+
+static Node *getfreepos (Table *t) {
+  while (t->lastfree-- > t->node) {
+    if (ttisnil(gkey(t->lastfree)))
+      return t->lastfree;
+  }
+  return NULL;  /* could not find a free place */
+}
+
+
+
+/*
+** inserts a new key into a hash table; first, check whether key's main 
+** position is free. If not, check whether colliding node is in its main 
+** position or not: if it is not, move colliding node to an empty place and 
+** put new key in its main position; otherwise (colliding node is in its main 
+** position), new key goes to an empty position. 
+*/
+static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
+  Node *mp = mainposition(t, key);
+  if (!ttisnil(gval(mp)) || mp == dummynode) {
+    Node *othern;
+    Node *n = getfreepos(t);  /* get a free place */
+    if (n == NULL) {  /* cannot find a free place? */
+      rehash(L, t, key);  /* grow table */
+      return luaH_set(L, t, key);  /* re-insert key into grown table */
+    }
+    lua_assert(n != dummynode);
+    othern = mainposition(t, key2tval(mp));
+    if (othern != mp) {  /* is colliding node out of its main position? */
+      /* yes; move colliding node into free position */
+      while (gnext(othern) != mp) othern = gnext(othern);  /* find previous */
+      gnext(othern) = n;  /* redo the chain with `n' in place of `mp' */
+      *n = *mp;  /* copy colliding node into free pos. (mp->next also goes) */
+      gnext(mp) = NULL;  /* now `mp' is free */
+      setnilvalue(gval(mp));
+    }
+    else {  /* colliding node is in its own main position */
+      /* new node will go into free position */
+      gnext(n) = gnext(mp);  /* chain new position */
+      gnext(mp) = n;
+      mp = n;
+    }
+  }
+  gkey(mp)->value = key->value; gkey(mp)->tt = key->tt;
+  luaC_barriert(L, t, key);
+  lua_assert(ttisnil(gval(mp)));
+  return gval(mp);
+}
+
+
+/*
+** search function for integers
+*/
+const TValue *luaH_getnum (Table *t, int key) {
+  /* (1 <= key && key <= t->sizearray) */
+  if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
+    return &t->array[key-1];
+  else {
+    lua_Number nk = cast_num(key);
+    Node *n = hashnum(t, nk);
+    do {  /* check whether `key' is somewhere in the chain */
+      if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
+        return gval(n);  /* that's it */
+      else n = gnext(n);
+    } while (n);
+    return luaO_nilobject;
+  }
+}
+
+
+/*
+** search function for strings
+*/
+const TValue *luaH_getstr (Table *t, TString *key) {
+  Node *n = hashstr(t, key);
+  do {  /* check whether `key' is somewhere in the chain */
+    if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
+      return gval(n);  /* that's it */
+    else n = gnext(n);
+  } while (n);
+  return luaO_nilobject;
+}
+
+
+/*
+** main search function
+*/
+const TValue *luaH_get (Table *t, const TValue *key) {
+  switch (ttype(key)) {
+    case LUA_TNIL: return luaO_nilobject;
+    case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
+    case LUA_TNUMBER: {
+      int k;
+      lua_Number n = nvalue(key);
+      lua_number2int(k, n);
+      if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
+        return luaH_getnum(t, k);  /* use specialized version */
+      /* else go through */
+    }
+    default: {
+      Node *n = mainposition(t, key);
+      do {  /* check whether `key' is somewhere in the chain */
+        if (luaO_rawequalObj(key2tval(n), key))
+          return gval(n);  /* that's it */
+        else n = gnext(n);
+      } while (n);
+      return luaO_nilobject;
+    }
+  }
+}
+
+
+TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
+  const TValue *p = luaH_get(t, key);
+  t->flags = 0;
+  if (p != luaO_nilobject)
+    return cast(TValue *, p);
+  else {
+    if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+    else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
+      luaG_runerror(L, "table index is NaN");
+    return newkey(L, t, key);
+  }
+}
+
+
+TValue *luaH_setnum (lua_State *L, Table *t, int key) {
+  const TValue *p = luaH_getnum(t, key);
+  if (p != luaO_nilobject)
+    return cast(TValue *, p);
+  else {
+    TValue k;
+    setnvalue(&k, cast_num(key));
+    return newkey(L, t, &k);
+  }
+}
+
+
+TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
+  const TValue *p = luaH_getstr(t, key);
+  if (p != luaO_nilobject)
+    return cast(TValue *, p);
+  else {
+    TValue k;
+    setsvalue(L, &k, key);
+    return newkey(L, t, &k);
+  }
+}
+
+
+static int unbound_search (Table *t, unsigned int j) {
+  unsigned int i = j;  /* i is zero or a present index */
+  j++;
+  /* find `i' and `j' such that i is present and j is not */
+  while (!ttisnil(luaH_getnum(t, j))) {
+    i = j;
+    j *= 2;
+    if (j > cast(unsigned int, MAX_INT)) {  /* overflow? */
+      /* table was built with bad purposes: resort to linear search */
+      i = 1;
+      while (!ttisnil(luaH_getnum(t, i))) i++;
+      return i - 1;
+    }
+  }
+  /* now do a binary search between them */
+  while (j - i > 1) {
+    unsigned int m = (i+j)/2;
+    if (ttisnil(luaH_getnum(t, m))) j = m;
+    else i = m;
+  }
+  return i;
+}
+
+
+/*
+** Try to find a boundary in table `t'. A `boundary' is an integer index
+** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
+*/
+int luaH_getn (Table *t) {
+  unsigned int j = t->sizearray;
+  if (j > 0 && ttisnil(&t->array[j - 1])) {
+    /* there is a boundary in the array part: (binary) search for it */
+    unsigned int i = 0;
+    while (j - i > 1) {
+      unsigned int m = (i+j)/2;
+      if (ttisnil(&t->array[m - 1])) j = m;
+      else i = m;
+    }
+    return i;
+  }
+  /* else must find a boundary in hash part */
+  else if (t->node == dummynode)  /* hash part is empty? */
+    return j;  /* that is easy... */
+  else return unbound_search(t, j);
+}
+
+
+
+#if defined(LUA_DEBUG)
+
+Node *luaH_mainposition (const Table *t, const TValue *key) {
+  return mainposition(t, key);
+}
+
+int luaH_isdummy (Node *n) { return n == dummynode; }
+
+#endif
Index: /code/branches/physics/src/lua/ltable.h
===================================================================
--- /code/branches/physics/src/lua/ltable.h	(revision 2122)
+++ /code/branches/physics/src/lua/ltable.h	(revision 2122)
@@ -0,0 +1,40 @@
+/*
+** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
+** Lua tables (hash)
+** See Copyright Notice in lua.h
+*/
+
+#ifndef ltable_h
+#define ltable_h
+
+#include "lobject.h"
+
+
+#define gnode(t,i)	(&(t)->node[i])
+#define gkey(n)		(&(n)->i_key.nk)
+#define gval(n)		(&(n)->i_val)
+#define gnext(n)	((n)->i_key.nk.next)
+
+#define key2tval(n)	(&(n)->i_key.tvk)
+
+
+LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
+LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
+LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
+LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
+LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
+LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
+LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
+LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
+LUAI_FUNC void luaH_free (lua_State *L, Table *t);
+LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
+LUAI_FUNC int luaH_getn (Table *t);
+
+
+#if defined(LUA_DEBUG)
+LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
+LUAI_FUNC int luaH_isdummy (Node *n);
+#endif
+
+
+#endif
Index: /code/branches/physics/src/lua/ltablib.c
===================================================================
--- /code/branches/physics/src/lua/ltablib.c	(revision 2122)
+++ /code/branches/physics/src/lua/ltablib.c	(revision 2122)
@@ -0,0 +1,279 @@
+/*
+** $Id: ltablib.c,v 1.38.1.2 2007/12/28 15:32:23 roberto Exp $
+** Library for Table Manipulation
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stddef.h>
+
+#define ltablib_c
+#define LUA_LIB
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+#define aux_getn(L,n)	(luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
+
+
+static int foreachi (lua_State *L) {
+  int i;
+  int n = aux_getn(L, 1);
+  luaL_checktype(L, 2, LUA_TFUNCTION);
+  for (i=1; i <= n; i++) {
+    lua_pushvalue(L, 2);  /* function */
+    lua_pushinteger(L, i);  /* 1st argument */
+    lua_rawgeti(L, 1, i);  /* 2nd argument */
+    lua_call(L, 2, 1);
+    if (!lua_isnil(L, -1))
+      return 1;
+    lua_pop(L, 1);  /* remove nil result */
+  }
+  return 0;
+}
+
+
+static int foreach (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+  luaL_checktype(L, 2, LUA_TFUNCTION);
+  lua_pushnil(L);  /* first key */
+  while (lua_next(L, 1)) {
+    lua_pushvalue(L, 2);  /* function */
+    lua_pushvalue(L, -3);  /* key */
+    lua_pushvalue(L, -3);  /* value */
+    lua_call(L, 2, 1);
+    if (!lua_isnil(L, -1))
+      return 1;
+    lua_pop(L, 2);  /* remove value and result */
+  }
+  return 0;
+}
+
+
+static int maxn (lua_State *L) {
+  lua_Number max = 0;
+  luaL_checktype(L, 1, LUA_TTABLE);
+  lua_pushnil(L);  /* first key */
+  while (lua_next(L, 1)) {
+    lua_pop(L, 1);  /* remove value */
+    if (lua_type(L, -1) == LUA_TNUMBER) {
+      lua_Number v = lua_tonumber(L, -1);
+      if (v > max) max = v;
+    }
+  }
+  lua_pushnumber(L, max);
+  return 1;
+}
+
+
+static int getn (lua_State *L) {
+  lua_pushinteger(L, aux_getn(L, 1));
+  return 1;
+}
+
+
+static int setn (lua_State *L) {
+  luaL_checktype(L, 1, LUA_TTABLE);
+#ifndef luaL_setn
+  luaL_setn(L, 1, luaL_checkint(L, 2));
+#else
+  luaL_error(L, LUA_QL("setn") " is obsolete");
+#endif
+  lua_pushvalue(L, 1);
+  return 1;
+}
+
+
+static int tinsert (lua_State *L) {
+  int e = aux_getn(L, 1) + 1;  /* first empty element */
+  int pos;  /* where to insert new element */
+  switch (lua_gettop(L)) {
+    case 2: {  /* called with only 2 arguments */
+      pos = e;  /* insert new element at the end */
+      break;
+    }
+    case 3: {
+      int i;
+      pos = luaL_checkint(L, 2);  /* 2nd argument is the position */
+      if (pos > e) e = pos;  /* `grow' array if necessary */
+      for (i = e; i > pos; i--) {  /* move up elements */
+        lua_rawgeti(L, 1, i-1);
+        lua_rawseti(L, 1, i);  /* t[i] = t[i-1] */
+      }
+      break;
+    }
+    default: {
+      return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
+    }
+  }
+  luaL_setn(L, 1, e);  /* new size */
+  lua_rawseti(L, 1, pos);  /* t[pos] = v */
+  return 0;
+}
+
+
+static int tremove (lua_State *L) {
+  int e = aux_getn(L, 1);
+  int pos = luaL_optint(L, 2, e);
+  if (!(1 <= pos && pos <= e))  /* position is outside bounds? */
+   return 0;  /* nothing to remove */
+  luaL_setn(L, 1, e - 1);  /* t.n = n-1 */
+  lua_rawgeti(L, 1, pos);  /* result = t[pos] */
+  for ( ;pos<e; pos++) {
+    lua_rawgeti(L, 1, pos+1);
+    lua_rawseti(L, 1, pos);  /* t[pos] = t[pos+1] */
+  }
+  lua_pushnil(L);
+  lua_rawseti(L, 1, e);  /* t[e] = nil */
+  return 1;
+}
+
+
+static int tconcat (lua_State *L) {
+  luaL_Buffer b;
+  size_t lsep;
+  int i, last;
+  const char *sep = luaL_optlstring(L, 2, "", &lsep);
+  luaL_checktype(L, 1, LUA_TTABLE);
+  i = luaL_optint(L, 3, 1);
+  last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
+  luaL_buffinit(L, &b);
+  for (; i <= last; i++) {
+    lua_rawgeti(L, 1, i);
+    luaL_argcheck(L, lua_isstring(L, -1), 1, "table contains non-strings");
+    luaL_addvalue(&b);
+    if (i != last)
+      luaL_addlstring(&b, sep, lsep);
+  }
+  luaL_pushresult(&b);
+  return 1;
+}
+
+
+
+/*
+** {======================================================
+** Quicksort
+** (based on `Algorithms in MODULA-3', Robert Sedgewick;
+**  Addison-Wesley, 1993.)
+*/
+
+
+static void set2 (lua_State *L, int i, int j) {
+  lua_rawseti(L, 1, i);
+  lua_rawseti(L, 1, j);
+}
+
+static int sort_comp (lua_State *L, int a, int b) {
+  if (!lua_isnil(L, 2)) {  /* function? */
+    int res;
+    lua_pushvalue(L, 2);
+    lua_pushvalue(L, a-1);  /* -1 to compensate function */
+    lua_pushvalue(L, b-2);  /* -2 to compensate function and `a' */
+    lua_call(L, 2, 1);
+    res = lua_toboolean(L, -1);
+    lua_pop(L, 1);
+    return res;
+  }
+  else  /* a < b? */
+    return lua_lessthan(L, a, b);
+}
+
+static void auxsort (lua_State *L, int l, int u) {
+  while (l < u) {  /* for tail recursion */
+    int i, j;
+    /* sort elements a[l], a[(l+u)/2] and a[u] */
+    lua_rawgeti(L, 1, l);
+    lua_rawgeti(L, 1, u);
+    if (sort_comp(L, -1, -2))  /* a[u] < a[l]? */
+      set2(L, l, u);  /* swap a[l] - a[u] */
+    else
+      lua_pop(L, 2);
+    if (u-l == 1) break;  /* only 2 elements */
+    i = (l+u)/2;
+    lua_rawgeti(L, 1, i);
+    lua_rawgeti(L, 1, l);
+    if (sort_comp(L, -2, -1))  /* a[i]<a[l]? */
+      set2(L, i, l);
+    else {
+      lua_pop(L, 1);  /* remove a[l] */
+      lua_rawgeti(L, 1, u);
+      if (sort_comp(L, -1, -2))  /* a[u]<a[i]? */
+        set2(L, i, u);
+      else
+        lua_pop(L, 2);
+    }
+    if (u-l == 2) break;  /* only 3 elements */
+    lua_rawgeti(L, 1, i);  /* Pivot */
+    lua_pushvalue(L, -1);
+    lua_rawgeti(L, 1, u-1);
+    set2(L, i, u-1);
+    /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
+    i = l; j = u-1;
+    for (;;) {  /* invariant: a[l..i] <= P <= a[j..u] */
+      /* repeat ++i until a[i] >= P */
+      while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
+        if (i>u) luaL_error(L, "invalid order function for sorting");
+        lua_pop(L, 1);  /* remove a[i] */
+      }
+      /* repeat --j until a[j] <= P */
+      while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
+        if (j<l) luaL_error(L, "invalid order function for sorting");
+        lua_pop(L, 1);  /* remove a[j] */
+      }
+      if (j<i) {
+        lua_pop(L, 3);  /* pop pivot, a[i], a[j] */
+        break;
+      }
+      set2(L, i, j);
+    }
+    lua_rawgeti(L, 1, u-1);
+    lua_rawgeti(L, 1, i);
+    set2(L, u-1, i);  /* swap pivot (a[u-1]) with a[i] */
+    /* a[l..i-1] <= a[i] == P <= a[i+1..u] */
+    /* adjust so that smaller half is in [j..i] and larger one in [l..u] */
+    if (i-l < u-i) {
+      j=l; i=i-1; l=i+2;
+    }
+    else {
+      j=i+1; i=u; u=j-2;
+    }
+    auxsort(L, j, i);  /* call recursively the smaller one */
+  }  /* repeat the routine for the larger one */
+}
+
+static int sort (lua_State *L) {
+  int n = aux_getn(L, 1);
+  luaL_checkstack(L, 40, "");  /* assume array is smaller than 2^40 */
+  if (!lua_isnoneornil(L, 2))  /* is there a 2nd argument? */
+    luaL_checktype(L, 2, LUA_TFUNCTION);
+  lua_settop(L, 2);  /* make sure there is two arguments */
+  auxsort(L, 1, n);
+  return 0;
+}
+
+/* }====================================================== */
+
+
+static const luaL_Reg tab_funcs[] = {
+  {"concat", tconcat},
+  {"foreach", foreach},
+  {"foreachi", foreachi},
+  {"getn", getn},
+  {"maxn", maxn},
+  {"insert", tinsert},
+  {"remove", tremove},
+  {"setn", setn},
+  {"sort", sort},
+  {NULL, NULL}
+};
+
+
+LUALIB_API int luaopen_table (lua_State *L) {
+  luaL_register(L, LUA_TABLIBNAME, tab_funcs);
+  return 1;
+}
+
Index: /code/branches/physics/src/lua/ltm.c
===================================================================
--- /code/branches/physics/src/lua/ltm.c	(revision 2122)
+++ /code/branches/physics/src/lua/ltm.c	(revision 2122)
@@ -0,0 +1,75 @@
+/*
+** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
+** Tag methods
+** See Copyright Notice in lua.h
+*/
+
+
+#include <string.h>
+
+#define ltm_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "lobject.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+
+
+
+const char *const luaT_typenames[] = {
+  "nil", "boolean", "userdata", "number",
+  "string", "table", "function", "userdata", "thread",
+  "proto", "upval"
+};
+
+
+void luaT_init (lua_State *L) {
+  static const char *const luaT_eventname[] = {  /* ORDER TM */
+    "__index", "__newindex",
+    "__gc", "__mode", "__eq",
+    "__add", "__sub", "__mul", "__div", "__mod",
+    "__pow", "__unm", "__len", "__lt", "__le",
+    "__concat", "__call"
+  };
+  int i;
+  for (i=0; i<TM_N; i++) {
+    G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
+    luaS_fix(G(L)->tmname[i]);  /* never collect these names */
+  }
+}
+
+
+/*
+** function to be used with macro "fasttm": optimized for absence of
+** tag methods
+*/
+const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
+  const TValue *tm = luaH_getstr(events, ename);
+  lua_assert(event <= TM_EQ);
+  if (ttisnil(tm)) {  /* no tag method? */
+    events->flags |= cast_byte(1u<<event);  /* cache this fact */
+    return NULL;
+  }
+  else return tm;
+}
+
+
+const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
+  Table *mt;
+  switch (ttype(o)) {
+    case LUA_TTABLE:
+      mt = hvalue(o)->metatable;
+      break;
+    case LUA_TUSERDATA:
+      mt = uvalue(o)->metatable;
+      break;
+    default:
+      mt = G(L)->mt[ttype(o)];
+  }
+  return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
+}
+
Index: /code/branches/physics/src/lua/ltm.h
===================================================================
--- /code/branches/physics/src/lua/ltm.h	(revision 2122)
+++ /code/branches/physics/src/lua/ltm.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
+** Tag methods
+** See Copyright Notice in lua.h
+*/
+
+#ifndef ltm_h
+#define ltm_h
+
+
+#include "lobject.h"
+
+
+/*
+* WARNING: if you change the order of this enumeration,
+* grep "ORDER TM"
+*/
+typedef enum {
+  TM_INDEX,
+  TM_NEWINDEX,
+  TM_GC,
+  TM_MODE,
+  TM_EQ,  /* last tag method with `fast' access */
+  TM_ADD,
+  TM_SUB,
+  TM_MUL,
+  TM_DIV,
+  TM_MOD,
+  TM_POW,
+  TM_UNM,
+  TM_LEN,
+  TM_LT,
+  TM_LE,
+  TM_CONCAT,
+  TM_CALL,
+  TM_N		/* number of elements in the enum */
+} TMS;
+
+
+
+#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
+  ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
+
+#define fasttm(l,et,e)	gfasttm(G(l), et, e)
+
+LUAI_DATA const char *const luaT_typenames[];
+
+
+LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
+LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
+                                                       TMS event);
+LUAI_FUNC void luaT_init (lua_State *L);
+
+#endif
Index: /code/branches/physics/src/lua/lua.h
===================================================================
--- /code/branches/physics/src/lua/lua.h	(revision 2122)
+++ /code/branches/physics/src/lua/lua.h	(revision 2122)
@@ -0,0 +1,388 @@
+/*
+** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $
+** Lua - An Extensible Extension Language
+** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
+** See Copyright Notice at the end of this file
+*/
+
+
+#ifndef lua_h
+#define lua_h
+
+#include <stdarg.h>
+#include <stddef.h>
+
+
+#include "luaconf.h"
+
+
+#define LUA_VERSION	"Lua 5.1"
+#define LUA_RELEASE	"Lua 5.1.3"
+#define LUA_VERSION_NUM	501
+#define LUA_COPYRIGHT	"Copyright (C) 1994-2008 Lua.org, PUC-Rio"
+#define LUA_AUTHORS 	"R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
+
+
+/* mark for precompiled code (`<esc>Lua') */
+#define	LUA_SIGNATURE	"\033Lua"
+
+/* option for multiple returns in `lua_pcall' and `lua_call' */
+#define LUA_MULTRET	(-1)
+
+
+/*
+** pseudo-indices
+*/
+#define LUA_REGISTRYINDEX	(-10000)
+#define LUA_ENVIRONINDEX	(-10001)
+#define LUA_GLOBALSINDEX	(-10002)
+#define lua_upvalueindex(i)	(LUA_GLOBALSINDEX-(i))
+
+
+/* thread status; 0 is OK */
+#define LUA_YIELD	1
+#define LUA_ERRRUN	2
+#define LUA_ERRSYNTAX	3
+#define LUA_ERRMEM	4
+#define LUA_ERRERR	5
+
+
+typedef struct lua_State lua_State;
+
+typedef int (*lua_CFunction) (lua_State *L);
+
+
+/*
+** functions that read/write blocks when loading/dumping Lua chunks
+*/
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+
+typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
+
+
+/*
+** prototype for memory-allocation functions
+*/
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+
+
+/*
+** basic types
+*/
+#define LUA_TNONE		(-1)
+
+#define LUA_TNIL		0
+#define LUA_TBOOLEAN		1
+#define LUA_TLIGHTUSERDATA	2
+#define LUA_TNUMBER		3
+#define LUA_TSTRING		4
+#define LUA_TTABLE		5
+#define LUA_TFUNCTION		6
+#define LUA_TUSERDATA		7
+#define LUA_TTHREAD		8
+
+
+
+/* minimum Lua stack available to a C function */
+#define LUA_MINSTACK	20
+
+
+/*
+** generic extra include file
+*/
+#if defined(LUA_USER_H)
+#include LUA_USER_H
+#endif
+
+
+/* type of numbers in Lua */
+typedef LUA_NUMBER lua_Number;
+
+
+/* type for integer functions */
+typedef LUA_INTEGER lua_Integer;
+
+
+
+/*
+** state manipulation
+*/
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
+LUA_API void       (lua_close) (lua_State *L);
+LUA_API lua_State *(lua_newthread) (lua_State *L);
+
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
+
+
+/*
+** basic stack manipulation
+*/
+LUA_API int   (lua_gettop) (lua_State *L);
+LUA_API void  (lua_settop) (lua_State *L, int idx);
+LUA_API void  (lua_pushvalue) (lua_State *L, int idx);
+LUA_API void  (lua_remove) (lua_State *L, int idx);
+LUA_API void  (lua_insert) (lua_State *L, int idx);
+LUA_API void  (lua_replace) (lua_State *L, int idx);
+LUA_API int   (lua_checkstack) (lua_State *L, int sz);
+
+LUA_API void  (lua_xmove) (lua_State *from, lua_State *to, int n);
+
+
+/*
+** access functions (stack -> C)
+*/
+
+LUA_API int             (lua_isnumber) (lua_State *L, int idx);
+LUA_API int             (lua_isstring) (lua_State *L, int idx);
+LUA_API int             (lua_iscfunction) (lua_State *L, int idx);
+LUA_API int             (lua_isuserdata) (lua_State *L, int idx);
+LUA_API int             (lua_type) (lua_State *L, int idx);
+LUA_API const char     *(lua_typename) (lua_State *L, int tp);
+
+LUA_API int            (lua_equal) (lua_State *L, int idx1, int idx2);
+LUA_API int            (lua_rawequal) (lua_State *L, int idx1, int idx2);
+LUA_API int            (lua_lessthan) (lua_State *L, int idx1, int idx2);
+
+LUA_API lua_Number      (lua_tonumber) (lua_State *L, int idx);
+LUA_API lua_Integer     (lua_tointeger) (lua_State *L, int idx);
+LUA_API int             (lua_toboolean) (lua_State *L, int idx);
+LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);
+LUA_API size_t          (lua_objlen) (lua_State *L, int idx);
+LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);
+LUA_API void	       *(lua_touserdata) (lua_State *L, int idx);
+LUA_API lua_State      *(lua_tothread) (lua_State *L, int idx);
+LUA_API const void     *(lua_topointer) (lua_State *L, int idx);
+
+
+/*
+** push functions (C -> stack)
+*/
+LUA_API void  (lua_pushnil) (lua_State *L);
+LUA_API void  (lua_pushnumber) (lua_State *L, lua_Number n);
+LUA_API void  (lua_pushinteger) (lua_State *L, lua_Integer n);
+LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
+LUA_API void  (lua_pushstring) (lua_State *L, const char *s);
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
+                                                      va_list argp);
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
+LUA_API void  (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
+LUA_API void  (lua_pushboolean) (lua_State *L, int b);
+LUA_API void  (lua_pushlightuserdata) (lua_State *L, void *p);
+LUA_API int   (lua_pushthread) (lua_State *L);
+
+
+/*
+** get functions (Lua -> stack)
+*/
+LUA_API void  (lua_gettable) (lua_State *L, int idx);
+LUA_API void  (lua_getfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_rawget) (lua_State *L, int idx);
+LUA_API void  (lua_rawgeti) (lua_State *L, int idx, int n);
+LUA_API void  (lua_createtable) (lua_State *L, int narr, int nrec);
+LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
+LUA_API int   (lua_getmetatable) (lua_State *L, int objindex);
+LUA_API void  (lua_getfenv) (lua_State *L, int idx);
+
+
+/*
+** set functions (stack -> Lua)
+*/
+LUA_API void  (lua_settable) (lua_State *L, int idx);
+LUA_API void  (lua_setfield) (lua_State *L, int idx, const char *k);
+LUA_API void  (lua_rawset) (lua_State *L, int idx);
+LUA_API void  (lua_rawseti) (lua_State *L, int idx, int n);
+LUA_API int   (lua_setmetatable) (lua_State *L, int objindex);
+LUA_API int   (lua_setfenv) (lua_State *L, int idx);
+
+
+/*
+** `load' and `call' functions (load and run Lua code)
+*/
+LUA_API void  (lua_call) (lua_State *L, int nargs, int nresults);
+LUA_API int   (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
+LUA_API int   (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
+LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
+                                        const char *chunkname);
+
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
+
+
+/*
+** coroutine functions
+*/
+LUA_API int  (lua_yield) (lua_State *L, int nresults);
+LUA_API int  (lua_resume) (lua_State *L, int narg);
+LUA_API int  (lua_status) (lua_State *L);
+
+/*
+** garbage-collection function and options
+*/
+
+#define LUA_GCSTOP		0
+#define LUA_GCRESTART		1
+#define LUA_GCCOLLECT		2
+#define LUA_GCCOUNT		3
+#define LUA_GCCOUNTB		4
+#define LUA_GCSTEP		5
+#define LUA_GCSETPAUSE		6
+#define LUA_GCSETSTEPMUL	7
+
+LUA_API int (lua_gc) (lua_State *L, int what, int data);
+
+
+/*
+** miscellaneous functions
+*/
+
+LUA_API int   (lua_error) (lua_State *L);
+
+LUA_API int   (lua_next) (lua_State *L, int idx);
+
+LUA_API void  (lua_concat) (lua_State *L, int n);
+
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
+LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+
+
+
+/* 
+** ===============================================================
+** some useful macros
+** ===============================================================
+*/
+
+#define lua_pop(L,n)		lua_settop(L, -(n)-1)
+
+#define lua_newtable(L)		lua_createtable(L, 0, 0)
+
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+
+#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)
+
+#define lua_strlen(L,i)		lua_objlen(L, (i))
+
+#define lua_isfunction(L,n)	(lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n)	(lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n)	(lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n)		(lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n)	(lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n)	(lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n)		(lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n)	(lua_type(L, (n)) <= 0)
+
+#define lua_pushliteral(L, s)	\
+	lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+
+#define lua_setglobal(L,s)	lua_setfield(L, LUA_GLOBALSINDEX, (s))
+#define lua_getglobal(L,s)	lua_getfield(L, LUA_GLOBALSINDEX, (s))
+
+#define lua_tostring(L,i)	lua_tolstring(L, (i), NULL)
+
+
+
+/*
+** compatibility macros and functions
+*/
+
+#define lua_open()	luaL_newstate()
+
+#define lua_getregistry(L)	lua_pushvalue(L, LUA_REGISTRYINDEX)
+
+#define lua_getgccount(L)	lua_gc(L, LUA_GCCOUNT, 0)
+
+#define lua_Chunkreader		lua_Reader
+#define lua_Chunkwriter		lua_Writer
+
+
+/* hack */
+LUA_API void lua_setlevel	(lua_State *from, lua_State *to);
+
+
+/*
+** {======================================================================
+** Debug API
+** =======================================================================
+*/
+
+
+/*
+** Event codes
+*/
+#define LUA_HOOKCALL	0
+#define LUA_HOOKRET	1
+#define LUA_HOOKLINE	2
+#define LUA_HOOKCOUNT	3
+#define LUA_HOOKTAILRET 4
+
+
+/*
+** Event masks
+*/
+#define LUA_MASKCALL	(1 << LUA_HOOKCALL)
+#define LUA_MASKRET	(1 << LUA_HOOKRET)
+#define LUA_MASKLINE	(1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT	(1 << LUA_HOOKCOUNT)
+
+typedef struct lua_Debug lua_Debug;  /* activation record */
+
+
+/* Functions to be called by the debuger in specific events */
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+
+LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
+LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
+
+LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
+LUA_API lua_Hook lua_gethook (lua_State *L);
+LUA_API int lua_gethookmask (lua_State *L);
+LUA_API int lua_gethookcount (lua_State *L);
+
+
+struct lua_Debug {
+  int event;
+  const char *name;	/* (n) */
+  const char *namewhat;	/* (n) `global', `local', `field', `method' */
+  const char *what;	/* (S) `Lua', `C', `main', `tail' */
+  const char *source;	/* (S) */
+  int currentline;	/* (l) */
+  int nups;		/* (u) number of upvalues */
+  int linedefined;	/* (S) */
+  int lastlinedefined;	/* (S) */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  /* private part */
+  int i_ci;  /* active function */
+};
+
+/* }====================================================================== */
+
+
+/******************************************************************************
+* Copyright (C) 1994-2008 Lua.org, PUC-Rio.  All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to deal in the Software without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to
+* permit persons to whom the Software is furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+******************************************************************************/
+
+
+#endif
Index: /code/branches/physics/src/lua/lua.hpp
===================================================================
--- /code/branches/physics/src/lua/lua.hpp	(revision 2122)
+++ /code/branches/physics/src/lua/lua.hpp	(revision 2122)
@@ -0,0 +1,9 @@
+// lua.hpp
+// Lua header files for C++
+// <<extern "C">> not supplied automatically because Lua also compiles as C++
+
+extern "C" {
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+}
Index: /code/branches/physics/src/lua/luaconf.h
===================================================================
--- /code/branches/physics/src/lua/luaconf.h	(revision 2122)
+++ /code/branches/physics/src/lua/luaconf.h	(revision 2122)
@@ -0,0 +1,763 @@
+/*
+** $Id: luaconf.h,v 1.82.1.6 2008/01/18 17:07:48 roberto Exp $
+** Configuration file for Lua
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lconfig_h
+#define lconfig_h
+
+#include <limits.h>
+#include <stddef.h>
+
+
+/*
+** ==================================================================
+** Search for "@@" to find all configurable definitions.
+** ===================================================================
+*/
+
+
+/*
+@@ LUA_ANSI controls the use of non-ansi features.
+** CHANGE it (define it) if you want Lua to avoid the use of any
+** non-ansi feature or library.
+*/
+#if defined(__STRICT_ANSI__)
+#define LUA_ANSI
+#endif
+
+
+#if !defined(LUA_ANSI) && defined(_WIN32)
+#define LUA_WIN
+#endif
+
+#if defined(LUA_USE_LINUX)
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
+#define LUA_USE_READLINE	/* needs some extra libraries */
+#endif
+
+#if defined(LUA_USE_MACOSX)
+#define LUA_USE_POSIX
+#define LUA_DL_DYLD		/* does not need extra library */
+#endif
+
+
+
+/*
+@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
+@* Interfaces Extension (XSI).
+** CHANGE it (define it) if your system is XSI compatible.
+*/
+#if defined(LUA_USE_POSIX)
+#define LUA_USE_MKSTEMP
+#define LUA_USE_ISATTY
+#define LUA_USE_POPEN
+#define LUA_USE_ULONGJMP
+#endif
+
+
+/*
+@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
+@* Lua check to set its paths.
+@@ LUA_INIT is the name of the environment variable that Lua
+@* checks for initialization code.
+** CHANGE them if you want different names.
+*/
+#define LUA_PATH        "LUA_PATH"
+#define LUA_CPATH       "LUA_CPATH"
+#define LUA_INIT	"LUA_INIT"
+
+
+/*
+@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
+@* Lua libraries.
+@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
+@* C libraries.
+** CHANGE them if your machine has a non-conventional directory
+** hierarchy or if you want to install your libraries in
+** non-conventional directories.
+*/
+#if defined(_WIN32)
+/*
+** In Windows, any exclamation mark ('!') in the path is replaced by the
+** path of the directory of the executable file of the current process.
+*/
+#define LUA_LDIR	"!\\lua\\"
+#define LUA_CDIR	"!\\"
+#define LUA_PATH_DEFAULT  \
+		".\\?.lua;"  LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
+		             LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua"
+#define LUA_CPATH_DEFAULT \
+	".\\?.dll;"  LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
+
+#else
+#define LUA_ROOT	"/usr/local/"
+#define LUA_LDIR	LUA_ROOT "share/lua/5.1/"
+#define LUA_CDIR	LUA_ROOT "lib/lua/5.1/"
+#define LUA_PATH_DEFAULT  \
+		"./?.lua;"  LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
+		            LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua"
+#define LUA_CPATH_DEFAULT \
+	"./?.so;"  LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
+#endif
+
+
+/*
+@@ LUA_DIRSEP is the directory separator (for submodules).
+** CHANGE it if your machine does not use "/" as the directory separator
+** and is not Windows. (On Windows Lua automatically uses "\".)
+*/
+#if defined(_WIN32)
+#define LUA_DIRSEP	"\\"
+#else
+#define LUA_DIRSEP	"/"
+#endif
+
+
+/*
+@@ LUA_PATHSEP is the character that separates templates in a path.
+@@ LUA_PATH_MARK is the string that marks the substitution points in a
+@* template.
+@@ LUA_EXECDIR in a Windows path is replaced by the executable's
+@* directory.
+@@ LUA_IGMARK is a mark to ignore all before it when bulding the
+@* luaopen_ function name.
+** CHANGE them if for some reason your system cannot use those
+** characters. (E.g., if one of those characters is a common character
+** in file/directory names.) Probably you do not need to change them.
+*/
+#define LUA_PATHSEP	";"
+#define LUA_PATH_MARK	"?"
+#define LUA_EXECDIR	"!"
+#define LUA_IGMARK	"-"
+
+
+/*
+@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+** machines, ptrdiff_t gives a good choice between int or long.)
+*/
+#define LUA_INTEGER	ptrdiff_t
+
+
+/*
+@@ LUA_API is a mark for all core API functions.
+@@ LUALIB_API is a mark for all standard library functions.
+** CHANGE them if you need to define those functions in some special way.
+** For instance, if you want to create one Windows DLL with the core and
+** the libraries, you may want to use the following definition (define
+** LUA_BUILD_AS_DLL to get it).
+*/
+#if defined(LUA_BUILD_AS_DLL)
+
+#if defined(LUA_CORE) || defined(LUA_LIB)
+#define LUA_API __declspec(dllexport)
+#else
+#define LUA_API __declspec(dllimport)
+#endif
+
+#else
+
+#define LUA_API		extern
+
+#endif
+
+/* more often than not the libs go together with the core */
+#define LUALIB_API	LUA_API
+
+
+/*
+@@ LUAI_FUNC is a mark for all extern functions that are not to be
+@* exported to outside modules.
+@@ LUAI_DATA is a mark for all extern (const) variables that are not to
+@* be exported to outside modules.
+** CHANGE them if you need to mark them in some special way. Elf/gcc
+** (versions 3.2 and later) mark them as "hidden" to optimize access
+** when Lua is compiled as a shared library.
+*/
+#if defined(luaall_c)
+#define LUAI_FUNC	static
+#define LUAI_DATA	/* empty */
+
+#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+      defined(__ELF__)
+#define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
+#define LUAI_DATA	LUAI_FUNC
+
+#else
+#define LUAI_FUNC	extern
+#define LUAI_DATA	extern
+#endif
+
+
+
+/*
+@@ LUA_QL describes how error messages quote program elements.
+** CHANGE it if you want a different appearance.
+*/
+#define LUA_QL(x)	"'" x "'"
+#define LUA_QS		LUA_QL("%s")
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@* of a function in debug information.
+** CHANGE it if you want a different size.
+*/
+#define LUA_IDSIZE	60
+
+
+/*
+** {==================================================================
+** Stand-alone configuration
+** ===================================================================
+*/
+
+#if defined(lua_c) || defined(luaall_c)
+
+/*
+@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
+@* is, whether we're running lua interactively).
+** CHANGE it if you have a better definition for non-POSIX/non-Windows
+** systems.
+*/
+#if defined(LUA_USE_ISATTY)
+#include <unistd.h>
+#define lua_stdin_is_tty()	isatty(0)
+#elif defined(LUA_WIN)
+#include <io.h>
+#include <stdio.h>
+#define lua_stdin_is_tty()	_isatty(_fileno(stdin))
+#else
+#define lua_stdin_is_tty()	1  /* assume stdin is a tty */
+#endif
+
+
+/*
+@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
+@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
+** CHANGE them if you want different prompts. (You can also change the
+** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
+*/
+#define LUA_PROMPT		"> "
+#define LUA_PROMPT2		">> "
+
+
+/*
+@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
+** CHANGE it if your stand-alone interpreter has a different name and
+** your system is not able to detect that name automatically.
+*/
+#define LUA_PROGNAME		"lua"
+
+
+/*
+@@ LUA_MAXINPUT is the maximum length for an input line in the
+@* stand-alone interpreter.
+** CHANGE it if you need longer lines.
+*/
+#define LUA_MAXINPUT	512
+
+
+/*
+@@ lua_readline defines how to show a prompt and then read a line from
+@* the standard input.
+@@ lua_saveline defines how to "save" a read line in a "history".
+@@ lua_freeline defines how to free a line read by lua_readline.
+** CHANGE them if you want to improve this functionality (e.g., by using
+** GNU readline and history facilities).
+*/
+#if defined(LUA_USE_READLINE)
+#include <stdio.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+#define lua_readline(L,b,p)	((void)L, ((b)=readline(p)) != NULL)
+#define lua_saveline(L,idx) \
+	if (lua_strlen(L,idx) > 0)  /* non-empty line? */ \
+	  add_history(lua_tostring(L, idx));  /* add it to history */
+#define lua_freeline(L,b)	((void)L, free(b))
+#else
+#define lua_readline(L,b,p)	\
+	((void)L, fputs(p, stdout), fflush(stdout),  /* show prompt */ \
+	fgets(b, LUA_MAXINPUT, stdin) != NULL)  /* get line */
+#define lua_saveline(L,idx)	{ (void)L; (void)idx; }
+#define lua_freeline(L,b)	{ (void)L; (void)b; }
+#endif
+
+#endif
+
+/* }================================================================== */
+
+
+/*
+@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
+@* as a percentage.
+** CHANGE it if you want the GC to run faster or slower (higher values
+** mean larger pauses which mean slower collection.) You can also change
+** this value dynamically.
+*/
+#define LUAI_GCPAUSE	200  /* 200% (wait memory to double before next GC) */
+
+
+/*
+@@ LUAI_GCMUL defines the default speed of garbage collection relative to
+@* memory allocation as a percentage.
+** CHANGE it if you want to change the granularity of the garbage
+** collection. (Higher values mean coarser collections. 0 represents
+** infinity, where each step performs a full collection.) You can also
+** change this value dynamically.
+*/
+#define LUAI_GCMUL	200 /* GC runs 'twice the speed' of memory allocation */
+
+
+
+/*
+@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
+** CHANGE it (define it) if you want exact compatibility with the
+** behavior of setn/getn in Lua 5.0.
+*/
+#undef LUA_COMPAT_GETN
+
+/*
+@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
+** CHANGE it to undefined as soon as you do not need a global 'loadlib'
+** function (the function is still available as 'package.loadlib').
+*/
+#undef LUA_COMPAT_LOADLIB
+
+/*
+@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
+** CHANGE it to undefined as soon as your programs use only '...' to
+** access vararg parameters (instead of the old 'arg' table).
+*/
+#define LUA_COMPAT_VARARG
+
+/*
+@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
+** CHANGE it to undefined as soon as your programs use 'math.fmod' or
+** the new '%' operator instead of 'math.mod'.
+*/
+#define LUA_COMPAT_MOD
+
+/*
+@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
+@* facility.
+** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
+** off the advisory error when nesting [[...]].
+*/
+#define LUA_COMPAT_LSTR		1
+
+/*
+@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
+** CHANGE it to undefined as soon as you rename 'string.gfind' to
+** 'string.gmatch'.
+*/
+#define LUA_COMPAT_GFIND
+
+/*
+@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
+@* behavior.
+** CHANGE it to undefined as soon as you replace to 'luaL_register'
+** your uses of 'luaL_openlib'
+*/
+#define LUA_COMPAT_OPENLIB
+
+
+
+/*
+@@ luai_apicheck is the assert macro used by the Lua-C API.
+** CHANGE luai_apicheck if you want Lua to perform some checks in the
+** parameters it gets from API calls. This may slow down the interpreter
+** a bit, but may be quite useful when debugging C code that interfaces
+** with Lua. A useful redefinition is to use assert.h.
+*/
+#if defined(LUA_USE_APICHECK)
+#include <assert.h>
+#define luai_apicheck(L,o)	{ (void)L; assert(o); }
+#else
+#define luai_apicheck(L,o)	{ (void)L; }
+#endif
+
+
+/*
+@@ LUAI_BITSINT defines the number of bits in an int.
+** CHANGE here if Lua cannot automatically detect the number of bits of
+** your machine. Probably you do not need to change this.
+*/
+/* avoid overflows in comparison */
+#if INT_MAX-20 < 32760
+#define LUAI_BITSINT	16
+#elif INT_MAX > 2147483640L
+/* int has at least 32 bits */
+#define LUAI_BITSINT	32
+#else
+#error "you must define LUA_BITSINT with number of bits in an integer"
+#endif
+
+
+/*
+@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
+@@ LUAI_INT32 is an signed integer with at least 32 bits.
+@@ LUAI_UMEM is an unsigned integer big enough to count the total
+@* memory used by Lua.
+@@ LUAI_MEM is a signed integer big enough to count the total memory
+@* used by Lua.
+** CHANGE here if for some weird reason the default definitions are not
+** good enough for your machine. (The definitions in the 'else'
+** part always works, but may waste space on machines with 64-bit
+** longs.) Probably you do not need to change this.
+*/
+#if LUAI_BITSINT >= 32
+#define LUAI_UINT32	unsigned int
+#define LUAI_INT32	int
+#define LUAI_MAXINT32	INT_MAX
+#define LUAI_UMEM	size_t
+#define LUAI_MEM	ptrdiff_t
+#else
+/* 16-bit ints */
+#define LUAI_UINT32	unsigned long
+#define LUAI_INT32	long
+#define LUAI_MAXINT32	LONG_MAX
+#define LUAI_UMEM	unsigned long
+#define LUAI_MEM	long
+#endif
+
+
+/*
+@@ LUAI_MAXCALLS limits the number of nested calls.
+** CHANGE it if you need really deep recursive calls. This limit is
+** arbitrary; its only purpose is to stop infinite recursion before
+** exhausting memory.
+*/
+#define LUAI_MAXCALLS	20000
+
+
+/*
+@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
+@* can use.
+** CHANGE it if you need lots of (Lua) stack space for your C
+** functions. This limit is arbitrary; its only purpose is to stop C
+** functions to consume unlimited stack space.
+*/
+#define LUAI_MCS_AUX	((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
+#define LUAI_MAXCSTACK	(LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
+
+
+
+/*
+** {==================================================================
+** CHANGE (to smaller values) the following definitions if your system
+** has a small C stack. (Or you may want to change them to larger
+** values if your system has a large C stack and these limits are
+** too rigid for you.) Some of these constants control the size of
+** stack-allocated arrays used by the compiler or the interpreter, while
+** others limit the maximum number of recursive calls that the compiler
+** or the interpreter can perform. Values too large may cause a C stack
+** overflow for some forms of deep constructs.
+** ===================================================================
+*/
+
+
+/*
+@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
+@* syntactical nested non-terminals in a program.
+*/
+#define LUAI_MAXCCALLS		200
+
+
+/*
+@@ LUAI_MAXVARS is the maximum number of local variables per function
+@* (must be smaller than 250).
+*/
+#define LUAI_MAXVARS		200
+
+
+/*
+@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
+@* (must be smaller than 250).
+*/
+#define LUAI_MAXUPVALUES	60
+
+
+/*
+@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
+*/
+#define LUAL_BUFFERSIZE		BUFSIZ
+
+/* }================================================================== */
+
+
+
+
+/*
+** {==================================================================
+@@ LUA_NUMBER is the type of numbers in Lua.
+** CHANGE the following definitions only if you want to build Lua
+** with a number type different from double. You may also need to
+** change lua_number2int & lua_number2integer.
+** ===================================================================
+*/
+
+#define LUA_NUMBER_DOUBLE
+#define LUA_NUMBER	double
+
+/*
+@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+@* over a number.
+*/
+#define LUAI_UACNUMBER	double
+
+
+/*
+@@ LUA_NUMBER_SCAN is the format for reading numbers.
+@@ LUA_NUMBER_FMT is the format for writing numbers.
+@@ lua_number2str converts a number to a string.
+@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+@@ lua_str2number converts a string to a number.
+*/
+#define LUA_NUMBER_SCAN		"%lf"
+#define LUA_NUMBER_FMT		"%.14g"
+#define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))
+#define LUAI_MAXNUMBER2STR	32 /* 16 digits, sign, point, and \0 */
+#define lua_str2number(s,p)	strtod((s), (p))
+
+
+/*
+@@ The luai_num* macros define the primitive operations over numbers.
+*/
+#if defined(LUA_CORE)
+#include <math.h>
+#define luai_numadd(a,b)	((a)+(b))
+#define luai_numsub(a,b)	((a)-(b))
+#define luai_nummul(a,b)	((a)*(b))
+#define luai_numdiv(a,b)	((a)/(b))
+#define luai_nummod(a,b)	((a) - floor((a)/(b))*(b))
+#define luai_numpow(a,b)	(pow(a,b))
+#define luai_numunm(a)		(-(a))
+#define luai_numeq(a,b)		((a)==(b))
+#define luai_numlt(a,b)		((a)<(b))
+#define luai_numle(a,b)		((a)<=(b))
+#define luai_numisnan(a)	(!luai_numeq((a), (a)))
+#endif
+
+
+/*
+@@ lua_number2int is a macro to convert lua_Number to int.
+@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
+** CHANGE them if you know a faster way to convert a lua_Number to
+** int (with any rounding method and without throwing errors) in your
+** system. In Pentium machines, a naive typecast from double to int
+** in C is extremely slow, so any alternative is worth trying.
+*/
+
+/* On a Pentium, resort to a trick */
+#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
+    (defined(__i386) || defined (_M_IX86) || defined(__i386__))
+
+/* On a Microsoft compiler, use assembler */
+#if defined(_MSC_VER)
+
+#define lua_number2int(i,d)   __asm fld d   __asm fistp i
+#define lua_number2integer(i,n)		lua_number2int(i, n)
+
+/* the next trick should work on any Pentium, but sometimes clashes
+   with a DirectX idiosyncrasy */
+#else
+
+union luai_Cast { double l_d; long l_l; };
+#define lua_number2int(i,d) \
+  { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
+#define lua_number2integer(i,n)		lua_number2int(i, n)
+
+#endif
+
+
+/* this option always works, but may be slow */
+#else
+#define lua_number2int(i,d)	((i)=(int)(d))
+#define lua_number2integer(i,d)	((i)=(lua_Integer)(d))
+
+#endif
+
+/* }================================================================== */
+
+
+/*
+@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
+** CHANGE it if your system requires alignments larger than double. (For
+** instance, if your system supports long doubles and they must be
+** aligned in 16-byte boundaries, then you should add long double in the
+** union.) Probably you do not need to change this.
+*/
+#define LUAI_USER_ALIGNMENT_T	union { double u; void *s; long l; }
+
+
+/*
+@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
+** CHANGE them if you prefer to use longjmp/setjmp even with C++
+** or if want/don't to use _longjmp/_setjmp instead of regular
+** longjmp/setjmp. By default, Lua handles errors with exceptions when
+** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
+** and with longjmp/setjmp otherwise.
+*/
+#if defined(__cplusplus)
+/* C++ exceptions */
+#define LUAI_THROW(L,c)	throw(c)
+#define LUAI_TRY(L,c,a)	try { a } catch(...) \
+	{ if ((c)->status == 0) (c)->status = -1; }
+#define luai_jmpbuf	int  /* dummy variable */
+
+#elif defined(LUA_USE_ULONGJMP)
+/* in Unix, try _longjmp/_setjmp (more efficient) */
+#define LUAI_THROW(L,c)	_longjmp((c)->b, 1)
+#define LUAI_TRY(L,c,a)	if (_setjmp((c)->b) == 0) { a }
+#define luai_jmpbuf	jmp_buf
+
+#else
+/* default handling with long jumps */
+#define LUAI_THROW(L,c)	longjmp((c)->b, 1)
+#define LUAI_TRY(L,c,a)	if (setjmp((c)->b) == 0) { a }
+#define luai_jmpbuf	jmp_buf
+
+#endif
+
+
+/*
+@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
+@* can do during pattern-matching.
+** CHANGE it if you need more captures. This limit is arbitrary.
+*/
+#define LUA_MAXCAPTURES		32
+
+
+/*
+@@ lua_tmpnam is the function that the OS library uses to create a
+@* temporary name.
+@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
+** CHANGE them if you have an alternative to tmpnam (which is considered
+** insecure) or if you want the original tmpnam anyway.  By default, Lua
+** uses tmpnam except when POSIX is available, where it uses mkstemp.
+*/
+#if defined(loslib_c) || defined(luaall_c)
+
+#if defined(LUA_USE_MKSTEMP)
+#include <unistd.h>
+#define LUA_TMPNAMBUFSIZE	32
+#define lua_tmpnam(b,e)	{ \
+	strcpy(b, "/tmp/lua_XXXXXX"); \
+	e = mkstemp(b); \
+	if (e != -1) close(e); \
+	e = (e == -1); }
+
+#else
+#define LUA_TMPNAMBUFSIZE	L_tmpnam
+#define lua_tmpnam(b,e)		{ e = (tmpnam(b) == NULL); }
+#endif
+
+#endif
+
+
+/*
+@@ lua_popen spawns a new process connected to the current one through
+@* the file streams.
+** CHANGE it if you have a way to implement it in your system.
+*/
+#if defined(LUA_USE_POPEN)
+
+#define lua_popen(L,c,m)	((void)L, fflush(NULL), popen(c,m))
+#define lua_pclose(L,file)	((void)L, (pclose(file) != -1))
+
+#elif defined(LUA_WIN)
+
+#define lua_popen(L,c,m)	((void)L, _popen(c,m))
+#define lua_pclose(L,file)	((void)L, (_pclose(file) != -1))
+
+#else
+
+#define lua_popen(L,c,m)	((void)((void)c, m),  \
+		luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
+#define lua_pclose(L,file)		((void)((void)L, file), 0)
+
+#endif
+
+/*
+@@ LUA_DL_* define which dynamic-library system Lua should use.
+** CHANGE here if Lua has problems choosing the appropriate
+** dynamic-library system for your platform (either Windows' DLL, Mac's
+** dyld, or Unix's dlopen). If your system is some kind of Unix, there
+** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
+** it.  To use dlopen you also need to adapt the src/Makefile (probably
+** adding -ldl to the linker options), so Lua does not select it
+** automatically.  (When you change the makefile to add -ldl, you must
+** also add -DLUA_USE_DLOPEN.)
+** If you do not want any kind of dynamic library, undefine all these
+** options.
+** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
+*/
+#if defined(LUA_USE_DLOPEN)
+#define LUA_DL_DLOPEN
+#endif
+
+#if defined(LUA_WIN)
+#define LUA_DL_DLL
+#endif
+
+
+/*
+@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
+@* (the data goes just *before* the lua_State pointer).
+** CHANGE (define) this if you really need that. This value must be
+** a multiple of the maximum alignment required for your machine.
+*/
+#define LUAI_EXTRASPACE		0
+
+
+/*
+@@ luai_userstate* allow user-specific actions on threads.
+** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
+** extra when a thread is created/deleted/resumed/yielded.
+*/
+#define luai_userstateopen(L)		((void)L)
+#define luai_userstateclose(L)		((void)L)
+#define luai_userstatethread(L,L1)	((void)L)
+#define luai_userstatefree(L)		((void)L)
+#define luai_userstateresume(L,n)	((void)L)
+#define luai_userstateyield(L,n)	((void)L)
+
+
+/*
+@@ LUA_INTFRMLEN is the length modifier for integer conversions
+@* in 'string.format'.
+@@ LUA_INTFRM_T is the integer type correspoding to the previous length
+@* modifier.
+** CHANGE them if your system supports long long or does not support long.
+*/
+
+#if defined(LUA_USELONGLONG)
+
+#define LUA_INTFRMLEN		"ll"
+#define LUA_INTFRM_T		long long
+
+#else
+
+#define LUA_INTFRMLEN		"l"
+#define LUA_INTFRM_T		long
+
+#endif
+
+
+
+/* =================================================================== */
+
+/*
+** Local configuration. You can use this space to add your redefinitions
+** without modifying the main part of the file.
+*/
+
+
+
+#endif
+
Index: /code/branches/physics/src/lua/lualib.h
===================================================================
--- /code/branches/physics/src/lua/lualib.h	(revision 2122)
+++ /code/branches/physics/src/lua/lualib.h	(revision 2122)
@@ -0,0 +1,53 @@
+/*
+** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
+** Lua standard libraries
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lualib_h
+#define lualib_h
+
+#include "lua.h"
+
+
+/* Key to file-handle type */
+#define LUA_FILEHANDLE		"FILE*"
+
+
+#define LUA_COLIBNAME	"coroutine"
+LUALIB_API int (luaopen_base) (lua_State *L);
+
+#define LUA_TABLIBNAME	"table"
+LUALIB_API int (luaopen_table) (lua_State *L);
+
+#define LUA_IOLIBNAME	"io"
+LUALIB_API int (luaopen_io) (lua_State *L);
+
+#define LUA_OSLIBNAME	"os"
+LUALIB_API int (luaopen_os) (lua_State *L);
+
+#define LUA_STRLIBNAME	"string"
+LUALIB_API int (luaopen_string) (lua_State *L);
+
+#define LUA_MATHLIBNAME	"math"
+LUALIB_API int (luaopen_math) (lua_State *L);
+
+#define LUA_DBLIBNAME	"debug"
+LUALIB_API int (luaopen_debug) (lua_State *L);
+
+#define LUA_LOADLIBNAME	"package"
+LUALIB_API int (luaopen_package) (lua_State *L);
+
+
+/* open all previous libraries */
+LUALIB_API void (luaL_openlibs) (lua_State *L); 
+
+
+
+#ifndef lua_assert
+#define lua_assert(x)	((void)0)
+#endif
+
+
+#endif
Index: /code/branches/physics/src/lua/lundump.c
===================================================================
--- /code/branches/physics/src/lua/lundump.c	(revision 2122)
+++ /code/branches/physics/src/lua/lundump.c	(revision 2122)
@@ -0,0 +1,225 @@
+/*
+** $Id: lundump.c,v 2.7.1.2 2008/01/18 16:39:11 roberto Exp $
+** load precompiled Lua chunks
+** See Copyright Notice in lua.h
+*/
+
+#include <string.h>
+
+#define lundump_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lmem.h"
+#include "lobject.h"
+#include "lstring.h"
+#include "lundump.h"
+#include "lzio.h"
+
+typedef struct {
+ lua_State* L;
+ ZIO* Z;
+ Mbuffer* b;
+ const char* name;
+} LoadState;
+
+#ifdef LUAC_TRUST_BINARIES
+#define IF(c,s)
+#define error(S,s)
+#else
+#define IF(c,s)		if (c) error(S,s)
+
+static void error(LoadState* S, const char* why)
+{
+ luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
+ luaD_throw(S->L,LUA_ERRSYNTAX);
+}
+#endif
+
+#define LoadMem(S,b,n,size)	LoadBlock(S,b,(n)*(size))
+#define	LoadByte(S)		(lu_byte)LoadChar(S)
+#define LoadVar(S,x)		LoadMem(S,&x,1,sizeof(x))
+#define LoadVector(S,b,n,size)	LoadMem(S,b,n,size)
+
+static void LoadBlock(LoadState* S, void* b, size_t size)
+{
+ size_t r=luaZ_read(S->Z,b,size);
+ UNUSED(r);
+ IF (r!=0, "unexpected end");
+}
+
+static int LoadChar(LoadState* S)
+{
+ char x;
+ LoadVar(S,x);
+ return x;
+}
+
+static int LoadInt(LoadState* S)
+{
+ int x;
+ LoadVar(S,x);
+ IF (x<0, "bad integer");
+ return x;
+}
+
+static lua_Number LoadNumber(LoadState* S)
+{
+ lua_Number x;
+ LoadVar(S,x);
+ return x;
+}
+
+static TString* LoadString(LoadState* S)
+{
+ size_t size;
+ LoadVar(S,size);
+ if (size==0)
+  return NULL;
+ else
+ {
+  char* s=luaZ_openspace(S->L,S->b,size);
+  LoadBlock(S,s,size);
+  return luaS_newlstr(S->L,s,size-1);		/* remove trailing '\0' */
+ }
+}
+
+static void LoadCode(LoadState* S, Proto* f)
+{
+ int n=LoadInt(S);
+ f->code=luaM_newvector(S->L,n,Instruction);
+ f->sizecode=n;
+ LoadVector(S,f->code,n,sizeof(Instruction));
+}
+
+static Proto* LoadFunction(LoadState* S, TString* p);
+
+static void LoadConstants(LoadState* S, Proto* f)
+{
+ int i,n;
+ n=LoadInt(S);
+ f->k=luaM_newvector(S->L,n,TValue);
+ f->sizek=n;
+ for (i=0; i<n; i++) setnilvalue(&f->k[i]);
+ for (i=0; i<n; i++)
+ {
+  TValue* o=&f->k[i];
+  int t=LoadChar(S);
+  switch (t)
+  {
+   case LUA_TNIL:
+   	setnilvalue(o);
+	break;
+   case LUA_TBOOLEAN:
+   	setbvalue(o,LoadChar(S));
+	break;
+   case LUA_TNUMBER:
+	setnvalue(o,LoadNumber(S));
+	break;
+   case LUA_TSTRING:
+	setsvalue2n(S->L,o,LoadString(S));
+	break;
+   default:
+	error(S,"bad constant");
+	break;
+  }
+ }
+ n=LoadInt(S);
+ f->p=luaM_newvector(S->L,n,Proto*);
+ f->sizep=n;
+ for (i=0; i<n; i++) f->p[i]=NULL;
+ for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
+}
+
+static void LoadDebug(LoadState* S, Proto* f)
+{
+ int i,n;
+ n=LoadInt(S);
+ f->lineinfo=luaM_newvector(S->L,n,int);
+ f->sizelineinfo=n;
+ LoadVector(S,f->lineinfo,n,sizeof(int));
+ n=LoadInt(S);
+ f->locvars=luaM_newvector(S->L,n,LocVar);
+ f->sizelocvars=n;
+ for (i=0; i<n; i++) f->locvars[i].varname=NULL;
+ for (i=0; i<n; i++)
+ {
+  f->locvars[i].varname=LoadString(S);
+  f->locvars[i].startpc=LoadInt(S);
+  f->locvars[i].endpc=LoadInt(S);
+ }
+ n=LoadInt(S);
+ f->upvalues=luaM_newvector(S->L,n,TString*);
+ f->sizeupvalues=n;
+ for (i=0; i<n; i++) f->upvalues[i]=NULL;
+ for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
+}
+
+static Proto* LoadFunction(LoadState* S, TString* p)
+{
+ Proto* f=luaF_newproto(S->L);
+ setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
+ f->source=LoadString(S); if (f->source==NULL) f->source=p;
+ f->linedefined=LoadInt(S);
+ f->lastlinedefined=LoadInt(S);
+ f->nups=LoadByte(S);
+ f->numparams=LoadByte(S);
+ f->is_vararg=LoadByte(S);
+ f->maxstacksize=LoadByte(S);
+ LoadCode(S,f);
+ LoadConstants(S,f);
+ LoadDebug(S,f);
+ IF (!luaG_checkcode(f), "bad code");
+ S->L->top--;
+ return f;
+}
+
+static void LoadHeader(LoadState* S)
+{
+ char h[LUAC_HEADERSIZE];
+ char s[LUAC_HEADERSIZE];
+ luaU_header(h);
+ LoadBlock(S,s,LUAC_HEADERSIZE);
+ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
+}
+
+/*
+** load precompiled chunk
+*/
+Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
+{
+ LoadState S;
+ if (*name=='@' || *name=='=')
+  S.name=name+1;
+ else if (*name==LUA_SIGNATURE[0])
+  S.name="binary string";
+ else
+  S.name=name;
+ S.L=L;
+ S.Z=Z;
+ S.b=buff;
+ LoadHeader(&S);
+ return LoadFunction(&S,luaS_newliteral(L,"=?"));
+}
+
+/*
+* make header
+*/
+void luaU_header (char* h)
+{
+ int x=1;
+ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
+ h+=sizeof(LUA_SIGNATURE)-1;
+ *h++=(char)LUAC_VERSION;
+ *h++=(char)LUAC_FORMAT;
+ *h++=(char)*(char*)&x;				/* endianness */
+ *h++=(char)sizeof(int);
+ *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+ *h++=(char)(((lua_Number)0.5)==0);		/* is lua_Number integral? */
+}
Index: /code/branches/physics/src/lua/lundump.h
===================================================================
--- /code/branches/physics/src/lua/lundump.h	(revision 2122)
+++ /code/branches/physics/src/lua/lundump.h	(revision 2122)
@@ -0,0 +1,36 @@
+/*
+** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
+** load precompiled Lua chunks
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lundump_h
+#define lundump_h
+
+#include "lobject.h"
+#include "lzio.h"
+
+/* load one chunk; from lundump.c */
+LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
+
+/* make header; from lundump.c */
+LUAI_FUNC void luaU_header (char* h);
+
+/* dump one chunk; from ldump.c */
+LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+
+#ifdef luac_c
+/* print one chunk; from print.c */
+LUAI_FUNC void luaU_print (const Proto* f, int full);
+#endif
+
+/* for header of binary files -- this is Lua 5.1 */
+#define LUAC_VERSION		0x51
+
+/* for header of binary files -- this is the official format */
+#define LUAC_FORMAT		0
+
+/* size of header of binary files */
+#define LUAC_HEADERSIZE		12
+
+#endif
Index: /code/branches/physics/src/lua/lvm.c
===================================================================
--- /code/branches/physics/src/lua/lvm.c	(revision 2122)
+++ /code/branches/physics/src/lua/lvm.c	(revision 2122)
@@ -0,0 +1,763 @@
+/*
+** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
+** Lua virtual machine
+** See Copyright Notice in lua.h
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define lvm_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "ldebug.h"
+#include "ldo.h"
+#include "lfunc.h"
+#include "lgc.h"
+#include "lobject.h"
+#include "lopcodes.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+#include "lvm.h"
+
+
+
+/* limit for table tag-method chains (to avoid loops) */
+#define MAXTAGLOOP	100
+
+
+const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
+  lua_Number num;
+  if (ttisnumber(obj)) return obj;
+  if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
+    setnvalue(n, num);
+    return n;
+  }
+  else
+    return NULL;
+}
+
+
+int luaV_tostring (lua_State *L, StkId obj) {
+  if (!ttisnumber(obj))
+    return 0;
+  else {
+    char s[LUAI_MAXNUMBER2STR];
+    lua_Number n = nvalue(obj);
+    lua_number2str(s, n);
+    setsvalue2s(L, obj, luaS_new(L, s));
+    return 1;
+  }
+}
+
+
+static void traceexec (lua_State *L, const Instruction *pc) {
+  lu_byte mask = L->hookmask;
+  const Instruction *oldpc = L->savedpc;
+  L->savedpc = pc;
+  if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
+    resethookcount(L);
+    luaD_callhook(L, LUA_HOOKCOUNT, -1);
+  }
+  if (mask & LUA_MASKLINE) {
+    Proto *p = ci_func(L->ci)->l.p;
+    int npc = pcRel(pc, p);
+    int newline = getline(p, npc);
+    /* call linehook when enter a new function, when jump back (loop),
+       or when enter a new line */
+    if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p)))
+      luaD_callhook(L, LUA_HOOKLINE, newline);
+  }
+}
+
+
+static void callTMres (lua_State *L, StkId res, const TValue *f,
+                        const TValue *p1, const TValue *p2) {
+  ptrdiff_t result = savestack(L, res);
+  setobj2s(L, L->top, f);  /* push function */
+  setobj2s(L, L->top+1, p1);  /* 1st argument */
+  setobj2s(L, L->top+2, p2);  /* 2nd argument */
+  luaD_checkstack(L, 3);
+  L->top += 3;
+  luaD_call(L, L->top - 3, 1);
+  res = restorestack(L, result);
+  L->top--;
+  setobjs2s(L, res, L->top);
+}
+
+
+
+static void callTM (lua_State *L, const TValue *f, const TValue *p1,
+                    const TValue *p2, const TValue *p3) {
+  setobj2s(L, L->top, f);  /* push function */
+  setobj2s(L, L->top+1, p1);  /* 1st argument */
+  setobj2s(L, L->top+2, p2);  /* 2nd argument */
+  setobj2s(L, L->top+3, p3);  /* 3th argument */
+  luaD_checkstack(L, 4);
+  L->top += 4;
+  luaD_call(L, L->top - 4, 0);
+}
+
+
+void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
+  int loop;
+  for (loop = 0; loop < MAXTAGLOOP; loop++) {
+    const TValue *tm;
+    if (ttistable(t)) {  /* `t' is a table? */
+      Table *h = hvalue(t);
+      const TValue *res = luaH_get(h, key); /* do a primitive get */
+      if (!ttisnil(res) ||  /* result is no nil? */
+          (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
+        setobj2s(L, val, res);
+        return;
+      }
+      /* else will try the tag method */
+    }
+    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
+      luaG_typeerror(L, t, "index");
+    if (ttisfunction(tm)) {
+      callTMres(L, val, tm, t, key);
+      return;
+    }
+    t = tm;  /* else repeat with `tm' */ 
+  }
+  luaG_runerror(L, "loop in gettable");
+}
+
+
+void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
+  int loop;
+  for (loop = 0; loop < MAXTAGLOOP; loop++) {
+    const TValue *tm;
+    if (ttistable(t)) {  /* `t' is a table? */
+      Table *h = hvalue(t);
+      TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
+      if (!ttisnil(oldval) ||  /* result is no nil? */
+          (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
+        setobj2t(L, oldval, val);
+        luaC_barriert(L, h, val);
+        return;
+      }
+      /* else will try the tag method */
+    }
+    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
+      luaG_typeerror(L, t, "index");
+    if (ttisfunction(tm)) {
+      callTM(L, tm, t, key, val);
+      return;
+    }
+    t = tm;  /* else repeat with `tm' */ 
+  }
+  luaG_runerror(L, "loop in settable");
+}
+
+
+static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
+                       StkId res, TMS event) {
+  const TValue *tm = luaT_gettmbyobj(L, p1, event);  /* try first operand */
+  if (ttisnil(tm))
+    tm = luaT_gettmbyobj(L, p2, event);  /* try second operand */
+  if (ttisnil(tm)) return 0;
+  callTMres(L, res, tm, p1, p2);
+  return 1;
+}
+
+
+static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
+                                  TMS event) {
+  const TValue *tm1 = fasttm(L, mt1, event);
+  const TValue *tm2;
+  if (tm1 == NULL) return NULL;  /* no metamethod */
+  if (mt1 == mt2) return tm1;  /* same metatables => same metamethods */
+  tm2 = fasttm(L, mt2, event);
+  if (tm2 == NULL) return NULL;  /* no metamethod */
+  if (luaO_rawequalObj(tm1, tm2))  /* same metamethods? */
+    return tm1;
+  return NULL;
+}
+
+
+static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
+                         TMS event) {
+  const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
+  const TValue *tm2;
+  if (ttisnil(tm1)) return -1;  /* no metamethod? */
+  tm2 = luaT_gettmbyobj(L, p2, event);
+  if (!luaO_rawequalObj(tm1, tm2))  /* different metamethods? */
+    return -1;
+  callTMres(L, L->top, tm1, p1, p2);
+  return !l_isfalse(L->top);
+}
+
+
+static int l_strcmp (const TString *ls, const TString *rs) {
+  const char *l = getstr(ls);
+  size_t ll = ls->tsv.len;
+  const char *r = getstr(rs);
+  size_t lr = rs->tsv.len;
+  for (;;) {
+    int temp = strcoll(l, r);
+    if (temp != 0) return temp;
+    else {  /* strings are equal up to a `\0' */
+      size_t len = strlen(l);  /* index of first `\0' in both strings */
+      if (len == lr)  /* r is finished? */
+        return (len == ll) ? 0 : 1;
+      else if (len == ll)  /* l is finished? */
+        return -1;  /* l is smaller than r (because r is not finished) */
+      /* both strings longer than `len'; go on comparing (after the `\0') */
+      len++;
+      l += len; ll -= len; r += len; lr -= len;
+    }
+  }
+}
+
+
+int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
+  int res;
+  if (ttype(l) != ttype(r))
+    return luaG_ordererror(L, l, r);
+  else if (ttisnumber(l))
+    return luai_numlt(nvalue(l), nvalue(r));
+  else if (ttisstring(l))
+    return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
+  else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
+    return res;
+  return luaG_ordererror(L, l, r);
+}
+
+
+static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
+  int res;
+  if (ttype(l) != ttype(r))
+    return luaG_ordererror(L, l, r);
+  else if (ttisnumber(l))
+    return luai_numle(nvalue(l), nvalue(r));
+  else if (ttisstring(l))
+    return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
+  else if ((res = call_orderTM(L, l, r, TM_LE)) != -1)  /* first try `le' */
+    return res;
+  else if ((res = call_orderTM(L, r, l, TM_LT)) != -1)  /* else try `lt' */
+    return !res;
+  return luaG_ordererror(L, l, r);
+}
+
+
+int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
+  const TValue *tm;
+  lua_assert(ttype(t1) == ttype(t2));
+  switch (ttype(t1)) {
+    case LUA_TNIL: return 1;
+    case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
+    case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2);  /* true must be 1 !! */
+    case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
+    case LUA_TUSERDATA: {
+      if (uvalue(t1) == uvalue(t2)) return 1;
+      tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
+                         TM_EQ);
+      break;  /* will try TM */
+    }
+    case LUA_TTABLE: {
+      if (hvalue(t1) == hvalue(t2)) return 1;
+      tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
+      break;  /* will try TM */
+    }
+    default: return gcvalue(t1) == gcvalue(t2);
+  }
+  if (tm == NULL) return 0;  /* no TM? */
+  callTMres(L, L->top, tm, t1, t2);  /* call TM */
+  return !l_isfalse(L->top);
+}
+
+
+void luaV_concat (lua_State *L, int total, int last) {
+  do {
+    StkId top = L->base + last + 1;
+    int n = 2;  /* number of elements handled in this pass (at least 2) */
+    if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
+      if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
+        luaG_concaterror(L, top-2, top-1);
+    } else if (tsvalue(top-1)->len == 0)  /* second op is empty? */
+      (void)tostring(L, top - 2);  /* result is first op (as string) */
+    else {
+      /* at least two string values; get as many as possible */
+      size_t tl = tsvalue(top-1)->len;
+      char *buffer;
+      int i;
+      /* collect total length */
+      for (n = 1; n < total && tostring(L, top-n-1); n++) {
+        size_t l = tsvalue(top-n-1)->len;
+        if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
+        tl += l;
+      }
+      buffer = luaZ_openspace(L, &G(L)->buff, tl);
+      tl = 0;
+      for (i=n; i>0; i--) {  /* concat all strings */
+        size_t l = tsvalue(top-i)->len;
+        memcpy(buffer+tl, svalue(top-i), l);
+        tl += l;
+      }
+      setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
+    }
+    total -= n-1;  /* got `n' strings to create 1 new */
+    last -= n-1;
+  } while (total > 1);  /* repeat until only 1 result left */
+}
+
+
+static void Arith (lua_State *L, StkId ra, const TValue *rb,
+                   const TValue *rc, TMS op) {
+  TValue tempb, tempc;
+  const TValue *b, *c;
+  if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
+      (c = luaV_tonumber(rc, &tempc)) != NULL) {
+    lua_Number nb = nvalue(b), nc = nvalue(c);
+    switch (op) {
+      case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
+      case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
+      case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
+      case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
+      case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
+      case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
+      case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
+      default: lua_assert(0); break;
+    }
+  }
+  else if (!call_binTM(L, rb, rc, ra, op))
+    luaG_aritherror(L, rb, rc);
+}
+
+
+
+/*
+** some macros for common tasks in `luaV_execute'
+*/
+
+#define runtime_check(L, c)	{ if (!(c)) break; }
+
+#define RA(i)	(base+GETARG_A(i))
+/* to be used after possible stack reallocation */
+#define RB(i)	check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
+#define RC(i)	check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
+#define RKB(i)	check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
+	ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
+#define RKC(i)	check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
+	ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
+#define KBx(i)	check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
+
+
+#define dojump(L,pc,i)	{(pc) += (i); luai_threadyield(L);}
+
+
+#define Protect(x)	{ L->savedpc = pc; {x;}; base = L->base; }
+
+
+#define arith_op(op,tm) { \
+        TValue *rb = RKB(i); \
+        TValue *rc = RKC(i); \
+        if (ttisnumber(rb) && ttisnumber(rc)) { \
+          lua_Number nb = nvalue(rb), nc = nvalue(rc); \
+          setnvalue(ra, op(nb, nc)); \
+        } \
+        else \
+          Protect(Arith(L, ra, rb, rc, tm)); \
+      }
+
+
+
+void luaV_execute (lua_State *L, int nexeccalls) {
+  LClosure *cl;
+  StkId base;
+  TValue *k;
+  const Instruction *pc;
+ reentry:  /* entry point */
+  lua_assert(isLua(L->ci));
+  pc = L->savedpc;
+  cl = &clvalue(L->ci->func)->l;
+  base = L->base;
+  k = cl->p->k;
+  /* main loop of interpreter */
+  for (;;) {
+    const Instruction i = *pc++;
+    StkId ra;
+    if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
+        (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
+      traceexec(L, pc);
+      if (L->status == LUA_YIELD) {  /* did hook yield? */
+        L->savedpc = pc - 1;
+        return;
+      }
+      base = L->base;
+    }
+    /* warning!! several calls may realloc the stack and invalidate `ra' */
+    ra = RA(i);
+    lua_assert(base == L->base && L->base == L->ci->base);
+    lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
+    lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
+    switch (GET_OPCODE(i)) {
+      case OP_MOVE: {
+        setobjs2s(L, ra, RB(i));
+        continue;
+      }
+      case OP_LOADK: {
+        setobj2s(L, ra, KBx(i));
+        continue;
+      }
+      case OP_LOADBOOL: {
+        setbvalue(ra, GETARG_B(i));
+        if (GETARG_C(i)) pc++;  /* skip next instruction (if C) */
+        continue;
+      }
+      case OP_LOADNIL: {
+        TValue *rb = RB(i);
+        do {
+          setnilvalue(rb--);
+        } while (rb >= ra);
+        continue;
+      }
+      case OP_GETUPVAL: {
+        int b = GETARG_B(i);
+        setobj2s(L, ra, cl->upvals[b]->v);
+        continue;
+      }
+      case OP_GETGLOBAL: {
+        TValue g;
+        TValue *rb = KBx(i);
+        sethvalue(L, &g, cl->env);
+        lua_assert(ttisstring(rb));
+        Protect(luaV_gettable(L, &g, rb, ra));
+        continue;
+      }
+      case OP_GETTABLE: {
+        Protect(luaV_gettable(L, RB(i), RKC(i), ra));
+        continue;
+      }
+      case OP_SETGLOBAL: {
+        TValue g;
+        sethvalue(L, &g, cl->env);
+        lua_assert(ttisstring(KBx(i)));
+        Protect(luaV_settable(L, &g, KBx(i), ra));
+        continue;
+      }
+      case OP_SETUPVAL: {
+        UpVal *uv = cl->upvals[GETARG_B(i)];
+        setobj(L, uv->v, ra);
+        luaC_barrier(L, uv, ra);
+        continue;
+      }
+      case OP_SETTABLE: {
+        Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
+        continue;
+      }
+      case OP_NEWTABLE: {
+        int b = GETARG_B(i);
+        int c = GETARG_C(i);
+        sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
+        Protect(luaC_checkGC(L));
+        continue;
+      }
+      case OP_SELF: {
+        StkId rb = RB(i);
+        setobjs2s(L, ra+1, rb);
+        Protect(luaV_gettable(L, rb, RKC(i), ra));
+        continue;
+      }
+      case OP_ADD: {
+        arith_op(luai_numadd, TM_ADD);
+        continue;
+      }
+      case OP_SUB: {
+        arith_op(luai_numsub, TM_SUB);
+        continue;
+      }
+      case OP_MUL: {
+        arith_op(luai_nummul, TM_MUL);
+        continue;
+      }
+      case OP_DIV: {
+        arith_op(luai_numdiv, TM_DIV);
+        continue;
+      }
+      case OP_MOD: {
+        arith_op(luai_nummod, TM_MOD);
+        continue;
+      }
+      case OP_POW: {
+        arith_op(luai_numpow, TM_POW);
+        continue;
+      }
+      case OP_UNM: {
+        TValue *rb = RB(i);
+        if (ttisnumber(rb)) {
+          lua_Number nb = nvalue(rb);
+          setnvalue(ra, luai_numunm(nb));
+        }
+        else {
+          Protect(Arith(L, ra, rb, rb, TM_UNM));
+        }
+        continue;
+      }
+      case OP_NOT: {
+        int res = l_isfalse(RB(i));  /* next assignment may change this value */
+        setbvalue(ra, res);
+        continue;
+      }
+      case OP_LEN: {
+        const TValue *rb = RB(i);
+        switch (ttype(rb)) {
+          case LUA_TTABLE: {
+            setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
+            break;
+          }
+          case LUA_TSTRING: {
+            setnvalue(ra, cast_num(tsvalue(rb)->len));
+            break;
+          }
+          default: {  /* try metamethod */
+            Protect(
+              if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
+                luaG_typeerror(L, rb, "get length of");
+            )
+          }
+        }
+        continue;
+      }
+      case OP_CONCAT: {
+        int b = GETARG_B(i);
+        int c = GETARG_C(i);
+        Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
+        setobjs2s(L, RA(i), base+b);
+        continue;
+      }
+      case OP_JMP: {
+        dojump(L, pc, GETARG_sBx(i));
+        continue;
+      }
+      case OP_EQ: {
+        TValue *rb = RKB(i);
+        TValue *rc = RKC(i);
+        Protect(
+          if (equalobj(L, rb, rc) == GETARG_A(i))
+            dojump(L, pc, GETARG_sBx(*pc));
+        )
+        pc++;
+        continue;
+      }
+      case OP_LT: {
+        Protect(
+          if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
+            dojump(L, pc, GETARG_sBx(*pc));
+        )
+        pc++;
+        continue;
+      }
+      case OP_LE: {
+        Protect(
+          if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
+            dojump(L, pc, GETARG_sBx(*pc));
+        )
+        pc++;
+        continue;
+      }
+      case OP_TEST: {
+        if (l_isfalse(ra) != GETARG_C(i))
+          dojump(L, pc, GETARG_sBx(*pc));
+        pc++;
+        continue;
+      }
+      case OP_TESTSET: {
+        TValue *rb = RB(i);
+        if (l_isfalse(rb) != GETARG_C(i)) {
+          setobjs2s(L, ra, rb);
+          dojump(L, pc, GETARG_sBx(*pc));
+        }
+        pc++;
+        continue;
+      }
+      case OP_CALL: {
+        int b = GETARG_B(i);
+        int nresults = GETARG_C(i) - 1;
+        if (b != 0) L->top = ra+b;  /* else previous instruction set top */
+        L->savedpc = pc;
+        switch (luaD_precall(L, ra, nresults)) {
+          case PCRLUA: {
+            nexeccalls++;
+            goto reentry;  /* restart luaV_execute over new Lua function */
+          }
+          case PCRC: {
+            /* it was a C function (`precall' called it); adjust results */
+            if (nresults >= 0) L->top = L->ci->top;
+            base = L->base;
+            continue;
+          }
+          default: {
+            return;  /* yield */
+          }
+        }
+      }
+      case OP_TAILCALL: {
+        int b = GETARG_B(i);
+        if (b != 0) L->top = ra+b;  /* else previous instruction set top */
+        L->savedpc = pc;
+        lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
+        switch (luaD_precall(L, ra, LUA_MULTRET)) {
+          case PCRLUA: {
+            /* tail call: put new frame in place of previous one */
+            CallInfo *ci = L->ci - 1;  /* previous frame */
+            int aux;
+            StkId func = ci->func;
+            StkId pfunc = (ci+1)->func;  /* previous function index */
+            if (L->openupval) luaF_close(L, ci->base);
+            L->base = ci->base = ci->func + ((ci+1)->base - pfunc);
+            for (aux = 0; pfunc+aux < L->top; aux++)  /* move frame down */
+              setobjs2s(L, func+aux, pfunc+aux);
+            ci->top = L->top = func+aux;  /* correct top */
+            lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize);
+            ci->savedpc = L->savedpc;
+            ci->tailcalls++;  /* one more call lost */
+            L->ci--;  /* remove new frame */
+            goto reentry;
+          }
+          case PCRC: {  /* it was a C function (`precall' called it) */
+            base = L->base;
+            continue;
+          }
+          default: {
+            return;  /* yield */
+          }
+        }
+      }
+      case OP_RETURN: {
+        int b = GETARG_B(i);
+        if (b != 0) L->top = ra+b-1;
+        if (L->openupval) luaF_close(L, base);
+        L->savedpc = pc;
+        b = luaD_poscall(L, ra);
+        if (--nexeccalls == 0)  /* was previous function running `here'? */
+          return;  /* no: return */
+        else {  /* yes: continue its execution */
+          if (b) L->top = L->ci->top;
+          lua_assert(isLua(L->ci));
+          lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL);
+          goto reentry;
+        }
+      }
+      case OP_FORLOOP: {
+        lua_Number step = nvalue(ra+2);
+        lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
+        lua_Number limit = nvalue(ra+1);
+        if (luai_numlt(0, step) ? luai_numle(idx, limit)
+                                : luai_numle(limit, idx)) {
+          dojump(L, pc, GETARG_sBx(i));  /* jump back */
+          setnvalue(ra, idx);  /* update internal index... */
+          setnvalue(ra+3, idx);  /* ...and external index */
+        }
+        continue;
+      }
+      case OP_FORPREP: {
+        const TValue *init = ra;
+        const TValue *plimit = ra+1;
+        const TValue *pstep = ra+2;
+        L->savedpc = pc;  /* next steps may throw errors */
+        if (!tonumber(init, ra))
+          luaG_runerror(L, LUA_QL("for") " initial value must be a number");
+        else if (!tonumber(plimit, ra+1))
+          luaG_runerror(L, LUA_QL("for") " limit must be a number");
+        else if (!tonumber(pstep, ra+2))
+          luaG_runerror(L, LUA_QL("for") " step must be a number");
+        setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
+        dojump(L, pc, GETARG_sBx(i));
+        continue;
+      }
+      case OP_TFORLOOP: {
+        StkId cb = ra + 3;  /* call base */
+        setobjs2s(L, cb+2, ra+2);
+        setobjs2s(L, cb+1, ra+1);
+        setobjs2s(L, cb, ra);
+        L->top = cb+3;  /* func. + 2 args (state and index) */
+        Protect(luaD_call(L, cb, GETARG_C(i)));
+        L->top = L->ci->top;
+        cb = RA(i) + 3;  /* previous call may change the stack */
+        if (!ttisnil(cb)) {  /* continue loop? */
+          setobjs2s(L, cb-1, cb);  /* save control variable */
+          dojump(L, pc, GETARG_sBx(*pc));  /* jump back */
+        }
+        pc++;
+        continue;
+      }
+      case OP_SETLIST: {
+        int n = GETARG_B(i);
+        int c = GETARG_C(i);
+        int last;
+        Table *h;
+        if (n == 0) {
+          n = cast_int(L->top - ra) - 1;
+          L->top = L->ci->top;
+        }
+        if (c == 0) c = cast_int(*pc++);
+        runtime_check(L, ttistable(ra));
+        h = hvalue(ra);
+        last = ((c-1)*LFIELDS_PER_FLUSH) + n;
+        if (last > h->sizearray)  /* needs more space? */
+          luaH_resizearray(L, h, last);  /* pre-alloc it at once */
+        for (; n > 0; n--) {
+          TValue *val = ra+n;
+          setobj2t(L, luaH_setnum(L, h, last--), val);
+          luaC_barriert(L, h, val);
+        }
+        continue;
+      }
+      case OP_CLOSE: {
+        luaF_close(L, ra);
+        continue;
+      }
+      case OP_CLOSURE: {
+        Proto *p;
+        Closure *ncl;
+        int nup, j;
+        p = cl->p->p[GETARG_Bx(i)];
+        nup = p->nups;
+        ncl = luaF_newLclosure(L, nup, cl->env);
+        ncl->l.p = p;
+        for (j=0; j<nup; j++, pc++) {
+          if (GET_OPCODE(*pc) == OP_GETUPVAL)
+            ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
+          else {
+            lua_assert(GET_OPCODE(*pc) == OP_MOVE);
+            ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
+          }
+        }
+        setclvalue(L, ra, ncl);
+        Protect(luaC_checkGC(L));
+        continue;
+      }
+      case OP_VARARG: {
+        int b = GETARG_B(i) - 1;
+        int j;
+        CallInfo *ci = L->ci;
+        int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1;
+        if (b == LUA_MULTRET) {
+          Protect(luaD_checkstack(L, n));
+          ra = RA(i);  /* previous call may change the stack */
+          b = n;
+          L->top = ra + n;
+        }
+        for (j = 0; j < b; j++) {
+          if (j < n) {
+            setobjs2s(L, ra + j, ci->base - n + j);
+          }
+          else {
+            setnilvalue(ra + j);
+          }
+        }
+        continue;
+      }
+    }
+  }
+}
+
Index: /code/branches/physics/src/lua/lvm.h
===================================================================
--- /code/branches/physics/src/lua/lvm.h	(revision 2122)
+++ /code/branches/physics/src/lua/lvm.h	(revision 2122)
@@ -0,0 +1,36 @@
+/*
+** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
+** Lua virtual machine
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lvm_h
+#define lvm_h
+
+
+#include "ldo.h"
+#include "lobject.h"
+#include "ltm.h"
+
+
+#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
+
+#define tonumber(o,n)	(ttype(o) == LUA_TNUMBER || \
+                         (((o) = luaV_tonumber(o,n)) != NULL))
+
+#define equalobj(L,o1,o2) \
+	(ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
+
+
+LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
+LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
+LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
+LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
+                                            StkId val);
+LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
+                                            StkId val);
+LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
+LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
+
+#endif
Index: /code/branches/physics/src/lua/lzio.c
===================================================================
--- /code/branches/physics/src/lua/lzio.c	(revision 2122)
+++ /code/branches/physics/src/lua/lzio.c	(revision 2122)
@@ -0,0 +1,82 @@
+/*
+** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
+** a generic input stream interface
+** See Copyright Notice in lua.h
+*/
+
+
+#include <string.h>
+
+#define lzio_c
+#define LUA_CORE
+
+#include "lua.h"
+
+#include "llimits.h"
+#include "lmem.h"
+#include "lstate.h"
+#include "lzio.h"
+
+
+int luaZ_fill (ZIO *z) {
+  size_t size;
+  lua_State *L = z->L;
+  const char *buff;
+  lua_unlock(L);
+  buff = z->reader(L, z->data, &size);
+  lua_lock(L);
+  if (buff == NULL || size == 0) return EOZ;
+  z->n = size - 1;
+  z->p = buff;
+  return char2int(*(z->p++));
+}
+
+
+int luaZ_lookahead (ZIO *z) {
+  if (z->n == 0) {
+    if (luaZ_fill(z) == EOZ)
+      return EOZ;
+    else {
+      z->n++;  /* luaZ_fill removed first byte; put back it */
+      z->p--;
+    }
+  }
+  return char2int(*z->p);
+}
+
+
+void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
+  z->L = L;
+  z->reader = reader;
+  z->data = data;
+  z->n = 0;
+  z->p = NULL;
+}
+
+
+/* --------------------------------------------------------------- read --- */
+size_t luaZ_read (ZIO *z, void *b, size_t n) {
+  while (n) {
+    size_t m;
+    if (luaZ_lookahead(z) == EOZ)
+      return n;  /* return number of missing bytes */
+    m = (n <= z->n) ? n : z->n;  /* min. between n and z->n */
+    memcpy(b, z->p, m);
+    z->n -= m;
+    z->p += m;
+    b = (char *)b + m;
+    n -= m;
+  }
+  return 0;
+}
+
+/* ------------------------------------------------------------------------ */
+char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
+  if (n > buff->buffsize) {
+    if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
+    luaZ_resizebuffer(L, buff, n);
+  }
+  return buff->buffer;
+}
+
+
Index: /code/branches/physics/src/lua/lzio.h
===================================================================
--- /code/branches/physics/src/lua/lzio.h	(revision 2122)
+++ /code/branches/physics/src/lua/lzio.h	(revision 2122)
@@ -0,0 +1,67 @@
+/*
+** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
+** Buffered streams
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lzio_h
+#define lzio_h
+
+#include "lua.h"
+
+#include "lmem.h"
+
+
+#define EOZ	(-1)			/* end of stream */
+
+typedef struct Zio ZIO;
+
+#define char2int(c)	cast(int, cast(unsigned char, (c)))
+
+#define zgetc(z)  (((z)->n--)>0 ?  char2int(*(z)->p++) : luaZ_fill(z))
+
+typedef struct Mbuffer {
+  char *buffer;
+  size_t n;
+  size_t buffsize;
+} Mbuffer;
+
+#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
+
+#define luaZ_buffer(buff)	((buff)->buffer)
+#define luaZ_sizebuffer(buff)	((buff)->buffsize)
+#define luaZ_bufflen(buff)	((buff)->n)
+
+#define luaZ_resetbuffer(buff) ((buff)->n = 0)
+
+
+#define luaZ_resizebuffer(L, buff, size) \
+	(luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
+	(buff)->buffsize = size)
+
+#define luaZ_freebuffer(L, buff)	luaZ_resizebuffer(L, buff, 0)
+
+
+LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
+LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
+                                        void *data);
+LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n);	/* read next n bytes */
+LUAI_FUNC int luaZ_lookahead (ZIO *z);
+
+
+
+/* --------- Private Part ------------------ */
+
+struct Zio {
+  size_t n;			/* bytes still unread */
+  const char *p;		/* current position in buffer */
+  lua_Reader reader;
+  void* data;			/* additional data */
+  lua_State *L;			/* Lua state (for reader) */
+};
+
+
+LUAI_FUNC int luaZ_fill (ZIO *z);
+
+#endif
Index: /code/branches/physics/src/network/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/network/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/network/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,53 @@
+SET( NETWORK_SRC_FILES
+  ChatListener.cc
+  Client.cc
+  ClientConnection.cc
+  ClientInformation.cc
+  ClientConnectionListener.cc
+  ConnectionManager.cc
+  GamestateManager.cc
+  GamestateClient.cc
+  GamestateHandler.cc
+  PacketBuffer.cc
+  Server.cc
+  Synchronisable.cc
+  Host.cc
+  packet/Packet.cc
+  packet/Chat.cc
+  packet/ClassID.cc
+  packet/Acknowledgement.cc
+  packet/Gamestate.cc
+  packet/Welcome.cc
+  packet/DeleteObjects.cc
+)
+
+IF(WIN32)
+  ADD_LIBRARY( network ${NETWORK_SRC_FILES} )
+ELSE(WIN32)
+  ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
+ENDIF(WIN32)
+
+TARGET_LINK_LIBRARIES( network
+  ${ZLIB_LIBRARY}
+  ${ENet_LIBRARY}
+  ${Boost_thread_LIBRARIES}
+  core
+)
+
+
+# build those parts only on request.
+IF(NETWORK_TESTING_ENABLED)
+  ##### test for gamestate stuff #####
+  SET( TEST_SRC_FILES
+    ${NETWORK_SRC_FILES}
+  )
+  ADD_EXECUTABLE(networktest ${TEST_SRC_FILES})
+  TARGET_LINK_LIBRARIES( networktest
+    ${OGRE_LIBRARIES}
+    network
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+  )
+  ##### end test for gamestate stuff #####
+ENDIF(NETWORK_TESTING_ENABLED)
Index: /code/branches/physics/src/network/ChatListener.cc
===================================================================
--- /code/branches/physics/src/network/ChatListener.cc	(revision 2122)
+++ /code/branches/physics/src/network/ChatListener.cc	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ChatListener.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+
+namespace network
+{
+    ChatListener::ChatListener()
+    {
+        RegisterRootObject(ChatListener);
+    }
+}
+
+
Index: /code/branches/physics/src/network/ChatListener.h
===================================================================
--- /code/branches/physics/src/network/ChatListener.h	(revision 2122)
+++ /code/branches/physics/src/network/ChatListener.h	(revision 2122)
@@ -0,0 +1,49 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _NETWORK_ChatListener__
+#define _NETWORK_ChatListener__
+
+#include "NetworkPrereqs.h"
+
+#include "ClientInformation.h"
+#include "core/OrxonoxClass.h"
+
+namespace network
+{
+    class _NetworkExport ChatListener : virtual public orxonox::OrxonoxClass
+    {
+        public:
+            ChatListener();
+            virtual ~ChatListener() {}
+
+            virtual void incomingChat(const std::string& message, unsigned int senderID) = 0;
+    };
+}
+
+#endif /* _NETWORK_ChatListener__ */
Index: /code/branches/physics/src/network/Client.cc
===================================================================
--- /code/branches/physics/src/network/Client.cc	(revision 2122)
+++ /code/branches/physics/src/network/Client.cc	(revision 2122)
@@ -0,0 +1,170 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: Client
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <cassert>
+
+#include "Client.h"
+#include "Host.h"
+#include "Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include "packet/Packet.h"
+
+// #include "packet/Acknowledgement.h"
+
+namespace network
+{
+//   SetConsoleCommandShortcut(Client, chat);
+
+
+  /**
+  * Constructor for the Client class
+  * initializes the address and the port to default localhost:NETWORK_PORT
+  */
+  Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){
+    // set server address to localhost
+    isConnected=false;
+    isSynched_=false;
+    gameStateFailure_=false;
+  }
+
+  /**
+  * Constructor for the Client class
+  * @param address the server address
+  * @param port port of the application on the server
+  */
+  Client::Client(const std::string& address, int port) : client_connection(port, address){
+    isConnected=false;
+    isSynched_=false;
+    gameStateFailure_=false;
+  }
+
+  /**
+  * Constructor for the Client class
+  * @param address the server address
+  * @param port port of the application on the server
+  */
+  Client::Client(const char *address, int port) : client_connection(port, address){
+    isConnected=false;
+    isSynched_=false;
+    gameStateFailure_=false;
+  }
+
+  Client::~Client(){
+    if(isConnected)
+      closeConnection();
+  }
+
+  /**
+  * Establish the Connection to the Server
+  * @return true/false
+  */
+  bool Client::establishConnection(){
+    Synchronisable::setClient(true);
+    isConnected=client_connection.createConnection();
+    if(!isConnected)
+      COUT(1) << "could not create connection laber" << std::endl;
+    return isConnected;
+  }
+
+  /**
+  * closes the Connection to the Server
+  * @return true/false
+  */
+  bool Client::closeConnection(){
+    isConnected=false;
+    return client_connection.closeConnection();
+  }
+
+  bool Client::queuePacket(ENetPacket *packet, int clientID){
+    return client_connection.addPacket(packet);
+  }
+
+  bool Client::processChat(const std::string& message, unsigned int playerID){
+//    COUT(1) << "Player " << playerID << ": " << message << std::endl;
+    return true;
+  }
+
+  /**
+   * This function implements the method of sending a chat message to the server
+   * @param message message to be sent
+   * @return result(true/false)
+   */
+  bool Client::chat(const std::string& message){
+    packet::Chat *m = new packet::Chat(message, Host::getPlayerID());
+    return m->send();
+  }
+
+
+  /**
+   * Processes incoming packets, sends a gamestate to the server and does the cleanup
+   * @param time
+   */
+  void Client::tick(float time){
+//     COUT(3) << ".";
+    if(client_connection.isConnected() && isSynched_){
+      COUT(4) << "popping partial gamestate: " << std::endl;
+      packet::Gamestate *gs = gamestate.getGamestate();
+      if(gs){
+        COUT(4) << "client tick: sending gs " << gs << std::endl;
+        if( !gs->send() )
+          COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
+        // gs gets automatically deleted by enet callback
+      }
+    }
+    ENetEvent *event;
+    // stop if the packet queue is empty
+    while(!(client_connection.queueEmpty())){
+      event = client_connection.getEvent();
+      COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
+      packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
+      // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler
+      bool b = packet->process();
+      assert(b);
+    }
+    if(gamestate.processGamestates())
+    {
+      if(!isSynched_)
+        isSynched_=true;
+    }
+    gamestate.cleanup();
+    return;
+  }
+
+}
Index: /code/branches/physics/src/network/Client.h
===================================================================
--- /code/branches/physics/src/network/Client.h	(revision 2122)
+++ /code/branches/physics/src/network/Client.h	(revision 2122)
@@ -0,0 +1,96 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: Client
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _Client_H__
+#define _Client_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+
+#include "Host.h"
+#include "packet/Chat.h"
+#include "ClientConnection.h"
+#include "GamestateClient.h"
+//#include "NetworkFrameListener.h"
+
+
+
+namespace network
+{
+  /**
+  network::Client *client;
+  * The network/Client class
+  * This class implements all necessary function for the network communication
+  * It is the root class of the network module
+  *
+  */
+  class _NetworkExport Client : public Host{
+  public:
+    Client();
+    Client(const std::string& address, int port);
+    Client(const char *address, int port);
+    ~Client();
+
+    bool establishConnection();
+    bool closeConnection();
+    bool queuePacket(ENetPacket *packet, int clientID);
+    bool processChat(const std::string& message, unsigned int playerID);
+    virtual bool chat(const std::string& message);
+    virtual bool broadcast(const std::string& message) { return false; }
+    //bool sendChat(packet::Chat *chat);
+
+    void tick(float time);
+
+  private:
+    virtual bool isServer_(){return false;}
+
+    ClientConnection client_connection;
+    GamestateClient gamestate;
+    bool isConnected;
+    bool isSynched_;
+
+    bool gameStateFailure_;
+  };
+
+
+}
+
+#endif /* _Client_H__ */
Index: /code/branches/physics/src/network/ClientConnection.cc
===================================================================
--- /code/branches/physics/src/network/ClientConnection.cc	(revision 2122)
+++ /code/branches/physics/src/network/ClientConnection.cc	(revision 2122)
@@ -0,0 +1,247 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ClientConnection
+//
+// Description: The Class ClientConnection manages the servers conenctions to the clients.
+// each connection is provided by a new process. communication between master process and
+// connection processes is provided by ...
+//
+//
+// Author:  Oliver Scheuss
+//
+
+#include "ClientConnection.h"
+
+#include <iostream>
+// boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include "util/Sleep.h"
+#include "util/Debug.h"
+
+namespace network
+{
+  //static boost::thread_group network_threads;
+
+  boost::recursive_mutex ClientConnection::enet_mutex_;
+
+  ClientConnection::ClientConnection(int port, const std::string& address) {
+    quit=false;
+    server=NULL;
+    enet_address_set_host(&serverAddress, address.c_str());
+    serverAddress.port = port;
+    established=false;
+  }
+
+  ClientConnection::ClientConnection(int port, const char *address) {
+    quit=false;
+    server=NULL;
+    enet_address_set_host(&serverAddress, address);
+    serverAddress.port = port;
+    established=false;
+  }
+
+  bool ClientConnection::waitEstablished(int milisec) {
+    for(int i=0; i<=milisec && !established; i++)
+      msleep(1);
+
+    return established;
+  }
+
+  ClientConnection::~ClientConnection(){
+    if(established)
+      closeConnection();
+  }
+
+  ENetEvent *ClientConnection::getEvent(){
+    if(!buffer.isEmpty())
+      return buffer.pop();
+    else
+      return NULL;
+  }
+
+  bool ClientConnection::queueEmpty() {
+    return buffer.isEmpty();
+  }
+
+  bool ClientConnection::createConnection() {
+    receiverThread_ = new boost::thread(boost::bind(&ClientConnection::receiverThread, this));
+    //network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this));
+    // wait 10 seconds for the connection to be established
+    return waitEstablished(NETWORK_CLIENT_CONNECT_TIMEOUT);
+  }
+
+  bool ClientConnection::closeConnection() {
+    quit=true;
+    //network_threads.join_all();
+    receiverThread_->join();
+    established=false;
+    return true;
+  }
+
+
+  bool ClientConnection::addPacket(ENetPacket *packet) {
+    if(server==NULL)
+      return false;
+    if(packet==NULL){
+      COUT(3) << "Cl.con: addpacket: invalid packet" << std::endl;
+      return false;
+    }
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    if(enet_peer_send(server, 0, packet)<0)
+      return false;
+    else
+      return true;
+  }
+
+  bool ClientConnection::sendPackets() {
+    if(server==NULL)
+      return false;
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    enet_host_flush(client);
+    lock.unlock();
+    return true;
+  }
+
+  void ClientConnection::receiverThread() {
+    // what about some error-handling here ?
+    atexit(enet_deinitialize);
+    ENetEvent *event;
+    {
+      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      enet_initialize();
+      client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
+      lock.unlock();
+    }
+    if(client==NULL) {
+      COUT(2) << "ClientConnection: could not create client host" << std::endl;
+      // add some error handling here ==========================
+      quit=true;
+    }
+    //connect to the server
+    if(!establishConnection()){
+      COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl;
+      quit=true;
+      return;
+    }
+    event = new ENetEvent;
+    //main loop
+    while(!quit){
+      //std::cout << "connection loop" << std::endl;
+      {
+        boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+        if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
+          // we should never reach this point
+          quit=true;
+          continue;
+          // add some error handling here ========================
+        }
+        lock.unlock();
+      }
+      switch(event->type){
+        // log handling ================
+      case ENET_EVENT_TYPE_CONNECT:
+        break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;
+        if ( !processData(event) ) COUT(2) << "Current packet was not pushed to packetBuffer -> ev ongoing SegFault" << std::endl;
+        COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl;
+        event = new ENetEvent;
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        quit=true;
+        // server closed the connection
+        return;
+        break;
+      case ENET_EVENT_TYPE_NONE:
+        //receiverThread_->yield();
+        msleep(1);
+        break;
+      }
+    }
+    // now disconnect
+
+    if(!disconnectConnection())
+      // if disconnecting failed destroy conn.
+      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      enet_peer_reset(server);
+    return;
+  }
+
+  bool ClientConnection::disconnectConnection() {
+    ENetEvent event;
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    enet_peer_disconnect(server, 0);
+    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){
+      switch (event.type)
+      {
+      case ENET_EVENT_TYPE_NONE:
+      case ENET_EVENT_TYPE_CONNECT:
+      case ENET_EVENT_TYPE_RECEIVE:
+        enet_packet_destroy(event.packet);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        return true;
+      }
+    }
+    enet_peer_reset(server);
+    return false;
+  }
+
+  bool ClientConnection::establishConnection() {
+    ENetEvent event;
+    // connect to peer (server is type ENetPeer*)
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    server = enet_host_connect(client, &serverAddress, NETWORK_CLIENT_CHANNELS);
+    if(server==NULL) {
+      COUT(2) << "ClientConnection: server == NULL" << std::endl;
+      // error handling
+      return false;
+    }
+    // handshake
+    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit){
+      if( event.type == ENET_EVENT_TYPE_CONNECT ){
+        established=true;
+        return true;
+      }
+    }
+    COUT(2) << "ClientConnection: enet_host_service < 0 or event.type != ENET_EVENT_TYPE_CONNECT # EVENT:" << event.type << std::endl;
+    return false;
+  }
+
+  bool ClientConnection::processData(ENetEvent *event) {
+    COUT(5) << "Cl.Con: got packet, pushing to queue" << std::endl;
+    // just add packet to the buffer
+    // this can be extended with some preprocessing
+    return buffer.push(event);
+  }
+
+}
Index: /code/branches/physics/src/network/ClientConnection.h
===================================================================
--- /code/branches/physics/src/network/ClientConnection.h	(revision 2122)
+++ /code/branches/physics/src/network/ClientConnection.h	(revision 2122)
@@ -0,0 +1,111 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ClientConnection
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _ClientConnection_H__
+#define _ClientConnection_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+#include "PacketBuffer.h"
+
+namespace boost { class thread; }
+
+namespace network
+{
+
+    const int NETWORK_PORT = 55556;
+    const int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
+    const int NETWORK_CLIENT_WAIT_TIME = 1;
+    const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds
+    const int NETWORK_CLIENT_CHANNELS = 2;
+
+
+  class _NetworkExport ClientConnection{
+  public:
+    ClientConnection(int port, const std::string& address);
+    ClientConnection(int port, const char* address);
+    ~ClientConnection();
+    ENetEvent *getEvent();
+    // check wheter the packet queue is empty
+    bool queueEmpty();
+    // create a new listener thread
+    bool createConnection();
+    bool closeConnection();
+    // add a packet to queue for the server
+    bool addPacket(ENetPacket *packet);
+    // send out all queued packets
+    bool sendPackets();
+    // send out all queued packets and save result in event
+    //bool sendPackets(ENetEvent *event);
+    bool waitEstablished(int milisec);
+    bool isConnected(){return established;}
+  private:
+    bool processData(ENetEvent *event);
+    // implementation of the listener
+    void receiverThread(); //thread2
+    //packetbuffer
+    bool establishConnection();
+    bool disconnectConnection();
+    PacketBuffer buffer;
+    // enet stuff
+    ENetHost *client;
+    ENetAddress serverAddress;
+    // quit-variable (communication with threads)
+    bool quit;
+    bool established;
+    // clientlist
+    ENetPeer *server;
+    boost::thread *receiverThread_;
+
+    static boost::recursive_mutex enet_mutex_;
+  };
+
+
+
+
+
+
+
+
+}
+
+#endif /* _ClientConnection_H__ */
Index: /code/branches/physics/src/network/ClientConnectionListener.cc
===================================================================
--- /code/branches/physics/src/network/ClientConnectionListener.cc	(revision 2122)
+++ /code/branches/physics/src/network/ClientConnectionListener.cc	(revision 2122)
@@ -0,0 +1,24 @@
+#include "ClientConnectionListener.h"
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+
+namespace network{
+
+  ClientConnectionListener::ClientConnectionListener()
+  { 
+    RegisterRootObject(ClientConnectionListener); 
+  }
+
+  void ClientConnectionListener::getConnectedClients(){
+    if(orxonox::Core::showsGraphics())
+      this->clientConnected(0); //server client id
+    ClientInformation *client = ClientInformation::getBegin();
+    while(client){
+      this->clientConnected(client->getID());
+      client=client->next();
+    }
+  }
+
+}
+
+
Index: /code/branches/physics/src/network/ClientConnectionListener.h
===================================================================
--- /code/branches/physics/src/network/ClientConnectionListener.h	(revision 2122)
+++ /code/branches/physics/src/network/ClientConnectionListener.h	(revision 2122)
@@ -0,0 +1,28 @@
+#ifndef _NETWORK_CLIENTCONNECTIONLISTENER__
+#define _NETWORK_CLIENTCONNECTIONLISTENER__
+
+#include "NetworkPrereqs.h"
+#include "ClientInformation.h"
+#include "core/OrxonoxClass.h"
+
+namespace network{
+
+  class _NetworkExport ClientConnectionListener : virtual public orxonox::OrxonoxClass
+  {
+    friend class Server;
+
+  public:
+    ClientConnectionListener();
+    virtual ~ClientConnectionListener() {}
+
+    void getConnectedClients();
+
+  protected:
+    virtual void clientConnected(unsigned int clientID) = 0;
+    virtual void clientDisconnected(unsigned int clientID) = 0;
+  };
+
+}
+
+
+#endif
Index: /code/branches/physics/src/network/ClientInformation.cc
===================================================================
--- /code/branches/physics/src/network/ClientInformation.cc	(revision 2122)
+++ /code/branches/physics/src/network/ClientInformation.cc	(revision 2122)
@@ -0,0 +1,271 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: ClientInformation
+//
+// Description:
+//
+//
+// Author:  <>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "ClientInformation.h"
+
+#include <iostream> //debug
+
+namespace network
+{
+
+  ClientInformation *ClientInformation::head_=0;
+
+  ClientInformation::ClientInformation() {
+    if(!head_)
+      head_=this;
+    gamestateID_=GAMESTATEID_INITIAL;
+    preve=0;
+    nexte=0;
+    partialGamestateID_=GAMESTATEID_INITIAL-1;
+    synched_=false;
+  }
+
+  ClientInformation::~ClientInformation() {
+    if(prev()!=0)
+      prev()->setNext(this->next());
+    if(next()!=0)
+      next()->setPrev(this->prev());
+    if(this==head_)
+      head_=next();
+  }
+
+  ClientInformation *ClientInformation::next() {
+    if(this!=0)
+      return this->nexte;
+    else
+      return 0;
+  }
+  ClientInformation *ClientInformation::prev() {
+    if(this!=0)
+      return this->preve;
+    else
+      return 0;
+  }
+
+  bool ClientInformation::setPrev(ClientInformation *prev) {
+    if(this==head_)
+      head_=prev;
+    this->preve = prev;
+    return true;
+  }
+
+  bool ClientInformation::setNext(ClientInformation *next) {
+    this->nexte = next;
+    return true;
+  }
+
+  ClientInformation *ClientInformation::insertAfter(ClientInformation *ins) {
+    this->next()->setPrev(ins);
+    ins->setNext(this->next());
+    ins->setPrev(this);
+    this->nexte = ins;
+    return ins;
+  }
+
+  ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){
+    if(!this)
+      return NULL;
+    this->prev()->setNext(ins);
+    ins->setPrev(this->prev());
+    this->preve=ins;
+    ins->setNext(this);
+    return ins;
+  }
+
+  void ClientInformation::setID(int clientID){
+    if(!this)
+      return;
+    clientID_ = clientID;
+  }
+
+  bool ClientInformation::setPeer(ENetPeer *peer){
+    if(!this)
+      return false;
+    peer_ = peer;
+    return true;
+  }
+
+  bool ClientInformation::setGamestateID(int id){
+    if(!this)
+      return false;
+    gamestateID_=id;
+    return true;
+  }
+
+  bool ClientInformation::setPartialGamestateID(int id){
+    if(!this)
+      return false;
+    partialGamestateID_=id;
+    return true;
+  }
+
+  unsigned int ClientInformation::getID() {
+    if(!this)
+      return CLIENTID_UNKNOWN;
+    else
+      return clientID_;
+  }
+
+  ENetPeer *ClientInformation::getPeer() {
+    if(this)
+      return peer_;
+    else
+      return NULL;
+  }
+
+  int ClientInformation::getFailures(){
+    return failures_;
+  }
+  void ClientInformation::addFailure(){
+    failures_++;
+  }
+  void ClientInformation::resetFailures(){
+    failures_=0;
+  }
+
+  enet_uint32 ClientInformation::getRTT(){
+    return this->peer_->roundTripTime;
+  }
+
+  double ClientInformation::getPacketLoss(){
+    return ((double)this->peer_->packetLoss)/ENET_PEER_PACKET_LOSS_SCALE;
+  }
+
+  unsigned int ClientInformation::getGamestateID() {
+    if(this)
+      return gamestateID_;
+    else
+      return (unsigned int)-1;
+  }
+
+  unsigned int ClientInformation::getPartialGamestateID() {
+    if(this)
+      return partialGamestateID_;
+    else
+      return (unsigned int)-1;
+  }
+
+  ClientInformation *ClientInformation::insertBack(ClientInformation *ins) {
+    ClientInformation *temp = head_;
+    if(temp==ins){
+      return head_;
+    }
+    while(temp->next()!=0){
+      temp = temp->next();
+    }
+    temp->setNext(ins);
+    ins->setPrev(temp);
+    return ins;
+  }
+
+  bool ClientInformation::removeClient(unsigned int clientID) {
+    if((unsigned int)clientID==CLIENTID_UNKNOWN)
+      return false;
+    ClientInformation *temp = head_;
+    while(temp!=0 && temp->getID()!=clientID)
+      temp = temp->next();
+    if(temp==0)
+      return false;
+    delete temp;
+    return true;
+  }
+
+  bool ClientInformation::removeClient(ENetPeer *peer) {
+    if(!peer)
+      return false;
+    ClientInformation *temp = head_;
+    while(temp!=0){
+      if(temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port)
+        break;
+      temp = temp->next();
+    }
+    if(temp==0)
+      return false;
+    delete temp;
+    return true;
+  }
+
+  /**
+  * This function goes forward through the list and looks for an element with clientID
+  * This function should only be applied to the head of the list
+  * @param clientID id to look for
+  * @return pointer to the last element in the list or 0 if the search was unsuccessfull
+  */
+  ClientInformation *ClientInformation::findClient(unsigned int clientID, bool look_backwards) {
+    ClientInformation *temp = head_;
+    while(temp!=0 && temp->getID()!=clientID){
+      temp = temp->next();
+    }
+    // returns 0 if nothing has been found
+    return temp;
+  }
+
+  /**
+  * This function goes forward through the list and looks for an element with clientID
+  * This function should only be applied to the head of the list
+  * @param peer peer to look for
+  * @return pointer to the element in the list
+  */
+  ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) {
+    ClientInformation *temp = head_;
+    while(temp!=0){
+      if(temp->getPeer()->address.host==address->host && temp->getPeer()->address.port == address->port)
+        break;
+      temp = temp->next();
+    }
+    // returns 0 if nothing has been found
+    return temp;
+  }
+
+  bool ClientInformation::setSynched(bool s) {
+    if(!this)
+      return false;
+    synched_=s;
+    return true;
+  }
+
+  bool ClientInformation::getSynched() {
+    if(this)
+      return synched_;
+    else
+      return false;
+  }
+
+}
Index: /code/branches/physics/src/network/ClientInformation.h
===================================================================
--- /code/branches/physics/src/network/ClientInformation.h	(revision 2122)
+++ /code/branches/physics/src/network/ClientInformation.h	(revision 2122)
@@ -0,0 +1,122 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ClientInformation
+//
+// Description:
+//
+//
+// Author:  <>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _ClientInformation_H__
+#define _ClientInformation_H__
+
+#include "NetworkPrereqs.h"
+
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+
+// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
+
+namespace network
+{
+  static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
+  static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
+
+  /**
+  * This class implements a list for client informations
+  * @author Oliver Scheuss
+  */
+  class _NetworkExport ClientInformation{
+  public:
+    ClientInformation();
+    //   ClientInformation(ClientInformation *prev, ClientInformation *next);
+    //   ClientInformation(ClientInformation *prev);
+    ~ClientInformation();
+    ClientInformation *next();
+    ClientInformation *prev();
+    static ClientInformation *insertBack(ClientInformation *ins);
+
+    // set functions
+    void setID(int clientID);
+    bool setPeer(ENetPeer *peer);
+    bool setGamestateID(int id);
+    bool setPartialGamestateID(int id);
+    inline void setShipID(unsigned int id){ShipID_=id;}
+
+    // get functions
+    inline unsigned int getShipID(){return ShipID_;}
+    unsigned int getID();
+    unsigned int getGamestateID();
+    unsigned int getPartialGamestateID();
+    ENetPeer *getPeer();
+
+    int getFailures();
+    void addFailure();
+    void resetFailures();
+    enet_uint32 getRTT();
+    double getPacketLoss();
+
+    static bool removeClient(unsigned int clientID);
+    static bool removeClient(ENetPeer *peer);
+    static ClientInformation *findClient(unsigned int clientID, bool look_backwards=false);
+    static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
+    static ClientInformation *getBegin(){return head_;}
+
+    bool setSynched(bool s);
+    bool getSynched();
+
+
+  private:
+    static ClientInformation *head_;
+
+    bool setNext(ClientInformation *next);
+    bool setPrev(ClientInformation *prev);
+    ClientInformation *insertAfter(ClientInformation *ins);
+    ClientInformation *insertBefore(ClientInformation *ins);
+
+    ClientInformation *preve;
+    ClientInformation *nexte;
+    //actual information:
+    ENetPeer *peer_;
+    unsigned int clientID_;
+    unsigned int gamestateID_;
+    unsigned int partialGamestateID_;
+    unsigned int ShipID_;   // this is the unique objectID
+    bool synched_;
+    unsigned short failures_;
+
+  };
+
+}
+
+#endif /* _ClientInformation_H__ */
Index: /code/branches/physics/src/network/ConnectionManager.cc
===================================================================
--- /code/branches/physics/src/network/ConnectionManager.cc	(revision 2122)
+++ /code/branches/physics/src/network/ConnectionManager.cc	(revision 2122)
@@ -0,0 +1,341 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ConnectionManager
+//
+// Description: The Class ConnectionManager manages the servers conenctions to the clients.
+// each connection is provided by a new process. communication between master process and
+// connection processes is provided by ...
+//
+//
+// Author:  Oliver Scheuss
+//
+
+#include "ConnectionManager.h"
+
+#include <iostream>
+#include <assert.h>
+// boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "core/Iterator.h"
+#include "util/Math.h"
+#include "util/Sleep.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+#include "packet/ClassID.h"
+
+namespace std
+{
+  bool operator< (ENetAddress a, ENetAddress b) {
+    if(a.host <= b.host)
+      return true;
+    else
+      return false;
+  }
+}
+
+namespace network
+{
+  //boost::thread_group network_threads;
+
+  ConnectionManager *ConnectionManager::instance_=0;
+
+  ConnectionManager::ConnectionManager():receiverThread_(0){
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    bindAddress.host = ENET_HOST_ANY;
+    bindAddress.port = NETWORK_PORT;
+  }
+  boost::recursive_mutex ConnectionManager::enet_mutex;
+
+  ConnectionManager::ConnectionManager(int port){
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    bindAddress.host = ENET_HOST_ANY;
+    bindAddress.port = port;
+  }
+
+  ConnectionManager::ConnectionManager(int port, const std::string& address) :receiverThread_(0) {
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    enet_address_set_host (& bindAddress, address.c_str());
+    bindAddress.port = NETWORK_PORT;
+  }
+
+  ConnectionManager::ConnectionManager(int port, const char *address) : receiverThread_(0) {
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    enet_address_set_host (& bindAddress, address);
+    bindAddress.port = NETWORK_PORT;
+  }
+
+  ConnectionManager::~ConnectionManager(){
+    if(!quit)
+      quitListener();
+    instance_=0;
+  }
+
+
+  ENetEvent *ConnectionManager::getEvent(){
+    if(!buffer.isEmpty())
+      return buffer.pop();
+    else
+      return NULL;
+  }
+
+  bool ConnectionManager::queueEmpty() {
+    return buffer.isEmpty();
+  }
+
+  void ConnectionManager::createListener() {
+    receiverThread_ = new boost::thread(boost::bind(&ConnectionManager::receiverThread, this));
+    //network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+         //boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+    return;
+  }
+
+  bool ConnectionManager::quitListener() {
+    quit=true;
+    //network_threads.join_all();
+    receiverThread_->join();
+    return true;
+  }
+
+
+  bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) {
+    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex);
+    if(enet_peer_send(peer, NETWORK_DEFAULT_CHANNEL, packet)!=0)
+      return false;
+    return true;
+  }
+
+  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
+    ClientInformation *temp = ClientInformation::findClient(clientID);
+    if(!temp){
+      COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
+      return false;
+    }
+    return addPacket(packet, temp->getPeer());
+  }
+
+  bool ConnectionManager::addPacketAll(ENetPacket *packet) {
+    if(!instance_)
+      return false;
+    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex);
+    for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
+      COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
+      if(enet_peer_send(i->getPeer(), 0, packet)!=0)
+        return false;
+    }
+    return true;
+  }
+
+  // we actually dont need that function, because host_service does that for us
+  bool ConnectionManager::sendPackets() {
+    if(server==NULL || !instance_)
+      return false;
+    boost::recursive_mutex::scoped_lock lock(enet_mutex);
+    enet_host_flush(server);
+    lock.unlock();
+    return true;
+  }
+
+  void ConnectionManager::receiverThread() {
+    // what about some error-handling here ?
+    ENetEvent *event;
+    atexit(enet_deinitialize);
+    { //scope of the mutex
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
+      enet_initialize();
+      server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);
+      lock.unlock();
+    }
+    if(server==NULL){
+      // add some error handling here ==========================
+      quit=true;
+      return;
+    }
+
+    event = new ENetEvent;
+    while(!quit){
+      { //mutex scope
+        boost::recursive_mutex::scoped_lock lock(enet_mutex);
+        if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
+          // we should never reach this point
+          quit=true;
+          continue;
+          // add some error handling here ========================
+        }
+        lock.unlock();
+      }
+      switch(event->type){
+        // log handling ================
+        case ENET_EVENT_TYPE_CONNECT:
+          COUT(3) << "adding event_type_connect to queue" << std::endl;
+        case ENET_EVENT_TYPE_DISCONNECT:
+          //addClient(event);
+          //this is a workaround to ensure thread safety
+          //COUT(5) << "Con.Man: connection event has occured" << std::endl;
+          //break;
+        case ENET_EVENT_TYPE_RECEIVE:
+          //std::cout << "received data" << std::endl;
+          COUT(5) << "Con.Man: receive event has occured" << std::endl;
+          // only add, if client has connected yet and not been disconnected
+          //if(head_->findClient(&event->peer->address))
+            processData(event);
+            event = new ENetEvent;
+//           else
+//             COUT(3) << "received a packet from a client we don't know" << std::endl;
+          break;
+        //case ENET_EVENT_TYPE_DISCONNECT:
+          //clientDisconnect(event->peer);
+          //break;
+        case ENET_EVENT_TYPE_NONE:
+          //receiverThread_->yield();
+          msleep(1);
+          break;
+      }
+//       usleep(100);
+      //receiverThread_->yield(); //TODO: find apropriate
+    }
+    disconnectClients();
+    // if we're finishied, destroy server
+    {
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
+      enet_host_destroy(server);
+      lock.unlock();
+    }
+  }
+
+  //### added some bugfixes here, but we cannot test them because
+  //### the server crashes everytime because of some gamestates
+  //### (trying to resolve that now)
+  void ConnectionManager::disconnectClients() {
+    ENetEvent event;
+    ClientInformation *temp = ClientInformation::getBegin()->next();
+    while(temp!=0){
+      {
+        boost::recursive_mutex::scoped_lock lock(enet_mutex);
+        enet_peer_disconnect(temp->getPeer(), 0);
+        lock.unlock();
+      }
+      temp = temp->next();
+    }
+    //bugfix: might be the reason why server crashes when clients disconnects
+    temp = ClientInformation::getBegin()->next();
+    boost::recursive_mutex::scoped_lock lock(enet_mutex);
+    while( temp!=0 && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) >= 0){
+      switch (event.type)
+      {
+      case ENET_EVENT_TYPE_NONE: break;
+      case ENET_EVENT_TYPE_CONNECT: break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        enet_packet_destroy(event.packet);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        COUT(4) << "disconnecting all clients" << std::endl;
+        if(ClientInformation::findClient(&(event.peer->address)))
+          delete ClientInformation::findClient(&(event.peer->address));
+        //maybe needs bugfix: might also be a reason for the server to crash
+        temp = temp->next();
+        break;
+      }
+    }
+    return;
+  }
+
+  bool ConnectionManager::processData(ENetEvent *event) {
+    // just add packet to the buffer
+    // this can be extended with some preprocessing
+    return buffer.push(event);
+  }
+
+
+
+  int ConnectionManager::getClientID(ENetPeer peer) {
+    return getClientID(peer.address);
+  }
+
+  int ConnectionManager::getClientID(ENetAddress address) {
+    return ClientInformation::findClient(&address)->getID();
+  }
+
+  ENetPeer *ConnectionManager::getClientPeer(int clientID) {
+    return ClientInformation::findClient(clientID)->getPeer();
+  }
+
+  /**
+   *
+   * @param clientID
+   */
+  void ConnectionManager::syncClassid(unsigned int clientID) {
+    unsigned int network_id=0, failures=0;
+    std::string classname;
+    orxonox::Identifier *id;
+    std::map<std::string, orxonox::Identifier*>::const_iterator it = orxonox::Factory::getFactoryMapBegin();
+    while(it != orxonox::Factory::getFactoryMapEnd()){
+      id = (*it).second;
+      if(id == NULL)
+        continue;
+      classname = id->getName();
+      network_id = id->getNetworkID();
+      if(network_id==0)
+        COUT(3) << "we got a null class id: " << id->getName() << std::endl;
+      COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
+
+      packet::ClassID *classid = new packet::ClassID( network_id, classname );
+      classid->setClientID(clientID);
+      while(!classid->send() && failures < 10){
+        failures++;
+      }
+      ++it;
+    }
+    //sendPackets();
+    COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
+  }
+
+
+  void ConnectionManager::disconnectClient(ClientInformation *client){
+    {
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
+      enet_peer_disconnect(client->getPeer(), 0);
+      lock.unlock();
+    }
+  }
+
+
+}
Index: /code/branches/physics/src/network/ConnectionManager.h
===================================================================
--- /code/branches/physics/src/network/ConnectionManager.h	(revision 2122)
+++ /code/branches/physics/src/network/ConnectionManager.h	(revision 2122)
@@ -0,0 +1,123 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ConnectionManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _ConnectionManager_H__
+#define _ConnectionManager_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+#include <map>
+// enet library for networking support
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+
+#include "PacketBuffer.h"
+#include "packet/Packet.h"
+
+namespace boost { class thread; }
+
+namespace std
+{
+  bool operator<(ENetAddress a, ENetAddress b);
+}
+
+namespace network
+{
+    const int NETWORK_PORT = 55556;
+    const int NETWORK_MAX_CONNECTIONS = 50;
+    const int NETWORK_WAIT_TIMEOUT = 1;
+    const int NETWORK_DEFAULT_CHANNEL = 0;
+
+  struct _NetworkExport ClientList{
+    ENetEvent *event;
+    int ID;
+    ClientList *next;
+  };
+
+  class _NetworkExport ConnectionManager{
+    public:
+    static boost::recursive_mutex enet_mutex;
+    ConnectionManager();
+    //ConnectionManager(ClientInformation *head);
+    ConnectionManager(int port);
+    ConnectionManager(int port, const char *address);
+    ConnectionManager(int port, const std::string& address);
+    ~ConnectionManager();
+    //ENetPacket *getPacket(ENetAddress &address); // thread1
+    //ENetPacket *getPacket(int &clientID);
+    ENetEvent *getEvent();
+    bool queueEmpty();
+    void createListener();
+    bool quitListener();
+//     bool addPacket(Packet::Packet *packet);
+    static bool addPacket(ENetPacket *packet, ENetPeer *peer);
+    static bool addPacket(ENetPacket *packet, int ID);
+    static bool addPacketAll(ENetPacket *packet);
+  //  bool sendPackets(ENetEvent *event);
+    bool sendPackets();
+    //bool createClient(int clientID);
+    void disconnectClient(ClientInformation *client);
+    void syncClassid(unsigned int clientID);
+
+  private:
+//     bool clientDisconnect(ENetPeer *peer);
+//     bool removeClient(int clientID);
+    bool processData(ENetEvent *event);
+    //bool addClient(ENetEvent *event);
+    void receiverThread();
+    void disconnectClients();
+    int getClientID(ENetPeer peer);
+    int getClientID(ENetAddress address);
+    ENetPeer *getClientPeer(int clientID);
+    PacketBuffer buffer;
+
+    ENetHost *server;
+    ENetAddress bindAddress;
+
+    bool quit; // quit-variable (communication with threads)
+
+    boost::thread *receiverThread_;
+    static ConnectionManager *instance_;
+
+  };
+
+}
+
+#endif /* _ConnectionManager_H__ */
Index: /code/branches/physics/src/network/GamestateClient.cc
===================================================================
--- /code/branches/physics/src/network/GamestateClient.cc	(revision 2122)
+++ /code/branches/physics/src/network/GamestateClient.cc	(revision 2122)
@@ -0,0 +1,171 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Dumeni Manatschal
+ *
+ */
+
+#include "GamestateClient.h"
+
+#include <cassert>
+#include <zlib.h>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "core/Iterator.h"
+#include "Synchronisable.h"
+#include "packet/Acknowledgement.h"
+
+
+namespace network
+{
+  struct _NetworkExport GameStateItem{
+    packet::Gamestate *state;
+    unsigned int id;
+  };
+
+  GamestateClient::GamestateClient() {
+    COUT(5) << "this: " << this << std::endl;
+    last_diff_=0;
+    last_gamestate_=GAMESTATEID_INITIAL-1;
+    tempGamestate_=NULL;
+  }
+
+  GamestateClient::~GamestateClient() {
+  }
+
+  bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID){
+    return true;
+  }
+
+  bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID){
+    if(tempGamestate_!=NULL){
+      //delete the obsolete gamestate
+      if(tempGamestate_->getID()>gs->getID())
+        return false;
+      delete tempGamestate_;
+    }
+    tempGamestate_=gs;
+    return true;
+  }
+
+  bool GamestateClient::processGamestates(){
+    if(tempGamestate_==NULL)
+      return false;
+    int id = GAMESTATEID_INITIAL;
+    packet::Gamestate *processed = processGamestate(tempGamestate_);
+//    assert(processed);
+    if (!processed)
+        return false;
+    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
+    tempGamestate_=NULL;
+    gamestateMap_[processed->getID()]=processed;
+    last_diff_ = processed->getID();
+    id = processed->getID();
+    sendAck(id);
+    return true;
+  }
+
+
+  /**
+  * This function removes a Synchronisable out of the universe
+  * @param it iterator of the list pointing to the object
+  * @return iterator pointing to the next object in the list
+  */
+  void GamestateClient::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
+    orxonox::ObjectList<Synchronisable>::iterator temp=it;
+    ++it;
+    delete  *temp;
+  }
+
+  packet::Gamestate *GamestateClient::getGamestate(){
+    packet::Gamestate *gs = new packet::Gamestate();
+    if(!gs->collectData(0)){
+      delete gs;
+      return 0;
+    }
+    return gs;
+  }
+
+  void GamestateClient::cleanup(){
+    std::map<unsigned int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
+    while(it!=gamestateMap_.end()){
+      if(it->first>=last_diff_)
+        break;
+      // otherwise delete that stuff
+      delete (*it).second;
+      temp=it++;
+      gamestateMap_.erase(temp);
+    }
+    tempGamestate_=NULL;
+  }
+
+  void GamestateClient::printGamestateMap(){
+    std::map<unsigned int, packet::Gamestate*>::iterator it;
+    COUT(4) << "gamestates: ";
+    for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
+      COUT(4) << it->first << ":" << it->second << "|";
+    }
+    COUT(4) << std::endl;
+
+  }
+
+  bool GamestateClient::sendAck(unsigned int gamestateID){
+    packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0);
+    if(!ack->send()){
+      COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
+      return false;
+    }
+    else{
+      COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
+      return true;
+    }
+  }
+
+  packet::Gamestate *GamestateClient::processGamestate(packet::Gamestate *gs){
+    if(gs->isCompressed())
+    {
+      bool b = gs->decompressData();
+      assert(b);
+    }
+    if(gs->isDiffed()){
+      packet::Gamestate *base = gamestateMap_[gs->getBaseID()];
+      if(!base){
+        delete gs;
+        return 0;
+      }
+//       assert(base); //TODO: fix this
+      packet::Gamestate *undiffed = gs->undiff(base);
+      delete gs;
+      gs=undiffed;
+      COUT(5) << "successfully undiffed gamestate id: " << undiffed->getID() << std::endl;
+    }
+    if(gs->spreadData())
+      return gs;
+    else
+      return NULL;
+  }
+
+}
+
Index: /code/branches/physics/src/network/GamestateClient.h
===================================================================
--- /code/branches/physics/src/network/GamestateClient.h	(revision 2122)
+++ /code/branches/physics/src/network/GamestateClient.h	(revision 2122)
@@ -0,0 +1,82 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Dumeni Manatschal
+ *
+ */
+
+//
+// C++ Interface: GameStateClient
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _GamestateClient_H__
+#define _GamestateClient_H__
+
+#include <map>
+//
+#include "NetworkPrereqs.h"
+#include "core/CorePrereqs.h"
+#include "packet/Gamestate.h"
+#include "GamestateHandler.h"
+
+const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
+
+namespace network
+{
+  class _NetworkExport GamestateClient: public GamestateHandler
+  {
+  public:
+    GamestateClient();
+    ~GamestateClient();
+
+    bool add(packet::Gamestate *gs, unsigned int clientID);
+    bool ack(unsigned int gamestateID, unsigned int clientID);
+
+    bool processGamestates();
+    packet::Gamestate *getGamestate();
+    void cleanup();
+  private:
+    packet::Gamestate *processGamestate(packet::Gamestate *gs);
+    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
+    void printGamestateMap();
+    bool sendAck(unsigned int gamestateID);
+
+    unsigned int           last_diff_;
+    unsigned int           last_gamestate_;
+    std::map<unsigned int, packet::Gamestate *> gamestateMap_;
+    packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
+    unsigned char *shipCache_;
+
+  };
+
+}
+
+#endif /* _GamestateClient_H__ */
Index: /code/branches/physics/src/network/GamestateHandler.cc
===================================================================
--- /code/branches/physics/src/network/GamestateHandler.cc	(revision 2122)
+++ /code/branches/physics/src/network/GamestateHandler.cc	(revision 2122)
@@ -0,0 +1,24 @@
+#include <assert.h>
+
+#include "GamestateHandler.h"
+#include "packet/Packet.h"
+
+namespace network {
+
+GamestateHandler *GamestateHandler::instance_=0;
+  
+GamestateHandler::GamestateHandler()
+{
+  assert(instance_==0);
+  instance_=this;
+}
+
+
+GamestateHandler::~GamestateHandler()
+{
+  instance_=0;
+}
+
+
+
+}//namespace network
Index: /code/branches/physics/src/network/GamestateHandler.h
===================================================================
--- /code/branches/physics/src/network/GamestateHandler.h	(revision 2122)
+++ /code/branches/physics/src/network/GamestateHandler.h	(revision 2122)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKGAMESTATEHANDLER_H
+#define NETWORKGAMESTATEHANDLER_H
+
+#include <string>
+
+#include "NetworkPrereqs.h"
+#include "packet/Chat.h"
+
+namespace network {
+
+/**
+	@author Oliver Scheuss
+*/
+class _NetworkExport GamestateHandler{
+  private:
+    virtual bool add(packet::Gamestate *gs, unsigned int clientID)=0;
+    virtual bool ack(unsigned int gamestateID, unsigned int clientID)=0;
+
+    static GamestateHandler *instance_;
+
+
+  protected:
+    GamestateHandler();
+    virtual ~GamestateHandler();
+
+  public:
+    static bool addGamestate(packet::Gamestate *gs, unsigned int clientID){ return instance_->add(gs, clientID); }
+    static bool ackGamestate(unsigned int gamestateID, unsigned int clientID){ return instance_->ack(gamestateID, clientID); }
+};
+
+}
+
+#endif
Index: /code/branches/physics/src/network/GamestateManager.cc
===================================================================
--- /code/branches/physics/src/network/GamestateManager.cc	(revision 2122)
+++ /code/branches/physics/src/network/GamestateManager.cc	(revision 2122)
@@ -0,0 +1,208 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: GameStateManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "GamestateManager.h"
+
+#include <utility>
+#include <iostream>
+#include <zlib.h>
+#include <cassert>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+
+namespace network
+{
+  GamestateManager::GamestateManager() {
+    id_=0;
+  }
+
+  GamestateManager::~GamestateManager() {
+  }
+
+  bool GamestateManager::update(){
+//     cleanup();
+    return getSnapshot();
+  }
+
+  bool GamestateManager::add(packet::Gamestate *gs, unsigned int clientID){
+    assert(gs);
+    std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
+    if(it!=gamestateQueue.end()){
+      // delete obsolete gamestate
+      delete it->second;
+    }
+    gamestateQueue[clientID] = gs;
+    return true;
+  }
+
+  bool GamestateManager::processGamestates(){
+    std::map<unsigned int, packet::Gamestate*>::iterator it;
+    // now push only the most recent gamestates we received (ignore obsolete ones)
+    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
+      bool b = processGamestate(it->second);
+      assert(b);
+      delete it->second;
+    }
+    // now clear the queue
+    gamestateQueue.clear();
+    return true;
+  }
+
+
+  bool GamestateManager::getSnapshot(){
+    reference = new packet::Gamestate();
+    if(!reference->collectData(++id_)){ //we have no data to send
+      delete reference;
+      reference=0;
+    }
+    return true;
+  }
+
+  /**
+   * this function is used to keep the memory usage low
+   * it tries to delete all the unused gamestates
+   *
+   *
+   */
+/*  void GamestateManager::cleanup(){
+    std::map<int,int>::iterator it = gamestateUsed.begin();
+    while(it!=gamestateUsed.end()){
+      if((id_-(*it).first)<KEEP_GAMESTATES)
+        break;
+      if( (*it).second <= 0 ){
+        COUT(5) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
+        std::map<int, packet::Gamestate *>::iterator tempit = gamestateMap.find((*it).first);
+        if( tempit != gamestateMap.end() ){
+          packet::Gamestate *temp = tempit->second;
+          if(temp){
+            delete gamestateMap[(*it).first];
+            gamestateMap.erase((*it).first);
+          }
+        }
+        gamestateUsed.erase(it++);
+        continue;
+      }
+      it++;
+    }
+  }*/
+
+  packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) {
+    //why are we searching the same client's gamestate id as we searched in
+    //Server::sendGameState?
+    packet::Gamestate *gs;
+    unsigned int gID = ClientInformation::findClient(clientID)->getGamestateID();
+    if(!reference)
+      return 0;
+    gs = reference->doSelection(clientID);
+//     gs = new packet::Gamestate(*reference);
+//     gs = new packet::Gamestate(*reference);
+    // save the (undiffed) gamestate in the clients gamestate map
+    gamestateMap_[clientID].insert(std::pair<int, packet::Gamestate*>(gs->getID(), gs));
+    //chose wheather the next gamestate is the first or not
+    packet::Gamestate *client=NULL;
+    if(gID != GAMESTATEID_INITIAL){
+      std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);
+      if(clientMap!=gamestateMap_.end()){
+        std::map<unsigned int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);
+        if(it!=clientMap->second.end())
+          client = it->second;
+      }
+    }
+    if(client){
+//       COUT(3) << "diffing" << std::endl;
+      gs = gs->diff(client);
+    }
+    else{
+//       COUT(3) << "not diffing" << std::endl;
+      gs = new packet::Gamestate(*gs);
+    }
+    bool b = gs->compressData();
+    assert(b);
+    return gs;
+  }
+
+
+  bool GamestateManager::ack(unsigned int gamestateID, unsigned int clientID) {
+    ClientInformation *temp = ClientInformation::findClient(clientID);
+    assert(temp);
+    unsigned int curid = temp->getGamestateID();
+
+    if(gamestateID == 0){
+      temp->setGamestateID(GAMESTATEID_INITIAL);
+      return true;
+    }
+
+    assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID);
+    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
+    std::map<unsigned int, packet::Gamestate*>::iterator it, tempit;
+    for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; it++){
+      delete it->second;
+      tempit=it++;
+      gamestateMap_[clientID].erase(tempit);
+    }
+    temp->setGamestateID(gamestateID);
+    return true;
+  }
+
+  void GamestateManager::removeClient(ClientInformation* client){
+    assert(client);
+    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
+    // first delete all remained gamestates
+    std::map<unsigned int, packet::Gamestate*>::iterator it;
+    for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++)
+      delete it->second;
+    // now delete the clients gamestatemap
+    gamestateMap_.erase(clientMap);
+  }
+
+  bool GamestateManager::processGamestate(packet::Gamestate *gs){
+    if(gs->isCompressed())
+    {
+       bool b = gs->decompressData();
+       assert(b);
+    }
+    assert(!gs->isDiffed());
+    return gs->spreadData();
+  }
+
+}
Index: /code/branches/physics/src/network/GamestateManager.h
===================================================================
--- /code/branches/physics/src/network/GamestateManager.h	(revision 2122)
+++ /code/branches/physics/src/network/GamestateManager.h	(revision 2122)
@@ -0,0 +1,96 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: GamestateManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _GamestateManager_H__
+#define _GamestateManager_H__
+
+#include "NetworkPrereqs.h"
+#include "GamestateHandler.h"
+#include <map>
+
+#include "packet/Gamestate.h"
+
+namespace network
+{
+
+    const int KEEP_GAMESTATES = 10;
+
+  /**
+  * This Class implements a manager for gamestates:
+  * - creating snapshots of gamestates
+  * - writing gamestates to universe
+  * - diffing gamestates
+  * EN/DECODATION:
+  * a: last Gamestate a client has received
+  * b: new Gamestate
+  * x: diffed and compressed gamestate
+  * x=(a^b)
+  * b=(a^x)
+  * diff(a,diff(a,x))=x (hope this is correct)
+  * @author Oliver Scheuss
+  */
+  class _NetworkExport GamestateManager: public GamestateHandler{
+  public:
+    GamestateManager();
+    ~GamestateManager();
+
+    bool add(packet::Gamestate *gs, unsigned int clientID);
+    bool processGamestates();
+    bool update();
+    packet::Gamestate *popGameState(unsigned int clientID);
+
+    bool getSnapshot();
+
+    bool ack(unsigned int gamestateID, unsigned int clientID);
+    void removeClient(ClientInformation *client);
+    private:
+//     void cleanup(); // "garbage handler"
+    bool processGamestate(packet::Gamestate *gs);
+
+    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
+    //std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
+    //std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
+    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
+    packet::Gamestate *reference;
+    unsigned int id_;
+  };
+
+}
+
+#endif /* _GameStateManager_H__ */
Index: /code/branches/physics/src/network/Host.cc
===================================================================
--- /code/branches/physics/src/network/Host.cc	(revision 2122)
+++ /code/branches/physics/src/network/Host.cc	(revision 2122)
@@ -0,0 +1,118 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <assert.h>
+
+#include "Host.h"
+#include "core/ConsoleCommand.h"
+#include "packet/Packet.h"
+#include "ChatListener.h"
+
+namespace network {
+
+SetConsoleCommandShortcut(Host, Chat);
+
+Host *Host::instance_=0;
+
+/**
+ * @brief Constructor: assures that only one reference will be created and sets the pointer
+ */
+Host::Host()
+{
+  clientID_=0;
+  assert(instance_==0);
+  instance_=this;
+}
+
+
+/**
+ * @brief Destructor: resets the instance pointer to 0
+ */
+Host::~Host()
+{
+  instance_=0;
+}
+
+/**
+ * This function is used to add an enetpacket to be sent to another peer
+ * @param packet Packet to be added
+ * @param clientID ID of the client the packet should be sent to
+ * @return success?
+ */
+bool Host::addPacket(ENetPacket *packet, int clientID){
+  if(instance_)
+    return instance_->queuePacket(packet, clientID);
+  else
+    return false;
+}
+
+
+// bool Host::chat(std::string& message){
+//   if(!instance_)
+//     return false;
+//   packet::Chat *c = new packet::Chat(message, getPlayerID());
+//   return instance_->sendChat(c);
+// }
+
+// bool Host::receiveChat(network::packet::Chat *message, unsigned int clientID){
+//   if(instance_)
+//     return instance_->processChat(message, clientID);
+//   else
+//     return false;
+// }
+
+/**
+ * This function returns the ID of the player
+ * @return playerID
+ */
+unsigned int Host::getPlayerID(){
+  if(!instance_)
+    return 0;
+  return instance_->clientID_;
+}
+
+bool Host::Chat(const std::string& message){
+  if(!instance_)
+    return false;
+  return instance_->chat(message);
+}
+
+bool Host::Broadcast(const std::string& message){
+  if(!instance_)
+    return false;
+  return instance_->broadcast(message);
+}
+
+bool Host::incomingChat(const std::string& message, unsigned int playerID){
+  for (orxonox::ObjectList<ChatListener>::iterator it = orxonox::ObjectList<ChatListener>::begin(); it != orxonox::ObjectList<ChatListener>::end(); ++it)
+    it->incomingChat(message, playerID);
+
+  return instance_->processChat(message, playerID);
+}
+
+}//namespace network
Index: /code/branches/physics/src/network/Host.h
===================================================================
--- /code/branches/physics/src/network/Host.h	(revision 2122)
+++ /code/branches/physics/src/network/Host.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKHOST_H
+#define NETWORKHOST_H
+
+#include <string>
+
+#include "NetworkPrereqs.h"
+#include "packet/Chat.h"
+
+namespace network {
+
+/**
+*       @brief Base class of Server and Client
+*       This is the Base class of the Server and Client classes
+*       - Makes server and client a singleton
+*       - defines static functions available on both server and client
+*       - is the interface to be used when communicating with the network
+*	@author Oliver Scheuss
+*/
+class _NetworkExport Host{
+  private:
+    //TODO add theese functions or adequate
+    //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
+    //virtual bool sendChat(packet::Chat *chat)=0;
+    virtual bool queuePacket(ENetPacket *packet, int clientID)=0;
+    virtual bool chat(const std::string& message)=0;
+    virtual bool broadcast(const std::string& message)=0;
+    virtual bool processChat(const std::string& message, unsigned int playerID)=0;
+    virtual bool isServer_()=0;
+
+
+
+  protected:
+    Host();
+    virtual ~Host();
+    static Host *instance_;
+    unsigned int clientID_;
+    unsigned int shipID_;
+
+  public:
+    static bool running(){return instance_!=0;}
+    static bool addPacket(ENetPacket *packet, int clientID=0);
+    //static bool chat(std::string& message);
+//     static bool receiveChat(packet::Chat *message, unsigned int clientID);
+    static unsigned int getPlayerID();
+    static unsigned int getShipID(){return instance_->shipID_;}
+    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
+    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
+    static bool isServer(){ return instance_->isServer_(); }
+    static bool Chat(const std::string& message);
+    static bool Broadcast(const std::string& message);
+    static bool incomingChat(const std::string& message, unsigned int playerID);
+  private:
+};
+
+}
+
+#endif
Index: /code/branches/physics/src/network/Makefile.norm
===================================================================
--- /code/branches/physics/src/network/Makefile.norm	(revision 2122)
+++ /code/branches/physics/src/network/Makefile.norm	(revision 2122)
@@ -0,0 +1,40 @@
+CC=g++
+MAIN_INC=..
+INC=-I ${MAIN_INC}
+
+all: server client
+
+# Link command:
+server: PacketBuffer.o ConnectionManager.o dummyserver.o PacketDecoder.o PacketGenerator.o
+	${CC} PacketDecoder.o PacketGenerator.o ConnectionManager.o dummyserver.o PacketBuffer.o -o server -lenet -lboost_thread -g
+
+dummyserver.o: dummyserver.cc
+	${CC} -c dummyserver.cc -o dummyserver.o -g ${INC}
+# Compilation commands:
+ConnectionManager.o: ConnectionManager.cc ConnectionManager.h
+	${CC} -c ConnectionManager.cc -o ConnectionManager.o -g ${INC}
+ClientConnection.o: ClientConnection.cc ClientConnection.h
+	${CC} -c ClientConnection.cc -o ClientConnection.o -g ${INC}
+
+PacketBuffer.o: PacketBuffer.cc
+	${CC} -c PacketBuffer.cc -o PacketBuffer.o -g ${INC}
+PacketGenerator.o: PacketGenerator.cc
+	${CC} -c PacketGenerator.cc -o PacketGenerator.o -g ${INC}
+PacketDecoder.o: PacketDecoder.cc
+	${CC} -c PacketDecoder.cc -o PacketDecoder.o -g ${INC}
+Client.o: Client.cc
+	${CC} -c Client.cc -g ${INC}
+Server.o: Server.cc
+	${CC} -c Server.cc -g ${INC}
+Synchronisable.o: Synchronisable.cc
+	${CC} -c Synchronisable.cc -g ${INC}
+GameStateManager.o: GameStateManager.cc
+	${CC} -c GameStateManager.cc -g ${INC}
+
+clean:
+	rm -rf *.o
+
+client_old: PacketGenerator.o dummyclient.cc
+	${CC} dummyclient.cc PacketGenerator.o -o client -lenet -g ${INC}
+client: PacketGenerator.o ClientConnection.o PacketBuffer.o dummyclient2.cc 
+	${CC} dummyclient2.cc PacketGenerator.o PacketBuffer.o ClientConnection.o -o client -lenet -lboost_thread -g ${INC}
Index: /code/branches/physics/src/network/Makefile.tardis
===================================================================
--- /code/branches/physics/src/network/Makefile.tardis	(revision 2122)
+++ /code/branches/physics/src/network/Makefile.tardis	(revision 2122)
@@ -0,0 +1,39 @@
+all: server client
+
+CC=g++-4.1.1
+
+BOOST_INC=/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/include/boost-1_34_1/
+BOOST_LIB=/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/lib/
+MAIN_INC=..
+ENET_INC=/usr/pack/enet-2007-sd/include/
+ENET_LIB=/usr/pack/enet-2007-sd/i686-debian-linux3.1/lib/
+INC=-I ${BOOST_INC} -I ${MAIN_INC} -I ${ENET_INC}
+LIB=-L ${BOOST_LIB} -L ${ENET_LIB}
+
+# Link command:
+server: clean PacketBuffer.o ConnectionManager.o dummyserver.o PacketGenerator.o PacketDecoder.o
+	${CC} ConnectionManager.o dummyserver.o PacketBuffer.o PacketDecoder.o PacketGenerator.o -o server -lenet -lboost_thread-gcc41-mt -g ${INC} ${LIB} -Wl,-rpath,${BOOST_LIB} -Wl,-rpath,${ENET_LIB}
+
+dummyserver.o:
+	${CC} -c dummyserver.cc -o dummyserver.o -g ${INC}
+# Compilation commands:
+
+ConnectionManager.o:
+	${CC} -c ConnectionManager.cc -o ConnectionManager.o -g ${INC}
+
+PacketBuffer.o: 
+	${CC} -c PacketBuffer.cc -o PacketBuffer.o -g ${INC}
+PacketGenerator.o: PacketGenerator.cc
+	${CC} -c PacketGenerator.cc -o PacketGenerator.o -g ${INC}
+PacketDecoder.o: PacketDecoder.cc
+	${CC} -c PacketDecoder.cc -o PacketDecoder.o -g ${INC}
+Synchronisable.o: Synchronisable.cc
+	${CC} -c Synchronisable.cc -g ${INC}
+GameStateManager.o: GameStateManager.cc
+	${CC} -c GameStateManager.cc -g ${INC}
+
+clean:
+	rm -rf *.o
+
+client: dummyclient.cc PacketDecoder.o PacketGenerator.o
+	${CC} PacketGenerator.o PacketDecoder.o dummyclient.cc -o client -lenet ${LIB} ${INC} -Wl,-rpath,${BOOST_LIB}
Index: /code/branches/physics/src/network/Makefile.test
===================================================================
--- /code/branches/physics/src/network/Makefile.test	(revision 2122)
+++ /code/branches/physics/src/network/Makefile.test	(revision 2122)
@@ -0,0 +1,45 @@
+CC=g++
+MAIN_INC=..
+INC=-I ${MAIN_INC} -I..
+
+all: server client
+
+# Link command:
+server: PacketBuffer.o ConnectionManager.o dummyserver.o PacketDecoder.o PacketGenerator.o ClientInformation.o
+	${CC} PacketDecoder.o PacketGenerator.o ClientInformation.o ConnectionManager.o dummyserver.o PacketBuffer.o -o server -lenet -lboost_thread -g
+
+dummyserver.o: dummyserver.cc
+	${CC} -c dummyserver.cc -o dummyserver.o -g ${INC}
+# Compilation commands:
+ConnectionManager.o: ConnectionManager.cc ConnectionManager.h
+	${CC} -c ConnectionManager.cc -o ConnectionManager.o -g ${INC}
+ClientConnection.o: ClientConnection.cc ClientConnection.h
+	${CC} -c ClientConnection.cc -o ClientConnection.o -g ${INC}
+
+PacketBuffer.o: PacketBuffer.cc
+	${CC} -c PacketBuffer.cc -o PacketBuffer.o -g ${INC}
+PacketGenerator.o: PacketGenerator.cc
+	${CC} -c PacketGenerator.cc -o PacketGenerator.o -g ${INC}
+PacketDecoder.o: PacketDecoder.cc
+	${CC} -c PacketDecoder.cc -o PacketDecoder.o -g ${INC}
+Client.o: Client.cc
+	${CC} -c Client.cc -g ${INC}
+Server.o: Server.cc
+	${CC} -c Server.cc -g ${INC}
+Synchronisable.o: Synchronisable.cc
+	${CC} -c Synchronisable.cc -g ${INC}
+GameStateManager.o: GameStateManager.cc
+	${CC} -c GameStateManager.cc -g ${INC}
+ClientInformation.o: ClientInformation.cc
+	${CC} -c ClientInformation.cc -g ${INC}
+
+clean:
+	rm -rf *.o
+
+client_old: PacketGenerator.o dummyclient.cc
+	${CC} dummyclient.cc PacketGenerator.o -o client -lenet -g ${INC}
+client: PacketGenerator.o ClientConnection.o PacketBuffer.o dummyclient2.cc 
+	${CC} dummyclient2.cc PacketGenerator.o PacketBuffer.o ClientConnection.o -o client -lenet -lboost_thread -g ${INC}
+
+chatserver: Server.o ConnectionManager.o PacketGenerator.o PacketDecoder.o PacketBuffer.o ClientInformation.o GameStateManager.o
+	${CC} dummyserver3.cc Server.o ConnectionManager.o PacketGenerator.o PacketBuffer.o GameStateManager.o ClientInformation.o -o chatserver -lenet -lboost_thread -g ${INC}
Index: /code/branches/physics/src/network/NetworkCallback.h
===================================================================
--- /code/branches/physics/src/network/NetworkCallback.h	(revision 2122)
+++ /code/branches/physics/src/network/NetworkCallback.h	(revision 2122)
@@ -0,0 +1,32 @@
+#ifndef _NETWORK_CALLBACK__
+#define _NETWORK_CALLBACK__
+
+#include "NetworkPrereqs.h"
+
+namespace network{
+  class _NetworkExport NetworkCallbackBase
+  {
+    public:
+      virtual void call() = 0;
+	  virtual ~NetworkCallbackBase() {}
+  };
+
+  template <class T>
+  class NetworkCallback: public NetworkCallbackBase
+  {
+    public:
+      NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {}
+	  virtual ~NetworkCallback() {}
+      virtual void call()
+        { (this->object_->*function_)(); }
+
+    private:
+      T* object_;
+      void (T::*function_) (void);
+  };
+
+
+}
+
+
+#endif
Index: /code/branches/physics/src/network/NetworkPrereqs.h
===================================================================
--- /code/branches/physics/src/network/NetworkPrereqs.h	(revision 2122)
+++ /code/branches/physics/src/network/NetworkPrereqs.h	(revision 2122)
@@ -0,0 +1,91 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _NetworkPrereqs_H__
+#define _NetworkPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( NETWORK_STATIC_BUILD )
+#  ifdef NETWORK_SHARED_BUILD
+#    define _NetworkExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _NetworkExport
+#    else
+#      define _NetworkExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _NetworkExport  __attribute__ ((visibility("default")))
+#else
+#  define _NetworkExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace network
+{
+  class Client;
+  class ClientConnection;
+  class ClientConnectionListener;
+  class ClientFrameListener;
+  class ClientInformation;
+  class ConnectionManager;
+  class GamestateClient;
+  class GamestateManager;
+  class GamestateHandler;
+  class PacketBuffer;
+  class Server;
+  class ServerFrameListener;
+  class Synchronisable;
+  struct ClientList;
+  struct PacketEnvelope;
+  struct QueueItem;
+  struct syncData;
+  struct synchronisableVariable;
+  namespace packet{
+    class Gamestate;
+    class Packet;
+    class Acknowledgement;
+    class ClassID;
+    class Welcome;
+    class Chat;
+  }
+}
+
+#endif /* _NetworkPrereqs_H__ */
Index: /code/branches/physics/src/network/PacketBuffer.cc
===================================================================
--- /code/branches/physics/src/network/PacketBuffer.cc	(revision 2122)
+++ /code/branches/physics/src/network/PacketBuffer.cc	(revision 2122)
@@ -0,0 +1,149 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+// C++ PacketBuffer
+// d
+// Author Oliver Scheuss
+
+#include "PacketBuffer.h"
+
+#include <iostream>
+#include <queue>
+#include <string>
+#include <boost/bind.hpp>
+#include <boost/thread/mutex.hpp>
+
+namespace network
+{
+   boost::recursive_mutex PacketBuffer::mutex_;
+
+  PacketBuffer::PacketBuffer() {
+    closed=false;
+    first=NULL;
+    last=NULL;
+  }
+  //this is needed in order to make the packetbuffer threadsafe
+
+
+  bool PacketBuffer::push(ENetEvent *ev) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
+    //   if(closed)
+    //     return false;
+    // first element?
+    if(first==NULL){
+      first=new QueueItem;
+      last=first;
+      last->next=NULL;
+      // change this!!!!!!!  ---- we are not doing stl so we won't change this
+      last->event = ev;
+      //last->address = ev->peer->address;
+    } else {
+      //insert a new element at the bottom
+      last->next = new QueueItem;
+      last=last->next;
+      // initialize last->next
+      last->next=NULL;
+      // save the packet to the new element
+      last->event = ev;
+      //last->address = ev->peer->address;
+    }
+    lock.unlock();
+    return true;
+  }
+
+  //returns the first element in the list without deleting it but
+  //moving first pointer to next element
+  /*ENetPacket *PacketBuffer::pop() {
+    ENetAddress address;
+    return pop(address);
+  }*/
+  
+  ENetEvent *PacketBuffer::pop(){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    //std::cout << "packetbuffer pop(address)" << std::endl;
+    if(first!=NULL /*&& !closed*/){
+      QueueItem *temp = first;
+      // get packet
+      ENetEvent *ev=first->event;
+      //address = first->address;
+      // remove first element
+      first = first->next;
+      delete temp;
+      lock.unlock();
+      //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
+      return ev;
+    } else{
+      lock.unlock();
+      return NULL;
+    }
+  }
+
+  /*ENetPacket *PacketBuffer::pop(ENetAddress &address) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    //std::cout << "packetbuffer pop(address)" << std::endl;
+    if(first!=NULL ){
+      QueueItem *temp = first;
+      // get packet
+      ENetPacket *pck=first->event->packet;
+      address = first->event->peer->address;
+      // remove first element
+      first = first->next;
+      delete temp;
+      lock.unlock();
+      //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
+      return pck;
+    } else{
+      lock.unlock();
+      return NULL;
+    }
+  }*/
+
+  bool PacketBuffer::isEmpty() {
+    return (first==NULL);
+  }
+
+  void PacketBuffer::print() {
+    QueueItem *temp=first;
+    while(temp!=NULL){
+      //    std::cout << temp->packet->data << std::endl;
+      temp=temp->next;
+    }
+
+  }
+
+  bool PacketBuffer::isClosed() {
+    return closed;
+  }
+
+  void PacketBuffer::setClosed(bool value){
+    closed=value;
+    return;
+  }
+
+} // namespace network
Index: /code/branches/physics/src/network/PacketBuffer.h
===================================================================
--- /code/branches/physics/src/network/PacketBuffer.h	(revision 2122)
+++ /code/branches/physics/src/network/PacketBuffer.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: PacketBuffer
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _PacketBuffer_H__
+#define _PacketBuffer_H__
+
+#include "NetworkPrereqs.h"
+
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+
+namespace network
+{
+  struct _NetworkExport PacketEnvelope{
+    int length;
+    int data;
+  };
+
+  struct _NetworkExport QueueItem{
+    ENetEvent *event;
+    //ENetAddress address;
+    QueueItem *next;
+  };
+
+  class _NetworkExport PacketBuffer{
+  public:
+    PacketBuffer();
+    bool isEmpty();
+    bool isClosed();
+    void setClosed(bool value);
+    void print();
+    // pops a packet from the queue
+    //ENetPacket *pop();
+    //ENetPacket *pop(ENetAddress &address);
+    ENetEvent *pop();
+    // pushs a packet to the queue
+    bool push(ENetEvent *ev);
+
+  private:
+    QueueItem *first;
+    QueueItem *last;
+    bool closed;
+    static boost::recursive_mutex mutex_;
+  };
+
+} //namespace
+#endif /* _PacketBuffer_H__ */
Index: /code/branches/physics/src/network/Server.cc
===================================================================
--- /code/branches/physics/src/network/Server.cc	(revision 2122)
+++ /code/branches/physics/src/network/Server.cc	(revision 2122)
@@ -0,0 +1,412 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: Server
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "Server.h"
+
+#include <iostream>
+#include <cassert>
+
+
+#include "ConnectionManager.h"
+#include "ClientConnectionListener.h"
+#include "GamestateManager.h"
+#include "ClientInformation.h"
+#include "util/Sleep.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+#include "packet/Chat.h"
+#include "packet/Packet.h"
+#include "packet/Welcome.h"
+#include "packet/DeleteObjects.h"
+#include <util/Convert.h>
+#include "ChatListener.h"
+
+namespace network
+{
+  const unsigned int MAX_FAILURES = 20;
+  const unsigned int NETWORK_FREQUENCY = 25;
+  const float NETWORK_PERIOD = (float)1/NETWORK_FREQUENCY;
+
+  /**
+  * Constructor for default values (bindaddress is set to ENET_HOST_ANY
+  *
+  */
+  Server::Server() {
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager();
+    gamestates_ = new GamestateManager();
+  }
+
+  Server::Server(int port){
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager(port);
+    gamestates_ = new GamestateManager();
+  }
+
+  /**
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, const std::string& bindAddress) {
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager(port, bindAddress);
+    gamestates_ = new GamestateManager();
+  }
+
+  /**
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, const char *bindAddress) {
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager(port, bindAddress);
+    gamestates_ = new GamestateManager();
+  }
+
+  /**
+  * @brief Destructor
+  */
+  Server::~Server(){
+    if(connection)
+      delete connection;
+    if(gamestates_)
+      delete gamestates_;
+  }
+
+  /**
+  * This function opens the server by creating the listener thread
+  */
+  void Server::open() {
+    connection->createListener();
+    return;
+  }
+
+  /**
+  * This function closes the server
+  */
+  void Server::close() {
+    connection->quitListener();
+    return;
+  }
+
+  bool Server::processChat(const std::string& message, unsigned int playerID){
+    ClientInformation *temp = ClientInformation::getBegin();
+    packet::Chat *chat;
+    while(temp){
+      chat = new packet::Chat(message, playerID);
+      chat->setClientID(temp->getID());
+      if(!chat->send())
+        COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
+      temp = temp->next();
+    }
+//    COUT(1) << "Player " << playerID << ": " << message << std::endl;
+    return true;
+  }
+
+
+  /**
+  * Run this function once every tick
+  * calls processQueue and updateGamestate
+  * @param time time since last tick
+  */
+  void Server::tick(float time) {
+    processQueue();
+    //this steers our network frequency
+    timeSinceLastUpdate_+=time;
+    if(timeSinceLastUpdate_>=NETWORK_PERIOD){
+      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
+      gamestates_->processGamestates();
+      updateGamestate();
+    }
+  }
+
+  bool Server::queuePacket(ENetPacket *packet, int clientID){
+    return connection->addPacket(packet, clientID);
+  }
+  
+  /**
+   * @brief: returns ping time to client in milliseconds 
+   */
+  unsigned int Server::getPing(unsigned int clientID){
+    assert(ClientInformation::findClient(clientID));
+    return ClientInformation::findClient(clientID)->getRTT();
+  }
+
+  /**
+   * @brief: return packet loss ratio to client (scales from 0 to 1)
+   */
+  double Server::getPacketLoss(unsigned int clientID){
+    assert(ClientInformation::findClient(clientID));
+    return ClientInformation::findClient(clientID)->getPacketLoss();
+  }
+  
+  /**
+  * processes all the packets waiting in the queue
+  */
+  void Server::processQueue() {
+    ENetEvent *event;
+    while(!connection->queueEmpty()){
+      //std::cout << "Client " << clientID << " sent: " << std::endl;
+      //clientID here is a reference to grab clientID from ClientInformation
+      event = connection->getEvent();
+      if(!event)
+        continue;
+      assert(event->type != ENET_EVENT_TYPE_NONE);
+      switch( event->type ) {
+      case ENET_EVENT_TYPE_CONNECT:
+        COUT(3) << "processing event_Type_connect" << std::endl;
+        addClient(event);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        if(ClientInformation::findClient(&event->peer->address))
+          disconnectClient(event);
+        break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        if(!processPacket(event->packet, event->peer))
+          COUT(3) << "processing incoming packet failed" << std::endl;
+        break;
+      default:
+        break;
+      }
+      delete event;
+      //if statement to catch case that packetbuffer is empty
+    }
+  }
+
+  /**
+  * takes a new snapshot of the gamestate and sends it to the clients
+  */
+  void Server::updateGamestate() {
+    gamestates_->update();
+    COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
+    //std::cout << "updated gamestate, sending it" << std::endl;
+    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
+    sendGameState();
+    sendObjectDeletes();
+    COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
+    //std::cout << "sent gamestate" << std::endl;
+  }
+
+  bool Server::processPacket( ENetPacket *packet, ENetPeer *peer ){
+    packet::Packet *p = packet::Packet::createPacket(packet, peer);
+    return p->process();
+  }
+
+  /**
+  * sends the gamestate
+  */
+  bool Server::sendGameState() {
+    COUT(5) << "Server: starting function sendGameState" << std::endl;
+    ClientInformation *temp = ClientInformation::getBegin();
+    bool added=false;
+    while(temp != NULL){
+      if( !(temp->getSynched()) ){
+        COUT(5) << "Server: not sending gamestate" << std::endl;
+        temp=temp->next();
+        if(!temp)
+          break;
+        //think this works without continue
+        continue;
+      }
+      COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
+      COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
+      int gid = temp->getGamestateID(); //get gamestate id
+      int cid = temp->getID(); //get client id
+      COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl;
+      packet::Gamestate *gs = gamestates_->popGameState(cid);
+      if(gs==NULL){
+        COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
+        temp = temp->next();
+        continue;
+      }
+      //std::cout << "adding gamestate" << std::endl;
+      gs->setClientID(cid);
+      if ( !gs->send() ){
+        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
+        temp->addFailure();
+      }else
+        temp->resetFailures();
+      added=true;
+      temp=temp->next();
+      // gs gets automatically deleted by enet callback
+    }
+    return true;
+  }
+
+  bool Server::sendObjectDeletes(){
+    ClientInformation *temp = ClientInformation::getBegin();
+    packet::DeleteObjects *del = new packet::DeleteObjects();
+    if(!del->fetchIDs())
+      return true;  //everything ok (no deletes this tick)
+//     COUT(3) << "sending DeleteObjects" << std::endl;
+    while(temp != NULL){
+      if( !(temp->getSynched()) ){
+        COUT(5) << "Server: not sending gamestate" << std::endl;
+        temp=temp->next();
+        continue;
+      }
+      int cid = temp->getID(); //get client id
+      packet::DeleteObjects *cd = new packet::DeleteObjects(*del);
+      assert(cd);
+      cd->setClientID(cid);
+      if ( !cd->send() )
+        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
+      temp=temp->next();
+      // gs gets automatically deleted by enet callback
+    }
+    return true;
+  }
+
+
+  bool Server::addClient(ENetEvent *event){
+    static unsigned int newid=1;
+
+    COUT(2) << "Server: adding client" << std::endl;
+    ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
+    if(!temp){
+      COUT(2) << "Server: could not add client" << std::endl;
+      return false;
+    }
+    /*if(temp==ClientInformation::getBegin()) { //not good if you use anything else than insertBack
+      newid=1;
+    }
+    else
+      newid=temp->prev()->getID()+1;*/
+    temp->setID(newid);
+    temp->setPeer(event->peer);
+
+    // inform all the listeners
+    orxonox::ObjectList<ClientConnectionListener>::iterator listener = orxonox::ObjectList<ClientConnectionListener>::begin();
+    while(listener){
+      listener->clientConnected(newid);
+      listener++;
+    }
+
+    newid++;
+
+    COUT(3) << "Server: added client id: " << temp->getID() << std::endl;
+    return createClient(temp->getID());
+}
+
+  bool Server::createClient(int clientID){
+    ClientInformation *temp = ClientInformation::findClient(clientID);
+    if(!temp){
+      COUT(2) << "Conn.Man. could not create client with id: " << clientID << std::endl;
+      return false;
+    }
+    COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
+    connection->syncClassid(temp->getID());
+    temp->setSynched(true);
+    COUT(3) << "sending welcome" << std::endl;
+    packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
+    w->setClientID(temp->getID());
+    bool b = w->send();
+    assert(b);
+    packet::Gamestate *g = new packet::Gamestate();
+    g->setClientID(temp->getID());
+    b = g->collectData(0);
+    if(!b)
+      return false; //no data for the client
+    b = g->compressData();
+    assert(b);
+    b = g->send();
+    assert(b);
+    return true;
+  }
+
+  bool Server::disconnectClient(ENetEvent *event){
+    COUT(4) << "removing client from list" << std::endl;
+    //return removeClient(head_->findClient(&(peer->address))->getID());
+
+    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
+    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
+    if(!client)
+      return false;
+    gamestates_->removeClient(client);
+
+// inform all the listeners
+    orxonox::ObjectList<ClientConnectionListener>::iterator listener = orxonox::ObjectList<ClientConnectionListener>::begin();
+    while(listener){
+      listener->clientDisconnected(client->getID());
+      listener++;
+    }
+
+    return ClientInformation::removeClient(event->peer);
+  }
+
+  void Server::disconnectClient(int clientID){
+    ClientInformation *client = ClientInformation::findClient(clientID);
+    if(client)
+      disconnectClient(client);
+  }
+  void Server::disconnectClient( ClientInformation *client){
+    connection->disconnectClient(client);
+    gamestates_->removeClient(client);
+  }
+
+  bool Server::chat(const std::string& message){
+      return this->sendChat(message, Host::getPlayerID());
+  }
+
+  bool Server::broadcast(const std::string& message){
+      return this->sendChat(message, CLIENTID_UNKNOWN);
+  }
+
+  bool Server::sendChat(const std::string& message, unsigned int clientID){
+    ClientInformation *temp = ClientInformation::getBegin();
+    packet::Chat *chat;
+    while(temp){
+      chat = new packet::Chat(message, clientID);
+      chat->setClientID(temp->getID());
+      if(!chat->send())
+        COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
+      temp = temp->next();
+    }
+//    COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl;
+    for (orxonox::ObjectList<ChatListener>::iterator it = orxonox::ObjectList<ChatListener>::begin(); it != orxonox::ObjectList<ChatListener>::end(); ++it)
+      it->incomingChat(message, clientID);
+
+    return true;
+  }
+
+}
Index: /code/branches/physics/src/network/Server.h
===================================================================
--- /code/branches/physics/src/network/Server.h	(revision 2122)
+++ /code/branches/physics/src/network/Server.h	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: Server
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _Server_H__
+#define _Server_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+
+#include "Host.h"
+#include "GamestateManager.h"
+
+namespace network
+{
+  const int CLIENTID_SERVER = 0;
+
+  /**
+  * This class is the root class of the network module for a server.
+  * It implements all functions necessary for a Server
+  */
+  class _NetworkExport Server : public Host{
+  public:
+    Server();
+    Server(int port);
+    Server(int port, const std::string& bindAddress);
+    Server(int port, const char *bindAddress);
+    ~Server();
+
+    void open();
+    void close();
+    bool processChat(const std::string& message, unsigned int playerID);
+    bool queuePacket(ENetPacket *packet, int clientID);
+    void tick(float time);
+    unsigned int getPing(unsigned int clientID);
+    double getPacketLoss(unsigned int clientID);
+  protected:
+    void processQueue();
+    void updateGamestate();
+  private:
+    virtual bool isServer_(){return true;}
+    unsigned int shipID(){return 0;}
+    unsigned int playerID(){return 0;}
+
+    bool addClient(ENetEvent *event);
+    bool createClient(int clientID);
+    bool disconnectClient(ENetEvent *event);
+    void disconnectClient(int clientID);
+    void disconnectClient( ClientInformation *client);
+    bool processPacket( ENetPacket *packet, ENetPeer *peer );
+    bool sendGameState();
+    bool sendObjectDeletes();
+    virtual bool chat(const std::string& message);
+    virtual bool broadcast(const std::string& message);
+    bool sendChat(const std::string& message, unsigned int clientID);
+
+    //void processChat( chat *data, int clientId);
+    ConnectionManager *connection;
+    GamestateManager *gamestates_;
+
+
+    float timeSinceLastUpdate_;
+  };
+
+
+
+
+}
+
+#endif /* _Server_H__ */
Index: /code/branches/physics/src/network/Synchronisable.cc
===================================================================
--- /code/branches/physics/src/network/Synchronisable.cc	(revision 2122)
+++ /code/branches/physics/src/network/Synchronisable.cc	(revision 2122)
@@ -0,0 +1,523 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Dumeni Manatschal, (C) 2007
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: synchronisable
+//
+// Description:
+//
+//
+// Author:  Dumeni, Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+
+#include "Synchronisable.h"
+
+#include <cstring>
+#include <string>
+#include <iostream>
+#include <assert.h>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+// #include "core/Identifier.h"
+
+namespace network
+{
+
+
+  std::map<unsigned int, Synchronisable *> Synchronisable::objectMap_;
+  std::queue<unsigned int> Synchronisable::deletedObjects_;
+
+  int Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
+
+  /**
+  * Constructor:
+  * Initializes all Variables and sets the right objectID
+  */
+  Synchronisable::Synchronisable(orxonox::BaseObject* creator){
+    RegisterRootObject(Synchronisable);
+    static uint32_t idCounter=0;
+    objectFrequency_=1;
+    objectMode_=0x1; // by default do not send data to server
+    objectID=idCounter++;
+    classID = (unsigned int)-1;
+    syncList = new std::list<synchronisableVariable *>;
+
+    this->creatorID = OBJECTID_UNKNOWN;
+
+    searchcreatorID:
+    if (creator)
+    {
+        Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
+        if (synchronisable_creator && synchronisable_creator->objectMode_)
+        {
+            this->creatorID = synchronisable_creator->getObjectID();
+        }
+        else if (creator != creator->getCreator())
+        {
+            creator = creator->getCreator();
+            goto searchcreatorID;
+        }
+    }
+  }
+
+  /**
+   * Destructor:
+   * Delete all callback objects and remove objectID from the objectMap_
+   */
+  Synchronisable::~Synchronisable(){
+    // delete callback function objects
+    if(!orxonox::Identifier::isCreatingHierarchy()){
+      for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
+        delete (*it)->callback;
+      if (this->objectMode_ != 0x0)
+        deletedObjects_.push(objectID);
+//       COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
+//       COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;
+//       assert(objectMap_[objectID]->objectID==objectID);
+//       objectMap_.erase(objectID);
+    }
+  }
+
+  /**
+   * This function gets called after all neccessary data has been passed to the object
+   * Overload this function and recall the create function of the parent class
+   * @return true/false
+   */
+  bool Synchronisable::create(){
+    this->classID = this->getIdentifier()->getNetworkID();
+//     COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
+
+//     COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl;
+//     objectMap_[objectID]=this;
+//     assert(objectMap_[objectID]==this);
+//     assert(objectMap_[objectID]->objectID==objectID);
+    return true;
+  }
+
+
+  /**
+   * This function sets the internal mode for synchronisation
+   * @param b true if this object is located on a client or on a server
+   */
+  void Synchronisable::setClient(bool b){
+    if(b) // client
+      state_=0x2;
+    else  // server
+      state_=0x1;
+  }
+
+  /**
+   * This function fabricated a new synchrnisable (and children of it), sets calls updateData and create
+   * After calling this function the mem pointer will be increased by the size of the needed data
+   * @param mem pointer to where the appropriate data is located
+   * @param mode defines the mode, how the data should be loaded
+   * @return pointer to the newly created synchronisable
+   */
+  Synchronisable *Synchronisable::fabricate(uint8_t*& mem, int mode)
+  {
+    synchronisableHeader *header = (synchronisableHeader *)mem;
+
+    if(!header->dataAvailable)
+    {
+      mem += header->size;
+      return 0;
+    }
+    
+    COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
+
+    orxonox::Identifier* id = ClassByID(header->classID);
+    assert(id);
+    orxonox::BaseObject* creator = 0;
+    if (header->creatorID != OBJECTID_UNKNOWN)
+    {
+      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header->creatorID);
+      if (!synchronisable_creator)
+      {
+        mem += header->size; //.TODO: this suckz.... remove size from header
+        return 0;
+      }
+      else
+        creator = dynamic_cast<orxonox::BaseObject*>(synchronisable_creator);
+    }
+    orxonox::BaseObject *bo = id->fabricate(creator);
+    assert(bo);
+    Synchronisable *no = dynamic_cast<Synchronisable *>(bo);
+    assert(no);
+    no->objectID=header->objectID;
+    no->creatorID=header->creatorID; //TODO: remove this
+    no->classID=header->classID;
+    COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
+          // update data and create object/entity...
+    bool b = no->updateData(mem, mode, true);
+    assert(b);
+    if (b)
+    {
+        b = no->create();
+        assert(b);
+    }
+    return no;
+  }
+
+
+  /**
+   * Finds and deletes the Synchronisable with the appropriate objectID
+   * @param objectID objectID of the Synchronisable
+   * @return true/false
+   */
+  bool Synchronisable::deleteObject(unsigned int objectID){
+//     assert(getSynchronisable(objectID));
+    if(!getSynchronisable(objectID))
+      return false;
+    assert(getSynchronisable(objectID)->objectID==objectID);
+//     delete objectMap_[objectID];
+    Synchronisable *s = getSynchronisable(objectID);
+    if(s)
+      delete s;
+    else
+      return false;
+    return true;
+  }
+
+  /**
+   * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
+   * @param objectID objectID of the Synchronisable
+   * @return pointer to the Synchronisable with the objectID
+   */
+  Synchronisable* Synchronisable::getSynchronisable(unsigned int objectID){
+    orxonox::ObjectList<Synchronisable>::iterator it;
+    for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
+      if( it->getObjectID()==objectID )
+           return *it;
+    }
+    return NULL;
+
+//     std::map<unsigned int, Synchronisable *>::iterator i = objectMap_.find(objectID);
+//     if(i==objectMap_.end())
+//       return NULL;
+//     assert(i->second->objectID==objectID);
+//     return (*i).second;
+  }
+
+
+  /**
+  * This function is used to register a variable to be synchronized
+  * also counts the total datasize needed to save the variables
+  * @param var pointer to the variable
+  * @param size size of the datatype the variable consists of
+  * @param t the type of the variable (network::DATA or network::STRING
+  * @param mode same as in getData
+  * @param cb callback object that should get called, if the value of the variable changes
+  */
+  void Synchronisable::registerVar(void *var, int size, variableType t, int mode, NetworkCallbackBase *cb){
+    assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);
+    // create temporary synch.Var struct
+    synchronisableVariable *temp = new synchronisableVariable;
+    temp->size = size;
+    temp->var = var;
+    temp->mode = mode;
+    temp->type = t;
+    temp->callback = cb;
+    if( ( mode & direction::bidirectional ) )
+    {
+      temp->varBuffer = new uint8_t[size];
+      memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time
+      temp->varReference = 0;
+    }
+    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;
+    //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;
+    COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl;
+    syncList->push_back(temp);
+#ifndef NDEBUG
+    std::list<synchronisableVariable *>::iterator it = syncList->begin();
+    while(it!=syncList->end()){
+      assert(*it!=var);
+      it++;
+    }
+#endif
+  }
+
+  /**
+   * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID and classID to the given memory
+   * takes a pointer to already allocated memory (must have at least getSize bytes length)
+   * structure of the bitstream:
+   * |totalsize,objectID,classID,var1,var2,string1_length,string1,var3,...|
+   * length of varx: size saved int syncvarlist
+   * @param mem pointer to allocated memory with enough size
+   * @param id gamestateid of the gamestate to be saved (important for priorities)
+   * @param mode defines the direction in which the data will be send/received
+   *             0x1: server->client
+   *             0x2: client->server (not recommended)
+   *             0x3: bidirectional
+   * @return true: if !doSync or if everything was successfully saved
+   */
+  bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){
+    //if this tick is we dont synchronise, then abort now
+    if(!doSync(id))
+      return true;
+    //std::cout << "inside getData" << std::endl;
+    unsigned int tempsize = 0;
+    if(mode==0x0)
+      mode=state_;
+    if(classID==0)
+      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
+
+    if (this->classID == (unsigned int)-1)
+        this->classID = this->getIdentifier()->getNetworkID();
+
+    assert(this->classID==this->getIdentifier()->getNetworkID());
+//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
+    std::list<synchronisableVariable *>::iterator i;
+    unsigned int size;
+    size=getSize(id, mode);
+
+    // start copy header
+    synchronisableHeader *header = (synchronisableHeader *)mem;
+    header->size = size;
+    header->objectID = this->objectID;
+    header->creatorID = this->creatorID;
+    header->classID = this->classID;
+    header->dataAvailable = true;
+    tempsize+=sizeof(synchronisableHeader);
+    mem+=sizeof(synchronisableHeader);
+    // end copy header
+
+
+    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
+    // copy to location
+    for(i=syncList->begin(); i!=syncList->end(); ++i){
+      if( ((*i)->mode & mode) == 0 ){
+        COUT(5) << "not getting data: " << std::endl;
+        continue;  // this variable should only be received
+      }
+      // if the variable gets synchronised bidirectional, then add the reference to the bytestream
+      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
+      {
+        *(uint8_t*)mem = (*i)->varReference;
+        mem += sizeof( (*i)->varReference );
+        tempsize += sizeof( (*i)->varReference );
+      }
+      switch((*i)->type){
+        case DATA:
+          memcpy( (void *)(mem), (void*)((*i)->var), (*i)->size);
+          mem+=(*i)->size;
+          tempsize+=(*i)->size;
+          break;
+        case STRING:
+          memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(size_t) );
+          mem+=sizeof(size_t);
+          const char *data = ( ( *(std::string *) (*i)->var).c_str());
+          memcpy( mem, (void*)data, (*i)->size);
+          COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
+          mem+=(*i)->size;
+          tempsize+=(*i)->size + sizeof(size_t);
+          break;
+      }
+    }
+    assert(tempsize==size);
+    return true;
+  }
+
+
+  /**
+   * This function takes a bytestream and loads the data into the registered variables
+   * @param mem pointer to the bytestream
+   * @param mode same as in getData
+   * @return true/false
+   */
+  bool Synchronisable::updateData(uint8_t*& mem, int mode, bool forceCallback){
+    if(mode==0x0)
+      mode=state_;
+    std::list<synchronisableVariable *>::iterator i;
+    if(syncList->empty()){
+      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
+      return false;
+    }
+
+    uint8_t *data=mem;
+    // start extract header
+    synchronisableHeader *syncHeader = (synchronisableHeader *)mem;
+    assert(syncHeader->objectID==this->objectID);
+//    assert(syncHeader->creatorID==this->creatorID);
+    if(syncHeader->dataAvailable==false){
+      mem+=syncHeader->size;
+      return true;
+    }
+
+    mem+=sizeof(synchronisableHeader);
+    // stop extract header
+    assert(this->objectID==syncHeader->objectID);
+//    assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?
+
+    COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl;
+    for(i=syncList->begin(); i!=syncList->end() && mem <= data+syncHeader->size; i++){
+      if( ((*i)->mode ^ mode) == 0 ){
+        COUT(5) << "synchronisable: not updating variable " << std::endl;
+        continue;  // this variable should only be set
+      }
+      COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
+      bool callback=false;
+      switch((*i)->type){
+        case DATA:
+          if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
+          {
+            if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
+                  ( mode == 0x2 && (*i)->mode == direction::clientMaster ) )    // if true we are master on this variable
+            {
+              uint8_t refNr = *(uint8_t *)mem;
+              if( refNr != (*i)->varReference )
+              {
+                mem += sizeof((*i)->varReference) + (*i)->size; // the reference for this variable is not recent, discard data
+                break;
+              }
+            }
+            else //we are slave for this variable
+            {
+              (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable
+            }
+            mem += sizeof((*i)->varReference);
+          }
+          if((*i)->callback) // check whether this variable changed (but only if callback was set)
+            if(strncmp((char *)(*i)->var, (char *)mem, (*i)->size)!=0)
+              callback=true;
+          memcpy((void*)(*i)->var, mem, (*i)->size);
+          mem+=(*i)->size;
+          break;
+        case STRING:
+          if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
+          {
+            if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
+                  ( mode == 0x2 && (*i)->mode == direction::clientMaster ) )    // if true we are master for this variable
+            {
+              uint8_t refNr = *(uint8_t *)mem;
+              mem += sizeof( (*i)->varReference );
+              if( refNr != (*i)->varReference ){
+                mem += sizeof(size_t) + *(size_t *)mem; // the reference for this variable is not recent, discard data
+                break;
+              }
+            }
+            else //we are slave for this variable
+            {
+              (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable
+            }
+            mem += sizeof( (*i)->varReference );
+          }
+          (*i)->size = *(size_t *)mem;
+          COUT(5) << "string size: " << (*i)->size << std::endl;
+          mem += sizeof(size_t);
+          if((*i)->callback) // check whether this string changed
+            if( *(std::string *)((*i)->var) != std::string((char *)mem) )
+              callback=true;
+          *((std::string *)((*i)->var)) = std::string((const char*)mem);
+          COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl;
+          mem += (*i)->size;
+          break;
+      }
+      // call the callback function, if defined
+      if((callback || forceCallback) && (*i)->callback)
+        (*i)->callback->call();
+    }
+    return true;
+  }
+
+  /**
+  * This function returns the total amount of bytes needed by getData to save the whole content of the variables
+  * @param id id of the gamestate
+  * @param mode same as getData
+  * @return amount of bytes
+  */
+  uint32_t Synchronisable::getSize(unsigned int id, int mode){
+    if(!doSync(id))
+      return 0;
+    int tsize=sizeof(synchronisableHeader);
+    if(mode==0x0)
+      mode=state_;
+    std::list<synchronisableVariable *>::iterator i;
+    for(i=syncList->begin(); i!=syncList->end(); i++){
+      if( ((*i)->mode & mode) == 0 )
+        continue;  // this variable should only be received, so dont add its size to the send-size
+      switch((*i)->type){
+      case DATA:
+        tsize+=(*i)->size;
+        break;
+      case STRING:
+        tsize+=sizeof(int);
+        (*i)->size=((std::string *)(*i)->var)->length()+1;
+        COUT(5) << "String size: " << (*i)->size << std::endl;
+        tsize+=(*i)->size;
+        break;
+      }
+      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
+      {
+        tsize+=sizeof( (*i)->varReference );
+      }
+    }
+    return tsize;
+  }
+
+  /**
+   * This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction)
+   * @param id gamestate id
+   * @return true/false
+   */
+  bool Synchronisable::doSync(unsigned int id){
+    return ( (objectMode_&state_)!=0 && (!syncList->empty() ) );
+  }
+
+  bool Synchronisable::doSelection(unsigned int id){
+    return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
+  }
+
+  /**
+   * This function looks at the header located in the bytestream and checks wheter objectID and classID match with the Synchronisables ones
+   * @param mem pointer to the bytestream
+   */
+  bool Synchronisable::isMyData(uint8_t* mem)
+  {
+    synchronisableHeader *header = (synchronisableHeader *)mem;
+    assert(header->objectID==this->objectID);
+    return header->dataAvailable;
+  }
+
+  /**
+   * This function sets the synchronisation mode of the object
+   * If set to 0x1 variables will only be synchronised to the client
+   * If set to 0x2 variables will only be synchronised to the server
+   * If set to 0x3 variables will be synchronised bidirectionally (only if set so in registerVar)
+   * @param mode same as in registerVar
+   */
+  void Synchronisable::setObjectMode(int mode){
+    assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3);
+    objectMode_=mode;
+  }
+
+
+}
Index: /code/branches/physics/src/network/Synchronisable.h
===================================================================
--- /code/branches/physics/src/network/Synchronisable.h	(revision 2122)
+++ /code/branches/physics/src/network/Synchronisable.h	(revision 2122)
@@ -0,0 +1,145 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Synchronisable_H__
+#define _Synchronisable_H__
+
+#include "NetworkPrereqs.h"
+
+#include <list>
+#include <map>
+#include <queue>
+#include "util/Integers.h"
+#include "core/OrxonoxClass.h"
+#include "core/XMLIncludes.h"
+#include "NetworkCallback.h"
+#include "util/Integers.h"
+
+#define REGISTERDATA(varname, ...) \
+    registerVar((void*)&varname, sizeof(varname), network::DATA, __VA_ARGS__)
+#define REGISTERSTRING(stringname, ...) \
+    registerVar(&stringname, stringname.length()+1, network::STRING, __VA_ARGS__)
+
+namespace network
+{
+  static const unsigned int OBJECTID_UNKNOWN = (unsigned int)-1;
+
+  namespace direction{
+    enum syncdirection{
+      toclient=0x1,
+      toserver=0x2,
+      bidirectional=0x3,
+      serverMaster=0x3,
+      clientMaster=0x7
+    };
+  }
+
+  namespace syncmode{
+    enum mode{
+      one=0,
+      always=1
+    };
+  }
+
+  enum variableType{
+    DATA,
+    STRING,
+  };
+
+  struct _NetworkExport synchronisableHeader{
+    uint32_t size:31;
+    bool dataAvailable:1;
+    uint32_t objectID;
+    uint32_t creatorID;
+    uint32_t classID;
+  };
+
+  struct _NetworkExport synchronisableVariable{
+    unsigned int size;
+    int mode; // this determines in which direction the variable gets synchronised
+    void *var;
+    variableType type;
+    NetworkCallbackBase *callback;
+    void *varBuffer;
+    uint8_t varReference;
+  };
+
+  /**
+  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
+   * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list.
+  * @author Oliver Scheuss
+  */
+  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
+  public:
+    friend class packet::Gamestate;
+    friend class GamestateClient;
+    friend class Server;
+    virtual ~Synchronisable();
+
+
+    virtual bool create();
+    static void setClient(bool b);
+
+    static Synchronisable *fabricate(uint8_t*& mem, int mode=0x0);
+    static bool deleteObject(unsigned int objectID);
+    static Synchronisable *getSynchronisable(unsigned int objectID);
+    static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); }
+    static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
+
+    inline unsigned int getObjectID(){return objectID;}
+    inline unsigned int getClassID(){return classID;}
+  protected:
+    Synchronisable(orxonox::BaseObject* creator);
+    void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
+    void setObjectMode(int mode);
+    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
+
+
+  private:
+    bool getData(uint8_t*& men, unsigned int id, int mode=0x0);
+    uint32_t getSize(unsigned int id, int mode=0x0);
+    bool updateData(uint8_t*& mem, int mode=0x0, bool forceCallback=false);
+    bool isMyData(uint8_t* mem);
+    bool doSelection(unsigned int id);
+    bool doSync(unsigned int id);
+
+    unsigned int objectID;
+    unsigned int creatorID;
+    unsigned int classID;
+
+    std::list<synchronisableVariable *> *syncList;
+    static int state_; // detemines wheter we are server (default) or client
+    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
+    unsigned int objectFrequency_;
+    int objectMode_;
+    static std::map<unsigned int, Synchronisable *> objectMap_;
+    static std::queue<unsigned int> deletedObjects_;
+  };
+}
+
+#endif /* _Synchronisable_H__ */
Index: /code/branches/physics/src/network/TODO
===================================================================
--- /code/branches/physics/src/network/TODO	(revision 2122)
+++ /code/branches/physics/src/network/TODO	(revision 2122)
@@ -0,0 +1,15 @@
+TODO:
+
+- change ConnectionManager clientlist [done]
+- change gamestatemanager clientlist [done]
+- put them together into ClientInformation [done]
+
+- do better gamestate-update/snapshot-handling [partially done]
+- integrate ClientInformation into gamestatemanager [done]
+
+- write dummyserver and dummyclient (chat system) [done]
+
+- include GameStateClient into Client and write processGamestate (also packetdecoder (virtual))
+- create object with worldentity .....
+
+- try and error ;)
Index: /code/branches/physics/src/network/diffTest.cc
===================================================================
--- /code/branches/physics/src/network/diffTest.cc	(revision 2122)
+++ /code/branches/physics/src/network/diffTest.cc	(revision 2122)
@@ -0,0 +1,726 @@
+#include "enet/enet.h"
+#include "Orxonox.h"
+#include "NetworkPrereqs.h"
+#include "PacketTypes.h"
+#include "GameStateManager.h"
+#include "Synchronisable.h"
+#include "GameStateClient.h"
+#include "iostream"
+#include "core/CoreIncludes.h"
+#include "time.h"
+#include "ConnectionManager.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+#include "util/Sleep.h"
+
+using namespace network;
+
+void printData( unsigned char* data, int length ) {
+  for ( int i=0; i<length; i++ )
+    std::cout << (int)data[i] << " ";
+  std::cout << std::endl;
+}
+
+void printGameStateCompressed( GameStateCompressed* gc ) {
+  //std::cout << "=================================================" << std::endl;
+  std::cout << "GameStateCompressed id:\t\t" << gc->id << std::endl;
+  std::cout << "GameStateCompressed normsize:\t" << gc->normsize << std::endl;
+  std::cout << "GameStateCompressed compsize:\t" << gc->compsize << std::endl;
+  std::cout << "GameStateCompressed diffed:\t" << gc->diffed << std::endl;
+  //std::cout << "GameState data:\t" << gc->data << std::endl;
+  std::cout << "GameStateCompressed compressing rate:\t" << 100.0-((100.0/(gc->normsize))*(gc->compsize)) << "%" << std::endl;
+  std::cout << "=================================================" << std::endl;
+  return;
+}
+
+bool compareData( GameState* g1, GameState* g2 ) {
+  if ( g1->id != g2->id ) {
+    std::cout << "\t--> GameStates are not comparable -> not same id" << std::endl;
+    return true;
+  }
+  else if ( g1->size != g2->size ) {
+    std::cout << "\t--> GameStates are not the same size!!" << std::endl;
+    std::cout << g1->size << " != " << g2->size << std::endl;
+  }
+  int length = g1->size;
+  for ( int i=0; i<length; i++ ) {
+    if ( g1->data[i] != g2->data[i] ) {
+      std::cout << "\t--> data of both GameStates are not identical" << std::endl;
+      return false;
+    }
+  }
+  //std::cout << "\t--> GameData are identical (compareData)" << std::endl;
+  return true;
+}
+
+bool compareData2( GameState* g1, GameState* g2 ) {
+  int length = g1->size;
+  for ( int i=0; i<length; i++ ) {
+    if ( g1->data[i] != g2->data[i] ) {
+      return false;
+    }
+  }
+  //std::cout << "\t--> GameData are identical (compareData)" << std::endl;
+  return true;
+}
+
+bool compareGameStates( GameState* g1, GameState* g2 ) {
+  if ( g1->id != g2->id ) {
+    std::cout << "\t==> GameState id's not identical (GameStateCompare)" << std::endl;
+  }
+  if( g1->size != g2->size ) {
+    std::cout << "\t==> GameState sizes are not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  else if ( g1->diffed != g2->diffed ) {
+    std::cout << "\t==> GameState diffed params not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  else if ( !compareData2( g1, g2 ) ) {
+    std::cout << "\t==> GameState data are not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  //std::cout << "\t==> GameStates are identical (GameStateCompare)" << std::endl;
+  return true;
+}
+
+void printGameState( GameState* gstate ) {
+  //std::cout << "=================================================" << std::endl;
+  std::cout << "GameState id:\t\t" << gstate->id << std::endl;
+  std::cout << "GameState size:\t\t" << gstate->size << std::endl;
+  std::cout << "GameState diffed:\t" << gstate->diffed << std::endl;
+  //std::cout << "GameState data:\t" << gstate->data << std::endl;
+  std::cout << "=================================================" << std::endl;
+  return;
+}
+
+unsigned char* createData( int length, int mode ) {
+  char* data = new char[ length ];
+  if ( mode == 1 ) {
+    for ( int i=0; i<length; i++ )
+      data[i] = (char)(i%255);
+  }
+  else if ( mode == 2 ) {
+    for ( int i=0; i<length; i++ ) {
+      if ( i%98 == 0 ) data[i] = (char)(i%255);
+      else data[i] = (char)0;
+    }
+  }
+  else if ( mode == 3 ) {
+    for ( int i=0; i<length; i++ ){
+      data[i] = (char)(rand()%255);
+    }
+  }
+  else if ( mode == 4 ) {
+    for ( int i=0; i<length; i++ ){
+      data[i] = (char)(rand()%127);
+    }
+  }
+
+  //printData( data, length );  
+
+  unsigned char* dat = (unsigned char*)data;
+  return dat;
+}
+
+GameState* changeGameStateABit( GameState* a, int mode ) {
+  int length = a->size;
+  GameState* b = new GameState;
+  b->id = a->id;
+  b->diffed = a->diffed;
+
+  if ( mode == 1 ) {
+    b->data = new unsigned char[length];
+    b->size = a->size;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+  else if ( mode == 2 ) {
+    b->data = new unsigned char[length];
+    b->size = length;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%(rand()%((length)/11)+rand()) == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+  else if ( mode == 3 ) {
+    int s = length + (rand()%(length));
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+    for( int i=length; i<s; i++ ) {
+      b->data[i] = (char)rand()%255;
+    }
+  }
+  else if ( mode == 4 ) {
+    int s = length + (rand()%(length));
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%(rand()%(length)+rand()) == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+    for( int i=length; i<s; i++ ) {
+      b->data[i] = rand()%255;
+    }
+  }
+    else if ( mode == 5 ) {
+    int s = (length)/2;
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<s; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+
+  return b;
+}
+
+void testCompression( int size, int mode ) {
+  std::cout << "testing compression with: size = " << size << " ,mode = " << mode << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameState* g_new = new GameState;
+  GameState* g_old = new GameState;
+  GameStateCompressed* gc = new GameStateCompressed;
+  
+  g_old->data = createData( size, mode );
+  g_old->size = size;
+  g_old->id = 0;
+  g_old->diffed = false;
+  printGameState( g_old );
+  
+  gc = g_manager->testCompress( g_old );
+  printGameStateCompressed( gc );
+
+  g_new = g_client->testDecompress( gc );
+  printGameState( g_new );
+
+  compareGameStates( g_new, g_old );
+
+  return;
+}
+
+void testDifferentiation( int size, int modeCreateData, int modeChangeData ) {
+  std::cout << "testing diff with: size = " << size << " modeCreateData = " 
+            << modeCreateData << " modeChangeData = " << modeChangeData << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;
+  
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_result;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  printGameState( g_undiff1 );
+
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  printGameState( g_undiff2 );
+
+  if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " BUT THAT'S HOW IT HAS TO BE" << std::endl;
+
+  //printData( g_undiff1->data, g_undiff1->size );
+  //printData( g_undiff2->data, g_undiff2->size );
+  
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  printGameState( g_diffed );
+  //printData( g_diffed->data, g_diffed->size );
+  
+  g_result = g_client->testUndiff( g_undiff1, g_diffed );
+  compareGameStates( g_result, g_undiff2 );
+
+  return;
+}
+
+void testCompressWithDiff( int size, int modeCreateData, int modeChangeData ) {
+  std::cout << "testing CompressWithDiff with: size = " << size << " modeCreateData = " 
+            << modeCreateData << " modeChangeData = " << modeChangeData << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameStateCompressed* gc = new GameStateCompressed;
+  GameStateCompressed* g_compressedNoDiff;
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_resultDiffed;
+  GameState* g_resultUndiffed;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  
+  std::cout << "---First generated Gamestate" << std::endl;
+  printGameState( g_undiff1 );
+
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  std::cout << "---First gererated Gamestate with some changes ev. longer" << std::endl;
+  printGameState( g_undiff2 );  
+
+  if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " DATA not identical.. ok" << std::endl;
+
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  std::cout << "---Diffed Gamestate not compressed" << std::endl;
+  printGameState( g_diffed );
+
+  gc = g_manager->testCompress( g_diffed );
+  std::cout << "---Diffed Gamestate compressed" << std::endl;
+  printGameStateCompressed( gc );
+
+  g_compressedNoDiff = g_manager->testCompress( g_undiff2 );
+  std::cout << "---Same not Diffed Gamestate compressen" << std::endl;
+  printGameStateCompressed( g_compressedNoDiff ); 
+
+  g_resultDiffed = g_client->testDecompress( gc );
+  std::cout << "---Diffed Gamestate of above uncompressed" << std::endl;
+  printGameState( g_resultDiffed );
+
+  std::cout << "---Diffed Gamestates before compressed and after uncompress comparsion" << std::endl;
+  if ( compareGameStates( g_resultDiffed, g_diffed ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl;
+ 
+  g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed );
+  std::cout << "---New Gamestate of pseudo Server compared with new gamestate that Client gets" << std::endl;
+  if ( compareGameStates( g_resultUndiffed, g_undiff2 ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl;
+
+  return;  
+}
+
+bool testNCompressWithDiff( int n, int size, int modeCreateData, int modeChangeData ) { 
+
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameStateCompressed* gc = new GameStateCompressed;
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_resultDiffed;
+  GameState* g_resultUndiffed;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  //l = -1;
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+
+  while( compareData2( g_undiff1, g_undiff2 ) ) {
+    delete g_undiff2->data;
+    g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  } 
+  //l = -2;
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  gc = g_manager->testCompress( g_diffed );
+  g_resultDiffed = g_client->testDecompress( gc );
+
+  if ( !compareGameStates( g_resultDiffed, g_diffed ) ) return false;
+  //l = -3;
+  g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed );
+  if ( !compareGameStates( g_resultUndiffed, g_undiff2 ) ) return false;
+  //l = 1;
+  /*if ( gc != NULL && gc->data != NULL )
+    delete gc->data;
+  //l = 2;
+  //if ( gc != NULL ) 
+    //delete gc;
+  //l = 3;
+  if ( g_undiff1 != NULL && g_undiff1->data != NULL )
+    delete g_undiff1->data;
+  //l = 4; 
+  //if ( g_undiff1 != NULL )
+   //delete g_undiff1;
+  //l = 5;
+  if ( g_undiff2 != NULL && g_undiff2->data )
+    delete g_undiff2->data;
+  //l = 6; 
+  //if ( g_undiff2 != NULL )
+    //delete g_undiff2;
+  //l = 7;
+  if ( g_diffed != NULL && g_diffed->data )
+    //delete g_diffed->data;
+  //l = 8; 
+  //if ( g_diffed )
+    //delete g_diffed;
+  //l = 9;
+  if ( g_resultDiffed != NULL && g_resultDiffed->data )
+    delete g_resultDiffed->data;
+  //l = 10; 
+  //if ( g_resultDiffed )
+    //delete g_resultDiffed;
+  //l = 11;*/
+  
+  return true;
+}
+
+bool testNCompression( int n, int size, int mode ) { 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameState* g_new = new GameState;
+  GameState* g_old = new GameState;
+  GameStateCompressed* gc = new GameStateCompressed;
+  
+  g_old->data = createData( size, mode );
+  g_old->size = size;
+  g_old->id = 0;
+  g_old->diffed = false;
+  
+  gc = g_manager->testCompress( g_old );
+
+  g_new = g_client->testDecompress( gc );
+
+  if ( !compareGameStates( g_new, g_old ) ) return false;
+  
+  
+  if ( g_new != NULL && g_new->data != NULL )
+    delete g_new->data;
+
+  if ( g_old != NULL && g_old->data != NULL )
+    delete g_old->data;
+
+  if ( gc != NULL && gc->data )
+    delete gc->data;
+
+  return true;
+}
+
+void printClientObjectMapping( ConnectionManager* cmanager, int clients ) {
+  std::map<int, int>::iterator iter;
+  std::map<int, int> clientsmap = cmanager->testGetClientsShip();   
+  for( iter = clientsmap.begin(); iter != clientsmap.end(); iter++ ) {
+    std::cout << "clientID: " << iter->first << "\t-> objectID: " << iter->second << std::endl;
+  }
+  return;
+}
+
+bool is( int a[], int b, int size ) {
+  for ( int i=0; i<size; i++ ) {
+    if ( a[i] == b ) return true;
+  }
+  return false;
+}
+
+void testClientObjectMapping( int clients ) {
+  ConnectionManager* cmanager = new ConnectionManager();
+  int shift = 2;
+  std::cout << "create a map length [clients]" << std::endl;
+  for ( int i=0; i<clients; i++ ) {
+    cmanager->testAddClientsShipID( i, i+shift );
+  }
+  printClientObjectMapping( cmanager, clients );
+  
+  std::cout << "get random client's ship id" << std::endl;
+  int id;
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = rand()%clients;
+    std::cout << "client: " << id << "\t-> ship: " << cmanager->testGetClientsShipID( id ) << std::endl;  
+  }
+
+  std::cout <<"get random ship's client id" << std::endl;
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = (rand()%clients)+shift;
+    std::cout << "ship:   " << id << "\t-> client: " << cmanager->testGetObjectsClientID( id ) << std::endl;  
+  }
+
+  std::cout << "delete random client from map" << std::endl;
+  int deleted[clients/3];
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = rand()%clients;
+    if ( !is( deleted, id, clients/3 ) ) {
+      std::cout << "delete client " << id << std::endl;
+      cmanager->testDeleteClientsIDReg( id ); 
+    }
+    deleted[i] = id;
+  }
+  std::cout << "resulting list:" << std::endl;
+  printClientObjectMapping( cmanager, clients-(clients/3));
+  
+  std::cout << "delete random object from map" << std::endl;
+  int jap = 0;
+  while( jap < 3 ) {
+    id = (rand()%clients) + shift;
+    if ( !is( deleted, id, clients/3 ) ) {
+      std::cout << "delete object: " << id << std::endl;
+      cmanager->testDeleteObjectIDReg( id );
+      jap++;
+    }
+  }
+  std::cout << "resulting list:" << std::endl;
+  printClientObjectMapping( cmanager, clients-(clients/3)-3);
+}
+
+bool addClientTest( ENetEvent* event, ClientInformation*& head ) {
+  ClientInformation *temp = head->insertBack(new ClientInformation);
+  if(!temp)
+    return false;
+  if(temp->prev()->head) {
+    temp->prev()->setID(0);
+    temp->setID(1);
+  }
+  else
+    temp->setID(temp->prev()->getID()+1);
+  temp->setPeer(event->peer);
+  std::cout << "added client id: " << temp->getID() << std::endl;
+
+  return temp->setSynched(true);
+}
+
+void printClientInformationBox( ClientInformation* box ) {
+  if(!box)
+    return;
+  std::cout << "ClientList: id: " << box->getID() << "\t";
+  std::cout << "g_id: " << box->getGamestateID() << " \t";
+  std::cout << "synched: " << box->getSynched() << "\t";
+  std::cout << "is head: " << box->head << std::endl;
+}
+
+void printClientInformationList( ClientInformation* list ) {
+  printClientInformationBox( list );
+  list = list->next();
+  
+  while( list != 0 ) {
+    printClientInformationBox( list );
+    list = list->next();
+  }
+  return;
+}
+
+void testClientInformation( int numberOfClients ) {
+  ClientInformation* head = new ClientInformation( true );
+  ConnectionManager* connectionManager;
+  ENetEvent event;
+  
+  for ( int i=0; i<numberOfClients; i++ ) {
+    if ( !addClientTest( &event, head ) ) {
+      std::cout << "addClientTest didn't work with: " << i << std::endl;
+    }
+  }
+  std::cout << "(now id should be synched, since that works and this is test of list, this step is left out)" << std::endl;
+
+  printClientInformationList( head );
+
+  std::cout << "remove some clients" << std::endl;
+  if ( head->removeClient( numberOfClients/3 ) ) std::cout << "client " << numberOfClients/3 << " removed" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients/3 << std::endl;
+  if ( head->removeClient( numberOfClients ) ) std::cout << "client " << numberOfClients << " removed" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients << std::endl;
+  if ( head->removeClient( 1 ) ) std::cout << "client " << 1 << " removed" << std::endl;
+  else std::cout << "could not remove client: " << 1 << std::endl;
+  if ( head->removeClient( 1 ) ) std::cout << "client " << 1 << " removed a second time" << std::endl;
+  else std::cout << "could not remove client: " << 1 << std::endl;
+  if ( head->removeClient( numberOfClients + 100 ) ) std::cout << "client " << numberOfClients + 100 << " removed a second time" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients + 100 << std::endl;
+
+  printClientInformationList( head );
+  
+  std::cout << "try to find some clients with findClient(..., false)" << std::endl;
+  ClientInformation* temp = head->findClient( 2 );
+  printClientInformationBox( temp );
+  temp = head->findClient( numberOfClients/3 );
+  printClientInformationBox( temp );
+  temp = head->findClient( 0 );
+  printClientInformationBox( temp );
+  temp = head->findClient( 8 );
+  printClientInformationBox( temp );
+
+  std::cout << "find the same, output should be identical with above but with findClient(..., TRUE)" << std::endl;
+  temp = head->findClient( 2, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( numberOfClients/3, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( 0, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( 8, true );
+  printClientInformationBox( temp );
+
+  std::cout << "test setGamestateID" << std::endl;
+  temp->setGameStateID( 8 );
+  printClientInformationBox( temp );
+
+  std::cout << "test insertAfter() and insertBefore()" << std::endl;
+  ClientInformation* newInfo = new ClientInformation;
+  ClientInformation* toool = new ClientInformation;
+  newInfo->setGamestateID( 200 );
+  newInfo->setID( numberOfClients+2);
+  newInfo->setSynched( true );
+  newInfo->setPeer( NULL );
+  toool->setGameStateID( 199 );
+  toool->setID( numberOfClients+1);
+  toool->setSynched( true );
+  toool->setPeer( NULL );
+
+  //never use the same ClientInformation box in this situation
+  //-> results in endless loop
+  temp->insertAfter( newInfo );
+  temp->insertBefore( toool );
+
+  printClientInformationList( head );
+  return;
+}
+
+//### following stuff is to test buffer, took from PacketBufferTestExt.cc ###
+
+void write(PacketBuffer *test){
+  ENetEvent event;
+  ENetPacket *packet;
+  if(test->isEmpty())
+    std::cout << "buffer is empty" << std::endl;
+  for(int i=0; i<10; i++){
+    std::string temp = "packet ";
+    packet = enet_packet_create("packet", strlen("packet ")+1,
+      ENET_PACKET_FLAG_RELIABLE);
+    std::cout << i << ": pushing " << packet->data << std::endl;
+    event.packet=packet;
+    test->push(&event);
+    if(i==5)
+      usleep(200000);
+  }
+  test->setClosed(true);
+  return;
+}
+
+void read(PacketBuffer *test){
+  //test->print();
+  // exit if the queue is closed and empty
+  while(!test->isClosed() || !test->isEmpty()){
+    // only pop if the queue isn't empty
+    while(!test->isEmpty()){
+      std::cout << "We popped the value " << test->pop()->data << std::endl;
+    }
+  }
+  return;
+}
+
+void testPacketBuffer() {
+  PacketBuffer test = PacketBuffer();
+  boost::thread thrd1(boost::bind(&write, &test));
+  boost::thread thrd2(boost::bind(&read, &test));
+
+  thrd1.join();
+  thrd2.join();
+  return;
+}
+
+//### end packetbuffer test stuff ###
+
+void testSynchronisable() {
+  Synchronisable* synchtest;
+  unsigned char* data = new unsigned char[100];
+  for( int i=0; i<100; i++ ) {
+    data[i] = i%10;
+  }
+  //synchtest->registerVar( (const void*)data, 100, network::DATA );
+}
+
+//#########################################################################
+//### this stuff is only a loop to chose one of the prev test functions ###
+//#########################################################################
+void displayModes() {
+  std::cout << "mode datalength: length of data array to create" << std::endl;
+  std::cout << "mode Data:" << std::endl;
+  std::cout << "\t-1 -> array[length] with numbers length%255" << std::endl;
+  std::cout << "\t-2 -> array[length] with numbers length%255, every %98 is != 0" << std::endl;
+  std::cout << "\t-3 -> array[length] with random numbers (-126:127) no modulo zeros" << std::endl;
+  std::cout << "\t-4 -> array[length] with random numbers (0:127) no modulo zeros" << std::endl;
+  std::cout << "---------------------------------------------------------------------------------" << std::endl;
+  std::cout << "mode Change:" << std::endl;
+  std::cout << "\t-1 -> every %10 == 0 index is different from original" << std::endl;
+  std::cout << "\t-2 -> every %(rand()%(length/11)) is different from original" << std::endl;
+  std::cout << "\t-3 -> every %10 == 0 index is different and randomly longer till 2xlonger" << std::endl;
+  std::cout << "\t-4 -> random differences and randomly longer" << std::endl;
+  std::cout << "\t-5 -> only half as long and ever %10 == 0 index is different" << std::endl;
+}
+
+int main( int argc, char* argv[] ) {
+  int a,b,c,n;
+  std::string dec = "nothing";
+  std::cout << "############### START TEST (quit q) ###############" << std::endl;
+  std::cout << "possible tests: " << std::endl;
+  std::cout << "displayModes:\t\t modes" << std::endl;
+  std::cout << "testCompression:\t tc [datalength] [mode Data]" << std::endl;
+  std::cout << "testNCompression:\t tnc [#of loops] [datalength] [mode Data]" << std::endl;
+  std::cout << "testDifferentiation:\t td [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testCompressWithDiff:\t tcd [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testNCompressWithDiff:\t tncd [#of loops] [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testClientObjectMapping: tcom [#clients]" << std::endl;
+  std::cout << "testClientInformation:\t tci [#clients] (call with >10)" << std::endl;
+  std::cout << "testPacketBuffer:\t tbuf (comment address assignements in PacketBuffer.cc!)" << std::endl;
+  while ( dec.compare("q") != 0 ) {
+    std::cin >> dec;
+    if ( dec.compare("tc") == 0 ) {
+      std::cin >> a; std::cin >> b;
+      testCompression( a, b );
+    }
+    else if ( dec.compare("td") == 0 ) {
+      std::cin>> a; std::cin >> b; std::cin >> c;
+      testDifferentiation( a, b, c );
+    }
+    else if ( dec.compare("tcd") == 0 ) {
+      std::cin>> a; std::cin >> b; std::cin >> c;
+      testCompressWithDiff( a, b, c );
+    }
+    else if ( dec.compare("modes") == 0 )
+      displayModes();
+    else if ( dec.compare("tcom") == 0 ) {
+      std::cin>> a;
+      testClientObjectMapping( a );
+    }
+    else if ( dec.compare("tci") == 0 ) {
+      std::cin >> a;
+      testClientInformation( a );
+    } 
+    else if ( dec.compare("tbuf") == 0 ) {
+      testPacketBuffer();
+    } 
+    else if ( dec.compare("tncd") == 0 ) {
+      std::cin >> n; std::cin >> a; std::cin >> b; std::cin >> c;
+      for ( int i=1; i<=n; i++ ) {  
+        std::cout << i << " s" << a << " ";      
+        //std::cout << "start loop test " << i << std::endl;
+        if ( !testNCompressWithDiff( i, a, b, c ) ) {
+          std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl;
+          break;
+        }
+      }
+      std::cout << "end loop comparsion test" << std::endl;
+    }
+    else if ( dec.compare("tnc") == 0 ) {
+      std::cin >> n; std::cin >> a; std::cin >> b;
+      for ( int i=1; i<=n; i++ ) {  
+        std::cout << i << " s" << a << " ";      
+        //std::cout << "start loop test " << i << std::endl;
+        if ( !testNCompression( i, a, b ) ) {
+          std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl;
+          break;
+        }
+      }
+      std::cout << "end loop comparsion test" << std::endl;
+    }
+    else std::cout << "invalid input" << std::endl;  
+    std::cout << "################## END ONE TURN ##################@" << std::endl;
+  }
+  return 0;
+}
+/*
+int main() {
+  std::cout << "############### START TEST (quit q) ###############" << std::endl;
+  testSynchronisable();
+}*/
+
+//#########################################################################
+//### the prev loop is only to chose one prev prev test functions       ###
+//#########################################################################
Index: /code/branches/physics/src/network/packet/Acknowledgement.cc
===================================================================
--- /code/branches/physics/src/network/packet/Acknowledgement.cc	(revision 2122)
+++ /code/branches/physics/src/network/packet/Acknowledgement.cc	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "Acknowledgement.h"
+#include "network/Host.h"
+#include "network/GamestateHandler.h"
+#include "core/CoreIncludes.h"
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAGS_ACK    0
+#define _PACKETID           0
+#define _ACKID              _PACKETID + sizeof(network::packet::ENUM::Type)
+  
+Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_ACK;
+  data_=new uint8_t[ getSize() ];
+  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement;
+  *(uint32_t *)(data_ + _ACKID ) = id;
+  clientID_=clientID;
+}
+
+Acknowledgement::Acknowledgement( uint8_t *data, unsigned int clientID )
+  : Packet(data, clientID)
+{
+}
+
+Acknowledgement::~Acknowledgement()
+{
+}
+
+unsigned int Acknowledgement::getSize() const{
+  return _ACKID + sizeof(uint32_t);
+}
+
+bool Acknowledgement::process(){
+  bool b = GamestateHandler::ackGamestate(getAckID(), clientID_);
+  delete this;
+  return b;
+}
+
+unsigned int Acknowledgement::getAckID(){
+  return *(uint32_t *)(data_ + _ACKID);
+}
+
+} //namespace packet
+} //namespace network
Index: /code/branches/physics/src/network/packet/Acknowledgement.h
===================================================================
--- /code/branches/physics/src/network/packet/Acknowledgement.h	(revision 2122)
+++ /code/branches/physics/src/network/packet/Acknowledgement.h	(revision 2122)
@@ -0,0 +1,57 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKACKNOLEDGEMENT_H
+#define NETWORKACKNOLEDGEMENT_H
+
+#include "../NetworkPrereqs.h"
+#include "Packet.h"
+
+
+namespace network {
+namespace packet {
+/**
+	@author
+*/
+class _NetworkExport Acknowledgement : public Packet
+{
+public:
+  Acknowledgement( unsigned int id, unsigned int clientID );
+  Acknowledgement( uint8_t* data, unsigned int clientID );
+  ~Acknowledgement();
+
+  inline unsigned int getSize() const;
+  bool process();
+
+  unsigned int getAckID();
+private:
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/physics/src/network/packet/Chat.cc
===================================================================
--- /code/branches/physics/src/network/packet/Chat.cc	(revision 2122)
+++ /code/branches/physics/src/network/packet/Chat.cc	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Chat.h"
+#include <assert.h>
+#include "network/Host.h"
+
+namespace network {
+namespace packet {
+  
+#define   PACKET_FLAGS_CHAT ENET_PACKET_FLAG_RELIABLE
+#define   _PACKETID         0
+const int _PLAYERID     =   _PACKETID + sizeof(ENUM::Type);
+#define   _MESSAGELENGTH    _PLAYERID + sizeof(uint32_t)
+#define   _MESSAGE          _MESSAGELENGTH + sizeof(uint32_t)
+
+Chat::Chat( std::string message, unsigned int playerID )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_CHAT;
+  messageLength_ = message.length()+1;
+  data_=new unsigned char[ getSize() ];
+  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Chat;
+  *(unsigned int *)(data_ + _PLAYERID ) = playerID;
+  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
+  memcpy( data_+_MESSAGE, (void *)message.c_str(), messageLength_ );
+}
+
+Chat::Chat( uint8_t* data, unsigned int clientID )
+  : Packet(data, clientID)
+{
+  messageLength_ = *(uint32_t *)(data + _MESSAGELENGTH );
+}
+
+Chat::~Chat()
+{
+}
+
+unsigned int Chat::getSize() const{
+  return _MESSAGE + messageLength_;
+}
+
+bool Chat::process(){
+  bool b = Host::incomingChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_PLAYERID));
+  delete this;
+  return b;
+}
+
+unsigned char *Chat::getMessage(){
+  return data_ + _MESSAGE;
+}
+
+} //namespace packet
+} //namespace network
Index: /code/branches/physics/src/network/packet/Chat.h
===================================================================
--- /code/branches/physics/src/network/packet/Chat.h	(revision 2122)
+++ /code/branches/physics/src/network/packet/Chat.h	(revision 2122)
@@ -0,0 +1,37 @@
+
+#ifndef NETWORKCHAT_H
+#define NETWORKCHAT_H
+
+#include "../NetworkPrereqs.h"
+
+#include <string>
+#include <cstring>
+
+#include "Packet.h"
+
+namespace network {
+namespace packet {
+/**
+	@author
+*/
+class _NetworkExport Chat : public Packet
+{
+public:
+  Chat( std::string message, unsigned int playerID );
+  Chat( uint8_t* data, unsigned int clientID );
+  ~Chat();
+
+  inline unsigned int getSize() const;
+  bool process();
+
+  unsigned int getMessageLength(){ return messageLength_; };
+  unsigned char *getMessage();
+private:
+  uint32_t messageLength_;
+  unsigned int clientID_;
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/physics/src/network/packet/ClassID.cc
===================================================================
--- /code/branches/physics/src/network/packet/ClassID.cc	(revision 2122)
+++ /code/branches/physics/src/network/packet/ClassID.cc	(revision 2122)
@@ -0,0 +1,88 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+
+#include "ClassID.h"
+#include "core/CoreIncludes.h"
+#include <cstring>
+#include <assert.h>
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID             0
+#define _CLASSID              _PACKETID + sizeof(ENUM::Type)
+#define _CLASSNAMELENGTH      _CLASSID + sizeof(uint32_t)
+#define _CLASSNAME            _CLASSNAMELENGTH + sizeof(classNameLength_)
+
+  ClassID::ClassID( unsigned int classID, std::string className )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_CLASSID;
+  classNameLength_=className.length()+1;
+  assert(getSize());
+  data_=new unsigned char[ getSize() ];
+  assert(data_);
+  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::ClassID;
+  *(unsigned int *)(data_ + _CLASSID ) = classID;
+  *(unsigned int *)(data_ + _CLASSNAMELENGTH ) = classNameLength_;
+  memcpy( data_+_CLASSNAME, (void *)className.c_str(), classNameLength_ );
+}
+
+ClassID::ClassID( uint8_t* data, unsigned int clientID )
+  : Packet(data, clientID)
+{
+  memcpy( (void *)&classNameLength_, &data[ _CLASSNAMELENGTH ], sizeof(classNameLength_) );
+}
+
+ClassID::~ClassID()
+{
+}
+
+unsigned int ClassID::getSize() const{
+  return sizeof(network::packet::ENUM::Type) + 2*sizeof(uint32_t) + classNameLength_;
+}
+
+bool ClassID::process(){
+  COUT(3) << "processing classid: " << getClassID() << " name: " << (const char*)(data_+_CLASSNAME) << std::endl;
+  orxonox::Identifier *id=ClassByID( std::string((const char*)(data_+_CLASSNAME) ));
+  if(id==NULL)
+    return false;
+  id->setNetworkID( getClassID() );
+  delete this;
+  return true;
+}
+
+unsigned int ClassID::getClassID(){
+  return *(uint32_t *)(data_ + _CLASSID);
+}
+
+} //namespace packet
+}//namespace network
Index: /code/branches/physics/src/network/packet/ClassID.h
===================================================================
--- /code/branches/physics/src/network/packet/ClassID.h	(revision 2122)
+++ /code/branches/physics/src/network/packet/ClassID.h	(revision 2122)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKCLASSID_H
+#define NETWORKCLASSID_H
+
+#include "../NetworkPrereqs.h"
+
+#include <string>
+
+#include "Packet.h"
+
+namespace network {
+namespace packet {
+
+/**
+	@author
+*/
+class _NetworkExport ClassID : public Packet
+{
+public:
+  ClassID( unsigned int classID, std::string className );
+  ClassID( uint8_t* data, unsigned int clientID );
+  ~ClassID();
+
+  inline unsigned int getSize() const;
+  bool process();
+
+  unsigned int getClassID();
+  unsigned int getClassNameLength(){ return classNameLength_; }
+  unsigned char *getClassName();
+private:
+  uint32_t classNameLength_;
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/physics/src/network/packet/DeleteObjects.cc
===================================================================
--- /code/branches/physics/src/network/packet/DeleteObjects.cc	(revision 2122)
+++ /code/branches/physics/src/network/packet/DeleteObjects.cc	(revision 2122)
@@ -0,0 +1,97 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "DeleteObjects.h"
+#include <enet/enet.h>
+#include "network/Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include <assert.h>
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAG_DELETE  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID           0
+#define _QUANTITY           _PACKETID + sizeof(ENUM::Type)
+#define _OBJECTIDS          _QUANTITY + sizeof(uint32_t)
+  
+DeleteObjects::DeleteObjects()
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAG_DELETE;
+}
+
+DeleteObjects::DeleteObjects( uint8_t *data, unsigned int clientID )
+  : Packet(data, clientID)
+{
+}
+
+DeleteObjects::~DeleteObjects()
+{
+}
+
+bool DeleteObjects::fetchIDs(){
+  unsigned int number = Synchronisable::getNumberOfDeletedObject();
+  if(number==0)
+    return false;
+  COUT(3) << "sending DeleteObjects: ";
+  unsigned int size = sizeof(ENUM::Type) + sizeof(uint32_t)*(number+1);
+  data_ = new uint8_t[size];
+  uint8_t *tdata = data_;
+  *(ENUM::Type *)(tdata) = ENUM::DeleteObjects;
+  tdata += sizeof(ENUM::Type);
+  *(uint32_t *)tdata = number;
+  tdata += sizeof(uint32_t);
+  for(unsigned int i=0; i<number; i++){
+    unsigned int temp = Synchronisable::popDeletedObject();
+//     assert(temp<10000); //ugly hack
+    *(uint32_t *)(tdata) = temp;
+    COUT(3) << temp << " ";
+    tdata += sizeof(uint32_t);
+  }
+  COUT(3) << std::endl;
+  return true;
+}
+
+unsigned int DeleteObjects::getSize() const{
+  assert(data_);
+  return _OBJECTIDS + *(uint32_t*)(data_+_QUANTITY)*sizeof(uint32_t);
+}
+
+bool DeleteObjects::process(){
+  for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++){
+    COUT(3) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;
+    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
+  }
+  return true;
+}
+
+
+} //namespace packet
+} //namespace network
Index: /code/branches/physics/src/network/packet/DeleteObjects.h
===================================================================
--- /code/branches/physics/src/network/packet/DeleteObjects.h	(revision 2122)
+++ /code/branches/physics/src/network/packet/DeleteObjects.h	(revision 2122)
@@ -0,0 +1,59 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKPACKETDELETEOBJECTS_H
+#define NETWORKPACKETDELETEOBJECTS_H
+
+#include "../NetworkPrereqs.h"
+
+#include "Packet.h"
+
+
+namespace network {
+namespace packet {
+/**
+	@author
+*/
+class _NetworkExport DeleteObjects : public Packet
+{
+public:
+  DeleteObjects( );
+  DeleteObjects( uint8_t* data, unsigned int clientID );
+  ~DeleteObjects();
+
+  bool fetchIDs();
+
+  inline unsigned int getSize() const;
+  bool process();
+
+private:
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/physics/src/network/packet/Gamestate.cc
===================================================================
--- /code/branches/physics/src/network/packet/Gamestate.cc	(revision 2122)
+++ /code/branches/physics/src/network/packet/Gamestate.cc	(revision 2122)
@@ -0,0 +1,603 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Gamestate.h"
+#include "network/ClientInformation.h"
+#include "network/GamestateHandler.h"
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+
+#include <zlib.h>
+#include <assert.h>
+
+
+
+namespace network {
+
+namespace packet {
+
+#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
+#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
+#define HEADER GAMESTATE_HEADER(data_)
+
+
+#define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
+
+Gamestate::Gamestate()
+{
+  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
+}
+
+Gamestate::Gamestate(uint8_t *data, unsigned int clientID):
+    Packet(data, clientID)
+{
+  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
+}
+
+Gamestate::Gamestate(uint8_t *data)
+{
+  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
+  data_=data;
+}
+
+
+Gamestate::~Gamestate()
+{
+}
+
+bool Gamestate::collectData(int id, int mode)
+{
+  int tempsize=0, currentsize=0;
+  assert(data_==0);
+  int size = calcGamestateSize(id, mode);
+
+  COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
+  if(size==0)
+    return false;
+  data_ = new unsigned char[size + sizeof(GamestateHeader)];
+  if(!data_){
+    COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
+    return false;
+  }
+
+#ifndef NDEBUG
+  std::list<Synchronisable*> slist;
+  std::list<Synchronisable*>::iterator iit;
+#endif
+  //start collect data synchronisable by synchronisable
+  uint8_t *mem=data_;
+  mem+=sizeof(GamestateHeader);
+  orxonox::ObjectList<Synchronisable>::iterator it;
+  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
+    tempsize=it->getSize(id, mode);
+
+    if(currentsize+tempsize > size){
+      // start allocate additional memory
+      COUT(3) << "G.St.Man: need additional memory" << std::endl;
+      orxonox::ObjectList<Synchronisable>::iterator temp = it;
+      int addsize=tempsize;
+      while(++temp)
+        addsize+=temp->getSize(id, mode);
+      data_ = (uint8_t *)realloc(data_, sizeof(GamestateHeader) + currentsize + addsize);
+      if(!data_)
+        return false;
+      size = currentsize+addsize;
+    }// stop allocate additional memory
+
+#ifndef NDEBUG
+    for(iit=slist.begin(); iit!=slist.end(); iit++)
+      assert((*iit)!=*it);
+    slist.push_back(*it);
+#endif
+
+    //if(it->doSelection(id))
+    dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
+    if(!it->getData(mem, id, mode))
+      return false; // mem pointer gets automatically increased because of call by reference
+    // increase size counter by size of current synchronisable
+    currentsize+=tempsize;
+  }
+
+
+  //start write gamestate header
+  HEADER->packetType = ENUM::Gamestate;
+  assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);
+  HEADER->datasize = currentsize;
+  HEADER->id = id;
+  HEADER->diffed = false;
+  HEADER->complete = true;
+  HEADER->compressed = false;
+  //stop write gamestate header
+
+  COUT(5) << "G.ST.Man: Gamestate size: " << currentsize << std::endl;
+  COUT(5) << "G.ST.Man: 'estimated' (and corrected) Gamestate size: " << size << std::endl;
+  return true;
+}
+
+bool Gamestate::spreadData(int mode)
+{
+  assert(data_);
+  assert(!HEADER->compressed);
+  assert(!HEADER->diffed);
+  uint8_t *mem=data_+sizeof(GamestateHeader);
+    // get the start of the Synchronisable list
+  //orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
+  Synchronisable *s;
+
+  // update the data of the objects we received
+  while(mem < data_+sizeof(GamestateHeader)+HEADER->datasize){
+    synchronisableHeader *objectheader = (synchronisableHeader*)mem;
+
+    s = Synchronisable::getSynchronisable( objectheader->objectID );
+    if(!s)
+    {
+      Synchronisable::fabricate(mem, mode);
+    }
+    else
+    {
+      bool b = s->updateData(mem, mode);
+      assert(b);
+      //if(!s->updateData(mem, mode))
+        //return false;
+    }
+  }
+
+  return true;
+}
+
+
+
+int Gamestate::getID(){
+  return HEADER->id;
+}
+
+unsigned int Gamestate::getSize() const
+{
+  assert(data_);
+  if(HEADER->compressed)
+    return HEADER->compsize+sizeof(GamestateHeader);
+  else
+  {
+    return HEADER->datasize+sizeof(GamestateHeader);
+  }
+}
+
+bool Gamestate::operator==(packet::Gamestate gs){
+  uint8_t *d1 = data_+sizeof(GamestateHeader);
+  uint8_t *d2 = gs.data_+sizeof(GamestateHeader);
+  assert(!isCompressed());
+  assert(!gs.isCompressed());
+  while(d1<data_+HEADER->datasize)
+  {
+    if(*d1!=*d2)
+      return false;
+    d1++;
+    d2++;
+  }
+  return true;
+}
+
+bool Gamestate::process()
+{
+  return GamestateHandler::addGamestate(this, getClientID());
+}
+
+
+
+bool Gamestate::compressData()
+{
+  assert(HEADER);
+  assert(!HEADER->compressed);
+  uLongf buffer = (uLongf)(((HEADER->datasize + 12)*1.01)+1);
+  if(buffer==0)
+    return false;
+
+  uint8_t *ndata = new uint8_t[buffer+sizeof(GamestateHeader)];
+  uint8_t *dest = GAMESTATE_START(ndata);
+  //unsigned char *dest = new unsigned char[buffer];
+  uint8_t *source = GAMESTATE_START(data_);
+  int retval;
+  retval = compress( dest, &buffer, source, (uLong)(HEADER->datasize) );
+  switch ( retval ) {
+    case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
+    case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; return false;
+    case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; return false;
+    case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false;
+  }
+#ifndef NDEBUG
+  //decompress and compare the start and the decompressed data
+  uint8_t *rdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];
+  uint8_t *d2 = GAMESTATE_START(rdata);
+  uLongf length2 = HEADER->datasize;
+  uncompress(d2, &length2, dest, buffer);
+  for(unsigned int i=0; i<HEADER->datasize; i++){
+    assert(*(source+i)==*(d2+i));
+  }
+  delete[] rdata;
+#endif
+
+  //copy and modify header
+#ifndef NDEBUG
+  HEADER->crc32 = calcCRC(data_+sizeof(GamestateHeader), HEADER->datasize);
+#endif
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+  //delete old data
+  delete[] data_;
+  //save new data
+  data_ = ndata;
+  HEADER->compsize = buffer;
+  HEADER->compressed = true;
+  assert(HEADER->compressed);
+  COUT(4) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
+  return true;
+}
+bool Gamestate::decompressData()
+{
+  assert(HEADER);
+  assert(HEADER->compressed);
+  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
+  unsigned int datasize = HEADER->datasize;
+  unsigned int compsize = HEADER->compsize;
+  unsigned int bufsize;
+//  assert(compsize<=datasize);
+  bufsize = datasize;
+  assert(bufsize!=0);
+  uint8_t *ndata = new uint8_t[bufsize + sizeof(GamestateHeader)];
+  uint8_t *dest = ndata + sizeof(GamestateHeader);
+  uint8_t *source = data_ + sizeof(GamestateHeader);
+  int retval;
+  uLongf length=bufsize;
+  retval = uncompress( dest, &length, source, (uLong)compsize );
+  switch ( retval ) {
+    case Z_OK: COUT(5) << "successfully decompressed" << std::endl; break;
+    case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return false;
+    case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return false;
+    case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;
+  }
+#ifndef NDEBUG
+  assert(HEADER->crc32==calcCRC(ndata+sizeof(GamestateHeader), HEADER->datasize));
+#endif
+
+  //copy over the header
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+
+  if (this->bDataENetAllocated_){
+    // Memory was allocated by ENet. --> We let it be since enet_packet_destroy will
+    // deallocated it anyway. So data and packet stay together.
+    this->bDataENetAllocated_ = false;
+  }
+  else{
+    // We allocated the memory in the first place (unlikely). So we destroy the old data
+    // and overwrite it with the new decompressed data.
+    delete[] this->data_;
+  }
+
+  //set new pointers
+  data_ = ndata;
+  HEADER->compressed = false;
+  assert(HEADER->datasize==datasize);
+  assert(HEADER->compsize==compsize);
+  return true;
+}
+
+Gamestate *Gamestate::diff(Gamestate *base)
+{
+  assert(HEADER);
+  assert(!HEADER->compressed);
+  assert(!HEADER->diffed);
+  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
+  uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
+  unsigned int of=0; // pointers offset
+  unsigned int dest_length=0;
+  dest_length=HEADER->datasize;
+  if(dest_length==0)
+    return NULL;
+  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+sizeof(GamestateHeader)];
+  uint8_t *dest = ndata + sizeof(GamestateHeader);
+  while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
+    *(dest+of)=*(basep+of)^*(gs+of); // do the xor
+    ++of;
+  }
+  if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
+    uint8_t n=0;
+    if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
+      while(of<dest_length){
+        *(dest+of)=n^*(gs+of);
+        of++;
+      }
+    }
+  }
+
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+  GAMESTATE_HEADER(ndata)->diffed = true;
+  GAMESTATE_HEADER(ndata)->base_id = base->getID();
+  Gamestate *g = new Gamestate(ndata, getClientID());
+  g->flags_=flags_;
+  g->packetDirection_ = packetDirection_;
+  return g;
+}
+
+Gamestate* Gamestate::doSelection(unsigned int clientID){
+  assert(data_);
+  std::map<unsigned int, Synchronisable *>::iterator it;
+
+  // allocate memory for new data
+  uint8_t *gdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];
+  // create a gamestate out of it
+  Gamestate *gs = new Gamestate(gdata);
+  uint8_t *newdata = gdata + sizeof(GamestateHeader);
+  uint8_t *origdata = GAMESTATE_START(data_);
+
+  //copy the GamestateHeader
+  *(GamestateHeader*)gdata = *HEADER;
+
+  synchronisableHeader *oldobjectheader, *newobjectheader;
+  unsigned int objectOffset;
+
+  //copy in the zeros
+  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
+    oldobjectheader = (synchronisableHeader*)origdata;
+    newobjectheader = (synchronisableHeader*)newdata;
+    unsigned int objectsize = oldobjectheader->size;
+    assert(it->second->objectID==oldobjectheader->objectID);
+    *newobjectheader = *oldobjectheader;
+    objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader
+    if(it->second->doSelection(HEADER->id)){
+      newobjectheader->dataAvailable=true; //TODO: probably not neccessary
+      while(objectOffset<objectsize){
+        *(newdata + objectOffset)=*(origdata + objectOffset);    // copy the data
+        objectOffset++;
+      }
+    }else{
+      newobjectheader->dataAvailable=false;
+      while(objectOffset<objectsize){
+        *(newdata+objectOffset)=0;    // set to 0
+        objectOffset++;
+      }
+      assert(objectOffset==objectsize);
+    }
+    newdata += objectsize;
+    origdata += objectsize;
+  }
+  return gs;
+}
+
+
+Gamestate* Gamestate::intelligentDiff(Gamestate *base, unsigned int clientID){
+  // asserts
+  assert(data_);
+  assert(base->data_);
+  assert(!GAMESTATE_HEADER(base->data_)->diffed);
+  assert(!GAMESTATE_HEADER(base->data_)->compressed);
+  assert(!HEADER->compressed);
+  assert(!HEADER->diffed);
+
+  //preparations
+  std::map<unsigned int, Synchronisable *>::iterator it;
+  uint8_t *origdata, *basedata, *destdata, *ndata;
+  unsigned int objectOffset, streamOffset=0;    //data offset
+  unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
+  synchronisableHeader *origheader;
+  synchronisableHeader *destheader;
+
+  origdata = GAMESTATE_START(this->data_);
+  basedata = GAMESTATE_START(base->data_);
+  ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];
+  destdata = ndata + sizeof(GamestateHeader);
+
+  // do the diff
+  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
+    assert(streamOffset<HEADER->datasize);
+    bool sendData = it->second->doSelection(HEADER->id);
+    origheader = (synchronisableHeader *)(origdata+streamOffset);
+    destheader = (synchronisableHeader *)(destdata+streamOffset);
+
+    //copy and partially diff the object header
+    assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
+    *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
+    *(bool*)(destdata+sizeof(uint32_t)) = sendData;
+    if(sendData){
+      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it)
+      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it)
+    }else{
+      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0;
+      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0;
+    }
+    objectOffset=sizeof(synchronisableHeader);
+    streamOffset+=sizeof(synchronisableHeader);
+
+    //now handle the object data or fill with zeros
+    while(objectOffset<origheader->size ){
+
+      if(sendData && streamOffset<minsize)
+        *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor
+      else if(sendData)
+        *(destdata+objectOffset)=((uint8_t)0)^*(origdata+objectOffset); // xor with 0 (basestream is too short)
+      else
+        *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered
+
+      objectOffset++;
+      streamOffset++;
+    }
+    destdata+=objectOffset;
+    origdata+=objectOffset;
+    basedata+=objectOffset;
+  }
+
+  //copy over the gamestate header and set the diffed flag
+  *(GamestateHeader *)ndata = *HEADER; //copy over the header
+  Gamestate *gs = new Gamestate(ndata);
+  GAMESTATE_HEADER(ndata)->diffed=true;
+  return gs;
+}
+
+Gamestate* Gamestate::intelligentUnDiff(Gamestate *base){
+  // asserts
+  assert(data_);
+  assert(base->data_);
+  assert(!GAMESTATE_HEADER(base->data_)->diffed);
+  assert(!GAMESTATE_HEADER(base->data_)->compressed);
+  assert(!HEADER->compressed);
+  assert(HEADER->diffed);
+
+  //preparations
+  std::map<unsigned int, Synchronisable *>::iterator it;
+  uint8_t *origdata, *basedata, *destdata, *ndata;
+  unsigned int objectOffset, streamOffset=0;    //data offset
+  unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
+  synchronisableHeader *origheader;
+  synchronisableHeader *destheader;
+
+  origdata = GAMESTATE_START(this->data_);
+  basedata = GAMESTATE_START(base->data_);
+  ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];
+  destdata = ndata + sizeof(GamestateHeader);
+
+  // do the undiff
+  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
+    assert(streamOffset<HEADER->datasize);
+    origheader = (synchronisableHeader *)(origdata+streamOffset);
+    destheader = (synchronisableHeader *)(destdata+streamOffset);
+    bool sendData;
+
+    //copy and partially diff the object header
+    assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
+    *(unsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)
+    *(bool*)(destdata+sizeof(unsigned int)) = *(bool*)(origdata+sizeof(unsigned int));
+    sendData = *(bool*)(origdata+sizeof(unsigned int));
+    if(sendData){
+      *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)
+      *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)
+    }else{
+      *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;
+      *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;
+    }
+    objectOffset=sizeof(synchronisableHeader);
+    streamOffset+=sizeof(synchronisableHeader);
+
+    //now handle the object data or fill with zeros
+    while(objectOffset<origheader->size ){
+
+      if(sendData && streamOffset<minsize)
+        *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor
+      else if(sendData)
+        *(destdata+objectOffset)=((unsigned char)0)^*(origdata+objectOffset); // xor with 0 (basestream is too short)
+      else
+        *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered
+
+      objectOffset++;
+      streamOffset++;
+    }
+    destdata+=objectOffset;
+    origdata+=objectOffset;
+    basedata+=objectOffset;
+  }
+
+  //copy over the gamestate header and set the diffed flag
+  *(GamestateHeader *)ndata = *HEADER; //copy over the header
+  Gamestate *gs = new Gamestate(ndata);
+  GAMESTATE_HEADER(ndata)->diffed=false;
+  return gs;
+}
+
+Gamestate *Gamestate::undiff(Gamestate *base)
+{
+  assert(this && base);assert(HEADER);
+  assert(HEADER->diffed);
+  assert(!HEADER->compressed && !GAMESTATE_HEADER(base->data_)->compressed);
+  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
+  uint8_t *basep = GAMESTATE_START(base->data_);
+  uint8_t *gs = GAMESTATE_START(this->data_);
+  unsigned int of=0; // pointers offset
+  unsigned int dest_length=0;
+  dest_length=HEADER->datasize;
+  if(dest_length==0)
+    return NULL;
+  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+sizeof(GamestateHeader)];
+  uint8_t *dest = ndata + sizeof(GamestateHeader);
+  while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
+    *(dest+of)=*(basep+of)^*(gs+of); // do the xor
+    ++of;
+  }
+  if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
+    uint8_t n=0;
+    if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
+      while(of < dest_length){
+        *(dest+of)=n^*(gs+of);
+        of++;
+      }
+    }
+  }
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+  GAMESTATE_HEADER(ndata)->diffed = false;
+  Gamestate *g = new Gamestate(ndata, getClientID());
+  g->flags_=flags_;
+  g->packetDirection_ = packetDirection_;
+  assert(!g->isDiffed());
+  assert(!g->isCompressed());
+  return g;
+}
+
+
+unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)
+{
+  int size=0;
+    // get the start of the Synchronisable list
+  orxonox::ObjectList<Synchronisable>::iterator it;
+    // get total size of gamestate
+  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it)
+    size+=it->getSize(id, mode); // size of the actual data of the synchronisable
+//  size+=sizeof(GamestateHeader);
+  return size;
+}
+
+/**
+ * This function removes a Synchronisable out of the universe
+ * @param it iterator of the list pointing to the object
+ * @return iterator pointing to the next object in the list
+ */
+  void Gamestate::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
+    orxonox::ObjectList<Synchronisable>::iterator temp=it;
+    ++it;
+    delete  *temp;
+  }
+
+  bool Gamestate::isDiffed(){
+    return HEADER->diffed;
+  }
+
+  bool Gamestate::isCompressed(){
+    return HEADER->compressed;
+  }
+
+  int Gamestate::getBaseID(){
+    return HEADER->base_id;
+  }
+}
+
+}
Index: /code/branches/physics/src/network/packet/Gamestate.h
===================================================================
--- /code/branches/physics/src/network/packet/Gamestate.h	(revision 2122)
+++ /code/branches/physics/src/network/packet/Gamestate.h	(revision 2122)
@@ -0,0 +1,101 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef NETWORK_PACKETGAMESTATE_H
+#define NETWORK_PACKETGAMESTATE_H
+
+#include "../NetworkPrereqs.h"
+
+#include "Packet.h"
+#include "network/Synchronisable.h"
+#include <map>
+#ifndef NDEBUG
+#include "util/CRC32.h"
+#endif
+
+namespace network {
+
+namespace packet {
+
+struct _NetworkExport GamestateHeader{
+  ENUM::Type packetType;
+  int32_t id; // id of the gamestate
+  uint32_t compsize;
+  uint32_t datasize;
+  int32_t base_id; // id of the base-gamestate diffed from
+  bool diffed:1; // wheter diffed or not
+  bool complete:1; // wheter it is a complete gamestate or only partial
+  bool compressed:1;
+#ifndef NDEBUG
+  uint32_t crc32;
+#endif
+};
+
+/**
+	@author Oliver Scheuss
+*/
+class _NetworkExport Gamestate: public Packet{
+  public:
+    Gamestate();
+    Gamestate(uint8_t *data, unsigned int clientID);
+    Gamestate(uint8_t *data);
+
+    ~Gamestate();
+
+    bool collectData(int id, int mode=0x0);
+    bool spreadData(int mode=0x0);
+    int getID();
+    bool isDiffed();
+    bool isCompressed();
+    int getBaseID();
+    Gamestate *diff(Gamestate *base);
+    Gamestate* intelligentDiff(Gamestate *base, unsigned int clientID);
+    Gamestate *undiff(Gamestate *base);
+    Gamestate* intelligentUnDiff(Gamestate *base);
+    Gamestate* doSelection(unsigned int clientID);
+    bool compressData();
+    bool decompressData();
+
+    // Packet functions
+  private:
+    virtual unsigned int getSize() const;
+    virtual bool process();
+
+    bool operator ==(packet::Gamestate gs);
+  private:
+    unsigned int calcGamestateSize(unsigned int id, int mode=0x0);
+    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
+    std::map<unsigned int, Synchronisable*> dataMap_;
+};
+
+}
+
+}
+
+#endif
Index: /code/branches/physics/src/network/packet/Packet.cc
===================================================================
--- /code/branches/physics/src/network/packet/Packet.cc	(revision 2122)
+++ /code/branches/physics/src/network/packet/Packet.cc	(revision 2122)
@@ -0,0 +1,222 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "Packet.h"
+
+#include <cassert>
+#include <enet/enet.h>
+#include <boost/bind.hpp>
+
+#include "network/ConnectionManager.h"
+#include "network/ClientInformation.h"
+
+#include "Acknowledgement.h"
+#include "Chat.h"
+#include "ClassID.h"
+#include "Gamestate.h"
+#include "Welcome.h"
+#include "DeleteObjects.h"
+#include "network/Host.h"
+#include "core/CoreIncludes.h"
+
+namespace network{
+
+namespace packet{
+
+#define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE
+#define _PACKETID           0
+
+std::map<ENetPacket *, Packet *> Packet::packetMap_;
+
+Packet::Packet(){
+  flags_ = PACKET_FLAG_DEFAULT;
+  packetDirection_ = ENUM::Outgoing;
+  clientID_=0;
+  data_=0;
+  enetPacket_=0;
+  bDataENetAllocated_ = false;
+}
+
+void blub(ENetPacket *packet){
+  COUT(4) << "blubb" << std::endl;
+}
+
+Packet::Packet(uint8_t *data, unsigned int clientID){
+  flags_ = PACKET_FLAG_DEFAULT;
+  packetDirection_ = ENUM::Incoming;
+  clientID_=clientID;
+  data_=data;
+  enetPacket_=0;
+  bDataENetAllocated_ = false;
+}
+
+
+Packet::Packet(const Packet &p){
+  enetPacket_=p.enetPacket_;
+  flags_=p.flags_;
+  packetDirection_ = p.packetDirection_;
+  clientID_ = p.clientID_;
+  if(p.data_){
+    data_ = new uint8_t[p.getSize()];
+    memcpy(data_, p.data_, p.getSize());
+  }else
+    data_=0;
+  bDataENetAllocated_ = p.bDataENetAllocated_;
+}
+
+/**
+@brief
+    Destroys a packet completely.
+    
+    That also means destroying the ENetPacket if one exists. There 
+*/
+Packet::~Packet(){
+  // Deallocate data_ memory if necessary.
+  if (this->bDataENetAllocated_){
+    // In this case ENet allocated data_ and will destroy it.
+  }
+  else if (this->data_) {
+    // This destructor was probably called as a consequence to ENet executing our callback.
+    // It simply serves us to be able to deallocate the packet content (data_) ourselves since
+    // we have created it in the first place.
+    delete[] this->data_;
+  }
+
+  // Destroy the ENetPacket if necessary.
+  // Note: For the case ENet used the callback to destroy the packet, we have already set
+  // enetPacket_ to NULL to avoid destroying it again.
+  if (this->enetPacket_){
+    // enetPacket_->data gets destroyed too by ENet if it was allocated by it.
+    enet_packet_destroy(enetPacket_);
+  }
+}
+
+bool Packet::send(){
+  if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){
+    assert(0);
+    return false;
+  }
+  if(!enetPacket_){
+    if(!data_){
+      assert(0);
+      return false;
+    }
+    // We deliver ENet the data address so that it doesn't memcpy everything again.
+    // --> We have to delete data_ ourselves!
+    enetPacket_ = enet_packet_create(getData(), getSize(), getFlags());
+    enetPacket_->freeCallback = &Packet::deletePacket;
+    // Add the packet to a global list so we can access it again once enet calls our
+    // deletePacket method. We can of course only give a one argument function to the ENet C library.
+    packetMap_[enetPacket_] = this;
+  }
+#ifndef NDEBUG
+  switch( *(ENUM::Type *)(data_ + _PACKETID) )
+  {
+    case ENUM::Acknowledgement:
+    case ENUM::Chat:
+    case ENUM::ClassID:
+    case ENUM::Gamestate:
+    case ENUM::Welcome:
+    case ENUM::DeleteObjects:
+      break;
+    default:
+      assert(0); //there was some error, if this is the case
+      break;
+  }
+#endif
+//  ENetPacket *temp = enetPacket_;
+//  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
+  network::Host::addPacket( enetPacket_, clientID_);
+  return true;
+}
+
+Packet *Packet::createPacket(ENetPacket *packet, ENetPeer *peer){
+  uint8_t *data = packet->data;
+  assert(ClientInformation::findClient(&peer->address)->getID() != (unsigned int)-2 || !Host::isServer());
+  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
+  Packet *p;
+  COUT(5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
+  switch( *(ENUM::Type *)(data + _PACKETID) )
+  {
+    case ENUM::Acknowledgement:
+      COUT(4) << "ack" << std::endl;
+      p = new Acknowledgement( data, clientID );
+      break;
+    case ENUM::Chat:
+      COUT(4) << "chat" << std::endl;
+      p = new Chat( data, clientID );
+      break;
+    case ENUM::ClassID:
+      COUT(4) << "classid" << std::endl;
+      p = new ClassID( data, clientID );
+      break;
+    case ENUM::Gamestate:
+      COUT(4) << "gamestate" << std::endl;
+      // TODO: remove brackets
+      p = new Gamestate( data, clientID );
+      break;
+    case ENUM::Welcome:
+      COUT(4) << "welcome" << std::endl;
+      p = new Welcome( data, clientID );
+      break;
+    case ENUM::DeleteObjects:
+      COUT(4) << "deleteobjects" << std::endl;
+      p = new DeleteObjects( data, clientID );
+      break;
+    default:
+      assert(0); //TODO: repair this
+      break;
+  }
+
+  // Data was created by ENet
+  p->bDataENetAllocated_ = true;
+
+  return p;
+}
+
+/**
+@brief
+    ENet calls this method whenever it wants to destroy a packet that contains
+    data we allocated ourselves.
+*/
+void Packet::deletePacket(ENetPacket *enetPacket){
+  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
+  std::map<ENetPacket*, Packet*>::iterator it = packetMap_.find(enetPacket);
+  assert(it != packetMap_.end());
+  // Make sure we don't delete it again in the destructor
+  it->second->enetPacket_ = 0;
+  delete it->second;
+  //packetMap_.erase(it);
+  COUT(4) << "PacketMap size: " << packetMap_.size() << std::endl;
+}
+
+} // namespace packet
+
+} // namespace network
+
Index: /code/branches/physics/src/network/packet/Packet.h
===================================================================
--- /code/branches/physics/src/network/packet/Packet.h	(revision 2122)
+++ /code/branches/physics/src/network/packet/Packet.h	(revision 2122)
@@ -0,0 +1,102 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKPACKET_H
+#define NETWORKPACKET_H
+
+#include "../NetworkPrereqs.h"
+
+#include <map>
+#include <enet/enet.h>
+
+#include "util/Integers.h"
+
+namespace network {
+
+namespace packet{
+
+namespace ENUM{
+  enum Direction{
+    Incoming,
+    Outgoing,
+    Bidirectional
+  };
+  enum Type{
+    Acknowledgement,
+    Gamestate,
+    ClassID,
+    Chat,
+    Welcome,
+    DeleteObjects
+  };
+}
+
+/**
+	@author Oliver Scheuss <scheusso [at] ee.ethz.ch>
+*/
+class _NetworkExport Packet{
+  public:
+    Packet(const Packet &p);
+    virtual ~Packet();
+    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
+    static void deletePacket(ENetPacket *packet);
+
+    virtual unsigned char *getData(){ return data_; };
+    virtual unsigned int getSize() const =0;
+    virtual bool process()=0;
+    enet_uint32 getFlags()
+      { return flags_; }
+    int getClientID()
+      { return clientID_; }
+    void setClientID( int id )
+      { clientID_ = id; }
+
+    bool send();
+  protected:
+    Packet();
+    Packet(uint8_t *data, unsigned int clientID);
+//    Packet(ENetPacket *packet, ENetPeer *peer);
+    enet_uint32 flags_;
+    unsigned int clientID_;
+    ENUM::Direction packetDirection_;
+    /** Pointer to the data. Be careful when deleting it because it might
+        point to a location that was allocated by ENet.
+        See bDataENetAllocated_ */
+    uint8_t *data_;
+    /** Tells whether data_ was allocated by ENet or ourselves.
+        data_ might no correlate with enetPacket_->data. */
+    bool bDataENetAllocated_;
+  private:
+    static std::map<ENetPacket *, Packet *> packetMap_;
+    ENetPacket *enetPacket_;
+};
+
+} //namespace packet
+
+} //namespace network
+
+#endif
Index: /code/branches/physics/src/network/packet/Welcome.cc
===================================================================
--- /code/branches/physics/src/network/packet/Welcome.cc	(revision 2122)
+++ /code/branches/physics/src/network/packet/Welcome.cc	(revision 2122)
@@ -0,0 +1,89 @@
+
+
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "Welcome.h"
+#include "network/Host.h"
+#include "network/Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include <assert.h>
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID             0
+#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
+#define _SHIPID               _CLIENTID + sizeof(uint32_t)
+  
+  Welcome::Welcome( unsigned int clientID, unsigned int shipID )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_CLASSID;
+  assert(getSize());
+  data_=new uint8_t[ getSize() ];
+  assert(data_);
+  *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
+  *(uint32_t *)&data_[ _CLIENTID ] = clientID;
+  *(uint32_t *)&data_[ _SHIPID ] = shipID;
+}
+
+Welcome::Welcome( uint8_t* data, unsigned int clientID )
+  : Packet(data, clientID)
+{
+}
+
+Welcome::~Welcome()
+{
+}
+
+uint8_t *Welcome::getData(){
+  return data_;
+}
+
+unsigned int Welcome::getSize() const{
+  return sizeof(network::packet::ENUM::Type) + 2*sizeof(uint32_t);
+}
+
+bool Welcome::process(){
+  unsigned int shipID, clientID;
+  clientID = *(uint32_t *)&data_[ _CLIENTID ];
+  shipID = *(uint32_t *)&data_[ _SHIPID ];
+  Host::setClientID(clientID);
+  Host::setShipID(shipID);
+  COUT(3) << "Welcome set clientId: " << clientID << " shipID: " << shipID << std::endl;
+  Synchronisable::setClient(true);
+  delete this;
+  return true;
+}
+
+
+} //namespace packet
+}//namespace network
Index: /code/branches/physics/src/network/packet/Welcome.h
===================================================================
--- /code/branches/physics/src/network/packet/Welcome.h	(revision 2122)
+++ /code/branches/physics/src/network/packet/Welcome.h	(revision 2122)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKWELCOME_H
+#define NETWORKWELCOME_H
+
+#include "../NetworkPrereqs.h"
+
+#include "Packet.h"
+
+namespace network {
+namespace packet {
+
+/**
+	@author
+*/
+class _NetworkExport Welcome : public Packet
+{
+public:
+  Welcome( unsigned int clientID, unsigned int shipID );
+  Welcome( uint8_t* data, unsigned int clientID );
+  virtual ~Welcome();
+
+  uint8_t *getData();
+  inline unsigned int getSize() const;
+  bool process();
+
+private:
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/physics/src/ogrebullet/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/ogrebullet/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,2 @@
+ADD_SUBDIRECTORY(Collisions)
+ADD_SUBDIRECTORY(Dynamics)
Index: /code/branches/physics/src/ogrebullet/Collisions/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,30 @@
+SET( OGREBULLET_COLLISIONS_SRC_FILES
+  OgreBulletCollisionsObject.cpp
+  OgreBulletCollisionsObjectState.cpp
+  OgreBulletCollisionsRay.cpp
+  OgreBulletCollisionsShape.cpp
+  OgreBulletCollisionsWorld.cpp
+  
+  Debug/OgreBulletCollisionsDebugContact.cpp
+  Debug/OgreBulletCollisionsDebugDrawer.cpp
+  Debug/OgreBulletCollisionsDebugLines.cpp
+  Debug/OgreBulletCollisionsDebugShape.cpp
+  
+  Shapes/OgreBulletCollisionsBoxShape.cpp
+  Shapes/OgreBulletCollisionsCapsuleShape.cpp
+  Shapes/OgreBulletCollisionsCompoundShape.cpp
+  Shapes/OgreBulletCollisionsConeShape.cpp
+  Shapes/OgreBulletCollisionsConvexHullShape.cpp
+  Shapes/OgreBulletCollisionsCylinderShape.cpp
+  Shapes/OgreBulletCollisionsGImpactShape.cpp
+  Shapes/OgreBulletCollisionsMinkowskiSumShape.cpp
+  Shapes/OgreBulletCollisionsMultiSphereShape.cpp
+  Shapes/OgreBulletCollisionsSphereShape.cpp
+  Shapes/OgreBulletCollisionsStaticPlaneShape.cpp
+  Shapes/OgreBulletCollisionsTriangleShape.cpp
+  Shapes/OgreBulletCollisionsTrimeshShape.cpp
+  
+  Utils/OgreBulletCollisionsMeshToShapeConverter.cpp
+)
+
+ADD_LIBRARY(ogrebullet_collisions_orxonox STATIC ${OGREBULLET_COLLISIONS_SRC_FILES})
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp	(revision 2122)
@@ -0,0 +1,650 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+
+#include "OgreBulletCollisions.h"
+
+#include "Ogre.h"
+#include "OgreFontManager.h"
+
+#include "Debug/OgreBulletCollisionsDebugContact.h"
+#include "OgreBulletCollisionsShape.h"
+#include "OgreBulletCollisionsObject.h"
+#include "OgreBulletCollisionsWorld.h"
+
+using namespace Ogre;
+
+#define POS_TEX_BINDING    0
+#define COLOUR_BINDING     1
+
+namespace OgreBulletCollisions
+{
+    //------------------------------------------------------------------------------------------------
+    DebugContact::DebugContact(const String &name, CollisionsWorld *world) : 
+        _name(name), 
+        _world(world),
+        _enabled(false)
+    {
+        // scene node 
+        _node = _world->getSceneManager()->getRootSceneNode ()->createChildSceneNode ();
+
+        // sphere attach to contact point
+        _point = _world->getSceneManager()->createEntity(name + String("_debug_point"), "sphere.mesh");
+        _point_node = _node->createChildSceneNode ();
+        _point_node->attachObject (_point);
+        _point_node->setScale(0.001, 0.001, 0.001);
+
+        // normal direction debug
+         _normal = new DebugNormal();
+         _node->attachObject (_normal);
+
+         // text info on contact
+        _text = new DebugContactText(name + String("_debug_text"), _node->createChildSceneNode ());
+        _text->setPosition (Vector3(0,5,0));
+        _text->setCaption ("-");
+        _text->setVisible (false);
+
+        _node->setVisible (false);
+    }
+     //------------------------------------------------------------------------------------------------
+    DebugContact::~DebugContact()
+    {
+        delete _text;
+
+        _point_node->detachObject (_point->getName ());
+        _node->detachObject (_normal->getName ());
+
+        _world->getSceneManager()->destroyEntity (_point->getName ());
+
+        _node->detachAllObjects ();
+        _node->removeAndDestroyAllChildren ();
+
+        delete _normal;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContact::update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth)
+    {
+        _node->setPosition (pt);
+
+        _point_node->setPosition (depth * normal);
+
+        //String contactLabel("p: ");
+        //contactLabel = contactLabel + StringConverter::toString(contact->getPosition());
+        //contactLabel = contactLabel + ", n: ";
+        //contactLabel = contactLabel + StringConverter::toString(contact->getNormal());
+        //_text->setCaption (contactLabel);
+        //_text->setVisible (false);
+
+        //_text->setPosition (contact->getPosition () + Vector3(0,5,0));
+        
+        _normal->update (normal, pt, depth);
+    }
+    //------------------------------------------------------------------------------------------------
+    bool DebugContact::isEnabled () const 
+    {
+        return _enabled;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContact::setEnabled (bool enable)
+    {
+        _enabled = enable;
+        _node->setVisible (_enabled);
+    };
+    //------------------------------------------------------------------------------------------------
+    void DebugNormal::update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth)
+    {
+       DebugLines::clear ();
+       // set normal following contact normal
+       //contact->_normal 
+       //contact->_position
+       DebugLines::addLine (Vector3::ZERO, 
+                            5*normal);
+        DebugLines::draw ();
+    }
+    //------------------------------------------------------------------------------------------------
+    DebugContactText::DebugContactText(const String &name, 
+                                SceneNode *node,
+                                const String &caption, 
+                                const String &fontName, 
+                                int charHeight, 
+                                const ColourValue &color)
+        : mpCam(NULL)
+        , mpWin(NULL)
+        , mpFont(NULL)
+        , mName(name)
+        , mCaption(caption)
+        , mFontName(fontName)
+        , mCharHeight(charHeight)
+        , mColor(color)
+        , mType("DebugContact")
+        , mTimeUntilNextToggle(0)
+        , mSpaceWidth(0)
+        , mUpdateColors(true)
+        , mOnTop(false)
+        , mHorizontalAlignment(H_LEFT)
+        , mVerticalAlignment(V_BELOW)
+        , mAdditionalHeight(0.0)
+        , mNode(node)
+
+    {
+        if (name.empty())
+            Exception(Exception::ERR_INVALIDPARAMS, "Trying to create DebugContact without name", "DebugContact::DebugContact");
+// 
+//         if (caption.empty())
+//            Exception(Exception::ERR_INVALIDPARAMS, "Trying to create DebugContact without caption", "DebugContact::DebugContact");
+
+        mRenderOp.vertexData = NULL;
+        this->setFontName(mFontName);
+        //this->_setupGeometry();
+        mNode->attachObject(this);
+    }
+    //------------------------------------------------------------------------------------------------
+    DebugContactText::~DebugContactText()
+    {
+        mNode->detachObject(this->getName());
+        if (mRenderOp.vertexData)
+            delete mRenderOp.vertexData;
+    }
+#if (OGRE_VERSION >=  ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0)
+	void DebugContactText::visitRenderables(Renderable::Visitor* visitor, 
+		bool debugRenderables)
+	{
+		visitor->visit(this, 0, false);
+	}
+#endif
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setPosition(const Vector3 &pos)
+    {
+        mNode->setPosition (pos);
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setFontName(const String &fontName)
+    {
+        if((Ogre::MaterialManager::getSingletonPtr()->resourceExists(mName + "Material"))) 
+        { 
+            Ogre::MaterialManager::getSingleton().remove(mName + "Material"); 
+        }
+
+        if (mFontName != fontName || mpMaterial.isNull() || !mpFont)
+        {
+            mFontName = fontName;
+            mpFont = (Font *)FontManager::getSingleton().getByName(mFontName).getPointer();
+            if (!mpFont)
+                Exception(Exception::ERR_ITEM_NOT_FOUND, "Could not find font " + fontName, "DebugContact::setFontName");
+
+            mpFont->load();
+            if (!mpMaterial.isNull())
+            {
+                MaterialManager::getSingletonPtr()->remove(mpMaterial->getName());
+                mpMaterial.setNull();
+            }
+
+            mpMaterial = mpFont->getMaterial()->clone(mName + "Material");
+            if (!mpMaterial->isLoaded())
+                mpMaterial->load();
+
+            mpMaterial->setDepthCheckEnabled(!mOnTop);
+            //mpMaterial->setDepthBias(!mOnTop);
+            mpMaterial->setDepthBias(0,!mOnTop);
+            mpMaterial->setDepthWriteEnabled(mOnTop);
+            mpMaterial->setLightingEnabled(false);
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setCaption(const String &caption)
+    {
+        if (caption != mCaption)
+        {
+            mCaption = caption;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setColor(const ColourValue &color)
+    {
+        if (color != mColor)
+        {
+            mColor = color;
+            mUpdateColors = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setCharacterHeight(unsigned int height)
+    {
+        if (height != mCharHeight)
+        {
+            mCharHeight = height;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setSpaceWidth(unsigned int width)
+    {
+        if (width != mSpaceWidth)
+        {
+            mSpaceWidth = width;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setTextAlignment(const HorizontalAlignment& horizontalAlignment, const VerticalAlignment& verticalAlignment)
+    {
+        if(mHorizontalAlignment != horizontalAlignment)
+        {
+            mHorizontalAlignment = horizontalAlignment;
+            mNeedUpdate = true;
+        }
+        if(mVerticalAlignment != verticalAlignment)
+        {
+            mVerticalAlignment = verticalAlignment;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setAdditionalHeight( Real height )
+    {
+        if( mAdditionalHeight != height )
+        {
+            mAdditionalHeight = height;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::showOnTop(bool show)
+    {
+        if( mOnTop != show && !mpMaterial.isNull() )
+        {
+            mOnTop = show;
+            mpMaterial->setDepthBias(0,!mOnTop);
+            mpMaterial->setDepthCheckEnabled(!mOnTop);
+            mpMaterial->setDepthWriteEnabled(mOnTop);
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_setupGeometry()
+    {
+        assert(mpFont);
+        assert(!mpMaterial.isNull());
+
+        unsigned int vertexCount = static_cast<unsigned int>(mCaption.size() * 6);
+
+        if (mRenderOp.vertexData)
+        {
+            // Removed this test as it causes problems when replacing a caption
+            // of the same size: replacing "Hello" with "hello"
+            // as well as when changing the text alignment
+            //if (mRenderOp.vertexData->vertexCount != vertexCount)
+            {
+                delete mRenderOp.vertexData;
+                mRenderOp.vertexData = NULL;
+                mUpdateColors = true;
+            }
+        }
+
+        if (!mRenderOp.vertexData)
+            mRenderOp.vertexData = new VertexData();
+
+        mRenderOp.indexData = 0;
+        mRenderOp.vertexData->vertexStart = 0;
+        mRenderOp.vertexData->vertexCount = vertexCount;
+        mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST; 
+        mRenderOp.useIndexes = false; 
+
+        VertexDeclaration  *decl = mRenderOp.vertexData->vertexDeclaration;
+        VertexBufferBinding   *bind = mRenderOp.vertexData->vertexBufferBinding;
+        size_t offset = 0;
+
+        // create/bind positions/tex.ccord. buffer
+        if (!decl->findElementBySemantic(VES_POSITION))
+            decl->addElement(POS_TEX_BINDING, offset, VET_FLOAT3, VES_POSITION);
+
+        offset += VertexElement::getTypeSize(VET_FLOAT3);
+
+        if (!decl->findElementBySemantic(VES_TEXTURE_COORDINATES))
+            decl->addElement(POS_TEX_BINDING, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
+
+        HardwareVertexBufferSharedPtr ptbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(POS_TEX_BINDING),
+            mRenderOp.vertexData->vertexCount,
+            HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
+        bind->setBinding(POS_TEX_BINDING, ptbuf);
+
+        // Colours - store these in a separate buffer because they change less often
+        if (!decl->findElementBySemantic(VES_DIFFUSE))
+            decl->addElement(COLOUR_BINDING, 0, VET_COLOUR, VES_DIFFUSE);
+
+        HardwareVertexBufferSharedPtr cbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(COLOUR_BINDING),
+            mRenderOp.vertexData->vertexCount,
+            HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
+        bind->setBinding(COLOUR_BINDING, cbuf);
+
+        size_t charlen = mCaption.size();
+        Real *pPCBuff = static_cast<Real*>(ptbuf->lock(HardwareBuffer::HBL_DISCARD));
+
+        float largestWidth = 0;
+        float left = 0 * 2.0 - 1.0;
+        float top = -((0 * 2.0) - 1.0);
+
+        // Derive space width from a capital A
+        if (mSpaceWidth == 0)
+            mSpaceWidth = mpFont->getGlyphAspectRatio('A') * mCharHeight * 2.0;
+
+        // for calculation of AABB
+        Ogre::Vector3 min, max, currPos;
+        Ogre::Real maxSquaredRadius;
+        bool first = true;
+
+        // Use iterator
+        String::iterator i, iend;
+        iend = mCaption.end();
+        bool newLine = true;
+        Real len = 0.0f;
+
+        if(mVerticalAlignment == DebugContactText::V_ABOVE)
+        {
+            // Raise the first line of the caption
+            top += mCharHeight;
+            for (i = mCaption.begin(); i != iend; ++i)
+            {
+                if (*i == '\n')
+                    top += mCharHeight * 2.0;
+            }
+        }
+
+        for (i = mCaption.begin(); i != iend; ++i)
+        {
+            if (newLine)
+            {
+                len = 0.0f;
+                for (String::iterator j = i; j != iend && *j != '\n'; j++)
+                {
+                    if (*j == ' ')
+                        len += mSpaceWidth;
+                    else 
+                        len += mpFont->getGlyphAspectRatio(*j) * mCharHeight * 2.0;
+                }
+                newLine = false;
+            }
+
+            if (*i == '\n')
+            {
+                left = 0 * 2.0 - 1.0;
+                top -= mCharHeight * 2.0;
+                newLine = true;
+                continue;
+            }
+
+            if (*i == ' ')
+            {
+                // Just leave a gap, no tris
+                left += mSpaceWidth;
+                // Also reduce tri count
+                mRenderOp.vertexData->vertexCount -= 6;
+                continue;
+            }
+
+            Real horiz_height = mpFont->getGlyphAspectRatio(*i);
+            
+            //mpFont->getGlyphTexCoords(*i, u1, v1, u2, v2);
+            const Font::UVRect &uvRect = mpFont->getGlyphTexCoords(*i);
+            const Real u1 = uvRect.left; 
+            const Real u2 = uvRect.right; 
+            const Real v1 = uvRect.top; 
+            const Real v2 = uvRect.bottom; 
+
+            // each vert is (x, y, z, u, v)
+            //-------------------------------------------------------------------------------------
+            // First tri
+            //
+            // Upper left
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u1;
+            *pPCBuff++ = v1;
+
+            // Deal with bounds
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                currPos = Ogre::Vector3(left, top, -1.0);
+            else
+                currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
+            if (first)
+            {
+                min = max = currPos;
+                maxSquaredRadius = currPos.squaredLength();
+                first = false;
+            }
+            else
+            {
+                min.makeFloor(currPos);
+                max.makeCeil(currPos);
+                maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+            }
+
+            top -= mCharHeight * 2.0;
+
+            // Bottom left
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u1;
+            *pPCBuff++ = v2;
+
+            // Deal with bounds
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                currPos = Ogre::Vector3(left, top, -1.0);
+            else
+                currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            top += mCharHeight * 2.0;
+            left += horiz_height * mCharHeight * 2.0;
+
+            // Top right
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u2;
+            *pPCBuff++ = v1;
+            //-------------------------------------------------------------------------------------
+
+            // Deal with bounds
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                currPos = Ogre::Vector3(left, top, -1.0);
+            else
+                currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            //-------------------------------------------------------------------------------------
+            // Second tri
+            //
+            // Top right (again)
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u2;
+            *pPCBuff++ = v1;
+
+            currPos = Ogre::Vector3(left, top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            top -= mCharHeight * 2.0;
+            left -= horiz_height  * mCharHeight * 2.0;
+
+            // Bottom left (again)
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u1;
+            *pPCBuff++ = v2;
+
+            currPos = Ogre::Vector3(left, top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            left += horiz_height  * mCharHeight * 2.0;
+
+            // Bottom right
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u2;
+            *pPCBuff++ = v2;
+            //-------------------------------------------------------------------------------------
+
+            currPos = Ogre::Vector3(left, top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            // Go back up with top
+            top += mCharHeight * 2.0;
+
+            float currentWidth = (left + 1)/2 - 0;
+            if (currentWidth > largestWidth)
+                largestWidth = currentWidth;
+        }
+
+        // Unlock vertex buffer
+        ptbuf->unlock();
+
+        // update AABB/Sphere radius
+        mAABB = Ogre::AxisAlignedBox(min, max);
+        mRadius = Ogre::Math::Sqrt(maxSquaredRadius);
+
+        if (mUpdateColors)
+            this->_updateColors();
+
+        mNeedUpdate = false;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_updateColors(void)
+    {
+        assert(mpFont);
+        assert(!mpMaterial.isNull());
+
+        // Convert to system-specific
+        RGBA color;
+        Root::getSingleton().convertColourValue(mColor, &color);
+        HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(COLOUR_BINDING);
+        RGBA *pDest = static_cast<RGBA*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
+        for (unsigned int i = 0; i < mRenderOp.vertexData->vertexCount; ++i)
+            *pDest++ = color;
+        vbuf->unlock();
+        mUpdateColors = false;
+    }
+    //------------------------------------------------------------------------------------------------
+    const Quaternion& DebugContactText::getWorldOrientation(void) const
+    {
+        assert(mpCam);
+        return const_cast<Quaternion&>(mpCam->getDerivedOrientation());
+    }
+    //------------------------------------------------------------------------------------------------
+    const Vector3& DebugContactText::getWorldPosition(void) const
+    {
+        assert(mParentNode);
+        return mParentNode->_getDerivedPosition();
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::getWorldTransforms(Matrix4 *xform) const 
+    {
+        if (this->isVisible() && mpCam)
+        {
+            Matrix3 rot3x3, scale3x3 = Matrix3::IDENTITY;
+
+            // store rotation in a matrix
+            mpCam->getDerivedOrientation().ToRotationMatrix(rot3x3);
+
+            // parent node position
+            Vector3 ppos = mParentNode->_getDerivedPosition() + Vector3::UNIT_Y*mAdditionalHeight;
+
+            // apply scale
+            scale3x3[0][0] = mParentNode->_getDerivedScale().x / 2;
+            scale3x3[1][1] = mParentNode->_getDerivedScale().y / 2;
+            scale3x3[2][2] = mParentNode->_getDerivedScale().z / 2;
+
+            // apply all transforms to xform       
+            *xform = (rot3x3 * scale3x3);
+            xform->setTrans(ppos);
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::getRenderOperation(RenderOperation &op)
+    {
+        if (this->isVisible())
+        {
+            if (mNeedUpdate)
+                this->_setupGeometry();
+            if (mUpdateColors)
+                this->_updateColors();
+            op = mRenderOp;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_notifyCurrentCamera(Camera *cam)
+    {
+        mpCam = cam;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_updateRenderQueue(RenderQueue* queue)
+    {
+        if (this->isVisible())
+        {
+            if (mNeedUpdate)
+                this->_setupGeometry();
+            if (mUpdateColors)
+                this->_updateColors();
+
+            queue->addRenderable(this, mRenderQueueID, OGRE_RENDERABLE_DEFAULT_PRIORITY);
+            //      queue->addRenderable(this, mRenderQueueID, RENDER_QUEUE_SKIES_LATE);
+        }
+    }
+}
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h	(revision 2122)
@@ -0,0 +1,177 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+    (Object-oriented Graphics Rendering Engine Bullet Wrapper)
+	For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+	Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef __OgreBulletCollisionsDebugContact_H__
+#define __OgreBulletCollisionsDebugContact_H__
+
+#include "OgreBulletCollisionsPreRequisites.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+
+namespace OgreBulletCollisions 
+{
+    //------------------------------------------------------------------------------------------------
+    class DebugContact
+    {
+    public:
+        DebugContact(const Ogre::String &name, CollisionsWorld *world);
+         ~DebugContact();
+
+         bool isEnabled () const;
+         void setEnabled (bool enable);
+
+         void update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
+
+    private:
+        DebugNormal         *_normal;
+        DebugContactText    *_text;
+        Ogre::Entity        *_point;
+        bool                _enabled;
+        Ogre::String        _name;
+        Ogre::SceneNode     *_node;
+        Ogre::SceneNode     *_point_node;
+        CollisionsWorld               *_world;
+    };
+
+    //------------------------------------------------------------------------------------------------
+    class DebugNormal : public DebugLines
+    {
+    public:
+        DebugNormal() : DebugLines(){};
+        ~DebugNormal(){};
+
+        void update (const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
+    };
+
+    //------------------------------------------------------------------------------------------------
+    class DebugContactText : public Ogre::MovableObject, public Ogre::Renderable
+    {
+    public:
+        enum HorizontalAlignment    {H_LEFT, H_CENTER};
+        enum VerticalAlignment      {V_BELOW, V_ABOVE};
+        /******************************** public methods ******************************/
+    public:
+        DebugContactText(const Ogre::String &name, 
+                         Ogre::SceneNode *node,
+                         const Ogre::String &caption = "", 
+                         const Ogre::String &fontName = "BlueHighway", 
+                         int charHeight = 32, 
+                         const Ogre::ColourValue &color = Ogre::ColourValue::White);
+
+
+         ~DebugContactText();
+
+#if (OGRE_VERSION >=  ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0)
+		void visitRenderables(Renderable::Visitor* visitor, bool debugRenderables);
+#endif
+        // Set settings
+        void    setPosition(const Ogre::Vector3 &pos);
+
+        void    setFontName(const Ogre::String &fontName);
+        void    setCaption(const Ogre::String &caption);
+        void    setColor(const Ogre::ColourValue &color);
+        void    setCharacterHeight(unsigned int height);
+        void    setSpaceWidth(unsigned int width);
+        void    setTextAlignment(const HorizontalAlignment& horizontalAlignment, 
+                                const VerticalAlignment& verticalAlignment);
+        void    setAdditionalHeight( Ogre::Real height );
+        void    showOnTop(bool show=true);
+
+        // Get settings
+        const   Ogre::String          &getFontName() const {return mFontName;}
+        const   Ogre::String          &getCaption() const {return mCaption;}
+        const   Ogre::ColourValue     &getColor() const {return mColor;}
+
+        unsigned int    getCharacterHeight() const {return mCharHeight;}
+        unsigned int    getSpaceWidth() const {return mSpaceWidth;}
+        Ogre::Real                  getAdditionalHeight() const {return mAdditionalHeight;}
+        bool                    getShowOnTop() const {return mOnTop;}
+        Ogre::AxisAlignedBox	        GetAABB(void) { return mAABB; }
+
+        /******************************** protected methods and overload **************/
+    protected:
+
+        // from OgreBulletCollisionsDebugContact, create the object
+        void	_setupGeometry();
+        void	_updateColors();
+
+        // from MovableObject
+        void                            getWorldTransforms(Ogre::Matrix4 *xform) const;
+        Ogre::Real                      getBoundingRadius(void) const {return mRadius;};
+        Ogre::Real                      getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;};
+        const   Ogre::Quaternion        &getWorldOrientation(void) const;
+        const   Ogre::Vector3           &getWorldPosition(void) const;
+        const   Ogre::AxisAlignedBox    &getBoundingBox(void) const {return mAABB;};
+        const   Ogre::String            &getName(void) const {return mName;};
+        const   Ogre::String            &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
+
+        void                            _notifyCurrentCamera(Ogre::Camera *cam);
+        void                            _updateRenderQueue(Ogre::RenderQueue* queue);
+
+        // from renderable
+        void                            getRenderOperation(Ogre::RenderOperation &op);
+        const   Ogre::MaterialPtr       &getMaterial(void) const {assert(!mpMaterial.isNull());return mpMaterial;};
+        const   Ogre::LightList         &getLights(void) const {return mLList;};
+
+        /******************************** OgreBulletCollisionsDebugContact data ****************************/
+  
+
+    protected:
+        Ogre::String			mFontName;
+        Ogre::String			mType;
+        Ogre::String			mName;
+        Ogre::String			mCaption;
+        HorizontalAlignment	    mHorizontalAlignment;
+        VerticalAlignment	    mVerticalAlignment;
+
+        Ogre::ColourValue		mColor;
+        Ogre::RenderOperation	mRenderOp;
+        Ogre::AxisAlignedBox	mAABB;
+        Ogre::LightList		    mLList;
+
+        unsigned int			mCharHeight;
+        unsigned int			mSpaceWidth;
+
+        bool			        mNeedUpdate;
+        bool			        mUpdateColors;
+        bool			        mOnTop;
+
+        Ogre::Real			    mTimeUntilNextToggle;
+        Ogre::Real			    mRadius;
+        Ogre::Real              mAdditionalHeight;
+
+        Ogre::Camera			*mpCam;
+        Ogre::RenderWindow	    *mpWin;
+        Ogre::Font			    *mpFont;
+        Ogre::MaterialPtr		mpMaterial;
+        Ogre::MaterialPtr		mpBackgroundMaterial;
+
+        Ogre::SceneNode         *mNode;
+    };
+}
+
+#endif //__OgreBulletCollisionsDebugContact_H__
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp	(revision 2122)
@@ -0,0 +1,241 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Debug/OgreBulletCollisionsDebugDrawer.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace OgreBulletCollisions;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+DebugDrawer::DebugDrawer() :
+    DebugLines(),
+    btIDebugDraw(),
+    mDebugMode(0)
+{
+}
+//------------------------------------------------------------------------------------------------
+DebugDrawer::~DebugDrawer() 
+{
+}
+//------------------------------------------------------------------------------------------------
+void	DebugDrawer::reportErrorWarning(const char* warningString)
+{
+	Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(warningString);
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawAabb(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_DrawAabb;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_DrawAabb;
+}
+//------------------------------------------------------------------------------------------------
+void	DebugDrawer::draw3dText(const btVector3& location,const char* textString)
+{
+}
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawAabb () const {return (mDebugMode & btIDebugDraw::DBG_DrawAabb) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawWireframe () const {return (mDebugMode & btIDebugDraw::DBG_DrawWireframe) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawFeaturesText () const {return (mDebugMode & btIDebugDraw::DBG_DrawFeaturesText) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawContactPoints () const {return (mDebugMode & btIDebugDraw::DBG_DrawContactPoints) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesNoDeactivation () const {return (mDebugMode & btIDebugDraw::DBG_NoDeactivation) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesNoHelpText () const {return (mDebugMode & btIDebugDraw::DBG_NoHelpText) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawText () const {return (mDebugMode & btIDebugDraw::DBG_DrawText) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesProfileTimings () const {return (mDebugMode & btIDebugDraw::DBG_ProfileTimings) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesEnableSatComparison () const {return (mDebugMode & btIDebugDraw::DBG_EnableSatComparison) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDisableBulletLCP () const {return (mDebugMode & btIDebugDraw::DBG_DisableBulletLCP) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesEnableCCD () const {return (mDebugMode & btIDebugDraw::DBG_EnableCCD) != 0;};
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawWireframe(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_DrawWireframe;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_DrawWireframe;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawFeaturesText(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_DrawFeaturesText;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_DrawFeaturesText;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawContactPoints(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_DrawContactPoints;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_DrawContactPoints;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setNoDeactivation(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_NoDeactivation;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_NoDeactivation;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setNoHelpText(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_NoHelpText;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_NoHelpText;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawText(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_DrawText;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_DrawText;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setProfileTimings(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_ProfileTimings;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_ProfileTimings;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setEnableSatComparison(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_EnableSatComparison;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_EnableSatComparison;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDisableBulletLCP (bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_DisableBulletLCP ;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_DisableBulletLCP ;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setEnableCCD(bool enable)
+{ 
+    if (enable) 
+        mDebugMode |= btIDebugDraw::DBG_EnableCCD;
+    else
+        mDebugMode &= ~btIDebugDraw::DBG_EnableCCD;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawAabb(const btVector3& from,const btVector3& to,const btVector3& color)
+{
+    if (mDebugMode & btIDebugDraw::DBG_DrawAabb)
+    {
+        drawAabb (BtOgreConverter::to(from), BtOgreConverter::to(to), BtOgreConverter::to (color));
+    }
+}
+//------------------------------------------------------------------------------------------------
+void	DebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
+{
+    if (mDebugMode > 0)
+    {
+        drawLine (BtOgreConverter::to(from), BtOgreConverter::to(to), BtOgreConverter::to (color));
+    }
+}
+//------------------------------------------------------------------------------------------------
+void	DebugDrawer::drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,
+                                              btScalar distance,int lifeTime,const btVector3& color)
+{
+    if (mDebugMode & btIDebugDraw::DBG_DrawContactPoints)
+    {
+        //
+    }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawAabb (const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color)
+{
+    if (mDebugMode & btIDebugDraw::DBG_DrawAabb)
+    {
+        Vector3 halfExtents = (to-from)* 0.5f;
+        Vector3 center = (to+from) *0.5f;
+        int i,j;
+
+        Vector3 edgecoord(1.f,1.f,1.f),pa,pb;
+        for (i=0;i<4;i++)
+        {
+            for (j=0;j<3;j++)
+            {
+                pa = Vector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],		
+                    edgecoord[2]*halfExtents[2]);
+                pa+=center;
+
+                int othercoord = j%3;
+                edgecoord[othercoord]*=-1.f;
+                pb = Vector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],	
+                    edgecoord[2]*halfExtents[2]);
+                pb+=center;
+
+                drawLine(pa,pb,color);
+            }
+            edgecoord = Vector3(-1.f,-1.f,-1.f);
+            if (i<3)
+                edgecoord[i]*=-1.f;
+        }
+    }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawLine(const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color)
+{
+    if (mDebugMode > 0)
+    {
+        addLine (from, to);
+    }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawContactPoint(const Ogre::Vector3& PointOnB,const Ogre::Vector3& normalOnB,
+                                   Real distance,int lifeTime,const Ogre::Vector3& color)
+{
+    if (mDebugMode & btIDebugDraw::DBG_DrawContactPoints)
+    {
+
+    }
+    //...
+}
+//------------------------------------------------------------------------------------------------
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h	(revision 2122)
@@ -0,0 +1,91 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OgreBulletCollisions_DebugDrawer_H_
+#define _OgreBulletCollisions_DebugDrawer_H_
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+namespace OgreBulletCollisions
+{
+	//------------------------------------------------------------------------------------------------
+	class  DebugDrawer : public DebugLines, public btIDebugDraw
+	{
+	public:
+        DebugDrawer();
+		virtual ~DebugDrawer();
+
+
+        virtual void	setDebugMode(int mode){mDebugMode = mode;};
+        virtual int		getDebugMode() const { return mDebugMode;};
+
+        virtual void	drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
+        virtual void	drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,
+            btScalar distance,int lifeTime,const btVector3& color);
+
+        void drawAabb(const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color);
+        void drawLine(const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color);
+        void drawContactPoint(const Ogre::Vector3& PointOnB,const Ogre::Vector3& normalOnB,
+            Ogre::Real distance,int lifeTime,const Ogre::Vector3& color);
+
+        void setDrawAabb(bool enable);
+        void setDrawWireframe(bool enable);
+        void setDrawFeaturesText(bool enable);
+        void setDrawContactPoints(bool enable);
+        void setNoDeactivation(bool enable);
+        void setNoHelpText(bool enable);
+        void setDrawText(bool enable);
+        void setProfileTimings(bool enable);
+        void setEnableSatComparison(bool enable);
+        void setDisableBulletLCP (bool enable);
+        void setEnableCCD(bool enable);
+
+        bool doesDrawAabb () const;
+        bool doesDrawWireframe () const;
+        bool doesDrawFeaturesText () const;
+        bool doesDrawContactPoints () const;
+        bool doesNoDeactivation () const;
+        bool doesNoHelpText () const;
+        bool doesDrawText () const;
+        bool doesProfileTimings () const;
+        bool doesEnableSatComparison () const;
+        bool doesDisableBulletLCP () const;
+        bool doesEnableCCD () const;
+
+        void drawAabb(const btVector3& from,const btVector3& to,const btVector3& color);
+
+		// TODO
+		void	draw3dText(const btVector3& location,const char* textString);
+
+		void	reportErrorWarning(const char* warningString);
+	protected:
+        int mDebugMode;
+	};
+}
+
+#endif //_OgreBulletCollisions_DebugDrawer_H_
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp	(revision 2122)
@@ -0,0 +1,162 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace OgreBulletCollisions;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+bool DebugLines::_materials_created = false;
+//------------------------------------------------------------------------------------------------
+DebugLines::DebugLines() : SimpleRenderable()
+{
+    mRenderOp.vertexData = new Ogre::VertexData();
+    _drawn = false;
+
+    if (!_materials_created)
+    {
+        MaterialPtr red = MaterialManager::getSingleton().create("OgreBulletCollisionsDebugLines/Disabled","OgreBulletCollisions");
+        MaterialPtr green = MaterialManager::getSingleton().create("OgreBulletCollisionsDebugLines/Enabled","OgreBulletCollisions");
+        MaterialPtr blue = MaterialManager::getSingleton().create("OgreBulletCollisionsDebugLines/Static","OgreBulletCollisions");
+
+        red->setReceiveShadows(false);
+        red->getTechnique(0)->setLightingEnabled(true);
+        red->getTechnique(0)->getPass(0)->setSelfIllumination(1,0,0);
+
+        green->setReceiveShadows(false);
+        green->getTechnique(0)->setLightingEnabled(true);
+        green->getTechnique(0)->getPass(0)->setSelfIllumination(0,1,0);
+
+        blue->setReceiveShadows(false);
+        blue->getTechnique(0)->setLightingEnabled(true);
+        blue->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
+
+        _materials_created = true;
+    }
+    setCastShadows (false);
+    this->setMaterial("OgreBulletCollisionsDebugLines/Enabled");
+}
+
+
+//------------------------------------------------------------------------------------------------
+void DebugLines::clear()
+{
+    if (_drawn)
+    {
+        _drawn = false;
+        _points.clear();
+        delete mRenderOp.vertexData;
+
+        mRenderOp.vertexData = new Ogre::VertexData();
+    }
+}
+//------------------------------------------------------------------------------------------------
+DebugLines::~DebugLines(void)
+{
+    clear();
+
+    delete mRenderOp.vertexData;
+}
+//------------------------------------------------------------------------------------------------
+void DebugLines::draw()
+{
+    if (_drawn || _points.empty()) 
+        return;
+    else 
+        _drawn = true;
+
+    // Initialization stuff
+    mRenderOp.indexData = 0;
+    mRenderOp.vertexData->vertexCount = _points.size();
+    mRenderOp.vertexData->vertexStart = 0;
+    mRenderOp.operationType = RenderOperation::OT_LINE_LIST;
+    mRenderOp.useIndexes = false;
+
+    Ogre::VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
+    Ogre::VertexBufferBinding *bind = mRenderOp.vertexData->vertexBufferBinding;
+
+    decl->addElement(0, 0, VET_FLOAT3, VES_POSITION);
+
+    HardwareVertexBufferSharedPtr vbuf =
+        HardwareBufferManager::getSingleton().createVertexBuffer(
+        decl->getVertexSize(0),
+        mRenderOp.vertexData->vertexCount,
+        HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+
+    bind->setBinding(0, vbuf);
+
+    // Drawing stuff
+    unsigned int size = (unsigned int)_points.size();
+    Ogre::Vector3 vaabMin = _points[0];
+    Ogre::Vector3 vaabMax = _points[0];
+
+    float *prPos = static_cast<float*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
+
+    for(unsigned int i = 0; i < size; i++)
+    {
+        *prPos++ = _points[i].x;
+        *prPos++ = _points[i].y;
+        *prPos++ = _points[i].z;
+
+        if (_points[i].x < vaabMin.x)
+            vaabMin.x = _points[i].x;
+        if (_points[i].y < vaabMin.y)
+            vaabMin.y = _points[i].y;
+        if (_points[i].z < vaabMin.z)
+            vaabMin.z = _points[i].z;
+
+        if (_points[i].x > vaabMax.x)
+            vaabMax.x = _points[i].x;
+        if (_points[i].y > vaabMax.y)
+            vaabMax.y = _points[i].y;
+        if (_points[i].z > vaabMax.z)
+            vaabMax.z = _points[i].z;
+    }
+
+    vbuf->unlock();
+
+    mBox.setExtents(vaabMin, vaabMax);
+}
+//------------------------------------------------------------------------------------------------
+Real DebugLines::getSquaredViewDepth(const Camera *cam) const
+{
+    Vector3 vMin, vMax, vMid, vDist;
+    vMin = mBox.getMinimum();
+    vMax = mBox.getMaximum();
+    vMid = ((vMin - vMax) * 0.5) + vMin;
+    vDist = cam->getDerivedPosition() - vMid;
+
+    return vDist.squaredLength();
+}
+//------------------------------------------------------------------------------------------------
+Real DebugLines::getBoundingRadius() const
+{
+    return Math::Sqrt(std::max(mBox.getMaximum().squaredLength(), mBox.getMinimum().squaredLength()));
+}
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.h	(revision 2122)
@@ -0,0 +1,82 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OgreBulletCollisions_DEBUGLines_H_
+#define _OgreBulletCollisions_DEBUGLines_H_
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+namespace OgreBulletCollisions
+{
+    //------------------------------------------------------------------------------------------------
+    class  DebugLines:public Ogre::SimpleRenderable
+    {
+    public:
+        DebugLines(void);
+        ~DebugLines(void);
+
+        void addLine (const Ogre::Vector3 &start,const Ogre::Vector3 &end)
+        {
+            clear ();
+
+            _points.push_back (start);
+            _points.push_back (end);
+        }
+
+        void addLine(Ogre::Real start_x, Ogre::Real start_y, Ogre::Real start_z, 
+            Ogre::Real end_x, Ogre::Real end_y, Ogre::Real end_z)
+        {
+            addLine (Ogre::Vector3(start_x,start_y,start_z),
+                Ogre::Vector3(end_x,end_y,end_z));
+        }
+
+        void addPoint (const Ogre::Vector3 &pt)
+        {
+            clear();
+
+            _points.push_back(pt);
+        }
+
+        void addPoint (Ogre::Real x, Ogre::Real y, Ogre::Real z)
+        {
+            addPoint (Ogre::Vector3(x, y, z));
+        }
+
+        void draw ();
+        void clear ();
+
+        Ogre::Real getSquaredViewDepth (const Ogre::Camera *cam) const;
+        Ogre::Real getBoundingRadius (void) const;
+
+    protected:
+
+        Vector3Array _points;
+        bool _drawn;
+
+        static bool _materials_created;
+    };
+}
+#endif //_OgreBulletCollisions_DEBUGLines_H_
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.cpp	(revision 2122)
@@ -0,0 +1,110 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "OgreBulletCollisionsShape.h"
+#include "Debug/OgreBulletCollisionsDebugShape.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace OgreBulletCollisions;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+DebugCollisionShape::DebugCollisionShape(CollisionShape *shape, DebugCollisionShape::Mode mode) 
+{
+    setStatemode(mode);
+    // try to draw debug wire frame of the shape
+    mIsVisual = shape->drawWireFrame (this);
+
+    // if no success (not possible or not implemented
+    // does not draw, hence saving a segfault
+    if (mIsVisual)
+        DebugLines::draw ();
+}
+//------------------------------------------------------------------------------------------------
+void DebugCollisionShape::setStatemode(DebugCollisionShape::Mode mode)
+{
+	if (mode != mStatemode)
+	{
+		mStatemode = mode;
+		switch(mStatemode)
+		{
+			case DebugCollisionShape::Mode_Enabled:
+				setMaterial("OgreBulletCollisionsDebugLines/Enabled");
+			break;
+
+			case DebugCollisionShape::Mode_Disabled:
+				setMaterial("OgreBulletCollisionsDebugLines/Disabled");
+
+			break;
+
+			case DebugCollisionShape::Mode_Static:
+				setMaterial("OgreBulletCollisionsDebugLines/Static");
+			break;
+		}
+	}
+}
+//------------------------------------------------------------------------------------------------
+DebugCollisionShape::~DebugCollisionShape() 
+{
+}
+//------------------------------------------------------------------------------------------------
+bool DebugCollisionShape::getIsVisual() const
+{
+    return mIsVisual;
+}
+//------------------------------------------------------------------------------------------------
+void DebugCollisionShape::setIsVisual( bool val )
+{
+    mIsVisual = val;
+}
+//------------------------------------------------------------------------------------------------
+RayDebugShape::RayDebugShape(const Ogre::Vector3& start, 
+							   const Ogre::Vector3& direction, 
+							   const Ogre::Real length)
+{
+	const Ogre::Vector3 end (start + (direction.normalisedCopy() * length));
+	addLine(start, end);
+
+	draw();
+}
+//------------------------------------------------------------------------------------------------
+void RayDebugShape::setDefinition(const Ogre::Vector3& start,
+							const Ogre::Vector3& direction, 
+							const Ogre::Real length)
+{
+	clear();
+
+	const Ogre::Vector3 end (start + (direction.normalisedCopy() * length));
+	addLine(start, end);
+
+	draw();
+}
+//------------------------------------------------------------------------------------------------
+RayDebugShape::~RayDebugShape()
+{
+}
Index: /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.h	(revision 2122)
@@ -0,0 +1,84 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OgreBulletCollisions_DEBUGOBJECT_H_
+#define _OgreBulletCollisions_DEBUGOBJECT_H_
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+namespace OgreBulletCollisions
+{
+   
+	//------------------------------------------------------------------------------------------------
+	class  DebugCollisionShape : public DebugLines
+	{
+	public:
+		enum Mode
+		{
+			Mode_Unknown,
+			Mode_Enabled,
+			Mode_Disabled,
+			Mode_Static
+        };
+
+	public:
+        /** DebugCollisionShape ctor
+        */
+        DebugCollisionShape(CollisionShape * shape, 
+                            DebugCollisionShape::Mode mode = DebugCollisionShape::Mode_Enabled);
+		/** ~DebugCollisionShape ctor
+		*/
+        virtual ~DebugCollisionShape();
+        // mStatemode getter
+        DebugCollisionShape::Mode getStatemode() const { return mStatemode; }
+        // mStatemode setter
+        void setStatemode(DebugCollisionShape::Mode val);
+        // mIsVisual getter
+        bool getIsVisual() const;
+        // mIsVisual setter
+        void setIsVisual(bool val);
+
+	protected:
+        DebugCollisionShape::Mode mStatemode;
+        bool                      mIsVisual;
+
+
+	};
+	//------------------------------------------------------------------------------------------------
+	class  RayDebugShape:public DebugLines
+	{
+	public:
+		RayDebugShape(const Ogre::Vector3& start,const Ogre::Vector3& direction,const Ogre::Real length);
+		void setDefinition(const Ogre::Vector3& start,const Ogre::Vector3& direction,const Ogre::Real length);
+		virtual ~RayDebugShape();
+    };
+    //------------------------------------------------------------------------------------------------
+}
+
+#endif //_OgreBulletCollisions_DEBUGOBJECT_H_
+
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisions.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisions.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisions.h	(revision 2122)
@@ -0,0 +1,94 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_H
+#define _OGREBULLETCOLLISIONS_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+
+#ifdef _PRECOMP
+
+
+    #include "Utils/OgreBulletConverter.h"
+
+	//Debug Helpers
+	#include "Debug/OgreBulletCollisionsDebugLines.h"
+	#include "Debug/OgreBulletCollisionsDebugShape.h"
+	#include "Debug/OgreBulletCollisionsDebugDrawer.h"
+	#include "Debug/OgreBulletCollisionsDebugContact.h"
+
+    //Shapes
+    #include "OgreBulletCollisionsShape.h"
+
+    #include "Shapes/OgreBulletCollisionsBoxShape.h"
+    #include "Shapes/OgreBulletCollisionsConeShape.h"
+    #include "Shapes/OgreBulletCollisionsSphereShape.h"
+    #include "Shapes/OgreBulletCollisionsCylinderShape.h"
+	#include "Shapes/OgreBulletCollisionsTriangleShape.h"
+	#include "Shapes/OgreBulletCollisionsTerrainShape.h"
+	#include "Shapes/OgreBulletCollisionsCylinderShape.h"
+	#include "Shapes/OgreBulletCollisionsCapsuleShape.h"
+    #include "Shapes/OgreBulletCollisionsStaticPlaneShape.h"
+
+    #include "Shapes/OgreBulletCollisionsCompoundShape.h"
+
+    #include "Shapes/OgreBulletCollisionsMultiSphereShape.h"
+
+    #include "Shapes/OgreBulletCollisionsConvexHullShape.h"
+    #include "Shapes/OgreBulletCollisionsMinkowskiSumShape.h"
+
+    #include "Shapes/OgreBulletCollisionsTrimeshShape.h"
+
+    //Utils
+    #include "Utils/OgreBulletCollisionsMeshToShapeConverter.h"
+
+    // Ray
+    //#include "OgreBulletCollisionsConvexCast.h"
+
+    // Core Collisions
+    #include "OgreBulletCollisionsObject.h"
+    #include "OgreBulletCollisionsObjectState.h"
+
+    #include "OgreBulletCollisionsWorld.h"
+
+    #include "OgreBulletCollisionsRay.h"
+
+
+
+
+
+    #include "OgreString.h"
+    #include "OgreFontManager.h"
+
+    #include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h"
+    #include "BulletCollision/CollisionShapes/btTriangleShape.h"
+
+
+#endif //_PRECOMP
+
+#endif //_OGREBULLETCOLLISIONS_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObject.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObject.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObject.cpp	(revision 2122)
@@ -0,0 +1,197 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "OgreBulletCollisionsObject.h"
+#include "Debug/OgreBulletCollisionsDebugShape.h"
+
+#include "OgreBulletCollisionsObjectState.h"
+#include "OgreBulletCollisionsShape.h"
+#include "OgreBulletCollisionsWorld.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    //-----------------------------------------------------------------------
+    const Ogre::String Object::mMovableType = "OgreBullet::Object";
+    // -------------------------------------------------------------------------
+    Object::Object(const String &name, CollisionsWorld *world, bool init)
+        :	
+        MovableObject(name),
+        UserDefinedObject(),
+        mWorld(world),
+        mShape(0),
+        mState(0),
+        mRootNode(0),
+        mBounds(Vector3::ZERO, Vector3::ZERO),
+        mDebugShape(0),
+        mShapeNode(0),
+        mDebugNode(0)
+    {
+        if (init)
+        {
+            mObject = new btCollisionObject();
+            mState = new ObjectState(this);
+        }
+    }
+    // -------------------------------------------------------------------------
+    Object::~Object()
+    {
+        if (mRootNode)
+        {
+            showDebugShape(false);
+            mShapeNode->detachObject (this);
+            mRootNode->removeAndDestroyChild (mShapeNode->getName ());
+            //mRootNode->getParentSceneNode ()->removeAndDestroyChild (mRootNode->getName ());
+        }
+
+        getBulletCollisionWorld()->removeCollisionObject( mObject );
+		getCollisionWorld()->removeObject(this);
+
+        delete mObject;        
+        delete mShape;
+        delete mState;
+        delete mDebugShape;
+    }
+    //-----------------------------------------------------------------------
+    void Object::showDebugShape(bool show)
+    {
+        if (show && mDebugShape == 0 && mShape)
+        {
+            mDebugShape = new DebugCollisionShape(mShape);
+            if (mDebugShape->getIsVisual ())
+            {
+                assert (mDebugNode == 0);
+                mDebugNode = mRootNode->createChildSceneNode(mName + "DebugShape");
+                mDebugNode->attachObject (mDebugShape);
+            }
+        }
+        else if (mDebugShape)
+        {
+            if (mDebugShape->getIsVisual ())
+            {
+                assert (mDebugNode);
+                mDebugNode->detachObject (mDebugShape->getName());
+                mRootNode->removeAndDestroyChild (mDebugNode->getName());
+                mDebugNode = 0;
+            }
+            assert (mDebugNode == 0);
+            delete mDebugShape;
+            mDebugShape = 0;
+        }
+    }
+    // -------------------------------------------------------------------------
+    void Object::setTransform(const btVector3 &pos, const btQuaternion &quat)
+    { 
+        mRootNode->setPosition(pos[0], pos[1], pos[2]);
+        mRootNode->setOrientation(quat.getW(),quat.getX(), quat.getY(), quat.getZ());
+    }
+    // -------------------------------------------------------------------------
+    void Object::setPosition(const btVector3 &pos)
+    {
+        mRootNode->setPosition(pos[0], pos[1], pos[2]);
+    }
+    // -------------------------------------------------------------------------
+    void Object::setOrientation(const btQuaternion &quat)
+    {   
+        mRootNode->setOrientation(quat.getW(),quat.getX(), quat.getY(), quat.getZ());
+    }
+    // -------------------------------------------------------------------------
+    void Object::setTransform(const btTransform& worldTrans)
+    { 
+        mRootNode->setPosition(worldTrans.getOrigin()[0], worldTrans.getOrigin()[1],worldTrans.getOrigin()[2]);
+        mRootNode->setOrientation(worldTrans.getRotation().getW(),worldTrans.getRotation().getX(), worldTrans.getRotation().getY(), worldTrans.getRotation().getZ());
+    }
+    //-----------------------------------------------------------------------
+    void Object::setShape(CollisionShape *shape, 
+        const Vector3 &pos, 
+        const Quaternion &quat)
+    {
+        mShape = shape;
+
+        mRootNode = mWorld->getSceneManager()->getRootSceneNode()->createChildSceneNode(mName, pos, quat);
+        mShapeNode = mRootNode->createChildSceneNode(mName + "Shape");
+        mShapeNode->attachObject(this);
+
+        mObject->setCollisionShape(shape->getBulletShape());
+        showDebugShape(mWorld->getShowDebugShapes());       
+    }
+    // -------------------------------------------------------------------------
+    //-----------------------------------------------------------------------
+    void Object::_notifyAttached(Node* parent, bool isTagPoint)
+    {
+        MovableObject::_notifyAttached(parent,isTagPoint);
+        if (parent)
+        {
+            Object* other_object = mWorld->findObject(static_cast<SceneNode*>(parent));
+            if ((other_object) && (other_object != this))
+            {
+                static_cast<SceneNode*>(parent)->detachObject(other_object);
+
+            }
+            setPosition(parent->getPosition());
+            setOrientation(parent->getOrientation());
+        } 
+    }
+#if (OGRE_VERSION >=  ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0)
+    //-----------------------------------------------------------------------
+	void Object::visitRenderables(Renderable::Visitor* visitor, 
+		bool debugRenderables)
+	{
+		//visitor->visit(this, 0, false);
+	}
+#endif
+    //-----------------------------------------------------------------------
+    const Ogre::String& Object::getMovableType() const
+    {
+        return mMovableType;
+    }
+
+    //-----------------------------------------------------------------------
+    void Object::_notifyCurrentCamera(Camera* camera)
+    {
+    }
+
+    //-----------------------------------------------------------------------
+    const AxisAlignedBox& Object::getBoundingBox(void) const
+    {
+        return mBounds;
+    }
+    //-----------------------------------------------------------------------
+    Real Object::getBoundingRadius(void) const
+    {
+        return Ogre::Real(0.0);
+    }
+
+    //-----------------------------------------------------------------------
+    void Object::_updateRenderQueue(RenderQueue* queue)
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObject.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObject.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObject.h	(revision 2122)
@@ -0,0 +1,123 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_CollisionObject_H
+#define _OGREBULLETCOLLISIONS_CollisionObject_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsWorld.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    /*!
+	 * \brief
+	 * 
+	 * Object is the Basic Bullet Collision representation of an Physical thing in
+     * a scene. It does need a Shape Object to know its "Geometrics" Bounds.
+	 * 
+	 * \remarks
+	 * Objects doesn't need to be represented by a Visible 3D mesh.
+	 * 
+	 * \see
+	 * Ogre::MovableObject | Ogre::UserDefinedObject | OgreBulletDynamics::RigidBody
+	 */
+	class Object : public Ogre::MovableObject, public Ogre::UserDefinedObject
+    {
+    public:
+
+
+
+        Object(const Ogre::String &name,  CollisionsWorld *world, bool init);
+
+
+        virtual ~Object();
+
+        // override Movables
+#if (OGRE_VERSION >=  ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0)
+		void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables);
+#endif
+        virtual const Ogre::String& getMovableType() const; 
+        virtual void _notifyAttached(Ogre::Node* parent,bool isTagPoint = false);
+        //virtual const Ogre::String& getName(void) const {return mName};
+        virtual void _notifyCurrentCamera(Ogre::Camera* camera);
+        virtual const Ogre::AxisAlignedBox& getBoundingBox(void) const;
+        virtual Ogre::Real getBoundingRadius(void) const;
+        virtual void _updateRenderQueue(Ogre::RenderQueue* queue);
+
+
+        inline const Ogre::Vector3 &getWorldPosition() const {return mRootNode->_getDerivedPosition();};
+		inline const Ogre::Quaternion &getWorldOrientation() const {return mRootNode->_getDerivedOrientation();};
+
+        inline void setPosition(const Ogre::Vector3 &p) {mRootNode->setPosition (p);};
+        inline void setOrientation(const Ogre::Quaternion &q)  {return mRootNode->setOrientation (q);};
+
+        inline void setPosition(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z) {mRootNode->setPosition (x,y,z);};
+        inline void setOrientation(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z, const Ogre::Real w)  {return mRootNode->setOrientation (x,y,z,w);};
+
+        virtual void setPosition(const btVector3 &pos);
+        virtual void setOrientation(const btQuaternion &quat);
+        virtual void setTransform(const btVector3 &pos, const btQuaternion &quat);
+        virtual void setTransform(const btTransform& worldTrans);
+
+        inline btCollisionObject*  getBulletObject() const { return mObject;};
+        inline btCollisionWorld*  getBulletCollisionWorld() const { return mWorld->getBulletCollisionWorld ();};
+        inline CollisionsWorld*  getCollisionWorld() const { return mWorld;};
+        
+        inline CollisionShape *getShape() const{ return mShape;};
+        inline DebugCollisionShape* getDebugShape() const{ return mDebugShape;};
+
+        void setShape(CollisionShape *shape, 
+            const Ogre::Vector3 &pos, 
+            const Ogre::Quaternion &quat);
+        void showDebugShape(bool show);
+
+		Ogre::SceneNode *getRootNode() { return mRootNode; }
+
+    protected:
+
+        Ogre::SceneNode*        mRootNode;
+        Ogre::SceneNode*        mShapeNode;
+        Ogre::SceneNode*        mDebugNode;
+
+        ObjectState   *         mState;
+        CollisionsWorld*        mWorld;
+
+        btCollisionObject*      mObject;
+
+        Ogre::AxisAlignedBox    mBounds;
+
+        CollisionShape*         mShape;
+        DebugCollisionShape *   mDebugShape;
+
+    public:
+        static const Ogre::String mMovableType;
+    };
+    // -------------------------------------------------------------------------
+}
+#endif //_OGREBULLETCOLLISIONS_CollisionObject_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObjectState.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObjectState.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObjectState.cpp	(revision 2122)
@@ -0,0 +1,64 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Utils/OgreBulletConverter.h"
+#include "OgreBulletCollisionsObject.h"
+#include "OgreBulletCollisionsObjectState.h"
+
+using namespace Ogre;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    ObjectState::ObjectState(Object *parent):	
+        mObject(parent)
+    {
+    }
+    // -------------------------------------------------------------------------
+    ObjectState::~ObjectState()
+    {
+    }
+    // -------------------------------------------------------------------------
+    void ObjectState::getWorldTransform(btTransform& worldTrans) const
+    {
+        assert (mObject);
+
+        // could use mWorldTrans ?
+		
+        worldTrans.setOrigin(OgreBtConverter::to(mObject->getWorldPosition()));
+        worldTrans.setRotation(OgreBtConverter::to(mObject->getWorldOrientation()));
+    }
+    // -------------------------------------------------------------------------
+    void ObjectState::setWorldTransform(const btTransform& worldTrans)
+    {
+        assert (mObject);        
+
+        mObject->setTransform (worldTrans);
+        mWorldTrans = worldTrans;        
+    }
+}
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObjectState.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObjectState.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsObjectState.h	(revision 2122)
@@ -0,0 +1,50 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_ObjectState_H
+#define _OGREBULLETCOLLISIONS_ObjectState_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+
+namespace OgreBulletCollisions
+{
+    class ObjectState : public btMotionState
+    {
+    public:
+	    ObjectState(Object *parent);
+	    ~ObjectState();
+    	
+	    virtual void getWorldTransform(btTransform& worldTrans ) const;
+        virtual void setWorldTransform(const btTransform& worldTrans);	
+
+    private:
+        Object      *mObject;
+        btTransform  mWorldTrans;
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_ObjectState_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsPreRequisites.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsPreRequisites.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsPreRequisites.h	(revision 2122)
@@ -0,0 +1,95 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_PREREQUISITES_H
+#define _OGREBULLETCOLLISIONS_PREREQUISITES_H
+
+#include "btBulletCollisionCommon.h"
+
+#include "BulletCollision/GIMPACT/btGImpactShape.h"
+#include "BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.h"
+
+#include "Ogre.h"
+
+/* Some <math.h> files do not define M_PI... */
+#ifndef M_PI
+#define M_PI 3.14159265
+#endif
+
+namespace OgreBulletCollisions
+{
+    class BtOgreConverter;
+    class OgreBtConverter;
+
+    class CollisionsWorld;
+
+    class CollisionRayResultCallback;
+    class CollisionClosestRayResultCallback;
+
+    class DebugLines;
+
+    class DebugDrawer;
+
+    class DebugContact;
+    class DebugNormal;
+    class DebugContactText;
+    
+    class DebugCollisionShape;
+    class BoxDebugShape;
+    class SphereDebugShape;
+    class ConeDebugShape;
+    class TriangleMeshDebugShape;
+    class RayDebugShape;
+
+	class GImpactConcaveShape;
+	class HeightmapCollisionShape;
+    class CollisionShape;
+    class BoxCollisionShape;
+    class SphereCollisionShape;
+    class CylinderCollisionShape;
+	class CapsuleCollisionShape;
+    class ConeCollisionShape;
+
+    class CompoundCollisionShape;
+
+    class MultiSphereCollisionShape;
+    class MinkowskiSumCollisionShape;
+
+    class ConvexHullCollisionShape;
+    class TriangleMeshCollisionShape;
+
+    class Object;
+
+    class ObjectState;
+
+    typedef std::vector<Ogre::Vector3> Vector3Array;
+    typedef std::map<unsigned char, Vector3Array* > BoneIndex;
+    typedef std::pair<unsigned short, Vector3Array* > BoneKeyIndex;
+
+}
+
+#endif //_OGREBULLETCOLLISIONS_PREREQUISITES_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsPrecompiled.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsPrecompiled.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsPrecompiled.cpp	(revision 2122)
@@ -0,0 +1,27 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsRay.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsRay.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsRay.cpp	(revision 2122)
@@ -0,0 +1,104 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "OgreBulletCollisionsWorld.h"
+#include "OgreBulletCollisionsRay.h"
+#include "Utils/OgreBulletConverter.h"
+
+#include "OgreBulletCollisionsObject.h"
+#include "Debug/OgreBulletCollisionsDebugShape.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+	CollisionRayResultCallback::CollisionRayResultCallback(const Ogre::Ray &ray, 
+							CollisionsWorld *world, Ogre::Real max_distance,
+							bool init):
+        mRayResultCallback(0),
+        mWorld(world),
+        mRay (ray),
+		mMaxDistance(max_distance)
+    {
+        if (init)
+        {
+            //mRay = new btCollisionWorld::RayResultCallback (
+            //    OgreBtConverter::to(ray.getOrigin ()), 
+            //   OgreBtConverter::to(ray.getDirection ()));
+        }
+	}
+    // -------------------------------------------------------------------------
+    CollisionRayResultCallback::~CollisionRayResultCallback()
+    {
+        if (mRayResultCallback)
+        {
+            delete mRayResultCallback;
+            mRayResultCallback = 0;
+        }
+    }
+    Ogre::Vector3 CollisionRayResultCallback::getRayStartPoint() const
+    {
+      return mRay.getOrigin();
+    }
+    // -------------------------------------------------------------------------
+    Ogre::Vector3 CollisionRayResultCallback::getRayEndPoint() const
+    {
+      return mRay.getPoint(mMaxDistance);
+    }
+    // -------------------------------------------------------------------------
+    bool  CollisionRayResultCallback::doesCollide() const
+    {
+        return mRayResultCallback->hasHit();
+    }
+    // -------------------------------------------------------------------------
+    Object  *CollisionClosestRayResultCallback::getCollidedObject () const
+    {        
+        return mWorld->findObject(static_cast<btCollisionWorld::ClosestRayResultCallback *> (mRayResultCallback)->m_collisionObject);
+	}
+    // -------------------------------------------------------------------------
+	CollisionClosestRayResultCallback::CollisionClosestRayResultCallback(const Ogre::Ray &ray, CollisionsWorld *world, Ogre::Real max_distance) :
+        CollisionRayResultCallback(ray, world, max_distance, false)
+    {
+        mRayResultCallback = new btCollisionWorld::ClosestRayResultCallback (
+            OgreBtConverter::to(getRayStartPoint ()), 
+            OgreBtConverter::to(getRayEndPoint ()));
+    } 
+    // -------------------------------------------------------------------------
+    Vector3 CollisionClosestRayResultCallback::getCollisionPoint() const
+    {
+        return BtOgreConverter::to(getBulletClosestRayResultCallback()->m_hitPointWorld);
+	}
+	// -------------------------------------------------------------------------
+	Vector3 CollisionClosestRayResultCallback::getCollisionNormal() const
+	{
+		return BtOgreConverter::to(getBulletClosestRayResultCallback()->m_hitNormalWorld);
+	}
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsRay.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsRay.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsRay.h	(revision 2122)
@@ -0,0 +1,88 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_CollisionRay_H
+#define _OGREBULLETCOLLISIONS_CollisionRay_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic CollisionRay
+    class CollisionRayResultCallback 
+    {
+	public:
+		CollisionRayResultCallback(const Ogre::Ray &ray, CollisionsWorld *world, Ogre::Real max_distance, bool init = true);
+	    virtual ~CollisionRayResultCallback();
+
+        btCollisionWorld::RayResultCallback *getBulletRay() const {return mRayResultCallback;}
+
+		bool doesCollide () const;
+
+		void setRay(const Ogre::Ray &ray);
+		void setWorld(CollisionsWorld *world);
+		void setMaxDistance(Ogre::Real max_distance);
+
+        inline const Ogre::Ray &getRay() const;
+		inline Ogre::Vector3 getRayStartPoint() const;
+		inline Ogre::Vector3 getRayEndPoint() const;
+
+    protected:
+
+        btCollisionWorld::RayResultCallback   *mRayResultCallback;
+        CollisionsWorld                       *mWorld;
+        Ogre::Ray                              mRay;
+		Ogre::Real                             mMaxDistance;
+
+    };
+    // -------------------------------------------------------------------------
+    // basic CollisionRay inline methods
+    inline const Ogre::Ray &CollisionRayResultCallback ::getRay() const 
+    {
+        return mRay;
+    }
+    // -------------------------------------------------------------------------
+    //  CollisionClosestRay
+    class CollisionClosestRayResultCallback : public CollisionRayResultCallback
+    { 
+	public:
+		CollisionClosestRayResultCallback(const Ogre::Ray &ray, CollisionsWorld *world, Ogre::Real max_distance);
+        virtual ~CollisionClosestRayResultCallback(){};
+
+        Object *getCollidedObject() const;
+		Ogre::Vector3 getCollisionPoint() const;
+		Ogre::Vector3 getCollisionNormal() const;
+
+        inline btCollisionWorld::ClosestRayResultCallback *getBulletClosestRayResultCallback() const 
+        {
+            return static_cast <btCollisionWorld::ClosestRayResultCallback * > (mRayResultCallback);
+        }
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_CollisionRay_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsShape.cpp	(revision 2122)
@@ -0,0 +1,172 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "OgreBulletCollisionsShape.h"
+#include "Utils/OgreBulletConverter.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    CollisionShape::CollisionShape()
+        :	
+        mShape(0)
+    {
+    }
+    // -------------------------------------------------------------------------
+    CollisionShape::~CollisionShape()
+    {
+       delete mShape;
+    }
+    // -------------------------------------------------------------------------
+    bool CollisionShape::drawWireFrame(DebugLines *wire, const Vector3 &pos, const Quaternion &quat) const
+    {   
+        if (mShape->isConvex ())
+            return drawConvexWireFrame (wire, pos, quat);
+
+        return false;
+    }
+    // -------------------------------------------------------------------------
+    bool CollisionShape::drawConvexWireFrame(DebugLines *wire, const Vector3 &pos, const Quaternion &quat) const
+    {   
+        assert (mShape->isConvex ());
+        
+        const btConvexShape * const s = static_cast <btConvexShape *> (mShape);
+
+        Vector3 lastVec;
+        bool sideBeginning;
+
+        #define getVertex(X,Y,Z) BtOgreConverter::to(s->localGetSupportingVertex (btVector3(X,Y,Z)))
+
+        const bool hasVecTransform = (pos != Vector3::ZERO);
+        const bool hasQuatTransform = (quat != Quaternion::IDENTITY);
+        const bool hasTransform = (hasVecTransform) || (hasQuatTransform);
+
+        Vector3 curVec;
+        size_t i = 0;
+        const int subDivisionCount = 1;
+        const float subDivide = 1.0f / subDivisionCount;
+        for (int x = -subDivisionCount; x <= subDivisionCount; x++)
+        {
+            for (int y = -subDivisionCount; y <= subDivisionCount; y++)
+            {
+                sideBeginning = true;
+                for (int z = -subDivisionCount; z <= subDivisionCount; z++)
+                {
+                    curVec = getVertex(x*subDivide, y*subDivide, z*subDivide);
+                    if (hasTransform)
+                    {
+                        // apply transformation
+                        if (hasQuatTransform) 
+                            curVec = quat * curVec;
+                        if (hasVecTransform) 
+                            curVec += pos;
+//                        if (hasVecTransform) 
+//                            curVec -= pos;
+//                        if (hasQuatTransform) 
+//                            curVec = quat * curVec;
+                    }
+
+                    if (sideBeginning)
+                        sideBeginning = false;
+                    else
+                        wire->addLine (lastVec, curVec);
+                    lastVec = curVec;
+
+                    i++;
+                }
+            }
+        }
+
+
+        for (int x = -subDivisionCount; x <= subDivisionCount; x++)
+        {
+            for (int z = -subDivisionCount; z <= subDivisionCount; z++)
+            {
+                sideBeginning = true;
+                for (int y = -subDivisionCount; y <= subDivisionCount; y++)
+                {
+                    curVec = getVertex(x*subDivide, y*subDivide, z*subDivide);
+                    if (hasTransform)
+                    {
+                        // apply transformation
+                        if (hasVecTransform) 
+                            curVec -= pos;
+                        if (hasQuatTransform) 
+                            curVec = quat * curVec;
+                    }
+
+                    if (sideBeginning)
+                        sideBeginning = false;
+                    else
+                        wire->addLine (lastVec, curVec);
+                    lastVec = curVec;
+
+                    i++;
+                }
+            }
+        }
+
+
+
+        for (int z = -subDivisionCount; z <= subDivisionCount; z++)
+        {
+            for (int y = -subDivisionCount; y <= subDivisionCount; y++)
+            {
+                sideBeginning = true;
+                for (int x = -subDivisionCount; x <= subDivisionCount; x++)
+                {
+                    curVec = getVertex(x*subDivide, y*subDivide, z*subDivide);
+                    if (hasTransform)
+                    {
+                        // apply transformation
+                        if (hasVecTransform) 
+                            curVec -= pos;
+                        if (hasQuatTransform) 
+                            curVec = quat * curVec;
+                    }
+
+                    if (sideBeginning)
+                        sideBeginning = false;
+                    else
+                        wire->addLine (lastVec, curVec);
+                    lastVec = curVec;
+
+                    i++;
+                }
+            }
+        }
+#undef getVertex
+
+        return true;
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsShape.h	(revision 2122)
@@ -0,0 +1,57 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_Shape_H
+#define _OGREBULLETCOLLISIONS_Shape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic Shape
+    class CollisionShape 
+    {
+
+    public:
+	    CollisionShape();
+        virtual ~CollisionShape();
+        
+        inline btCollisionShape* getBulletShape () {return mShape;};
+
+        virtual bool drawWireFrame(DebugLines *wire, 
+            const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+            const Ogre::Quaternion &quat= Ogre::Quaternion::IDENTITY) const;
+
+    protected:
+        btCollisionShape*       mShape;        
+        bool drawConvexWireFrame(DebugLines *wire, const Ogre::Vector3 &pos, const Ogre::Quaternion &quat) const;
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_Shape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsWorld.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsWorld.cpp	(revision 2122)
@@ -0,0 +1,238 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "OgreBulletCollisionsWorld.h"
+#include "Utils/OgreBulletConverter.h"
+
+#include "OgreBulletCollisionsObject.h"
+#include "Debug/OgreBulletCollisionsDebugShape.h"
+#include "OgreBulletCollisionsRay.h"
+
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    CollisionsWorld::CollisionsWorld(SceneManager *scn, const AxisAlignedBox &bounds, bool init, bool set32bitsAxisSweep):
+        mScnMgr(scn),
+        mBounds(bounds),
+        mShowDebugShapes(false),
+        mShowDebugContactPoints(false),
+        mDebugContactPoints(0)
+	{
+        mDispatcher = new btCollisionDispatcher(&mDefaultCollisionConfiguration);
+
+		if (set32bitsAxisSweep)
+		{
+			mBroadphase = new bt32BitAxisSweep3(
+				OgreBtConverter::to(bounds.getMinimum()), 
+				OgreBtConverter::to(bounds.getMaximum()));
+		}
+		else
+		{
+			mBroadphase = new btAxisSweep3(
+				OgreBtConverter::to(bounds.getMinimum()), 
+				OgreBtConverter::to(bounds.getMaximum()));
+		}
+
+        // if not called by a inherited class
+        if (init)
+		{
+			mWorld = new btCollisionWorld(mDispatcher, mBroadphase, &mDefaultCollisionConfiguration);
+
+			btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(mWorld->getDispatcher());
+			btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
+		}
+    }
+    // -------------------------------------------------------------------------
+    CollisionsWorld::~CollisionsWorld()
+    {
+        delete mWorld;
+		delete mBroadphase;
+        delete mDispatcher;
+    }
+    // -------------------------------------------------------------------------
+    void CollisionsWorld::setShowDebugContactPoints(bool show)
+    {
+        if (show && !mShowDebugContactPoints)
+        {
+            assert (mDebugContactPoints == 0);
+
+            mShowDebugContactPoints = true;
+            return;
+        }
+        if (!show && mShowDebugContactPoints)
+        {
+            assert (mDebugContactPoints != 0);
+
+            mShowDebugContactPoints = false;
+            return;
+        }
+    }
+    // -------------------------------------------------------------------------
+    void CollisionsWorld::setShowDebugShapes(bool show)
+    {
+        if (show && !mShowDebugShapes)
+        {
+            //assert (mDebugShapes == 0);
+            std::deque<Object*>::iterator it = mObjects.begin();
+            while (it != mObjects.end())
+            {
+                (*it)->showDebugShape(show);
+                ++it;
+            }
+            mShowDebugShapes = true;
+            return;
+        }
+        if (!show && mShowDebugShapes)
+        {
+            //assert (mDebugShapes != 0);
+            std::deque<Object*>::iterator it = mObjects.begin();
+            while (it != mObjects.end())
+            {
+                (*it)->showDebugShape(show);
+                ++it;
+            }
+            mShowDebugShapes = false;
+            return;
+        }
+    }
+    // -------------------------------------------------------------------------
+    void CollisionsWorld::addObject(Object *obj)
+    {
+        mObjects.push_back (obj);
+        mWorld->addCollisionObject(obj->getBulletObject());
+    }
+    //------------------------------------------------------------------------- 
+	bool CollisionsWorld::removeObject(Object *obj)
+    {
+       std::deque<Object*>::iterator it = find(mObjects.begin(),mObjects.end(), obj);
+       if (it == mObjects.end())
+          return false;
+       mObjects.erase(it);
+       return true;
+    }
+    // -------------------------------------------------------------------------
+    bool CollisionsWorld::isObjectregistered(Object *obj) const
+    {
+        std::deque<Object *>::const_iterator itRes = std::find(mObjects.begin(), mObjects.end(), obj);
+        if (itRes != mObjects.end())
+            return true;
+        return false;
+    }
+    // -------------------------------------------------------------------------
+    Object *CollisionsWorld::findObject(btCollisionObject *object) const
+    {
+        std::deque<Object *>::const_iterator it = mObjects.begin();
+        while (it != mObjects.end())
+        {
+            if ((*it)->getBulletObject() == object)
+                return (*it);
+            ++it;
+        }
+        return 0;
+    }
+    // -------------------------------------------------------------------------
+    Object *CollisionsWorld::findObject(SceneNode *node) const
+    {
+        std::deque<Object *>::const_iterator it = mObjects.begin();
+        while (it != mObjects.end())
+        {
+            //if ((*it)->getParentNode() == node)
+			if((*it)->getRootNode() == node)
+                return (*it);
+            ++it;
+        }
+        return 0;
+    }
+    // -------------------------------------------------------------------------
+    void CollisionsWorld::discreteCollide()
+    {
+        mWorld->performDiscreteCollisionDetection();
+
+
+        ///one way to draw all the contact points is iterating over contact manifolds / points:
+        const unsigned int  numManifolds = mWorld->getDispatcher()->getNumManifolds();
+        for (unsigned int i=0;i < numManifolds; i++)
+        {
+            btPersistentManifold* contactManifold = mWorld->getDispatcher()->getManifoldByIndexInternal(i);
+
+            btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
+            btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
+
+            contactManifold->refreshContactPoints(obA->getWorldTransform(),obB->getWorldTransform());
+
+            const unsigned int numContacts = contactManifold->getNumContacts();
+            for (unsigned int j = 0;j < numContacts; j++)
+            {
+                btManifoldPoint& pt = contactManifold->getContactPoint(j);
+
+                if (mShowDebugContactPoints)
+                {
+                    btVector3 ptA = pt.getPositionWorldOnA();
+                    btVector3 ptB = pt.getPositionWorldOnB();
+
+                    mDebugContactPoints->addLine(ptA.x(),ptA.y(),ptA.z(),
+                                                     ptB.x(),ptB.y(),ptB.z());
+                }
+            }
+            //you can un-comment out this line, and then all points are removed
+            //contactManifold->clearManifold();	
+        }
+
+        /*
+        if (mShowDebugShapes)
+        {
+            std::deque<Object*>::iterator it = mObjects.begin();
+            while (it != mObjects.end())
+            {
+
+                //(*it)->getBulletObject()->getWorldTransform().getOpenGLMatrix( m );
+                mShowDebugDrawShapes->
+                //GL_ShapeDrawer::drawOpenGL(m,objects[i].getCollisionShape(),btVector3(1,1,1),getDebugMode());
+
+                ++it;
+            }
+        }
+        */
+    }
+
+    // -------------------------------------------------------------------------
+    void CollisionsWorld::launchRay(CollisionRayResultCallback &rayresult, short int collisionFilterMask)
+    {
+        mWorld->rayTest(
+            OgreBtConverter::to(rayresult.getRayStartPoint()), 
+            OgreBtConverter::to(rayresult.getRayEndPoint()), 
+            *rayresult.getBulletRay ()
+			//, collisionFilterMask
+			);
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsWorld.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsWorld.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/OgreBulletCollisionsWorld.h	(revision 2122)
@@ -0,0 +1,89 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_CollisionWorld_H
+#define _OGREBULLETCOLLISIONS_CollisionWorld_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic CollisionWorld
+    class CollisionsWorld 
+    {
+    public:
+        CollisionsWorld(Ogre::SceneManager *scn, const Ogre::AxisAlignedBox &bounds, bool init = true, bool set32bitsAxisSweep = true);
+	    virtual ~CollisionsWorld();
+
+        void addObject(Object *obj);
+
+		/// Returns false if obj was not found.
+		bool removeObject(Object *obj);
+
+        void discreteCollide();
+
+        bool isObjectregistered(Object *) const;
+        Object *findObject(Ogre::SceneNode *node) const;
+        Object *findObject(btCollisionObject *object) const;
+
+
+        // mShowDebugContactPoints getter
+        bool getShowDebugContactPoints() const { return mShowDebugContactPoints; }
+        // mShowDebugContactPoints setter
+        void setShowDebugContactPoints(bool show);
+        // mShowDebugShapes getter
+        bool getShowDebugShapes() const { return mShowDebugShapes; }
+        // mShowDebugShapes setter
+        void setShowDebugShapes(bool val);
+
+        Ogre::SceneManager *getSceneManager() const {return mScnMgr;}
+        btCollisionWorld *getBulletCollisionWorld() const {return mWorld;}
+
+        void launchRay (CollisionRayResultCallback &ray, short int collisionFilterMask = -1);
+
+    protected:
+        btCollisionWorld*          mWorld;
+        btCollisionDispatcher*     mDispatcher;
+
+		btBroadphaseInterface*	   mBroadphase;
+
+        Ogre::AxisAlignedBox       mBounds;
+
+		btDefaultCollisionConfiguration	mDefaultCollisionConfiguration;
+
+        std::deque<Object *>        mObjects;
+
+        bool                        mShowDebugShapes;
+        bool                        mShowDebugContactPoints;
+        DebugLines *                mDebugContactPoints;
+
+        Ogre::SceneManager *        mScnMgr;
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_CollisionWorld_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.cpp	(revision 2122)
@@ -0,0 +1,49 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Utils/OgreBulletConverter.h"
+#include "Shapes/OgreBulletCollisionsBoxShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    BoxCollisionShape::BoxCollisionShape(const Vector3  &bodyBounds):	
+        CollisionShape()
+    {
+            mShape = new btBoxShape(OgreBtConverter::to(bodyBounds));
+    }
+    // -------------------------------------------------------------------------
+    BoxCollisionShape::~BoxCollisionShape()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.h	(revision 2122)
@@ -0,0 +1,47 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_BoxShape_H
+#define _OGREBULLETCOLLISIONS_BoxShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic BoxShape
+    class BoxCollisionShape : public CollisionShape
+    {
+    public:
+        BoxCollisionShape(const Ogre::Vector3  &boxBounds);
+	    virtual ~BoxCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_BoxShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCapsuleShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCapsuleShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCapsuleShape.cpp	(revision 2122)
@@ -0,0 +1,54 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+#include "Utils/OgreBulletConverter.h"
+
+#include "Shapes/OgreBulletCollisionsCapsuleShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    CapsuleCollisionShape::CapsuleCollisionShape(const Real  radius, const Real height, const Vector3 &axe):	
+        CollisionShape()
+    {
+        if (axe == Vector3::UNIT_X)
+            mShape = new btCapsuleShapeX(radius, height);
+        else if (axe == Vector3::UNIT_Y)
+            mShape = new btCapsuleShape (radius, height);
+        else if (axe == Vector3::UNIT_Z)
+            mShape = new btCapsuleShapeZ(radius, height);
+    }
+    // -------------------------------------------------------------------------
+    CapsuleCollisionShape::~CapsuleCollisionShape()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCapsuleShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCapsuleShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCapsuleShape.h	(revision 2122)
@@ -0,0 +1,47 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_CapsuleShape_H
+#define _OGREBULLETCOLLISIONS_CapsuleShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic CapsuleShape
+    class CapsuleCollisionShape : public CollisionShape
+    {
+    public:
+        CapsuleCollisionShape(const Ogre::Real radius, const Ogre::Real height, const Ogre::Vector3 &axe);
+	    virtual ~CapsuleCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_CapsuleShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.cpp	(revision 2122)
@@ -0,0 +1,93 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+#include "Utils/OgreBulletConverter.h"
+
+#include "Shapes/OgreBulletCollisionsCompoundShape.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    CompoundCollisionShape::CompoundCollisionShape():	
+        CollisionShape()
+    {
+            mShape = new btCompoundShape();
+    }
+    // -------------------------------------------------------------------------
+    CompoundCollisionShape::~CompoundCollisionShape()
+    {
+    }
+    // -------------------------------------------------------------------------
+    void CompoundCollisionShape::addChildShape(CollisionShape *shape, const Vector3 &pos, const Quaternion &quat)
+    {
+        btTransform localTrans;
+        
+        //localTrans.setIdentity();
+        //localTrans effectively shifts the center of mass with respect to the chassis
+        localTrans.setOrigin (OgreBtConverter::to(pos));
+        localTrans.setRotation (OgreBtConverter::to(quat));
+
+        static_cast <btCompoundShape *> (mShape)->addChildShape(localTrans, shape->getBulletShape());
+        
+        mShapes.push_back (shape);
+    }
+    // -------------------------------------------------------------------------
+    bool CompoundCollisionShape::drawWireFrame(DebugLines *wire, 
+        const Ogre::Vector3 &pos, 
+        const Ogre::Quaternion &quat) const
+    {
+        bool isVisual = false;
+        btCompoundShape * const myBtCompoundShape = static_cast <btCompoundShape *> (mShape);
+        int numChildShapes = myBtCompoundShape->getNumChildShapes ();
+
+        int i;
+        for (std::vector<CollisionShape *>::const_iterator itShape = mShapes.begin(); 
+            itShape != mShapes.end(); ++itShape)
+        {
+            const btCollisionShape * const shape = (*itShape)->getBulletShape();
+            for (i = 0; i < numChildShapes; i++)
+            {
+                if (myBtCompoundShape->getChildShape (i) == shape)
+                    break;
+            }
+            assert (i < numChildShapes);
+
+            const btTransform &localTrans = myBtCompoundShape->getChildTransform (i);
+
+            const Vector3 pos (BtOgreConverter::to(localTrans.getOrigin ()));
+            const Quaternion quat( BtOgreConverter::to(localTrans.getRotation ()));
+
+            if ((*itShape)->drawWireFrame(wire, pos, quat))
+                isVisual = true;
+        }
+        return isVisual;
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.h	(revision 2122)
@@ -0,0 +1,58 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_CompoundCollisionShape_H
+#define _OGREBULLETCOLLISIONS_CompoundCollisionShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic CompoundShape
+    class CompoundCollisionShape : public CollisionShape
+    {
+    public:
+        CompoundCollisionShape();
+	    virtual ~CompoundCollisionShape();
+
+        void addChildShape(CollisionShape *shape, 
+                            const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+                            const Ogre::Quaternion &quat = Ogre::Quaternion::IDENTITY);
+
+
+        bool drawWireFrame(DebugLines *wire, 
+            const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+            const Ogre::Quaternion &quat= Ogre::Quaternion::IDENTITY) const;
+
+    protected:
+        std::vector<CollisionShape *> mShapes;
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_CompoundCollisionShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.cpp	(revision 2122)
@@ -0,0 +1,54 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsConeShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    ConeCollisionShape::ConeCollisionShape(Real radius, Real height, const Vector3 &axe):	
+        CollisionShape()
+    {
+        if (axe == Vector3::UNIT_Y)
+            mShape = new btConeShape (btScalar (radius), btScalar (height));
+        else if (axe == Vector3::UNIT_X)
+            mShape = new btConeShapeX (btScalar (radius), btScalar (height));
+        else
+             mShape = new btConeShapeZ (btScalar (radius), btScalar (height));
+
+    }
+    // -------------------------------------------------------------------------
+    ConeCollisionShape::~ConeCollisionShape ()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.h	(revision 2122)
@@ -0,0 +1,47 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_ConeShape_H
+#define _OGREBULLETCOLLISIONS_ConeShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic ConeShape
+    class ConeCollisionShape : public CollisionShape
+    {
+    public:
+        ConeCollisionShape(Ogre::Real radius, Ogre::Real height, const Ogre::Vector3 &axe);
+	    virtual ~ConeCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_ConeShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.cpp	(revision 2122)
@@ -0,0 +1,55 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsConvexHullShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    ConvexHullCollisionShape::ConvexHullCollisionShape(const Real* points, int numPoints, int stride):	
+        CollisionShape()
+    {
+            mShape = new btConvexHullShape((btScalar*) points, numPoints, stride);
+    }
+    // -------------------------------------------------------------------------
+    ConvexHullCollisionShape::ConvexHullCollisionShape():	
+    CollisionShape()
+    {
+        mShape = new btConvexHullShape();
+    }
+    // -------------------------------------------------------------------------
+    ConvexHullCollisionShape::~ConvexHullCollisionShape()
+    {
+    }
+
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.h	(revision 2122)
@@ -0,0 +1,49 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_ConvexHullShape_H
+#define _OGREBULLETCOLLISIONS_ConvexHullShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic ConvexHullShape
+    class ConvexHullCollisionShape : public CollisionShape
+    {
+    public:
+        ConvexHullCollisionShape(const Ogre::Real* points, int numPoints, int stride);
+        ConvexHullCollisionShape();
+
+	    virtual ~ConvexHullCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_ConvexHullShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.cpp	(revision 2122)
@@ -0,0 +1,54 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+#include "Utils/OgreBulletConverter.h"
+
+#include "Shapes/OgreBulletCollisionsCylinderShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    CylinderCollisionShape::CylinderCollisionShape(const Vector3  &halfExtents, const Vector3 &axe):	
+        CollisionShape()
+    {
+        if (axe == Vector3::UNIT_X)
+            mShape = new btCylinderShapeX(OgreBtConverter::to(halfExtents));
+        else if (axe == Vector3::UNIT_Y)
+            mShape = new btCylinderShape (OgreBtConverter::to(halfExtents));
+        else if (axe == Vector3::UNIT_Z)
+            mShape = new btCylinderShapeZ(OgreBtConverter::to(halfExtents));
+    }
+    // -------------------------------------------------------------------------
+    CylinderCollisionShape::~CylinderCollisionShape()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.h	(revision 2122)
@@ -0,0 +1,47 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_CylinderShape_H
+#define _OGREBULLETCOLLISIONS_CylinderShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic CylinderShape
+    class CylinderCollisionShape : public CollisionShape
+    {
+    public:
+        CylinderCollisionShape(const Ogre::Vector3  &halfExtents, const Ogre::Vector3 &axe);
+	    virtual ~CylinderCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_CylinderShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsGImpactShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsGImpactShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsGImpactShape.cpp	(revision 2122)
@@ -0,0 +1,166 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsGImpactShape.h"
+
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "Shapes/OgreBulletCollisionsTrimeshShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+	GImpactConcaveShape::GImpactConcaveShape(
+		Ogre::Vector3 *_vertices,
+		unsigned int _vertex_count,
+		unsigned int *_indices,
+		unsigned int int_index_count) : CollisionShape(), mTriMesh(0)
+	{
+		mTriMesh = new btTriangleMesh();
+
+		unsigned int numFaces = int_index_count / 3;
+
+		btVector3    vertexPos[3];
+		for (size_t n = 0; n < numFaces; ++n)
+		{
+			for (unsigned int i = 0; i < 3; ++i)
+			{
+				const Vector3 &vec = _vertices[*_indices];
+				vertexPos[i][0] = vec.x;
+				vertexPos[i][1] = vec.y;
+				vertexPos[i][2] = vec.z;
+				*_indices++;
+			}
+
+			mTriMesh->addTriangle(vertexPos[0], vertexPos[1], vertexPos[2]);
+		}
+
+		btGImpactMeshShape * trimesh = new btGImpactMeshShape(mTriMesh);
+		trimesh->setLocalScaling(btVector3(1, 1, 1));
+		trimesh->updateBound();
+		mShape = trimesh;
+	}
+
+	GImpactConcaveShape::~GImpactConcaveShape()
+	{
+	}
+	// -------------------------------------------------------------------------
+	bool GImpactConcaveShape::drawWireFrame(DebugLines *wire, 
+		const Ogre::Vector3 &pos, 
+		const Ogre::Quaternion &quat) const
+	{
+		const int numTris = mTriMesh->getNumTriangles ();
+		if (numTris > 0)
+		{
+
+			const int numSubParts = mTriMesh->getNumSubParts ();
+			for (int currSubPart = 0; currSubPart < numSubParts; currSubPart++)
+			{
+				const unsigned char* vertexBase = NULL;
+				int numVerts;
+				PHY_ScalarType vertexType;
+				int vertexStride;
+				const unsigned char* indexBase = NULL;
+				int indexStride;
+				int numFaces;
+				PHY_ScalarType indexType;
+
+				mTriMesh->getLockedReadOnlyVertexIndexBase (&vertexBase, numVerts, 
+					vertexType, vertexStride, 
+					&indexBase, indexStride, numFaces, indexType, currSubPart);
+
+				float* p;
+				btVector3 vert0;
+				btVector3 vert1;
+				btVector3 vert2;
+				for (int t = 0; t < numFaces; t++)
+				{
+#define setVector(A, B) {A.setX(B[0]);A.setY(B[1]);A.setZ(B[2]);};
+
+					if (indexType == PHY_SHORT)
+					{
+						short int* index = (short int*)(indexBase + t*indexStride);
+
+						p = (float*)(vertexBase + index[0]*vertexStride);
+						setVector(vert0, p);						
+						p = (float*)(vertexBase + index[1]*vertexStride);
+						setVector(vert1, p);			
+						p = (float*)(vertexBase + index[2]*vertexStride);
+						setVector(vert2, p);		
+					} 
+					else
+					{
+						int* index = (int*)(indexBase + t*indexStride);
+
+						p = (float*)(vertexBase + index[0]*vertexStride);
+						setVector(vert0, p);						
+						p = (float*)(vertexBase + index[1]*vertexStride);
+						setVector(vert1, p);			
+						p = (float*)(vertexBase + index[2]*vertexStride);
+						setVector(vert2, p);		
+					}
+#undef setVector
+
+					wire->addLine (BtOgreConverter::to(vert0), BtOgreConverter::to(vert1));
+					wire->addLine (BtOgreConverter::to(vert1), BtOgreConverter::to(vert2));
+					wire->addLine (BtOgreConverter::to(vert2), BtOgreConverter::to(vert0));
+				}
+			}
+			return true;
+		}
+		return false;
+	}
+}
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsGImpactShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsGImpactShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsGImpactShape.h	(revision 2122)
@@ -0,0 +1,56 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef   _OGREBULLETCOLLISIONS_GImpact_Shapes_H
+#define   _OGREBULLETCOLLISIONS_GImpact_Shapes_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "BulletCollision/GIMPACT/btGImpactShape.h"
+#include "BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+	class __declspec( dllexport ) GImpactConcaveShape : public CollisionShape
+#else
+	class GImpactConcaveShape : public CollisionShape
+#endif
+	{
+	public:
+		GImpactConcaveShape(Ogre::Vector3 *_vertices, unsigned int _vertex_count, unsigned int *_indices, unsigned int_index_count);
+		virtual ~GImpactConcaveShape();
+
+		bool drawWireFrame(DebugLines *wire, 
+			const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+			const Ogre::Quaternion &quat= Ogre::Quaternion::IDENTITY) const;
+
+	private:
+		btTriangleMesh*         mTriMesh;
+	};
+}
+#endif
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.cpp	(revision 2122)
@@ -0,0 +1,56 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsMinkowskiSumShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    MinkowskiSumCollisionShape::MinkowskiSumCollisionShape(CollisionShape* shapeA, CollisionShape* shapeB) :	
+        CollisionShape()
+    {
+        //assert (shapeA->getBulletShape()->getClass() == CONVEX && 
+         //       shapeB->getBulletShape()->getClass() == CONVEX);
+
+        mShape = new btMinkowskiSumShape(
+            (btConvexShape*)shapeA->getBulletShape(),
+            (btConvexShape*)shapeB->getBulletShape()
+            );
+    }
+    // -------------------------------------------------------------------------
+    MinkowskiSumCollisionShape::~MinkowskiSumCollisionShape()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.h	(revision 2122)
@@ -0,0 +1,47 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_MinkowskiSumShape_H
+#define _OGREBULLETCOLLISIONS_MinkowskiSumShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic MinkowskiSumShape
+    class MinkowskiSumCollisionShape : public CollisionShape
+    {
+    public:
+	    MinkowskiSumCollisionShape(CollisionShape* shapeA, CollisionShape* shapeB);
+	    virtual ~MinkowskiSumCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_MinkowskiSumShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.cpp	(revision 2122)
@@ -0,0 +1,68 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsMultiSphereShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    MultiSphereCollisionShape::MultiSphereCollisionShape(
+        const Ogre::Vector3& inertiaHalfExtents,
+        const Ogre::Vector3* positions,
+        const Ogre::Real* radi,
+        int numSpheres):	
+        CollisionShape()
+    {
+		btVector3 * btPositions = new btVector3[numSpheres];
+		{
+			unsigned int currNum = numSpheres;
+			while (currNum-- > 0)
+			{
+				btPositions[currNum] = OgreBtConverter::to(positions[currNum]);
+			}
+		}
+
+        mShape = new btMultiSphereShape(
+            OgreBtConverter::to(inertiaHalfExtents),
+            (btVector3 *) btPositions,
+            (const btScalar *) radi,
+            numSpheres);
+
+		delete [] btPositions;
+    }
+    // -------------------------------------------------------------------------
+    MultiSphereCollisionShape::~MultiSphereCollisionShape()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.h	(revision 2122)
@@ -0,0 +1,51 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_MultiSphereShape_H
+#define _OGREBULLETCOLLISIONS_MultiSphereShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic MultiSphereShape
+    class MultiSphereCollisionShape : public CollisionShape
+    {
+    public:
+        MultiSphereCollisionShape(
+            const Ogre::Vector3& inertiaHalfExtents,
+            const Ogre::Vector3* positions,
+            const Ogre::Real* radi,
+            int numSpheres);
+	    virtual ~MultiSphereCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_MultiSphereShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.cpp	(revision 2122)
@@ -0,0 +1,48 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsSphereShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    SphereCollisionShape::SphereCollisionShape(const Real radius):	
+        CollisionShape()
+    {
+            mShape = new btSphereShape(radius);
+    }
+    // -------------------------------------------------------------------------
+    SphereCollisionShape::~SphereCollisionShape()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.h	(revision 2122)
@@ -0,0 +1,48 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_SphereShape_H
+#define _OGREBULLETCOLLISIONS_SphereShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic SphereShape
+    class SphereCollisionShape : public CollisionShape
+    {
+    public:
+        SphereCollisionShape(const Ogre::Real  radius);
+	    virtual ~SphereCollisionShape();
+
+    private:
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_SphereShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.cpp	(revision 2122)
@@ -0,0 +1,56 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsStaticPlaneShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    StaticPlaneCollisionShape::StaticPlaneCollisionShape(const Vector3 normal, Real distance):	
+        CollisionShape()
+    {
+            mShape = new btStaticPlaneShape (btVector3 (normal.x, normal.y, normal.z), btScalar (distance));
+    }
+    // -------------------------------------------------------------------------
+    StaticPlaneCollisionShape::~StaticPlaneCollisionShape()
+    {
+    }
+    // -------------------------------------------------------------------------
+    bool StaticPlaneCollisionShape::drawWireFrame(DebugLines *wire, 
+        const Ogre::Vector3 &pos, 
+        const Ogre::Quaternion &quat) const
+    {        
+        return false;
+    }
+
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.h	(revision 2122)
@@ -0,0 +1,50 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_StaticPlaneShape_H
+#define _OGREBULLETCOLLISIONS_StaticPlaneShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic BoxShape
+    class StaticPlaneCollisionShape : public CollisionShape
+    {
+    public:
+        StaticPlaneCollisionShape(const Ogre::Vector3 normal, Ogre::Real distance);
+	    virtual ~StaticPlaneCollisionShape();
+
+        bool drawWireFrame(DebugLines *wire, 
+            const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+            const Ogre::Quaternion &quat= Ogre::Quaternion::IDENTITY) const;
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_StaticPlaneShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTerrainShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTerrainShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTerrainShape.h	(revision 2122)
@@ -0,0 +1,131 @@
+#ifndef _OGREBULLET_HEIGHTMAP_
+#define _OGREBULLET_HEIGHTMAP_
+
+
+#include "OgreBulletCollisionsPrerequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
+#include "BulletCollision/CollisionShapes/btTriangleCallback.h"
+#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
+
+namespace OgreBulletCollisions
+{
+	
+	class DebugHelper : public btIDebugDraw
+	{
+	public:
+
+		DebugHelper(DebugLines* pLines) : m_pLines(pLines) {}
+		~DebugHelper () {}
+
+		void	drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
+		{
+			Ogre::Vector3 a(from.x(), from.y(), from.z());
+			Ogre::Vector3 b(to.x(), to.y(), to.z());
+			m_pLines->addLine(a, b);
+		}
+		void	draw3dText(const btVector3 &,const char *)
+		{
+
+		}
+
+		void	drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)
+		{
+		}
+
+		void	reportErrorWarning(const char* warningString)
+		{
+		}
+
+		void	setDebugMode(int debugMode)
+		{
+		}
+
+		int		getDebugMode() const
+		{
+			return -1;
+		}
+
+	private:
+		DebugLines* m_pLines;
+	};
+
+	class DebugTriangleDrawCallback : public btTriangleCallback
+	{
+	private:
+
+		DebugHelper     *mDebugHelper;
+		btTransform     mTransform;
+		btVector3		mColor;
+
+	public:
+
+		DebugTriangleDrawCallback(DebugHelper *db, btTransform &bt, const btVector3& color) :
+		  btTriangleCallback(),
+			mDebugHelper(db),
+			mTransform(bt),
+			mColor(color)
+		{
+
+		}
+
+		void processTriangle(btVector3* triangle, int partId, int triangleIndex)
+		{
+			mDebugHelper->drawLine (*triangle,     *(triangle+1), mColor);
+			mDebugHelper->drawLine (*(triangle+1), *(triangle+2), mColor);
+			mDebugHelper->drawLine (*(triangle+2), *triangle,     mColor);
+		}						 
+	};
+
+	class HeightmapCollisionShape : public CollisionShape
+	{
+	public:
+		HeightmapCollisionShape(int width, int length, Ogre::Vector3& scale, Ogre::Real* pHeightData, bool bFlip)
+		{
+			int upIndex = 1;
+			bool useFloatDatam=true;
+			bool flipQuadEdges=bFlip;
+
+			btHeightfieldTerrainShape* pHeightShape = 
+				new btHeightfieldTerrainShape(width, length, pHeightData, scale.y, upIndex, useFloatDatam, flipQuadEdges);
+			pHeightShape->setUseDiamondSubdivision(true);
+
+			mShape = pHeightShape;
+
+			btVector3 sc(scale.x, scale.y, scale.z);
+			mShape->setLocalScaling(sc);
+
+		}
+
+		virtual ~HeightmapCollisionShape()
+		{
+		}
+
+		bool drawWireFrame(DebugLines *wire, 
+			const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+			const Ogre::Quaternion &quat= Ogre::Quaternion::IDENTITY) const
+		{
+			btHeightfieldTerrainShape* pHeightShape = static_cast<btHeightfieldTerrainShape*>(mShape);
+
+			btTransform bt;
+			bt.setIdentity();
+
+			btVector3 colour(255.0, 255.0, 255.0);
+
+			DebugHelper ddraw(wire);
+			DebugTriangleDrawCallback cb(&ddraw, bt, colour);
+
+			btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
+			btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
+			pHeightShape->processAllTriangles(&cb, aabbMin, aabbMax);
+			return true;
+		}
+
+	};
+}
+
+
+#endif // _OGREBULLET_HEIGHTMAP_
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.cpp	(revision 2122)
@@ -0,0 +1,67 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsTriangleShape.h"
+
+#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "Utils/OgreBulletConverter.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    TriangleCollisionShape::TriangleCollisionShape(
+        const Ogre::Vector3 &p1, 
+        const Ogre::Vector3 &p2, 
+        const Ogre::Vector3 &p3):	
+        CollisionShape()
+    {
+            mShape = new btTriangleShape(OgreBtConverter::to(p1), 
+                                         OgreBtConverter::to(p2), 
+                                         OgreBtConverter::to(p3)); 
+    }
+    // -------------------------------------------------------------------------
+    TriangleCollisionShape::TriangleCollisionShape( 
+        Ogre::Real p1X, Ogre::Real p1Y, Ogre::Real p1Z, 
+        Ogre::Real p2X, Ogre::Real p2Y, Ogre::Real p2Z,  
+        Ogre::Real p3X, Ogre::Real p3Y, Ogre::Real p3Z):
+        CollisionShape()
+    {
+        mShape = new btTriangleShape(btVector3(p1X, p1Z, p1Z), 
+                                     btVector3(p2X, p2Y, p2Z), 
+                                     btVector3(p3X, p3Y, p3Z)); 
+    }
+    // -------------------------------------------------------------------------
+    TriangleCollisionShape::~TriangleCollisionShape()
+    {
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.h	(revision 2122)
@@ -0,0 +1,52 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_TriangleShape_H
+#define _OGREBULLETCOLLISIONS_TriangleShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic TriangleShape
+    class TriangleCollisionShape : public CollisionShape
+    {
+    public:
+        TriangleCollisionShape(const Ogre::Vector3 &p1, const Ogre::Vector3 &p2, const Ogre::Vector3 &p3);	
+        TriangleCollisionShape( 
+            Ogre::Real p1X, Ogre::Real p1Y, Ogre::Real p1Z, 
+            Ogre::Real p2X, Ogre::Real p2Y, Ogre::Real p2Z,  
+            Ogre::Real p3X, Ogre::Real p3Y, Ogre::Real p3Z);
+
+	    virtual ~TriangleCollisionShape();
+
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_TriangleShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.cpp	(revision 2122)
@@ -0,0 +1,154 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Shapes/OgreBulletCollisionsTrimeshShape.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    TriangleMeshCollisionShape::TriangleMeshCollisionShape(
+        Vector3        *vertices, 
+        unsigned int vertexCount, 
+        unsigned int *indices, 
+        unsigned int indexCount,
+		bool use32bitsIndices) :	
+        CollisionShape(),
+        mTriMesh(0)
+    {
+		unsigned int numFaces = indexCount / 3;
+
+		mTriMesh = new btTriangleMesh(use32bitsIndices);
+
+        btVector3    vertexPos[3];
+        for (unsigned int n = 0; n < numFaces; ++n)
+        {
+			{
+				const Vector3 &vec = vertices[*indices];
+				vertexPos[0][0] = vec.x;
+				vertexPos[0][1] = vec.y;
+				vertexPos[0][2] = vec.z;
+			}
+			{
+				const Vector3 &vec = vertices[*(indices + 1)];
+				vertexPos[1][0] = vec.x;
+				vertexPos[1][1] = vec.y;
+				vertexPos[1][2] = vec.z;
+			}
+			{
+				const Vector3 &vec = vertices[*(indices + 2)];
+				vertexPos[2][0] = vec.x;
+				vertexPos[2][1] = vec.y;
+				vertexPos[2][2] = vec.z;
+			}
+
+			indices += 3;
+
+            mTriMesh->addTriangle(vertexPos[0], vertexPos[1], vertexPos[2]);
+        }
+
+		const bool useQuantizedAABB = true;
+        mShape = new btBvhTriangleMeshShape(mTriMesh, useQuantizedAABB);
+
+    }
+    // -------------------------------------------------------------------------
+    TriangleMeshCollisionShape::~TriangleMeshCollisionShape()
+    {
+    }
+    // -------------------------------------------------------------------------
+	bool TriangleMeshCollisionShape::drawWireFrame(DebugLines *wire, 
+		const Ogre::Vector3 &pos, 
+		const Ogre::Quaternion &quat) const
+    {
+        const int numTris = mTriMesh->getNumTriangles ();
+        if (numTris > 0)
+        {
+
+			const int numSubParts = mTriMesh->getNumSubParts ();
+			for (int currSubPart = 0; currSubPart < numSubParts; currSubPart++)
+			{
+				const unsigned char* vertexBase = NULL;
+				int numVerts;
+				PHY_ScalarType vertexType;
+				int vertexStride;
+				const unsigned char* indexBase = NULL;
+				int indexStride;
+				int numFaces;
+				PHY_ScalarType indexType;
+
+				mTriMesh->getLockedReadOnlyVertexIndexBase (&vertexBase, numVerts, 
+					vertexType, vertexStride, 
+					&indexBase, indexStride, numFaces, indexType, currSubPart);
+
+				float* p;
+				btVector3 vert0;
+				btVector3 vert1;
+				btVector3 vert2;
+				for (int t = 0; t < numFaces; t++)
+				{
+#define setVector(A, B) {A.setX(B[0]);A.setY(B[1]);A.setZ(B[2]);};
+
+					if (indexType == PHY_SHORT)
+					{
+						short int* index = (short int*)(indexBase + t*indexStride);
+
+						p = (float*)(vertexBase + index[0]*vertexStride);
+						setVector(vert0, p);						
+						p = (float*)(vertexBase + index[1]*vertexStride);
+						setVector(vert1, p);			
+						p = (float*)(vertexBase + index[2]*vertexStride);
+						setVector(vert2, p);		
+					} 
+					else
+					{
+						int* index = (int*)(indexBase + t*indexStride);
+
+						p = (float*)(vertexBase + index[0]*vertexStride);
+						setVector(vert0, p);						
+						p = (float*)(vertexBase + index[1]*vertexStride);
+						setVector(vert1, p);			
+						p = (float*)(vertexBase + index[2]*vertexStride);
+						setVector(vert2, p);		
+					}
+#undef setVector
+
+					wire->addLine (BtOgreConverter::to(vert0), BtOgreConverter::to(vert1));
+					wire->addLine (BtOgreConverter::to(vert1), BtOgreConverter::to(vert2));
+					wire->addLine (BtOgreConverter::to(vert2), BtOgreConverter::to(vert0));
+				}
+			}
+            return true;
+        }
+        return false;
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.h	(revision 2122)
@@ -0,0 +1,53 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETCOLLISIONS_TrimeshShape_H
+#define _OGREBULLETCOLLISIONS_TrimeshShape_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+namespace OgreBulletCollisions
+{
+    // -------------------------------------------------------------------------
+    // basic TrimeshShape
+    class TriangleMeshCollisionShape : public CollisionShape
+    {
+	public:
+		TriangleMeshCollisionShape(Ogre::Vector3 *_vertices, unsigned int _vertex_count, unsigned int *_indices, unsigned int_index_count, bool use32bitsIndices = true);
+	    virtual ~TriangleMeshCollisionShape();
+
+		bool drawWireFrame(DebugLines *wire, 
+			const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+			const Ogre::Quaternion &quat= Ogre::Quaternion::IDENTITY) const;
+
+    private:
+        btTriangleMesh*         mTriMesh;
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_TrimeshShape_H
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.cpp	(revision 2122)
@@ -0,0 +1,782 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletCollisions.h"
+
+#include "Utils/OgreBulletCollisionsMeshToShapeConverter.h"
+
+#include "Shapes/OgreBulletCollisionsTrimeshShape.h"
+#include "Shapes/OgreBulletCollisionsCylinderShape.h"
+#include "Shapes/OgreBulletCollisionsSphereShape.h"
+#include "Shapes/OgreBulletCollisionsBoxShape.h"
+#include "Shapes/OgreBulletCollisionsConvexHullShape.h"
+#include "Shapes/OgreBulletCollisionsCapsuleShape.h"
+
+using namespace OgreBulletCollisions;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+void VertexIndexToShape::addStaticVertexData(const VertexData *vertex_data)
+{
+	if (!vertex_data) 
+        return;
+
+	const VertexData *data = vertex_data;
+
+	const unsigned int prev_size = mVertexCount;
+    mVertexCount += (unsigned int)data->vertexCount;
+
+    Ogre::Vector3* tmp_vert = new Ogre::Vector3[mVertexCount];
+	if (mVertexBuffer)
+	{
+		memcpy(tmp_vert, mVertexBuffer, sizeof(Vector3) * prev_size);
+		delete[] mVertexBuffer;
+	}
+	mVertexBuffer = tmp_vert;
+
+	// Get the positional buffer element
+    {	
+        const Ogre::VertexElement* posElem = data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);			
+        Ogre::HardwareVertexBufferSharedPtr vbuf = data->vertexBufferBinding->getBuffer(posElem->getSource());
+        const unsigned int vSize = (unsigned int)vbuf->getVertexSize();
+
+	    unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
+	    float* pReal;
+        Ogre::Vector3 * curVertices = &mVertexBuffer[prev_size];
+        const unsigned int vertexCount = (unsigned int)data->vertexCount;
+	    for(unsigned int j = 0; j < vertexCount; ++j)
+	    {
+		    posElem->baseVertexPointerToElement(vertex, &pReal);
+            vertex += vSize;
+
+		    curVertices->x = (*pReal++);
+		    curVertices->y = (*pReal++);
+		    curVertices->z = (*pReal++);
+
+		    *curVertices = mTransform * (*curVertices);
+            
+            curVertices++;
+        }
+	    vbuf->unlock();
+    }
+}
+
+//------------------------------------------------------------------------------------------------
+void VertexIndexToShape::addAnimatedVertexData(const Ogre::VertexData *vertex_data,
+											   const Ogre::VertexData *blend_data,
+											   const Ogre::Mesh::IndexMap *indexMap)
+{	
+	// Get the bone index element
+	assert(vertex_data);
+
+	const VertexData *data = blend_data;
+	const unsigned int prev_size = mVertexCount;
+	mVertexCount += (unsigned int)data->vertexCount;
+	Ogre::Vector3* tmp_vert = new Ogre::Vector3[mVertexCount];
+	if (mVertexBuffer)
+	{
+		memcpy(tmp_vert, mVertexBuffer, sizeof(Vector3) * prev_size);
+		delete[] mVertexBuffer;
+	}
+	mVertexBuffer = tmp_vert;
+
+	// Get the positional buffer element
+	{	
+		const Ogre::VertexElement* posElem = data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);	
+		assert (posElem);
+		Ogre::HardwareVertexBufferSharedPtr vbuf = data->vertexBufferBinding->getBuffer(posElem->getSource());
+		const unsigned int vSize = (unsigned int)vbuf->getVertexSize();
+
+		unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
+		float* pReal;
+		Ogre::Vector3 * curVertices = &mVertexBuffer[prev_size];
+		const unsigned int vertexCount = (unsigned int)data->vertexCount;
+		for(unsigned int j = 0; j < vertexCount; ++j)
+		{
+			posElem->baseVertexPointerToElement(vertex, &pReal);
+			vertex += vSize;
+
+			curVertices->x = (*pReal++);
+			curVertices->y = (*pReal++);
+			curVertices->z = (*pReal++);
+
+			*curVertices = mTransform * (*curVertices);
+
+			curVertices++;
+		}
+		vbuf->unlock();
+	}
+	{
+		const Ogre::VertexElement* bneElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_BLEND_INDICES);
+		assert (bneElem);
+		
+		Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(bneElem->getSource());
+		const unsigned int vSize = (unsigned int)vbuf->getVertexSize();
+		unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
+
+		unsigned char* pBone;
+
+		if (!mBoneIndex)
+			mBoneIndex = new BoneIndex();	
+		BoneIndex::iterator i;
+
+		Ogre::Vector3 * curVertices = &mVertexBuffer[prev_size];
+
+		const unsigned int vertexCount = (unsigned int)vertex_data->vertexCount;
+		for(unsigned int j = 0; j < vertexCount; ++j)
+		{
+			bneElem->baseVertexPointerToElement(vertex, &pBone);
+			vertex += vSize;
+
+			const unsigned char currBone = (indexMap) ? (*indexMap)[*pBone] : *pBone;
+			i = mBoneIndex->find (currBone);
+			Vector3Array* l = 0;
+			if (i == mBoneIndex->end())
+			{
+				l = new Vector3Array;
+				mBoneIndex->insert(BoneKeyIndex(currBone, l));
+			}						
+			else 
+			{
+				l = i->second;
+			}
+
+			l->push_back(*curVertices);
+
+			curVertices++;
+		}
+		vbuf->unlock();	
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void VertexIndexToShape::addIndexData(IndexData *data, const unsigned int offset)
+{
+    const unsigned int prev_size = mIndexCount;
+    mIndexCount += (unsigned int)data->indexCount;
+
+	unsigned int* tmp_ind = new unsigned int[mIndexCount];
+	if (mIndexBuffer)
+	{
+		memcpy (tmp_ind, mIndexBuffer, sizeof(unsigned int) * prev_size);
+		delete[] mIndexBuffer;
+	}
+	mIndexBuffer = tmp_ind;
+
+	const unsigned int numTris = (unsigned int) data->indexCount / 3;
+	HardwareIndexBufferSharedPtr ibuf = data->indexBuffer;	
+	const bool use32bitindexes = (ibuf->getType() == HardwareIndexBuffer::IT_32BIT);
+    unsigned int index_offset = prev_size;
+
+	if (use32bitindexes) 
+    {
+        const unsigned int* pInt = static_cast<unsigned int*>(ibuf->lock(HardwareBuffer::HBL_READ_ONLY));
+        for(unsigned int k = 0; k < numTris; ++k)
+        {
+            mIndexBuffer[index_offset ++] = offset + *pInt++;
+            mIndexBuffer[index_offset ++] = offset + *pInt++;
+            mIndexBuffer[index_offset ++] = offset + *pInt++;
+        }
+        ibuf->unlock();
+    }
+	else 
+    {
+        const unsigned short* pShort = static_cast<unsigned short*>(ibuf->lock(HardwareBuffer::HBL_READ_ONLY));
+		for(unsigned int k = 0; k < numTris; ++k)
+        {
+            mIndexBuffer[index_offset ++] = offset + static_cast<unsigned int> (*pShort++);
+            mIndexBuffer[index_offset ++] = offset + static_cast<unsigned int> (*pShort++);
+            mIndexBuffer[index_offset ++] = offset + static_cast<unsigned int> (*pShort++);
+        }
+        ibuf->unlock();
+    }
+
+}
+//------------------------------------------------------------------------------------------------
+Real VertexIndexToShape::getRadius()
+{
+	if (mBoundRadius == (-1))
+	{
+		getSize();
+		mBoundRadius = (std::max(mBounds.x,std::max(mBounds.y,mBounds.z)) * 0.5);
+	}
+	return mBoundRadius;
+}
+//------------------------------------------------------------------------------------------------
+Vector3 VertexIndexToShape::getSize()
+{
+    const unsigned int vCount = getVertexCount();
+	if (mBounds == Ogre::Vector3(-1,-1,-1) && vCount > 0)
+	{
+
+		const Ogre::Vector3 * const v = getVertices();
+
+        Ogre::Vector3 vmin(v[0]);
+        Ogre::Vector3 vmax(v[0]);
+
+		for(unsigned int j = 1; j < vCount; j++)
+		{
+			vmin.x = std::min(vmin.x, v[j].x);
+			vmin.y = std::min(vmin.y, v[j].y);
+			vmin.z = std::min(vmin.z, v[j].z);
+
+			vmax.x = std::max(vmax.x, v[j].x);
+			vmax.y = std::max(vmax.y, v[j].y);
+			vmax.z = std::max(vmax.z, v[j].z);
+		}
+
+		mBounds.x = vmax.x - vmin.x;
+		mBounds.y = vmax.y - vmin.y;
+		mBounds.z = vmax.z - vmin.z;
+	}
+
+	return mBounds;
+}
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3* VertexIndexToShape::getVertices()
+{
+	return mVertexBuffer;
+}
+//------------------------------------------------------------------------------------------------
+unsigned int VertexIndexToShape::getVertexCount()
+{
+	return mVertexCount;
+}
+//------------------------------------------------------------------------------------------------
+const unsigned int* VertexIndexToShape::getIndices()
+{
+	return mIndexBuffer;
+}
+//------------------------------------------------------------------------------------------------
+unsigned int VertexIndexToShape::getIndexCount()
+{
+	return mIndexCount;
+}
+
+//------------------------------------------------------------------------------------------------
+SphereCollisionShape* VertexIndexToShape::createSphere()
+{
+	const Ogre::Real rad = getRadius();
+	assert((rad > 0.0) && 
+        ("Sphere radius must be greater than zero"));
+    SphereCollisionShape* shape = new SphereCollisionShape(rad);
+
+    return shape;
+}
+//------------------------------------------------------------------------------------------------
+BoxCollisionShape* VertexIndexToShape::createBox()
+{
+	const Ogre::Vector3 sz = getSize();
+
+	assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.y > 0.0) && 
+        ("Size of box must be greater than zero on all axes"));
+
+	BoxCollisionShape* shape = new BoxCollisionShape(sz);
+	return shape;
+}
+//------------------------------------------------------------------------------------------------
+CylinderCollisionShape* VertexIndexToShape::createCylinder()
+{
+    const Ogre::Vector3 sz = getSize();
+
+    assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.y > 0.0) && 
+        ("Size of Cylinder must be greater than zero on all axes"));
+
+    CylinderCollisionShape* shape = new CylinderCollisionShape(sz, Vector3::UNIT_X);
+    return shape;
+}
+//------------------------------------------------------------------------------------------------
+ConvexHullCollisionShape* VertexIndexToShape::createConvex()
+{
+    assert(mVertexCount && (mIndexCount >= 6) && 
+        ("Mesh must have some vertices and at least 6 indices (2 triangles)"));
+
+    return new ConvexHullCollisionShape(&mVertexBuffer[0].x, mVertexCount, sizeof(Vector3));
+}
+//------------------------------------------------------------------------------------------------
+TriangleMeshCollisionShape* VertexIndexToShape::createTrimesh()
+{
+	assert(mVertexCount && (mIndexCount >= 6) && 
+        ("Mesh must have some vertices and at least 6 indices (2 triangles)"));
+
+	return new TriangleMeshCollisionShape(mVertexBuffer, mVertexCount,mIndexBuffer, mIndexCount);
+}
+//------------------------------------------------------------------------------------------------
+VertexIndexToShape::~VertexIndexToShape()
+{
+	delete[] mVertexBuffer;
+	delete[] mIndexBuffer;
+
+	if (mBoneIndex)
+	{
+		for(BoneIndex::iterator i = mBoneIndex->begin();
+            i != mBoneIndex->end();
+            ++i)
+		{
+			delete i->second;
+		}
+		delete mBoneIndex;
+	}
+}
+//------------------------------------------------------------------------------------------------
+VertexIndexToShape::VertexIndexToShape(const Matrix4 &transform) :
+	mVertexBuffer (0),
+	mIndexBuffer (0),
+	mVertexCount (0),
+	mIndexCount (0),
+	mBounds (Vector3(-1,-1,-1)),
+	mBoundRadius (-1),
+	mBoneIndex (0),
+	mTransform (transform)
+{	
+}
+//------------------------------------------------------------------------------------------------
+StaticMeshToShapeConverter::StaticMeshToShapeConverter() :
+VertexIndexToShape(),
+	mEntity (0),
+	mNode (0)
+{
+}
+//------------------------------------------------------------------------------------------------
+StaticMeshToShapeConverter::~StaticMeshToShapeConverter()
+{
+}
+//------------------------------------------------------------------------------------------------
+StaticMeshToShapeConverter::StaticMeshToShapeConverter(Entity *entity,  const Matrix4 &transform) :
+	VertexIndexToShape(transform),
+	mEntity (0),
+	mNode (0)
+{
+	addEntity(entity, transform);	
+}
+//------------------------------------------------------------------------------------------------
+StaticMeshToShapeConverter::StaticMeshToShapeConverter(Renderable *rend, const Matrix4 &transform) :
+	VertexIndexToShape(transform),
+	mEntity (0),
+	mNode (0)
+{
+	RenderOperation op;
+	rend->getRenderOperation(op);
+	VertexIndexToShape::addStaticVertexData(op.vertexData);
+	if(op.useIndexes)
+		VertexIndexToShape::addIndexData(op.indexData);
+
+}
+//------------------------------------------------------------------------------------------------
+void StaticMeshToShapeConverter::addEntity(Entity *entity,const Matrix4 &transform)
+{
+	// Each entity added need to reset size and radius
+	// next time getRadius and getSize are asked, they're computed.
+	mBounds  = Ogre::Vector3(-1,-1,-1);
+	mBoundRadius = -1;
+
+	mEntity = entity;
+	mNode = (SceneNode*)(mEntity->getParentNode());
+	mTransform = transform;
+
+	if (mEntity->getMesh()->sharedVertexData)
+	{
+		VertexIndexToShape::addStaticVertexData (mEntity->getMesh()->sharedVertexData);
+	}
+
+	for (unsigned int i = 0;i < mEntity->getNumSubEntities();++i)
+	{
+		SubMesh *sub_mesh = mEntity->getSubEntity(i)->getSubMesh();
+
+		if (!sub_mesh->useSharedVertices)
+		{
+			VertexIndexToShape::addIndexData(sub_mesh->indexData, mVertexCount);
+			VertexIndexToShape::addStaticVertexData (sub_mesh->vertexData);
+		}
+		else 
+		{
+			VertexIndexToShape::addIndexData (sub_mesh->indexData);
+		}
+
+	}
+}
+//------------------------------------------------------------------------------------------------
+void StaticMeshToShapeConverter::addMesh(const MeshPtr &mesh, const Matrix4 &transform)
+{
+	// Each entity added need to reset size and radius
+	// next time getRadius and getSize are asked, they're computed.
+	mBounds  = Ogre::Vector3(-1,-1,-1);
+	mBoundRadius = -1;
+
+	//_entity = entity;
+	//_node = (SceneNode*)(_entity->getParentNode());
+	mTransform = transform;
+
+	if (mesh->hasSkeleton ())
+		Ogre::LogManager::getSingleton().logMessage("MeshToShapeConverter::addMesh : Mesh " + mesh->getName () + " as skeleton but added to trimesh non animated");
+
+	if (mesh->sharedVertexData)
+	{
+		VertexIndexToShape::addStaticVertexData (mesh->sharedVertexData);
+	}
+
+	for(unsigned int i = 0;i < mesh->getNumSubMeshes();++i)
+	{
+		SubMesh *sub_mesh = mesh->getSubMesh(i);
+
+		if (!sub_mesh->useSharedVertices)
+		{
+			VertexIndexToShape::addIndexData(sub_mesh->indexData, mVertexCount);
+			VertexIndexToShape::addStaticVertexData (sub_mesh->vertexData);
+		}
+		else 
+		{
+			VertexIndexToShape::addIndexData (sub_mesh->indexData);
+		}
+
+	}
+}
+//------------------------------------------------------------------------------------------------
+AnimatedMeshToShapeConverter::AnimatedMeshToShapeConverter(Entity *entity,const Matrix4 &transform) :
+VertexIndexToShape(transform),
+mEntity (0),
+mNode (0),
+mTransformedVerticesTemp(0),
+mTransformedVerticesTempSize(0)
+{
+	addEntity(entity, transform);	
+}
+//------------------------------------------------------------------------------------------------
+AnimatedMeshToShapeConverter::AnimatedMeshToShapeConverter() :
+VertexIndexToShape(),
+mEntity (0),
+mNode (0),
+mTransformedVerticesTemp(0),
+mTransformedVerticesTempSize(0)
+{
+}
+//------------------------------------------------------------------------------------------------
+AnimatedMeshToShapeConverter::~AnimatedMeshToShapeConverter()
+{
+	delete[] mTransformedVerticesTemp;
+}
+//------------------------------------------------------------------------------------------------
+void AnimatedMeshToShapeConverter::addEntity(Entity *entity,const Matrix4 &transform)
+{
+	// Each entity added need to reset size and radius
+	// next time getRadius and getSize are asked, they're computed.
+	mBounds  = Ogre::Vector3(-1,-1,-1);
+	mBoundRadius = -1;
+
+	mEntity = entity;
+	mNode = (SceneNode*)(mEntity->getParentNode());
+	mTransform = transform;
+
+	assert (entity->getMesh()->hasSkeleton ());
+
+	mEntity->addSoftwareAnimationRequest(false);
+	mEntity->_updateAnimation();
+
+	if (mEntity->getMesh()->sharedVertexData)
+	{
+		VertexIndexToShape::addAnimatedVertexData (mEntity->getMesh()->sharedVertexData, 
+			mEntity->_getSkelAnimVertexData(),
+			&mEntity->getMesh()->sharedBlendIndexToBoneIndexMap); 
+	}
+
+	for (unsigned int i = 0;i < mEntity->getNumSubEntities();++i)
+	{
+		SubMesh *sub_mesh = mEntity->getSubEntity(i)->getSubMesh();
+
+		if (!sub_mesh->useSharedVertices)
+		{
+			VertexIndexToShape::addIndexData(sub_mesh->indexData, mVertexCount);
+
+			VertexIndexToShape::addAnimatedVertexData (sub_mesh->vertexData, 
+				mEntity->getSubEntity(i)->_getSkelAnimVertexData(),
+				&sub_mesh->blendIndexToBoneIndexMap); 
+		}
+		else 
+		{
+			VertexIndexToShape::addIndexData (sub_mesh->indexData);
+		}
+
+	}
+
+	mEntity->removeSoftwareAnimationRequest(false);
+}
+//------------------------------------------------------------------------------------------------
+void AnimatedMeshToShapeConverter::addMesh(const MeshPtr &mesh, const Matrix4 &transform)
+{
+	// Each entity added need to reset size and radius
+	// next time getRadius and getSize are asked, they're computed.
+	mBounds  = Ogre::Vector3(-1,-1,-1);
+	mBoundRadius = -1;
+
+	//_entity = entity;
+	//_node = (SceneNode*)(_entity->getParentNode());
+	mTransform = transform;
+
+	assert (mesh->hasSkeleton ());
+
+	if (mesh->sharedVertexData)
+	{
+		VertexIndexToShape::addAnimatedVertexData (mesh->sharedVertexData, 
+			0,
+			&mesh->sharedBlendIndexToBoneIndexMap); 
+	}
+
+	for(unsigned int i = 0;i < mesh->getNumSubMeshes();++i)
+	{
+		SubMesh *sub_mesh = mesh->getSubMesh(i);
+
+		if (!sub_mesh->useSharedVertices)
+		{
+			VertexIndexToShape::addIndexData(sub_mesh->indexData, mVertexCount);
+
+			VertexIndexToShape::addAnimatedVertexData (sub_mesh->vertexData, 
+				0,
+				&sub_mesh->blendIndexToBoneIndexMap); 
+		}
+		else 
+		{
+			VertexIndexToShape::addIndexData (sub_mesh->indexData);
+		}
+
+	}
+}
+//------------------------------------------------------------------------------------------------
+bool AnimatedMeshToShapeConverter::getBoneVertices(unsigned char bone, 
+													 unsigned int &vertex_count, 
+													 Ogre::Vector3* &vertices,
+													 const Vector3 &bonePosition)
+{
+	BoneIndex::iterator i = mBoneIndex->find(bone);
+
+	if (i == mBoneIndex->end()) 
+		return false;
+
+	if (i->second->empty()) 
+		return false;
+
+	vertex_count = (unsigned int) i->second->size() + 1;
+	if (vertex_count > mTransformedVerticesTempSize)
+	{	
+		if (mTransformedVerticesTemp)
+			delete[] mTransformedVerticesTemp;
+
+		mTransformedVerticesTemp = new Ogre::Vector3[vertex_count];
+
+	}
+
+	vertices = mTransformedVerticesTemp;
+	vertices[0] = bonePosition;
+	//mEntity->_getParentNodeFullTransform() * 
+	//	mEntity->getSkeleton()->getBone(bone)->_getDerivedPosition();
+
+	//mEntity->getSkeleton()->getBone(bone)->_getDerivedOrientation()
+	unsigned int currBoneVertex = 1;
+	Vector3Array::iterator j = i->second->begin();
+	while(j != i->second->end())
+	{
+		vertices[currBoneVertex] = (*j);
+		++j;
+		++currBoneVertex; 
+	}       
+	return true;
+}
+//------------------------------------------------------------------------------------------------
+BoxCollisionShape* AnimatedMeshToShapeConverter::createAlignedBox(unsigned char bone, 
+																  const Vector3 &bonePosition,
+																  const Quaternion &boneOrientation)
+{
+	unsigned int vertex_count;
+	Vector3* vertices;
+
+	if (!getBoneVertices(bone, vertex_count, vertices, bonePosition)) 
+		return 0;
+
+	Vector3 min_vec(vertices[0]);
+	Vector3 max_vec(vertices[0]);
+
+	for(unsigned int j = 1; j < vertex_count ;j++)
+	{
+		min_vec.x = std::min(min_vec.x,vertices[j].x);
+		min_vec.y = std::min(min_vec.y,vertices[j].y);
+		min_vec.z = std::min(min_vec.z,vertices[j].z);
+
+		max_vec.x = std::max(max_vec.x,vertices[j].x);
+		max_vec.y = std::max(max_vec.y,vertices[j].y);
+		max_vec.z = std::max(max_vec.z,vertices[j].z);
+	}
+	const Ogre::Vector3 maxMinusMin(max_vec - min_vec);
+	BoxCollisionShape* box = new BoxCollisionShape(maxMinusMin);
+
+	const Ogre::Vector3 pos
+		(min_vec.x + (maxMinusMin.x * 0.5),
+		min_vec.y + (maxMinusMin.y * 0.5),
+		min_vec.z + (maxMinusMin.z * 0.5));
+
+	//box->setPosition(pos);
+
+	return box;
+}
+//------------------------------------------------------------------------------------------------
+bool AnimatedMeshToShapeConverter::getOrientedBox(unsigned char bone, 
+					 const Vector3 &bonePosition,
+					 const Quaternion &boneOrientation,
+					 Vector3 &box_afExtent,
+					 Vector3 *box_akAxis,
+					 Vector3 &box_kCenter)
+{
+	unsigned int vertex_count;
+	Vector3* vertices;
+
+	if (!getBoneVertices(bone, vertex_count, vertices, bonePosition))
+		return false;
+
+	 box_kCenter = Vector3::ZERO;
+
+	 {
+		 for(unsigned int c = 0 ;c < vertex_count;c++)
+		 {
+			 box_kCenter += vertices[c];
+		 }
+		 const Ogre::Real invVertexCount = 1.0 / vertex_count;
+		 box_kCenter *= invVertexCount;
+	 }
+	Quaternion orient = boneOrientation;
+	orient.ToAxes(box_akAxis);
+
+
+	// Let C be the box center and let U0, U1, and U2 be the box axes.  Each
+	// input point is of the form X = C + y0*U0 + y1*U1 + y2*U2.  The
+	// following code computes min(y0), max(y0), min(y1), max(y1), min(y2),
+	// and max(y2).  The box center is then adjusted to be
+	//   C' = C + 0.5*(min(y0)+max(y0))*U0 + 0.5*(min(y1)+max(y1))*U1 +
+	//        0.5*(min(y2)+max(y2))*U2
+
+	Ogre::Vector3 kDiff (vertices[1] - box_kCenter);
+	Ogre::Real fY0Min = kDiff.dotProduct(box_akAxis[0]), fY0Max = fY0Min;
+	Ogre::Real fY1Min = kDiff.dotProduct(box_akAxis[1]), fY1Max = fY1Min;
+	Ogre::Real fY2Min = kDiff.dotProduct(box_akAxis[2]), fY2Max = fY2Min;
+
+	for (unsigned int i = 2; i < vertex_count; i++)
+	{
+		kDiff = vertices[i] - box_kCenter;
+
+		const Ogre::Real fY0 = kDiff.dotProduct(box_akAxis[0]);
+		if ( fY0 < fY0Min )
+			fY0Min = fY0;
+		else if ( fY0 > fY0Max )
+			fY0Max = fY0;
+
+		const Ogre::Real fY1 = kDiff.dotProduct(box_akAxis[1]);
+		if ( fY1 < fY1Min )
+			fY1Min = fY1;
+		else if ( fY1 > fY1Max )
+			fY1Max = fY1;
+
+		const Ogre::Real fY2 = kDiff.dotProduct(box_akAxis[2]);
+		if ( fY2 < fY2Min )
+			fY2Min = fY2;
+		else if ( fY2 > fY2Max )
+			fY2Max = fY2;
+	}
+
+	box_afExtent.x = ((Real)0.5)*(fY0Max - fY0Min);
+	box_afExtent.y = ((Real)0.5)*(fY1Max - fY1Min);
+	box_afExtent.z = ((Real)0.5)*(fY2Max - fY2Min);
+
+	box_kCenter += (0.5*(fY0Max+fY0Min))*box_akAxis[0] +
+		(0.5*(fY1Max+fY1Min))*box_akAxis[1] +
+		(0.5*(fY2Max+fY2Min))*box_akAxis[2];
+
+	box_afExtent *= 2.0;
+
+	return true;
+}
+//------------------------------------------------------------------------------------------------
+BoxCollisionShape* AnimatedMeshToShapeConverter::createOrientedBox(unsigned char bone, 
+																   const Vector3 &bonePosition,
+																   const Quaternion &boneOrientation)
+{
+	Ogre::Vector3 box_akAxis[3];
+	Ogre::Vector3 box_afExtent;
+	Ogre::Vector3 box_afCenter;
+
+	if (!getOrientedBox(bone, bonePosition, boneOrientation,
+						box_afExtent,
+						box_akAxis,
+						box_afCenter))
+		return 0;
+
+	BoxCollisionShape *geom = new BoxCollisionShape(box_afExtent);
+	//geom->setOrientation(Quaternion(box_akAxis[0],box_akAxis[1],box_akAxis[2]));
+	//geom->setPosition(box_afCenter);
+	return geom; 
+}
+//------------------------------------------------------------------------------------------------
+CapsuleCollisionShape* AnimatedMeshToShapeConverter::createOrientedCapsuleCollisionShape(unsigned char bone, 
+																							 const Vector3 &bonePosition,
+																							 const Quaternion &boneOrientation)
+{
+	Ogre::Vector3 box_akAxis[3];
+	Ogre::Vector3 box_afExtent;
+	Ogre::Vector3 box_afCenter;
+
+	if (!getOrientedBox(bone,  bonePosition, boneOrientation,
+						box_afExtent,
+						box_akAxis,
+						box_afCenter))
+		return 0;
+
+	// find axes with longest length
+
+	Vector3 cap_dir;    //std::max(box_afExtent.x,std::max(box_afExtent.y,box_afExtent.z));
+	Real cap_dirLength;  //std::max(box_afExtent.x,std::max(box_afExtent.y,box_afExtent.z));
+	Real cap_radius;	 // max axe length
+	if (box_afExtent.x - box_afExtent.y > 0 && box_afExtent.x - box_afExtent.z > 0)
+	{
+		cap_dir = Vector3::UNIT_X;
+		cap_dirLength = box_afExtent.x;
+		cap_radius = std::max (box_afExtent.y, box_afExtent.z);
+	}
+	else if (box_afExtent.y - box_afExtent.x > 0 && box_afExtent.y - box_afExtent.z > 0)
+	{
+		cap_dir = Vector3::UNIT_Y;
+		cap_dirLength = box_afExtent.y;
+		cap_radius = std::max (box_afExtent.x, box_afExtent.z);
+	}
+	else if (box_afExtent.z - box_afExtent.y > 0 && box_afExtent.z - box_afExtent.y > 0)
+	{
+		cap_dir = Vector3::UNIT_Z;
+		cap_dirLength = box_afExtent.z;
+		cap_radius = std::max (box_afExtent.x, box_afExtent.z);
+	}
+
+	CapsuleCollisionShape* geom = new CapsuleCollisionShape(cap_radius, cap_dirLength, cap_dir);
+
+	//geom->setOrientation(orient);
+	//geom->setPosition(cap_orig + (boneOrientation * (cap_dirLength * 0.5)));
+
+	return geom;
+}
Index: /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.h	(revision 2122)
@@ -0,0 +1,155 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OgreBulletCollisionsMeshToShapeConverter_H_
+#define _OgreBulletCollisionsMeshToShapeConverter_H_
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+namespace OgreBulletCollisions 
+{
+	class VertexIndexToShape
+	{
+	public:
+		VertexIndexToShape(const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		~VertexIndexToShape();
+
+		Ogre::Real      getRadius();
+		Ogre::Vector3   getSize();
+
+
+		SphereCollisionShape*           createSphere();
+		BoxCollisionShape*              createBox();
+		TriangleMeshCollisionShape*     createTrimesh();
+		CylinderCollisionShape*         createCylinder();
+		ConvexHullCollisionShape*       createConvex();
+
+
+		const Ogre::Vector3*    getVertices();
+		unsigned int            getVertexCount();
+		const unsigned int*     getIndices();
+		unsigned int            getIndexCount();
+
+	protected:
+
+		void addStaticVertexData(const Ogre::VertexData *vertex_data);
+
+		void addAnimatedVertexData(const Ogre::VertexData *vertex_data, 
+							const Ogre::VertexData *blended_data, 
+							const Ogre::Mesh::IndexMap *indexMap);
+
+		void addIndexData(Ogre::IndexData *data, const unsigned int offset = 0);
+
+	
+	protected:
+		Ogre::Vector3*	    mVertexBuffer;
+		unsigned int*       mIndexBuffer;
+		unsigned int        mVertexCount;
+		unsigned int        mIndexCount;
+
+		Ogre::Matrix4		mTransform;
+
+		Ogre::Real		    mBoundRadius;
+		Ogre::Vector3		mBounds;
+
+		BoneIndex           *mBoneIndex;
+
+	};
+
+	class StaticMeshToShapeConverter : public VertexIndexToShape
+	{
+	public:
+
+		StaticMeshToShapeConverter(Ogre::Renderable *rend, const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		StaticMeshToShapeConverter(Ogre::Entity *entity,   const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		StaticMeshToShapeConverter();
+
+		~StaticMeshToShapeConverter();
+
+		void addEntity(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		
+		void addMesh(const Ogre::MeshPtr &mesh, const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+
+
+	protected:
+
+		Ogre::Entity*		mEntity;
+		Ogre::SceneNode*	mNode;
+
+	};
+
+	class AnimatedMeshToShapeConverter : public VertexIndexToShape
+	{
+	public:
+
+		AnimatedMeshToShapeConverter(Ogre::Entity *entity, const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		AnimatedMeshToShapeConverter();
+		~AnimatedMeshToShapeConverter();
+
+		void addEntity(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		void addMesh(const Ogre::MeshPtr &mesh, const Ogre::Matrix4 &transform);
+
+		BoxCollisionShape* createAlignedBox(unsigned char bone, 
+			const Ogre::Vector3 &bonePosition,
+			const Ogre::Quaternion &boneOrientation);
+
+		BoxCollisionShape* createOrientedBox(unsigned char bone, 
+			const Ogre::Vector3 &bonePosition,
+			const Ogre::Quaternion &boneOrientation);
+
+		CapsuleCollisionShape* createOrientedCapsuleCollisionShape(unsigned char bone, 
+			const Ogre::Vector3 &bonePosition,
+			const Ogre::Quaternion &boneOrientation);
+
+	protected:
+
+		bool getBoneVertices(unsigned char bone, 
+			unsigned int &vertex_count, 
+			Ogre::Vector3* &vertices,
+			const Ogre::Vector3 &bonePosition);
+
+		bool getOrientedBox(unsigned char bone, 
+			const Ogre::Vector3 &bonePosition,
+			const Ogre::Quaternion &boneOrientation,
+			Ogre::Vector3 &extents,
+			Ogre::Vector3 *axis,
+			Ogre::Vector3 &center);
+
+		
+		Ogre::Entity*		mEntity;
+		Ogre::SceneNode*	mNode;
+
+		Ogre::Vector3       *mTransformedVerticesTemp;
+		size_t               mTransformedVerticesTempSize;
+
+	};
+
+}
+
+#endif
+
+
+
+
Index: /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletConverter.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletConverter.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Collisions/Utils/OgreBulletConverter.h	(revision 2122)
@@ -0,0 +1,71 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+#ifndef _OGREBULLETCOLLISIONS_OgreBtConverter_H
+#define _OGREBULLETCOLLISIONS_OgreBtConverter_H
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "OgreVector3.h"
+#include "OgreQuaternion.h"
+
+namespace OgreBulletCollisions
+{
+    class OgreBtConverter
+    {
+    public:
+        OgreBtConverter(){};
+        ~OgreBtConverter(){};
+
+        static btVector3 to(const Ogre::Vector3 &V)
+        {
+            return btVector3(V.x, V.y, V.z);
+        };
+
+        static btQuaternion to(const Ogre::Quaternion &Q)
+        {
+            return btQuaternion(Q.x, Q.y, Q.z, Q.w);
+        };
+
+    };
+    class BtOgreConverter
+    {
+    public:
+        BtOgreConverter(){};
+        ~BtOgreConverter(){};
+
+        static Ogre::Vector3 to(const btVector3 &V)
+        {
+            return Ogre::Vector3(V.x(), V.y(), V.z());
+        };
+
+        static Ogre::Quaternion to(const btQuaternion &Q)
+        {
+            return Ogre::Quaternion(Q.w(), Q.x(), Q.y(), Q.z());
+            //return Ogre::Quaternion(Q.x(), Q.y(), Q.z(), Q[3]);
+        };
+    };
+}
+#endif //_OGREBULLETCOLLISIONS_OgreBtConverter_H
Index: /code/branches/physics/src/ogrebullet/Dynamics/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,16 @@
+SET( OGREBULLET_DYNAMICS_SRC_FILES
+  OgreBulletDynamicsConstraint.cpp
+  OgreBulletDynamicsObjectState.cpp
+  OgreBulletDynamicsRigidBody.cpp
+  OgreBulletDynamicsWorld.cpp
+  
+  Constraints/OgreBulletDynamics6DofConstraint.cpp
+  Constraints/OgreBulletDynamicsConeTwistConstraint.cpp
+  Constraints/OgreBulletDynamicsHingeConstraint.cpp
+  Constraints/OgreBulletDynamicsPoint2pointConstraint.cpp
+  Constraints/OgreBulletDynamicsRaycastVehicle.cpp
+  
+  Prefab/OgreBulletDynamicsRagDoll.cpp
+)
+
+ADD_LIBRARY(ogrebullet_dynamics_orxonox STATIC ${OGREBULLET_DYNAMICS_SRC_FILES})
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.cpp	(revision 2122)
@@ -0,0 +1,91 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsRigidBody.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+#include "Constraints/OgreBulletDynamics6DofConstraint.h"
+
+using namespace Ogre;
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    SixDofConstraint::SixDofConstraint(RigidBody * rbA, RigidBody * rbB, 
+        const Vector3& FrameInAVector3, const Quaternion& FrameInAOrientation,
+        const Vector3& FrameInBVector3, const Quaternion& FrameInBOrientation):
+    TypedConstraint(rbA, rbB)
+    {
+        btTransform frameInA (OgreBulletCollisions::OgreBtConverter::to (FrameInAOrientation), 
+                              OgreBulletCollisions::OgreBtConverter::to (FrameInAVector3));
+        btTransform frameInB (OgreBulletCollisions::OgreBtConverter::to (FrameInBOrientation),
+                              OgreBulletCollisions::OgreBtConverter::to (FrameInBVector3));
+
+        mConstraint = new btGeneric6DofConstraint(
+            *rbA->getBulletRigidBody (),
+            *rbB->getBulletRigidBody (), 
+            frameInA,
+            frameInB,
+			true); // Eric added this because Bullet 2.61 has a new argument (useLinearReferenceFrameA)
+    }
+    // -------------------------------------------------------------------------
+    SixDofConstraint::~SixDofConstraint()
+    {
+	}
+	// -------------------------------------------------------------------------
+	void	 SixDofConstraint::setLinearLowerLimit(const Ogre::Vector3& linearLower)
+	{
+		static_cast<btGeneric6DofConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (linearLower));
+	}
+	// -------------------------------------------------------------------------
+	void	 SixDofConstraint::setLinearUpperLimit(const Ogre::Vector3& linearUpper)
+	{
+		static_cast<btGeneric6DofConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (linearUpper));
+	}
+	// -------------------------------------------------------------------------
+	void	 SixDofConstraint::setAngularLowerLimit(const Ogre::Vector3& angularLower)
+	{
+		static_cast<btGeneric6DofConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (angularLower));
+	}
+	// -------------------------------------------------------------------------
+	void	 SixDofConstraint::setAngularUpperLimit(const Ogre::Vector3& angularUpper)
+	{
+		static_cast<btGeneric6DofConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (angularUpper));
+	}
+	// -------------------------------------------------------------------------
+	void	 SixDofConstraint::setLimit(const int axis, const Ogre::Real lo, const Ogre::Real hi)
+	{
+		static_cast<btGeneric6DofConstraint* > (mConstraint)->setLimit(axis, lo, hi);
+	}
+	// -------------------------------------------------------------------------
+	bool	 SixDofConstraint::isLimited(int limitIndex)
+	{
+		return static_cast<btGeneric6DofConstraint* > (mConstraint)->isLimited(limitIndex);
+	}
+}
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.h	(revision 2122)
@@ -0,0 +1,65 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OGREBULLETDYNAMICS_SixDofConstraint_H
+#define _OGREBULLETDYNAMICS_SixDofConstraint_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    // SixDofConstraint  class
+    class SixDofConstraint : public TypedConstraint
+    {
+    public:
+        SixDofConstraint(RigidBody * rbA, RigidBody * rbB, 
+            const Ogre::Vector3& FrameInAVector, const Ogre::Quaternion& FrameInAOrientation,
+            const Ogre::Vector3& FrameInBVector, const Ogre::Quaternion& FrameInBOrientation);
+
+		void	setLinearLowerLimit(const Ogre::Vector3& linearLower);
+		void	setLinearUpperLimit(const Ogre::Vector3& linearUpper);
+		void	setAngularLowerLimit(const Ogre::Vector3& angularLower);
+		void	setAngularUpperLimit(const Ogre::Vector3& angularUpper);
+
+		void	setLimit(const int axis, const Ogre::Real lo, const Ogre::Real hi);
+		//! Test limit
+		/*!
+		- free means upper < lower,
+		- locked means upper == lower
+		- limited means upper > lower
+		- limitIndex: first 3 are linear, next 3 are angular
+		*/
+		bool	 isLimited(int limitIndex);
+
+        virtual ~SixDofConstraint();
+
+    };
+}
+#endif //_OGREBULLETDYNAMICS_SixDofConstraint_H
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.cpp	(revision 2122)
@@ -0,0 +1,59 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper) For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+    file added by rtti (at) elane2k (dot) com
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GPL General Public License with runtime exception as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+----------------------------------------------------------------------------
+-
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsRigidBody.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+#include "Constraints/OgreBulletDynamicsConeTwistConstraint.h"
+
+using namespace Ogre;
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    ConeTwistConstraint::ConeTwistConstraint(RigidBody * rbA, RigidBody * rbB,
+        const Vector3& FrameInAVector3, const Quaternion& FrameInAOrientation,
+        const Vector3& FrameInBVector3, const Quaternion& FrameInBOrientation):
+    TypedConstraint(rbA, rbB)
+    {
+        btTransform frameInA (OgreBulletCollisions::OgreBtConverter::to(FrameInAOrientation),
+                              OgreBulletCollisions::OgreBtConverter::to(FrameInAVector3));
+        btTransform frameInB (OgreBulletCollisions::OgreBtConverter::to(FrameInBOrientation),
+                              OgreBulletCollisions::OgreBtConverter::to(FrameInBVector3));
+
+        mConstraint = new btConeTwistConstraint(
+            *rbA->getBulletRigidBody (),
+            *rbB->getBulletRigidBody (),
+            frameInA,
+            frameInB);
+    }
+    //-------------------------------------------------------------------------
+    ConeTwistConstraint::~ConeTwistConstraint()
+    {
+    }
+   
+    void ConeTwistConstraint::setLimit(Ogre::Real a, Ogre::Real b, Ogre::Real c)
+    {
+        dynamic_cast<btConeTwistConstraint*>(mConstraint)->setLimit(a,b,c);
+    }
+   
+}
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.h	(revision 2122)
@@ -0,0 +1,43 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper) For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+    file added by rtti (at) elane2k (dot) com
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GPL General Public License with runtime exception as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+----------------------------------------------------------------------------
+-
+*/
+#ifndef _OGREBULLETDYNAMICS_ConeTwistConstraint_H
+#define _OGREBULLETDYNAMICS_ConeTwistConstraint_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+
+
+namespace OgreBulletDynamics
+{
+    //-------------------------------------------------------------------------
+    // ConeTwistConstraint  class
+    class ConeTwistConstraint : public TypedConstraint
+    {
+    public:
+        ConeTwistConstraint(RigidBody * rbA, RigidBody * rbB,
+            const Ogre::Vector3& FrameInAVector, const Ogre::Quaternion& FrameInAOrientation,
+            const Ogre::Vector3& FrameInBVector, const Ogre::Quaternion& FrameInBOrientation);
+
+        virtual ~ConeTwistConstraint();
+       
+        void setLimit(Ogre::Real a, Ogre::Real b, Ogre::Real c);
+
+    };
+}
+#endif //_OGREBULLETDYNAMICS_ConeTwistConstraint_H
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.cpp	(revision 2122)
@@ -0,0 +1,84 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsRigidBody.h"
+#include "OgreBulletDynamicsConstraint.h"
+#include "Constraints/OgreBulletDynamicsHingeConstraint.h"
+
+using namespace Ogre;
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    HingeConstraint::HingeConstraint(RigidBody * rbA, RigidBody * rbB, const Vector3& pivotInA,
+        const Vector3& pivotInB, const Vector3& axisInA, const Vector3& axisInB):
+        TypedConstraint(rbA, rbB)
+    {
+        btVector3 vec[4];
+        vec[0] = OgreBulletCollisions::OgreBtConverter::to(pivotInA);
+        vec[1] = OgreBulletCollisions::OgreBtConverter::to(pivotInB);
+        vec[2] = OgreBulletCollisions::OgreBtConverter::to(axisInA);
+        vec[3] = OgreBulletCollisions::OgreBtConverter::to(axisInB);
+       
+        mConstraint = new btHingeConstraint(
+            *rbA->getBulletRigidBody (),
+            *rbB->getBulletRigidBody (),
+            vec[0], vec[1], vec[2], vec[3]);
+/*
+        mConstraint = new btHingeConstraint(
+            *rbA->getBulletRigidBody (),
+            *rbB->getBulletRigidBody (), 
+            OgreBulletCollisions::OgreBtConverter::to(pivotInA),
+            OgreBulletCollisions::OgreBtConverter::to(pivotInB), 
+            OgreBulletCollisions::OgreBtConverter::to(axisInA), 
+            OgreBulletCollisions::OgreBtConverter::to(axisInB));*/
+    }
+    // -------------------------------------------------------------------------
+        HingeConstraint::HingeConstraint(RigidBody * rbA, 
+            const Vector3& pivotInA, 
+            const Vector3&  axisInA):
+    TypedConstraint(rbA)
+    {
+        btVector3 vec[2];
+        vec[0] = OgreBulletCollisions::OgreBtConverter::to(pivotInA);
+        vec[1] = OgreBulletCollisions::OgreBtConverter::to(axisInA);
+
+        mConstraint = new btHingeConstraint(*rbA->getBulletRigidBody (),
+            vec[0], vec[1]);
+
+/*
+        mConstraint = new btHingeConstraint(*rbA->getBulletRigidBody (),
+            OgreBulletCollisions::OgreBtConverter::to(pivotInA),
+            OgreBulletCollisions::OgreBtConverter::to(axisInA));*/
+    }
+    // -------------------------------------------------------------------------
+    HingeConstraint::~HingeConstraint()
+    {
+    }
+}
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.h	(revision 2122)
@@ -0,0 +1,57 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OGREBULLETDYNAMICS_HingeConstraint_H
+#define _OGREBULLETDYNAMICS_HingeConstraint_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    // HingeConstraint  class
+    class HingeConstraint : public TypedConstraint
+    {
+    public:
+        HingeConstraint(RigidBody * rbA, 
+                            RigidBody * rbB, 
+                            const Ogre::Vector3& pivotInA,
+                            const Ogre::Vector3& pivotInB, 
+                            const Ogre::Vector3& axisInA, 
+                            const Ogre::Vector3& axisInB);
+        HingeConstraint(RigidBody * rbA, 
+            const Ogre::Vector3& pivotInA, 
+            const Ogre::Vector3&  axisInA);
+
+
+        virtual ~HingeConstraint();
+
+    };
+}
+#endif //_OGREBULLETDYNAMICS_HingeConstraint_H
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.cpp	(revision 2122)
@@ -0,0 +1,81 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsRigidBody.h"
+#include "OgreBulletDynamicsConstraint.h"
+#include "Constraints/OgreBulletDynamicsPoint2pointConstraint.h"
+
+using namespace Ogre;
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    PointToPointConstraint::PointToPointConstraint(RigidBody *body, const Vector3 &pivot) :
+        TypedConstraint(body)
+    {
+        mConstraint = new btPoint2PointConstraint(*(body->getBulletRigidBody ()), 
+            OgreBulletCollisions::OgreBtConverter::to(pivot));
+    }
+    // -------------------------------------------------------------------------
+    PointToPointConstraint::~PointToPointConstraint()
+    {
+    }
+    // -------------------------------------------------------------------------
+    void	PointToPointConstraint::setPivotA(const Ogre::Vector3& pivotA)
+    {
+        getBulletPoint2PointConstraint()->setPivotA(
+            OgreBulletCollisions::OgreBtConverter::to(pivotA));
+    }
+    // -------------------------------------------------------------------------
+    void	PointToPointConstraint::setPivotB(const Ogre::Vector3& pivotB)
+    {
+        getBulletPoint2PointConstraint()->setPivotB(
+            OgreBulletCollisions::OgreBtConverter::to(pivotB));
+    }
+    // -------------------------------------------------------------------------
+    void PointToPointConstraint::setTau (float tau) 
+    {
+        getBulletPoint2PointConstraint()->m_setting.m_tau = tau;
+    };
+    // -------------------------------------------------------------------------
+    void PointToPointConstraint::setDamping (float damping) 
+    {
+        getBulletPoint2PointConstraint()->m_setting.m_damping = damping;
+    };
+    // -------------------------------------------------------------------------
+    float PointToPointConstraint::getTau () const 
+    {
+        return getBulletPoint2PointConstraint()->m_setting.m_tau;
+    };
+    // -------------------------------------------------------------------------
+    float PointToPointConstraint::getDamping () const 
+    {
+        return getBulletPoint2PointConstraint()->m_setting.m_damping;
+    };
+}
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.h	(revision 2122)
@@ -0,0 +1,67 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OGREBULLETDYNAMICS_PointTopointConstraint_H
+#define _OGREBULLETDYNAMICS_PointTopointConstraint_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    // PointTopointConstraint  class
+    class PointToPointConstraint : public TypedConstraint
+    {
+    public:
+	    PointToPointConstraint(RigidBody *body, const Ogre::Vector3 &pivot);
+
+	    virtual ~PointToPointConstraint();
+
+        inline btPoint2PointConstraint * getBulletPoint2PointConstraint () const;
+
+        void setTau (float tau);
+        void setDamping (float damping);
+
+        float getTau () const;
+        float getDamping () const;
+
+
+        void	setPivotA(const Ogre::Vector3& pivotA);
+        void	setPivotB(const Ogre::Vector3& pivotB);
+
+    };
+    // -------------------------------------------------------------------------
+    // inline PointTopointConstraint  class methods
+    // -------------------------------------------------------------------------
+    inline btPoint2PointConstraint * PointToPointConstraint::getBulletPoint2PointConstraint () const 
+    {
+        return static_cast <btPoint2PointConstraint *> (mConstraint);
+    }
+}
+#endif //_OGREBULLETDYNAMICS_PointTopointConstraint_H
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.cpp	(revision 2122)
@@ -0,0 +1,183 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsRigidBody.h"
+#include "OgreBulletDynamicsConstraint.h"
+#include "Constraints/OgreBulletDynamicsRaycastVehicle.h"
+
+using namespace Ogre;
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    VehicleRayCaster::VehicleRayCaster(DynamicsWorld *world)
+    {
+        mBulletVehicleRayCaster = new btDefaultVehicleRaycaster(world->getBulletDynamicsWorld ());
+    }
+    // -------------------------------------------------------------------------
+    VehicleRayCaster::~VehicleRayCaster()
+    {
+        delete mBulletVehicleRayCaster;
+    }   
+    // -------------------------------------------------------------------------
+    VehicleTuning::VehicleTuning(const Ogre::Real suspensionStiffness,
+				const Ogre::Real suspensionCompression,
+				const Ogre::Real suspensionDamping,
+				const Ogre::Real maxSuspensionTravelCm,
+				const Ogre::Real frictionSlip)
+    {
+        mBulletTuning = new btRaycastVehicle::btVehicleTuning();
+
+        mBulletTuning->m_suspensionStiffness =  suspensionStiffness;
+        mBulletTuning->m_suspensionCompression = suspensionCompression;
+        mBulletTuning->m_suspensionDamping = suspensionDamping;
+        mBulletTuning->m_maxSuspensionTravelCm = maxSuspensionTravelCm;
+        mBulletTuning->m_frictionSlip = frictionSlip;
+    }
+    // -------------------------------------------------------------------------
+    VehicleTuning::~VehicleTuning()
+    {
+    }
+    // -------------------------------------------------------------------------
+    RaycastVehicle::RaycastVehicle(WheeledRigidBody *body,  
+                                VehicleTuning *vt,
+                                VehicleRayCaster *caster) :
+        TypedConstraint(body),
+        mTuning(vt),
+        mRayCaster(caster)
+    {
+        if (mRayCaster == 0)
+            mRayCaster = new VehicleRayCaster(mWorld);
+
+        btRaycastVehicle *v = new btRaycastVehicle(
+                *(mTuning->getBulletTuning()),
+                body->getBulletRigidBody (), 
+                mRayCaster->getBulletVehicleRayCaster()
+                );
+        mConstraint = v;
+        mWorld->addVehicle(this);
+        body->setVehicle (this);
+    }
+    // -------------------------------------------------------------------------
+    RaycastVehicle::~RaycastVehicle()
+    {
+    }
+    // -------------------------------------------------------------------------
+    void RaycastVehicle::setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex)
+    {
+        getBulletVehicle()->setCoordinateSystem(rightIndex, upIndex, forwardIndex);
+    }
+    // -------------------------------------------------------------------------
+    void RaycastVehicle::addWheel(SceneNode *node,
+                                  const Ogre::Vector3 &connectionPoint,
+                                  const Ogre::Vector3 &wheelDirection,
+                                  const Ogre::Vector3 &wheelAxle,
+
+                                  const Ogre::Real suspensionRestLength,
+                                  const Ogre::Real wheelRadius,
+                                  const bool isFrontWheel,
+                                  
+                                  const Ogre::Real wheelFriction,
+                                  const Ogre::Real rollInfluence)
+    {
+        btRaycastVehicle *v = static_cast<btRaycastVehicle *> (mConstraint);
+
+        mWheelsInfo.push_back (
+            &v->addWheel(OgreBulletCollisions::OgreBtConverter::to(connectionPoint),
+                        OgreBulletCollisions::OgreBtConverter::to(wheelDirection),
+                        OgreBulletCollisions::OgreBtConverter::to(wheelAxle),
+                        suspensionRestLength,
+                        wheelRadius, 
+                        *(mTuning->getBulletTuning ()),
+                        isFrontWheel));
+
+        {
+            const size_t wheelCurrent = mWheelsInfo.size() - 1;
+            mWheelsInfo[wheelCurrent]->m_suspensionStiffness = mTuning->getBulletTuning()->m_suspensionStiffness;
+            mWheelsInfo[wheelCurrent]->m_wheelsDampingRelaxation = mTuning->getBulletTuning()->m_suspensionDamping;
+            mWheelsInfo[wheelCurrent]->m_wheelsDampingCompression = mTuning->getBulletTuning()->m_suspensionCompression;
+
+            mWheelsInfo[wheelCurrent]->m_frictionSlip = wheelFriction;
+            mWheelsInfo[wheelCurrent]->m_rollInfluence = rollInfluence;
+        }
+
+        // create wheel scene Node
+        {
+            node->setPosition (connectionPoint);
+
+            mWheelNodes.push_back ( node);
+            const size_t wheelCurrent = mWheelsInfo.size() - 1;
+
+            //mWheelsInfo[wheelCurrent]->
+        }
+    }
+    // -------------------------------------------------------------------------
+    void RaycastVehicle::setWheelsAttached()
+    {
+        btRaycastVehicle *v = static_cast<btRaycastVehicle *> (mConstraint);
+        for (int i=0; i < v->getNumWheels(); i++)
+        {
+            btWheelInfo& wheel = v->getWheelInfo(i);
+
+            wheel.m_suspensionStiffness = mTuning->getBulletTuning()->m_suspensionStiffness;
+            wheel.m_wheelsDampingRelaxation = mTuning->getBulletTuning()->m_suspensionDamping;
+            wheel.m_wheelsDampingCompression = mTuning->getBulletTuning()->m_suspensionCompression;
+
+            //wheel.m_frictionSlip = mBulletTuning->getBulletTuning()->m_wheelFriction;
+            //wheel.m_rollInfluence = mBulletTuning->getBulletTuning()->m_rollInfluence;
+        }
+    }
+    // -------------------------------------------------------------------------
+    void RaycastVehicle::setTransform()
+    {
+        //should update wheels as well ?
+        for (int i=0; i < getBulletVehicle()->getNumWheels(); i++)
+        {
+            //synchronize the wheels with the (interpolated) chassis world transform
+            getBulletVehicle()->updateWheelTransform(i, true);
+            //draw wheels (cylinders)
+            const btTransform &w = getBulletVehicle()->getWheelInfo(i).m_worldTransform;
+
+            mWheelNodes[i]->setPosition (w.getOrigin()[0], w.getOrigin()[1], w.getOrigin()[2]);
+            mWheelNodes[i]->setOrientation (w.getRotation().getW(), w.getRotation().getX(), w.getRotation().getY(), w.getRotation().getZ());
+
+        }
+    }
+    // -------------------------------------------------------------------------
+    void RaycastVehicle::applyEngineForce (float engineForce, int wheel)
+    {
+        getBulletVehicle()->applyEngineForce (engineForce, wheel);
+    }
+    // -------------------------------------------------------------------------
+    void RaycastVehicle::setSteeringValue(float steering, int wheel)
+    {
+        getBulletVehicle()->setSteeringValue (steering, wheel);
+    }
+    // -------------------------------------------------------------------------
+}
Index: /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.h	(revision 2122)
@@ -0,0 +1,132 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OGREBULLETDYNAMICS_RaycastVehicle_H
+#define _OGREBULLETDYNAMICS_RaycastVehicle_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+
+
+namespace OgreBulletDynamics
+{
+
+    // -------------------------------------------------------------------------
+    // VehicleRayCaster  class
+    class VehicleRayCaster
+    {
+    public:
+        VehicleRayCaster(DynamicsWorld *world);
+        virtual ~VehicleRayCaster();
+        
+        btVehicleRaycaster *getBulletVehicleRayCaster()
+        {return static_cast <btVehicleRaycaster*> (mBulletVehicleRayCaster);};
+         
+    private:
+        btDefaultVehicleRaycaster *mBulletVehicleRayCaster;        
+    };
+    // -------------------------------------------------------------------------
+    // VehicleTuning  class
+    class VehicleTuning
+    {
+    public:
+        VehicleTuning(
+            const Ogre::Real suspensionStiffness,
+            const Ogre::Real suspensionCompression,
+            const Ogre::Real suspensionDamping,
+            const Ogre::Real maxSuspensionTravelCm,
+            const Ogre::Real frictionSlip);
+        virtual ~VehicleTuning();
+        
+        btRaycastVehicle::btVehicleTuning *getBulletTuning()
+        {return mBulletTuning;};
+        
+    private:
+        btRaycastVehicle::btVehicleTuning *mBulletTuning;        
+    };
+    // -------------------------------------------------------------------------
+    // RaycastVehicle  class
+    class WheelInfo
+    {
+    public:
+        WheelInfo(btWheelInfo &w): 
+          mWheel(&w)
+          {};
+        virtual ~WheelInfo(){};
+
+        btWheelInfo *getBulletWheelInfo(){return static_cast<btWheelInfo *> (mWheel);}
+       
+    protected:
+        btWheelInfo                   *mWheel;
+    };
+    // -------------------------------------------------------------------------
+    // RaycastVehicle  class
+    class RaycastVehicle : public TypedConstraint
+    {
+    public:
+        RaycastVehicle(WheeledRigidBody *body,  
+            VehicleTuning        *vt,
+            VehicleRayCaster     *caster = 0);
+
+        virtual ~RaycastVehicle();
+
+        btRaycastVehicle *getBulletVehicle()
+        {return static_cast<btRaycastVehicle *> (mConstraint);};
+        void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex);
+
+        void addWheel(
+            Ogre::SceneNode *node,
+            const Ogre::Vector3 &connectionPoint,
+            const Ogre::Vector3 &wheelDirection,
+            const Ogre::Vector3 &wheelAxle,
+            const Ogre::Real suspensionRestLength,
+            const Ogre::Real wheelRadius,
+            const bool isFrontWheel,
+            const Ogre::Real wheelFriction,
+            const Ogre::Real rollInfluence);
+
+        // when all wheels are attached, make vehicle aware of it
+        void setWheelsAttached();
+        // update wheels when needed.
+        void setTransform();
+
+        void applyEngineForce (float engineForce, int wheel);
+        void setSteeringValue(float steering, int wheel);
+
+     protected:
+         VehicleTuning                   *mTuning;
+         VehicleRayCaster                *mRayCaster;
+    
+         std::vector<btWheelInfo *>         mWheelsInfo;
+         std::vector<Ogre::SceneNode *>      mWheelNodes;
+
+         WheeledRigidBody* mChassisBody;
+         Ogre::SceneNode *mNode;
+         
+    };
+}
+#endif //_OGREBULLETDYNAMICS_RaycastVehicle_H
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamics.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamics.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamics.h	(revision 2122)
@@ -0,0 +1,50 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETDYNAMICS_H
+#define _OGREBULLETDYNAMICS_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#ifdef _PRECOMP
+
+    #include "OgreBulletDynamicsRigidBody.h"
+    #include "OgreBulletDynamicsObjectState.h"
+
+    #include "OgreBulletDynamicsConstraint.h"
+    #include "Constraints/OgreBulletDynamics6DofConstraint.h"
+    #include "Constraints/OgreBulletDynamicsHingeConstraint.h"
+    #include "Constraints/OgreBulletDynamicsPoint2pointConstraint.h"
+	#include "Constraints/OgreBulletDynamicsConeTwistConstraint.h"
+
+	#include "Constraints/OgreBulletDynamicsRaycastVehicle.h"
+	#include "Prefab/OgreBulletDynamicsRagDoll.h"
+
+    #include "OgreBulletDynamicsWorld.h"
+
+#endif //_PRECOMP
+ 
+#endif //_OGREBULLETDYNAMICS_H
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.cpp	(revision 2122)
@@ -0,0 +1,78 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletDynamicsConstraint.h"
+
+#include "OgreBulletDynamicsWorld.h"
+
+#include "OgreBulletDynamicsRigidBody.h"
+
+using namespace Ogre;
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    TypedConstraint::TypedConstraint(DynamicsWorld *world) :
+            mConstraint (0),
+            mWorld (world),
+            mBodyA (0),
+            mBodyB (0)
+    {
+    }
+    // -------------------------------------------------------------------------
+    TypedConstraint::TypedConstraint(RigidBody *bodyA) :
+            mConstraint(0),
+            mWorld(bodyA->getDynamicsWorld()),
+            mBodyA (bodyA),
+            mBodyB (0)
+    {
+            mBodyA = bodyA;
+    }
+    // -------------------------------------------------------------------------
+    TypedConstraint::TypedConstraint(RigidBody *bodyA, RigidBody *bodyB) :
+            mConstraint(0),
+            mWorld(bodyA->getDynamicsWorld()),
+            mBodyA (bodyA),
+            mBodyB (bodyB)
+    {
+        assert (bodyA->getDynamicsWorld() == bodyB->getDynamicsWorld());
+        mBodyA = bodyA;
+        mBodyB = bodyB;
+    }
+    // -------------------------------------------------------------------------
+    TypedConstraint::~TypedConstraint()
+    {
+        if (mConstraint)
+        {
+            assert (mWorld->isConstraintRegistered (this) == false);
+            delete mConstraint;
+        }
+    }
+    // -------------------------------------------------------------------------
+
+}
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.h	(revision 2122)
@@ -0,0 +1,58 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+#ifndef _OGREBULLETDYNAMICS_TypedConstraint_H
+#define _OGREBULLETDYNAMICS_TypedConstraint_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletCollisionsObject.h"
+
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    // basic constraint class
+    class TypedConstraint
+    {
+    public:
+        TypedConstraint(DynamicsWorld *world);
+        TypedConstraint(RigidBody *bodyA);
+        TypedConstraint(RigidBody *bodyA, RigidBody *bodyB);
+
+	    virtual ~TypedConstraint();
+
+
+        inline btTypedConstraint* getBulletTypedConstraint() const {return static_cast <btTypedConstraint*> (mConstraint);};
+
+    protected:
+        btTypedConstraint       *mConstraint;
+
+        DynamicsWorld           *mWorld;
+        RigidBody               *mBodyA;
+        RigidBody               *mBodyB;
+    };
+}
+#endif //_OGREBULLETDYNAMICS_TypedConstraint_H
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.cpp	(revision 2122)
@@ -0,0 +1,65 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletDynamicsObjectState.h"
+#include "OgreBulletDynamicsRigidBody.h"
+
+using namespace Ogre;
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    PhysicState::PhysicState(RigidBody *parent)
+        :	
+      btMotionState(),
+        mObject(parent)
+    {
+    }
+    // -------------------------------------------------------------------------
+    PhysicState::~PhysicState()
+    {
+    }
+    // -------------------------------------------------------------------------
+    void PhysicState::getWorldTransform(btTransform& worldTrans ) const
+    {
+        assert (mObject);
+        
+        worldTrans.setOrigin(OgreBulletCollisions::OgreBtConverter::to(mObject->getWorldPosition()));
+        worldTrans.setRotation(OgreBulletCollisions::OgreBtConverter::to(mObject->getWorldOrientation()));
+        
+    }
+    // -------------------------------------------------------------------------
+    void PhysicState::setWorldTransform(const btTransform& worldTrans)
+    {
+        assert (mObject);
+
+        mObject->setPosition(OgreBulletCollisions::BtOgreConverter::to(worldTrans.getOrigin()));
+        mObject->setOrientation(OgreBulletCollisions::BtOgreConverter::to(worldTrans.getRotation()));
+        
+    }
+}
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.h	(revision 2122)
@@ -0,0 +1,51 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETDYNAMICS_PhysicState_H
+#define _OGREBULLETDYNAMICS_PhysicState_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    // Object transforms
+    class PhysicState : public btMotionState
+    {
+    public:
+	    PhysicState(RigidBody *parent);
+	    ~PhysicState();
+
+	    virtual void getWorldTransform(btTransform& worldTrans ) const;
+	    virtual void setWorldTransform(const btTransform& worldTrans);	
+    
+    protected:
+        RigidBody *mObject;
+    };
+}
+#endif //_OGREBULLETDYNAMICS_PhysicState_H
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsPreRequisites.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsPreRequisites.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsPreRequisites.h	(revision 2122)
@@ -0,0 +1,58 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETDYNAMICS_PREREQUISITES_H
+#define _OGREBULLETDYNAMICS_PREREQUISITES_H
+
+#include "btBulletCollisionCommon.h"
+#include "btBulletDynamicsCommon.h"
+
+#include "Ogre.h"
+#include "OgreBulletCollisions.h"
+
+
+namespace OgreBulletDynamics
+{
+    class RigidBody;
+    class PhysicState;
+    class DynamicsWorld;
+
+    class TypedConstraint;
+    class HingeConstraint;
+    class SixDofConstraint;
+    class PointToPointConstraint;
+	class ConeTwistConstraint;
+
+    class WheeledRigidBody;
+    class VehicleRayCaster;
+    class VehicleTuning;
+    class RaycastVehicle;
+    class WheelInfo;
+
+	class RagDoll;
+}
+
+#endif //_OGREBULLETDYNAMICS_PREREQUISITES_H
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsPrecompiled.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsPrecompiled.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsPrecompiled.cpp	(revision 2122)
@@ -0,0 +1,27 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.cpp	(revision 2122)
@@ -0,0 +1,224 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletCollisionsShape.h"
+#include "OgreBulletCollisionsObject.h"
+#include "OgreBulletCollisionsWorld.h"
+#include "OgreBulletCollisionsObjectState.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsRigidBody.h"
+#include "OgreBulletDynamicsObjectState.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletDynamics
+{
+
+    // -------------------------------------------------------------------------
+    RigidBody::RigidBody(const String &name, DynamicsWorld *world, const short collisionGroup, const short collisionMask)
+        :	
+        Object(name, world, false)
+    {
+		mCollisionGroup = collisionGroup;
+		mCollisionMask = collisionMask;
+    }
+    // -------------------------------------------------------------------------
+    RigidBody::~RigidBody()
+    {
+    }  
+    // -------------------------------------------------------------------------
+    void RigidBody::setShape(Ogre::SceneNode *node,  
+        OgreBulletCollisions::CollisionShape *shape,                          
+        const float      bodyRestitution,
+        const float      bodyFriction,
+        const float      bodyMass,
+        const Vector3 &pos, 
+        const Quaternion &quat)
+    {
+
+        mState = new ObjectState(this);
+
+        mRootNode = node;
+        mShapeNode = mRootNode->createChildSceneNode(mName + "Node");
+        mShapeNode->attachObject(this);
+
+        node->setPosition (pos);
+        node->setOrientation (quat);
+
+        mShape = shape;
+        showDebugShape(mWorld->getShowDebugShapes());
+
+        btVector3 localInertiaTensor = btVector3(0,0,0);
+		if (bodyMass > 0.0)
+	        mShape->getBulletShape ()->calculateLocalInertia(bodyMass, localInertiaTensor);
+
+        btRigidBody *body = new btRigidBody(bodyMass, mState, mShape->getBulletShape (), localInertiaTensor);
+        body->setRestitution(bodyRestitution);
+        body->setFriction(bodyFriction);
+
+        mObject = body;
+
+		getDynamicsWorld()->addRigidBody(this, mCollisionGroup, mCollisionMask);
+    }
+
+    // -------------------------------------------------------------------------
+    void RigidBody::setStaticShape(Ogre::SceneNode *node, 
+        OgreBulletCollisions::CollisionShape *shape,
+        const float      bodyRestitution,
+        const float      bodyFriction,
+        const Vector3 &pos, 
+        const Quaternion &quat)
+    {
+        mState = new ObjectState(this);
+
+        mRootNode = node;
+
+        mShapeNode = mRootNode->createChildSceneNode(mName + "Node");
+        mShapeNode->attachObject(this);
+
+        node->setPosition (pos);
+        node->setOrientation (quat);
+
+        mShape = shape;
+        showDebugShape(mWorld->getShowDebugShapes());
+
+        btRigidBody *body = new btRigidBody(0.0, mState, mShape->getBulletShape ());
+
+        body->setRestitution(bodyRestitution);
+        body->setFriction(bodyFriction);
+
+        body->getWorldTransform().setOrigin(btVector3(pos.x, pos.y, pos.z));
+        body->getWorldTransform().setRotation(btQuaternion(quat.x, quat.y, quat.z, quat.w));
+
+        mObject = body;
+		getDynamicsWorld()->addRigidBody(this, mCollisionGroup, mCollisionMask);
+    }
+    // -------------------------------------------------------------------------
+    void RigidBody::setStaticShape(OgreBulletCollisions::CollisionShape *shape,
+        const float      bodyRestitution,
+        const float      bodyFriction,
+        const Vector3 &pos, 
+        const Quaternion &quat)
+    {
+        //mState = new ObjectState(this);
+
+        mShape = shape;
+        btRigidBody *body = new btRigidBody(0.0, 0, mShape->getBulletShape ());
+
+        body->setRestitution(bodyRestitution);
+        body->setFriction(bodyFriction);
+
+        body->getWorldTransform().setOrigin(btVector3(pos.x, pos.y, pos.z));
+        body->getWorldTransform().setRotation(btQuaternion(quat.x, quat.y, quat.z, quat.w));
+
+        mObject = body;
+		getDynamicsWorld()->addRigidBody(this, mCollisionGroup, mCollisionMask);
+	}
+	// -------------------------------------------------------------------------
+	void RigidBody::setKinematicObject(bool isKinematic) {
+		if (this->isKinematicObject() != isKinematic) {
+			//flip kinematic state
+			getBulletRigidBody()->setCollisionFlags(
+				getBulletRigidBody()->getCollisionFlags() ^ btCollisionObject::CF_KINEMATIC_OBJECT);
+		}
+	} 
+    // -------------------------------------------------------------------------
+    void RigidBody::setLinearVelocity( const Ogre::Vector3 &vel )
+    {
+        getBulletRigidBody()->setLinearVelocity (btVector3(vel.x, vel.y, vel.z));
+    }
+    // -------------------------------------------------------------------------
+    void RigidBody::setLinearVelocity( const Ogre::Real x, const Ogre::Real y, const Ogre::Real z )
+    {
+        getBulletRigidBody()->setLinearVelocity (btVector3(x, y, z));
+    }
+    // -------------------------------------------------------------------------
+	Ogre::Vector3 RigidBody::getLinearVelocity()
+	{
+		const btVector3 lv = getBulletRigidBody()->getLinearVelocity();
+		return BtOgreConverter::to(lv);
+	}
+    // -------------------------------------------------------------------------
+    void RigidBody::applyImpulse( const Ogre::Vector3 &impulse, const Ogre::Vector3 &position )
+    {
+        getBulletRigidBody()->applyImpulse (OgreBtConverter::to(impulse), OgreBtConverter::to(position));
+    }
+    // -------------------------------------------------------------------------
+    void RigidBody::applyForce( const Ogre::Vector3 &impulse, const Ogre::Vector3 &position )
+    {
+        getBulletRigidBody()->applyForce(OgreBtConverter::to(impulse), OgreBtConverter::to(position));
+    }
+    // -------------------------------------------------------------------------
+    Ogre::Vector3 RigidBody::getCenterOfMassPivot( const Ogre::Vector3 &pivotPosition ) const
+    {
+        const btVector3 centerOfMassPivot(getCenterOfMassTransform().inverse()* OgreBtConverter::to(pivotPosition));
+        return BtOgreConverter::to(centerOfMassPivot);
+    }
+    // -------------------------------------------------------------------------
+    void RigidBody::setDeactivationTime( const float ftime )
+    {
+        getBulletRigidBody()->setDeactivationTime( ftime );
+    }
+    // -------------------------------------------------------------------------
+    void RigidBody::setDamping( const Ogre::Real linearDamping, const Ogre::Real angularDamping )
+    {
+        getBulletRigidBody()->setDamping( linearDamping,  angularDamping);
+    }
+    // -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
+    void WheeledRigidBody::setPosition(const btVector3 &pos)
+    { 
+        //should update wheels as well ?
+        mRootNode->setPosition(pos[0], pos[1], pos[2]);
+    };
+    // -------------------------------------------------------------------------
+    void WheeledRigidBody::setOrientation(const btQuaternion &quat)
+    { 
+        mRootNode->setOrientation(quat.getW(),quat.getX(), quat.getY(), quat.getZ());
+    };
+    // -------------------------------------------------------------------------
+    void WheeledRigidBody::setTransform(const btVector3 &pos, const btQuaternion &quat)
+    {
+        mRootNode->setPosition(pos[0], pos[1], pos[2]);
+        mRootNode->setOrientation(quat.getW(),quat.getX(), quat.getY(), quat.getZ());
+
+        mVehicle->setTransform();
+    }
+    // -------------------------------------------------------------------------
+    void WheeledRigidBody::setTransform(const btTransform& worldTrans)
+    { 
+        mRootNode->setPosition(worldTrans.getOrigin()[0], worldTrans.getOrigin()[1],worldTrans.getOrigin()[2]);
+        mRootNode->setOrientation(worldTrans.getRotation().getW(),worldTrans.getRotation().getX(), worldTrans.getRotation().getY(), worldTrans.getRotation().getZ());
+
+        mVehicle->setTransform();
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.h	(revision 2122)
@@ -0,0 +1,197 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETDYNAMICS_RigidObject_H
+#define _OGREBULLETDYNAMICS_RigidObject_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletCollisionsObject.h"
+#include "OgreBulletCollisionsWorld.h"
+#include "Utils/OgreBulletConverter.h"
+
+#include "OgreBulletDynamicsWorld.h"
+
+#include "Constraints/OgreBulletDynamicsRaycastVehicle.h"
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    // basic rigid body class
+    class RigidBody : public OgreBulletCollisions::Object
+    {
+    public:
+	    RigidBody(const Ogre::String &name, 
+				  DynamicsWorld *world,
+				  const short collisionGroup = 0,
+				  const short collisionMask = 0);
+
+	    virtual ~RigidBody();
+
+        void setShape(Ogre::SceneNode *node, 
+            OgreBulletCollisions::CollisionShape *shape,
+            const float      bodyRestitution,
+            const float      bodyFriction,
+            const float      bodyMass,
+            const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+            const Ogre::Quaternion &quat = Ogre::Quaternion::IDENTITY);
+
+        void setStaticShape(Ogre::SceneNode *node,
+            OgreBulletCollisions::CollisionShape *shape,
+            const float      bodyRestitution,
+            const float      bodyFriction,
+            const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+            const Ogre::Quaternion &quat = Ogre::Quaternion::IDENTITY);
+
+        void setStaticShape(OgreBulletCollisions::CollisionShape *shape,
+            const float      bodyRestitution,
+            const float      bodyFriction,
+            const Ogre::Vector3 &pos = Ogre::Vector3::ZERO, 
+            const Ogre::Quaternion &quat = Ogre::Quaternion::IDENTITY);
+
+
+        void setLinearVelocity(const Ogre::Vector3 &vel);
+        void setLinearVelocity(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z);
+		Ogre::Vector3 getLinearVelocity();
+        void applyImpulse(const Ogre::Vector3 &impulse, const Ogre::Vector3 &position);
+        void applyForce(const Ogre::Vector3 &impulse, const Ogre::Vector3 &position);
+
+
+        inline btRigidBody*         getBulletRigidBody() const;
+        inline btDynamicsWorld*     getBulletDynamicsWorld() const;
+        inline DynamicsWorld*       getDynamicsWorld();
+
+        Ogre::SceneNode*  getSceneNode() const {return mRootNode;};
+
+        inline bool isStaticObject() const;
+        inline bool isKinematicObject() const;
+
+		void setKinematicObject(bool isKinematic);
+
+        inline void disableDeactivation();
+        inline void enableActiveState ();
+        inline void forceActivationState();
+        void setDeactivationTime(const float ftime);
+
+        inline const btTransform &getCenterOfMassTransform() const;
+        inline Ogre::Quaternion    getCenterOfMassOrientation () const;
+        inline Ogre::Vector3 getCenterOfMassPosition() const;
+
+        Ogre::Vector3       getCenterOfMassPivot (const Ogre::Vector3 &pivotPosition) const;
+        
+        void setDamping( const Ogre::Real linearDamping, const Ogre::Real angularDamping );
+	protected:
+		short mCollisionGroup;
+		short mCollisionMask;
+    };
+    // -------------------------------------------------------------------------
+    // basic rigid body class
+    class WheeledRigidBody : public RigidBody
+    {
+    public:
+        WheeledRigidBody(const Ogre::String &name, DynamicsWorld *world): 
+            RigidBody(name, world),
+                mVehicle(0)
+        {
+        };
+
+        
+        void setVehicle(RaycastVehicle *v){mVehicle = v;};
+
+       virtual void setPosition(const btVector3 &pos);
+       virtual void setOrientation(const btQuaternion &quat);
+       virtual void setTransform(const btVector3 &pos, const btQuaternion &quat);
+       virtual void setTransform(const btTransform& worldTrans);
+
+        virtual ~WheeledRigidBody(){};
+
+    protected:
+		RaycastVehicle *mVehicle;
+
+    };
+    // -------------------------------------------------------------------------
+    // basic rigid body class inline methods
+    // -------------------------------------------------------------------------
+    inline btRigidBody*  RigidBody::getBulletRigidBody() const 
+    {
+        return static_cast <btRigidBody* > (mObject);
+    };
+    // -------------------------------------------------------------------------
+    inline btDynamicsWorld*     RigidBody::getBulletDynamicsWorld() const 
+    { 
+        return static_cast <btDynamicsWorld * > (mWorld->getBulletCollisionWorld ());
+    };
+    // -------------------------------------------------------------------------
+    inline DynamicsWorld*       RigidBody::getDynamicsWorld() 
+    { 
+        return static_cast <DynamicsWorld* > (mWorld);
+    };
+    // -------------------------------------------------------------------------
+    inline bool RigidBody::isStaticObject() const 
+    {
+        return getBulletRigidBody()->isStaticObject();
+    }
+    // -------------------------------------------------------------------------
+    inline bool RigidBody::isKinematicObject() const 
+    {
+        return getBulletRigidBody()->isKinematicObject();
+    };
+    // -------------------------------------------------------------------------
+    inline void RigidBody::disableDeactivation()
+    {
+        getBulletRigidBody()->setActivationState(DISABLE_DEACTIVATION);
+    }
+    // -------------------------------------------------------------------------
+    inline void RigidBody::enableActiveState()
+    {
+        getBulletRigidBody()->setActivationState(ACTIVE_TAG);
+    }
+    // -------------------------------------------------------------------------
+    inline void RigidBody::forceActivationState()
+    {
+        getBulletRigidBody()->forceActivationState(ACTIVE_TAG);
+    }
+    // -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
+    inline const btTransform &RigidBody::getCenterOfMassTransform() const
+    {
+        return getBulletRigidBody()->getCenterOfMassTransform();
+    }
+    // -------------------------------------------------------------------------
+    inline Ogre::Quaternion RigidBody::getCenterOfMassOrientation() const
+    {
+        return OgreBulletCollisions::BtOgreConverter::to(getCenterOfMassTransform().getRotation ());
+    }
+    // -------------------------------------------------------------------------
+    inline Ogre::Vector3 RigidBody::getCenterOfMassPosition() const
+    {
+        return OgreBulletCollisions::BtOgreConverter::to(getBulletRigidBody()->getCenterOfMassPosition());
+    }
+    // -------------------------------------------------------------------------   
+    
+}
+#endif //_OGREBULLETDYNAMICS_RigidObject_H
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsWorld.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsWorld.cpp	(revision 2122)
@@ -0,0 +1,160 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletCollisionsShape.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsObjectState.h"
+#include "OgreBulletDynamicsRigidBody.h"
+#include "OgreBulletDynamicsConstraint.h"
+
+#include "Constraints/OgreBulletDynamicsRaycastVehicle.h"
+
+#include "BulletCollision/GIMPACT/btGImpactShape.h"
+#include "BulletCollision/GIMPACT/btGImpactCollisionAlgorithm.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletDynamics
+{
+
+    DynamicsWorld::DynamicsWorld(Ogre::SceneManager *mgr, 
+                const Ogre::AxisAlignedBox &bounds,  
+                const Ogre::Vector3 &gravity,
+                bool init) :
+        CollisionsWorld(mgr, bounds, false),
+            mDebugDrawer(0)
+    {
+        //btSequentialImpulseConstraintSolver
+        //btSequentialImpulseConstraintSolver3
+        mConstraintsolver = new btSequentialImpulseConstraintSolver();
+
+        //only if init is true, otherwise you have to create mWorld manually later on
+        if (init) {
+            mWorld = new btDiscreteDynamicsWorld(mDispatcher, mBroadphase, mConstraintsolver, &mDefaultCollisionConfiguration);
+			static_cast <btDiscreteDynamicsWorld *> (mWorld)->setGravity(btVector3(gravity.x,gravity.y,gravity.z));
+
+			btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(mWorld->getDispatcher());
+			btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
+		}
+
+    }
+    // -------------------------------------------------------------------------
+    DynamicsWorld::~DynamicsWorld()
+    {
+        delete mConstraintsolver;
+    }
+
+    // -------------------------------------------------------------------------
+    void DynamicsWorld::addRigidBody (RigidBody *rb, short collisionGroup, short collisionMask)
+    {
+        mObjects.push_back (static_cast <Object *> (rb));
+
+		if (collisionGroup == 0 && collisionMask == 0)
+		{
+			// use default collision group/mask values (dynamic/kinematic/static)
+			static_cast <btDiscreteDynamicsWorld *> (mWorld)->addRigidBody(rb->getBulletRigidBody());      
+		}
+		else
+		{
+			static_cast <btDiscreteDynamicsWorld *> (mWorld)->addRigidBody(rb->getBulletRigidBody(), collisionGroup, collisionMask);      
+		}
+    }
+    // -------------------------------------------------------------------------
+    void DynamicsWorld::stepSimulation(const Ogre::Real elapsedTime, int maxSubSteps, const Ogre::Real fixedTimestep)
+    {
+        // Reset Debug Lines
+        if (mDebugDrawer) 
+            mDebugDrawer->clear ();
+
+        static_cast <btDiscreteDynamicsWorld *> (mWorld)->stepSimulation(elapsedTime, maxSubSteps, fixedTimestep);
+
+        if (mDebugDrawer) 
+        {
+            // draw lines that step Simulation sent.
+            mDebugDrawer->draw();
+
+            const bool drawFeaturesText = (mDebugDrawer->getDebugMode () & btIDebugDraw::DBG_DrawFeaturesText) != 0;
+            if (drawFeaturesText)
+            {
+                // on all bodies we have
+                // we get all shapes and draw more information
+                //depending on mDebugDrawer mode.
+                std::deque<Object*>::iterator it = mObjects.begin();
+                while (it != mObjects.end())
+                {
+                    //(*it)->drawFeaturesText();
+                    ++it;
+                }
+            }
+        }
+    }
+    // -------------------------------------------------------------------------
+    void DynamicsWorld::removeConstraint(TypedConstraint *constraint)
+    {
+        getBulletDynamicsWorld()->removeConstraint(constraint->getBulletTypedConstraint());
+        std::deque <TypedConstraint*>::iterator it = mConstraints.begin();
+        while (it != mConstraints.end())
+        {
+            if ((*it) == constraint)
+            {
+                mConstraints.erase (it);
+                break;
+            }
+            ++it;
+        }
+    }
+    // -------------------------------------------------------------------------
+    void DynamicsWorld::addConstraint(TypedConstraint *constraint)
+    {
+        getBulletDynamicsWorld()->addConstraint(constraint->getBulletTypedConstraint());
+        mConstraints.push_back(constraint);
+    }
+    // -------------------------------------------------------------------------
+    void DynamicsWorld::addVehicle(RaycastVehicle *v)
+    {
+        getBulletDynamicsWorld()->addVehicle(v->getBulletVehicle ());
+        mConstraints.push_back(static_cast <TypedConstraint *> (v));
+
+        //mVehicles.push_back(v);
+    }
+    // -------------------------------------------------------------------------
+    bool DynamicsWorld::isConstraintRegistered(TypedConstraint *constraint) const
+    {
+        std::deque <TypedConstraint*>::const_iterator it = mConstraints.begin();
+        while (it != mConstraints.end())
+        {
+            if ((*it) == constraint)
+                return true;
+            ++it;
+        }
+        return false;
+    }
+}
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsWorld.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsWorld.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/OgreBulletDynamicsWorld.h	(revision 2122)
@@ -0,0 +1,85 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GPL General Public License with runtime exception as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
+
+You should have received a copy of the GPL General Public License with runtime exception along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _OGREBULLETDYNAMICS_DynamicWorld_H
+#define _OGREBULLETDYNAMICS_DynamicWorld_H
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+#include "OgreBulletCollisionsWorld.h"
+#include "Debug/OgreBulletCollisionsDebugDrawer.h"
+
+namespace OgreBulletDynamics
+{
+    // -------------------------------------------------------------------------
+    // basic rigid body class
+    class DynamicsWorld : public OgreBulletCollisions::CollisionsWorld
+    {
+    public:
+        DynamicsWorld(Ogre::SceneManager *mgr, 
+            const Ogre::AxisAlignedBox &bounds,  
+            const Ogre::Vector3 &gravity,
+            bool init = true);
+
+	    ~DynamicsWorld();
+
+        template <class BTDNYWORLDCLASS>
+            void createBtDynamicsWorld(BTDNYWORLDCLASS *&createdWorld)
+            {
+				createdWorld = new BTDNYWORLDCLASS(mDispatcher, mBroadphase, mConstraintsolver, &mDefaultCollisionConfiguration);
+                mWorld = createdWorld;
+            }
+
+        void stepSimulation(const Ogre::Real elapsedTime, int maxSubSteps = 1, const Ogre::Real fixedTimestep = 1./60.);
+
+        void addRigidBody (RigidBody *rb, short collisionGroup, short collisionMask);
+
+        void setDebugDrawer(OgreBulletCollisions::DebugDrawer *debugdrawer)
+        {
+            mDebugDrawer = debugdrawer;
+            (static_cast <btDiscreteDynamicsWorld *> (mWorld))->setDebugDrawer(mDebugDrawer);
+        };
+
+        OgreBulletCollisions::DebugDrawer *getDebugDrawer(){return mDebugDrawer;};
+
+        inline btDynamicsWorld * getBulletDynamicsWorld() const {return static_cast<btDynamicsWorld *> (mWorld);};
+
+        void removeConstraint(TypedConstraint *constraint);
+        void addConstraint(TypedConstraint *constraint);
+        bool isConstraintRegistered(TypedConstraint *constraint) const;
+
+        void addVehicle(RaycastVehicle *v);
+
+    private:
+        OgreBulletCollisions::DebugDrawer                 *mDebugDrawer;
+
+        btConstraintSolver                                *mConstraintsolver;
+
+        std::deque <TypedConstraint *>                    mConstraints;
+    };
+}
+#endif //_OGREBULLETDYNAMICS_DynamicWorld_H
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/Prefab/OgreBulletDynamicsRagDoll.cpp
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Prefab/OgreBulletDynamicsRagDoll.cpp	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Prefab/OgreBulletDynamicsRagDoll.cpp	(revision 2122)
@@ -0,0 +1,151 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#include "OgreBulletDynamics.h"
+
+#include "OgreBulletCollisionsShape.h"
+#include "OgreBulletCollisionsObject.h"
+#include "OgreBulletCollisionsWorld.h"
+#include "OgreBulletCollisionsObjectState.h"
+
+#include "OgreBulletDynamicsWorld.h"
+#include "OgreBulletDynamicsRigidBody.h"
+#include "Prefab/OgreBulletDynamicsRagDoll.h"
+
+using namespace Ogre;
+using namespace OgreBulletCollisions;
+
+namespace OgreBulletDynamics
+{
+
+	// -------------------------------------------------------------------------
+	RagDoll::RagDoll (btDynamicsWorld* ownerWorld, const btVector3& positionOffset)
+		: 
+		m_ownerWorld (ownerWorld)
+	{
+		// Setup all the rigid bodies
+		btTransform offset; offset.setIdentity();
+		offset.setOrigin(positionOffset);
+
+
+		btTransform transform;
+
+		// for
+		{
+			transform.setIdentity();
+			transform.setOrigin(btVector3(btScalar(0.), btScalar(1.), btScalar(0.)));
+			m_bodies.push_back(
+				localCreateRigidBody(btScalar(1.), 
+										offset*transform, 
+										new btCapsuleShape(btScalar(0.15), btScalar(0.20))
+										)
+									);
+		}
+
+		// Setup some damping on the m_bodies
+		for(std::vector<btRigidBody* >::iterator i=m_bodies.begin();
+			i!=m_bodies.end();
+			++i) 
+		{
+			(*i)->setDamping(0.05, 0.85);
+			(*i)->setDeactivationTime(0.8);
+			(*i)->setSleepingThresholds(1.6, 2.5);
+		}
+
+		// Now setup the constraints
+		btHingeConstraint* hingeC;
+		btConeTwistConstraint* coneC;
+		btTransform localA, localB;
+
+		// for
+		{
+			localA.setIdentity(); localB.setIdentity();
+			localA.getBasis().setEulerZYX(0, Ogre::Math::TWO_PI,0); 
+			localA.setOrigin(btVector3(btScalar(0.), btScalar(0.15), btScalar(0.)));
+			localB.getBasis().setEulerZYX(0,Ogre::Math::TWO_PI,0); 
+			localB.setOrigin(btVector3(btScalar(0.), btScalar(-0.15), btScalar(0.)));
+			hingeC =  new btHingeConstraint(*m_bodies[0], *m_bodies[1], 
+				localA, localB);
+			hingeC->setLimit(btScalar(-Ogre::Math::TWO_PI*2), btScalar(Ogre::Math::TWO_PI));
+			m_joints.push_back(hingeC);
+			m_ownerWorld->addConstraint(hingeC, true);
+		}
+
+	}
+    // -------------------------------------------------------------------------
+	RagDoll::~RagDoll ()
+	{
+		std::vector<btCollisionShape* >  m_shapes;
+		std::vector<btRigidBody* >		 m_bodies;
+		std::vector<btTypedConstraint* > m_joints;
+		// Remove all constraints
+		for(std::vector<btTypedConstraint* >::iterator i=m_joints.begin();
+			i!=m_joints.end();
+			++i) 
+		{
+			m_ownerWorld->removeConstraint(*i);
+			delete *i;
+		}
+
+		// Remove all bodies and shapes
+		for(std::vector<btRigidBody* >::iterator i=m_bodies.begin();
+			i!=m_bodies.end();
+			++i) 
+		{
+			m_ownerWorld->removeRigidBody(*i);
+
+			delete (*i)->getMotionState();
+			delete *i;
+		}
+		for(std::vector<btCollisionShape* >::iterator i=m_shapes.begin();
+			i!=m_shapes.end();
+			++i) 
+		{
+			delete *i;
+		}
+	}
+	// -------------------------------------------------------------------------
+	btRigidBody* RagDoll::localCreateRigidBody (btScalar mass, 
+		const btTransform& startTransform, 
+		btCollisionShape* shape)
+	{
+		bool isDynamic = (mass != 0.f);
+
+		btVector3 localInertia(0,0,0);
+		if (isDynamic)
+			shape->calculateLocalInertia(mass,localInertia);
+
+		btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
+
+		btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
+		btRigidBody* body = new btRigidBody(rbInfo);
+
+		m_ownerWorld->addRigidBody(body);
+
+		return body;
+	}
+}
+
Index: /code/branches/physics/src/ogrebullet/Dynamics/Prefab/OgreBulletDynamicsRagDoll.h
===================================================================
--- /code/branches/physics/src/ogrebullet/Dynamics/Prefab/OgreBulletDynamicsRagDoll.h	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Dynamics/Prefab/OgreBulletDynamicsRagDoll.h	(revision 2122)
@@ -0,0 +1,82 @@
+/***************************************************************************
+
+This source file is part of OGREBULLET
+(Object-oriented Graphics Rendering Engine Bullet Wrapper)
+For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
+
+Copyright (c) 2007 tuan.kuranes@gmail.com
+
+
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+
+#ifndef _OGREBULLETCOLLISIONS_RagDoll_H
+#define _OGREBULLETCOLLISIONS_RagDoll_H
+
+
+#include "OgreBulletDynamicsPreRequisites.h"
+
+
+namespace OgreBulletDynamics
+{
+	// -------------------------------------------------------------------------
+	// basic CollisionWorld
+	class RagDoll 
+	{
+	public:
+		RagDoll (btDynamicsWorld* ownerWorld, 
+				const btVector3& positionOffset);
+
+		virtual	~RagDoll ();
+
+		// Make ragdoll  active.
+		void ragdollEnable(bool doEnable);
+		// is ragdoll active.
+		bool isRagdollEnabled();
+
+		// Make constraint between body part active.
+		void constraintEnable(bool value);
+		// are constraint between body part active ?
+		bool isConstraintEnabled();
+
+		// Make it collidable or not.
+		void collisionEnable(bool value);
+		// if shapes can collide
+		bool isCollisionEnabled();
+
+		// Make it fixed in a pose or not.
+		void rigidityEnable(bool value);
+		// is it fixed on a pose?
+		bool isRigidityEnable();
+
+
+	protected:
+		btDynamicsWorld* m_ownerWorld;
+
+		std::vector<btCollisionShape* >  m_shapes;
+		std::vector<btRigidBody* >		 m_bodies;
+		std::vector<btTypedConstraint* > m_joints;
+
+		btRigidBody* localCreateRigidBody (btScalar mass, 
+			const btTransform& startTransform, 
+			btCollisionShape* shape);
+
+	};
+}
+#endif //_OGREBULLETCOLLISIONS_CollisionWorld_H
+
Index: /code/branches/physics/src/ogrebullet/OgreBullet_LGPL.txt
===================================================================
--- /code/branches/physics/src/ogrebullet/OgreBullet_LGPL.txt	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/OgreBullet_LGPL.txt	(revision 2122)
@@ -0,0 +1,514 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
+
Index: /code/branches/physics/src/ogrebullet/OgreBullet_licence.txt
===================================================================
--- /code/branches/physics/src/ogrebullet/OgreBullet_licence.txt	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/OgreBullet_licence.txt	(revision 2122)
@@ -0,0 +1,24 @@
+Licence for OgreBullet
+===================
+
+Copyright 2007 Paul "Tuan Kuranes" Cheyrou-Lagrèze.
+
+This file is part of OgreBullet an integration layer between the OGRE 3D 
+graphics engine and the Bullet physic library.
+
+OgreBullet is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+OgreBullet is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OgreBullet; see the file OgreBullet_LGPL.txt If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+
+
Index: /code/branches/physics/src/ogrebullet/OgreBullet_readme.txt
===================================================================
--- /code/branches/physics/src/ogrebullet/OgreBullet_readme.txt	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/OgreBullet_readme.txt	(revision 2122)
@@ -0,0 +1,69 @@
+Readme for OgreBullet
+==================
+
+Chaster's Changelog: (latest changes at top)
+============================================
+11/8/2007 - added "getLinearVelocity()" function to OgreBullet RigidBody class.
+11/1/2007 - Fix ray in demos and added CollisionClosestRayResultCallback::getCollisionNormal()
+11/1/2007 - added "applyForce()" function to OgreBullet RigidBody class.  Similar to applyImpulse().
+10/29/2007 - added fixes from Dermont for Linux Compiling.
+10/25/2007 - small syntax fix for CollisionClosestRayResultCallback().  Thanks andy
+10/24/2007 - multiple enhancements and fixes:
+		case sensitivity for OSX/Linux compiles, 
+	     	changed default world from btSimpleDynamicsWorld to btDiscreteDynamicsWorld,
+	     	added optional maxSubsteps argument for StepSimulation,
+		added optional CollisionGroup & CollisionMask bitmask arguments to RigidBody constructor,
+		removed OgreBulletCollisionsConvexCast.cpp since it doesn't seem to be used and doesn't compile,
+		added some missing paths for the project so can compile using OgreCVS instead of just OgreSDK,
+		added lib folder hierarchy with "keepme" dummy files so compile doesn't fail,
+		added various small Linux build fixes. 
+
+DOWNLOADED VERSION
+======================
+Brief build instructions follow for OgreBullet 0.2 . 
+
+1) You should have extracted this archive next to $OGRE_TOP, where $OGRE_TOP
+   is the root directory of your Ogre installation, usually named 'ogresdk'.
+   All file paths in this build environment should be relative and all the DLLs
+   and executables should get sent to the correct place upon building.
+
+2) Bullet is available from http://www.Bullet.org/ It requires that you get Latest Bullet version
+ which is actually available only in Bullet subversion repository.
+
+
+5) Use the solution OgreBullet_SDK.sln to build the  OgreBullet library with 
+    Microsoft Visual C++ 2005. The DLLs and executables will be built to the $OGRE_TOP/bin/Debug
+   and Release directories.
+
+   Simply open up that solution and perform a batch build.
+
+6) There are some scripts which should build OgreBullet under Linux in the scripts/Linux
+   directory. They are provided courtesy of Pablo, please see the Readme in that directory
+   for further details.
+
+Post On Ogre Forums for details.
+
+CVS VERSION
+======================
+Brief build instructions follow for OgreBullet CVS Version.
+Chaster (Eric Cha) has done updates to this version.  I (Chaster) will try to keep this readme file
+updated with changes as I go.
+
+1) This version of OgreBullet can be compiled against version 
+   1.4.X branch of the Ogre library aka Eihort, and version 1.5/1.6 (Shoggoth - unreleased!).
+
+2) you need to get Bullet library (version 2.64RC2 as of this writing) using subversion or SDK release. 
+   Bullet download instruction and community is available from http://www.Bullet.org/
+   
+3) you have to set the BULLET_HOME envirronment variable in Windows to the corresponding directory. 
+    If you don't use the one shipped, you'll have to make sure Bullet is compiled against 
+    the DLL version of msvcrt. 
+    Compile with "RunTime Library : Multi-threaded DLL (/MD)" and  "RunTime Library : Multi-threaded Debug DLL (/MDd)"
+
+5) Use the OgreBullet_SDK.sln solution  to build the core OgreBullet library, 
+   with Microsoft Visual C++ 2005. The DLLs and executables will be copied to
+   the ..\OgreSDK\bin\debug and  ..\OgreSDK\bin\release
+
+   Simply open up that solution and perform a batch build.
+
+Post On Ogre Forums for details.
Index: /code/branches/physics/src/ogrebullet/Revision.txt
===================================================================
--- /code/branches/physics/src/ogrebullet/Revision.txt	(revision 2122)
+++ /code/branches/physics/src/ogrebullet/Revision.txt	(revision 2122)
@@ -0,0 +1,3 @@
+This source code was taken from revision
+2493
+of the ogreaddons SVN repositories.
Index: /code/branches/physics/src/ogreode/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/ogreode/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/ogreode/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,22 @@
+SET( OGREODE_SRC_FILES
+  OgreOdeBody.cpp
+  OgreOdeCollision.cpp
+  OgreOdeDebugContact.cpp
+  OgreOdeDebugObject.cpp
+  OgreOdeEigenSolver.cpp
+  OgreOdeEntityInformer.cpp
+  OgreOdeGeometry.cpp
+  OgreOdeJoint.cpp
+  OgreOdeMass.cpp
+  OgreOdeSpace.cpp
+  OgreOdeStepper.cpp
+  OgreOdeTriangleMeshData.cpp
+  OgreOdeTriangleMeshDataManager.cpp
+  OgreOdeUtility.cpp
+  OgreOdeWorld.cpp
+)
+
+ADD_LIBRARY(ogreode_orxonox SHARED ${OGREODE_SRC_FILES})
+
+TARGET_LINK_LIBRARIES(ogreode_orxonox ${ODE_LIBRARIES})
+
Index: /code/branches/physics/src/ogreode/OgreOdeBody.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeBody.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeBody.cpp	(revision 2122)
@@ -0,0 +1,858 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeBody.h"
+
+#include <OgreStringConverter.h>
+#include <OgreSceneManager.h>
+
+#include "OgreOdeWorld.h"
+#include "OgreOdeMass.h"
+#include "OgreOdeDebugObject.h"
+#include "OgreOdeGeometry.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+
+//-----------------------------------------------------------------------
+BodyState::BodyState(const Ogre::Vector3	&position,
+                     const Ogre::Quaternion &orientation)
+{
+    _position = position;
+    _orientation = orientation;	
+}
+//-----------------------------------------------------------------------
+void BodyState::operator=(const BodyState &other)
+{
+    _position = other._position;
+    _orientation = other._orientation;
+}
+//-----------------------------------------------------------------------
+bool BodyState::operator==(const BodyState &other) const
+{
+    return _position == other._position && 
+        _orientation == other._orientation;			
+}
+//-----------------------------------------------------------------------
+bool BodyState::operator!=(const BodyState &other) const
+{
+    return _position != other._position || 
+        _orientation != other._orientation;
+} 
+//-----------------------------------------------------------------------
+/// compare with another physics state for "significant" differences.
+/// used for detecting position or orientation snaps which need smoothing.
+bool BodyState::isDifferent(const BodyState &other, const Ogre::Real threshold) const
+{
+    return (other._position-_position).squaredLength() > threshold || 
+        (other._orientation-_orientation).normalise() > threshold;
+}
+
+//-----------------------------------------------------------------------
+void BodyState::interpolate(const BodyState * const _previous_state, 
+                                   const BodyState * const _current_state, 
+                                   const Ogre::Real alpha)
+{
+    const Ogre::Real timeDiffuseless = Ogre::Real(0.0001);
+    if (alpha - timeDiffuseless < 0) // alpha <= 0
+    {	
+        _position = _current_state->_position;
+        _orientation = _current_state->_orientation;			
+    }
+    else if (alpha - 1 - timeDiffuseless > 0) // alpha >= 1
+    {	
+        _position = _previous_state->_position;
+        _orientation = _previous_state->_orientation;	
+    }
+    else
+#if _DEBUG 
+    if (_previous_state->isDifferent(*_current_state, Ogre::Real(0.01)))
+    {        
+        _position = _current_state->_position*alpha + _previous_state->_position * (1.0f - alpha);
+        _orientation = Ogre::Quaternion::Slerp(alpha, _previous_state->_orientation, _current_state->_orientation, true); //shortest path ?				
+    }
+    else
+    {
+        _position = _previous_state->_position;
+        _orientation = _previous_state->_orientation;
+    }
+#else
+    {
+        _position = _current_state->_position*alpha + _previous_state->_position * (1.0f - alpha);
+        _orientation = Ogre::Quaternion::Slerp(alpha, _previous_state->_orientation, _current_state->_orientation, true); //shortest path ?				
+    }
+#endif
+}
+
+//-----------------------------------------------------------------------
+int Body::_body_count = 0;
+//-----------------------------------------------------------------------
+const Ogre::String Body::MovableType = "OgreOde::Body";
+//-----------------------------------------------------------------------
+Body::Body(World *world, const Ogre::String& name):
+    MovableObject(),
+    //UserDefinedObject(),
+    _name(name), 
+	_modify_parent_orientation(true),
+    _world(world)
+{ 
+	_body_count++;
+	_body = dBodyCreate(_world->getWorldID()); 
+	
+	_debug_node = 0;
+	_mass = new Mass(); 
+
+	dBodySetData(_body,(void*)this);
+	_world->getBodyList().registerItem(this);
+
+	if (_name.empty())
+		_name = MovableType + Ogre::StringConverter::toString(_body_count);
+
+	setDamping (_world->_linear_damping, 
+				_world->_angular_damping);
+	_user_data = 0;
+	
+	_isEnabled = true;
+    _historyResize(_world->getHistorySize());
+    // Tie the physical body to the movable
+    // used when getting physical out of Movables. 
+    this->setUserObject (this);
+
+}
+//-----------------------------------------------------------------------
+void Body::_historyResize(const size_t size)
+{
+	_state_history.resize (size);
+	for (size_t i = 0; i < size; i++)
+	{
+		_state_history.add(new BodyState (_draw_state));
+	}
+}
+//-----------------------------------------------------------------------
+void Body::_notifyAttached(Node* parent,bool isTagPoint)
+{
+    MovableObject::_notifyAttached(parent,isTagPoint);
+    if (parent)
+    {
+        Body* other_body = _world->findBody(static_cast<SceneNode*>(parent));
+        if ((other_body) && (other_body != this))
+        {
+            static_cast<SceneNode*>(parent)->detachObject(other_body);
+
+        }
+
+        setPosition(parent->getPosition());
+        setOrientation(parent->getOrientation());
+    } 
+}
+//-----------------------------------------------------------------------
+void Body::destroyDebugNode()
+{
+	if (_debug_node)
+	{
+		_world->notifyGeometry(this);
+
+        SceneNode* sn = static_cast<SceneNode*>(_debug_node);
+        sn->removeAndDestroyAllChildren ();
+        sn = static_cast<SceneNode*>(_debug_node->getParent());
+        sn->removeAndDestroyChild(_debug_node->getName());
+		_debug_node = 0;
+	}
+}
+
+//-----------------------------------------------------------------------
+void Body::addDebugNode(Node* node)
+{
+	if (!_debug_node)
+	{
+		_debug_node = _world->_manager->getRootSceneNode()->createChild(_name + Ogre::String("_DebugBody"));
+	}
+   
+    _debug_node->addChild(node);
+   
+}
+
+//-----------------------------------------------------------------------
+void Body::setModifyParentOrientation(bool bModify)
+{
+	_modify_parent_orientation = bModify;
+} 
+//-----------------------------------------------------------------------
+void Body::setPosition(const Ogre::Vector3& position)
+{
+	dBodySetPosition(_body,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+
+	_draw_state._position = position;
+	for (size_t i = 0; i < _state_history.size (); i++)
+	{
+		_state_history[i]->_position = position;
+	}
+
+	if (mParentNode) 
+        mParentNode->setPosition(position);
+}
+
+//-----------------------------------------------------------------------
+void Body::setOrientation(const Ogre::Quaternion& orientation)
+{
+	dQuaternion q; 
+	q[0] = (dReal)orientation.w;
+	q[1] = (dReal)orientation.x;
+	q[2] = (dReal)orientation.y;
+	q[3] = (dReal)orientation.z;
+	dBodySetQuaternion(_body,q); 
+
+	_draw_state._orientation = orientation;
+	for (size_t i = 0; i < _state_history.size (); i++)
+	{
+		_state_history[i]->_orientation = orientation;
+	}
+
+	if (mParentNode && _modify_parent_orientation) 
+        mParentNode->setOrientation(orientation);
+}
+
+//-----------------------------------------------------------------------
+void Body::setLinearVelocity(const Ogre::Vector3& linear_velocity)
+{
+	dBodySetLinearVel(_body,(dReal)linear_velocity.x,(dReal)linear_velocity.y,(dReal)linear_velocity.z); 
+}
+
+//-----------------------------------------------------------------------
+void Body::setAngularVelocity(const Ogre::Vector3& angular_velocity)
+{
+	dBodySetAngularVel(_body,(dReal)angular_velocity.x,(dReal)angular_velocity.y,(dReal)angular_velocity.z); 
+}
+
+
+//-----------------------------------------------------------------------
+const Ogre::Vector3& Body::getLinearVelocity()
+{
+	const dReal* linear_velocity = dBodyGetLinearVel(_body); 
+	_linear_vel.x = (Real)linear_velocity[0];
+	_linear_vel.y = (Real)linear_velocity[1];
+	_linear_vel.z = (Real)linear_velocity[2];
+
+	return _linear_vel;
+}
+
+//-----------------------------------------------------------------------
+const Ogre::Vector3& Body::getAngularVelocity()
+{
+	const dReal* angular_velocity = dBodyGetAngularVel(_body); 
+	_angular_vel.x = (Real)angular_velocity[0];
+	_angular_vel.y = (Real)angular_velocity[1];
+	_angular_vel.z = (Real)angular_velocity[2];
+
+	return _angular_vel;
+}
+
+//-----------------------------------------------------------------------
+const Ogre::String& Body::getMovableType() const
+{
+	return MovableType;
+}
+
+//-----------------------------------------------------------------------
+void Body::_notifyCurrentCamera(Camera* camera)
+{
+}
+
+//-----------------------------------------------------------------------
+const AxisAlignedBox& Body::getBoundingBox(void) const
+{
+	return _bounding_box;
+}
+
+//-----------------------------------------------------------------------
+Real Body::getBoundingRadius(void) const
+{
+	return Ogre::Real(0.0);
+}
+//-----------------------------------------------------------------------
+void Body::_updateRenderQueue(RenderQueue* queue)
+{
+}
+//-----------------------------------------------------------------------
+void Body::setMass(const Mass& mass)
+{
+	dBodySetMass(_body,mass.getMassPtr());
+}
+
+//-----------------------------------------------------------------------
+const Mass& Body::getMass()
+{
+	dMass mass;
+	dBodyGetMass(_body,&mass); 
+	*_mass = &mass;
+	return *_mass;
+}
+
+//-----------------------------------------------------------------------
+void Body::addForce(const Ogre::Vector3& force)
+{
+	dBodyAddForce(_body,(dReal)force.x,(dReal)force.y,(dReal)force.z);
+}
+
+//-----------------------------------------------------------------------
+void Body::addTorque(const Ogre::Vector3& torque)
+{
+	dBodyAddTorque(_body,(dReal)torque.x,(dReal)torque.y,(dReal)torque.z);
+}
+
+//-----------------------------------------------------------------------
+void Body::addRelativeForce(const Ogre::Vector3& force)
+{
+	dBodyAddRelForce(_body,(dReal)force.x,(dReal)force.y,(dReal)force.z);
+}
+
+//-----------------------------------------------------------------------
+void Body::addRelativeTorque(const Ogre::Vector3& torque)
+{
+	dBodyAddRelTorque(_body,(dReal)torque.x,(dReal)torque.y,(dReal)torque.z);
+}
+
+//-----------------------------------------------------------------------
+void Body::addForceAt(const Ogre::Vector3& force,const Ogre::Vector3& position)
+{
+	dBodyAddForceAtPos(_body,(dReal)force.x,(dReal)force.y,(dReal)force.z,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+
+//-----------------------------------------------------------------------
+void Body::addForceAtRelative(const Ogre::Vector3& force,const Ogre::Vector3& position)
+{
+	dBodyAddForceAtRelPos(_body,(dReal)force.x,(dReal)force.y,(dReal)force.z,(dReal)position.x,(dReal)position.y,(dReal)position.z);
+}
+//-----------------------------------------------------------------------
+void Body::addRelativeForceAt(const Ogre::Vector3& force,const Ogre::Vector3& position)
+{
+    dBodyAddRelForceAtPos(_body,(dReal)force.x,(dReal)force.y,(dReal)force.z,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+//-----------------------------------------------------------------------
+void Body::addRelativeForceAtRelative(const Ogre::Vector3& force,const Ogre::Vector3& position)
+{
+	dBodyAddRelForceAtRelPos(_body,(dReal)force.x,(dReal)force.y,(dReal)force.z,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+//-----------------------------------------------------------------------
+const Ogre::Vector3& Body::getForce()
+{
+	const dReal* force = dBodyGetForce(_body); 
+	_force.x = force[0];
+	_force.y = force[1];
+	_force.z = force[2];
+
+	return _force;
+}
+//-----------------------------------------------------------------------
+const Ogre::Vector3& Body::getTorque()
+{
+	const dReal* torque = dBodyGetTorque(_body); 
+	_torque.x = torque[0];
+	_torque.y = torque[1];
+	_torque.z = torque[2];
+
+	return _torque;
+}
+//-----------------------------------------------------------------------
+void Body::setForce(const Ogre::Vector3& force)
+{
+    dBodySetForce(_body, (dReal) force.x, (dReal)force.y, (dReal)force.z);
+}
+//-----------------------------------------------------------------------
+void Body::setTorque(const Ogre::Vector3& torque)
+{
+    dBodySetTorque(_body, (dReal) torque.x, (dReal)torque.y, (dReal)torque.z);
+}
+//-----------------------------------------------------------------------
+/*
+Given a point on a body, get that point's position in the world
+*/
+Vector3 Body::getPointWorldPosition(const Ogre::Vector3& position)
+{
+	dVector3 result;
+	dBodyGetRelPointPos(_body,(dReal)position.x,(dReal)position.y,(dReal)position.z,result);
+
+	return Ogre::Vector3(result[0],result[1],result[2]);
+}
+//-----------------------------------------------------------------------
+/*
+Given a point on a body, get that point's velocity in the world
+*/
+Vector3 Body::getPointWorldVelocity(const Ogre::Vector3& position)
+{
+	dVector3 result;
+	dBodyGetRelPointVel(_body,(dReal)position.x,(dReal)position.y,(dReal)position.z,result);
+
+	return Ogre::Vector3(result[0],result[1],result[2]);
+}
+//-----------------------------------------------------------------------
+/*
+Given a point (in the world), get that point's velocity in the world with respect to the body
+i.e. convert the global point to a relative point on the body and compute the velocity of that
+point on the body
+*/
+Vector3 Body::getPointVelocity(const Ogre::Vector3& position)
+{
+	dVector3 result;
+	dBodyGetPointVel(_body,(dReal)position.x,(dReal)position.y,(dReal)position.z,result); 
+
+	return Ogre::Vector3(result[0],result[1],result[2]);
+}
+//-----------------------------------------------------------------------
+Vector3 Body::getPointBodyPosition(const Ogre::Vector3& position)
+{
+	dVector3 result;
+	dBodyGetPosRelPoint(_body,(dReal)position.x,(dReal)position.y,(dReal)position.z,result); 
+
+	return Ogre::Vector3(result[0],result[1],result[2]);
+}
+//-----------------------------------------------------------------------
+Vector3 Body::getVectorToWorld(const Ogre::Vector3& vector)
+{
+	dVector3 result;
+	dBodyVectorToWorld(_body,(dReal)vector.x,(dReal)vector.y,(dReal)vector.z,result);
+
+	return Ogre::Vector3(result[0],result[1],result[2]);
+}
+//-----------------------------------------------------------------------
+Vector3 Body::getVectorFromWorld(const Ogre::Vector3& vector)
+{
+	dVector3 result;
+	dBodyVectorFromWorld(_body,(dReal)vector.x,(dReal)vector.y,(dReal)vector.z,result); 
+
+	return Ogre::Vector3(result[0],result[1],result[2]);
+}
+//-----------------------------------------------------------------------
+void Body::wake()
+{
+	dBodyEnable(_body); 
+	_isEnabled = true;
+}
+//-----------------------------------------------------------------------
+void Body::sleep()
+{
+	dBodyDisable(_body); 
+	_isEnabled = false;
+}
+//-----------------------------------------------------------------------
+void Body::setAutoSleep(bool auto_disable)
+{
+	dBodySetAutoDisableFlag(_body,((auto_disable)?1:0)); 
+}
+//-----------------------------------------------------------------------
+bool Body::getAutoSleep()
+{
+	return ((dBodyGetAutoDisableFlag(_body))?true:false); 
+}
+//-----------------------------------------------------------------------
+void Body::setAutoSleepLinearThreshold(Real linear_threshold)
+{
+	dBodySetAutoDisableLinearThreshold(_body,(dReal)linear_threshold); 
+}
+//-----------------------------------------------------------------------
+Real Body::getAutoSleepLinearThreshold()
+{
+	return (Real)dBodyGetAutoDisableLinearThreshold(_body); 
+}
+//-----------------------------------------------------------------------
+void Body::setAutoSleepAngularThreshold(Real angular_threshold)
+{
+	dBodySetAutoDisableAngularThreshold(_body,(dReal)angular_threshold); 
+}
+//-----------------------------------------------------------------------
+Real Body::getAutoSleepAngularThreshold()
+{
+	return (Real)dBodyGetAutoDisableAngularThreshold(_body); 
+}
+//-----------------------------------------------------------------------
+void Body::setAutoSleepSteps(int steps)
+{
+	dBodySetAutoDisableSteps(_body,steps); 
+}
+//-----------------------------------------------------------------------
+int Body::getAutoSleepSteps()
+{
+	return dBodyGetAutoDisableSteps(_body); 
+}
+//-----------------------------------------------------------------------
+void Body::setAutoSleepTime(Real time)
+{
+	dBodySetAutoDisableTime(_body,(dReal)time); 
+}
+//-----------------------------------------------------------------------
+Real Body::getAutoSleepTime()
+{
+	return (Real)dBodyGetAutoDisableTime(_body); 
+}
+//-----------------------------------------------------------------------
+void Body::setAutoSleepDefaults()
+{
+	dBodySetAutoDisableDefaults(_body);
+}
+//-----------------------------------------------------------------------
+void Body::setFiniteRotationMode(bool on)
+{
+	dBodySetFiniteRotationMode(_body,((on)?1:0)); 
+}
+//-----------------------------------------------------------------------
+bool Body::getFiniteRotationMode()
+{
+	return ((dBodyGetFiniteRotationMode(_body))?true:false); 
+}
+//-----------------------------------------------------------------------
+void Body::setFiniteRotationAxis(const Ogre::Vector3& axis)
+{
+	dBodySetFiniteRotationAxis(_body,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z); 
+}
+//-----------------------------------------------------------------------
+const Ogre::Vector3& Body::getFiniteRotationAxis()
+{
+	dVector3 result;
+	dBodyGetFiniteRotationAxis(_body,result); 
+	_finite_axis.x = result[0];
+	_finite_axis.y = result[1];
+	_finite_axis.z = result[2];
+
+	return _finite_axis;
+}
+//-----------------------------------------------------------------------
+int Body::getJointCount()
+{
+	return dBodyGetNumJoints(_body); 
+}
+//-----------------------------------------------------------------------
+Joint* Body::getJoint(int index)
+{
+	return (Joint*)_world->getJointList().findItem((size_t)dBodyGetJoint(_body,index)); 
+}
+//-----------------------------------------------------------------------
+size_t Body::getGeometryCount()
+{
+    return _geometries.size();
+// 	int rc = 0;
+// 	Geometry* g= 0;
+// 	MaintainedItemIterator<Geometry> it = _world->_geometry_list.getIterator();
+// 	while(!it.end ())
+// 	{
+// 		g = (Geometry*) (it.getNext ());	
+// 		if (this == g->getBody()) 
+//             ++rc;
+// 	}
+// 
+// 	return rc;
+}
+//-----------------------------------------------------------------------
+Geometry* Body::getGeometry(int index)
+{
+    return _geometries[index];
+
+// 	Geometry* rc = 0;
+// 	int idx = 0;
+// 	Geometry* g = 0;
+// 	MaintainedItemIterator<Geometry> it = _world->_geometry_list.getIterator();
+// 	while(!it.end ())
+// 	{
+// 		g = (Geometry*) (it.getNext ());	
+// 		if (this == g->getBody())
+// 		{
+// 			rc = g;
+// 			++idx;
+// 
+// 			if (idx > index) 
+// 				break;
+// 		}
+// 	}
+// 
+// 	return rc;
+}
+GeometryArray* Body::getGeometries()
+{
+    return &_geometries;
+}
+
+//-----------------------------------------------------------------------
+void Body::addGeometry(Geometry *g) 
+{
+    _geometries.push_back(g);
+}
+//-----------------------------------------------------------------------
+void Body::removeGeometry(Geometry *g) 
+{
+    for (GeometryArray::iterator it = _geometries.begin ();
+        it != _geometries.end ();
+        ++it)
+    {
+        if (*it == g)
+        {
+            _geometries.erase (it);
+            return;
+        }
+    }
+}
+//-----------------------------------------------------------------------
+void Body::setAffectedByGravity(bool on)
+{
+	dBodySetGravityMode(_body,((on)?1:0)); 
+}
+//-----------------------------------------------------------------------
+bool Body::getAffectedByGravity()
+{
+	return ((dBodyGetGravityMode(_body))?true:false); 
+}
+//-----------------------------------------------------------------------
+dBodyID Body::getBodyID() const
+{
+	return _body;
+}
+//-----------------------------------------------------------------------
+const Ogre::String& Body::getName(void) const
+{
+	return _name;
+}
+
+//-----------------------------------------------------------------------
+void Body::deriveLocation()
+{
+	if (mParentNode)
+	{
+		setPosition(mParentNode->getPosition());
+		setOrientation(mParentNode->getOrientation());
+	}
+}
+
+//-----------------------------------------------------------------------
+void Body::recursiveSetMode(SceneNode* node)
+{
+	for(unsigned short i = 0;i < node->numChildren();i++)
+	{
+		recursiveSetMode(static_cast<SceneNode*>(node->getChild(i)));		
+	}
+
+	if (_debug_node)
+	{
+		for(unsigned short j = 0;j < node->numAttachedObjects();j++)
+		{
+			static_cast<DebugObject*>(node->getAttachedObject(j))->setMode(
+				(dBodyIsEnabled(_body))?
+				DebugObject::Mode_Enabled
+				:
+				DebugObject::Mode_Disabled);
+		}
+	}
+}
+//-----------------------------------------------------------------------
+void Body::setDamping(Real linear_damping,Real angular_damping)
+{
+	_linear_damping = -(dReal)linear_damping;
+	_is_linear_damped = (_linear_damping < 0.0);
+	_angular_damping = -(dReal)angular_damping;
+	_is_angular_damped = (_angular_damping < 0.0);
+
+	_is_damped = _linear_damping || _is_angular_damped;
+}
+//-----------------------------------------------------------------------
+void Body::setLinearDamping(Real linear_damping)
+{
+	_linear_damping = -(dReal)linear_damping;
+	_is_linear_damped = (_linear_damping < 0.0);
+
+	_is_damped = _linear_damping || _is_angular_damped;
+}
+//-----------------------------------------------------------------------
+void Body::setAngularDamping(Real angular_damping)
+{
+	_angular_damping = -(dReal)angular_damping;
+	_is_angular_damped = (_angular_damping < 0.0);
+
+	_is_damped = _linear_damping || _is_angular_damped;
+}
+//-----------------------------------------------------------------------
+Real Body::getLinearDamping()
+{
+	return -(Real)_linear_damping;
+}
+//-----------------------------------------------------------------------
+Real Body::getAngularDamping()
+{
+	return -(Real)_angular_damping;
+}
+//-----------------------------------------------------------------------
+void Body::applyDamping()
+{
+	assert (_isEnabled && _is_damped);
+	
+	if (_linear_damping)
+	{
+		const dReal * const v = dBodyGetLinearVel(_body);
+		dBodyAddForce(_body, v[0] * _linear_damping, v[1] * _linear_damping, v[2] * _linear_damping);
+	}
+
+	if (_is_angular_damped)
+	{
+		const dReal * const v = dBodyGetAngularVel(_body);
+		dBodyAddTorque(_body, v[0] * _angular_damping, v[1] * _angular_damping, v[2] * _angular_damping);
+	}	
+}
+//-----------------------------------------------------------------------
+void Body::setDebug(const bool debug)
+{
+	destroyDebugNode();
+}
+//-----------------------------------------------------------------------
+void Body::setUserData(size_t user_data)
+{
+	_user_data = user_data;
+}
+//-----------------------------------------------------------------------
+size_t Body::getUserData()
+{
+	return _user_data;
+}
+//-----------------------------------------------------------------------
+size_t Body::getID()
+{
+	return (size_t)_body;
+}
+//-----------------------------------------------------------------------
+Body::~Body()
+{
+	destroyDebugNode();
+	delete _mass;
+
+	_world->getBodyList().unregisterItem((size_t)_body);
+	dBodyDestroy(_body);
+}
+
+//-----------------------------------------------------------------------
+bool Body::collide(void* data, Geometry *otherGeometry)
+{
+    bool collided = false;
+    dContactGeom contactGeom;
+    Geometry *o1;
+    GeometryArray::const_iterator proxy1, proxy1end;
+    proxy1end = _geometries.end();
+
+    //dContact contact;
+    //Real bounce, velThresh, softness;
+
+    //CollisionInfo collInfo;
+
+    // @@TODO : HAS TO HANDLE TransFormedGeometry and GoemtryOffset
+    for (proxy1 = _geometries.begin(); proxy1 != proxy1end; ++proxy1)
+    {
+        o1 = *proxy1;
+        const int numc = dCollide(o1->getGeometryID(), otherGeometry->getGeometryID(), 0, &contactGeom, sizeof(dContactGeom));
+        if (numc)
+        {
+            // Create contact joints if either object is dynamics simulated
+            // If one is not, then sim will not affect it anyway, it will be fixed
+            // However if one is enabled, we need the contact joint
+            if (this->isAwake())
+            {
+                  _world->collisionCallback(data, o1->getGeometryID(), otherGeometry->getGeometryID());
+            }
+
+            // set return 
+            collided = true;
+            
+        }
+    }
+    return collided;
+}
+//-----------------------------------------------------------------------
+bool Body::collide(void* data, Body *otherBody)
+{
+    bool collided = false;
+    dContactGeom contactGeom;
+    Geometry *o1, *o2;
+    GeometryArray::const_iterator proxy1, proxy2, proxy1end, proxy2end;
+    proxy1end = _geometries.end();
+    proxy2end = otherBody->getGeometries()->end();
+
+    //dContact contact;
+    //Real bounce, velThresh, softness;
+
+    //CollisionInfo collInfo;
+
+    // @@TODO : HAS TO HANDLE TransFormedGeometry and GoemtryOffset
+    for (proxy1 = _geometries.begin(); proxy1 != proxy1end; ++proxy1)
+    {
+        for (proxy2 = otherBody->getGeometries()->begin(); proxy2 != proxy2end; ++proxy2)
+        {
+            o1 = *proxy1;
+            o2 = *proxy2;
+            const int numc = dCollide(o1->getGeometryID(), o2->getGeometryID(), 0, &contactGeom, sizeof(dContactGeom));
+            if (numc)
+            {
+                // Create contact joints if either object is dynamics simulated
+                // If one is not, then sim will not affect it anyway, it will be fixed
+                // However if one is enabled, we need the contact joint
+                if (this->isAwake() || otherBody->isAwake())
+                {
+
+                    _world->collisionCallback(data, o1->getGeometryID(), o2->getGeometryID());
+
+                }
+                // set return 
+                collided = true;
+            }
+        }
+    }
+    return collided;
+}
+//-------------------------------------------------------------------------
+bool Body::collidePlaneBounds(void* data, Ogre::SceneQuery::WorldFragment *wf)
+{
+    bool collided = false;
+    dContactGeom contactGeom;
+    Geometry *geom;
+    GeometryArray::const_iterator proxy, proxyend;
+    proxyend = _geometries.end();
+
+    std::list<Ogre::Plane>::const_iterator pi, piend;
+    piend = wf->planes->end();
+
+    //CollisionInfo collInfo;
+
+    // @@TODO : HAS TO HANDLE TransFormedGeometry and GoemtryOffset
+    for (proxy = _geometries.begin(); proxy != proxyend; ++proxy)
+    {
+        // Hack, simply collide against planes which is facing towards center
+        // We can't do this properly without mesh collision
+        geom = *proxy;
+		// Two unused variables
+        //Ogre::Real maxdist = -1.0f;
+        //const Ogre::Plane* bestPlane = 0;
+        for (pi = wf->planes->begin(); pi != piend; ++pi)
+        {
+            const Ogre::Plane * const boundPlane = &(*pi);
+            const Ogre::Real dist = boundPlane->getDistance (this->getPosition());
+            if (dist >= 0.0f)
+            {
+
+                //@@@@ TODO reuse a static InfinitePlaneGeometry ?
+                InfinitePlaneGeometry *sliding_plane = new InfinitePlaneGeometry(*boundPlane, 0);
+
+
+                int numc = dCollide(geom->getGeometryID(), 
+                                    sliding_plane->getGeometryID(), 
+                                    0, 
+                                    &contactGeom, 
+                                    sizeof(dContactGeom));
+                if (numc)
+                {
+                    // Create contact joints if object is dynamics simulated
+                    if (this->isAwake())
+                    {
+                        _world->collisionCallback(data, geom->getGeometryID(), sliding_plane->getGeometryID());
+
+                    }
+                    // set return 
+                    collided = true;
+                }
+            }
+        } 
+
+    }
+    return collided;
+}
+
Index: /code/branches/physics/src/ogreode/OgreOdeBody.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeBody.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeBody.h	(revision 2122)
@@ -0,0 +1,425 @@
+#ifndef _OGREODEBODY_H_
+#define _OGREODEBODY_H_
+
+#include "OgreOdePreReqs.h"
+#include <OgreUserDefinedObject.h>
+#include <OgreMovableObject.h>
+#include <OgreAxisAlignedBox.h>
+#include <OgreSceneQuery.h>
+#include <OgreSceneNode.h>
+
+namespace OgreOde 
+{
+	//-----------------------------------------------------------------------
+	class _OgreOdeExport BodyState
+	{
+	public:
+		BodyState(){};
+		BodyState(const Ogre::Vector3	&position,
+				  const Ogre::Quaternion &orientation);
+
+        void operator=(const BodyState &other);
+		bool operator==(const BodyState &other) const;
+		bool operator!=(const BodyState &other) const;
+
+		//-----------------------------------------------------------------------
+		/// compare with another physics state for "significant" differences.
+		/// used for detecting position or orientation snaps which need smoothing.
+		bool isDifferent(const BodyState &other, const Ogre::Real threshold = Ogre::Real(0.01)) const;
+
+        void interpolate(const BodyState * const _previous_state, 
+                                const BodyState * const _current_state, 
+                                const Ogre::Real alpha);
+
+		Ogre::Vector3		_position;
+		Ogre::Quaternion	_orientation;
+	};
+
+	//-----------------------------------------------------------------------
+	template <class T>
+	class _OgreOdeExport CircularBuffer
+	{
+	public:
+
+		CircularBuffer() :
+			head (0),
+			tail (0)
+		{
+		}
+
+		void resize(const size_t size)
+		{
+			head = 0;
+			tail = 0;
+			buffers.resize(size);
+		}
+
+		size_t size()
+		{
+			int count = (int)head - (int)tail;
+			if (count<0)
+				count += (int) buffers.size();
+			return (size_t) count;
+		}
+
+		void add(const T &buffer)
+		{
+			buffers[head] = buffer;
+			next(head);
+
+		}
+
+		void remove()
+		{
+			assert(!empty());
+			next(tail);
+		}
+
+		T& oldest()
+		{
+			assert(!empty());
+			return buffers[tail];
+		}
+
+		T& newest()
+		{
+			assert(!empty());
+			int index = (int)head - 1;
+			if (index == -1)
+				index = (int) buffers.size() - 1;
+			return buffers[index];
+		}
+
+		T& almostNewest()
+		{
+			assert(buffers.size() > 1);
+			int index = (int)head - 2;
+			if (index == -1)
+				index = (int) buffers.size() - 1;
+			return buffers[index];
+		}
+
+		bool empty() const
+		{
+			return head == tail;
+		}
+
+		void next(size_t &index)
+		{
+			if (index  == (size_t)buffers.size()) 
+				index -= (size_t)buffers.size();
+			else
+				index ++;
+		}
+
+		void previous(size_t &index)
+		{			
+			if ((int)index - 1 < 0)
+				index += (size_t)buffers.size();
+			else
+				index --;
+		}
+
+		T& operator[](size_t index)
+		{
+			assert(index<(size_t)buffers.size());
+			return buffers[index];
+		}
+
+	public:
+
+		size_t head;
+		size_t tail;
+
+	private:
+		std::vector<T> buffers;
+	};
+    /** 
+        This object is the class defining a for all Dynamically physical objects in OgreOde.
+    @remarks
+        This object is tied attached to a scene node, 
+        or/and tied a Entity Object using UserDefinedObject
+    @remarks
+        It extends the OGRE UserDefinedObject to allow reverse links from Ogre::Entity.
+        It extends the OGRE MovableObject to allow scene node attachment.
+    */  
+	class _OgreOdeExport Body : public Ogre::MovableObject, public Ogre::UserDefinedObject
+    {
+		friend class Joint;
+		friend class World;
+		friend class Geometry;
+
+	public:
+		Body(World *world, const Ogre::String& name = Ogre::StringUtil::BLANK);
+		virtual ~Body();
+
+        static const Ogre::String MovableType;
+
+		void _historyResize(const size_t size);
+		inline void updateParentNode();
+		inline void updatePreviousState();
+		inline void updateCurrentState();
+		inline void updateDrawState ();
+		inline void interpolateDrawState(const Ogre::Real alpha);
+		inline void synchronise();
+
+		void deriveLocation();
+
+		void setPosition(const Ogre::Vector3& position); 
+		void setOrientation(const Ogre::Quaternion& orientation); 
+		void setLinearVelocity(const Ogre::Vector3& linear_velocity); 
+		void setAngularVelocity(const Ogre::Vector3& angular_velocity); 
+
+		inline const Ogre::Vector3& getPosition() const;
+
+		inline const Ogre::Quaternion& getOrientation() const;
+		inline void updatePosition(BodyState * const bodystate);
+        inline void updateOrientation(BodyState * const bodystate);
+
+		const Ogre::Vector3& getLinearVelocity(); 
+		const Ogre::Vector3& getAngularVelocity(); 
+
+		virtual const Ogre::String& getMovableType() const; 
+        virtual void _notifyAttached(Ogre::Node* parent,bool isTagPoint = false);
+		virtual const Ogre::String& getName(void) const;
+		virtual void _notifyCurrentCamera(Ogre::Camera* camera);
+		virtual const Ogre::AxisAlignedBox& getBoundingBox(void) const;
+		virtual Ogre::Real getBoundingRadius(void) const;
+        virtual void _updateRenderQueue(Ogre::RenderQueue* queue);
+#if OGRE_VERSION >= ((1 << 16) | (5 << 8))
+		virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false){}
+#endif
+		void setMass(const Mass& mass);
+		const Mass& getMass();
+
+		void addForce(const Ogre::Vector3& force); 
+		void addTorque(const Ogre::Vector3& torque); 
+		void addRelativeForce(const Ogre::Vector3& force); 
+		void addRelativeTorque(const Ogre::Vector3& torque); 
+		void addForceAt(const Ogre::Vector3& force,const Ogre::Vector3& position); 
+		void addForceAtRelative(const Ogre::Vector3& force,const Ogre::Vector3& position); 
+		void addRelativeForceAt(const Ogre::Vector3& force,const Ogre::Vector3& position); 
+		void addRelativeForceAtRelative(const Ogre::Vector3& force,const Ogre::Vector3& position); 
+
+		const Ogre::Vector3& getForce(); 
+        const Ogre::Vector3& getTorque(); 
+        void setForce(const Ogre::Vector3&); 
+        void setTorque(const Ogre::Vector3&); 
+
+
+		Ogre::Vector3 getPointWorldPosition(const Ogre::Vector3& position); 
+		Ogre::Vector3 getPointWorldVelocity(const Ogre::Vector3& position);
+		Ogre::Vector3 getPointVelocity(const Ogre::Vector3& position); 
+		Ogre::Vector3 getPointBodyPosition(const Ogre::Vector3& position);
+		Ogre::Vector3 getVectorToWorld(const Ogre::Vector3& vector);
+		Ogre::Vector3 getVectorFromWorld(const Ogre::Vector3& vector);
+
+		void wake();
+		void sleep(); 
+		inline bool isAwake() const; 
+		void setAutoSleep(bool auto_sleep);
+		bool getAutoSleep(); 
+		void setAutoSleepLinearThreshold(Ogre::Real linear_threshold);
+		Ogre::Real getAutoSleepLinearThreshold(); 
+		void setAutoSleepAngularThreshold(Ogre::Real angular_threshold);
+		Ogre::Real getAutoSleepAngularThreshold(); 
+		void setAutoSleepSteps(int steps);
+		int  getAutoSleepSteps(); 
+		void setAutoSleepTime(Ogre::Real time);
+		Ogre::Real getAutoSleepTime(); 
+		void setAutoSleepDefaults();
+
+		void setFiniteRotationMode(bool on); 
+		bool getFiniteRotationMode(); 
+		void setFiniteRotationAxis(const Ogre::Vector3& axis); 
+		const Ogre::Vector3& getFiniteRotationAxis(); 
+
+        int getJointCount(); 
+		Joint* getJoint(int index); 
+
+		void setModifyParentOrientation(bool bModify);
+
+        void addGeometry(Geometry *g); 
+        void removeGeometry(Geometry *g); 
+        size_t getGeometryCount(); 
+        Geometry* getGeometry(int index);
+        GeometryArray* getGeometries();
+
+		void setAffectedByGravity(bool on);
+		bool getAffectedByGravity(); 
+
+		void setDamping(Ogre::Real linear_damping, Ogre::Real angular_damping);
+		void setLinearDamping(Ogre::Real linear_damping);
+		void setAngularDamping(Ogre::Real angular_damping);
+		Ogre::Real getLinearDamping();
+		Ogre::Real getAngularDamping();
+
+		void setUserData(size_t user_data);
+		size_t getUserData();
+
+		virtual size_t getID();
+		virtual void setDebug(const bool debug);
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+            Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Body");return sName;};
+
+        bool collide(void* data, Geometry *g);
+        bool collide(void* data, Body *b);
+        bool collidePlaneBounds(void* data, Ogre::SceneQuery::WorldFragment *);
+
+	protected:
+		dBodyID getBodyID() const;
+
+		void destroyDebugNode();
+		void addDebugNode(Ogre::Node* node);
+
+		void recursiveSetMode(Ogre::SceneNode* node);
+		
+		void applyDamping();
+
+	protected:
+		dBodyID	_body;
+		Ogre::String _name;
+		Ogre::Node* _debug_node;
+
+		static int _body_count;
+
+		Ogre::Vector3 _linear_vel;
+		Ogre::Vector3 _angular_vel;
+		Ogre::Vector3 _finite_axis;
+		Ogre::Vector3 _force;
+		Ogre::Vector3 _torque;
+		Ogre::AxisAlignedBox _bounding_box;
+		Mass* _mass;
+
+		bool _is_damped;
+		bool _is_linear_damped;
+		dReal _linear_damping;
+		bool _is_angular_damped;
+		dReal _angular_damping;
+
+		size_t _user_data;
+
+		// Major members
+		bool _isEnabled;
+		bool _modify_parent_orientation; 
+
+		BodyState	   _draw_state;
+        CircularBuffer<BodyState *> _state_history;
+
+        /// Collision proxies, must be set up if collision enabled
+        GeometryArray _geometries;
+        
+		World *_world;
+
+	};
+
+    //-----------------------------------------------------------------------
+    inline bool Body::isAwake() const { return _isEnabled; }
+    //-----------------------------------------------------------------------
+    inline void Body::updateParentNode()
+    {
+        if (mParentNode)
+        { 
+            mParentNode->setPosition(_draw_state._position);
+            mParentNode->setOrientation(_draw_state._orientation);
+        }
+
+        if (_debug_node)
+        {
+            _debug_node->setPosition(_draw_state._position);
+            _debug_node->setOrientation(_draw_state._orientation);
+
+            recursiveSetMode(static_cast<Ogre::SceneNode*>(_debug_node));
+        }
+    } 
+    //-----------------------------------------------------------------------
+    inline void Body::updatePreviousState()
+    {
+        _isEnabled = dBodyIsEnabled(_body) || _debug_node;
+        if (_isEnabled)
+        {
+            BodyState *previous = _state_history.almostNewest ();
+            updatePosition (previous);
+            updateOrientation (previous);
+        }
+    }
+    //-----------------------------------------------------------------------
+    inline void Body::updateCurrentState()
+    {
+        _isEnabled = dBodyIsEnabled(_body) || _debug_node;
+        if (_isEnabled)
+        {
+            BodyState *current = _state_history.newest ();
+            updatePosition(current);
+            updateOrientation(current);
+        }
+    }
+    //-----------------------------------------------------------------------
+    inline void Body::updateDrawState ()
+    {
+        _isEnabled = dBodyIsEnabled(_body) || _debug_node;
+        if (_isEnabled)
+        {
+            updatePosition(&_draw_state);
+            updateOrientation(&_draw_state);
+        }
+    }
+    //-----------------------------------------------------------------------
+    inline void Body::interpolateDrawState(const Ogre::Real alpha)
+    {
+        if (_isEnabled)
+        {
+            BodyState *current = _state_history.newest ();
+            BodyState *previous = _state_history.almostNewest ();
+            assert (current != previous);
+            _draw_state.interpolate (previous, current, alpha);
+        }
+    }
+    //-----------------------------------------------------------------------
+    inline void Body::synchronise()
+    {
+        if (_isEnabled)
+        {
+            if (_is_damped)
+                applyDamping();
+            updateParentNode();
+        }
+    }
+    //-----------------------------------------------------------------------
+    inline const Ogre::Vector3& Body::getPosition() const
+    {
+        return _draw_state._position;
+    }
+    //-----------------------------------------------------------------------
+    inline const Ogre::Quaternion& Body::getOrientation() const
+    {
+        return _draw_state._orientation;
+    }
+    //-----------------------------------------------------------------------
+    inline void Body::updatePosition(BodyState * const bodystate)
+    {
+        const dReal * const position = dBodyGetPosition(_body);
+
+        bodystate->_position.x = (Ogre::Real)position[0];
+        bodystate->_position.y = (Ogre::Real)position[1];
+        bodystate->_position.z = (Ogre::Real)position[2];
+    }
+    //-----------------------------------------------------------------------
+    inline void Body::updateOrientation(BodyState * const bodystate)
+    {
+        const dReal * const orientation = dBodyGetQuaternion(_body); 
+        bodystate->_orientation.w = (Ogre::Real)orientation[0];
+        bodystate->_orientation.x = (Ogre::Real)orientation[1];
+        bodystate->_orientation.y = (Ogre::Real)orientation[2];
+        bodystate->_orientation.z = (Ogre::Real)orientation[3];
+    }
+    //-----------------------------------------------------------------------
+}
+
+#endif
+
Index: /code/branches/physics/src/ogreode/OgreOdeCollision.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeCollision.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeCollision.cpp	(revision 2122)
@@ -0,0 +1,323 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeCollision.h"
+
+#include "OgreOdeSpace.h"
+#include "OgreOdeGeometry.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+CollisionListener::CollisionListener()
+{
+}
+//------------------------------------------------------------------------------------------------
+CollisionListener::~CollisionListener()
+{
+}
+
+//------------------------------------------------------------------------------------------------
+CollisionCallback::CollisionCallback()
+{
+}
+
+//------------------------------------------------------------------------------------------------
+CollisionCallback::~CollisionCallback()
+{
+}
+
+//-----------------------------------------------------------------------
+void CollisionCallback::collisionCallback(Space* spaceFirst, Space* spaceSecond)
+{
+	spaceFirst->collide(static_cast<CollisionCallback*>(this), spaceSecond);
+}
+	
+//-----------------------------------------------------------------------
+void CollisionCallback::collisionCallback(Space* space, Geometry* geometry)
+{
+	space->collide(static_cast<CollisionCallback*>(this), geometry);
+}
+	
+//-----------------------------------------------------------------------
+void CollisionCallback::collisionCallback(Space* space)
+{
+	space->collide(static_cast<CollisionCallback*>(this));
+}
+	
+//-----------------------------------------------------------------------
+void CollisionCallback::collisionCallback(Geometry* geometryFirst, Geometry* geometrySecond)
+{
+	geometryFirst->collide(geometrySecond, static_cast<CollisionListener*>(this));
+}
+
+//-----------------------------------------------------------------------
+void CollisionCallback::collisionCallback(void *data, dGeomID geom_a, dGeomID geom_b)
+{
+	CollisionCallback* colCallback = (CollisionCallback*) data;
+
+	const bool a_space = (dGeomIsSpace(geom_a))?true:false;
+	const bool b_space = (dGeomIsSpace(geom_b))?true:false;
+	
+	void* const ptr_a = dGeomGetData(geom_a);
+	void* const ptr_b = dGeomGetData(geom_b);
+
+	if(a_space  || b_space )
+	{
+		// Collide a space with a space
+		if(a_space && b_space) 
+			colCallback->collisionCallback(static_cast<Space*>(ptr_a), static_cast<Space*>(ptr_b));
+			//static_cast<Space*>(ptr_a)->collide(static_cast<Space*>(ptr_b), colCallback);
+		else if(a_space) 
+			colCallback->collisionCallback(static_cast<Space*>(ptr_a), static_cast<Geometry*>(ptr_b));
+			//static_cast<Space*>(ptr_a)->collide(static_cast<Geometry*>(ptr_b), colCallback);
+		else 
+			colCallback->collisionCallback(static_cast<Space*>(ptr_b), static_cast<Geometry*>(ptr_a));
+			//static_cast<Space*>(ptr_b)->collide(static_cast<Geometry*>(ptr_a), colCallback);
+
+		// Collide geometries internal to the spaces
+		if(a_space) 
+            static_cast<Space*>(ptr_a)->collide(colCallback);
+
+		if(b_space) 
+            static_cast<Space*>(ptr_b)->collide(colCallback);
+	}
+    else
+	{
+		// Collide a geom with a geom, i.e. generate contacts
+		colCallback->collisionCallback(static_cast<Geometry*>(ptr_a), static_cast<Geometry*>(ptr_b));
+		//static_cast<Geometry*>(ptr_a)->collide(static_cast<Geometry*>(ptr_b), static_cast<CollisionListener*>(colCallback));
+	}
+}
+
+
+//------------------------------------------------------------------------------------------------
+Contact::Contact()
+{
+}
+//------------------------------------------------------------------------------------------------
+Contact::~Contact()
+{
+}
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& Contact::getPosition()
+{
+	_position.x = (Real)(_contact->geom.pos[0]);
+	_position.y = (Real)(_contact->geom.pos[1]);
+	_position.z = (Real)(_contact->geom.pos[2]);
+	return _position;
+}
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& Contact::getNormal()
+{
+	_normal.x = (Real)(_contact->geom.normal[0]);
+	_normal.y = (Real)(_contact->geom.normal[1]);
+	_normal.z = (Real)(_contact->geom.normal[2]);
+	return _normal;
+}
+//------------------------------------------------------------------------------------------------
+Real Contact::getPenetrationDepth()
+{
+	return (Real)(_contact->geom.depth);
+}
+//------------------------------------------------------------------------------------------------
+Geometry* Contact::getFirstGeometry()
+{
+	dGeomID g = _contact->geom.g1;
+	if(!g) return 0;
+
+	return (Geometry*)dGeomGetData(g);
+}
+//------------------------------------------------------------------------------------------------
+Geometry* Contact::getSecondGeometry()
+{
+	dGeomID g = _contact->geom.g2;
+	if(!g) return 0;
+
+	return (Geometry*)dGeomGetData(g);
+}
+//------------------------------------------------------------------------------------------------
+int Contact::getFirstSide()
+{
+   return _contact->geom.side1;
+}
+//------------------------------------------------------------------------------------------------
+int Contact::getSecondSide()
+{
+   return _contact->geom.side2;
+} 
+//------------------------------------------------------------------------------------------------
+void Contact::setFirstFrictionDirection(const Ogre::Vector3& vector)
+{
+	_contact->fdir1[0] = (dReal)vector.x;
+	_contact->fdir1[1] = (dReal)vector.y;
+	_contact->fdir1[2] = (dReal)vector.z;
+
+	_contact->surface.mode |= (int)Flag_UseFirstFrictionDirection;
+}
+//------------------------------------------------------------------------------------------------
+void Contact::setCoulombFriction(Real mu,Real additional_mu)
+{
+	_contact->surface.mu = mu;
+	
+	if(additional_mu >= 0.0)
+	{
+		_contact->surface.mu2 = additional_mu;
+		_contact->surface.mode |= (int)Flag_UseAdditionalFriction;
+	}
+}
+//------------------------------------------------------------------------------------------------
+void Contact::setBouncyness(Real bouncyness,Real velocity_threshold)
+{
+	_contact->surface.bounce = bouncyness;
+	if(velocity_threshold >= 0.0)
+	{
+		_contact->surface.bounce_vel = velocity_threshold;
+	}
+	_contact->surface.mode |= (int)Flag_SurfaceIsBouncy;
+}
+//------------------------------------------------------------------------------------------------
+void Contact::setSoftness(Real ERP,Real CFM)
+{
+	_contact->surface.soft_erp = ERP;
+	_contact->surface.soft_cfm = CFM;
+
+	_contact->surface.mode |= (int)Flag_UseERP;
+	_contact->surface.mode |= (int)Flag_UseCFM;
+}
+//------------------------------------------------------------------------------------------------
+void Contact::setIndependentMotion(Real velocity,Real additional_velocity)
+{
+	_contact->surface.motion1 = velocity;
+	_contact->surface.mode |= (int)Flag_IndependentMotion; 
+
+	if(additional_velocity >= 0.0)
+	{
+		_contact->surface.motion2 = additional_velocity;
+		_contact->surface.mode |= (int)Flag_AdditionalIndependentMotion;
+	}
+}
+//------------------------------------------------------------------------------------------------
+void Contact::setForceDependentSlip(Real FDS)
+{
+	_contact->surface.slip1 = FDS;
+	_contact->surface.mode |= (int)Flag_UseFDS;
+}
+//------------------------------------------------------------------------------------------------
+void Contact::setAdditionalFDS(Real FDS)
+{
+	_contact->surface.slip2 = FDS;
+	_contact->surface.mode |= (int)Flag_UseAdditionalFDS;
+}
+//------------------------------------------------------------------------------------------------
+void Contact::setFrictionMode(Contact::Flag flag)
+{
+	assert((flag == Flag_FrictionPyramid)||(flag == Flag_BothFrictionPyramids)||(flag == Flag_AdditionalFrictionPyramid));
+	_contact->surface.mode |= (int)flag;			
+}
+//------------------------------------------------------------------------------------------------
+ContactMapCollisionListener::ContactMapCollisionListener()
+{
+}
+//------------------------------------------------------------------------------------------------
+bool ContactMapCollisionListener::collision(Contact* contact)
+{
+	return false;
+	/*
+	size_t mt1 = contact->getFirstGeometry()->getMaterialType();
+	if(!mt1) return false;
+	
+	size_t mt2 = contact->getSecondGeometry()->getMaterialType();
+	if(!mt2) return false;
+
+	Contact *c = getContactPtr(mt1,mt2);
+	if(!c) return false;
+
+	contact->_contact->fdir1[0] = c->_contact->fdir1[0];
+	contact->_contact->fdir1[1] = c->_contact->fdir1[1];
+	contact->_contact->fdir1[2] = c->_contact->fdir1[2];
+
+	contact->_contact->surface.mu = c->_contact->surface.mu;
+	contact->_contact->surface.mu2 = c->_contact->surface.mu2;
+
+	contact->_contact->surface.bounce = c->_contact->surface.bounce;
+	contact->_contact->surface.bounce_vel = c->_contact->surface.bounce_vel;
+
+	contact->_contact->surface.soft_erp = c->_contact->surface.soft_erp;
+	contact->_contact->surface.soft_cfm = c->_contact->surface.soft_cfm;
+
+	contact->_contact->surface.motion1 = c->_contact->surface.motion1;
+	contact->_contact->surface.motion2 = c->_contact->surface.motion2;
+
+	contact->_contact->surface.slip1 = c->_contact->surface.slip1;
+	contact->_contact->surface.slip2 = c->_contact->surface.slip2;
+
+	contact->_contact->surface.mode = c->_contact->surface.mode;
+
+	return true;
+	*/
+}
+//------------------------------------------------------------------------------------------------
+void ContactMapCollisionListener::createContact(MaterialID materialA,MaterialID materialB)
+{
+	std::map<MaterialID,MaterialMap* >::iterator i = _map.find(materialA);
+	if(i == _map.end())
+	{
+		_map.insert(MaterialMapPair(materialA,new MaterialMap()));
+		i = _map.find(materialA);
+	}
+
+	MaterialMap::iterator j = i->second->find(materialB);
+	if(j == i->second->end())
+	{
+		Contact *c = new Contact();
+		memset(c->_contact,0,sizeof(dContact));
+
+		i->second->insert(std::pair<MaterialID,Contact*>(materialB,c));
+	}
+}
+//------------------------------------------------------------------------------------------------
+Contact *ContactMapCollisionListener::getContactPtr(MaterialID materialA,MaterialID materialB)
+{
+	Contact *c = 0;
+	MaterialID A = materialA;
+	MaterialID B = materialB;
+
+	std::map<MaterialID,MaterialMap* >::iterator i = _map.find(A);
+	if(i == _map.end())
+	{
+		B = materialA;
+		A = materialB;
+
+		i = _map.find(A);
+	}
+
+	if(i != _map.end())
+	{
+		MaterialMap::iterator j = i->second->find(B);
+		if(j != i->second->end())
+		{
+			c = j->second;
+		}
+	}
+
+	return c;
+}
+//------------------------------------------------------------------------------------------------
+ContactMapCollisionListener::~ContactMapCollisionListener()
+{
+	std::map<MaterialID,MaterialMap* >::iterator i = _map.begin();
+	std::map<MaterialID,MaterialMap* >::iterator i_end = _map.end();
+
+	for(;i != i_end;++i)
+	{
+		MaterialMap::iterator j = i->second->begin();
+		MaterialMap::iterator j_end = i->second->end();
+
+		for(;j != j_end;++j) 
+			delete j->second;
+
+		delete i->second;
+	}
+}
+//------------------------------------------------------------------------------------------------
+
Index: /code/branches/physics/src/ogreode/OgreOdeCollision.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeCollision.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeCollision.h	(revision 2122)
@@ -0,0 +1,130 @@
+#ifndef _OGREODECOLLISION_H_
+#define _OGREODECOLLISION_H_
+
+#include "OgreOdePreReqs.h"
+#include <OgreVector3.h>
+
+namespace OgreOde 
+{
+	class _OgreOdeExport CollisionListener
+	{
+	public:
+		CollisionListener();
+		virtual ~CollisionListener();
+
+		virtual bool collision(Contact* contact) = 0;
+	};
+
+
+	/** Using the default collisionCallbacks provided here will use the internal collisions setting of 
+		of the space. 
+		The space collide function now takes a bool useInternalCollisionFlag if you want internal collisions.
+	*/
+	class _OgreOdeExport CollisionCallback : public CollisionListener
+	{
+	public:
+	
+		friend class Space;
+		friend class Geometry;
+	
+		CollisionCallback();
+		virtual ~CollisionCallback();
+		
+		/** handles the ode callback and passes on to pure virtual methods that inherited classes implement
+		*/
+		static void collisionCallback(void *data, dGeomID geom_a, dGeomID geom_b);
+
+		/** user impliemented
+		*/
+		virtual void collisionCallback(OgreOde::Space* spaceFirst, OgreOde::Space* spaceSecond);
+		
+		virtual void collisionCallback(OgreOde::Space* space, OgreOde::Geometry* geometry);
+		
+		virtual void collisionCallback(OgreOde::Space* space);
+		
+		// This is down to a AABB level of the geometry, call collide() in here to go down further.
+		virtual void collisionCallback(OgreOde::Geometry* geometryFirst, OgreOde::Geometry* geometrySecond);
+	};
+
+
+	class _OgreOdeExport Contact
+	{
+		friend class Geometry;
+		friend class ContactMapCollisionListener;
+	
+	public:
+		enum Flag
+		{
+			Flag_UseAdditionalFriction			= dContactMu2,
+			Flag_UseFirstFrictionDirection		= dContactFDir1,
+			Flag_SurfaceIsBouncy				= dContactBounce,
+			Flag_UseERP							= dContactSoftERP,
+			Flag_UseCFM							= dContactSoftCFM,
+			Flag_IndependentMotion				= dContactMotion1, 
+			Flag_AdditionalIndependentMotion	= dContactMotion2,
+			Flag_UseFDS							= dContactSlip1,
+			Flag_UseAdditionalFDS				= dContactSlip2,
+			Flag_FrictionPyramid				= dContactApprox1_1,
+			Flag_AdditionalFrictionPyramid		= dContactApprox1_2,
+			Flag_BothFrictionPyramids			= dContactApprox1 
+		};
+
+	public:
+		Contact();
+		~Contact();
+
+		const Ogre::Vector3& getPosition();
+		const Ogre::Vector3& getNormal();
+		Ogre::Real getPenetrationDepth();
+
+        int getFirstSide();
+        int getSecondSide();
+
+		Geometry* getFirstGeometry();
+		Geometry* getSecondGeometry();
+
+		void setFirstFrictionDirection(const Ogre::Vector3& vector);
+		void setFrictionMode(Contact::Flag flag);
+
+		void setCoulombFriction(Ogre::Real mu, Ogre::Real additional_mu = -1.0);
+		void setBouncyness(Ogre::Real bouncyness, Ogre::Real velocity_threshold = -1.0);
+		void setSoftness(Ogre::Real ERP, Ogre::Real CFM);
+		void setIndependentMotion(Ogre::Real velocity, Ogre::Real additional_velocity = -1.0);
+		void setForceDependentSlip(Ogre::Real FDS);
+		void setAdditionalFDS(Ogre::Real FDS);
+
+		inline void setContact(dContact* contact)
+		{
+			_contact = contact;
+			_contact->surface.mode = 0;
+		}
+	protected:
+		inline Contact& operator=(dContact* contact)
+		{
+			_contact = contact;
+			_contact->surface.mode = 0;
+			return *this;
+		}
+
+	protected:
+		dContact* _contact;
+		Ogre::Vector3 _position,_normal;
+	};
+
+	class _OgreOdeExport ContactMapCollisionListener:public CollisionListener
+	{
+	public:
+		ContactMapCollisionListener();
+		virtual ~ContactMapCollisionListener();
+
+		virtual bool collision(Contact* contact);
+
+		void createContact(MaterialID materialA,MaterialID materialB); 
+		Contact *getContactPtr(MaterialID materialA,MaterialID materialB); 
+
+	protected:
+		std::map<MaterialID,MaterialMap* > _map;
+	};
+}
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOdeDebugContact.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeDebugContact.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeDebugContact.cpp	(revision 2122)
@@ -0,0 +1,634 @@
+/**
+* File: OgreOdeDebugContact.cpp
+*
+* description: This create create a billboarding object that display a text.
+*  From MovableText
+* @author  2003 by cTh see gavocanov@rambler.ru
+* @update  2006 by barraq see nospam@barraquand.com
+*/
+
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeDebugContact.h"
+
+#include <OgreFontManager.h>
+#include <OgreEntity.h>
+#include <OgreSceneNode.h>
+#include <OgreMaterialManager.h>
+#include <OgreCamera.h>
+#include <OgreRoot.h>
+
+#include "OgreOdeCollision.h"
+#include "OgreOdeWorld.h"
+
+using namespace Ogre;
+
+#define POS_TEX_BINDING    0
+#define COLOUR_BINDING     1
+
+namespace OgreOde
+{
+    //------------------------------------------------------------------------------------------------
+    DebugContact::DebugContact(const String &name, World *world) : 
+        _enabled(false),
+        _name(name), 
+        _world(world)
+    {
+        // scene node 
+        _node = _world->getSceneManager()->getRootSceneNode ()->createChildSceneNode ();
+
+        // sphere attach to contact point
+        _point = _world->getSceneManager()->createEntity(name + String("_debug_point"), "sphere.mesh");
+        _point_node = _node->createChildSceneNode ();
+        _point_node->attachObject (_point);
+        _point_node->setScale(0.001, 0.001, 0.001);
+
+        // normal direction debug
+         _normal = new DebugNormal();
+         _node->attachObject (_normal);
+
+         // text info on contact
+        _text = new DebugContactText(name + String("_debug_text"), _node->createChildSceneNode ());
+        _text->setPosition (Vector3(0,5,0));
+        _text->setCaption ("-");
+        _text->setVisible (false);
+
+        _node->setVisible (false);
+    }
+     //------------------------------------------------------------------------------------------------
+    DebugContact::~DebugContact()
+    {
+        delete _text;
+
+        _point_node->detachObject (_point->getName ());
+        _node->detachObject (_normal->getName ());
+
+        _world->getSceneManager()->destroyEntity (_point->getName ());
+
+        _node->detachAllObjects ();
+        _node->removeAndDestroyAllChildren ();
+
+        delete _normal;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContact::update(Contact * const contact)
+    {
+        _node->setPosition (contact->getPosition ());
+
+        _point_node->setPosition (contact->getPenetrationDepth () * contact->getNormal());
+
+        //String contactLabel("p: ");
+        //contactLabel = contactLabel + StringConverter::toString(contact->getPosition());
+        //contactLabel = contactLabel + ", n: ";
+        //contactLabel = contactLabel + StringConverter::toString(contact->getNormal());
+        //_text->setCaption (contactLabel);
+        //_text->setVisible (false);
+
+        //_text->setPosition (contact->getPosition () + Vector3(0,5,0));
+        
+        _normal->update (contact);
+    }
+    //------------------------------------------------------------------------------------------------
+    bool DebugContact::isEnabled () const 
+    {
+        return _enabled;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContact::setEnabled (bool enable)
+    {
+        _enabled = enable;
+        _node->setVisible (_enabled);
+    };
+    //------------------------------------------------------------------------------------------------
+    void DebugNormal::update(Contact * const contact)
+    {
+       DebugLines::clear ();
+       // set normal following contact normal
+       //contact->_normal 
+       //contact->_position
+       DebugLines::addLine (Vector3::ZERO, 
+                            5*contact->getNormal ());
+        DebugLines::draw ();
+    }
+    //------------------------------------------------------------------------------------------------
+    DebugContactText::DebugContactText(const String &name, 
+                                SceneNode *node,
+                                const String &caption, 
+                                const String &fontName, 
+                                int charHeight, 
+                                const ColourValue &color)
+        : mFontName(fontName)
+        , mType("DebugContact")
+        , mName(name)
+        , mCaption(caption)
+        , mHorizontalAlignment(H_LEFT)
+        , mVerticalAlignment(V_BELOW)
+        , mColor(color)
+        , mCharHeight(charHeight)
+        , mSpaceWidth(0)
+        , mUpdateColors(true)
+        , mOnTop(false)
+        , mTimeUntilNextToggle(0)
+        , mAdditionalHeight(0.0)
+        , mpCam(NULL)
+        , mpWin(NULL)
+        , mpFont(NULL)
+        , mNode(node)
+
+    {
+        if (name.empty())
+            Exception(Exception::ERR_INVALIDPARAMS, "Trying to create DebugContact without name", "DebugContact::DebugContact");
+// 
+//         if (caption.empty())
+//            Exception(Exception::ERR_INVALIDPARAMS, "Trying to create DebugContact without caption", "DebugContact::DebugContact");
+
+        mRenderOp.vertexData = NULL;
+        this->setFontName(mFontName);
+        //this->_setupGeometry();
+        mNode->attachObject(this);
+    }
+    //------------------------------------------------------------------------------------------------
+    DebugContactText::~DebugContactText()
+    {
+        mNode->detachObject(this->getName());
+        if (mRenderOp.vertexData)
+            delete mRenderOp.vertexData;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setPosition(const Vector3 &pos)
+    {
+        mNode->setPosition (pos);
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setFontName(const String &fontName)
+    {
+        if((Ogre::MaterialManager::getSingletonPtr()->resourceExists(mName + "Material"))) 
+        { 
+            Ogre::MaterialManager::getSingleton().remove(mName + "Material"); 
+        }
+
+        if (mFontName != fontName || mpMaterial.isNull() || !mpFont)
+        {
+            mFontName = fontName;
+            mpFont = (Font *)FontManager::getSingleton().getByName(mFontName).getPointer();
+            if (!mpFont)
+                Exception(Exception::ERR_ITEM_NOT_FOUND, "Could not find font " + fontName, "DebugContact::setFontName");
+
+            mpFont->load();
+            if (!mpMaterial.isNull())
+            {
+                MaterialManager::getSingletonPtr()->remove(mpMaterial->getName());
+                mpMaterial.setNull();
+            }
+
+            mpMaterial = mpFont->getMaterial()->clone(mName + "Material");
+            if (!mpMaterial->isLoaded())
+                mpMaterial->load();
+
+            mpMaterial->setDepthCheckEnabled(!mOnTop);
+            mpMaterial->setDepthBias(0,!mOnTop);
+            mpMaterial->setDepthWriteEnabled(mOnTop);
+            mpMaterial->setLightingEnabled(false);
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setCaption(const String &caption)
+    {
+        if (caption != mCaption)
+        {
+            mCaption = caption;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setColor(const ColourValue &color)
+    {
+        if (color != mColor)
+        {
+            mColor = color;
+            mUpdateColors = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setCharacterHeight(unsigned int height)
+    {
+        if (height != mCharHeight)
+        {
+            mCharHeight = height;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setSpaceWidth(unsigned int width)
+    {
+        if (width != mSpaceWidth)
+        {
+            mSpaceWidth = width;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setTextAlignment(const HorizontalAlignment& horizontalAlignment, const VerticalAlignment& verticalAlignment)
+    {
+        if(mHorizontalAlignment != horizontalAlignment)
+        {
+            mHorizontalAlignment = horizontalAlignment;
+            mNeedUpdate = true;
+        }
+        if(mVerticalAlignment != verticalAlignment)
+        {
+            mVerticalAlignment = verticalAlignment;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::setAdditionalHeight( Real height )
+    {
+        if( mAdditionalHeight != height )
+        {
+            mAdditionalHeight = height;
+            mNeedUpdate = true;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::showOnTop(bool show)
+    {
+        if( mOnTop != show && !mpMaterial.isNull() )
+        {
+            mOnTop = show;
+            mpMaterial->setDepthBias(0,!mOnTop);
+            mpMaterial->setDepthCheckEnabled(!mOnTop);
+            mpMaterial->setDepthWriteEnabled(mOnTop);
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_setupGeometry()
+    {
+        assert(mpFont);
+        assert(!mpMaterial.isNull());
+
+        unsigned int vertexCount = static_cast<unsigned int>(mCaption.size() * 6);
+
+        if (mRenderOp.vertexData)
+        {
+            // Removed this test as it causes problems when replacing a caption
+            // of the same size: replacing "Hello" with "hello"
+            // as well as when changing the text alignment
+            //if (mRenderOp.vertexData->vertexCount != vertexCount)
+            {
+                delete mRenderOp.vertexData;
+                mRenderOp.vertexData = NULL;
+                mUpdateColors = true;
+            }
+        }
+
+        if (!mRenderOp.vertexData)
+            mRenderOp.vertexData = new VertexData();
+
+        mRenderOp.indexData = 0;
+        mRenderOp.vertexData->vertexStart = 0;
+        mRenderOp.vertexData->vertexCount = vertexCount;
+        mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST; 
+        mRenderOp.useIndexes = false; 
+
+        VertexDeclaration  *decl = mRenderOp.vertexData->vertexDeclaration;
+        VertexBufferBinding   *bind = mRenderOp.vertexData->vertexBufferBinding;
+        size_t offset = 0;
+
+        // create/bind positions/tex.ccord. buffer
+        if (!decl->findElementBySemantic(VES_POSITION))
+            decl->addElement(POS_TEX_BINDING, offset, VET_FLOAT3, VES_POSITION);
+
+        offset += VertexElement::getTypeSize(VET_FLOAT3);
+
+        if (!decl->findElementBySemantic(VES_TEXTURE_COORDINATES))
+            decl->addElement(POS_TEX_BINDING, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
+
+        HardwareVertexBufferSharedPtr ptbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(POS_TEX_BINDING),
+            mRenderOp.vertexData->vertexCount,
+            HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
+        bind->setBinding(POS_TEX_BINDING, ptbuf);
+
+        // Colours - store these in a separate buffer because they change less often
+        if (!decl->findElementBySemantic(VES_DIFFUSE))
+            decl->addElement(COLOUR_BINDING, 0, VET_COLOUR, VES_DIFFUSE);
+
+        HardwareVertexBufferSharedPtr cbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(COLOUR_BINDING),
+            mRenderOp.vertexData->vertexCount,
+            HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
+        bind->setBinding(COLOUR_BINDING, cbuf);
+
+		// Unused variable
+        //size_t charlen = mCaption.size();
+        Real *pPCBuff = static_cast<Real*>(ptbuf->lock(HardwareBuffer::HBL_DISCARD));
+
+        float largestWidth = 0;
+        float left = 0 * 2.0 - 1.0;
+        float top = -((0 * 2.0) - 1.0);
+
+        // Derive space width from a capital A
+        if (mSpaceWidth == 0)
+            mSpaceWidth = (unsigned int)(mpFont->getGlyphAspectRatio('A') * mCharHeight * 2.0);
+
+        // for calculation of AABB
+        Ogre::Vector3 min, max, currPos;
+        Ogre::Real maxSquaredRadius;
+        bool first = true;
+
+        // Use iterator
+        String::iterator i, iend;
+        iend = mCaption.end();
+        bool newLine = true;
+        Real len = 0.0f;
+
+        if(mVerticalAlignment == DebugContactText::V_ABOVE)
+        {
+            // Raise the first line of the caption
+            top += mCharHeight;
+            for (i = mCaption.begin(); i != iend; ++i)
+            {
+                if (*i == '\n')
+                    top += mCharHeight * 2.0;
+            }
+        }
+
+        for (i = mCaption.begin(); i != iend; ++i)
+        {
+            if (newLine)
+            {
+                len = 0.0f;
+                for (String::iterator j = i; j != iend && *j != '\n'; j++)
+                {
+                    if (*j == ' ')
+                        len += mSpaceWidth;
+                    else 
+                        len += mpFont->getGlyphAspectRatio(*j) * mCharHeight * 2.0;
+                }
+                newLine = false;
+            }
+
+            if (*i == '\n')
+            {
+                left = 0 * 2.0 - 1.0;
+                top -= mCharHeight * 2.0;
+                newLine = true;
+                continue;
+            }
+
+            if (*i == ' ')
+            {
+                // Just leave a gap, no tris
+                left += mSpaceWidth;
+                // Also reduce tri count
+                mRenderOp.vertexData->vertexCount -= 6;
+                continue;
+            }
+
+            Real horiz_height = mpFont->getGlyphAspectRatio(*i);
+            const Font::UVRect &uvRect = mpFont->getGlyphTexCoords(*i);
+            const Real u1 = uvRect.left; 
+            const Real u2 = uvRect.right; 
+            const Real v1 = uvRect.top; 
+            const Real v2 = uvRect.bottom; 
+
+            // each vert is (x, y, z, u, v)
+            //-------------------------------------------------------------------------------------
+            // First tri
+            //
+            // Upper left
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u1;
+            *pPCBuff++ = v1;
+
+            // Deal with bounds
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                currPos = Ogre::Vector3(left, top, -1.0);
+            else
+                currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
+            if (first)
+            {
+                min = max = currPos;
+                maxSquaredRadius = currPos.squaredLength();
+                first = false;
+            }
+            else
+            {
+                min.makeFloor(currPos);
+                max.makeCeil(currPos);
+                maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+            }
+
+            top -= mCharHeight * 2.0;
+
+            // Bottom left
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u1;
+            *pPCBuff++ = v2;
+
+            // Deal with bounds
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                currPos = Ogre::Vector3(left, top, -1.0);
+            else
+                currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            top += mCharHeight * 2.0;
+            left += horiz_height * mCharHeight * 2.0;
+
+            // Top right
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u2;
+            *pPCBuff++ = v1;
+            //-------------------------------------------------------------------------------------
+
+            // Deal with bounds
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                currPos = Ogre::Vector3(left, top, -1.0);
+            else
+                currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            //-------------------------------------------------------------------------------------
+            // Second tri
+            //
+            // Top right (again)
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u2;
+            *pPCBuff++ = v1;
+
+            currPos = Ogre::Vector3(left, top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            top -= mCharHeight * 2.0;
+            left -= horiz_height  * mCharHeight * 2.0;
+
+            // Bottom left (again)
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u1;
+            *pPCBuff++ = v2;
+
+            currPos = Ogre::Vector3(left, top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            left += horiz_height  * mCharHeight * 2.0;
+
+            // Bottom right
+            if(mHorizontalAlignment == DebugContactText::H_LEFT)
+                *pPCBuff++ = left;
+            else
+                *pPCBuff++ = left - (len / 2);
+            *pPCBuff++ = top;
+            *pPCBuff++ = -1.0;
+            *pPCBuff++ = u2;
+            *pPCBuff++ = v2;
+            //-------------------------------------------------------------------------------------
+
+            currPos = Ogre::Vector3(left, top, -1.0);
+            min.makeFloor(currPos);
+            max.makeCeil(currPos);
+            maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
+
+            // Go back up with top
+            top += mCharHeight * 2.0;
+
+            float currentWidth = (left + 1)/2 - 0;
+            if (currentWidth > largestWidth)
+                largestWidth = currentWidth;
+        }
+
+        // Unlock vertex buffer
+        ptbuf->unlock();
+
+        // update AABB/Sphere radius
+        mAABB = Ogre::AxisAlignedBox(min, max);
+        mRadius = Ogre::Math::Sqrt(maxSquaredRadius);
+
+        if (mUpdateColors)
+            this->_updateColors();
+
+        mNeedUpdate = false;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_updateColors(void)
+    {
+        assert(mpFont);
+        assert(!mpMaterial.isNull());
+
+        // Convert to system-specific
+        RGBA color;
+        Root::getSingleton().convertColourValue(mColor, &color);
+        HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(COLOUR_BINDING);
+        RGBA *pDest = static_cast<RGBA*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
+        for (unsigned int i = 0; i < mRenderOp.vertexData->vertexCount; ++i)
+            *pDest++ = color;
+        vbuf->unlock();
+        mUpdateColors = false;
+    }
+    //------------------------------------------------------------------------------------------------
+#if OGRE_VERSION < ((1 << 16) | (5 << 8))
+    const Quaternion& DebugContactText::getWorldOrientation(void) const
+#else
+    const Quaternion& DebugContactText::_getDerivedOrientation(void) const
+#endif
+    {
+        assert(mpCam);
+        return const_cast<Quaternion&>(mpCam->getDerivedOrientation());
+    }
+    //------------------------------------------------------------------------------------------------
+#if OGRE_VERSION < ((1 << 16) | (5 << 8))
+    const Vector3& DebugContactText::getWorldPosition(void) const
+#else
+    const Vector3& DebugContactText::_getDerivedPosition(void) const
+#endif
+    {
+        assert(mParentNode);
+        return mParentNode->_getDerivedPosition();
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::getWorldTransforms(Matrix4 *xform) const 
+    {	
+        if (this->isVisible() && mpCam)
+        {
+            Matrix3 rot3x3, scale3x3 = Matrix3::IDENTITY;
+
+            // store rotation in a matrix
+            mpCam->getDerivedOrientation().ToRotationMatrix(rot3x3);
+
+            // parent node position
+            Vector3 ppos = mParentNode->_getDerivedPosition() + Vector3::UNIT_Y*mAdditionalHeight;
+
+            // apply scale
+            scale3x3[0][0] = mParentNode->_getDerivedScale().x / 2;
+            scale3x3[1][1] = mParentNode->_getDerivedScale().y / 2;
+            scale3x3[2][2] = mParentNode->_getDerivedScale().z / 2;
+
+            // apply all transforms to xform       
+            *xform = (rot3x3 * scale3x3);
+            xform->setTrans(ppos);
+        }
+   }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::getRenderOperation(RenderOperation &op)
+    {
+        if (this->isVisible())
+        {
+            if (mNeedUpdate)
+                this->_setupGeometry();
+            if (mUpdateColors)
+                this->_updateColors();
+            op = mRenderOp;
+        }
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_notifyCurrentCamera(Camera *cam)
+    {
+        mpCam = cam;
+    }
+    //------------------------------------------------------------------------------------------------
+    void DebugContactText::_updateRenderQueue(RenderQueue* queue)
+    {
+        if (this->isVisible())
+        {
+            if (mNeedUpdate)
+                this->_setupGeometry();
+            if (mUpdateColors)
+                this->_updateColors();
+
+            queue->addRenderable(this, mRenderQueueID, OGRE_RENDERABLE_DEFAULT_PRIORITY);
+            //      queue->addRenderable(this, mRenderQueueID, RENDER_QUEUE_SKIES_LATE);
+        }
+    }
+}
Index: /code/branches/physics/src/ogreode/OgreOdeDebugContact.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeDebugContact.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeDebugContact.h	(revision 2122)
@@ -0,0 +1,167 @@
+/**
+* File: OgreOdeDebugContact.h
+*
+* description: This create create a billboarding object that display a text.
+* derived from Movable Text
+* @author  2003 by cTh see gavocanov@rambler.ru
+* @update  2006 by barraq see nospam@barraquand.com
+*/
+
+#ifndef __include_OgreOdeDebugContact_H__
+#define __include_OgreOdeDebugContact_H__
+
+#include "OgreOdePreReqs.h"
+
+#include <OgreMovableObject.h>
+#include <OgreRenderable.h>
+#include <OgreAxisAlignedBox.h>
+#include "OgreOdeDebugObject.h"
+
+namespace OgreOde 
+{
+    class DebugContact
+    {
+    public:
+        DebugContact(const Ogre::String &name, World *world);
+         ~DebugContact();
+
+         bool isEnabled () const;
+         void setEnabled (bool enable);
+
+        void update(Contact * const contact);
+
+    private:
+        DebugNormal         *_normal;
+        DebugContactText    *_text;
+        Ogre::Entity        *_point;
+        bool                _enabled;
+        Ogre::String        _name;
+        Ogre::SceneNode     *_node;
+        Ogre::SceneNode     *_point_node;
+        World               *_world;
+    };
+
+    class DebugNormal : public DebugLines
+    {
+    public:
+        DebugNormal() : DebugLines(){};
+        ~DebugNormal(){};
+
+        void update (Contact * const contact);
+    };
+
+    class DebugContactText : public Ogre::MovableObject, public Ogre::Renderable
+    {
+    public:
+        enum HorizontalAlignment    {H_LEFT, H_CENTER};
+        enum VerticalAlignment      {V_BELOW, V_ABOVE};
+        /******************************** public methods ******************************/
+    public:
+        DebugContactText(const Ogre::String &name, 
+                         Ogre::SceneNode *node,
+                         const Ogre::String &caption = "", 
+                         const Ogre::String &fontName = "BlueHighway", 
+                         int charHeight = 32, 
+                         const Ogre::ColourValue &color = Ogre::ColourValue::White);
+
+
+         ~DebugContactText();
+
+        // Set settings
+        void    setPosition(const Ogre::Vector3 &pos);
+
+        void    setFontName(const Ogre::String &fontName);
+        void    setCaption(const Ogre::String &caption);
+        void    setColor(const Ogre::ColourValue &color);
+        void    setCharacterHeight(unsigned int height);
+        void    setSpaceWidth(unsigned int width);
+        void    setTextAlignment(const HorizontalAlignment& horizontalAlignment, 
+                                const VerticalAlignment& verticalAlignment);
+        void    setAdditionalHeight( Ogre::Real height );
+        void    showOnTop(bool show=true);
+
+        // Get settings
+        const   Ogre::String          &getFontName() const {return mFontName;}
+        const   Ogre::String          &getCaption() const {return mCaption;}
+        const   Ogre::ColourValue     &getColor() const {return mColor;}
+
+
+        unsigned int    getCharacterHeight() const {return mCharHeight;}
+        unsigned int    getSpaceWidth() const {return mSpaceWidth;}
+        Ogre::Real                  getAdditionalHeight() const {return mAdditionalHeight;}
+        bool                    getShowOnTop() const {return mOnTop;}
+        Ogre::AxisAlignedBox	        GetAABB(void) { return mAABB; }
+		
+#if OGRE_VERSION >= ((1 << 16) | (5 << 8))
+		virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false){}
+#endif
+
+        /******************************** protected methods and overload **************/
+    protected:
+
+        // from OgreOdeDebugContact, create the object
+        void	_setupGeometry();
+        void	_updateColors();
+
+        // from MovableObject
+        void                            getWorldTransforms(Ogre::Matrix4 *xform) const;
+        Ogre::Real                      getBoundingRadius(void) const {return mRadius;};
+        Ogre::Real                      getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;};
+#if OGRE_VERSION < ((1 << 16) | (5 << 8))
+        const   Ogre::Quaternion        &getWorldOrientation() const;
+        const   Ogre::Vector3           &getWorldPosition() const;
+#else
+        const   Ogre::Quaternion        &_getDerivedOrientation(void) const;
+        const   Ogre::Vector3           &_getDerivedPosition(void) const;
+#endif
+        const   Ogre::AxisAlignedBox    &getBoundingBox(void) const {return mAABB;};
+        const   Ogre::String            &getName(void) const {return mName;};
+        const   Ogre::String            &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
+
+        void                            _notifyCurrentCamera(Ogre::Camera *cam);
+        void                            _updateRenderQueue(Ogre::RenderQueue* queue);
+
+        // from renderable
+        void                            getRenderOperation(Ogre::RenderOperation &op);
+        const   Ogre::MaterialPtr       &getMaterial(void) const {assert(!mpMaterial.isNull());return mpMaterial;};
+        const   Ogre::LightList         &getLights(void) const {return mLList;};
+
+        /******************************** OgreOdeDebugContact data ****************************/
+  
+
+    protected:
+        Ogre::String			mFontName;
+        Ogre::String			mType;
+        Ogre::String			mName;
+        Ogre::String			mCaption;
+        HorizontalAlignment	    mHorizontalAlignment;
+        VerticalAlignment	    mVerticalAlignment;
+
+        Ogre::ColourValue		mColor;
+        Ogre::RenderOperation	mRenderOp;
+        Ogre::AxisAlignedBox	mAABB;
+        Ogre::LightList		    mLList;
+
+        unsigned int			mCharHeight;
+        unsigned int			mSpaceWidth;
+
+        bool			        mNeedUpdate;
+        bool			        mUpdateColors;
+        bool			        mOnTop;
+
+        Ogre::Real			    mTimeUntilNextToggle;
+        Ogre::Real			    mRadius;
+        Ogre::Real              mAdditionalHeight;
+
+        Ogre::Camera			*mpCam;
+        Ogre::RenderWindow	    *mpWin;
+        Ogre::Font			    *mpFont;
+        Ogre::MaterialPtr		mpMaterial;
+        Ogre::MaterialPtr		mpBackgroundMaterial;
+
+        Ogre::SceneNode         *mNode;
+    };
+}
+
+#endif
+
Index: /code/branches/physics/src/ogreode/OgreOdeDebugObject.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeDebugObject.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeDebugObject.cpp	(revision 2122)
@@ -0,0 +1,799 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeDebugObject.h"
+
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+#include <OgreCamera.h>
+#include <OgreHardwareBufferManager.h>
+
+using namespace OgreOde;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+bool DebugLines::_materials_created = false;
+//------------------------------------------------------------------------------------------------
+DebugLines::DebugLines() : SimpleRenderable()
+{
+	mRenderOp.vertexData = new Ogre::VertexData();
+   _drawn = false;
+
+	if (!_materials_created)
+	{
+		MaterialPtr red = MaterialManager::getSingleton().create("OgreOdeDebugLines/Disabled","OgreOde");
+		MaterialPtr green = MaterialManager::getSingleton().create("OgreOdeDebugLines/Enabled","OgreOde");
+		MaterialPtr blue = MaterialManager::getSingleton().create("OgreOdeDebugLines/Static","OgreOde");
+
+        red->setReceiveShadows(false);
+		red->getTechnique(0)->setLightingEnabled(true);
+		red->getTechnique(0)->getPass(0)->setSelfIllumination(1,0,0);
+
+        green->setReceiveShadows(false);
+		green->getTechnique(0)->setLightingEnabled(true);
+		green->getTechnique(0)->getPass(0)->setSelfIllumination(0,1,0);
+
+        blue->setReceiveShadows(false);
+		blue->getTechnique(0)->setLightingEnabled(true);
+		blue->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
+
+		_materials_created = true;
+	}
+    setCastShadows (false);
+	this->setMaterial("OgreOdeDebugLines/Enabled");
+}
+
+
+//------------------------------------------------------------------------------------------------
+void DebugLines::clear()
+{
+	if (_drawn)
+	{
+		_drawn = false;
+		_points.clear();
+		delete mRenderOp.vertexData;
+
+		mRenderOp.vertexData = new Ogre::VertexData();
+	}
+}
+//------------------------------------------------------------------------------------------------
+DebugLines::~DebugLines(void)
+{
+   clear();
+
+   delete mRenderOp.vertexData;
+}
+//------------------------------------------------------------------------------------------------
+void DebugLines::draw()
+{
+   if (_drawn) 
+       return;
+   else 
+       _drawn = true;
+
+   // Initialization stuff
+   mRenderOp.indexData = 0;
+   mRenderOp.vertexData->vertexCount = _points.size();
+   mRenderOp.vertexData->vertexStart = 0;
+   mRenderOp.operationType = RenderOperation::OT_LINE_LIST;
+   mRenderOp.useIndexes = false;
+
+   Ogre::VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
+   Ogre::VertexBufferBinding *bind = mRenderOp.vertexData->vertexBufferBinding;
+
+   decl->addElement(0, 0, VET_FLOAT3, VES_POSITION);
+
+   HardwareVertexBufferSharedPtr vbuf =
+	   HardwareBufferManager::getSingleton().createVertexBuffer(
+         decl->getVertexSize(0),
+         mRenderOp.vertexData->vertexCount,
+		 HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+
+   bind->setBinding(0, vbuf);
+
+   // Drawing stuff
+   unsigned int size = (unsigned int)_points.size();
+   Ogre::Vector3 vaabMin = _points[0];
+   Ogre::Vector3 vaabMax = _points[0];
+
+   float *prPos = static_cast<float*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
+
+   for(unsigned int i = 0; i < size; i++)
+   {
+      *prPos++ = _points[i].x;
+      *prPos++ = _points[i].y;
+      *prPos++ = _points[i].z;
+
+      if (_points[i].x < vaabMin.x)
+         vaabMin.x = _points[i].x;
+      if (_points[i].y < vaabMin.y)
+         vaabMin.y = _points[i].y;
+      if (_points[i].z < vaabMin.z)
+         vaabMin.z = _points[i].z;
+
+      if (_points[i].x > vaabMax.x)
+         vaabMax.x = _points[i].x;
+      if (_points[i].y > vaabMax.y)
+         vaabMax.y = _points[i].y;
+      if (_points[i].z > vaabMax.z)
+         vaabMax.z = _points[i].z;
+   }
+
+   vbuf->unlock();
+
+   mBox.setExtents(vaabMin, vaabMax);
+}
+//------------------------------------------------------------------------------------------------
+Real DebugLines::getSquaredViewDepth(const Camera *cam) const
+{
+	Vector3 vMin, vMax, vMid, vDist;
+	vMin = mBox.getMinimum();
+	vMax = mBox.getMaximum();
+	vMid = ((vMin - vMax) * 0.5) + vMin;
+	vDist = cam->getDerivedPosition() - vMid;
+
+	return vDist.squaredLength();
+}
+//------------------------------------------------------------------------------------------------
+Real DebugLines::getBoundingRadius() const
+{
+	return Math::Sqrt(std::max(mBox.getMaximum().squaredLength(), mBox.getMinimum().squaredLength()));
+}
+//------------------------------------------------------------------------------------------------
+DebugObject::DebugObject(DebugObject::Mode mode) 
+{
+	_mode = DebugObject::Mode_Unknown;
+	setMode(mode);
+}
+//------------------------------------------------------------------------------------------------
+void DebugObject::setMode(DebugObject::Mode mode)
+{
+	if (mode != _mode)
+	{
+		_mode = mode;
+		switch(_mode)
+		{
+			case DebugObject::Mode_Enabled:
+				setMaterial("OgreOdeDebugLines/Enabled");
+			break;
+
+			case DebugObject::Mode_Disabled:
+				setMaterial("OgreOdeDebugLines/Disabled");
+
+			break;
+
+			case DebugObject::Mode_Static:
+				setMaterial("OgreOdeDebugLines/Static");
+			break;
+
+			case DebugObject::Mode_Unknown:
+				// don't do anything. Not handled.
+			break;
+		}
+	}
+}
+//------------------------------------------------------------------------------------------------
+DebugObject::~DebugObject() 
+{
+}
+//------------------------------------------------------------------------------------------------
+BoxDebugObject::BoxDebugObject(const Ogre::Vector3& size):DebugObject()
+{
+	AxisAlignedBox aabb(-size.x * 0.5,-size.y * 0.5,-size.z * 0.5,
+						size.x * 0.5,size.y * 0.5,size.z * 0.5);
+
+	Vector3 vmax = aabb.getMaximum();
+	Vector3 vmin = aabb.getMinimum();
+
+	addLine(vmin.x,vmin.y,vmin.z,vmax.x,vmin.y,vmin.z);
+	addLine(vmin.x,vmin.y,vmin.z,vmin.x,vmin.y,vmax.z);
+	addLine(vmin.x,vmin.y,vmin.z,vmin.x,vmax.y,vmin.z);
+	addLine(vmin.x,vmax.y,vmin.z,vmin.x,vmax.y,vmax.z);
+	addLine(vmin.x,vmax.y,vmin.z,vmax.x,vmax.y,vmin.z);
+	addLine(vmax.x,vmin.y,vmin.z,vmax.x,vmin.y,vmax.z);
+	addLine(vmax.x,vmin.y,vmin.z,vmax.x,vmax.y,vmin.z);
+	addLine(vmin.x,vmax.y,vmax.z,vmax.x,vmax.y,vmax.z);
+	addLine(vmin.x,vmax.y,vmax.z,vmin.x,vmin.y,vmax.z);
+	addLine(vmax.x,vmax.y,vmin.z,vmax.x,vmax.y,vmax.z);
+	addLine(vmax.x,vmin.y,vmax.z,vmax.x,vmax.y,vmax.z);
+	addLine(vmin.x,vmin.y,vmax.z,vmax.x,vmin.y,vmax.z);
+
+	draw();
+}
+//------------------------------------------------------------------------------------------------
+BoxDebugObject::~BoxDebugObject()
+{
+}
+//------------------------------------------------------------------------------------------------
+SphereDebugObject::SphereDebugObject(Real radius):DebugObject()
+{
+	// X/Y axis
+
+	// NW quadrant
+	addLine(-radius,			0.0,				0.0,
+	-0.866 * radius,	0.5 * radius,		0.0);
+
+	addLine(-0.866 * radius,	0.5 * radius,		0.0,
+	-0.5 * radius,	0.866 * radius,	0.0);
+
+	addLine(-0.5 * radius,	0.866 * radius,	0.0,
+	0.0,				radius,			0.0);
+
+	// NE quadrant
+	addLine(0.0,				radius,			0.0,
+	0.5 * radius,		0.866 * radius,	0.0);
+
+	addLine(0.5 * radius,		0.866 * radius,	0.0,
+	0.866 * radius,	0.5 * radius,		0.0);
+
+	addLine(0.866 * radius,	0.5 * radius,		0.0,
+	radius,			0.0,				0.0);
+
+	// SW quadrant
+	addLine(-radius,			0.0,				0.0,
+	-0.866 * radius,	-0.5 * radius,	0.0);
+
+	addLine(-0.866 * radius,	-0.5 * radius,	0.0,
+	-0.5 * radius,	-0.866 * radius,	0.0);
+
+	addLine(-0.5 * radius,	-0.866 * radius,	0.0,
+	0.0,				-radius,			0.0);
+
+	// SE quadrant
+	addLine(0.0,				-radius,			0.0,
+	0.5 * radius,		-0.866 * radius,	0.0);
+
+	addLine(0.5 * radius,		-0.866 * radius,	0.0,
+	0.866 * radius,	-0.5 * radius,	0.0);
+
+	addLine(0.866 * radius,	-0.5 * radius,	0.0,
+	radius,			0.0,				0.0);
+
+	// X/Z axis
+
+	// NW quadrant
+	addLine(-radius,			0.0,	0.0,	
+	-0.866 * radius,	0.0,	0.5 * radius);
+
+	addLine(-0.866 * radius,	0.0,	0.5 * radius,
+	-0.5 * radius,	0.0,	0.866 * radius);
+
+	addLine(-0.5 * radius,	0.0,	0.866 * radius,
+	0.0,				0.0,	radius);
+
+	// NE quadrant
+	addLine(0.0,				0.0,	radius,
+	0.5 * radius,		0.0,	0.866 * radius);
+
+	addLine(0.5 * radius,		0.0,	0.866 * radius,
+	0.866 * radius,	0.0,	0.5 * radius);
+
+	addLine(0.866 * radius,	0.0,	0.5 * radius,
+	radius,			0.0,	0.0);
+
+	// SW quadrant
+	addLine(-radius,			0.0,	0.0,	
+	-0.866 * radius,	0.0,	-0.5 * radius);
+
+	addLine(-0.866 * radius,	0.0,	-0.5 * radius,
+	-0.5 * radius,	0.0,	-0.866 * radius);
+
+	addLine(-0.5 * radius,	0.0,	-0.866 * radius,
+	0.0,				0.0,	-radius);
+
+	// SE quadrant
+	addLine(0.0,				0.0,	-radius,
+	0.5 * radius,		0.0,	-0.866 * radius);
+
+	addLine(0.5 * radius,		0.0,	-0.866 * radius,
+	0.866 * radius,	0.0,	-0.5 * radius);
+
+	addLine(0.866 * radius,	0.0,	-0.5 * radius,
+	radius,			0.0,	0.0);
+
+	// Y/Z axis
+
+	// NW quadrant
+	addLine(0.0,	-radius,			0.0,	
+	0.0,	-0.866 * radius,	0.5 * radius);
+
+	addLine(0.0,	-0.866 * radius,	0.5 * radius,
+	0.0,	-0.5 * radius,	0.866 * radius);
+
+	addLine(0.0,	-0.5 * radius,	0.866 * radius,
+	0.0,	0.0,				radius);
+
+	// NE quadrant
+	addLine(0.0,	0.0,				radius,
+	0.0,	0.5 * radius,		0.866 * radius);
+
+	addLine(0.0,	0.5 * radius,		0.866 * radius,
+	0.0,	0.866 * radius,	0.5 * radius);
+
+	addLine(0.0,	0.866 * radius,	0.5 * radius,
+	0.0,	radius,			0.0);
+
+	// SW quadrant
+	addLine(0.0,	-radius,			0.0,	
+	0.0,	-0.866 * radius,	-0.5 * radius);
+
+	addLine(0.0,	-0.866 * radius,	-0.5 * radius,
+	0.0,	-0.5 * radius,	-0.866 * radius);
+
+	addLine(0.0,	-0.5 * radius,	-0.866 * radius,
+	0.0,	0.0,				-radius);
+
+	// SE quadrant
+	addLine(0.0,	0.0,				-radius,
+	0.0,	0.5 * radius,		-0.866 * radius);
+
+	addLine(0.0,	0.5 * radius,		-0.866 * radius,
+	0.0,	0.866 * radius,	-0.5 * radius);
+
+	addLine(0.0,	0.866 * radius,	-0.5 * radius,
+	0.0,	radius,			0.0);
+
+	draw();
+}
+//------------------------------------------------------------------------------------------------
+SphereDebugObject::~SphereDebugObject()
+{
+}
+//------------------------------------------------------------------------------------------------
+CapsuleDebugObject::CapsuleDebugObject(Real radius,Real length):DebugObject()
+{
+	Real halflen = length * 0.5;
+	AxisAlignedBox aabb(-radius,-radius,-(halflen + radius),radius,radius,halflen + radius);
+
+	// X/Y axis - Near
+
+	// NW quadrant
+	addLine(-radius,			0.0,				halflen,
+	-0.866 * radius,	0.5 * radius,		halflen);
+
+	addLine(-0.866 * radius,	0.5 * radius,		halflen,
+		-0.5 * radius,	0.866 * radius,	halflen);
+
+	addLine(-0.5 * radius,	0.866 * radius,	halflen,
+	0.0,				radius,			halflen);
+
+	// NE quadrant
+	addLine(0.0,				radius,			halflen,
+		0.5 * radius,		0.866 * radius,	halflen);
+
+	addLine(0.5 * radius,		0.866 * radius,	halflen,
+	0.866 * radius,	0.5 * radius,		halflen);
+
+	addLine(0.866 * radius,	0.5 * radius,		halflen,
+	radius,			0.0,				halflen);
+
+	// SW quadrant
+	addLine(-radius,			0.0,				halflen,
+	-0.866 * radius,	-0.5 * radius,	halflen);
+
+	addLine(-0.866 * radius,	-0.5 * radius,	halflen,
+	-0.5 * radius,	-0.866 * radius,	halflen);
+
+	addLine(-0.5 * radius,	-0.866 * radius,	halflen,
+	0.0,				-radius,			halflen);
+
+	// SE quadrant
+	addLine(0.0,				-radius,			halflen,
+	0.5 * radius,		-0.866 * radius,	halflen);
+
+	addLine(0.5 * radius,		-0.866 * radius,	halflen,
+	0.866 * radius,	-0.5 * radius,	halflen);
+
+	addLine(0.866 * radius,	-0.5 * radius,	halflen,
+	radius,			0.0,				halflen);
+	
+	// X/Y axis - Far
+
+	// NW quadrant
+	addLine(-radius,			0.0,				-halflen,
+	-0.866 * radius,	0.5 * radius,		-halflen);
+
+	addLine(-0.866 * radius,	0.5 * radius,		-halflen,
+	-0.5 * radius,	0.866 * radius,	-halflen);
+
+	addLine(-0.5 * radius,	0.866 * radius,	-halflen,
+	0.0,				radius,			-halflen);
+
+	// NE quadrant
+	addLine(0.0,				radius,			-halflen,
+	0.5 * radius,		0.866 * radius,	-halflen);
+
+	addLine(0.5 * radius,		0.866 * radius,	-halflen,
+	0.866 * radius,	0.5 * radius,		-halflen);
+
+	addLine(0.866 * radius,	0.5 * radius,		-halflen,
+	radius,			0.0,				-halflen);
+
+	// SW quadrant
+	addLine(-radius,			0.0,				-halflen,
+	-0.866 * radius,	-0.5 * radius,	-halflen);
+
+	addLine(-0.866 * radius,	-0.5 * radius,	-halflen,
+	-0.5 * radius,	-0.866 * radius,	-halflen);
+
+	addLine(-0.5 * radius,	-0.866 * radius,	-halflen,
+	0.0,				-radius,			-halflen);
+
+	// SE quadrant
+	addLine(0.0,				-radius,			-halflen,
+	0.5 * radius,		-0.866 * radius,	-halflen);
+
+	addLine(0.5 * radius,		-0.866 * radius,	-halflen,
+	0.866 * radius,	-0.5 * radius,	-halflen);
+
+	addLine(0.866 * radius,	-0.5 * radius,	-halflen,
+	radius,			0.0,				-halflen);
+
+	// X/Z axis
+
+	// NW quadrant
+	addLine(-radius,			0.0,	halflen,	
+	-0.866 * radius,	0.0,	(0.5 * radius) + halflen);
+
+	addLine(-0.866 * radius,	0.0,	(0.5 * radius) + halflen,
+	-0.5 * radius,	0.0,	(0.866 * radius) + halflen);
+
+	addLine(-0.5 * radius,	0.0,	(0.866 * radius) + halflen,
+	0.0,				0.0,	radius + halflen);
+
+	// NE quadrant
+	addLine(0.0,				0.0,	radius + halflen,
+	0.5 * radius,		0.0,	(0.866 * radius) + halflen);
+
+	addLine(0.5 * radius,		0.0,	(0.866 * radius) + halflen,
+	0.866 * radius,	0.0,	(0.5 * radius) + halflen);
+
+	addLine(0.866 * radius,	0.0,	(0.5 * radius) + halflen,
+	radius,			0.0,	halflen);
+
+	// SW quadrant
+	addLine(-radius,			0.0,	-halflen,	
+	-0.866 * radius,	0.0,	(-0.5 * radius) - halflen);
+
+	addLine(-0.866 * radius,	0.0,	(-0.5 * radius) - halflen,
+	-0.5 * radius,	0.0,	(-0.866 * radius) - halflen);
+
+	addLine(-0.5 * radius,	0.0,	(-0.866 * radius) - halflen,
+	0.0,				0.0,	-radius - halflen);
+
+	// SE quadrant
+	addLine(0.0,				0.0,	-radius - halflen,
+	0.5 * radius,		0.0,	(-0.866 * radius) - halflen);
+
+	addLine(0.5 * radius,		0.0,	(-0.866 * radius) - halflen,
+	0.866 * radius,	0.0,	(-0.5 * radius) - halflen);
+
+	addLine(0.866 * radius,	0.0,	(-0.5 * radius) - halflen,
+	radius,			0.0,	- halflen);
+
+	// Y/Z axis
+
+	// NW quadrant
+	addLine(0.0,	-radius,			halflen,	
+	0.0,	-0.866 * radius,	(0.5 * radius) + halflen);
+
+	addLine(0.0,	-0.866 * radius,	(0.5 * radius) + halflen,
+	0.0,	-0.5 * radius,	(0.866 * radius) + halflen);
+
+	addLine(0.0,	-0.5 * radius,	(0.866 * radius) + halflen,
+	0.0,	0.0,				radius + halflen);
+
+	// NE quadrant
+	addLine(0.0,	0.0,				radius + halflen,
+	0.0,	0.5 * radius,		(0.866 * radius) + halflen);
+
+	addLine(0.0,	0.5 * radius,		(0.866 * radius) + halflen,
+	0.0,	0.866 * radius,	(0.5 * radius) + halflen);
+
+	addLine(0.0,	0.866 * radius,	(0.5 * radius) + halflen,
+	0.0,	radius,			halflen);
+
+	// SW quadrant
+	addLine(0.0,	-radius,			-halflen,	
+	0.0,	-0.866 * radius,	(-0.5 * radius) - halflen);
+
+	addLine(0.0,	-0.866 * radius,	(-0.5 * radius) - halflen,
+	0.0,	-0.5 * radius,	(-0.866 * radius) - halflen);
+
+	addLine(0.0,	-0.5 * radius,	(-0.866 * radius) - halflen,
+	0.0,	0.0,				-radius - halflen);
+
+	// SE quadrant
+	addLine(0.0,	0.0,				-radius - halflen,
+	0.0,	0.5 * radius,		(-0.866 * radius) - halflen);
+
+	addLine(0.0,	0.5 * radius,		(-0.866 * radius) - halflen,
+	0.0,	0.866 * radius,	(-0.5 * radius) - halflen);
+
+	addLine(0.0,	0.866 * radius,	(-0.5 * radius) - halflen,
+	0.0,	radius,			-halflen);
+
+	// Side lines
+	addLine(-radius,	0.0,		-halflen,
+	-radius,	0.0,		halflen);
+
+	addLine(radius,	0.0,		-halflen,
+	radius,	0.0,		halflen);
+
+	addLine(0.0,		radius,	-halflen,
+	0.0,		radius,	halflen);
+
+	addLine(0.0,		-radius,	-halflen,
+	0.0,		-radius,	halflen);
+
+	draw();
+}
+//------------------------------------------------------------------------------------------------
+CapsuleDebugObject::~CapsuleDebugObject()
+{
+}
+//------------------------------------------------------------------------------------------------
+CylinderDebugObject::CylinderDebugObject(Real radius,Real length):DebugObject()
+{
+	Real halflen = length * 0.5;
+	AxisAlignedBox aabb(-radius,-radius,-(halflen + radius),radius,radius,halflen + radius);
+
+	// X/Y axis - Near
+
+	// NW quadrant
+	addLine(-radius,			0.0,				halflen,
+		-0.866 * radius,	0.5 * radius,		halflen);
+
+	addLine(-0.866 * radius,	0.5 * radius,		halflen,
+		-0.5 * radius,	0.866 * radius,	halflen);
+
+	addLine(-0.5 * radius,	0.866 * radius,	halflen,
+		0.0,				radius,			halflen);
+
+	// NE quadrant
+	addLine(0.0,				radius,			halflen,
+		0.5 * radius,		0.866 * radius,	halflen);
+
+	addLine(0.5 * radius,		0.866 * radius,	halflen,
+		0.866 * radius,	0.5 * radius,		halflen);
+
+	addLine(0.866 * radius,	0.5 * radius,		halflen,
+		radius,			0.0,				halflen);
+
+	// SW quadrant
+	addLine(-radius,			0.0,				halflen,
+		-0.866 * radius,	-0.5 * radius,	halflen);
+
+	addLine(-0.866 * radius,	-0.5 * radius,	halflen,
+		-0.5 * radius,	-0.866 * radius,	halflen);
+
+	addLine(-0.5 * radius,	-0.866 * radius,	halflen,
+		0.0,				-radius,			halflen);
+
+	// SE quadrant
+	addLine(0.0,				-radius,			halflen,
+		0.5 * radius,		-0.866 * radius,	halflen);
+
+	addLine(0.5 * radius,		-0.866 * radius,	halflen,
+		0.866 * radius,	-0.5 * radius,	halflen);
+
+	addLine(0.866 * radius,	-0.5 * radius,	halflen,
+		radius,			0.0,				halflen);
+
+	// X/Y axis - Far
+
+	// NW quadrant
+	addLine(-radius,			0.0,				-halflen,
+		-0.866 * radius,	0.5 * radius,		-halflen);
+
+	addLine(-0.866 * radius,	0.5 * radius,		-halflen,
+		-0.5 * radius,	0.866 * radius,	-halflen);
+
+	addLine(-0.5 * radius,	0.866 * radius,	-halflen,
+		0.0,				radius,			-halflen);
+
+	// NE quadrant
+	addLine(0.0,				radius,			-halflen,
+		0.5 * radius,		0.866 * radius,	-halflen);
+
+	addLine(0.5 * radius,		0.866 * radius,	-halflen,
+		0.866 * radius,	0.5 * radius,		-halflen);
+
+	addLine(0.866 * radius,	0.5 * radius,		-halflen,
+		radius,			0.0,				-halflen);
+
+	// SW quadrant
+	addLine(-radius,			0.0,				-halflen,
+		-0.866 * radius,	-0.5 * radius,	-halflen);
+
+	addLine(-0.866 * radius,	-0.5 * radius,	-halflen,
+		-0.5 * radius,	-0.866 * radius,	-halflen);
+
+	addLine(-0.5 * radius,	-0.866 * radius,	-halflen,
+		0.0,				-radius,			-halflen);
+
+	// SE quadrant
+	addLine(0.0,				-radius,			-halflen,
+		0.5 * radius,		-0.866 * radius,	-halflen);
+
+	addLine(0.5 * radius,		-0.866 * radius,	-halflen,
+		0.866 * radius,	-0.5 * radius,	-halflen);
+
+	addLine(0.866 * radius,	-0.5 * radius,	-halflen,
+		radius,			0.0,				-halflen);
+
+	// X/Z axis
+
+	// NW quadrant
+	addLine(-radius,			0.0,	halflen,	
+		-0.866 * radius,	0.0,	(0.5 * radius) + halflen);
+
+	addLine(-0.866 * radius,	0.0,	(0.5 * radius) + halflen,
+		-0.5 * radius,	0.0,	(0.866 * radius) + halflen);
+
+	addLine(-0.5 * radius,	0.0,	(0.866 * radius) + halflen,
+		0.0,				0.0,	radius + halflen);
+
+	// NE quadrant
+	addLine(0.0,				0.0,	radius + halflen,
+		0.5 * radius,		0.0,	(0.866 * radius) + halflen);
+
+	addLine(0.5 * radius,		0.0,	(0.866 * radius) + halflen,
+		0.866 * radius,	0.0,	(0.5 * radius) + halflen);
+
+	addLine(0.866 * radius,	0.0,	(0.5 * radius) + halflen,
+		radius,			0.0,	halflen);
+
+	// SW quadrant
+	addLine(-radius,			0.0,	-halflen,	
+		-0.866 * radius,	0.0,	(-0.5 * radius) - halflen);
+
+	addLine(-0.866 * radius,	0.0,	(-0.5 * radius) - halflen,
+		-0.5 * radius,	0.0,	(-0.866 * radius) - halflen);
+
+	addLine(-0.5 * radius,	0.0,	(-0.866 * radius) - halflen,
+		0.0,				0.0,	-radius - halflen);
+
+	// SE quadrant
+	addLine(0.0,				0.0,	-radius - halflen,
+		0.5 * radius,		0.0,	(-0.866 * radius) - halflen);
+
+	addLine(0.5 * radius,		0.0,	(-0.866 * radius) - halflen,
+		0.866 * radius,	0.0,	(-0.5 * radius) - halflen);
+
+	addLine(0.866 * radius,	0.0,	(-0.5 * radius) - halflen,
+		radius,			0.0,	- halflen);
+
+	// Y/Z axis
+
+	// NW quadrant
+	addLine(0.0,	-radius,			halflen,	
+		0.0,	-0.866 * radius,	(0.5 * radius) + halflen);
+
+	addLine(0.0,	-0.866 * radius,	(0.5 * radius) + halflen,
+		0.0,	-0.5 * radius,	(0.866 * radius) + halflen);
+
+	addLine(0.0,	-0.5 * radius,	(0.866 * radius) + halflen,
+		0.0,	0.0,				radius + halflen);
+
+	// NE quadrant
+	addLine(0.0,	0.0,				radius + halflen,
+		0.0,	0.5 * radius,		(0.866 * radius) + halflen);
+
+	addLine(0.0,	0.5 * radius,		(0.866 * radius) + halflen,
+		0.0,	0.866 * radius,	(0.5 * radius) + halflen);
+
+	addLine(0.0,	0.866 * radius,	(0.5 * radius) + halflen,
+		0.0,	radius,			halflen);
+
+	// SW quadrant
+	addLine(0.0,	-radius,			-halflen,	
+		0.0,	-0.866 * radius,	(-0.5 * radius) - halflen);
+
+	addLine(0.0,	-0.866 * radius,	(-0.5 * radius) - halflen,
+		0.0,	-0.5 * radius,	(-0.866 * radius) - halflen);
+
+	addLine(0.0,	-0.5 * radius,	(-0.866 * radius) - halflen,
+		0.0,	0.0,				-radius - halflen);
+
+	// SE quadrant
+	addLine(0.0,	0.0,				-radius - halflen,
+		0.0,	0.5 * radius,		(-0.866 * radius) - halflen);
+
+	addLine(0.0,	0.5 * radius,		(-0.866 * radius) - halflen,
+		0.0,	0.866 * radius,	(-0.5 * radius) - halflen);
+
+	addLine(0.0,	0.866 * radius,	(-0.5 * radius) - halflen,
+		0.0,	radius,			-halflen);
+
+	// Side lines
+	addLine(-radius,	0.0,		-halflen,
+		-radius,	0.0,		halflen);
+
+	addLine(radius,	0.0,		-halflen,
+		radius,	0.0,		halflen);
+
+	addLine(0.0,		radius,	-halflen,
+		0.0,		radius,	halflen);
+
+	addLine(0.0,		-radius,	-halflen,
+		0.0,		-radius,	halflen);
+
+	draw();
+}
+//------------------------------------------------------------------------------------------------
+CylinderDebugObject::~CylinderDebugObject()
+{
+}
+//------------------------------------------------------------------------------------------------
+TriangleMeshDebugObject::TriangleMeshDebugObject(int vertex_count):DebugObject()
+{
+    _points.reserve(vertex_count); 
+    _points.resize(vertex_count); 
+}
+//------------------------------------------------------------------------------------------------
+void TriangleMeshDebugObject::beginDefinition()
+{
+}
+//------------------------------------------------------------------------------------------------
+void TriangleMeshDebugObject::setVertex(int index,const Ogre::Vector3& vertex)
+{
+    assert ((unsigned int)index < _points.size());
+	_points[index] = vertex;
+}
+//------------------------------------------------------------------------------------------------
+void TriangleMeshDebugObject::endDefinition()
+{
+	draw();
+}
+//------------------------------------------------------------------------------------------------
+TriangleMeshDebugObject::~TriangleMeshDebugObject()
+{
+}
+//------------------------------------------------------------------------------------------------
+RayDebugObject::RayDebugObject(const Ogre::Vector3& start,
+							   const Ogre::Vector3& direction,
+							   const Ogre::Real length):
+DebugObject()
+{
+
+	Ogre::Vector3 end;
+
+	if(length == Ogre::Math::POS_INFINITY)
+	{
+		end = (start + (direction.normalisedCopy() * 100000.0));
+	}
+	else
+	{
+		end = (start + (direction.normalisedCopy() * length));
+	}
+
+	addLine(start, end);
+
+	draw();
+} 
+void RayDebugObject::setDefinition(const Ogre::Vector3& start,
+								   const Ogre::Vector3& direction,
+								   const Ogre::Real length)
+{
+	clear();
+
+	Ogre::Vector3 end;
+
+	if(length == Ogre::Math::POS_INFINITY)
+	{
+		end = (start + (direction.normalisedCopy() * 100000.0));
+	}
+	else
+	{
+		end = (start + (direction.normalisedCopy() * length));
+	}
+
+	addLine(start, end);
+
+	draw();
+} 
+//------------------------------------------------------------------------------------------------
+RayDebugObject::~RayDebugObject()
+{
+}
+//------------------------------------------------------------------------------------------------
+
Index: /code/branches/physics/src/ogreode/OgreOdeDebugObject.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeDebugObject.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeDebugObject.h	(revision 2122)
@@ -0,0 +1,112 @@
+#ifndef _OGREODEDEBUGOBJECT_H_
+#define _OGREODEDEBUGOBJECT_H_
+
+#include "OgreOdePreReqs.h"
+
+#include <OgreSimpleRenderable.h>
+
+namespace OgreOde
+{
+    //------------------------------------------------------------------------------------------------
+	class _OgreOdeExport DebugLines:public Ogre::SimpleRenderable
+	{
+	public:
+		DebugLines(void);
+		~DebugLines(void);
+
+		void addLine(const Ogre::Vector3 &start,const Ogre::Vector3 &end)
+		{
+			clear();
+
+			_points.push_back(start);
+			_points.push_back(end);
+		}
+		void addLine(Ogre::Real start_x, Ogre::Real start_y, Ogre::Real start_z, 
+            Ogre::Real end_x, Ogre::Real end_y, Ogre::Real end_z)
+		{
+			addLine(Ogre::Vector3(start_x,start_y,start_z),Ogre::Vector3(end_x,end_y,end_z));
+		}
+		void draw();
+		void clear();
+
+		Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const;
+		Ogre::Real getBoundingRadius(void) const;
+
+	protected:
+
+		Vector3Array _points;
+		bool _drawn;
+
+		static bool _materials_created;
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport DebugObject:public DebugLines
+	{
+	public:
+		enum Mode
+		{
+			Mode_Unknown,
+			Mode_Enabled,
+			Mode_Disabled,
+			Mode_Static
+		};
+
+	public:
+        DebugObject(DebugObject::Mode mode = DebugObject::Mode_Enabled);
+		virtual ~DebugObject();
+
+		void setMode(DebugObject::Mode mode);
+
+	protected:
+		DebugObject::Mode _mode;
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport BoxDebugObject:public DebugObject
+	{
+	public:
+		BoxDebugObject(const Ogre::Vector3& size);
+		virtual ~BoxDebugObject();
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport SphereDebugObject:public DebugObject
+	{
+	public:
+		SphereDebugObject(Ogre::Real radius);
+		virtual ~SphereDebugObject();
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport CapsuleDebugObject:public DebugObject
+	{
+	public:
+		CapsuleDebugObject(Ogre::Real radius, Ogre::Real length);
+		virtual ~CapsuleDebugObject();
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport CylinderDebugObject:public DebugObject
+	{
+	public:
+		CylinderDebugObject(Ogre::Real radius, Ogre::Real length);
+		virtual ~CylinderDebugObject();
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TriangleMeshDebugObject:public DebugObject
+	{
+	public:
+		TriangleMeshDebugObject(int vertex_count);
+		virtual ~TriangleMeshDebugObject();
+
+		void beginDefinition();
+		void setVertex(int index, const Ogre::Vector3& vertex);
+		void endDefinition();
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport RayDebugObject:public DebugObject
+	{
+	public:
+		RayDebugObject(const Ogre::Vector3& start,const Ogre::Vector3& direction,const Ogre::Real length);
+		void setDefinition(const Ogre::Vector3& start,const Ogre::Vector3& direction,const Ogre::Real length);
+		virtual ~RayDebugObject();
+	};
+}
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOdeEigenSolver.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeEigenSolver.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeEigenSolver.cpp	(revision 2122)
@@ -0,0 +1,398 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeEigenSolver.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+void EigenSolver::DecrSortEigenStuff3 ()
+{
+	Tridiagonal3();
+	QLAlgorithm();
+	DecreasingSort();
+	GuaranteeRotation();
+}
+
+void EigenSolver::Tridiagonal3 ()
+{
+	const Ogre::Real fM00 = m_kMat[0][0];
+   Ogre::Real fM01 = m_kMat[0][1];
+	Real fM02 = m_kMat[0][2];
+	const Ogre::Real fM11 = m_kMat[1][1];
+	const Ogre::Real fM12 = m_kMat[1][2];
+	const Ogre::Real fM22 = m_kMat[2][2];
+
+	m_afDiag[0] = fM00;
+	m_afSubd[2] = (Real)0.0;
+	if ( fM02 != (Real)0.0 )
+	{
+		const Ogre::Real fLength = sqrtf(fM01*fM01+fM02*fM02);
+		const Ogre::Real fInvLength = ((Real)1.0)/fLength;
+		fM01 *= fInvLength;
+		fM02 *= fInvLength;
+		const Ogre::Real fQ = ((Real)2.0)*fM01*fM12+fM02*(fM22-fM11);
+		m_afDiag[1] = fM11+fM02*fQ;
+		m_afDiag[2] = fM22-fM02*fQ;
+		m_afSubd[0] = fLength;
+		m_afSubd[1] = fM12-fM01*fQ;
+		m_kMat[0][0] = (Real)1.0;
+		m_kMat[0][1] = (Real)0.0;
+		m_kMat[0][2] = (Real)0.0;
+		m_kMat[1][0] = (Real)0.0;
+		m_kMat[1][1] = fM01;
+		m_kMat[1][2] = fM02;
+		m_kMat[2][0] = (Real)0.0;
+		m_kMat[2][1] = fM02;
+		m_kMat[2][2] = -fM01;
+	}
+	else
+	{
+		m_afDiag[1] = fM11;
+		m_afDiag[2] = fM22;
+		m_afSubd[0] = fM01;
+		m_afSubd[1] = fM12;
+		m_kMat[0][0] = (Real)1.0;
+		m_kMat[0][1] = (Real)0.0;
+		m_kMat[0][2] = (Real)0.0;
+		m_kMat[1][0] = (Real)0.0;
+		m_kMat[1][1] = (Real)1.0;
+		m_kMat[1][2] = (Real)0.0;
+		m_kMat[2][0] = (Real)0.0;
+		m_kMat[2][1] = (Real)0.0;
+		m_kMat[2][2] = (Real)1.0;
+	}
+}
+
+bool EigenSolver::QLAlgorithm ()
+{
+	const int iMaxIter = 32;
+
+	for (int i0 = 0; i0 < m_iSize; i0++)
+	{
+		int i1;
+		for (i1 = 0; i1 < iMaxIter; i1++)
+		{
+			int i2;
+			for (i2 = i0; i2 <= m_iSize-2; i2++)
+			{
+				Real fTmp = fabs(m_afDiag[i2]) + fabs(m_afDiag[i2+1]);
+				if ( fabs(m_afSubd[i2]) + fTmp == fTmp ) break;
+			}
+			if ( i2 == i0 ) break;
+
+			Real fG = (m_afDiag[i0+1] - m_afDiag[i0])/(((Real)2.0) * m_afSubd[i0]);
+			Real fR = sqrtf(fG*fG+(Real)1.0);
+			if ( fG < (Real)0.0 ) fG = m_afDiag[i2]-m_afDiag[i0]+m_afSubd[i0]/(fG-fR);
+			else fG = m_afDiag[i2]-m_afDiag[i0]+m_afSubd[i0]/(fG+fR);
+			Real fSin = (Real)1.0, fCos = (Real)1.0, fP = (Real)0.0;
+			for (int i3 = i2-1; i3 >= i0; i3--)
+			{
+				Real fF = fSin*m_afSubd[i3];
+               Ogre::Real fB = fCos*m_afSubd[i3];
+	            if ( fabs(fF) >= fabs(fG) )
+		        {
+			        fCos = fG/fF;
+				    fR = sqrtf(fCos*fCos+(Real)1.0);
+					m_afSubd[i3+1] = fF*fR;
+                    fSin = ((Real)1.0)/fR;
+	                fCos *= fSin;
+		        }
+			    else
+				{
+					fSin = fF/fG;
+					fR = sqrtf(fSin*fSin+(Real)1.0);
+					m_afSubd[i3+1] = fG*fR;
+					fCos = ((Real)1.0)/fR;
+					fSin *= fCos;
+				}
+				fG = m_afDiag[i3+1]-fP;
+                fR = (m_afDiag[i3]-fG)*fSin+((Real)2.0)*fB*fCos;
+	            fP = fSin*fR;
+		        m_afDiag[i3+1] = fG+fP;
+			    fG = fCos*fR-fB;
+
+				for (int i4 = 0; i4 < m_iSize; i4++)
+				{
+					fF = m_kMat[i4][i3+1];
+                    m_kMat[i4][i3+1] = fSin*m_kMat[i4][i3]+fCos*fF;
+	                m_kMat[i4][i3] = fCos*m_kMat[i4][i3]-fSin*fF;
+		        }
+			}
+			m_afDiag[i0] -= fP;
+			m_afSubd[i0] = fG;
+			m_afSubd[i2] = (Real)0.0;
+		}
+		if ( i1 == iMaxIter ) return false;
+	}
+	return true;
+}
+
+void EigenSolver::DecreasingSort ()
+{
+	// sort eigenvalues in decreasing order, e[0] >= ... >= e[iSize-1]
+	for (int i0 = 0, i1; i0 <= m_iSize-2; i0++)
+	{
+		// locate maximum eigenvalue
+		i1 = i0;
+		Real fMax = m_afDiag[i1];
+		int i2;
+		for (i2 = i0+1; i2 < m_iSize; i2++)
+		{
+			if ( m_afDiag[i2] > fMax )
+			{
+				i1 = i2;
+				fMax = m_afDiag[i1];
+			}
+		}
+
+		if ( i1 != i0 )
+		{
+			// swap eigenvalues
+			m_afDiag[i1] = m_afDiag[i0];
+			m_afDiag[i0] = fMax;
+
+			// swap eigenvectors
+			for (i2 = 0; i2 < m_iSize; i2++)
+			{
+				Real fTmp = m_kMat[i2][i0];
+				m_kMat[i2][i0] = m_kMat[i2][i1];
+				m_kMat[i2][i1] = fTmp;
+				m_bIsRotation = !m_bIsRotation;
+			}
+		}
+	}
+}
+
+void EigenSolver::GuaranteeRotation ()
+{
+	if ( !m_bIsRotation )
+	{
+		// change sign on the first column
+		for (int iRow = 0; iRow < m_iSize; iRow++) 
+            m_kMat[iRow][0] = -m_kMat[iRow][0];
+	}
+}
+
+void EigenSolver::orthogonalLineFit(unsigned int vertex_count, const Ogre::Vector3* vertices,Vector3& origin,Vector3& direction)
+{
+	unsigned int i;
+
+    // compute average of points
+	origin = vertices[0];
+    for(i = 1; i < vertex_count; ++i) 
+        origin += vertices[i];
+
+	const Ogre::Real fInvQuantity = 1.0 / vertex_count;
+	origin *= fInvQuantity;
+
+	// compute sums of products
+	Real fSumXX = 0.0, fSumXY = 0.0, fSumXZ = 0.0;
+   Ogre::Real fSumYY = 0.0, fSumYZ = 0.0, fSumZZ = 0.0;
+	for (i = 0; i < vertex_count; i++) 
+	{
+		const Ogre::Vector3 kDiff (vertices[i] - origin);
+	    fSumXX += kDiff.x*kDiff.x;
+        fSumXY += kDiff.x*kDiff.y;
+		fSumXZ += kDiff.x*kDiff.z;
+	    fSumYY += kDiff.y*kDiff.y;
+        fSumYZ += kDiff.y*kDiff.z;
+		fSumZZ += kDiff.z*kDiff.z;
+	}
+	fSumXX *= fInvQuantity;
+	fSumXY *= fInvQuantity;
+	fSumXZ *= fInvQuantity;
+	fSumYY *= fInvQuantity;
+	fSumYZ *= fInvQuantity;
+	fSumZZ *= fInvQuantity;
+
+	// setup the eigensolver
+	EigenSolver kES(3);
+	kES(0,0) = fSumYY+fSumZZ;
+	kES(0,1) = -fSumXY;
+	kES(0,2) = -fSumXZ;
+	kES(1,0) = kES(0,1);
+	kES(1,1) = fSumXX+fSumZZ;
+	kES(1,2) = -fSumYZ;
+	kES(2,0) = kES(0,2);
+	kES(2,1) = kES(1,2);
+    kES(2,2) = fSumXX+fSumYY;
+
+	// compute eigenstuff, smallest eigenvalue is in last position
+	kES.DecrSortEigenStuff3();
+
+    // unit-length direction for best-fit line
+	kES.GetEigenvector(2,direction);
+}
+
+Real EigenSolver::SqrDistance(const Ogre::Vector3& rkPoint,const Ogre::Vector3& origin,const Ogre::Vector3& direction)
+{
+	Vector3 kDiff(rkPoint - origin);
+    const Ogre::Real fSqrLen = direction.squaredLength();
+	const Ogre::Real fT = kDiff.dotProduct(direction) / fSqrLen;
+
+    kDiff -= fT*direction;
+
+	return kDiff.squaredLength();
+}
+
+void EigenSolver::GenerateOrthonormalBasis (Vector3& rkU, Ogre::Vector3& rkV, Ogre::Vector3& rkW, bool bUnitLengthW)
+{
+	if ( !bUnitLengthW ) rkW.normalise();
+
+	Real fInvLength;
+
+	if ( fabs(rkW[0]) >= fabs(rkW[1]) )
+	{
+		// W.x or W.z is the largest magnitude component, swap them
+		fInvLength = 1.0 / sqrtf(rkW[0]*rkW[0] + rkW[2]*rkW[2]);
+
+	    rkU[0] = -rkW[2]*fInvLength;
+        rkU[1] = (Real)0.0;
+		rkU[2] = +rkW[0]*fInvLength;
+	}
+    else
+	{
+        // W.y or W.z is the largest magnitude component, swap them
+		fInvLength = 1.0 / sqrtf(rkW[1]*rkW[1] + rkW[2]*rkW[2]);
+
+	    rkU[0] = (Real)0.0;
+        rkU[1] = +rkW[2]*fInvLength;
+		rkU[2] = -rkW[1]*fInvLength;
+	}
+
+	rkV = rkW.crossProduct(rkU);
+}
+
+EigenSolver::EigenSolver(int iSize)
+{
+	assert( iSize >= 2 );
+    m_iSize = iSize;
+	m_afDiag = new Ogre::Real[m_iSize];
+    m_afSubd = new Ogre::Real[m_iSize];
+
+	// set according to the parity of the number of Householder reflections
+	m_bIsRotation = ((iSize % 2) == 0);
+}
+
+Ogre::Real& EigenSolver::operator() (int iRow, int iCol)
+{
+	return m_kMat[iRow][iCol];
+}
+
+EigenSolver::~EigenSolver()
+{
+    delete[] m_afSubd;
+	delete[] m_afDiag;
+}
+
+void EigenSolver::GetEigenvector (int i, Ogre::Vector3& rkV) const
+{
+	assert( m_iSize == 3 );
+	if ( m_iSize == 3 )
+	{
+		for (int iRow = 0; iRow < m_iSize; iRow++) 
+            rkV[iRow] = m_kMat[iRow][i];
+	}
+	else
+	{
+	    rkV = Ogre::Vector3::ZERO;
+    }
+}
+
+void EigenSolver::GaussPointsFit(unsigned int iQuantity,const Ogre::Vector3* akPoint,Vector3 &rkCenter,Vector3 akAxis[3],Real afExtent[3])
+{
+    // compute mean of points
+    rkCenter = akPoint[0];
+    unsigned int i;
+    for (i = 1; i < iQuantity; i++)
+        rkCenter += akPoint[i];
+    const Ogre::Real fInvQuantity = ((Real)1.0)/iQuantity;
+    rkCenter *= fInvQuantity;
+
+    // compute covariances of points
+   Ogre::Real fSumXX = (Real)0.0, fSumXY = (Real)0.0, fSumXZ = (Real)0.0;
+   Ogre::Real fSumYY = (Real)0.0, fSumYZ = (Real)0.0, fSumZZ = (Real)0.0;
+    for (i = 0; i < iQuantity; i++)
+    {
+        const Ogre::Vector3 kDiff (akPoint[i] - rkCenter);
+        fSumXX += kDiff.x*kDiff.x;
+        fSumXY += kDiff.x*kDiff.y;
+        fSumXZ += kDiff.x*kDiff.z;
+        fSumYY += kDiff.y*kDiff.y;
+        fSumYZ += kDiff.y*kDiff.z;
+        fSumZZ += kDiff.z*kDiff.z;
+    }
+    fSumXX *= fInvQuantity;
+    fSumXY *= fInvQuantity;
+    fSumXZ *= fInvQuantity;
+    fSumYY *= fInvQuantity;
+    fSumYZ *= fInvQuantity;
+    fSumZZ *= fInvQuantity;
+
+    // compute eigenvectors for covariance matrix
+    EigenSolver kES(3);
+    kES(0,0) = fSumXX;
+    kES(0,1) = fSumXY;
+    kES(0,2) = fSumXZ;
+    kES(1,0) = fSumXY;
+    kES(1,1) = fSumYY;
+    kES(1,2) = fSumYZ;
+    kES(2,0) = fSumXZ;
+    kES(2,1) = fSumYZ;
+    kES(2,2) = fSumZZ;
+    kES.IncrSortEigenStuff3();
+
+    for (i = 0; i < 3; i++)
+    {
+        afExtent[i] = kES.GetEigenvalue(i);
+        kES.GetEigenvector(i,akAxis[i]);
+    }
+}
+
+Real EigenSolver::GetEigenvalue (int i) const
+{
+    return m_afDiag[i];
+}
+
+void EigenSolver::IncrSortEigenStuff3 ()
+{
+    Tridiagonal3();
+    QLAlgorithm();
+    IncreasingSort();
+    GuaranteeRotation();
+}
+
+void EigenSolver::IncreasingSort ()
+{
+    // sort eigenvalues in increasing order, e[0] <= ... <= e[iSize-1]
+    for (int i0 = 0, i1; i0 <= m_iSize-2; i0++)
+    {
+        // locate minimum eigenvalue
+        i1 = i0;
+       Ogre::Real fMin = m_afDiag[i1];
+        int i2;
+        for (i2 = i0+1; i2 < m_iSize; i2++)
+        {
+            if ( m_afDiag[i2] < fMin )
+            {
+                i1 = i2;
+                fMin = m_afDiag[i1];
+            }
+        }
+
+        if ( i1 != i0 )
+        {
+            // swap eigenvalues
+            m_afDiag[i1] = m_afDiag[i0];
+            m_afDiag[i0] = fMin;
+
+            // swap eigenvectors
+            for (i2 = 0; i2 < m_iSize; i2++)
+            {
+               Ogre::Real fTmp = m_kMat[i2][i0];
+                m_kMat[i2][i0] = m_kMat[i2][i1];
+                m_kMat[i2][i1] = fTmp;
+                m_bIsRotation = !m_bIsRotation;
+            }
+        }
+    }
+}
Index: /code/branches/physics/src/ogreode/OgreOdeEigenSolver.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeEigenSolver.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeEigenSolver.h	(revision 2122)
@@ -0,0 +1,70 @@
+#ifndef _OGREODEEIGENSOLVER_H_
+#define _OGREODEEIGENSOLVER_H_
+
+#include "OgreOdePreReqs.h"
+
+#include <OgreMatrix3.h>
+
+namespace OgreOde 
+{
+	class _OgreOdeExport EigenSolver
+	{
+	public:
+		EigenSolver(int iSize);
+		~EigenSolver();
+
+		// set the matrix for eigensolving
+		Ogre::Real& operator() (int iRow, int iCol);
+
+		// Get the eigenresults (eigenvectors are columns of eigenmatrix).  The
+		// GetEigenvector calls involving Vector2, Ogre::Vector3, and Vector4 should
+		// only be called if you know that the eigenmatrix is of the appropriate
+		// size.
+	    void GetEigenvector (int i, Ogre::Vector3& rkV) const;
+		Ogre::Real GetEigenvalue (int i) const;
+
+		// solve eigensystem, use decreasing sort on eigenvalues
+	    void DecrSortEigenStuff3 ();
+		void IncrSortEigenStuff3 ();
+
+		static void GenerateOrthonormalBasis (Ogre::Vector3& rkU, Ogre::Vector3& rkV, Ogre::Vector3& rkW, bool bUnitLengthW);
+		static void orthogonalLineFit(unsigned int vertex_count, const Ogre::Vector3* vertices, Ogre::Vector3& origin, Ogre::Vector3& direction);
+		static Ogre::Real SqrDistance(const Ogre::Vector3& rkPoint,const Ogre::Vector3& origin,const Ogre::Vector3& direction);
+		static void GaussPointsFit(unsigned int iQuantity,const Ogre::Vector3* akPoint, Ogre::Vector3 &rkCenter, Ogre::Vector3 akAxis[3], Ogre::Real afExtent[3]);
+
+	protected:
+		int m_iSize;
+		Ogre::Matrix3 m_kMat;
+		Ogre::Real* m_afDiag;
+		Ogre::Real* m_afSubd;
+
+		// For odd size matrices, the Householder reduction involves an odd
+		// number of reflections.  The product of these is a reflection.  The
+		// QL algorithm uses rotations for further reductions.  The final
+		// orthogonal matrix whose columns are the eigenvectors is a reflection,
+		// so its determinant is -1.  For even size matrices, the Householder
+		// reduction involves an even number of reflections whose product is a
+		// rotation.  The final orthogonal matrix has determinant +1.  Many
+		// algorithms that need an eigendecomposition want a rotation matrix.
+		// We want to guarantee this is the case, so m_bRotation keeps track of
+		// this.  The DecrSort and IncrSort further complicate the issue since
+		// they swap columns of the orthogonal matrix, causing the matrix to
+		// toggle between rotation and reflection.  The value m_bRotation must
+		// be toggled accordingly.
+		bool m_bIsRotation;
+		void GuaranteeRotation ();
+
+		// Householder reduction to tridiagonal form
+	    void Tridiagonal3 ();
+  
+		// QL algorithm with implicit shifting, applies to tridiagonal matrices
+		bool QLAlgorithm ();
+
+		// sort eigenvalues from largest to smallest
+		void DecreasingSort ();
+
+		void IncreasingSort ();
+	};
+}
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOdeEntityInformer.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeEntityInformer.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeEntityInformer.cpp	(revision 2122)
@@ -0,0 +1,766 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeEntityInformer.h"
+
+#include <OgreEntity.h>
+#include <OgreSubEntity.h>
+#include <OgreSceneNode.h>
+#include <OgreSubMesh.h>
+#include <OgreLogManager.h>
+#include <OgreSkeletonInstance.h>
+#include <OgreBone.h>
+
+#include "OgreOdeBody.h"
+#include "OgreOdeGeometry.h"
+#include "OgreOdeMass.h"
+#include "OgreOdeEigenSolver.h"
+#include "OgreOdeTriangleMeshDataManager.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+void EntityInformer::addVertexData(const VertexData *vertex_data,
+                                   const VertexData *blended_data,
+                                   const Mesh::IndexMap *indexMap)
+{
+	if (!vertex_data) 
+        return;
+
+	const VertexData *data = (blended_data) ? blended_data: vertex_data;
+
+	const unsigned int prev_size = _vertex_count;
+    _vertex_count += (unsigned int)data->vertexCount;
+
+    Ogre::Vector3* tmp_vert = new Ogre::Vector3[_vertex_count];
+	if (_vertices)
+	{
+		memcpy(tmp_vert,_vertices,sizeof(Vector3) * prev_size);
+		delete[] _vertices;
+	}
+	_vertices = tmp_vert;
+
+	// Get the positional buffer element
+    {	
+        const Ogre::VertexElement* posElem = data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);			
+        Ogre::HardwareVertexBufferSharedPtr vbuf = data->vertexBufferBinding->getBuffer(posElem->getSource());
+        const unsigned int vSize = (unsigned int)vbuf->getVertexSize();
+
+	    unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
+	    float* pReal;
+        Ogre::Vector3 * curVertices = &_vertices[prev_size];
+        const unsigned int vertexCount = (unsigned int)data->vertexCount;
+	    for(unsigned int j = 0; j < vertexCount; ++j)
+	    {
+		    posElem->baseVertexPointerToElement(vertex, &pReal);
+            vertex += vSize;
+
+		    curVertices->x = (*pReal++);
+		    curVertices->y = (*pReal++);
+		    curVertices->z = (*pReal++);
+
+		    *curVertices = _transform * (*curVertices);
+            
+            curVertices++;
+        }
+	    vbuf->unlock();
+    }
+
+	// Get the bone index element
+	if (_entity && _entity->hasSkeleton())
+	{
+
+        Ogre::MeshPtr mesh = _entity->getMesh ();
+
+		const Ogre::VertexElement* bneElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_BLEND_INDICES);
+		assert (bneElem);
+		{
+            Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(bneElem->getSource());
+            const unsigned int vSize = (unsigned int)vbuf->getVertexSize();
+			unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
+
+			unsigned char* pBone;
+
+            if (!_bone_mapping)
+                _bone_mapping = new BoneMapping();	
+            BoneMapping::iterator i;
+
+            Ogre::Vector3 * curVertices = &_vertices[prev_size];
+            
+            const unsigned int vertexCount = (unsigned int)vertex_data->vertexCount;
+			for(unsigned int j = 0; j < vertexCount; ++j)
+			{
+				bneElem->baseVertexPointerToElement(vertex, &pBone);
+                vertex += vSize;
+               
+                const unsigned char currBone = (indexMap) ? (*indexMap)[*pBone] : *pBone;
+				i = _bone_mapping->find (currBone);
+				Vector3Array* l = 0;
+				if (i == _bone_mapping->end())
+				{
+					l = new Vector3Array;
+					_bone_mapping->insert(BoneMappingKey(currBone, l));
+				}						
+				else 
+                {
+                    l = i->second;
+                }
+
+				l->push_back(*curVertices);
+
+                curVertices++;
+			}
+			vbuf->unlock();
+		}
+	}
+}
+
+
+//------------------------------------------------------------------------------------------------
+void EntityInformer::addIndexData(IndexData *data, const unsigned int offset)
+{
+    const unsigned int prev_size = _index_count;
+    _index_count += (unsigned int)data->indexCount;
+
+	TriangleIndex* tmp_ind = new TriangleIndex[_index_count];
+	if (_indices)
+	{
+		memcpy (tmp_ind, _indices, sizeof(unsigned int) * prev_size);
+		delete[] _indices;
+	}
+	_indices = tmp_ind;
+
+	const unsigned int numTris = (unsigned int) data->indexCount / 3;
+	HardwareIndexBufferSharedPtr ibuf = data->indexBuffer;	
+	const bool use32bitindexes = (ibuf->getType() == HardwareIndexBuffer::IT_32BIT);
+    unsigned int index_offset = prev_size;
+
+	if (use32bitindexes) 
+    {
+        const unsigned int* pInt = static_cast<unsigned int*>(ibuf->lock(HardwareBuffer::HBL_READ_ONLY));
+        for(unsigned int k = 0; k < numTris; ++k)
+        {
+            _indices[index_offset ++] = offset + *pInt++;
+            _indices[index_offset ++] = offset + *pInt++;
+            _indices[index_offset ++] = offset + *pInt++;
+        }
+        ibuf->unlock();
+    }
+	else 
+    {
+        const unsigned short* pShort = static_cast<unsigned short*>(ibuf->lock(HardwareBuffer::HBL_READ_ONLY));
+		for(unsigned int k = 0; k < numTris; ++k)
+        {
+            _indices[index_offset ++] = offset + static_cast<unsigned int> (*pShort++);
+            _indices[index_offset ++] = offset + static_cast<unsigned int> (*pShort++);
+            _indices[index_offset ++] = offset + static_cast<unsigned int> (*pShort++);
+        }
+        ibuf->unlock();
+    }
+
+}
+//------------------------------------------------------------------------------------------------
+void EntityInformer::addEntity(Entity *entity,const Matrix4 &transform)
+{
+	// Each entity added need to reset size and radius
+	// next time getRadius and getSize are asked, they're computed.
+	_size  = Ogre::Vector3(-1,-1,-1);
+	_radius = -1;
+
+	_entity = entity;
+	_node = (SceneNode*)(_entity->getParentNode());
+	_transform = transform;
+
+	const bool isSkeletonAnimated = _entity->hasSkeleton();
+	//const bool isHWanimated = isSkeletonAnimated && entity->isHardwareAnimationEnabled();
+	if (isSkeletonAnimated)
+	{
+		_entity->addSoftwareAnimationRequest(false);
+		_entity->_updateAnimation();
+	}
+
+
+	if (_entity->getMesh()->sharedVertexData)
+	{
+		if (!isSkeletonAnimated)
+			addVertexData (_entity->getMesh()->sharedVertexData);
+		else
+			addVertexData (_entity->getMesh()->sharedVertexData, 
+			_entity->_getSkelAnimVertexData(),
+			&_entity->getMesh()->sharedBlendIndexToBoneIndexMap); 
+	}
+
+	for(unsigned int i = 0;i < _entity->getNumSubEntities();++i)
+	{
+		SubMesh *sub_mesh = _entity->getSubEntity(i)->getSubMesh();
+
+		if (!sub_mesh->useSharedVertices)
+		{
+			addIndexData(sub_mesh->indexData,_vertex_count);
+
+			if (!isSkeletonAnimated)
+				addVertexData (sub_mesh->vertexData);
+			else
+				addVertexData (sub_mesh->vertexData, 
+				_entity->getSubEntity(i)->_getSkelAnimVertexData(),
+				&sub_mesh->blendIndexToBoneIndexMap); 
+		}
+		else 
+		{
+			addIndexData (sub_mesh->indexData);
+		}
+
+	}
+
+	if (isSkeletonAnimated) 
+		_entity->removeSoftwareAnimationRequest(false);
+}
+//------------------------------------------------------------------------------------------------
+void EntityInformer::addMesh(const MeshPtr &mesh, const Matrix4 &transform)
+{
+	// Each entity added need to reset size and radius
+	// next time getRadius and getSize are asked, they're computed.
+	_size  = Ogre::Vector3(-1,-1,-1);
+	_radius = -1;
+
+	//_entity = entity;
+	//_node = (SceneNode*)(_entity->getParentNode());
+	_transform = transform;
+
+	if (mesh->hasSkeleton ())
+		Ogre::LogManager::getSingleton().logMessage("EntityInformer::addMesh : Mesh " + mesh->getName () + " as skeleton but added to trimesh non animated");
+// 		OGRE_EXCEPT(1, "Mesh " + mesh->getName () + " as skeleton but added to trimesh non animated", 
+// 					"EntityInformer::addMesh");
+
+	if (mesh->sharedVertexData)
+	{
+		addVertexData (mesh->sharedVertexData);
+	}
+
+	for(unsigned int i = 0;i < mesh->getNumSubMeshes();++i)
+	{
+		SubMesh *sub_mesh = mesh->getSubMesh(i);
+
+		if (!sub_mesh->useSharedVertices)
+		{
+			addIndexData(sub_mesh->indexData, _vertex_count);
+			addVertexData (sub_mesh->vertexData);
+		}
+		else 
+		{
+			addIndexData (sub_mesh->indexData);
+		}
+
+	}
+}
+//------------------------------------------------------------------------------------------------
+EntityInformer::EntityInformer(Entity *entity,const Matrix4 &transform) :
+	_radius (-1),
+	_size (Vector3(-1,-1,-1)),
+	_center (Vector3(-1,-1,-1)),
+	_vertices (0),
+	_indices (0),
+	_vertex_count (0),
+	_index_count (0),
+	_bone_mapping (0)
+{
+	addEntity(entity, transform);	
+}
+//------------------------------------------------------------------------------------------------
+EntityInformer::EntityInformer() :
+		_radius (-1),
+		_size (Vector3(-1,-1,-1)),
+		_center (Vector3(-1,-1,-1)),
+		_vertices (0),
+		_indices (0),
+		_vertex_count (0),
+		_index_count (0),
+        _bone_mapping (0)
+{
+	 
+}
+//------------------------------------------------------------------------------------------------
+Real EntityInformer::getRadius()
+{
+	if (_radius == (-1))
+	{
+		getSize();
+		_radius = (std::max(_size.x,std::max(_size.y,_size.z)) * 0.5);
+	}
+	return _radius;
+}
+//------------------------------------------------------------------------------------------------
+Vector3 EntityInformer::getSize()
+{
+    const unsigned int vCount = getVertexCount();
+	if (_size == Ogre::Vector3(-1,-1,-1) && vCount > 0)
+	{
+
+		const Ogre::Vector3 * const v = getVertices();
+
+        Ogre::Vector3 vmin(v[0]);
+        Ogre::Vector3 vmax(v[0]);
+
+		for(unsigned int j = 1; j < vCount; j++)
+		{
+			vmin.x = std::min(vmin.x, v[j].x);
+			vmin.y = std::min(vmin.y, v[j].y);
+			vmin.z = std::min(vmin.z, v[j].z);
+
+			vmax.x = std::max(vmax.x, v[j].x);
+			vmax.y = std::max(vmax.y, v[j].y);
+			vmax.z = std::max(vmax.z, v[j].z);
+		}
+
+		_size.x = vmax.x - vmin.x;
+		_size.y = vmax.y - vmin.y;
+		_size.z = vmax.z - vmin.z;
+
+		_center.x = vmin.x + _size.x * 0.5;
+		_center.y = vmin.y + _size.y * 0.5;
+		_center.z = vmin.z + _size.z * 0.5;
+
+	}
+
+	return _size;
+}
+//------------------------------------------------------------------------------------------------
+Vector3 EntityInformer::getCenter()
+{
+	const unsigned int vCount = getVertexCount();
+	if (_center == Ogre::Vector3(-1,-1,-1) && vCount > 0)
+	{
+		getSize();
+	}
+
+	return _center;
+}
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3* EntityInformer::getVertices()
+{
+	return _vertices;
+}
+//------------------------------------------------------------------------------------------------
+unsigned int EntityInformer::getVertexCount()
+{
+	return _vertex_count;
+}
+//------------------------------------------------------------------------------------------------
+const TriangleIndex* EntityInformer::getIndices()
+{
+	return _indices;
+}
+//------------------------------------------------------------------------------------------------
+unsigned int EntityInformer::getIndexCount()
+{
+	return _index_count;
+}
+//------------------------------------------------------------------------------------------------
+Body* EntityInformer::createSingleDynamicSphere(Real mass, World *world, Space* space)
+{
+	const Ogre::Real rad = getRadius();
+
+	assert((rad > 0.0) && 
+        ("Sphere radius must be greater than zero"));
+
+	Body* body = new Body(world, "OgreOde::Body_" + _entity->getName());
+	body->setMass(SphereMass(mass, rad));
+
+	SphereGeometry* geom = new SphereGeometry(rad, world, space);
+	geom->setBody(body);
+
+	body->setPosition(_node->_getDerivedPosition());
+	body->setOrientation(_node->_getDerivedOrientation());
+
+	_node->attachObject(body);
+
+	return body;
+}
+//------------------------------------------------------------------------------------------------
+Body* EntityInformer::createSingleDynamicBox(Real mass, World *world, Space* space)
+{
+	const Ogre::Vector3 sz = getSize();
+
+	assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.y > 0.0) && 
+        ("Size of box must be greater than zero on all axes"));
+
+	Body* body = new Body(world, "OgreOde::Body_" + _node->getName());
+	body->setMass(BoxMass(mass,sz));
+
+	BoxGeometry* geom = new BoxGeometry(sz, world, space);
+	geom->setBody(body);
+
+	body->setPosition(_node->_getDerivedPosition());
+	body->setOrientation(_node->_getDerivedOrientation());
+
+	_node->attachObject(body);
+
+	return body;
+}
+//------------------------------------------------------------------------------------------------
+TriangleMeshGeometry* EntityInformer::createStaticTriangleMesh(World *world, Space* space)
+{
+	assert(_vertex_count && (_index_count >= 6) && 
+        ("Mesh must have some vertices and at least 6 indices (2 triangles)"));
+
+	return new TriangleMeshGeometry(_vertices, _vertex_count,_indices, _index_count, world, space);
+}
+//------------------------------------------------------------------------------------------------
+BoxGeometry* EntityInformer::createSingleStaticBox(World *world, Space* space)
+{
+	BoxGeometry* geom = new BoxGeometry(getSize(), world, space);
+
+	geom->setPosition(_node->_getDerivedPosition());
+	geom->setOrientation(_node->_getDerivedOrientation());
+
+	return geom;
+}
+//------------------------------------------------------------------------------------------------
+bool EntityInformer::getBoneVertices(unsigned char bone, unsigned int &vertex_count, Ogre::Vector3* &vertices)
+{
+	BoneMapping::iterator i = _bone_mapping->find(bone);
+	
+    if (i == _bone_mapping->end()) 
+        return false;
+
+	if (i->second->empty()) 
+        return false;
+
+    vertex_count = (unsigned int) i->second->size() + 1;
+
+	vertices = new Ogre::Vector3[vertex_count];
+	vertices[0] = _entity->_getParentNodeFullTransform() * 
+            _entity->getSkeleton()->getBone(bone)->_getDerivedPosition();
+
+	unsigned int o = 1;
+	for(Vector3Array::iterator j = i->second->begin();
+        j != i->second->end(); ++j,++o) 
+    {
+        vertices[o] = (*j);
+    }       
+	return true;
+}
+//------------------------------------------------------------------------------------------------
+BoxGeometry* EntityInformer::createAlignedBox(unsigned char bone, World *world, Space* space)
+{
+	unsigned int vertex_count;
+	Vector3* vertices;
+	if (!getBoneVertices(bone, vertex_count, vertices)) 
+        return 0;
+
+	Vector3 min_vec(vertices[0]);
+	Vector3 max_vec(vertices[0]);
+
+	for(unsigned int j = 1; j < vertex_count ;j++)
+	{
+		min_vec.x = std::min(min_vec.x,vertices[j].x);
+		min_vec.y = std::min(min_vec.y,vertices[j].y);
+		min_vec.z = std::min(min_vec.z,vertices[j].z);
+
+		max_vec.x = std::max(max_vec.x,vertices[j].x);
+		max_vec.y = std::max(max_vec.y,vertices[j].y);
+		max_vec.z = std::max(max_vec.z,vertices[j].z);
+	}
+    const Ogre::Vector3 maxMinusMin(max_vec - min_vec);
+    BoxGeometry* box = new BoxGeometry(maxMinusMin, world, space);
+
+    const Ogre::Vector3 pos(min_vec.x + (maxMinusMin.x * 0.5),
+                      min_vec.y + (maxMinusMin.y * 0.5),
+                      min_vec.z + (maxMinusMin.z * 0.5));
+
+	box->setPosition(pos);
+
+	delete[] vertices;
+
+	return box;
+}
+//------------------------------------------------------------------------------------------------
+BoxGeometry* EntityInformer::createOrientedBox(unsigned char bone, World *world, Space* space)
+{
+
+#define TESTOOB
+#ifdef TESTOOB
+	unsigned int vertex_count;
+	Vector3* vertices;
+	if (!getBoneVertices(bone, vertex_count, vertices))
+		return 0;
+
+	Vector3 box_kCenter(Vector3::ZERO);
+	Ogre::Vector3 box_akAxis[3];
+	Ogre::Real box_afExtent[3];
+
+	//   EigenSolver::GaussPointsFit (vertex_count-1, &vertices[1], box_kCenter, box_akAxis, box_afExtent);
+
+	Ogre::Real invVertexCount=1.0/(Ogre::Real)vertex_count;
+	for(size_t c=0;c<vertex_count;c++)
+	{
+		box_kCenter+=vertices[c];
+	}
+	box_kCenter*=invVertexCount;
+
+	Quaternion orient=_entity->getSkeleton()->getBone(bone)->_getDerivedOrientation();
+	orient.ToAxes(box_akAxis);
+
+
+	// Let C be the box center and let U0, U1, and U2 be the box axes.  Each
+	// input point is of the form X = C + y0*U0 + y1*U1 + y2*U2.  The
+	// following code computes min(y0), max(y0), min(y1), max(y1), min(y2),
+	// and max(y2).  The box center is then adjusted to be
+	//   C' = C + 0.5*(min(y0)+max(y0))*U0 + 0.5*(min(y1)+max(y1))*U1 +
+	//        0.5*(min(y2)+max(y2))*U2
+
+
+	Ogre::Vector3 kDiff (vertices[1] - box_kCenter);
+	Ogre::Real fY0Min = kDiff.dotProduct(box_akAxis[0]), fY0Max = fY0Min;
+	Ogre::Real fY1Min = kDiff.dotProduct(box_akAxis[1]), fY1Max = fY1Min;
+	Ogre::Real fY2Min = kDiff.dotProduct(box_akAxis[2]), fY2Max = fY2Min;
+
+	for (unsigned int i = 2; i < vertex_count; i++)
+	{
+		kDiff = vertices[i] - box_kCenter;
+
+		const Ogre::Real fY0 = kDiff.dotProduct(box_akAxis[0]);
+		if ( fY0 < fY0Min )
+			fY0Min = fY0;
+		else if ( fY0 > fY0Max )
+			fY0Max = fY0;
+
+		const Ogre::Real fY1 = kDiff.dotProduct(box_akAxis[1]);
+		if ( fY1 < fY1Min )
+			fY1Min = fY1;
+		else if ( fY1 > fY1Max )
+			fY1Max = fY1;
+
+		const Ogre::Real fY2 = kDiff.dotProduct(box_akAxis[2]);
+		if ( fY2 < fY2Min )
+			fY2Min = fY2;
+		else if ( fY2 > fY2Max )
+			fY2Max = fY2;
+	}
+
+	box_afExtent[0] = ((Real)0.5)*(fY0Max - fY0Min);
+	box_afExtent[1] = ((Real)0.5)*(fY1Max - fY1Min);
+	box_afExtent[2] = ((Real)0.5)*(fY2Max - fY2Min);
+
+	box_kCenter += (0.5*(fY0Max+fY0Min))*box_akAxis[0] +
+		(0.5*(fY1Max+fY1Min))*box_akAxis[1] +
+		(0.5*(fY2Max+fY2Min))*box_akAxis[2];
+
+	BoxGeometry *geom = new BoxGeometry(Vector3(box_afExtent[0] * 2.0,
+		box_afExtent[1] * 2.0,
+		box_afExtent[2] * 2.0),
+		world, space);
+	geom->setOrientation(Quaternion(box_akAxis[0],box_akAxis[1],box_akAxis[2]));
+	geom->setPosition(box_kCenter);
+	return geom; 
+#else
+	unsigned int vertex_count;
+	Vector3* vertices;
+	if (!getBoneVertices(bone, vertex_count, vertices)) 
+		return 0;
+
+	Vector3 box_kCenter;
+	Ogre::Vector3 box_akAxis[3];
+	Ogre::Real box_afExtent[3];
+
+	EigenSolver::GaussPointsFit (vertex_count, vertices, box_kCenter, box_akAxis, box_afExtent);
+
+	// Let C be the box center and let U0, U1, and U2 be the box axes.  Each
+	// input point is of the form X = C + y0*U0 + y1*U1 + y2*U2.  The
+	// following code computes min(y0), max(y0), min(y1), max(y1), min(y2),
+	// and max(y2).  The box center is then adjusted to be
+	//   C' = C + 0.5*(min(y0)+max(y0))*U0 + 0.5*(min(y1)+max(y1))*U1 +
+	//        0.5*(min(y2)+max(y2))*U2
+
+	Ogre::Vector3 kDiff (vertices[0] - box_kCenter);
+	Ogre::Real fY0Min = kDiff.dotProduct(box_akAxis[0]), fY0Max = fY0Min;
+	Ogre::Real fY1Min = kDiff.dotProduct(box_akAxis[1]), fY1Max = fY1Min;
+	Ogre::Real fY2Min = kDiff.dotProduct(box_akAxis[2]), fY2Max = fY2Min;
+
+	for (unsigned int i = 1; i < vertex_count; i++)
+	{
+		kDiff = vertices[i] - box_kCenter;
+
+		const Ogre::Real fY0 = kDiff.dotProduct(box_akAxis[0]);
+		if ( fY0 < fY0Min )
+			fY0Min = fY0;
+		else if ( fY0 > fY0Max )
+			fY0Max = fY0;
+
+		const Ogre::Real fY1 = kDiff.dotProduct(box_akAxis[1]);
+		if ( fY1 < fY1Min )
+			fY1Min = fY1;
+		else if ( fY1 > fY1Max )
+			fY1Max = fY1;
+
+		const Ogre::Real fY2 = kDiff.dotProduct(box_akAxis[2]);
+		if ( fY2 < fY2Min )
+			fY2Min = fY2;
+		else if ( fY2 > fY2Max )
+			fY2Max = fY2;
+	}
+
+	box_afExtent[0] = ((Real)0.5)*(fY0Max - fY0Min);
+	box_afExtent[1] = ((Real)0.5)*(fY1Max - fY1Min);
+	box_afExtent[2] = ((Real)0.5)*(fY2Max - fY2Min);
+
+	box_kCenter += (box_afExtent[0])*box_akAxis[0] +
+		(box_afExtent[1])*box_akAxis[1] +
+		(box_afExtent[2])*box_akAxis[2];
+
+	BoxGeometry *geom = new BoxGeometry(Vector3(box_afExtent[0] * 2.0,
+		box_afExtent[1] * 2.0,
+		box_afExtent[2] * 2.0),
+		world, space);
+	geom->setOrientation(Quaternion(box_akAxis[0],box_akAxis[1],box_akAxis[2]));
+	geom->setPosition(box_kCenter);
+	return geom;
+#endif
+}
+//------------------------------------------------------------------------------------------------
+CapsuleGeometry* EntityInformer::createOrientedCapsule(unsigned char bone, World *world, Space* space)
+{
+	unsigned int vertex_count;
+	Vector3* vertices;
+
+	if (!getBoneVertices(bone,vertex_count,vertices)) 
+        return 0;
+
+	Vector3 cap_orig;
+	Vector3 cap_dir;
+	Real cap_rad;
+
+	Vector3 line_orig;
+	Vector3 line_dir;
+
+	EigenSolver::orthogonalLineFit (vertex_count, vertices, line_orig, line_dir);
+
+   Ogre::Real fMaxRadiusSqr = (Real) 0.0;
+    unsigned int c;
+    for (c = 0; c < vertex_count; c++)
+    {
+		const Ogre::Real fRadiusSqr = EigenSolver::SqrDistance(vertices[c], line_orig, line_dir);
+        if ( fRadiusSqr > fMaxRadiusSqr ) 
+            fMaxRadiusSqr = fRadiusSqr;
+    }
+
+    Ogre::Vector3 kU, kV, kW = line_dir;
+	EigenSolver::GenerateOrthonormalBasis (kU, kV, kW, true);
+
+   Ogre::Real fMin = FLT_MAX, fMax = -fMin;
+    for (c = 0; c < vertex_count; c++)
+    {
+        const  Ogre::Vector3 kDiff (vertices[c] - line_orig);
+        const Ogre::Real fU = kU.dotProduct (kDiff);
+        const Ogre::Real fV = kV.dotProduct (kDiff);
+        const Ogre::Real fW = kW.dotProduct (kDiff);
+        const Ogre::Real fDiscr = fMaxRadiusSqr - (fU*fU + fV*fV);
+        const Ogre::Real fRadical = sqrtf(fabs(fDiscr));
+
+        fMin = std::min(fW + fRadical, fMin);
+        fMax = std::max(fW - fRadical, fMax);
+    }
+
+    if ( fMin < fMax )
+    {
+        cap_orig = line_orig + fMin*line_dir;
+        cap_dir = (fMax-fMin)*line_dir;
+    }
+    else
+    {
+        // enclosing capsule is really a sphere
+        cap_orig = line_orig + (((Real)0.5)*(fMin+fMax))*line_dir;
+        //----------------------------
+        cap_dir = Ogre::Vector3::ZERO;
+        //cap_dir = (fMax-fMin)*line_dir;
+    }
+
+    cap_rad = sqrtf(fMaxRadiusSqr);
+
+
+    CapsuleGeometry* geom = 0;
+    const Ogre::Real cap_dirLength = cap_dir.length();
+    if (cap_rad > 0 && cap_dirLength > 0)
+    {
+        const Ogre::Vector3 orig_axis (Vector3::UNIT_Z);
+        const Ogre::Vector3 reqd_axis (cap_dir.normalisedCopy());
+        const Ogre::Vector3 rot_axis (orig_axis.crossProduct(reqd_axis));
+        const Ogre::Real cos_ang = orig_axis.dotProduct(reqd_axis);
+       Ogre::Real ang = acos(cos_ang);
+        if (cos_ang < 0.0) 
+            ang -= M_PI;
+
+        const Ogre::Quaternion orient = Ogre::Quaternion(Radian(ang),rot_axis);
+
+        geom = new CapsuleGeometry(cap_rad, cap_dirLength, world, space);
+        geom->setOrientation(orient);
+        geom->setPosition(cap_orig + (reqd_axis * (cap_dirLength * 0.5)));
+    }
+	return geom;
+}
+//------------------------------------------------------------------------------------------------
+EntityInformer::~EntityInformer()
+{
+	delete[] _vertices;
+	delete[] _indices;
+
+	if (_bone_mapping)
+	{
+		for(BoneMapping::iterator i = _bone_mapping->begin();
+            i != _bone_mapping->end();
+            ++i)
+		{
+			delete i->second;
+		}
+		delete _bone_mapping;
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+EntityInformerReuse::EntityInformerReuse(Entity *entity, const Vector3 &scale, bool forceRecreate) : EntityInformer()
+{
+	_transform.makeTransform(Vector3::ZERO, scale, Quaternion::IDENTITY);
+	
+	if(!forceRecreate)
+		_dataPtr = TriangleMeshDataManager::getSingleton().getTriangleMeshData(entity->getMesh()->getName(), scale);
+
+	if(_dataPtr.isNull()) 
+	{
+		EntityInformer::addEntity(entity, _transform);
+		
+		_dataPtr = new TriangleMeshData(entity->getMesh()->getName(), scale, _vertices, _vertex_count, _indices, _index_count);
+		TriangleMeshDataManager::getSingleton().addTriangleMeshData(entity->getMesh()->getName(), _dataPtr, scale);
+	}
+}
+//------------------------------------------------------------------------------------------------
+EntityInformerReuse::EntityInformerReuse(const MeshPtr &mesh, const Vector3 &scale, bool forceRecreate) : EntityInformer()
+{
+	_entity = NULL;
+	
+	_transform.makeTransform(Vector3::ZERO, scale, Quaternion::IDENTITY);
+	
+	if(!forceRecreate)
+		_dataPtr = TriangleMeshDataManager::getSingleton().getTriangleMeshData(mesh->getName(), scale);
+	
+	if(_dataPtr.isNull()) 
+	{
+		EntityInformer::addMesh(mesh, _transform);
+		
+		_dataPtr = new TriangleMeshData(mesh->getName(), scale, _vertices, _vertex_count, _indices, _index_count);
+		TriangleMeshDataManager::getSingleton().addTriangleMeshData(mesh->getName(), _dataPtr, scale);
+	}
+}
+//------------------------------------------------------------------------------------------------
+EntityInformerReuse::~EntityInformerReuse()
+{
+}
+//------------------------------------------------------------------------------------------------
+TriangleMeshGeometry* EntityInformerReuse::createStaticTriangleMesh(World *world, Space* space)
+{
+	return new TriangleMeshGeometry(_dataPtr, world, space);
+}
+//------------------------------------------------------------------------------------------------
+TriangleMeshGeometry* EntityInformerReuse::recreateStaticTriangleMesh(TriangleMeshGeometry* geom)
+{
+	geom->changeTriangleMeshData(_dataPtr);
+	return geom;
+}
Index: /code/branches/physics/src/ogreode/OgreOdeEntityInformer.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeEntityInformer.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeEntityInformer.h	(revision 2122)
@@ -0,0 +1,108 @@
+#ifndef _OGREODEENTITYINFORMER_H_
+#define _OGREODEENTITYINFORMER_H_
+
+#include "OgreOdePreReqs.h"
+
+#include <OgreMesh.h>
+#include "OgreOdeTriangleMeshData.h"
+
+namespace OgreOde 
+{
+    class _OgreOdeExport EntityInformer
+    {
+	public:
+		EntityInformer(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		EntityInformer();
+		~EntityInformer();
+
+		void addEntity(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+		// Cannot be animated. 
+		void addMesh(const Ogre::MeshPtr &mesh, const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY);
+
+		Ogre::Real getRadius();
+		Ogre::Vector3 getSize();
+		Ogre::Vector3 getCenter();
+
+		Body* createSingleDynamicSphere(Ogre::Real mass, World *world, Space* space = 0);
+		Body* createSingleDynamicBox(Ogre::Real mass, World *world, Space* space = 0);
+
+		TriangleMeshGeometry* createStaticTriangleMesh(World *world, Space* space = 0);
+		BoxGeometry* createSingleStaticBox(World *world, Space* space = 0);
+
+		CapsuleGeometry* createOrientedCapsule(unsigned char bone, World *world, Space* space = 0);
+		BoxGeometry* createOrientedBox(unsigned char bone, World *world, Space* space = 0);
+		BoxGeometry* createAlignedBox(unsigned char bone, World *world, Space* space = 0);
+
+		const Ogre::Vector3* getVertices();
+		unsigned int getVertexCount();
+		const TriangleIndex* getIndices();
+		unsigned int getIndexCount();
+
+	protected:
+        void addVertexData(const Ogre::VertexData *vertex_data, 
+            const Ogre::VertexData *blended_data = 0, 
+            const Ogre::Mesh::IndexMap *indexMap = 0);
+		void addIndexData(Ogre::IndexData *data, const unsigned int offset = 0);
+		bool getBoneVertices(unsigned char bone,unsigned int &vertex_count, Ogre::Vector3* &vertices);
+
+		Ogre::Entity*		_entity;
+		Ogre::SceneNode*	_node;
+		Ogre::Matrix4		_transform;
+
+		Ogre::Real			_radius;
+		Ogre::Vector3		_size;
+		Ogre::Vector3		_center;
+
+        Ogre::Vector3*		_vertices;
+		TriangleIndex*		_indices; 
+		unsigned int		_vertex_count;
+		unsigned int		_index_count;
+
+		BoneMapping *_bone_mapping;
+	};
+
+	/** Class may create a TriangleMeshDataPtr, store and reuses it with TriangleMeshDataManager.
+		This can limit the number of instances of the mesh data at a given scale to one.
+		Since TriangleMeshGeometry is created using TriangleMeshDataPtr, have the advantage that 
+		the TriangleMeshDataPtr can be changed without having to recreate the TriangleMeshGeometry see 
+		TriangleMeshGeometry::changeTriangleMeshData().
+		When TriangleMeshGeometry is created it is created at the origin with an identity orientation.
+	*/
+	class _OgreOdeExport EntityInformerReuse : public EntityInformer
+	{
+
+	public:
+	
+		/** forceRecreate will force the creation of a TriangleMeshDataPtr, use only when the mesh has undergone some change
+		*/
+		EntityInformerReuse(Ogre::Entity *entity, const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE, bool forceRecreate = false);
+		EntityInformerReuse(const Ogre::MeshPtr &mesh, const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE, bool forceRecreate = false);
+		
+		virtual ~EntityInformerReuse();
+		
+		/** Creates TriangleMeshGeometry using TriangleMeshDataPtr 
+		*/
+		TriangleMeshGeometry* createStaticTriangleMesh(World *world, Space* space = 0);
+		
+		/** Recreates any TriangleMeshGeometry with the TriangleMeshDataPtr
+		*/
+		TriangleMeshGeometry* recreateStaticTriangleMesh(TriangleMeshGeometry* geom);
+		
+		/** Shouldn't be adding Entity or Mesh, one TriangleMeshData per Mesh/Entity for any scale.
+		*/
+		virtual void addEntity(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY){}
+		virtual void addMesh(const Ogre::MeshPtr &mesh, const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY){}
+		
+		TriangleMeshDataPtr getTriangleMeshDataPtr(){ return _dataPtr; }
+		
+	protected:
+	
+		TriangleMeshDataPtr _dataPtr;
+		
+	};
+
+}
+
+#endif
+
+
Index: /code/branches/physics/src/ogreode/OgreOdeFrameListener.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeFrameListener.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeFrameListener.h	(revision 2122)
@@ -0,0 +1,155 @@
+/*
+    PhysicsFrameListener.h
+
+	A very simple wrapper class for ODE
+	primarily for the example car application
+*/
+#ifndef _PHYSICSFRAMELISTENER_H_
+#define _PHYSICSFRAMELISTENER_H_
+
+#include "OgreOdePreReqs.h"
+#include <OgreSceneQuery.h>
+#include <OgreFrameListener.h>
+
+// Uncomment this if you're planning to use the Plane2D joint
+// But you'll have to have modified ODE first!
+// #define INCLUDE_PLANE2D_JOINT
+
+/*
+A physical thing
+*/
+class PhysicalThing : public Ogre::RaySceneQueryListener
+{
+public:
+	// Doesn't actually do anything
+	PhysicalThing(dSpace *space);
+	~PhysicalThing(void);
+
+	// Just create geoms
+    void makePlane(Ogre::Real a, Ogre::Real b, Ogre::Real c, Ogre::Real d);				// Plane
+    void makeBox(Ogre::Real x, Ogre::Real y, Ogre::Real z, Ogre::Real lx, Ogre::Real ly, Ogre::Real lz);	// Box
+    void makeSphere(Ogre::Real x, Ogre::Real y, Ogre::Real z, Ogre::Real r);				// Sphere
+
+	// Create bodies and geoms
+    void makePlane(dWorld *world, Ogre::SceneNode *node);
+	void makeBox(dWorld *world, Ogre::SceneNode *node, Ogre::Real mass = 1, Ogre::Vector3 const &offs = Ogre::Vector3(0,0,0));
+    void makeSphere(dWorld *world, Ogre::SceneNode *node, Ogre::Real mass = 1);
+	void makeTerrainTriMesh(dWorld *world, Ogre::SceneManager *mgr, Ogre::Real grid_size, Ogre::Real grid_spacing);
+
+	// Callback functions for the ray scene query functionality
+	virtual bool queryResult(Ogre::SceneQuery::WorldFragment *fragment, Ogre::Real distance);
+	virtual bool queryResult(Ogre::MovableObject *obj, Ogre::Real distance);
+
+	// Update the position and orientation of the scene node we're controlling
+	void update(void);
+
+	// Utility functions to get at internal stuff
+	Ogre::SceneNode *getNode(void);
+	dBodyID getBodyID(void);
+	dSpaceID getSpaceID(void);
+
+protected:
+	dGeom		*_geom;
+	dBody		*_body;
+	dSpace		*_space;
+	Ogre::SceneNode	*_node;
+
+	std::list<Ogre::Vector3> _frag;
+
+	dVector3 *_vertices;
+	int *_indices;
+};
+
+/*
+A Frame listener that implements the physics
+*/
+class PhysicsFrameListener : public Ogre::FrameListener
+{
+protected:
+	// All the stuff we need for ODE
+    dWorld          *world;
+    dHashSpace      *space;
+    dJointGroup     *contactgroup;
+    dSpace          *current_space;
+	bool			paused;
+
+	// Keep track of anything we've created
+    std::list<PhysicalThing*>   things;
+    std::list<dSimpleSpace*>    spaces;
+	std::list<dJoint*>			joints;
+    
+	// Adjustable variables
+    Ogre::Real total_time,step_size;
+	Ogre::Real k_spring,k_damper,k_tyre,k_mu,k_erp,k_cfm;
+
+	// Utility function to find the physical thing associated with an Ogre scene node
+	dBodyID getBodyID(Ogre::SceneNode *node);
+
+public:
+	// Standard constructor/destructor
+    PhysicsFrameListener(void);
+    ~PhysicsFrameListener(void);
+
+	// Tell us when every frame's about to be started
+    bool frameStarted(const Ogre::FrameEvent& evt);
+	void pause(bool p = true);
+
+	// Mainly so we can access internal stuff from the collision callback
+    dWorld *getWorld(void){return world;};
+    dSpace *getSpace(void){return space;};
+    dJointGroup *getContactGroup(void){return contactgroup;};
+
+	// Create things manually, no physical bodies 
+	// so they won't move, but things will collide with them
+    PhysicalThing *createPlane(Ogre::Real a,Ogre::Real b,Ogre::Real c,Ogre::Real d);
+    PhysicalThing *createBox(Ogre::Real x,Ogre::Real y,Ogre::Real z,Ogre::Real lx,Ogre::Real ly,Ogre::Real lz);
+    PhysicalThing *createSphere(Ogre::Real x,Ogre::Real y,Ogre::Real z,Ogre::Real r);
+
+	// Create objects based on Ogre nodes, these nodes will then
+	// come under control of the physics simulation and will move about
+	// as if by magic!
+	// Except for the plane, which can't actually be a physical body
+	// and the trimesh which we're not going to allow to be a physical body
+    PhysicalThing *createPlane(Ogre::SceneNode *node);
+	PhysicalThing *createBox(Ogre::SceneNode *node,Ogre::Real mass = 1,Ogre::Vector3 const &offs = Ogre::Vector3(0,0,0));
+    PhysicalThing *createSphere(Ogre::SceneNode *node,Ogre::Real mass = 1);
+	PhysicalThing *createTerrainTriMesh(Ogre::SceneManager *mgr,Ogre::Real grid_size,Ogre::Real grid_spacing);
+
+	// Create and activate a new space inside the standard hash space
+	// Things won't collide within a space so (for example) the objects
+	// that make up a car won't collide with each other
+    dSimpleSpace *createSpace(void);
+
+	// Create joints between the nodes specified
+	// The order of n1/n2 does matter; n1 is what you want attaching
+	// and n2 is what you want it attaching to
+	dJoint *createHinge2(Ogre::SceneNode *n1,Ogre::SceneNode *n2,const Ogre::Vector3 &suspension = Ogre::Vector3(0,1,0),const Ogre::Vector3 &axle = Ogre::Vector3(1,0,0));
+	dJoint *createHinge(Ogre::SceneNode *n1,Ogre::SceneNode *n2,const Ogre::Vector3 &axis = Ogre::Vector3(1,0,0));
+	dJoint *createSlider(Ogre::SceneNode *n1,Ogre::SceneNode *n2,const Ogre::Vector3 &axis = Ogre::Vector3(0,1,0));
+	dJoint *createBall(Ogre::SceneNode *n1,Ogre::SceneNode *n2);
+#ifdef INCLUDE_PLANE2D_JOINT
+	dJoint *createPlane2D(Ogre::SceneNode *n);
+#endif
+
+	// Apply forces to a body under our control
+	void addTorque(Ogre::SceneNode *n,const Ogre::Vector3 &force);
+
+	// Set the parameters used for the CFM/ERP joint parameters
+	void setSuspension(Ogre::Real spring,Ogre::Real damper);
+
+	// Set the acceleration due to gravity
+	void setGravity(Ogre::Real g);
+
+	// Get our constants
+	Ogre::Real getTyre(void){return k_tyre;};
+	Ogre::Real getMu(void){return k_mu;};
+	Ogre::Real getCFM(void){return k_cfm;};
+	Ogre::Real getERP(void){return k_erp;};
+
+	// Static function for ODE to call when collisions (potentially) occur
+    static void collisionCallback(void *data,dGeomID o1,dGeomID o2);
+};
+
+#endif
+
+
Index: /code/branches/physics/src/ogreode/OgreOdeGeometry.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeGeometry.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeGeometry.cpp	(revision 2122)
@@ -0,0 +1,1404 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeGeometry.h"
+
+#include <OgreSceneNode.h>
+#include <OgreSceneManager.h>
+#include <OgreStringConverter.h>
+
+#include "OgreOdeWorld.h"
+#include "OgreOdeSpace.h"
+#include "OgreOdeBody.h"
+#include "OgreOdeCollision.h"
+#include "OgreOdeDebugObject.h"
+#include "OgreOdeDebugContact.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+int Geometry::_geometry_count = 0;
+const Ogre::String Geometry::MovableType = "OgreOde_Geometry";
+
+//------------------------------------------------------------------------------------------------
+Geometry::Geometry(World *world, Space* space):
+    UserDefinedObject(),
+	_geom (0),
+	_max_contacts (32),
+	_contact_high_water_mark (0),
+    _last_contact_num(0),
+	_contacts (0),
+	_debug_obj (0),
+	_debug_node (0),
+    _debug_contacts (0),
+	_encapsulator (0),
+	_user_data (0),
+	_user_object (0),
+    _world(world)
+{
+	mName = "";
+}
+//------------------------------------------------------------------------------------------------
+Geometry::~Geometry()
+{
+    destroyDebugObject();
+
+    delete[] _contacts;
+    if (_debug_contacts)
+    {         
+        for (unsigned int i = 0; i < _max_contacts; i++)
+            delete _debug_contacts[i];
+        delete [] _debug_contacts;
+    }
+    if (_geom)
+    {
+        _world->getGeometryList().unregisterItem((unsigned long)_geom);
+        dGeomDestroy(_geom); 
+    }
+}
+//------------------------------------------------------------------------------------------------
+dGeomID Geometry::getGeometryID() const
+{
+	return _geom;
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::setEncapsulator(Geometry* encapsulator)
+{
+	_encapsulator = encapsulator;
+
+	if (_world->getShowDebugGeometries())
+	{
+		reparentDebugObject(encapsulator->_debug_node);
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::reparentDebugObject(Ogre::Node* node)
+{
+	if ((node)&&(_debug_node)&&(_debug_node->getParent() != node))
+	{
+		Ogre::SceneNode* parent = static_cast<Ogre::SceneNode*>(_debug_node->getParent());
+		parent->removeChild(_debug_node->getName());
+		node->addChild(_debug_node);
+
+		_debug_node->setPosition(getPosition());
+		_debug_node->setOrientation(getOrientation());
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::createDebugObject()
+{
+	if (!_debug_node)
+	{
+		Ogre::SceneNode* parent = _world->_manager->getRootSceneNode();
+		_debug_node = static_cast<Ogre::Node*>(parent->createChildSceneNode(Ogre::String("OgreOde::Geometry_") + Ogre::StringConverter::toString(_geometry_count) + Ogre::String("_Debug"))); 
+
+        if (_debug_obj)
+        {
+            static_cast<Ogre::SceneNode*>(_debug_node)->attachObject(_debug_obj);
+        }
+
+        if (getBody())
+        {
+            static_cast<Ogre::SceneNode*>(_debug_node->getParent())->removeChild(_debug_node->getName());
+            getBody()->addDebugNode(_debug_node);
+            if (_debug_obj) 
+				_debug_obj->setMode(DebugObject::Mode_Enabled);
+			
+			//reposition the debug node if the geometry has an offset
+			if(isOffset())
+				_debug_node->setPosition(getOffsetPosition()); 
+        }
+		else if (_encapsulator)
+		{
+			reparentDebugObject(_encapsulator->_debug_node);
+		}
+		else
+		{
+			if (_debug_obj) 
+                _debug_obj->setMode(DebugObject::Mode_Static);
+			
+			_debug_node->setPosition(getPosition());
+			_debug_node->setOrientation(getOrientation());
+		}
+		_geometry_count++;
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::destroyDebugObject()
+{
+	if (_debug_node)
+    {
+
+        Ogre::SceneNode* sn = static_cast<Ogre::SceneNode*>(_debug_node);
+        sn->removeAndDestroyAllChildren ();
+        sn = static_cast<Ogre::SceneNode*>(_debug_node->getParent());
+        sn->removeAndDestroyChild(_debug_node->getName());
+		_debug_node = 0;
+	}
+
+	if (_debug_obj)
+	{
+		delete _debug_obj;
+		_debug_obj = 0;
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::registerGeometry()
+{
+	dGeomSetData(_geom, (void*)this);
+	assert(_world);
+    _world->getGeometryList().registerItem(this);
+
+    if (_world->getShowDebugGeometries()) 
+        createDebugObject();
+
+    setMaxContacts (_max_contacts);
+}
+//------------------------------------------------------------------------------------------------
+dSpaceID Geometry::getSpaceID(Space* space) const
+{
+	if (!space) return 0;
+	return space->getSpaceID();
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::setBody(Body* body)
+{
+	destroyDebugObject();
+    if (body)
+    {
+        body->addGeometry (this);
+        dGeomSetBody(_geom, body->getBodyID()); 
+    }
+    else
+    {
+        dGeomSetBody(_geom, 0); 
+    }
+	if (_world->getShowDebugGeometries()) 
+        createDebugObject();
+}
+
+//------------------------------------------------------------------------------------------------
+Body* Geometry::getBody()
+{
+	const dBodyID body = dGeomGetBody(_geom);
+	if (!body) return 0;
+	else return (Body*)dBodyGetData(body); 
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::notify(Body* body)
+{
+	if (getBody() == body)
+	{
+		destroyDebugObject();
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::setDebug(const bool debug)
+{
+    destroyDebugObject();
+    if (debug) 
+        createDebugObject();    
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::setDebugContact(const bool debug)
+{    
+    if (_debug_contacts)
+    {
+        for (unsigned int i = 0; i < _max_contacts; i++)
+            delete _debug_contacts[i];
+        delete [] _debug_contacts;
+        _debug_contacts = 0;
+    }
+    if (debug) 
+    {
+        _debug_contacts = new DebugContact*[_max_contacts];
+        for (unsigned int i = 0; i < _max_contacts; i++)
+            _debug_contacts[i] = new DebugContact(Ogre::StringConverter::toString((size_t)_geom) + 
+                                                    "_Contact_" + 
+                                                    Ogre::StringConverter::toString(i),
+                                                    _world);
+    }
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::setPosition(const Ogre::Vector3& position)
+{
+    dGeomSetPosition(_geom,(dReal)position.x,(dReal)position.y,(dReal)position.z);
+
+    if ((_debug_node)&& ((!getBody()) || (_encapsulator)))
+        _debug_node->setPosition(position);
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::setOrientation(const Ogre::Quaternion& orientation)
+{
+	dQuaternion q;
+	q[0] = (dReal)orientation.w;
+	q[1] = (dReal)orientation.x;
+	q[2] = (dReal)orientation.y;
+	q[3] = (dReal)orientation.z;
+	dGeomSetQuaternion(_geom,q); 
+
+	if ((_debug_node)&& ((!getBody()) || (_encapsulator))) _debug_node->setOrientation(orientation);
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& Geometry::getPosition()
+{
+	const dReal* position = dGeomGetPosition(_geom);
+	_position.x = (Ogre::Real)position[0];
+	_position.y = (Ogre::Real)position[1];
+	_position.z = (Ogre::Real)position[2];
+	return _position;
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Quaternion& Geometry::getOrientation()
+{
+	dQuaternion orientation;
+	dGeomGetQuaternion(_geom,orientation); 
+	_orientation.w = (Real)orientation[0];
+	_orientation.x = (Real)orientation[1];
+	_orientation.y = (Real)orientation[2];
+	_orientation.z = (Real)orientation[3];
+	return _orientation;
+}
+
+//------------------------------------------------------------------------------------------------
+const AxisAlignedBox& Geometry::getAxisAlignedBox()
+{
+	dReal aabb[6];
+	dGeomGetAABB(_geom,aabb);
+	_bounding_box.setExtents((Real)aabb[0],(Real)aabb[2],(Real)aabb[4],(Real)aabb[1],(Real)aabb[3],(Real)aabb[5]);
+	return _bounding_box;
+}
+
+//------------------------------------------------------------------------------------------------
+Space* Geometry::getSpace()
+{
+	if (dGeomGetSpace(_geom) == 0) 
+	{
+		// not in any space
+		return NULL;
+	}
+
+	return (Space*)_world->getSpaceList().findItem((size_t)dGeomGetSpace(_geom));
+}
+
+
+//------------------------------------------------------------------------------------------------
+void Geometry::enable()
+{
+	dGeomEnable(_geom);
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::disable()
+{
+	dGeomDisable(_geom); 
+}
+
+//------------------------------------------------------------------------------------------------
+bool Geometry::isEnabled()
+{
+	return dGeomIsEnabled(_geom) != 0; 
+}
+
+//------------------------------------------------------------------------------------------------
+Geometry::Class Geometry::getClass() const
+{
+	return (Geometry::Class)dGeomGetClass(_geom);
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::setCategoryBitfield(unsigned long bits)
+{
+	dGeomSetCategoryBits(_geom,bits); 
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::setCollisionBitfield(unsigned long bits)
+{
+	dGeomSetCollideBits(_geom,bits); 
+}
+
+//------------------------------------------------------------------------------------------------
+unsigned long Geometry::getCategoryBitfield()
+{
+	return dGeomGetCategoryBits(_geom); 
+}
+
+//------------------------------------------------------------------------------------------------
+unsigned long Geometry::getCollisionBitfield()
+{
+	return dGeomGetCollideBits(_geom); 
+}
+
+//------------------------------------------------------------------------------------------------
+int Geometry::collide(Geometry* geometry,CollisionListener* listener)
+{
+	const unsigned int num_contacts = (unsigned int) dCollide(_geom,
+										geometry->getGeometryID(),
+										_max_contacts,
+										&(_contacts[0].geom),
+										sizeof(dContact));
+	if (num_contacts)
+	{
+		_contact_high_water_mark = std::max(_contact_high_water_mark,num_contacts);
+
+		Contact contact;
+		
+		const dWorldID wid = _world->getWorldID();
+		const dJointGroupID cid = _world->getContactGroupID();
+		const dBodyID b1 = dGeomGetBody(_geom);
+		const dBodyID b2 = dGeomGetBody(geometry->getGeometryID());
+
+		if (listener)
+		{
+			for(unsigned int i = 0;i < num_contacts;i++)
+			{
+				contact.setContact (&_contacts[i]);
+
+				if (listener->collision(&contact))
+				{
+					dJointAttach(dJointCreateContact(wid,cid,&_contacts[i]),b1,b2);
+                } 
+			}
+		}
+		else
+		{
+			for(unsigned int i = 0;i < num_contacts;i++)
+			{
+				contact.setContact (&_contacts[i]);
+   
+				dJointAttach(dJointCreateContact(wid,cid,&_contacts[i]), b1, b2);
+			}
+		} 
+    }
+    _last_contact_num = num_contacts;
+	return num_contacts;
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::updateDebugContact()
+{
+    assert (_world->getShowDebugContact ());
+    assert (_debug_contacts);
+    {
+        unsigned int k = 0;
+        while (k < _max_contacts)
+        {
+            _debug_contacts[k++]->setEnabled(false);
+        }
+
+        if (_last_contact_num)
+        {
+            Contact contact;
+            for(unsigned int i = 0;i < _last_contact_num;i++)
+            {
+                k = 0;
+                while (k < _max_contacts)
+                {
+                    if (_debug_contacts[k]->isEnabled() == false)
+                        break;
+                    k++;
+                }
+                assert (k < _max_contacts);
+
+                _debug_contacts[k]->setEnabled(true);
+                contact.setContact (&_contacts[i]);
+                _debug_contacts[k]->update (&contact);
+            }
+        }
+    }
+    _last_contact_num = 0;
+ }
+//------------------------------------------------------------------------------------------------
+unsigned int Geometry::getMaxContacts() const
+{
+	return _max_contacts;
+}
+
+//------------------------------------------------------------------------------------------------
+void Geometry::setMaxContacts(unsigned int max_contacts)
+{
+	delete[] _contacts;
+	_contacts = new dContact[max_contacts];
+
+    if (_world->getShowDebugContact ())
+    {
+        if (_debug_contacts)
+        {         
+            for (unsigned int i = 0; i < _max_contacts; i++)
+                delete _debug_contacts[i];
+            delete [] _debug_contacts;
+        }
+        _debug_contacts = new DebugContact*[max_contacts];
+        for (unsigned int i = 0; i < max_contacts; i++)
+            _debug_contacts[i] = new DebugContact(Ogre::StringConverter::toString((size_t)_geom)  
+			+ "_Contact_" 
+			+ Ogre::StringConverter::toString(i),
+            _world);
+    }
+    _max_contacts = max_contacts;
+}
+
+//------------------------------------------------------------------------------------------------
+unsigned int Geometry::getContactHighWaterMark() const
+{
+	return _contact_high_water_mark;
+}
+
+//------------------------------------------------------------------------------------------------
+size_t Geometry::getID() const
+{
+	return (size_t)_geom;
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::clearOffset()
+{
+	dGeomClearOffset(_geom);
+}
+//------------------------------------------------------------------------------------------------
+int Geometry::isOffset()
+{
+	return dGeomIsOffset(_geom);
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::setOffsetPosition (const Ogre::Vector3 &pos)
+{
+	dGeomSetOffsetPosition (_geom, pos.x, pos.y, pos.z);
+
+	//move the debug object when setting offset if we have a body only
+	if ((_debug_node)&& ((getBody())/* || (_encapsulator)*/))
+		_debug_node->setPosition(getOffsetPosition()); 
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::setOffsetQuaternion(const Ogre::Quaternion &quat) 
+{
+	dQuaternion q;
+	q[0] = quat.w; 
+	q[1] = quat.x; 
+	q[2] = quat.y; 
+	q[3] = quat.z;
+	dGeomSetOffsetQuaternion (_geom, q);
+
+	if ((_debug_node)&& ((getBody())/* || (_encapsulator)*/))
+		_debug_node->setOrientation(getOffsetQuaternion()); 
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::setOffsetWorldPosition(const Ogre::Vector3 &pos) 
+{
+	dGeomSetOffsetWorldPosition(_geom, pos.x, pos.y, pos.z);
+
+	//move the debug object when setting offset if we have a body only
+	if ((_debug_node)&& ((getBody())/* || (_encapsulator)*/))
+		_debug_node->setPosition(getOffsetPosition()); 
+}
+//------------------------------------------------------------------------------------------------
+void Geometry::setOffsetWorldQuaternion(const Ogre::Quaternion &quat) 
+{
+	dQuaternion q;
+	q[0] = quat.w; 
+	q[1] = quat.x; 
+	q[2] = quat.y; 
+	q[3] = quat.z;
+	dGeomSetOffsetWorldQuaternion (_geom, q);
+
+	if ((_debug_node)&& ((getBody())/* || (_encapsulator)*/))
+		_debug_node->setOrientation(getOffsetQuaternion()); 
+}
+//------------------------------------------------------------------------------------------------
+Vector3 Geometry::getOffsetPosition() 
+{
+	const dReal *p =  dGeomGetOffsetPosition (_geom);
+	return Ogre::Vector3(p[0], p[1], p[2]);
+}
+//------------------------------------------------------------------------------------------------
+Quaternion Geometry::getOffsetQuaternion() 
+{
+	dQuaternion q;
+	dGeomGetOffsetQuaternion (_geom, q);
+	return Ogre::Quaternion(q[0], q[1], q[2], q[3]);
+}
+//-----------------------------------------------------------------------
+void Geometry::_notifyAttached(Node* parent, bool isTagPoint)
+{
+	MovableObject::_notifyAttached(parent, isTagPoint);
+	reparentDebugObject(parent);
+}
+//-----------------------------------------------------------------------
+void Geometry::_notifyMoved()
+{
+	MovableObject::_notifyMoved();
+		
+	if (!getBody())
+	{
+		setPosition(mParentNode->_getDerivedPosition());
+		setOrientation(mParentNode->_getDerivedOrientation());
+	}
+}
+//------------------------------------------------------------------------------------------------
+SphereGeometry::SphereGeometry(Real radius, World *world, Space* space):Geometry(world, space)
+{
+	_geom = dCreateSphere(getSpaceID(space),(dReal)radius); 
+	registerGeometry();
+}
+
+//------------------------------------------------------------------------------------------------
+void SphereGeometry::setRadius(Real radius)
+{
+	dGeomSphereSetRadius(_geom,(dReal)radius);
+}
+
+//------------------------------------------------------------------------------------------------
+Real SphereGeometry::getRadius()
+{
+	return (Real)dGeomSphereGetRadius(_geom); 
+}
+
+//------------------------------------------------------------------------------------------------
+Real SphereGeometry::getPointDepth(const Ogre::Vector3& point)
+{
+	return (Real)dGeomSpherePointDepth(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z); 
+}
+
+//------------------------------------------------------------------------------------------------
+void SphereGeometry::createDebugObject()
+{
+	_debug_obj = new SphereDebugObject(getRadius());
+	Geometry::createDebugObject();
+}
+
+//------------------------------------------------------------------------------------------------
+SphereGeometry::~SphereGeometry()
+{
+}
+
+//------------------------------------------------------------------------------------------------
+BoxGeometry::BoxGeometry(const Ogre::Vector3& size, World *world, Space* space):Geometry(world, space)
+{
+	_geom = dCreateBox(getSpaceID(space),(dReal)size.x,(dReal)size.y,(dReal)size.z); 
+	registerGeometry();
+}
+
+//------------------------------------------------------------------------------------------------
+void BoxGeometry::setSize(const Ogre::Vector3& size)
+{
+	dGeomBoxSetLengths(_geom,(dReal)size.x,(dReal)size.y,(dReal)size.z); 
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& BoxGeometry::getSize()
+{
+	dVector3 result;
+	dGeomBoxGetLengths(_geom,result); 
+	_size.x = (Real)result[0];
+	_size.y = (Real)result[1];
+	_size.z = (Real)result[2];
+	return _size;
+}
+
+//------------------------------------------------------------------------------------------------
+Real BoxGeometry::getPointDepth(const Ogre::Vector3& point)
+{
+	return (Real)dGeomBoxPointDepth(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z); 
+}
+
+//------------------------------------------------------------------------------------------------
+void BoxGeometry::createDebugObject()
+{
+	_debug_obj = new BoxDebugObject(getSize());
+	Geometry::createDebugObject();	
+}
+
+//------------------------------------------------------------------------------------------------
+BoxGeometry::~BoxGeometry()
+{
+}
+
+//------------------------------------------------------------------------------------------------
+InfinitePlaneGeometry::InfinitePlaneGeometry(const Plane& plane,World *world, Space* space):Geometry(world, space)
+{
+	_geom = dCreatePlane(getSpaceID(space),(dReal)plane.normal.x,(dReal)plane.normal.y,(dReal)plane.normal.z,(dReal)-plane.d); 
+	registerGeometry();
+}
+
+//------------------------------------------------------------------------------------------------
+void InfinitePlaneGeometry::setDefinition(const Plane& plane)
+{
+	dGeomPlaneSetParams(_geom,(dReal)plane.normal.x,(dReal)plane.normal.y,(dReal)plane.normal.z,(dReal)-plane.d); 
+}
+
+//------------------------------------------------------------------------------------------------
+const Plane& InfinitePlaneGeometry::getDefinition()
+{
+	dVector4 result;
+	dGeomPlaneGetParams(_geom,result); 
+	_plane.normal.x = result[0];
+	_plane.normal.y = result[1];
+	_plane.normal.z = result[2];
+	_plane.d = -result[3];
+	return _plane;
+}
+
+//------------------------------------------------------------------------------------------------
+Real InfinitePlaneGeometry::getPointDepth(const Ogre::Vector3& point)
+{
+	return (Real)dGeomPlanePointDepth(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z); 
+}
+
+//------------------------------------------------------------------------------------------------
+void InfinitePlaneGeometry::setPosition(const Ogre::Vector3& position)
+{
+}
+
+//------------------------------------------------------------------------------------------------
+void InfinitePlaneGeometry::setOrientation(const Ogre::Quaternion& orientation)
+{
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& InfinitePlaneGeometry::getPosition()
+{
+	return Ogre::Vector3::ZERO;
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Quaternion& InfinitePlaneGeometry::getOrientation()
+{
+	return Ogre::Quaternion::ZERO;
+}
+
+//------------------------------------------------------------------------------------------------
+const AxisAlignedBox& InfinitePlaneGeometry::getAxisAlignedBox()
+{
+	return _bounding_box;
+}
+
+//------------------------------------------------------------------------------------------------
+InfinitePlaneGeometry::~InfinitePlaneGeometry()
+{
+}
+
+//------------------------------------------------------------------------------------------------
+CapsuleGeometry::CapsuleGeometry(Real radius,Real length,World *world, Space* space):Geometry(world, space)
+{
+	_geom = dCreateCapsule(getSpaceID(space),(dReal)radius,(dReal)length);
+	registerGeometry();
+}
+
+//------------------------------------------------------------------------------------------------
+void CapsuleGeometry::setDefinition(Real radius,Real length)
+{
+	dGeomCapsuleSetParams(_geom,(dReal)radius,(dReal)length);
+}
+
+//------------------------------------------------------------------------------------------------
+Real CapsuleGeometry::getRadius()
+{
+	dReal radius,length;
+	dGeomCapsuleGetParams(_geom,&radius,&length); 
+	return radius;
+}
+
+//------------------------------------------------------------------------------------------------
+Real CapsuleGeometry::getLength()
+{
+	dReal radius,length;
+	dGeomCapsuleGetParams(_geom,&radius,&length); 
+	return length;
+}
+
+//------------------------------------------------------------------------------------------------
+Real CapsuleGeometry::getPointDepth(const Ogre::Vector3& point)
+{
+	return (Real)dGeomCapsulePointDepth(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z); 
+}
+
+//------------------------------------------------------------------------------------------------
+void CapsuleGeometry::createDebugObject()
+{
+	_debug_obj = new CapsuleDebugObject(getRadius(),getLength());
+	Geometry::createDebugObject();
+}
+
+//------------------------------------------------------------------------------------------------
+CapsuleGeometry::~CapsuleGeometry()
+{
+}
+
+//------------------------------------------------------------------------------------------------
+CylinderGeometry::CylinderGeometry(Real radius,Real length,World *world, Space* space):Geometry(world, space)
+{
+	_geom = dCreateCCylinder(getSpaceID(space),(dReal)radius,(dReal)length);
+	registerGeometry();
+}
+
+//------------------------------------------------------------------------------------------------
+void CylinderGeometry::setDefinition(Real radius,Real length)
+{
+	dGeomCCylinderSetParams(_geom,(dReal)radius,(dReal)length);
+}
+
+//------------------------------------------------------------------------------------------------
+Real CylinderGeometry::getRadius()
+{
+	dReal radius,length;
+	dGeomCCylinderGetParams(_geom,&radius,&length); 
+	return radius;
+}
+
+//------------------------------------------------------------------------------------------------
+Real CylinderGeometry::getLength()
+{
+	dReal radius,length;
+	dGeomCCylinderGetParams(_geom,&radius,&length); 
+	return length;
+}
+
+//------------------------------------------------------------------------------------------------
+Real CylinderGeometry::getPointDepth(const Ogre::Vector3& point)
+{
+	return (Real)dGeomCCylinderPointDepth(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z); 
+}
+
+//------------------------------------------------------------------------------------------------
+void CylinderGeometry::createDebugObject()
+{
+	_debug_obj = new CylinderDebugObject(getRadius(),getLength());
+	Geometry::createDebugObject();
+}
+
+//------------------------------------------------------------------------------------------------
+CylinderGeometry::~CylinderGeometry()
+{
+}
+//------------------------------------------------------------------------------------------------
+RayGeometry::RayGeometry(Real length,World *world, Space* space) : Geometry(world, space)
+{
+	_geom = dCreateRay(getSpaceID(space),(dReal)length);
+	registerGeometry();
+}
+
+//------------------------------------------------------------------------------------------------
+void RayGeometry::createDebugObject()
+{
+	_debug_obj = new RayDebugObject(getStart(),getDirection(),getLength());
+	Geometry::createDebugObject();
+	if (_debug_node)
+	{
+		_debug_node->setPosition(Vector3::ZERO);
+		_debug_node->setOrientation(Quaternion::IDENTITY);
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void RayGeometry::setLength(Real length)
+{
+	dGeomRaySetLength(_geom,(dReal)length); 
+}
+
+//------------------------------------------------------------------------------------------------
+Real RayGeometry::getLength()
+{
+	return (Real)dGeomRayGetLength(_geom); 
+}
+
+//------------------------------------------------------------------------------------------------
+void RayGeometry::setDefinition(const Ogre::Vector3& start,const Ogre::Vector3& direction)
+{
+	dGeomRaySet(_geom,
+					(dReal)start.x,(dReal)start.y,(dReal)start.z,
+					(dReal)direction.x,(dReal)direction.y,(dReal)direction.z);
+
+	if ((_debug_node)&& ((!getBody()) || (_encapsulator))) 
+		(static_cast<RayDebugObject *>(_debug_obj))->setDefinition(start, direction, (Real)dGeomRayGetLength(_geom));
+
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& RayGeometry::getStart()
+{
+	dVector3 start,direction;
+	dGeomRayGet(_geom,start,direction); 
+	_start.x = (Real)start[0];
+	_start.y = (Real)start[1];
+	_start.z = (Real)start[2];
+	return _start;
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& RayGeometry::getDirection()
+{
+	dVector3 start,direction;
+	dGeomRayGet(_geom,start,direction); 
+	_direction.x = (Real)direction[0];
+	_direction.y = (Real)direction[1];
+	_direction.z = (Real)direction[2];
+	return _direction;
+}
+
+//------------------------------------------------------------------------------------------------
+RayGeometry::~RayGeometry()
+{
+}
+
+//------------------------------------------------------------------------------------------------
+TransformGeometry::TransformGeometry(World *world, Space* space) : Geometry(world, space)
+{
+	_geom = dCreateGeomTransform(getSpaceID(space)); 
+	dGeomTransformSetCleanup(_geom,0);
+	dGeomTransformSetInfo(_geom,1);
+	registerGeometry();
+}
+
+//------------------------------------------------------------------------------------------------
+void TransformGeometry::setEncapsulatedGeometry(Geometry* geometry)
+{
+	dGeomTransformSetGeom(_geom,geometry->getGeometryID()); 
+	destroyDebugObject();
+	if (_world->getShowDebugGeometries()) 
+		createDebugObject();	
+
+	geometry->setEncapsulator(this);
+}
+
+//------------------------------------------------------------------------------------------------
+void TransformGeometry::createDebugObject()
+{
+	Geometry::createDebugObject();
+	if (getEncapsulatedGeometry())
+	{
+		getEncapsulatedGeometry()->destroyDebugObject();
+		getEncapsulatedGeometry()->createDebugObject();
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void TransformGeometry::destroyDebugObject()
+{
+	if (getEncapsulatedGeometry()) getEncapsulatedGeometry()->destroyDebugObject();
+	Geometry::destroyDebugObject();
+}
+
+//------------------------------------------------------------------------------------------------
+Geometry* TransformGeometry::getEncapsulatedGeometry() const
+{
+	dGeomID id = dGeomTransformGetGeom(_geom);
+	if (id == 0) return 0;
+	else return (Geometry*)dGeomGetData(id); 
+}
+
+//------------------------------------------------------------------------------------------------
+TransformGeometry::~TransformGeometry()
+{
+}
+
+
+//------------------------------------------------------------------------------------------------
+TriangleMeshGeometry::TriangleMeshGeometry(const Ogre::Vector3* vertices,
+                                           unsigned int vertex_count,
+                                           const TriangleIndex* indices,
+                                           unsigned int index_count,
+                                           World *world, Space* space) : 
+    Geometry(world, space),
+    _vertex_count (vertex_count),
+    _index_count (index_count)
+{
+	_vertex_count = vertex_count;
+	_index_count = index_count;
+	_vertices = new dVector3[vertex_count];
+	_indices = new unsigned int[index_count];
+
+	for(unsigned int i = 0;i < vertex_count;i++)
+	{
+		_vertices[i][0] = (dReal)vertices[i].x;
+		_vertices[i][1] = (dReal)vertices[i].y;
+		_vertices[i][2] = (dReal)vertices[i].z;
+	}
+
+	memcpy(_indices,indices,sizeof(unsigned int) * index_count);
+
+	_data = dGeomTriMeshDataCreate(); 
+
+	//dGeomTriMeshDataBuildSimple(_data,(const dReal*)_vertices, (int)vertex_count, _indices, (int) index_count); 
+    // modified version
+	dGeomTriMeshDataBuildSimple(_data,(const dReal*)_vertices, (int)vertex_count, (dTriIndex*)_indices, (int) index_count); 
+
+	_geom = dCreateTriMesh(getSpaceID(space),_data,0,0,0);
+	registerGeometry();
+
+	_collision_listener = 0;
+}
+//------------------------------------------------------------------------------------------------
+TriangleMeshGeometry::TriangleMeshGeometry(TriangleMeshDataPtr dataPtr, World *world, Space* space) :
+	Geometry(world, space)
+{
+	// increases the referance count
+	_dataPtr = dataPtr;	
+	
+	//printf ("dataPtr counter %d\n", dataPtr.useCount() );
+	//printf ("_dataPtr counter %d\n", _dataPtr.useCount() );
+	
+	_data			= dataPtr.getPointer()->getData();
+	_vertex_count	= dataPtr.getPointer()->getVertexCount();
+	_index_count	= dataPtr.getPointer()->getIndexCount();
+	_vertices		= dataPtr.getPointer()->getVertices();
+	_indices		= (unsigned int*) dataPtr.getPointer()->getIndices();
+	
+	_geom = dCreateTriMesh(getSpaceID(space), _data,0,0,0);
+	registerGeometry();
+	
+	_collision_listener = 0;
+}
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::changeTriangleMeshData(TriangleMeshDataPtr dataPtr)
+{
+	if(dataPtr.isNull() == false)
+	{
+		_dataPtr = dataPtr;
+		
+		_data			= dataPtr.getPointer()->getData();
+		_vertex_count	= dataPtr.getPointer()->getVertexCount();
+		_index_count	= dataPtr.getPointer()->getIndexCount();
+		_vertices		= dataPtr.getPointer()->getVertices();
+		_indices		= (unsigned int*) dataPtr.getPointer()->getIndices();
+	
+		dGeomTriMeshSetData(_geom, _data);
+	
+		if ( _world->getShowDebugGeometries() )
+		{
+			destroyDebugObject();
+			createDebugObject();
+		}
+	}
+	else // setting it to a NULL
+	{
+	
+		_dataPtr = dataPtr;
+		
+		_data			= NULL;
+		_vertex_count	= 0;
+		_index_count	= 0;
+		_vertices		= NULL;
+		_indices		= NULL;
+		
+		dGeomTriMeshSetData(_geom, _data);
+		
+		if ( _world->getShowDebugGeometries() )
+		{
+			destroyDebugObject();
+			createDebugObject();
+		}
+		//printf ("TriangleMeshGeometry::changeTriangleMeshData error : The TriangleMeshDataPtr passed in isNull\n");
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+Vector3 TriangleMeshGeometry::getPoint(unsigned int index,const Ogre::Vector3& uv)
+{
+	dVector3 out;
+	dGeomTriMeshGetPoint(_geom, (int) index, (dReal)uv.x, (dReal)uv.y, out); 
+	return Ogre::Vector3((Real)out[0],(Real)out[1],(Real)out[2]);
+}
+
+//------------------------------------------------------------------------------------------------
+TriangleMeshTriangle TriangleMeshGeometry::getTriangle(int index)
+{
+	dVector3 v0,v1,v2;
+	dGeomTriMeshGetTriangle(_geom,(int)index, &v0, &v1, &v2); 
+	
+	TriangleMeshTriangle tri;
+
+	tri.v0.x = v0[0]; tri.v0.y = v0[1]; tri.v0.z = v0[2];
+	tri.v1.x = v1[0]; tri.v1.y = v1[1]; tri.v1.z = v1[2];
+	tri.v2.x = v2[0]; tri.v2.y = v2[1]; tri.v2.z = v2[2];
+	
+	return tri;
+}
+
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::clearTemporalCoherenceCache()
+{
+	dGeomTriMeshClearTCCache(_geom); 
+}
+
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::enableTemporalCoherence(Geometry::Class geometry_class, bool enable)
+{
+	assert((geometry_class == Geometry::Class_Sphere)||(geometry_class == Geometry::Class_Box));
+	dGeomTriMeshEnableTC(_geom,(int)geometry_class,(enable)?1:0); 
+}
+
+//------------------------------------------------------------------------------------------------
+bool TriangleMeshGeometry::isTemporalCoherenceEnabled(Geometry::Class geometry_class)
+{
+	return ((dGeomTriMeshIsTCEnabled(_geom,(int)geometry_class))?true:false);
+}
+
+//------------------------------------------------------------------------------------------------
+int TriangleMeshGeometry::_collisionCallback(dGeomID mesh,dGeomID object,int triangle)
+{
+	TriangleMeshGeometry* trimesh = (TriangleMeshGeometry*)dGeomGetData(mesh);
+	if (trimesh->_collision_listener)
+	{
+		Geometry* geometry = (object)?((Geometry*)dGeomGetData(object)):0;
+		return ((trimesh->_collision_listener->collide(trimesh,geometry,triangle))?1:0);
+	}
+	return 1;
+}
+
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::setCollisionListener(TriangleMeshCollisionListener* collision_listener)
+{
+	_collision_listener = collision_listener;
+	dGeomTriMeshSetCallback(_geom,(_collision_listener)?TriangleMeshGeometry::_collisionCallback:0); 
+}
+
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::_intersectionCallback(dGeomID mesh,dGeomID object,const int* triangles,int triangle_count)
+{
+	TriangleMeshGeometry* trimesh = (TriangleMeshGeometry*)dGeomGetData(mesh);
+	if (trimesh->_intersection_listener)
+	{
+		Geometry* geometry = (object)?((Geometry*)dGeomGetData(object)):0;
+		trimesh->_intersection_listener->intersect(trimesh,geometry,triangles,triangle_count);
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::setIntersectionListener(TriangleMeshIntersectionListener* intersection_listener)
+{
+	_intersection_listener = intersection_listener;
+	dGeomTriMeshSetArrayCallback(_geom,(_intersection_listener)?TriangleMeshGeometry::_intersectionCallback:0); 
+}
+
+//------------------------------------------------------------------------------------------------
+int TriangleMeshGeometry::_rayCallback(dGeomID mesh,dGeomID ray,int triangle,dReal u,dReal v)
+{
+	TriangleMeshGeometry* trimesh = (TriangleMeshGeometry*)dGeomGetData(mesh);
+	if (trimesh->_ray_listener)
+	{
+		RayGeometry* ray_geometry = (ray)?((RayGeometry*)dGeomGetData(ray)):0;
+		return ((trimesh->_ray_listener->collide(trimesh,ray_geometry,triangle,Vector3((Real)u,(Real)v,0.0)))?1:0);
+	}
+	return 1;
+}
+
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::setRayListener(TriangleMeshRayListener* ray_listener)
+{
+	_ray_listener = ray_listener;
+	dGeomTriMeshSetRayCallback(_geom,(_ray_listener)?TriangleMeshGeometry::_rayCallback:0); 
+}
+
+//------------------------------------------------------------------------------------------------
+void TriangleMeshGeometry::createDebugObject()
+{
+	if (_index_count != 0)
+	{
+		_debug_obj = new TriangleMeshDebugObject((_index_count / 3) * 6);
+		TriangleMeshDebugObject* obj = static_cast<TriangleMeshDebugObject*>(_debug_obj);
+
+		obj->beginDefinition();
+		for(unsigned int i = 0,j = 0;i < _index_count;i+=3,j+=6)
+		{
+			obj->setVertex(j,Vector3((Real)_vertices[_indices[i]][0],(Real)_vertices[_indices[i]][1],(Real)_vertices[_indices[i]][2]));
+			obj->setVertex(j+1,Vector3((Real)_vertices[_indices[i+1]][0],(Real)_vertices[_indices[i+1]][1],(Real)_vertices[_indices[i+1]][2]));
+
+			obj->setVertex(j+2,Vector3((Real)_vertices[_indices[i+1]][0],(Real)_vertices[_indices[i+1]][1],(Real)_vertices[_indices[i+1]][2]));
+			obj->setVertex(j+3,Vector3((Real)_vertices[_indices[i+2]][0],(Real)_vertices[_indices[i+2]][1],(Real)_vertices[_indices[i+2]][2]));
+
+			obj->setVertex(j+4,Vector3((Real)_vertices[_indices[i+2]][0],(Real)_vertices[_indices[i+2]][1],(Real)_vertices[_indices[i+2]][2]));
+			obj->setVertex(j+5,Vector3((Real)_vertices[_indices[i]][0],(Real)_vertices[_indices[i]][1],(Real)_vertices[_indices[i]][2]));
+		}
+		obj->endDefinition();
+
+		Geometry::createDebugObject();
+	}
+}
+
+//------------------------------------------------------------------------------------------------
+TriangleMeshGeometry::~TriangleMeshGeometry()
+{
+	if (_dataPtr.isNull())
+	{
+		dGeomTriMeshDataDestroy(_data); 
+		delete[] _vertices;
+		delete[] _indices;
+	}
+}
+
+
+//------------------------------------------------------------------------------------------------
+ConvexGeometry::ConvexGeometry(const Ogre::Vector3* vertices,
+							   unsigned int vertex_count,
+							   const unsigned int* indices,
+							   unsigned int index_count,
+                               World *world, Space* space) : 
+    Geometry(world, space),
+    _vertex_count (vertex_count),
+    _index_count (index_count)
+{
+	_vertices = new dReal[vertex_count*3];
+	_indices = new unsigned int[index_count];
+
+	for(unsigned int i = 0;i < vertex_count;i++)
+	{
+		_vertices[i*3 + 0] = (dReal)vertices[i].x;
+		_vertices[i*3 + 1] = (dReal)vertices[i].y;
+		_vertices[i*3 + 2] = (dReal)vertices[i].z;
+	}
+
+	memcpy(_indices,indices,sizeof(unsigned int) * index_count);
+
+
+	_geom = dCreateConvex (getSpaceID(space),
+		0,//dReal *_planes,
+		0,//unsigned int _planecount,
+		_vertices,
+		vertex_count,
+		0);//unsigned int *_polygons)
+
+	// 	dGeomSetConvex (dGeomID g,
+	// 		dReal *_planes,
+	// 		unsigned int _count,
+	// 		dReal *_points,
+	// 		unsigned int _pointcount,unsigned int *_polygons);
+
+	registerGeometry();
+}
+//------------------------------------------------------------------------------------------------
+void ConvexGeometry::createDebugObject()
+{
+	_debug_obj = new TriangleMeshDebugObject((_index_count / 3) * 6);
+	TriangleMeshDebugObject* obj = static_cast<TriangleMeshDebugObject*>(_debug_obj);
+
+	obj->beginDefinition();
+	for(unsigned int i = 0,j = 0;i < _index_count;i+=3,j+=6)
+	{
+		obj->setVertex(j,Vector3((Real)_vertices[_indices[i]*3 + 0],(Real)_vertices[_indices[i]*3 + 1],(Real)_vertices[_indices[i]*3 + 2]));
+		obj->setVertex(j+1,Vector3((Real)_vertices[_indices[i+1]*3 + 0],(Real)_vertices[_indices[i+1]*3 + 1],(Real)_vertices[_indices[i+1]*3 + 2]));
+
+		obj->setVertex(j+2,Vector3((Real)_vertices[_indices[i+1]*3 + 0],(Real)_vertices[_indices[i+1]*3 + 1],(Real)_vertices[_indices[i+1]*3 + 2]));
+		obj->setVertex(j+3,Vector3((Real)_vertices[_indices[i+2]*3 + 0],(Real)_vertices[_indices[i+2]*3 + 1],(Real)_vertices[_indices[i+2]*3 + 2]));
+
+		obj->setVertex(j+4,Vector3((Real)_vertices[_indices[i+2]*3 + 0],(Real)_vertices[_indices[i+2]*3 + 1],(Real)_vertices[_indices[i+2]*3 + 2]));
+		obj->setVertex(j+5,Vector3((Real)_vertices[_indices[i]*3 + 0],(Real)_vertices[_indices[i]*3 + 1],(Real)_vertices[_indices[i]*3 + 2]));
+	}
+	obj->endDefinition();
+
+	Geometry::createDebugObject();
+}
+//------------------------------------------------------------------------------------------------
+ConvexGeometry::~ConvexGeometry()
+{
+	delete[] _vertices;
+	delete[] _indices;
+}
+
+//------------------------------------------------------------------------------------------------
+TerrainGeometry::TerrainGeometry(World *world, Space* space,
+								const Ogre::Vector3 &scale,
+                                int nodes_per_sideX,
+                                int nodes_per_sideY,
+                                Ogre::Real worldSizeX,
+                                Ogre::Real worldSizeZ,
+								bool centered,
+                                Ogre::Real thickness) :
+                        Geometry(world, space),
+                        _max_height (scale.y),
+                        _sample_width(scale.x),
+                        _sample_height(scale.z),
+                        _centered(centered),
+                        _halfWorldSizeX(worldSizeX * 0.5),
+                        _halfWorldSizeZ(worldSizeZ * 0.5)
+{
+	dHeightfieldDataID heightid = dGeomHeightfieldDataCreate();
+	dGeomHeightfieldDataBuildCallback(	heightid, //getSpaceID(space), 
+										this, // pUserData ?
+										TerrainGeometry::_heightCallback, 
+										(dReal) (worldSizeX), //X
+										(dReal) (worldSizeZ), //Z
+										nodes_per_sideX, // w // Vertex count along edge >= 2
+										nodes_per_sideY, // h // Vertex count along edge >= 2
+										REAL( 1.0 ),     //scale
+										REAL( 0.0 ),	// vOffset
+										thickness,	// vThickness
+										 0); // nWrapMode
+
+
+	// Give some very bounds which, while conservative,
+	// makes AABB computation more accurate than +/-INF.
+	dGeomHeightfieldDataSetBounds( heightid, REAL( 0.0 ),  _max_height );
+	_geom = dCreateHeightfield( getSpaceID(space), heightid, 1 );
+
+	_listener = 0;
+	_ray = Ogre::Ray (Ogre::Vector3::ZERO, Ogre::Vector3::NEGATIVE_UNIT_Y);
+	_ray_query = _world->getSceneManager()->createRayQuery(_ray);
+
+	_ray_query->setQueryTypeMask(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
+	_ray_query->setWorldFragmentType(Ogre::SceneQuery::WFT_SINGLE_INTERSECTION); 
+
+	registerGeometry();
+
+	if (_centered)
+	{
+		// PLSM2 is centered by default.	
+        //setPosition (Ogre::Vector3::ZERO);
+        ;
+	}
+	else
+	{
+        // TSM is not centered by default.	
+		setPosition (Ogre::Vector3(_halfWorldSizeX, 
+                                    0, 
+                                    _halfWorldSizeZ));
+	}
+	setOrientation(Ogre::Quaternion::ZERO);
+}
+
+//------------------------------------------------------------------------------------------------
+dReal TerrainGeometry::_heightCallback(void* data,int x,int z)
+{
+	TerrainGeometry * const terrain = (TerrainGeometry*)data;    
+	if (terrain->_listener)
+	{
+		return static_cast <dReal> (terrain->_listener->heightAt(Vector3((Ogre::Real)x,
+                                                                terrain->_max_height,
+                                                                (Ogre::Real)z)));
+	}
+    else
+    {
+        return static_cast <dReal> (terrain->getHeightAt(Vector3((Ogre::Real)x, 
+                                                        terrain->_max_height, 
+                                                        (Ogre::Real)z)));
+    }
+}
+
+//------------------------------------------------------------------------------------------------
+Ogre::Real TerrainGeometry::getPointDepth(const Ogre::Vector3& point)
+{
+	//return (Real)dGeomTerrainCallbackPointDepth(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z); 
+	//return (Real) dGeomHeightfieldPointDepth (_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z);
+	//dGetDepthFn(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z);
+	return (Real) 0.0;
+}
+
+//------------------------------------------------------------------------------------------------
+void TerrainGeometry::setHeightListener(TerrainGeometryHeightListener* listener)
+{
+	_listener = listener;
+}
+//------------------------------------------------------------------------------------------------
+bool TerrainGeometry::queryResult(Ogre::MovableObject *obj, Ogre::Real distance)
+{
+	return false;
+}
+
+//------------------------------------------------------------------------------------------------
+bool TerrainGeometry::queryResult(Ogre::SceneQuery::WorldFragment *fragment,Ogre::Real distance)
+{
+	_distance_to_terrain = distance;
+	return false;
+}
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& TerrainGeometry::getPosition()
+{
+	return Ogre::Vector3::ZERO;
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Quaternion& TerrainGeometry::getOrientation()
+{
+	return Ogre::Quaternion::ZERO;
+}
+
+//------------------------------------------------------------------------------------------------
+TerrainGeometry::~TerrainGeometry()
+{
+	_world->getSceneManager()->destroyQuery(_ray_query);
+}
+
+//------------------------------------------------------------------------------------------------
+std::list<Ogre::Plane>* PlaneBoundedRegionGeometry::_planeCallback(void* data,int x,int z)
+{
+    PlaneBoundedRegionGeometry* terrain = (PlaneBoundedRegionGeometry*)data;
+
+    if (terrain->_listener)
+    {
+        return terrain->_listener->planesAt(Vector3((Ogre::Real)x,
+            terrain->_max_height,
+            (Ogre::Real)z));
+    }
+    else
+    {
+        return  terrain->planesAt(Vector3((Ogre::Real)x, 
+                terrain->_max_height, 
+                (Ogre::Real)z));
+    }
+    return 0;
+}
+//------------------------------------------------------------------------------------------------
+PlaneBoundedRegionGeometry::PlaneBoundedRegionGeometry (World *world, Space* space,
+                                                        const Ogre::AxisAlignedBox &Size) : 
+    Geometry(world,space)
+{
+
+    _ray = Ogre::Ray (Ogre::Vector3::ZERO, Ogre::Vector3::NEGATIVE_UNIT_Y);
+    _ray_query = _world->getSceneManager()->createRayQuery(_ray);
+
+    _ray_query->setQueryTypeMask(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
+    _ray_query->setWorldFragmentType(Ogre::SceneQuery::WFT_SINGLE_INTERSECTION); 
+
+}
+
+//------------------------------------------------------------------------------------------------
+Ogre::Real PlaneBoundedRegionGeometry::getPointDepth(const Ogre::Vector3& point)
+{
+    //dGetDepthFn(_geom,(dReal)point.x,(dReal)point.y,(dReal)point.z);
+    return (Real) 0.0;
+}
+
+//------------------------------------------------------------------------------------------------
+void PlaneBoundedRegionGeometry::setPlaneListener(PlaneBoundedRegionGeometryPlaneListener* listener)
+{
+    _listener = listener;
+}
+//------------------------------------------------------------------------------------------------
+bool PlaneBoundedRegionGeometry::queryResult(Ogre::MovableObject *obj, Ogre::Real distance)
+{
+    return false;
+}
+
+//------------------------------------------------------------------------------------------------
+bool PlaneBoundedRegionGeometry::queryResult(Ogre::SceneQuery::WorldFragment *fragment,Ogre::Real distance)
+{
+    _distance_to_terrain = distance;
+    return false;
+}
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& PlaneBoundedRegionGeometry::getPosition()
+{
+    return Ogre::Vector3::ZERO;
+}
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Quaternion& PlaneBoundedRegionGeometry::getOrientation()
+{
+    return Ogre::Quaternion::ZERO;
+}
+
+//------------------------------------------------------------------------------------------------
+PlaneBoundedRegionGeometry::~PlaneBoundedRegionGeometry()
+{
+    _world->getSceneManager()->destroyQuery(_ray_query);
+}
+
+
Index: /code/branches/physics/src/ogreode/OgreOdeGeometry.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeGeometry.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeGeometry.h	(revision 2122)
@@ -0,0 +1,615 @@
+#ifndef _OGREODEGEOMETRY_H_
+#define _OGREODEGEOMETRY_H_
+
+#include "OgreOdePreReqs.h"
+
+#include <OgreUserDefinedObject.h>
+#include <OgreMovableObject.h>
+#include <OgreSceneQuery.h>
+#include "OgreOdeTriangleMeshData.h"
+
+namespace OgreOde 
+{
+    /** 
+    This object is the base class for all Geometry objects in OgreOde.
+    @remarks
+        This object is tied either to a Body (acting as collision proxy for a physic object) 
+        or to a Entity Object (which then is physically "static")
+    @remarks
+        It extends the OGRE UserDefinedObject to allow reverse links from Ogre::Entity.
+        Note that this class does not override the UserDefinedObject's getTypeId method 
+        because this class is abstract.
+    */  
+    class _OgreOdeExport Geometry : public Ogre::UserDefinedObject, public Ogre::MovableObject
+	{
+		friend class Space;
+        friend class World;
+        friend class Body;
+		friend class TransformGeometry;
+
+	public:
+		enum Class
+		{
+			Class_Sphere		= dSphereClass,
+			Class_Box			= dBoxClass,
+			Class_Capsule		= dCapsuleClass,
+			Class_Cylinder		= dCCylinderClass,
+			Class_InfinitePlane = dPlaneClass,
+			Class_Ray			= dRayClass,
+			Class_TriangleMesh	= dTriMeshClass,
+			Class_Terrain		= dHeightfieldClass,
+			Class_Convex		= dConvexClass,
+			Class_Transform		= dGeomTransformClass,
+			Class_NoGeometry
+		};
+
+	public:
+        Geometry(World *world,  Space* space = 0);
+		virtual ~Geometry();
+
+		virtual void                        setBody(Body* body);
+		Body*                               getBody(); 
+
+
+		virtual void                        setPosition(const Ogre::Vector3& position);
+		virtual void                        setOrientation(const Ogre::Quaternion& orientation);	
+		virtual const Ogre::Vector3&        getPosition();
+		virtual const Ogre::Quaternion&     getOrientation();
+		virtual const Ogre::AxisAlignedBox& getAxisAlignedBox(); 
+
+
+		Space*                              getSpace(); 
+
+		void                                 enable();
+		void                                 disable();
+		bool                                 isEnabled(); 
+
+		Geometry::Class                     getClass() const; 
+
+        void                                 setCategoryBitfield(unsigned long bits); 
+        void                                 setCollisionBitfield(unsigned long bits); 
+		unsigned long						 getCategoryBitfield(); 
+		unsigned long						 getCollisionBitfield(); 
+
+		int                                 collide(Geometry* geometry, CollisionListener* listener = 0);
+
+		void                                setMaxContacts(unsigned int max_contacts);
+		unsigned int                        getMaxContacts() const;
+		unsigned int                        getContactHighWaterMark() const;
+
+		void                                setEncapsulator(Geometry* encapsulator);
+		Geometry*                           getEncapsulator(){return _encapsulator;}
+
+		void                                setUserData(size_t user_data){_user_data = user_data;}
+		size_t								getUserData() const {return _user_data;}
+
+		void                                setUserObject(UserDefinedObject* object){_user_object = object;}
+		UserDefinedObject*                  getUserObject(){return _user_object;}
+
+		virtual size_t						 getID() const ;
+		virtual void                        notify(Body* body);
+
+
+        virtual void                        setDebug(const bool debug);
+        virtual void                        createDebugObject();
+        virtual void                        destroyDebugObject();
+        void                                reparentDebugObject(Ogre::Node* node);
+
+        virtual void                        setDebugContact(const bool debug);
+        void                                updateDebugContact();
+
+		void                                clearOffset();
+		int                                 isOffset();
+
+		void                                setOffsetPosition (const Ogre::Vector3 &position);
+		void                                setOffsetQuaternion(const Ogre::Quaternion &orientation);
+
+		 void                               setOffsetWorldPosition(const Ogre::Vector3 &position);		
+		 void                               setOffsetWorldQuaternion(const Ogre::Quaternion &orientation) ;
+
+		 Ogre::Vector3                      getOffsetPosition() ;
+		 Ogre::Quaternion                   getOffsetQuaternion() ;
+
+
+		/**	returns mGeometry's AABB
+		*/
+		virtual const Ogre::AxisAlignedBox& getBoundingBox(void) const	{return _bounding_box; };
+
+		/**
+		*/
+		static const Ogre::String MovableType;
+		virtual const Ogre::String& getMovableType() const { return MovableType; }; 
+
+		/**
+		*/		
+		virtual Ogre::Real getBoundingRadius(void) const { return Ogre::Real(0.0); }
+		
+		/**
+		*/
+		virtual void _updateRenderQueue(Ogre::RenderQueue* queue){}
+		
+		/** added for Ogre 1.5
+		*/
+#if OGRE_VERSION >= ((1 << 16) | (5 << 8))
+		virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false){}
+#endif
+
+		/** set mParentNode and sets mGeometrys position and orientation to match mParentNode's
+		*/
+		virtual void _notifyAttached(Ogre::Node* parent, bool isTagPoint = false);
+		
+		/** sets mGeometry position and orientation to match mParentNode's
+		*/
+		virtual void _notifyMoved();
+		
+		
+		virtual const Ogre::String& getName (void) const { return mName; }
+		
+		/** setting mName is not important - its not actually being used
+		it just helps debugging code
+		*/
+		void setName (Ogre::String name){ mName = name; }
+
+
+
+	protected:
+		dGeomID                             getGeometryID() const;
+		void                                registerGeometry();
+		dSpaceID                            getSpaceID(Space* space) const;
+
+	protected:
+		Ogre::String						mName;
+		dGeomID                             _geom;
+		unsigned int                        _max_contacts;
+        unsigned int                        _contact_high_water_mark;
+        unsigned int                        _last_contact_num;
+		dContact*                           _contacts;
+
+		DebugObject*                        _debug_obj;
+        Ogre::Node*                         _debug_node;
+        DebugContact**                      _debug_contacts;
+
+		Geometry*                           _encapsulator;
+		Ogre::AxisAlignedBox                _bounding_box;
+		Ogre::Quaternion                    _orientation;
+		Ogre::Vector3                       _position;
+
+		static int                          _geometry_count;
+		size_t								_user_data;
+		UserDefinedObject*                  _user_object;
+        World                               *_world;
+
+	};
+
+	//------------------------------------------------------------------------------------------------
+    class _OgreOdeExport SphereGeometry:public Geometry
+	{
+	public:
+		SphereGeometry(Ogre::Real radius, World *world, Space* space = 0);
+		~SphereGeometry();
+
+		virtual void createDebugObject();
+
+		void setRadius(Ogre::Real radius);
+		Ogre::Real getRadius();
+        Ogre::Real getPointDepth(const Ogre::Vector3& point);  
+        /** Return a string identifying the type of user defined object.
+           @remarks
+           Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Sphere");return sName;};
+
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport BoxGeometry:public Geometry
+	{
+	public:
+		BoxGeometry(const Ogre::Vector3& size,  World *world, Space* space = 0);
+		~BoxGeometry();
+
+		virtual void createDebugObject();
+
+		void setSize(const Ogre::Vector3& size);
+		const Ogre::Vector3& getSize();
+		Ogre::Real getPointDepth(const Ogre::Vector3& point);
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Box");return sName;};
+
+	protected:
+		Ogre::Vector3 _size;
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport InfinitePlaneGeometry:public Geometry
+	{
+	public:
+		InfinitePlaneGeometry(const Ogre::Plane& plane, World *world, Space* space = 0);
+		~InfinitePlaneGeometry();
+
+		void setDefinition(const Ogre::Plane& plane);
+		const Ogre::Plane& getDefinition();
+		Ogre::Real getPointDepth(const Ogre::Vector3& point);
+
+		void setPosition(const Ogre::Vector3& position);
+		void setOrientation(const Ogre::Quaternion& orientation);	
+		const Ogre::Vector3& getPosition();
+		const Ogre::Quaternion& getOrientation();
+		const Ogre::AxisAlignedBox& getAxisAlignedBox(); 
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Infinity Plane");return sName;};
+
+	protected:
+		Ogre::Plane _plane;
+    };
+    //------------------------------------------------------------------------------------------------
+	class _OgreOdeExport CapsuleGeometry:public Geometry
+	{
+	public:
+		CapsuleGeometry(Ogre::Real radius, Ogre::Real length, World *world, Space* space = 0);
+		~CapsuleGeometry();
+
+		virtual void createDebugObject();
+ 
+		void setDefinition(Ogre::Real radius, Ogre::Real length);
+		Ogre::Real getRadius();
+		Ogre::Real getLength();
+		Ogre::Real getPointDepth(const Ogre::Vector3& point);
+
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Capsule");return sName;};
+
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport CylinderGeometry:public Geometry
+	{
+	public:
+		CylinderGeometry(Ogre::Real radius, Ogre::Real length, World *world, Space* space = 0);
+		~CylinderGeometry();
+
+		virtual void createDebugObject();
+
+		void setDefinition(Ogre::Real radius, Ogre::Real length);
+		Ogre::Real getRadius();
+		Ogre::Real getLength();
+		Ogre::Real getPointDepth(const Ogre::Vector3& point);
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Cylinder");return sName;};
+
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport RayGeometry:public Geometry
+	{
+	public:
+		RayGeometry(Ogre::Real length, World *world, Space* space = 0);
+		~RayGeometry();
+
+		virtual void createDebugObject();
+		
+		void setLength(Ogre::Real length);
+		Ogre::Real getLength();
+		void setDefinition(const Ogre::Vector3& start, const Ogre::Vector3& direction);
+		const Ogre::Vector3& getStart();
+		const Ogre::Vector3& getDirection();
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Ray");return sName;};
+
+	protected:
+		Ogre::Vector3 _direction,_start;
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TransformGeometry:public Geometry
+	{
+	public:
+		TransformGeometry(World *world, Space* space);
+		~TransformGeometry();
+
+		virtual void createDebugObject();
+		virtual void destroyDebugObject();
+
+		void setEncapsulatedGeometry(Geometry* geometry);
+		Geometry* getEncapsulatedGeometry() const;
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Transform");return sName;};
+
+	};
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TriangleMeshCollisionListener
+	{
+	public:
+		TriangleMeshCollisionListener(){}
+		virtual ~TriangleMeshCollisionListener(){}
+
+		virtual bool collide(TriangleMeshGeometry* triangle_mesh, Geometry* geometry, int triangle) {return true;}
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TriangleMeshIntersectionListener
+	{
+	public:
+		TriangleMeshIntersectionListener(){}
+		virtual ~TriangleMeshIntersectionListener(){}
+
+		virtual void intersect(TriangleMeshGeometry* triangle_mesh, Geometry* geometry, const int* triangles, int triangle_count){}
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TriangleMeshRayListener
+	{
+	public:
+		TriangleMeshRayListener(){}
+		virtual ~TriangleMeshRayListener(){}
+
+		virtual bool collide(TriangleMeshGeometry* triangle_mesh, RayGeometry* ray,int triangle, const Ogre::Vector3& uv){return true;}
+	};
+
+	//------------------------------------------------------------------------------------------------
+	struct _OgreOdeExport TriangleMeshTriangle
+	{
+		Ogre::Vector3 v0,v1,v2;
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TriangleMeshGeometry:public Geometry
+	{
+	public:
+		TriangleMeshGeometry(const Ogre::Vector3* vertices, 
+                             unsigned int vertex_count, 
+                             const TriangleIndex* indices,
+                             unsigned int index_count,
+                             World *world, 
+                             Space* space = 0);
+		
+		TriangleMeshGeometry(TriangleMeshDataPtr dataPtr, World *world, Space* space = 0);
+		
+		void changeTriangleMeshData(TriangleMeshDataPtr dataPtr);
+		
+		TriangleMeshDataPtr getTriangleMeshData(){ return _dataPtr; }
+		
+		~TriangleMeshGeometry();
+
+		Ogre::Vector3 getPoint(unsigned int index, const Ogre::Vector3& uv);
+		TriangleMeshTriangle getTriangle(int index);
+
+		void clearTemporalCoherenceCache(); 
+		void enableTemporalCoherence(Geometry::Class geometry_class,bool enable); 
+		bool isTemporalCoherenceEnabled(Geometry::Class geometry_class);
+
+		static int _collisionCallback(dGeomID mesh,dGeomID object,int triangle);
+		void setCollisionListener(TriangleMeshCollisionListener* collision_listener);
+
+		static void _intersectionCallback(dGeomID mesh,dGeomID object,const int* triangles,int triangle_count);
+		void setIntersectionListener(TriangleMeshIntersectionListener* intersection_listener); 
+
+		static int _rayCallback(dGeomID mesh,dGeomID ray,int triangle,dReal u,dReal v);
+		void setRayListener(TriangleMeshRayListener* ray_listener); 
+
+		virtual void createDebugObject();
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Trimesh");return sName;};
+
+	protected:
+		dTriMeshDataID _data;
+		dVector3* _vertices;
+		unsigned int* _indices;
+		unsigned int _vertex_count;
+        unsigned int _index_count;
+
+		TriangleMeshDataPtr _dataPtr;
+		
+		TriangleMeshCollisionListener* _collision_listener;
+		TriangleMeshIntersectionListener* _intersection_listener;
+		TriangleMeshRayListener* _ray_listener;
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport ConvexGeometry:public Geometry
+	{
+	public:
+		ConvexGeometry(const Ogre::Vector3* vertices, 
+						unsigned int vertex_count, 
+						const unsigned int* indices,
+						unsigned int index_count,
+						World *world, 
+                        Space* space = 0);
+		~ConvexGeometry();
+
+
+		virtual void createDebugObject();
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Convex");return sName;};
+
+	protected:
+		dReal	* _vertices;
+		unsigned int* _indices;
+		unsigned int _vertex_count;
+		unsigned int _index_count;
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TerrainGeometryHeightListener
+	{
+	public:
+		TerrainGeometryHeightListener(){}
+		virtual ~TerrainGeometryHeightListener(){}
+
+		virtual Ogre::Real heightAt(const Ogre::Vector3& position) = 0;
+	};
+
+	//------------------------------------------------------------------------------------------------
+	class _OgreOdeExport TerrainGeometry:public Geometry, public Ogre::RaySceneQueryListener
+	{
+	public:
+        TerrainGeometry(World *world, 
+                        Space* space,
+                        const Ogre::Vector3 &scale,
+                        int nodes_per_sideX,
+                        int nodes_per_sideY,
+                        Ogre::Real worldSizeX,
+                        Ogre::Real worldSizeZ,
+                        bool centered,
+                        Ogre::Real thickness = 10.0f);
+
+		~TerrainGeometry();
+
+		Ogre::Real getPointDepth(const Ogre::Vector3& point);
+		const Ogre::Vector3& getPosition();
+		const Ogre::Quaternion& getOrientation();
+		
+		static dReal _heightCallback(void* data, dReal x, dReal z);
+		static dReal _heightCallback(void* data, int x, int z);
+		void setHeightListener(TerrainGeometryHeightListener* listener);
+
+        inline Ogre::Real getHeightAt(const Ogre::Vector3& position)
+        {
+            _num_query++;
+            const Ogre::Vector3 pos (position.x * _sample_width - (_centered?_halfWorldSizeX:0),
+                position.y,
+                position.z * _sample_height - (_centered?_halfWorldSizeZ:0)); 
+            _ray.setOrigin(pos);
+            _ray_query->setRay(_ray);
+            _distance_to_terrain = static_cast<Ogre::Real>(0.0);
+            _ray_query->execute(this);
+            return position.y - _distance_to_terrain;
+        }
+
+		bool queryResult(Ogre::MovableObject *obj, Ogre::Real distance);
+		bool queryResult(Ogre::SceneQuery::WorldFragment *fragment, Ogre::Real distance);
+
+        size_t getNumQueries() const {return _num_query;};
+        void resetNumQueries(){_num_query = 0;};
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Terrain");return sName;};
+
+	protected:
+		Ogre::Real _max_height;
+		Ogre::Real _distance_to_terrain;
+		Ogre::Real _sample_width, _sample_height;
+		TerrainGeometryHeightListener* _listener;
+		Ogre::Ray _ray;
+		Ogre::RaySceneQuery* _ray_query;
+        bool _centered;
+        Ogre::Real _halfWorldSizeX; 
+        Ogre::Real _halfWorldSizeZ;
+        size_t _num_query;
+    };
+    //------------------------------------------------------------------------------------------------
+    class _OgreOdeExport PlaneBoundedRegionGeometryPlaneListener
+    {
+    public:
+        PlaneBoundedRegionGeometryPlaneListener(){}
+        virtual ~PlaneBoundedRegionGeometryPlaneListener(){}
+
+        virtual std::list<Ogre::Plane>* planesAt(const Ogre::Vector3& position) = 0;
+    };
+
+    //------------------------------------------------------------------------------------------------
+    class _OgreOdeExport PlaneBoundedRegionGeometry:public Geometry, public Ogre::RaySceneQueryListener
+    {
+    public:
+        PlaneBoundedRegionGeometry(World *world, 
+                                    Space* space,
+                                    const Ogre::AxisAlignedBox &scale);
+
+        ~PlaneBoundedRegionGeometry();
+
+        Ogre::Real getPointDepth(const Ogre::Vector3& point);
+        const Ogre::Vector3& getPosition();
+        const Ogre::Quaternion& getOrientation();
+
+        static std::list<Ogre::Plane> * _planeCallback(void* data, dReal x, dReal z);
+        static std::list<Ogre::Plane> * _planeCallback(void* data, int x, int z);
+        void setPlaneListener(PlaneBoundedRegionGeometryPlaneListener* listener);
+
+        inline std::list<Ogre::Plane> *planesAt(const Ogre::Vector3& position)
+        {
+            _num_query++;
+//             const Ogre::Vector3 pos (position.x * _sample_width - (_centered?_halfWorldSizeX:0),
+//                                     position.y,
+//                                     position.z * _sample_height - (_centered?_halfWorldSizeZ:0)); 
+//             _ray.setOrigin(pos);
+//             _ray_query->setRay(_ray);
+//             _distance_to_terrain = static_cast<Ogre::Real>(0.0);
+//             _ray_query->execute(this);
+
+            return _last_query_results;
+
+        }
+
+        bool queryResult(Ogre::MovableObject *obj, Ogre::Real distance);
+        bool queryResult(Ogre::SceneQuery::WorldFragment *fragment, Ogre::Real distance);
+
+        size_t getNumQueries() const {return _num_query;};
+        void resetNumQueries(){_num_query = 0;};
+
+        /** Return a string identifying the type of user defined object.
+        @remarks
+        Used to differentiate between different Bodies, Geometries and prefab_object
+        */
+        const Ogre::String& getTypeName(void) const
+        {static Ogre::String sName("Geometry Plane Bounded Region");return sName;};
+
+    protected:
+        Ogre::Real _max_height;
+        Ogre::Real _distance_to_terrain;
+        Ogre::Real _sample_width, _sample_height;
+        PlaneBoundedRegionGeometryPlaneListener* _listener;
+        Ogre::Ray _ray;
+        Ogre::RaySceneQuery* _ray_query;
+        bool _centered;
+        Ogre::Real _halfWorldSizeX; 
+        Ogre::Real _halfWorldSizeZ;
+        size_t _num_query;
+
+        std::list<Ogre::Plane> *_last_query_results;
+    };
+}
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOdeJoint.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeJoint.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeJoint.cpp	(revision 2122)
@@ -0,0 +1,901 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeJoint.h"
+
+#include "OgreOdeWorld.h"
+#include "OgreOdeBody.h"
+#include "OgreOdeGeometry.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+JointGroup::JointGroup(World *world):
+_world(world)
+{
+	_joint_group = dJointGroupCreate(0); 
+	_world->getJointGroupList().registerItem(this);
+}
+//------------------------------------------------------------------------------------------------
+dJointGroupID JointGroup::getJointGroupID() const
+{
+	return _joint_group;
+}
+
+size_t JointGroup::getID()
+{
+	return (size_t)_joint_group;
+}
+
+void JointGroup::empty()
+{
+	dJointGroupEmpty(_joint_group); 
+}
+
+JointGroup::~JointGroup()
+{
+	_world->getJointGroupList().unregisterItem((size_t)_joint_group);
+	dJointGroupDestroy(_joint_group); 
+}
+
+Joint::Joint(World *world, const JointGroup* group):
+    _world(world)
+{
+}
+
+void Joint::registerJoint()
+{
+	_world->getJointList().registerItem(this);
+}
+
+void Joint::setAnchor(const Ogre::Vector3& position)
+{
+}
+
+void Joint::addTorque(Real torque,Real torque2,Real torque3)
+{
+}
+
+void Joint::addForce(Real force,Real force2,Real force3)
+{
+}
+
+const Ogre::Vector3& Joint::getAnchor()
+{
+	return Ogre::Vector3::ZERO;
+}
+
+const Ogre::Vector3& Joint::getAnchorError()
+{
+	return Ogre::Vector3::ZERO;
+}
+
+void Joint::setAxis(const Ogre::Vector3& axis)
+{
+}
+
+const Ogre::Vector3& Joint::getAxis()
+{
+	return Ogre::Vector3::ZERO;
+}
+
+void Joint::setAdditionalAxis(const Ogre::Vector3& axis)
+{
+}
+
+const Ogre::Vector3& Joint::getAdditionalAxis()
+{
+	return Ogre::Vector3::ZERO;
+}
+
+Real Joint::getAngle()
+{
+	return 0.0;
+}
+
+Real Joint::getAngleRate()
+{
+	return 0.0;
+}
+
+Real Joint::getPosition()
+{
+	return 0.0;
+}
+
+Real Joint::getPositionRate()
+{
+	return 0.0;
+}
+
+size_t Joint::getID()
+{
+	return (size_t)_joint;
+}
+
+Joint::~Joint()
+{
+	_world->getJointList().unregisterItem((size_t)_joint);
+	dJointDestroy(_joint); 
+}
+
+dWorldID Joint::getWorldID()
+{
+	return _world->getWorldID();
+}
+
+dJointGroupID Joint::getJointGroupID(const JointGroup* group) const
+{
+	return ((group)?group->getJointGroupID():0);
+}
+
+dJointID Joint::getJointID()
+{
+	return _joint;
+}
+
+Joint::Type Joint::getType()
+{
+	return (Joint::Type)(dJointGetType(_joint));
+}
+
+Body* Joint::getFirstBody()
+{
+	dBodyID b = dJointGetBody(_joint, 0); 
+	return ((Body*)dBodyGetData(b));
+}
+
+Body* Joint::getSecondBody()
+{
+	dBodyID b = dJointGetBody(_joint,1);
+	return b ? ((Body*)dBodyGetData(b)) : 0; 
+}
+
+bool Joint::areConnected(const Body* body_a,const Body* body_b)
+{
+	return (dAreConnected(body_a->getBodyID(),body_b->getBodyID()))?true:false; 
+}
+
+bool Joint::areConnectedExcluding(const Body* body_a,const Body* body_b,Joint::Type joint_type)
+{
+	return (dAreConnectedExcluding(body_a->getBodyID(),body_b->getBodyID(),(int)joint_type))?true:false; 
+}
+
+void Joint::enableFeedback()
+{
+	dJointSetFeedback(_joint,&_feedback); 
+}
+
+void Joint::disableFeedback()
+{
+	dJointSetFeedback(_joint,0); 
+}
+
+void Joint::detach()
+{
+	dJointAttach(_joint,0,0); 
+}
+
+void Joint::attach(const Body* body)
+{
+	dJointAttach(_joint,body->getBodyID(),0); 
+}
+
+void Joint::attach(const Body* body_a,const Body* body_b)
+{
+	dJointAttach(_joint,body_a->getBodyID(),body_b->getBodyID()); 
+}
+
+const Ogre::Vector3& Joint::getFirstForce()
+{
+	assert(dJointGetFeedback(_joint) == &_feedback);
+
+	_first_force.x = _feedback.f1[0];
+	_first_force.y = _feedback.f1[1];
+	_first_force.z = _feedback.f1[2];
+	return _first_force;
+}
+
+const Ogre::Vector3& Joint::getFirstTorque()
+{
+	assert(dJointGetFeedback(_joint) == &_feedback);
+
+	_first_torque.x = _feedback.t1[0];
+	_first_torque.y = _feedback.t1[1];
+	_first_torque.z = _feedback.t1[2];
+	return _first_torque;
+}
+
+const Ogre::Vector3& Joint::getSecondForce()
+{
+	assert(dJointGetFeedback(_joint) == &_feedback);
+
+	_second_force.x = _feedback.f2[0];
+	_second_force.y = _feedback.f2[1];
+	_second_force.z = _feedback.f2[2];
+	return _second_force;
+}
+
+const Ogre::Vector3& Joint::getSecondTorque()
+{
+	assert(dJointGetFeedback(_joint) == &_feedback);
+
+	_second_torque.x = _feedback.t2[0];
+	_second_torque.y = _feedback.t2[1];
+	_second_torque.z = _feedback.t2[2];
+	return _second_torque;
+}
+
+void Joint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+}
+
+Real Joint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return 0.0;
+}
+
+BallJoint::BallJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreateBall(getWorldID(),getJointGroupID(group));
+	registerJoint();
+}
+
+void BallJoint::setAnchor(const Ogre::Vector3& position)
+{
+	dJointSetBallAnchor(_joint,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+
+const Ogre::Vector3& BallJoint::getAnchor()
+{
+	dVector3 result;
+	dJointGetBallAnchor(_joint,result); 
+	_anchor.x = (Real)result[0];
+	_anchor.y = (Real)result[1];
+	_anchor.z = (Real)result[2];
+	return _anchor;
+}
+
+const Ogre::Vector3& BallJoint::getAnchorError()
+{
+	dVector3 result1,result2;
+	dJointGetBallAnchor(_joint,result1); 
+	dJointGetBallAnchor2(_joint,result2); 
+	_anchor_error.x = (Real)(result1[0] - result2[0]);
+	_anchor_error.y = (Real)(result1[1] - result2[1]);
+	_anchor_error.z = (Real)(result1[2] - result2[2]);
+	return _anchor_error;
+}
+
+void BallJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetBallParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value);  
+}
+
+Real BallJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetBallParam(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+
+BallJoint::~BallJoint()
+{
+}
+
+HingeJoint::HingeJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreateHinge(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+void HingeJoint::setAnchor(const Ogre::Vector3& position)
+{
+	dJointSetHingeAnchor(_joint,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+
+void HingeJoint::addTorque(Real torque,Real torque2,Real torque3)
+{
+	dJointAddHingeTorque(_joint,(dReal)torque);
+}
+
+const Ogre::Vector3& HingeJoint::getAnchor()
+{
+	dVector3 result;
+	dJointGetHingeAnchor(_joint,result); 
+	_anchor.x = (Real)result[0];
+	_anchor.y = (Real)result[1];
+	_anchor.z = (Real)result[2];
+	return _anchor;
+}
+
+const Ogre::Vector3& HingeJoint::getAnchorError()
+{
+	dVector3 result1,result2;
+	dJointGetHingeAnchor(_joint,result1); 
+	dJointGetHingeAnchor2(_joint,result2); 
+	_anchor_error.x = (Real)(result1[0] - result2[0]);
+	_anchor_error.y = (Real)(result1[1] - result2[1]);
+	_anchor_error.z = (Real)(result1[2] - result2[2]);
+	return _anchor_error;
+}
+
+void HingeJoint::setAxis(const Ogre::Vector3& axis)
+{
+	dJointSetHingeAxis(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& HingeJoint::getAxis()
+{
+	dVector3 result;
+	dJointGetHingeAxis(_joint,result); 
+	_axis.x = (Real)result[0];
+	_axis.y = (Real)result[1];
+	_axis.z = (Real)result[2];
+	return _axis;
+}
+
+Real HingeJoint::getAngle()
+{
+	return (Real)dJointGetHingeAngle(_joint); 
+}
+
+Real HingeJoint::getAngleRate()
+{
+	return (Real)dJointGetHingeAngleRate(_joint); 
+}
+
+void HingeJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetHingeParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value); 
+}
+
+Real HingeJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetHingeParam(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+HingeJoint::~HingeJoint()
+{
+}
+
+SliderJoint::SliderJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreateSlider(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+void SliderJoint::setAxis(const Ogre::Vector3& axis)
+{
+	dJointSetSliderAxis(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& SliderJoint::getAxis()
+{
+	dVector3 result;
+	dJointGetSliderAxis(_joint,result); 
+	_axis.x = (Real)result[0];
+	_axis.y = (Real)result[1];
+	_axis.z = (Real)result[2];
+	return _axis;
+}
+
+void SliderJoint::addForce(Real force,Real force2,Real force3)
+{
+	dJointAddSliderForce(_joint,(dReal)force);
+}
+
+Real SliderJoint::getPosition()
+{
+	return (Real)dJointGetSliderPosition(_joint); 
+}
+
+Real SliderJoint::getPositionRate()
+{
+	return (Real)dJointGetSliderPositionRate(_joint); 
+}
+
+void SliderJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetSliderParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value); 
+}
+
+Real SliderJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetSliderParam(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+SliderJoint::~SliderJoint()
+{
+}
+
+UniversalJoint::UniversalJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreateUniversal(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+void UniversalJoint::setAnchor(const Ogre::Vector3& position)
+{
+	dJointSetUniversalAnchor(_joint,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+
+void UniversalJoint::addTorque(Real torque,Real torque2,Real torque3)
+{
+	dJointAddUniversalTorques(_joint,(dReal)torque,(dReal)torque2);
+}
+
+const Ogre::Vector3& UniversalJoint::getAnchor()
+{
+	dVector3 result;
+	dJointGetUniversalAnchor(_joint,result); 
+	_anchor.x = (Real)result[0];
+	_anchor.y = (Real)result[1];
+	_anchor.z = (Real)result[2];
+	return _anchor;
+}
+
+const Ogre::Vector3& UniversalJoint::getAnchorError()
+{
+	dVector3 result1,result2;
+	dJointGetUniversalAnchor(_joint,result1); 
+	dJointGetUniversalAnchor2(_joint,result2); 
+	_anchor_error.x = (Real)(result1[0] - result2[0]);
+	_anchor_error.y = (Real)(result1[1] - result2[1]);
+	_anchor_error.z = (Real)(result1[2] - result2[2]);
+	return _anchor_error;
+}
+
+void UniversalJoint::setAxis(const Ogre::Vector3& axis)
+{
+	dJointSetUniversalAxis1(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& UniversalJoint::getAxis()
+{
+	dVector3 result;
+	dJointGetUniversalAxis1(_joint,result); 
+	_axis.x = (Real)result[0];
+	_axis.y = (Real)result[1];
+	_axis.z = (Real)result[2];
+	return _axis;
+}
+
+void UniversalJoint::setAdditionalAxis(const Ogre::Vector3& axis)
+{
+	dJointSetUniversalAxis2(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& UniversalJoint::getAdditionalAxis()
+{
+	dVector3 result;
+	dJointGetUniversalAxis2(_joint,result); 
+	_additional_axis.x = (Real)result[0];
+	_additional_axis.y = (Real)result[1];
+	_additional_axis.z = (Real)result[2];
+	return _additional_axis;
+}
+
+void UniversalJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetUniversalParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value); 
+}
+
+Real UniversalJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetUniversalParam(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+UniversalJoint::~UniversalJoint()
+{
+}
+
+FixedJoint::FixedJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreateFixed(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+void FixedJoint::attach(const Body* body)
+{
+	Joint::attach(body);
+	dJointSetFixed(_joint); 
+}
+
+void FixedJoint::attach(const Body* body_a,const Body* body_b)
+{
+	Joint::attach(body_a,body_b);
+	dJointSetFixed(_joint); 
+}
+
+FixedJoint::~FixedJoint()
+{
+}
+
+SuspensionJoint::SuspensionJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreateHinge2(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+void SuspensionJoint::setAnchor(const Ogre::Vector3& position)
+{
+	dJointSetHinge2Anchor(_joint,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+
+
+void SuspensionJoint::addTorque(Real torque,Real torque2,Real torque3)
+{
+	dJointAddHinge2Torques(_joint,(dReal)torque,(dReal)torque2);
+}
+
+const Ogre::Vector3& SuspensionJoint::getAnchor()
+{
+	dVector3 result;
+	dJointGetHinge2Anchor(_joint,result); 
+	_anchor.x = (Real)result[0];
+	_anchor.y = (Real)result[1];
+	_anchor.z = (Real)result[2];
+	return _anchor;
+}
+
+const Ogre::Vector3& SuspensionJoint::getAdditionalAnchor()
+{
+	dVector3 result;
+	dJointGetHinge2Anchor2(_joint,result);
+	_anchor2.x = (Real)result[0];
+	_anchor2.y = (Real)result[1];
+	_anchor2.z = (Real)result[2];
+	return _anchor2;
+}
+
+const Ogre::Vector3& SuspensionJoint::getAnchorError()
+{
+	dVector3 result1,result2;
+	dJointGetHinge2Anchor(_joint,result1); 
+	dJointGetHinge2Anchor2(_joint,result2); 
+	_anchor_error.x = (Real)(result1[0] - result2[0]);
+	_anchor_error.y = (Real)(result1[1] - result2[1]);
+	_anchor_error.z = (Real)(result1[2] - result2[2]);
+	return _anchor_error;
+}
+
+void SuspensionJoint::setAxis(const Ogre::Vector3& axis)
+{
+	dJointSetHinge2Axis1(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& SuspensionJoint::getAxis()
+{
+	dVector3 result;
+	dJointGetHinge2Axis1(_joint,result); 
+	_axis.x = (Real)result[0];
+	_axis.y = (Real)result[1];
+	_axis.z = (Real)result[2];
+	return _axis;
+}
+
+void SuspensionJoint::setAdditionalAxis(const Ogre::Vector3& axis)
+{
+	dJointSetHinge2Axis2(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& SuspensionJoint::getAdditionalAxis()
+{
+	dVector3 result;
+	dJointGetHinge2Axis2(_joint,result); 
+	_additional_axis.x = (Real)result[0];
+	_additional_axis.y = (Real)result[1];
+	_additional_axis.z = (Real)result[2];
+	return _additional_axis;
+}
+
+Real SuspensionJoint::getAngle()
+{
+	return (Real)dJointGetHinge2Angle1(_joint); 
+}
+
+Real SuspensionJoint::getAngleRate()
+{
+	return (Real)dJointGetHinge2Angle1Rate(_joint); 
+}
+
+Real SuspensionJoint::getPositionRate()
+{
+	return (Real)dJointGetHinge2Angle2Rate(_joint); 
+}
+
+void SuspensionJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetHinge2Param(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value); 
+}
+
+Real SuspensionJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetHinge2Param(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+SuspensionJoint::~SuspensionJoint()
+{
+}
+
+AngularMotorJoint::AngularMotorJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreateAMotor(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+void AngularMotorJoint::setMode(AngularMotorJoint::Mode mode)
+{
+	dJointSetAMotorMode(_joint,(int)mode); 
+}
+
+AngularMotorJoint::Mode AngularMotorJoint::getMode()
+{
+	return (AngularMotorJoint::Mode)dJointGetAMotorMode(_joint); 
+}
+
+void AngularMotorJoint::addTorque(Real torque,Real torque2,Real torque3)
+{
+	dJointAddAMotorTorques(_joint,(dReal)torque,(dReal)torque2,(dReal)torque3);
+}
+
+void AngularMotorJoint::setAxisCount(int axes)
+{
+	assert((axes >= 0) && (axes <= 3));
+	dJointSetAMotorNumAxes(_joint,axes); 
+}
+
+int AngularMotorJoint::getAxisCount()
+{
+	return dJointGetAMotorNumAxes(_joint); 
+}
+
+void AngularMotorJoint::setAxis(int axis_number,AngularMotorJoint::RelativeOrientation orientation,const Ogre::Vector3& axis)
+{
+	dJointSetAMotorAxis(_joint,axis_number,(int)orientation,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z); 
+}
+
+const Ogre::Vector3& AngularMotorJoint::getAxis(int axis_number)
+{
+	dVector3 result;
+	dJointGetAMotorAxis(_joint,axis_number,result); 
+	_axis.x = (Real)result[0];
+	_axis.y = (Real)result[1];
+	_axis.z = (Real)result[2];
+	return _axis;
+}
+
+AngularMotorJoint::RelativeOrientation AngularMotorJoint::getAxisRelativeOrientation(int axis_number)
+{
+	return (AngularMotorJoint::RelativeOrientation)dJointGetAMotorAxisRel(_joint,axis_number); 
+}
+
+void AngularMotorJoint::setAngle(int axis,Real angle)
+{
+	dJointSetAMotorAngle(_joint,axis,(dReal)angle); 
+}
+
+Real AngularMotorJoint::getAngle(int axis)
+{
+	return (Real)dJointGetAMotorAngle(_joint,axis); 
+}
+
+Real AngularMotorJoint::getAngleRate(int axis)
+{
+	return (Real)dJointGetAMotorAngleRate(_joint,axis); 
+}
+
+void AngularMotorJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetAMotorParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value); 
+}
+
+Real AngularMotorJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetAMotorParam(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+AngularMotorJoint::~AngularMotorJoint()
+{
+}
+
+PlanarJoint::PlanarJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreatePlane2D(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+void PlanarJoint::setParameterX(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetPlane2DXParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value);
+}
+
+void PlanarJoint::setParameterY(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetPlane2DYParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value);
+}
+
+void PlanarJoint::setParameterAngle(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetPlane2DAngleParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value);
+}
+
+PlanarJoint::~PlanarJoint()
+{
+}
+
+
+
+SliderHingeJoint::SliderHingeJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreatePR(getWorldID(),getJointGroupID(group)); 
+	registerJoint();
+}
+
+SliderHingeJoint::~SliderHingeJoint()
+{
+}
+
+void SliderHingeJoint::setAnchor(const Ogre::Vector3& position)
+{
+	dJointSetPRAnchor(_joint,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+
+const Ogre::Vector3& SliderHingeJoint::getAnchor()
+{
+	dVector3 result;
+	dJointGetPRAnchor(_joint,result); 
+	_anchor.x = (Real)result[0];
+	_anchor.y = (Real)result[1];
+	_anchor.z = (Real)result[2];
+	return _anchor;
+}
+
+
+Real SliderHingeJoint::getPosition()
+{
+	return (Real)dJointGetPRPosition(_joint); 
+}
+
+Real SliderHingeJoint::getPositionRate()
+{
+	return (Real)dJointGetPRPositionRate(_joint); 
+}
+
+void SliderHingeJoint::setAxis(const Ogre::Vector3& axis)
+{
+	dJointSetPRAxis1(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& SliderHingeJoint::getAxis()
+{
+	dVector3 result;
+	dJointGetPRAxis1(_joint,result); 
+	_axis.x = (Real)result[0];
+	_axis.y = (Real)result[1];
+	_axis.z = (Real)result[2];
+	return _axis;
+}
+
+void SliderHingeJoint::setAdditionalAxis(const Ogre::Vector3& axis)
+{
+	dJointSetPRAxis2(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& SliderHingeJoint::getAdditionalAxis()
+{
+	dVector3 result;
+	dJointGetPRAxis2(_joint,result); 
+	_additional_axis.x = (Real)result[0];
+	_additional_axis.y = (Real)result[1];
+	_additional_axis.z = (Real)result[2];
+	return _additional_axis;
+}
+
+void SliderHingeJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetPRParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value); 
+}
+
+Real SliderHingeJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetPRParam(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+void SliderHingeJoint::addTorque(Real torque,Real torque2,Real torque3)
+{
+	dJointAddPRTorque(_joint, (dReal)torque);
+}
+
+
+
+#if ODE_VERSION_MINOR > 9
+
+PistonJoint::PistonJoint(World *world, const JointGroup* group) : Joint(world, group)
+{
+	_joint = dJointCreatePiston(getWorldID(), getJointGroupID(group)); 
+	registerJoint();
+}
+
+void PistonJoint::setAnchor(const Ogre::Vector3& position)
+{
+	dJointSetPistonAnchor(_joint,(dReal)position.x,(dReal)position.y,(dReal)position.z); 
+}
+
+const Ogre::Vector3& PistonJoint::getAnchor()
+{
+	dVector3 result;
+	dJointGetPistonAnchor(_joint,result); 
+	_anchor.x = (Real)result[0];
+	_anchor.y = (Real)result[1];
+	_anchor.z = (Real)result[2];
+	return _anchor;
+}
+
+const Ogre::Vector3& PistonJoint::getAnchorError()
+{
+	dVector3 result1,result2;
+	dJointGetPistonAnchor(_joint,result1); 
+	dJointGetPistonAnchor2(_joint,result2); 
+	_anchor_error.x = (Real)(result1[0] - result2[0]);
+	_anchor_error.y = (Real)(result1[1] - result2[1]);
+	_anchor_error.z = (Real)(result1[2] - result2[2]);
+	return _anchor_error;
+}
+
+void PistonJoint::setAxis(const Ogre::Vector3& axis)
+{
+	dJointSetPistonAxis(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z);
+}
+
+const Ogre::Vector3& PistonJoint::getAxis()
+{
+	dVector3 result;
+	dJointGetPistonAxis(_joint,result); 
+	_axis.x = (Real)result[0];
+	_axis.y = (Real)result[1];
+	_axis.z = (Real)result[2];
+	return _axis;
+}
+
+void PistonJoint::setAxisDelta(const Ogre::Vector3& axis, const Ogre::Vector3& initalPosition)
+{
+	dJointSetPistonAxisDelta(_joint,(dReal)axis.x,(dReal)axis.y,(dReal)axis.z,
+		(dReal)initalPosition.x,(dReal)initalPosition.y,(dReal)initalPosition.z);
+}
+
+Real PistonJoint::getPosition()
+{
+	return (Real)dJointGetPistonPosition(_joint); 
+}
+
+Real PistonJoint::getPositionRate()
+{
+	return (Real)dJointGetPistonPositionRate(_joint); 
+}
+
+Real PistonJoint::getAngle()
+{
+	return (Real)dJointGetPistonAngle(_joint); 
+}
+
+Real PistonJoint::getAngleRate()
+{
+	return (Real)dJointGetPistonAngleRate(_joint); 
+}
+
+void PistonJoint::addForce(Real force,Real force2,Real force3)
+{
+	dJointAddPistonForce(_joint,(dReal)force);
+}
+
+void PistonJoint::setParameter(Joint::Parameter parameter,Real value,int axis)
+{
+	dJointSetPistonParam(_joint,((int)parameter) + dParamGroup * (axis - 1),(dReal)value);  
+}
+
+Real PistonJoint::getParameter(Joint::Parameter parameter,int axis)
+{
+	return (Real)dJointGetPistonParam(_joint,((int)parameter) + dParamGroup * (axis - 1));
+}
+
+#endif /* ODE_VERSION_MINOR > 9 */
Index: /code/branches/physics/src/ogreode/OgreOdeJoint.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeJoint.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeJoint.h	(revision 2122)
@@ -0,0 +1,382 @@
+#ifndef _OGREODEJOINT_H_
+#define _OGREODEJOINT_H_
+
+#include "OgreOdePreReqs.h"
+#include <OgreVector3.h>
+
+namespace OgreOde 
+{
+	class _OgreOdeExport JointGroup
+	{
+		friend class World;
+		friend class Joint;
+
+	public:
+        JointGroup(World *world);
+		virtual ~JointGroup();
+
+		void empty();
+
+		virtual size_t getID();
+
+	protected:
+		dJointGroupID getJointGroupID() const;
+
+	protected:
+        dJointGroupID _joint_group;
+        World *_world;
+	};
+
+	class _OgreOdeExport Joint
+    {
+		friend class World;
+
+	public:
+		enum Type
+		{
+			Type_BallJoint					= dJointTypeBall,
+			Type_HingeJoint					= dJointTypeHinge,
+			Type_SliderJoint				= dJointTypeSlider,
+			Type_UniversalJoint				= dJointTypeUniversal,
+			Type_Suspension_Joint			= dJointTypeHinge2,
+			Type_FixedJoint					= dJointTypeFixed,
+			Type_AngularMotorJoint			= dJointTypeAMotor,
+			Type_PlanarJoint				= dJointTypePlane2D,
+#if ODE_VERSION_MINOR > 9
+			Type_SliderHingeJoint			= dJointTypePR,
+			Type_SliderUniversalJoint		= dJointTypePU,
+			Type_PistonJoint				= dJointTypePiston
+#else
+			Type_SliderHingeJoint			= dJointTypePR
+#endif
+		};
+
+		enum Parameter
+		{
+			Parameter_LowStop				= dParamLoStop,
+			Parameter_HighStop				= dParamHiStop,
+			Parameter_MotorVelocity			= dParamVel,
+			Parameter_MaximumForce			= dParamFMax,
+			Parameter_FudgeFactor			= dParamFudgeFactor,
+			Parameter_Bounceyness			= dParamBounce,
+			Parameter_CFM					= dParamCFM,
+			Parameter_ERP					= dParamERP,
+			Parameter_StopERP				= dParamStopERP,
+			Parameter_StopCFM				= dParamStopCFM,
+			Parameter_SuspensionERP			= dParamSuspensionERP, // SuspensionJoint
+			Parameter_SuspensionCFM			= dParamSuspensionCFM  // SuspensionJoint
+		};
+
+	public:
+		Joint(World *world, const JointGroup* group = 0);
+		virtual ~Joint();
+
+		Joint::Type getType(); 
+
+		void registerJoint();
+
+		void detach();
+		virtual void attach(const Body* body);
+		virtual void attach(const Body* body_a,const Body* body_b); 
+
+		Body* getFirstBody(); 
+		Body* getSecondBody(); 
+		
+		static bool areConnected(const Body* body_a,const Body* body_b); 
+		static bool areConnectedExcluding(const Body* body_a,const Body* body_b,Joint::Type joint_type); 
+	
+		void enableFeedback(); 
+		void disableFeedback(); 
+		const Ogre::Vector3& getFirstForce();
+		const Ogre::Vector3& getFirstTorque();
+		const Ogre::Vector3& getSecondForce();
+		const Ogre::Vector3& getSecondTorque();
+
+		virtual void setAnchor(const Ogre::Vector3& position);
+		virtual const Ogre::Vector3& getAnchor();
+		virtual const Ogre::Vector3& getAnchorError();
+		virtual void setAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAxis();
+		virtual void setAdditionalAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAdditionalAxis();
+		virtual Ogre::Real getAngle();
+		virtual Ogre::Real getAngleRate();
+		virtual Ogre::Real getPosition();
+		virtual Ogre::Real getPositionRate();
+
+		virtual void setParameter(Joint::Parameter parameter,Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+
+		virtual size_t getID();
+
+		virtual void addTorque(Ogre::Real torque, Ogre::Real torque2 = 0.0, Ogre::Real torque3 = 0.0);
+		virtual void addForce(Ogre::Real force, Ogre::Real force2 = 0.0, Ogre::Real force3 = 0.0);
+
+	protected:
+		dJointID getJointID();
+
+		dWorldID getWorldID();
+		dJointGroupID getJointGroupID(const JointGroup* group) const;
+
+	protected:
+		dJointID _joint;
+		dJointFeedback _feedback;
+		Ogre::Vector3 _axis,_anchor,_anchor_error,_additional_axis;
+        Ogre::Vector3 _first_force,_first_torque,_second_force,_second_torque;
+        World *_world;
+	};
+
+	class _OgreOdeExport BallJoint:public Joint
+	{
+	public:
+		BallJoint(World *world, const JointGroup* group = 0);
+		~BallJoint();
+
+		virtual void setAnchor(const Ogre::Vector3& position);
+		virtual const Ogre::Vector3& getAnchor();
+		virtual const Ogre::Vector3& getAnchorError();
+		
+		// as of ode-0.9 can set Parameter_CFM and Parameter_ERP to make the joint springy, an axis value isn't needed
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+	};
+
+	class _OgreOdeExport HingeJoint:public Joint
+	{
+	public:
+		HingeJoint(World *world, const JointGroup* group = 0);
+		~HingeJoint();
+
+		virtual void setAnchor(const Ogre::Vector3& position);
+		virtual const Ogre::Vector3& getAnchor();
+		virtual const Ogre::Vector3& getAnchorError();
+		virtual void setAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAxis();
+		virtual Ogre::Real getAngle();
+		virtual Ogre::Real getAngleRate();
+
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+
+		virtual void addTorque(Ogre::Real torque, Ogre::Real torque2 = 0.0, Ogre::Real torque3 = 0.0);
+	};
+
+	class _OgreOdeExport SliderJoint:public Joint
+	{
+	public:
+		SliderJoint(World *world, const JointGroup* group = 0);
+		~SliderJoint();
+
+		virtual void setAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAxis();
+		virtual Ogre::Real getPosition();
+		virtual Ogre::Real getPositionRate();
+
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter, int axis = 1);
+
+		virtual void addForce(Ogre::Real force, Ogre::Real force2 = 0.0, Ogre::Real force3 = 0.0);
+	};
+
+	class _OgreOdeExport UniversalJoint:public Joint
+	{
+	public:
+		UniversalJoint(World *world, const JointGroup* group = 0);
+		~UniversalJoint();
+
+		virtual void setAnchor(const Ogre::Vector3& position);
+		virtual const Ogre::Vector3& getAnchor();
+		virtual const Ogre::Vector3& getAnchorError();
+		virtual void setAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAxis();
+		virtual void setAdditionalAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAdditionalAxis();
+
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value, int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+
+		virtual void addTorque(Ogre::Real torque, Ogre::Real torque2 = 0.0, Ogre::Real torque3 = 0.0);
+	};
+
+	class _OgreOdeExport FixedJoint:public Joint
+	{
+	public:
+		FixedJoint(World *world, const JointGroup* group = 0);
+		~FixedJoint();
+
+		virtual void attach(const Body* body);
+		virtual void attach(const Body* body_a,const Body* body_b); 
+	};
+
+	class _OgreOdeExport SuspensionJoint:public Joint
+	{
+	public:
+		SuspensionJoint(World *world, const JointGroup* group = 0);
+		~SuspensionJoint();
+
+		virtual void setAnchor(const Ogre::Vector3& position);
+		virtual const Ogre::Vector3& getAnchor();
+		virtual const Ogre::Vector3& getAdditionalAnchor();
+		virtual const Ogre::Vector3& getAnchorError();
+		virtual void setAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAxis();
+		virtual void setAdditionalAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAdditionalAxis();
+		virtual Ogre::Real getAngle();
+		virtual Ogre::Real getAngleRate();
+		virtual Ogre::Real getPositionRate();
+
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+
+		virtual void addTorque(Ogre::Real torque, Ogre::Real torque2 = 0.0, Ogre::Real torque3 = 0.0);
+
+	protected:
+		Ogre::Vector3 _anchor2;
+	};
+
+	class _OgreOdeExport AngularMotorJoint:public Joint
+	{
+	public:
+		enum Mode
+		{
+			Mode_UserAngularMotor	= dAMotorUser,
+			Mode_EulerAngularMotor	= dAMotorEuler 
+		};
+
+		enum RelativeOrientation
+		{
+			RelativeOrientation_GlobalFrame = 0,
+			RelativeOrientation_FirstBody	= 1,		
+			RelativeOrientation_SecondBody	= 2
+		};
+
+	public:
+		AngularMotorJoint(World *world, const JointGroup* group = 0);
+		~AngularMotorJoint();
+
+		void setMode(AngularMotorJoint::Mode mode);
+		AngularMotorJoint::Mode getMode(); 
+
+		void setAxisCount(int axes);
+		int getAxisCount(); 
+
+		void setAxis(int axis_number,AngularMotorJoint::RelativeOrientation orientation,const Ogre::Vector3& axis);
+		const Ogre::Vector3& getAxis(int axis_number);
+		AngularMotorJoint::RelativeOrientation getAxisRelativeOrientation(int axis_number); 
+
+		void setAngle(int axis, Ogre::Real angle); 
+		Ogre::Real getAngle(int axis); 
+		Ogre::Real getAngleRate(int axis); 
+
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+
+		virtual void addTorque(Ogre::Real torque, Ogre::Real torque2 = 0.0, Ogre::Real torque3 = 0.0);
+	};
+
+	/** Planar joints are for 2D physics in the x, y plane wth z=0
+	*/
+	class _OgreOdeExport PlanarJoint:public Joint
+	{
+	public:
+		PlanarJoint(World *world, const JointGroup* group = 0);
+		~PlanarJoint();
+
+		virtual void setParameterX(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual void setParameterY(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual void setParameterAngle(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+	};
+	
+	
+	/** A prismatic and rotoide joint (ODE_API JointPR) combines a Slider (prismatic) and a Hinge (rotoide). 
+		It can be used to decrease the number of bodies in a simulation. 
+		Usually you cannot attach 2 ODE joints together they need a body in between. 
+		An example of use of this type of joint can be in the creation of a hydraulic piston.
+		
+		The 2 axies must not be parallel. Since this is a new joint only when the 2 joint are at 
+		90deg of each other was fully tested.
+	*/
+	class _OgreOdeExport SliderHingeJoint:public Joint
+	{
+	public:
+		SliderHingeJoint(World *world, const JointGroup* group = 0);
+		~SliderHingeJoint();
+		
+		virtual void setAnchor(const Ogre::Vector3& position);
+		virtual const Ogre::Vector3& getAnchor();
+		
+		// Equivalent to getting the Slider's extension
+		virtual Ogre::Real getPosition();
+		virtual Ogre::Real getPositionRate();
+		
+		// Set the axis for the Slider articulation
+		virtual void setAxis(const Ogre::Vector3& axis);
+		// Get the axis for the Slider articulation
+		virtual const Ogre::Vector3& getAxis();
+		// Set the axis for the Hinge articulation. 
+		virtual void setAdditionalAxis(const Ogre::Vector3& axis);
+		// Get the axis for the Hinge articulation
+		virtual const Ogre::Vector3& getAdditionalAxis();
+		
+		// Set joint parameter axis = 3 for Hinge
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+		
+		// Applies the torque about the Hinge axis of the joint 
+		virtual void addTorque(Ogre::Real torque, Ogre::Real torque2 = 0.0, Ogre::Real torque3 = 0.0);
+	};
+	
+	
+#if ODE_VERSION_MINOR > 9
+
+	/** "A piston joint is similar to a Slider joint except that rotation around the translation axis is possible."
+	*/
+	class _OgreOdeExport PistonJoint : public Joint
+	{
+	public:
+		PistonJoint(World *world, const JointGroup* group = 0);
+		
+		// "The joint will try to keep the distance of this point fixed with respect to body2. 
+		// The input is specified in world coordinates. 
+		// If there is no body attached to the joint this function has not effect."
+		virtual void setAnchor(const Ogre::Vector3& position);
+		virtual const Ogre::Vector3& getAnchor();
+		virtual const Ogre::Vector3& getAnchorError();
+		
+		virtual void setAxis(const Ogre::Vector3& axis);
+		virtual const Ogre::Vector3& getAxis();
+		// "This function set prismatic axis of the joint and also set the position of the joint."
+		virtual void setAxisDelta(const Ogre::Vector3& axis, const Ogre::Vector3& initalPosition);
+		
+		// "Get the piston linear position.
+		// When the anchor is set, the current position of body1 and the anchor is examined and that 
+		// position will be the zero position"		
+		virtual Ogre::Real getPosition();
+		virtual Ogre::Real getPositionRate();
+		
+		// "Get the angle and the time derivative of this value. 
+		// The angle is measured between the two bodies, or between the body and the static environment. 
+		// The angle will be between -pi..pi. 
+		// The only possible axis of rotation is the one defined by the dJointSetPistonAxis.
+		// When the piston anchor or axis is set, the current position of the attached bodies is examined 
+		// and that position will be the zero angle."
+		virtual Ogre::Real getAngle();
+		virtual Ogre::Real getAngleRate();
+		
+		// "This function create a force inside the piston and this force will be applied on the 2 bodies.
+		// Then	force is apply to the center of mass of each body and the orientation of the force vector is 
+		// along the axis of the piston"
+		// One axis so only the first force is used
+		virtual void addForce(Ogre::Real force, Ogre::Real force2 = 0.0, Ogre::Real force3 = 0.0);
+		
+		// Set joint parameter
+		virtual void setParameter(Joint::Parameter parameter, Ogre::Real value,int axis = 1);
+		virtual Ogre::Real getParameter(Joint::Parameter parameter,int axis = 1);
+	};
+
+#endif /* ODE_VERSION_MINOR > 9 */
+
+}
+
+#endif 
Index: /code/branches/physics/src/ogreode/OgreOdeMaintainedList.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeMaintainedList.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeMaintainedList.h	(revision 2122)
@@ -0,0 +1,191 @@
+/*!
+ * <File comment goes here!!>
+ * 
+ * Copyright (c) 2005 by <your name/ organization here>
+ */
+#ifndef _OGREODEMAINTAINEDLIST_H_
+#define _OGREODEMAINTAINEDLIST_H_
+
+#include "OgreOdePreReqs.h"
+
+/*!
+ * \brief
+ * Write brief comment for OgreOde here.
+ * 
+ * Write detailed description for OgreOde here.
+ * 
+ * \remarks
+ * Write remarks for OgreOde here.
+ * 
+ * \see
+ * Separate items with the '|' character.
+ */
+namespace OgreOde
+{
+
+	/** Convenience class to make it easy to step through all MaintainedItem in a MaintainedList.
+	*/
+	template <class T>
+	class _OgreOdeExport MaintainedItemIterator
+	{
+
+	public:
+		typedef std::deque<T*> MaintainedItemList;
+		typedef std::map<size_t,T*> MaintainedItemMap;
+
+
+	protected:
+		typename MaintainedItemList::iterator mPos;
+		typename MaintainedItemList::iterator mStart;
+		typename MaintainedItemList::iterator mEnd;
+
+
+	public:
+		/// constructor, only available for MaintainedList::getIterator
+		MaintainedItemIterator(typename MaintainedItemList::iterator start, typename MaintainedItemList::iterator end)
+		{
+			mStart = mPos = start;
+			mEnd = end;
+		}
+		// Returns true when at the end of the MaintainedItem list
+		inline bool end(void) const 
+		{
+			return (mPos == mEnd);
+		}
+		/** Returns a pointer to the next MaintainedItem, and moves the iterator on by 1 element. */
+		inline T* getNext(void)
+		{
+			return static_cast<T*>(*mPos++);
+		}
+	};
+
+	template <class T>
+	class _OgreOdeExport MaintainedList
+	{
+	public:
+		typedef std::deque<T*>				MaintainedItemList;
+		typedef std::map<size_t,T*>	MaintainedItemMap;
+
+	public:
+		MaintainedList(){};
+		~MaintainedList(){};
+
+		void registerItem(T* ptr)	
+		{
+			assert(ptr->getID());
+			_map[ptr->getID()] = ptr;
+			_list.push_back (ptr);
+		}
+
+		T* findItem(size_t id)
+		{
+			assert (_map.find(id) != _map.end());
+			return _map[id];
+		}
+
+		void unregisterItem(size_t id)
+		{
+			assert (_map.find(id) != _map.end());
+			T* m = _map[id];
+			_map.erase(id);
+
+			typename MaintainedItemList::iterator i = std::find(_list.begin (), 
+				_list.end (), 
+				m);
+			if(i != _list.end())
+			{
+				assert(*i == m);
+				_list.erase(i);
+			}
+		}
+
+		void setDebug(const bool debug)
+		{
+			typename MaintainedItemList::iterator i = _list.begin();
+			typename MaintainedItemList::iterator end = _list.end();
+			for(;i != end;++i)
+			{
+				(*i)->setDebug(debug);
+			}
+        }
+
+        void setDebugContact(const bool debug)
+        {
+            typename MaintainedItemList::iterator i = _list.begin();
+            typename MaintainedItemList::iterator end = _list.end();
+            for(;i != end;++i)
+            {
+                (*i)->setDebugContact(debug);
+            }
+        }
+
+        void updateDebugContact()
+        {
+            std::for_each(_list.begin (), 
+                _list.end (),  
+                std::mem_fun(&T::updateDebugContact));
+        }
+
+
+
+		void synchronise()
+		{
+			std::for_each(_list.begin (), 
+				_list.end (),  
+				std::mem_fun(&T::synchronise));
+		}
+
+		void updateDrawState()
+		{
+			std::for_each(_list.begin (), 
+				_list.end (),  
+				std::mem_fun(&T::updateDrawState));
+		}
+		void updatePreviousState()
+		{
+			std::for_each(_list.begin (), 
+				_list.end (),  
+				std::mem_fun(&T::updatePreviousState));
+		}
+
+		void updateCurrentState()
+		{
+			std::for_each(_list.begin (), 
+				_list.end (),  
+				std::mem_fun(&T::updateCurrentState));
+		}
+
+		void interpolateDrawState(const Ogre::Real alpha)
+		{
+			typename MaintainedItemList::iterator i = _list.begin();
+			typename MaintainedItemList::iterator end = _list.end();
+			for(;i != end;++i)
+			{
+				(*i)->interpolateDrawState(alpha);
+			}
+		}
+
+		void notify(Body* body)
+		{
+			typename MaintainedItemList::iterator i = _list.begin();
+			typename MaintainedItemList::iterator end = _list.end();
+			for(;i != end;++i)
+			{
+				(*i)->notify(body);
+			}
+		}
+
+		MaintainedItemIterator<T> getIterator(void)
+		{
+			return MaintainedItemIterator<T>(_list.begin(), _list.end());
+		}
+
+	protected:
+
+		MaintainedItemMap  _map;
+		MaintainedItemList _list;
+	};
+
+}
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOdeMass.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeMass.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeMass.cpp	(revision 2122)
@@ -0,0 +1,177 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeMass.h"
+
+#include <OgreMatrix3.h>
+#include <OgreVector3.h>
+#include <OgreQuaternion.h>
+
+using namespace OgreOde;
+using namespace Ogre;
+
+Mass::Mass()
+{
+	dMassSetZero(&_mass); 
+}
+
+Mass::Mass(Real mass,const Ogre::Vector3& center_of_gravity,const Matrix3& intertia_matrix)
+{
+	dMassSetParameters
+	(
+		&_mass,
+		(dReal)mass,
+		(dReal)center_of_gravity.x,(dReal)center_of_gravity.y,(dReal)center_of_gravity.z,
+		(dReal)intertia_matrix[0][0],(dReal)intertia_matrix[1][1],(dReal)intertia_matrix[2][2],
+		(dReal)intertia_matrix[0][1],(dReal)intertia_matrix[0][2],(dReal)intertia_matrix[1][2]
+	); 
+}
+
+Mass::~Mass()
+{
+}
+
+void Mass::adjust(Real mass)
+{
+	dMassAdjust(&_mass,(dReal)mass); 
+}
+
+void Mass::translate(const Ogre::Vector3& offset)
+{
+	dMassTranslate(&_mass,offset.x,offset.y,offset.z); 
+}
+
+void Mass::rotate(const Ogre::Quaternion& orientation)
+{
+	Matrix3 m;
+	orientation.ToRotationMatrix(m);
+	dMatrix3 r;
+
+	r[0] = m[0][0];
+	r[1] = m[0][1];
+	r[2] = m[0][2];
+
+	r[3] = m[1][0];
+	r[4] = m[1][1];
+	r[5] = m[1][2];
+
+	r[6] = m[2][0];
+	r[7] = m[2][1];
+	r[8] = m[2][2];
+
+	r[9] = 0.0;
+	r[10] = 0.0;
+	r[11] = 0.0;
+
+	dMassRotate(&_mass,r); 
+}
+
+Ogre::Real Mass::getMassValue() const
+{
+	return _mass.mass;
+}
+
+Ogre::Vector3 Mass::getCenterOfGravity() const
+{
+	// not sure why its a dVector4 in dMass and not a dVector3
+	// and I think ode requires the center of mass to be the bodies position so this 
+	// would always return Vector3::ZERO
+	return Vector3(_mass.c[0], _mass.c[1], _mass.c[2]);
+}
+
+
+
+Ogre::Matrix3 Mass::getLocalInertiaTensor() const
+{
+	return Ogre::Matrix3(   
+		_mass.I[0], _mass.I[1], _mass.I[2],
+		_mass.I[4], _mass.I[5], _mass.I[6],
+		_mass.I[8], _mass.I[9], _mass.I[10]);
+}
+void Mass::add(const Mass& other)
+{
+	dMassAdd(&_mass,&(other._mass)); 
+}
+
+const dMass* Mass::getMassPtr() const
+{
+	return &_mass;
+}
+
+SphereMass::SphereMass():Mass()
+{
+}
+
+SphereMass::SphereMass(Real mass,Real radius)
+{
+	dMassSetSphereTotal(&_mass,(dReal)mass,(dReal)radius); 
+}
+
+SphereMass::~SphereMass()
+{
+}
+
+void SphereMass::setDensity(Real density,Real radius)
+{
+	dMassSetSphere(&_mass,(dReal)density,(dReal)radius); 
+}
+
+CapsuleMass::CapsuleMass():Mass()
+{
+}
+
+CapsuleMass::CapsuleMass(Real mass,Real radius,const Ogre::Vector3& direction,Real length)
+{
+	int dir = (direction == Ogre::Vector3::UNIT_X)?1:(direction == Ogre::Vector3::UNIT_Y)?2:(direction == Ogre::Vector3::UNIT_Z)?3:0;
+	assert(dir);
+	dMassSetCappedCylinderTotal(&_mass,(dReal)mass,dir,(dReal)radius,(dReal)length); 
+}
+
+CapsuleMass::~CapsuleMass()
+{
+}
+
+void CapsuleMass::setDensity(Real density,Real radius,const Ogre::Vector3& direction,Real length)
+{
+	int dir = (direction == Ogre::Vector3::UNIT_X)?1:(direction == Ogre::Vector3::UNIT_Y)?2:(direction == Ogre::Vector3::UNIT_Z)?3:0;
+	assert(dir && "Invalid direction specified for CapsuleMass");
+	dMassSetCappedCylinder(&_mass,(dReal)density,dir,(dReal)radius,(dReal)length); 
+}
+
+CylinderMass::CylinderMass():Mass()
+{
+}
+
+CylinderMass::CylinderMass(Real mass,const Ogre::Vector3& direction,Real radius,Real length)
+{
+	int dir = (direction == Ogre::Vector3::UNIT_X)?1:(direction == Ogre::Vector3::UNIT_Y)?2:(direction == Ogre::Vector3::UNIT_Z)?3:0;
+	assert(dir);
+	dMassSetCylinderTotal(&_mass,(dReal)mass,dir,(dReal)radius,(dReal)length); 
+}
+
+CylinderMass::~CylinderMass()
+{
+}
+
+void CylinderMass::setDensity(Real density,const Ogre::Vector3& direction,Real radius,Real length)
+{
+	int dir = (direction == Ogre::Vector3::UNIT_X)?1:(direction == Ogre::Vector3::UNIT_Y)?2:(direction == Ogre::Vector3::UNIT_Z)?3:0;
+	assert(dir);
+	dMassSetCylinder(&_mass,(dReal)density,dir,(dReal)radius,(dReal)length); 
+}
+
+BoxMass::BoxMass():Mass()
+{
+}
+
+BoxMass::BoxMass(Real mass,const Ogre::Vector3& size)
+{
+	dMassSetBoxTotal(&_mass,(dReal)mass,(dReal)size.x,(dReal)size.y,(dReal)size.z);
+}
+
+BoxMass::~BoxMass()
+{
+}
+
+void BoxMass::setDensity(Real density,const Ogre::Vector3& size)
+{
+	dMassSetBox(&_mass,(dReal)density,(dReal)size.x,(dReal)size.y,(dReal)size.z); 
+}
Index: /code/branches/physics/src/ogreode/OgreOdeMass.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeMass.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeMass.h	(revision 2122)
@@ -0,0 +1,96 @@
+#ifndef _OGREODEMASS_H_
+#define _OGREODEMASS_H_
+
+#include "OgreOdePreReqs.h"
+
+namespace OgreOde 
+{
+	class _OgreOdeExport Mass
+	{
+		friend class Body;
+
+	public:
+		Mass();
+        Mass(Ogre::Real mass, const Ogre::Vector3& center_of_gravity, const Ogre::Matrix3& intertia_matrix); 
+		virtual ~Mass();
+
+		inline Mass(const Mass& other)
+		{
+			memcpy(&_mass,&(other._mass),sizeof(_mass));
+		}
+
+		inline Mass& operator=(const Mass& other)
+		{
+			memcpy(&_mass,&(other._mass),sizeof(_mass));
+			return *this;
+		}
+
+		inline Mass& operator=(const dMass* other)
+		{
+			assert(other);
+			memcpy(&_mass,other,sizeof(_mass));
+			return *this;
+		}
+
+		void adjust(Ogre::Real mass); 
+		void translate(const Ogre::Vector3& offset); 
+		void rotate(const Ogre::Quaternion& orientation); 
+		void add(const Mass& other); 
+		
+		// total mass of the rigid body
+		Ogre::Real getMassValue() const;
+		// center of gravity position in body frame (x,y,z)
+		Ogre::Vector3 getCenterOfGravity() const;
+		// 3x3 inertia tensor in body frame, about POR
+		Ogre::Matrix3 getLocalInertiaTensor() const; 
+
+	protected:
+		const dMass* getMassPtr() const;
+		dMass _mass;
+	};
+
+	class _OgreOdeExport SphereMass:public Mass
+	{
+	public:
+		SphereMass();
+		SphereMass(Ogre::Real mass, Ogre::Real radius);
+		~SphereMass();
+
+		void setDensity(Ogre::Real density, Ogre::Real radius);
+	};
+	
+	// To add
+	// void dMassSetTrimesh(dMass *, dReal density, dGeomID g)
+
+	class _OgreOdeExport CapsuleMass:public Mass
+	{
+	public:
+		CapsuleMass();
+		CapsuleMass(Ogre::Real mass, Ogre::Real radius,const Ogre::Vector3& direction, Ogre::Real length);
+		~CapsuleMass();
+
+		void setDensity(Ogre::Real density, Ogre::Real radius,const Ogre::Vector3& direction, Ogre::Real length);
+	};
+
+	class _OgreOdeExport CylinderMass:public Mass
+	{
+	public:
+		CylinderMass();
+		CylinderMass(Ogre::Real mass,const Ogre::Vector3& direction, Ogre::Real radius, Ogre::Real length);
+		~CylinderMass();
+
+		void setDensity(Ogre::Real density,const Ogre::Vector3& direction, Ogre::Real radius, Ogre::Real length);
+	};
+
+	class _OgreOdeExport BoxMass:public Mass
+	{
+	public:
+		BoxMass();
+		BoxMass(Ogre::Real mass,const Ogre::Vector3& size);
+		~BoxMass();
+
+		void setDensity(Ogre::Real density,const Ogre::Vector3& size);
+	};
+}
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOdePreReqs.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdePreReqs.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdePreReqs.h	(revision 2122)
@@ -0,0 +1,125 @@
+#ifndef _OGREODEPREREQS_H_
+#define _OGREODEPREREQS_H_
+
+// we have to include the entire ode.h because the config file can either be
+// config.h or odeconfig.h and it takes these files to determine the version
+// in the first place.
+#include "ode/ode.h"
+#include <OgrePrerequisites.h>
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+#   if defined( OGREODE_EXPORTS )
+#       define _OgreOdeExport __declspec( dllexport )
+#   else
+#       if defined( __MINGW32__ )
+#           define _OgreOdeExport
+#       else
+#           define _OgreOdeExport __declspec(dllimport)
+#       endif
+#   endif
+#elif defined ( OGRE_GCC_VISIBILITY )
+#   define _OgreOdeExport  __attribute__ ((visibility("default")))
+#else
+#   define _OgreOdeExport
+#endif
+
+// determine ODE version. In 0.10 and following, ODE uses odeconfig.h in the headers and
+// out-"sourced" config.h to hide it from the include folder. So there is a new macro for the
+// header: ODECONFIG_H instead of _ODE_CONFIG_H_
+#ifdef ODECONFIG_H
+#  define ODE_VERSION_MINOR 10 // or larger
+#else
+#  define ODE_VERSION_MINOR 9 // or smaller
+#endif
+
+
+namespace OgreOde 
+{
+#if ODE_VERSION_MINOR < 10
+#  ifndef dTriIndex
+#    if dTRIMESH_16BIT_INDICES
+#      if dTRIMESH_GIMPACT
+
+    typedef uint32 dTriIndex;
+
+#      else // dTRIMESH_GIMPACT
+
+    typedef uint16 dTriIndex;
+
+#      endif // dTRIMESH_GIMPACT
+#    else // dTRIMESH_16BIT_INDICES
+
+    typedef int dTriIndex;
+
+#    endif // dTRIMESH_16BIT_INDICES
+#  endif
+#endif
+
+	typedef dTriIndex TriangleIndex;
+
+
+	class World;
+	class Space;
+
+	class Body;
+	class Mass;
+
+	class JointGroup;
+	class Joint;
+
+    class Geometry;
+    typedef std::list<Geometry*>   GeometryList;
+    typedef std::vector<Geometry*> GeometryArray;
+
+    class RayGeometry;
+    class CylinderGeometry;
+    class SphereGeometry;
+    class InfinitePlaneGeometry;
+    class TransformGeometry;
+	
+	class TriangleMeshData;
+	class TriangleMeshDataPtr;
+	class TriangleMeshGeometry;
+	class BoxGeometry;
+    class CapsuleGeometry;
+
+
+	class Contact;
+
+    class StepListener;
+
+    class StepHandler;
+    class BasicStepper;
+    class QuickStepper;
+    class FastStepper;
+
+    class StepMode;
+    class BasicStepMode;
+    class QuickStepMode;
+    class FastStepMode;
+
+
+
+	class CollisionListener;
+	class CollisionCallback;
+	class MaintainedItem;
+
+
+	class EntityInformer;
+    typedef std::vector<Ogre::Vector3> Vector3Array;
+	typedef std::map<unsigned char,Vector3Array* > BoneMapping;
+	typedef std::pair<unsigned short,Vector3Array* > BoneMappingKey;
+
+	typedef size_t MaterialID;
+	typedef std::map<MaterialID,Contact*> MaterialMap;
+    typedef std::pair<MaterialID,MaterialMap* > MaterialMapPair;
+
+    class DebugObject;
+    class DebugContact;
+    class DebugContactText;
+    class DebugNormal;
+}
+
+
+#endif
+
Index: /code/branches/physics/src/ogreode/OgreOdePrecompiledHeaders.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdePrecompiledHeaders.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdePrecompiledHeaders.cpp	(revision 2122)
@@ -0,0 +1,1 @@
+#include "OgreOdePrecompiledHeaders.h"
Index: /code/branches/physics/src/ogreode/OgreOdePrecompiledHeaders.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdePrecompiledHeaders.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdePrecompiledHeaders.h	(revision 2122)
@@ -0,0 +1,54 @@
+#ifndef __OgreOdePrecompiledHeaders_
+#define __OgreOdePrecompiledHeaders_
+ 
+#ifdef _PRECOMP
+
+// external headers
+#include <ode/ode.h>
+
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreSceneNode.h>
+#include <OgreRoot.h>
+#include <OgreSceneManager.h>
+#include <OgreEntity.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreRoot.h>
+#include <OgreSceneNode.h>
+#include <OgreAxisAlignedBox.h>
+#include <OgreCamera.h>
+#include <OgreMovableObject.h>
+#include <OgreSceneQuery.h>
+#include <OgreStringConverter.h>
+#include <OgreUserDefinedObject.h>
+#include <OgreRenderable.h>
+#include <OgreSimpleRenderable.h>
+#include <OgreMesh.h>
+#include <OgreFrameListener.h>
+
+// our own headers
+#include "OgreOdePreReqs.h"
+
+#include "OgreOdeBody.h"
+#include "OgreOdeCollision.h"
+#include "OgreOdeDebugContact.h"
+#include "OgreOdeDebugObject.h"
+#include "OgreOdeEigenSolver.h"
+#include "OgreOdeEntityInformer.h"
+#include "OgreOdeGeometry.h"
+#include "OgreOdeJoint.h"
+#include "OgreOdeMaintainedList.h"
+#include "OgreOdeMass.h" 
+#include "OgreOdeSpace.h"
+#include "OgreOdeStepper.h"
+#include "OgreOdeUtility.h"
+#include "OgreOdeTriangleMeshData.h"
+#include "OgreOdeTriangleMeshDataManager.h"
+#include "OgreOdeUtility.h"
+#include "OgreOdeWorld.h"
+
+#endif //_PRECOMP
+#endif //__OgreOdePrecompiledHeaders_
Index: /code/branches/physics/src/ogreode/OgreOdeSpace.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeSpace.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeSpace.cpp	(revision 2122)
@@ -0,0 +1,372 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeSpace.h"
+
+#include <OgreSceneManager.h>
+
+#include "OgreOdeBody.h"
+#include "OgreOdeGeometry.h"
+#include "OgreOdeWorld.h"
+#include "OgreOdeCollision.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+Space::Space(World *world, const Space* space) :
+    _internal_collisions (true),
+    _world(world)
+{
+}
+//------------------------------------------------------------------------------------------------
+#if ODE_VERSION_MINOR > 9
+Space::Class Space::getClass()
+{
+	return (Space::Class)(dSpaceGetClass(_space));
+}
+#endif
+//------------------------------------------------------------------------------------------------
+dSpaceID Space::getSpaceID() const
+{
+	return _space;
+}
+//------------------------------------------------------------------------------------------------
+dSpaceID Space::getSpaceID(const Space* space) const
+{
+	if(space) 
+        return space->getSpaceID();
+	return 0;
+}
+//------------------------------------------------------------------------------------------------
+void Space::setAutoCleanup(bool on)
+{
+	dSpaceSetCleanup(_space,(on)?1:0);
+}
+//------------------------------------------------------------------------------------------------
+bool Space::getAutoCleanup()
+{
+	return ((dSpaceGetCleanup(_space))?true:false); 
+}
+//------------------------------------------------------------------------------------------------
+void Space::addGeometry(const Geometry& geometry)
+{
+	dSpaceAdd(_space,geometry.getGeometryID()); 
+}
+//------------------------------------------------------------------------------------------------
+void Space::removeGeometry(const Geometry& geometry)
+{
+	dSpaceRemove(_space,geometry.getGeometryID()); 
+}
+//------------------------------------------------------------------------------------------------
+bool Space::containsGeometry(const Geometry& geometry)
+{
+	return ((dSpaceQuery(_space,geometry.getGeometryID()))?true:false); 
+}
+//------------------------------------------------------------------------------------------------
+int Space::getGeometryCount()
+{
+	return dSpaceGetNumGeoms(_space); 
+}
+//------------------------------------------------------------------------------------------------
+Geometry* Space::getGeometry(int index)
+{
+	return (Geometry*) _world->getGeometryList().findItem((size_t)dSpaceGetGeom(_space,index)); 
+}
+//------------------------------------------------------------------------------------------------
+void Space::registerSpace()
+{
+	_world->getSpaceList().registerItem(this);
+	dGeomSetData((dGeomID)_space,(void*)this);
+}
+//------------------------------------------------------------------------------------------------
+void Space::collide(void* data)
+{
+	if(_internal_collisions)
+	{
+		dSpaceCollide(_space,data,World::collisionCallback);
+	}
+}
+//------------------------------------------------------------------------------------------------
+void Space::collide(Space* space,void* data)
+{
+	dSpaceCollide2((dGeomID)_space,(dGeomID)(space->getSpaceID()),data,World::collisionCallback);
+}
+//------------------------------------------------------------------------------------------------
+void Space::collide(Geometry* geometry,void* data)
+{
+	dSpaceCollide2((dGeomID)_space,geometry->getGeometryID(),data,World::collisionCallback);
+}
+
+//------------------------------------------------------------------------------------------------
+void Space::collide(CollisionCallback* colCallback, bool useInternalCollisionFlag)
+{
+	if(useInternalCollisionFlag && !_internal_collisions)
+	{
+		return;
+	}
+	void* data = colCallback;	
+	dSpaceCollide(_space, data, CollisionCallback::collisionCallback);
+}
+//------------------------------------------------------------------------------------------------
+void Space::collide(CollisionCallback* colCallback, Space* space)
+{
+	void* data = colCallback;	
+	dSpaceCollide2((dGeomID)_space,(dGeomID)(space->getSpaceID()),data, CollisionCallback::collisionCallback);
+}
+//------------------------------------------------------------------------------------------------
+void Space::collide(CollisionCallback* colCallback, Geometry* geometry, bool useInternalCollisionFlag)
+{
+	if(useInternalCollisionFlag && !_internal_collisions && geometry->getSpace() == this )
+		return;
+
+	void* data = colCallback;	
+	dSpaceCollide2((dGeomID)_space, geometry->getGeometryID(), data, CollisionCallback::collisionCallback);
+}
+
+//------------------------------------------------------------------------------------------------
+void Space::setInternalCollisions(bool collide)
+{
+	_internal_collisions = collide;
+}
+//------------------------------------------------------------------------------------------------
+bool Space::getInternalCollisions()
+{
+	return _internal_collisions;
+}
+//------------------------------------------------------------------------------------------------
+const AxisAlignedBox& Space::getAxisAlignedBox()
+{
+	dReal aabb[6];
+	dGeomGetAABB((dGeomID)_space,aabb);
+	_bounding_box.setExtents((Real)aabb[0],(Real)aabb[2],(Real)aabb[4],(Real)aabb[1],(Real)aabb[3],(Real)aabb[5]);
+	return _bounding_box;
+}
+//------------------------------------------------------------------------------------------------
+size_t Space::getID()
+{
+	return (size_t)_space;
+}
+//------------------------------------------------------------------------------------------------
+Space::~Space()
+{
+	_world->getSpaceList().unregisterItem((size_t)_space);
+	dSpaceDestroy(_space); 
+}
+//------------------------------------------------------------------------------------------------
+SimpleSpace::SimpleSpace(World *world, const Space* space) : Space (world, space)
+{
+	_space = dSimpleSpaceCreate(getSpaceID(space)); 
+	registerSpace();
+}
+//------------------------------------------------------------------------------------------------
+SimpleSpace::~SimpleSpace()
+{
+}
+//------------------------------------------------------------------------------------------------
+HashTableSpace::HashTableSpace(World *world, const Space* space) : Space (world, space)
+{
+	_space = dHashSpaceCreate(getSpaceID(space)); 
+	registerSpace();
+}
+//------------------------------------------------------------------------------------------------
+void HashTableSpace::setLevels(int min_level,int max_level)
+{
+	dHashSpaceSetLevels(_space,min_level,max_level); 
+}
+//------------------------------------------------------------------------------------------------
+int HashTableSpace::getMinimumLevel()
+{
+	int min_level,max_level;
+	dHashSpaceGetLevels(_space,&min_level,&max_level);
+	return min_level;
+}
+//------------------------------------------------------------------------------------------------
+int HashTableSpace::getMaximumLevel()
+{
+	int min_level,max_level;
+	dHashSpaceGetLevels(_space,&min_level,&max_level);
+	return max_level;
+}
+//------------------------------------------------------------------------------------------------
+HashTableSpace::~HashTableSpace()
+{
+}
+//------------------------------------------------------------------------------------------------
+#if ODE_VERSION_MINOR > 9
+SweepAndPruneSpace::SweepAndPruneSpace(AxisOrder axisOrder, World *world, const Space* space) : Space (world, space)
+{
+	_space = dSweepAndPruneSpaceCreate(getSpaceID(space), axisOrder);
+	registerSpace();
+}
+#endif
+//------------------------------------------------------------------------------------------------
+QuadTreeSpace::QuadTreeSpace(const Ogre::Vector3& center,const Ogre::Vector3& extents,int depth,World *world, const Space* space) : Space (world, space)
+{
+	dVector3 c,e;
+	
+	c[0] = (dReal)center.x;
+	c[1] = (dReal)center.y;
+	c[2] = (dReal)center.z;
+
+	e[0] = (dReal)extents.x;
+	e[1] = (dReal)extents.y;
+	e[2] = (dReal)extents.z;
+
+	_space = dQuadTreeSpaceCreate(getSpaceID(space),c,e,depth); 
+	registerSpace();
+}
+//------------------------------------------------------------------------------------------------
+QuadTreeSpace::~QuadTreeSpace()
+{
+}
+//------------------------------------------------------------------------------------------------
+OgreSceneManagerSpace::OgreSceneManagerSpace(const Ogre::Vector3& center,
+                                             const Ogre::Vector3& extents,
+                                             int depth,
+                                             Ogre::SceneManager *_scn_mgr,
+                                             World *world, const Space* space) : 
+        Space (world, space),
+        _scn_mgr(_scn_mgr)
+{
+    _intersection_query = _scn_mgr->createIntersectionQuery();
+
+    const std::set<Ogre::SceneQuery::WorldFragmentType> *supportedQueryTypes = _intersection_query->getSupportedWorldFragmentTypes();
+    std::set<Ogre::SceneQuery::WorldFragmentType>::const_iterator it = 
+        supportedQueryTypes->find (Ogre::SceneQuery::WFT_PLANE_BOUNDED_REGION);
+    if (it != supportedQueryTypes->end())
+    {
+        _intersection_query->setWorldFragmentType(Ogre::SceneQuery::WFT_PLANE_BOUNDED_REGION);
+        _scene_geometry = true;
+    }
+    else
+    {
+        _intersection_query->setWorldFragmentType(Ogre::SceneQuery::WFT_NONE);
+        _scene_geometry = false;
+    }
+
+    // for now register a dummy space in ode.
+    // perhaps this step can be avoided.dVector3 c,e;
+
+    dVector3 c;
+    c[0] = (dReal)center.x;
+    c[1] = (dReal)center.y;
+    c[2] = (dReal)center.z;
+
+    dVector3 e;
+    e[0] = (dReal)extents.x;
+    e[1] = (dReal)extents.y;
+    e[2] = (dReal)extents.z;
+
+    _space = dQuadTreeSpaceCreate(getSpaceID(space), c, e,depth); 
+    registerSpace();
+}
+//------------------------------------------------------------------------------------------------
+OgreSceneManagerSpace::~OgreSceneManagerSpace()
+{
+    delete _intersection_query;
+}
+//------------------------------------------------------------------------------------------------
+void OgreSceneManagerSpace::collide(void* data)
+{
+    if(_internal_collisions)
+    {
+        // Collision detection
+        Ogre::IntersectionSceneQueryResult& results = _intersection_query->execute();
+
+        Body *body1, *body2;
+        Geometry *geom;
+        Ogre::UserDefinedObject *uo1, *uo2;
+
+        // Movables to Movables
+        Ogre::SceneQueryMovableIntersectionList::iterator it, itend;
+        itend = results.movables2movables.end();
+        for (it = results.movables2movables.begin(); it != itend; ++it)
+        {
+            /* debugging
+            MovableObject *mo1, *mo2;
+            mo1 = it->first;
+            mo2 = it->second;
+            */
+
+            // Get user defined objects (generic in OGRE)
+            uo1 = it->first->getUserObject();
+            uo2 = it->second->getUserObject();
+
+            // Only perform collision if we have UserDefinedObject links
+            if (uo1 && uo2)
+            {
+                bool isBody1 = false;
+                if (uo1->getTypeName () == "Body")
+                    isBody1 = true;
+
+                bool isBody2 = false;
+                if (uo2->getTypeName () == "Body")
+                    isBody2 = true;
+                if (isBody1 || isBody2)
+                {
+                    if (isBody2 && isBody1)
+                    {
+                        // Both are dynamic object
+                       body1 = static_cast<Body*>(uo1);
+                       body2 = static_cast<Body*>(uo2);
+
+                        // Do detailed collision test
+                        body1->collide (data, body2);
+                    }
+                    else
+                    {
+                        // Both are dynamic object
+                        if (isBody1)
+                        {
+                            body1 = static_cast<Body*>     (uo1);
+                            geom  = static_cast<Geometry*> (uo2);
+                        }
+                        else
+                        {
+                            geom  = static_cast<Geometry*> (uo1);
+                            body1 = static_cast<Body*>     (uo2);
+                        }
+
+                        // Do detailed collision test
+                        body1->collide(data, geom);
+                    }
+                }
+            }
+        }
+
+        // Movables to World
+        if (_scene_geometry)
+        {
+            Ogre::MovableObject *mo;
+            Ogre::SceneQuery::WorldFragment *wf;
+
+            Ogre::SceneQueryMovableWorldFragmentIntersectionList::iterator wit, witend;
+            witend = results.movables2world.end();
+            for (wit = results.movables2world.begin(); wit != witend; ++wit)
+            {
+                mo = wit->first;
+                wf = wit->second;
+
+                // Get user defined objects (generic in OGRE)
+                uo1 = mo->getUserObject();
+                // Only perform collision if we have UserDefinedObject link
+                // otherwise ...
+                if (uo1)
+                {
+                    // Cast to ApplicationObject
+                    if (uo1->getTypeName () == "Body")
+                    {
+                        body1 = static_cast<Body*>(uo1);
+                        body1->collidePlaneBounds(data, wf);
+                    }
+//                     else // static objects don't collide against Scene Geometry
+//                     {
+//                         geom = static_cast<Geometry*>(uo);
+//                         // Do detailed collision test
+//                     }
+                }
+            }
+        }
+        // no need to use that one.
+        // dSpaceCollide(_space,data, World::collisionCallback);
+    }
+}
Index: /code/branches/physics/src/ogreode/OgreOdeSpace.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeSpace.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeSpace.h	(revision 2122)
@@ -0,0 +1,146 @@
+#ifndef _OGREODESPACE_H_
+#define _OGREODESPACE_H_
+
+#include "OgreOdePreReqs.h"
+#include <OgreAxisAlignedBox.h>
+
+namespace OgreOde 
+{
+	class _OgreOdeExport Space
+	{
+        friend class Geometry;
+		friend class World;
+	
+#if ODE_VERSION_MINOR > 9
+	public:
+		enum Class
+		{
+			Class_SimpleSpace		= dSimpleSpaceClass,
+			Class_HashSpace			= dHashSpaceClass,
+			Class_SweepAndPrune		= dSweepAndPruneSpaceClass,
+			Class_QuadTree			= dQuadTreeSpaceClass,
+			Class_FirstUser			= dFirstUserClass,
+			Class_LastUser			= dLastUserClass
+		};
+		Space::Class getClass(); 
+#endif
+
+	public:
+		Space(World *world, const Space* space = 0);
+		virtual ~Space();
+
+		void registerSpace();
+
+		void setAutoCleanup(bool on); 
+		bool getAutoCleanup(); 
+
+		void addGeometry(const Geometry& geometry); 
+		void removeGeometry(const Geometry& geometry); 
+		bool containsGeometry(const Geometry& geometry); 
+		int getGeometryCount(); 
+		Geometry* getGeometry(int index);
+
+		virtual void collide(void* data = 0);
+		virtual void collide(Space* space,void* data = 0);
+		virtual void collide(Geometry* geometry,void* data = 0);
+		
+		
+		virtual void collide(CollisionCallback* colCallback, bool useInternalCollisionFlag = true);
+		virtual void collide(CollisionCallback* colCallback, Space* space);
+		virtual void collide(CollisionCallback* colCallback, Geometry* geometry, bool useInternalCollisionFlag = true);
+		
+		
+		void setInternalCollisions(bool collide);
+		bool getInternalCollisions();
+
+		virtual const Ogre::AxisAlignedBox& getAxisAlignedBox(); 
+
+		virtual size_t getID();
+
+		World* getWorld(){ return _world; }
+
+	protected:
+		dSpaceID getSpaceID() const;
+		dSpaceID getSpaceID(const Space* space) const;
+
+	protected:
+		dSpaceID                _space;
+		bool                    _internal_collisions;
+		Ogre::AxisAlignedBox    _bounding_box;
+        World                   *_world;
+	};
+
+	class _OgreOdeExport SimpleSpace:public Space
+	{
+	public:
+		SimpleSpace(World *world, const Space* space = 0);
+		~SimpleSpace();
+	};
+
+	class _OgreOdeExport HashTableSpace:public Space
+	{
+	public:
+		HashTableSpace(World *world, const Space* space = 0);
+		~HashTableSpace();
+
+		void setLevels(int min_level,int max_level);
+		int getMinimumLevel();
+		int getMaximumLevel();
+	};
+
+	class _OgreOdeExport QuadTreeSpace:public Space
+	{
+	public:
+		QuadTreeSpace(const Ogre::Vector3& center,const Ogre::Vector3& extents,int depth,World *world, const Space* space = 0);
+		~QuadTreeSpace();
+    };
+
+#if ODE_VERSION_MINOR > 9
+	class _OgreOdeExport SweepAndPruneSpace : public Space
+	{
+	public:
+		enum AxisOrder
+		{
+			AxisOrder_XYZ = dSAP_AXES_XYZ,
+			AxisOrder_XZY = dSAP_AXES_XZY,
+			AxisOrder_YXZ = dSAP_AXES_YXZ,
+			AxisOrder_YZX = dSAP_AXES_YZX,
+			AxisOrder_ZXY = dSAP_AXES_ZXY,
+			AxisOrder_ZYX = dSAP_AXES_ZYX
+		};
+		
+		// "Order XZY or ZXY usually works best, if your Y is up."
+		SweepAndPruneSpace(AxisOrder axisOrder, World *world, const Space* space = 0);
+	};
+#endif
+	
+    /*
+    * use Scene manager specialized scene partition algo to find collision
+    * 
+    */
+    class _OgreOdeExport OgreSceneManagerSpace:public Space
+    {
+    public:
+        OgreSceneManagerSpace(const Ogre::Vector3& center,
+                                const Ogre::Vector3& extents,
+                                int depth,
+                                Ogre::SceneManager *scn_mgr,
+                                World *world, const Space* space = 0);
+        ~OgreSceneManagerSpace();
+
+        void collide(void* data = 0);
+
+    private:
+        Ogre::SceneManager              *_scn_mgr;
+        Ogre::IntersectionSceneQuery    *_intersection_query;
+
+        // does scene manager has plane collision geometry support
+        // BSP scene manager has that.
+        bool                            _scene_geometry;
+    };
+
+	
+}
+
+#endif
+
Index: /code/branches/physics/src/ogreode/OgreOdeStepper.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeStepper.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeStepper.cpp	(revision 2122)
@@ -0,0 +1,376 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeStepper.h"
+
+#include <OgreRoot.h>
+
+#include "OgreOdeGeometry.h"
+#include "OgreOdeBody.h"
+#include "OgreOdeSpace.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+const Ogre::Real cEpsilon = std::numeric_limits<Real>::epsilon();
+//------------------------------------------------------------------------------------------------
+StepHandler::StepHandler(World *world, 
+                 StepModeType stepModeType,
+                 const Ogre::Real step_size, 
+                 const Ogre::Real max_interval, 
+                 const Ogre::Real time_scale) :
+    _world  (world),
+    _paused (false),
+    _auto_pre (false),
+    _auto_post (false), 
+    _listener (0),
+    _root  (0),
+    _step_size (step_size),
+    _total_time (Ogre::Real(0.0)),
+    _max_interval (max_interval),
+    _time_scale (time_scale)
+{
+    switch (stepModeType)
+    {
+        case BasicStep:
+            _current_stepper = new BasicStepMode(world);
+            break;
+        case QuickStep:
+            _current_stepper = new QuickStepMode(world);
+            break;
+        case FastStep:
+            _current_stepper = new FastStepMode(world);
+            break;
+        case StepModeTypeCount:
+        default:
+            assert(0);
+    }
+    assert((step_size > 0)&&("Step size must be greater than zero"));
+    assert((max_interval > 0)&&("max interval must be greater than zero"));
+}
+//------------------------------------------------------------------------------------------------
+void StepHandler::pause(bool pause)
+{
+	_paused = pause;
+}
+//------------------------------------------------------------------------------------------------
+void StepHandler::setStepListener(StepListener* listener)
+{
+	_listener = listener;
+}
+//------------------------------------------------------------------------------------------------
+bool StepHandler::isPaused()
+{
+	return _paused;
+}
+//------------------------------------------------------------------------------------------------
+void StepHandler::setAutomatic(StepHandler::AutoMode mode, Root* root)
+{
+	if ((_root)&&((_auto_pre)||(_auto_post))) 
+        _root->removeFrameListener(this);
+
+	_auto_pre = (mode == AutoMode_PreFrame)?true:false;
+	_auto_post = (mode == AutoMode_PostFrame)?true:false;
+
+	if ((root)&&((_auto_pre)||(_auto_post)))
+	{
+		_root = root;
+		_root->addFrameListener(this);
+	}
+}
+//------------------------------------------------------------------------------------------------
+bool StepHandler::frameStarted(const FrameEvent& evt)
+{
+	if (_auto_pre)
+	{
+		if (step (evt.timeSinceLastFrame)) 
+			_world->synchronise();
+	}
+	return true;
+}
+//------------------------------------------------------------------------------------------------
+bool StepHandler::frameEnded(const FrameEvent& evt)
+{
+	if (_auto_post)
+	{
+		if (step (evt.timeSinceLastFrame))
+			_world->synchronise();
+	}
+	return true;
+}
+//------------------------------------------------------------------------------------------------
+StepHandler::~StepHandler()
+{
+	setAutomatic(AutoMode_NotAutomatic);
+}
+//------------------------------------------------------------------------------------------------
+bool StepHandler::basicStep(const Ogre::Real time)
+{
+    if (_listener && !_listener->preStep(time))
+        return false;
+
+    _world->getDefaultSpace()->collide();
+
+    if (_listener && !_listener->middleStep(time))
+        return false;
+
+    _current_stepper->step(time);
+
+
+	_world->clearContacts();
+
+    if (_listener && !_listener->postStep(time))
+        return false;
+
+	return true;
+}
+//------------------------------------------------------------------------------------------------
+bool StepHandler::isRunning(const Ogre::Real time)
+{
+    if (!_paused)
+    {
+       return true;
+    }
+    return false;
+}
+//------------------------------------------------------------------------------------------------
+bool StepHandler::prepareSteppingTime(const Ogre::Real time)
+{
+    // make sure time is not too high (alt-tab, debug)
+	if (_max_interval - time < cEpsilon
+		)
+	{
+		_total_time += _max_interval * _time_scale;
+	}
+	else
+	{
+		_total_time += time * _time_scale;
+	}
+	return (_total_time - cEpsilon > 0);
+}
+//------------------------------------------------------------------------------------------------
+bool StepHandler::step(const Ogre::Real time)
+{
+	if (isRunning(time) && prepareSteppingTime(time))
+	{ 
+		if (basicStep(_total_time))
+		{
+			_world->updateDrawState ();
+            _total_time = Ogre::Real(0);
+		}
+		return true;
+	}
+	return false;
+}
+//------------------------------------------------------------------------------------------------
+ExactVariableStepHandler::ExactVariableStepHandler(World *world, 
+                                                   StepModeType stepModeType,
+                                                   const Ogre::Real step_size, 
+                                                   const Ogre::Real max_interval, 
+                                                   const Ogre::Real time_scale):
+    StepHandler(world, stepModeType, step_size,  max_interval, time_scale)
+{
+}
+//------------------------------------------------------------------------------------------------
+bool ExactVariableStepHandler::step(const Ogre::Real time)
+{
+    if (isRunning(time) && prepareSteppingTime(time))
+    {
+        // Steps in fixed time slices first...
+        bool did_run = false;
+
+        while (_total_time - _step_size > cEpsilon)
+        {
+            if (StepHandler::basicStep(_step_size))
+            {
+                did_run = true;
+                _total_time -= _step_size;
+            }
+            else 
+            {
+                break;
+            }
+        } 
+
+        // Then do a little clean-up step
+        if (_total_time > cEpsilon)
+        {
+            if (StepHandler::basicStep(_total_time))
+            {
+                did_run = true;
+                _total_time = Ogre::Real(0);
+            }
+        }
+
+        if (did_run)
+        {
+            _world->updateDrawState ();
+        }
+        return did_run;
+    }
+    return false;
+}
+//------------------------------------------------------------------------------------------------
+ExactVariableStepHandler::~ExactVariableStepHandler()
+{
+}
+//------------------------------------------------------------------------------------------------
+ForwardFixedStepHandler::ForwardFixedStepHandler(World *world, 
+    StepModeType stepModeType,
+    const Ogre::Real step_size, 
+    const Ogre::Real max_interval, 
+    const Ogre::Real time_scale):
+    StepHandler(world, stepModeType, step_size, max_interval, time_scale)
+{
+}
+//------------------------------------------------------------------------------------------------
+bool ForwardFixedStepHandler::step(const Ogre::Real time)
+{
+	if (isRunning(time) && prepareSteppingTime(time))
+	{
+		// Slightly different type of ODE stepper, always makes sure
+		// the ODE world is at least level with real-time, and possibly
+		// up to one step ahead, seems to make things a bit smoother (?)
+		bool did_run = false;
+
+        while (_total_time  > cEpsilon)
+        {
+            if (StepHandler::basicStep(_step_size))
+            {
+                did_run = true;
+                _total_time -= _step_size;
+            }
+            else 
+            {
+                break;
+            }
+        } 
+
+
+		if (did_run)
+			_world->updateDrawState ();
+
+		return did_run;
+	}
+	return false;
+}
+//------------------------------------------------------------------------------------------------
+ForwardFixedStepHandler::~ForwardFixedStepHandler()
+{
+}
+//------------------------------------------------------------------------------------------------
+ForwardFixedInterpolatedStepHandler::ForwardFixedInterpolatedStepHandler(World *world, 
+    StepModeType stepModeType,
+    const Ogre::Real step_size, 
+    const Ogre::Real frame_rate, 
+    const Ogre::Real max_interval, 
+    const Ogre::Real time_scale):
+        StepHandler(world, stepModeType, step_size, max_interval, time_scale),
+        _dbl_step_size(step_size * 2),
+        _inv_step_size(1.0 / frame_rate),
+        _frame_rate (frame_rate)
+{
+    if (frame_rate == Ogre::Real(0))
+    {
+        _fixed_frame_rate = false;
+        _next_frame_step_count = 1;
+    }
+    else
+    {
+        _fixed_frame_rate = true;
+        _next_frame_step_count = (unsigned int)(_frame_rate / (_step_size * _time_scale));
+        if (_next_frame_step_count == 0)
+            _next_frame_step_count = 1;
+    }
+    // compute here the frame_rate adapted to step_size
+    _next_total_time = _next_frame_step_count * _step_size;
+    _inv_next_total_time = 1 / _next_total_time;
+
+	// Need at least _previous and _current position
+	if (_world->getHistorySize() < 2)
+		_world->setHistorySize (2);
+}
+//------------------------------------------------------------------------------------------------
+bool ForwardFixedInterpolatedStepHandler::step(const Ogre::Real time)
+{
+    if (isRunning(time))
+	{	
+		bool did_run = false;
+
+        // if some time did elapse
+        bool should_run = prepareSteppingTime(time);
+        // if fixed frame rate.
+        // make sure we're waiting until next fixed frame rate stepping.
+        if (_fixed_frame_rate && _total_time - _next_total_time < cEpsilon)
+            should_run = false;
+
+        if (should_run)
+        {
+#ifdef _one_step_forward
+            // normal steps, without storing results in history
+            while (_total_time - _step_size > cEpsilon)
+            {
+                if (StepHandler::basicStep(_step_size))
+                {
+                    did_run = true;
+                    _total_time -= _step_size;
+                }
+                else 
+                {
+                    break;
+                }
+            }
+            if (did_run)
+            {
+                // last Special Single Step is specific as we save last state prior stepping.
+                _world->updatePreviousState ();
+                // compute next Frame physic state
+                StepHandler::basicStep(_step_size);
+                _world->updateCurrentState ();	
+            }
+
+#else// _OLD
+
+            // last Special Step is specific as we save last state prior stepping.
+            _world->updatePreviousState ();
+
+            // normal steps, without storing results in history
+            unsigned int next_frame_step_count = _next_frame_step_count;
+            while (next_frame_step_count--)
+            {
+                if (StepHandler::basicStep(_step_size))
+                {
+                    did_run = true;
+                }
+                else 
+                {
+                    break;
+                }
+            }
+
+            if (did_run)
+                _world->updateCurrentState ();	
+
+            _total_time = std::max(_total_time - _next_total_time, Ogre::Real(0.0));
+
+#endif// _OLD
+    		
+        }
+	    // even if no new physic step happened
+        // interpolation may changed its value if time changed...	
+
+	    // interpolate between previousState and currentState;
+        // currentState*interpolationTime + previousState * (1.0f - interpolationTime)
+        // interpolate 
+	    _world->interpolateDrawState(
+            Ogre::Real(1.0) -  (_next_total_time - _total_time) * _inv_next_total_time
+            //(_total_time - _next_total_time) * _inv_next_total_time
+            );
+		return true;
+	}
+	return false;
+}
+//------------------------------------------------------------------------------------------------
+ForwardFixedInterpolatedStepHandler::~ForwardFixedInterpolatedStepHandler()
+{
+}
+
Index: /code/branches/physics/src/ogreode/OgreOdeStepper.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeStepper.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeStepper.h	(revision 2122)
@@ -0,0 +1,180 @@
+#ifndef _OGREODESTEPPER_H_
+#define _OGREODESTEPPER_H_
+
+#include "OgreOdePreReqs.h"
+
+#include <OgreFrameListener.h>
+#include "OgreOdeWorld.h"
+
+namespace OgreOde 
+{
+    //------------------------------------------------------------------------------------------------
+    class _OgreOdeExport StepMode
+    {
+    public:
+        StepMode(World *world) : _world(world){};
+        virtual ~StepMode(){};
+
+        virtual void step(const Ogre::Real time) = 0;
+
+    protected:
+        World* _world;
+    };
+    //------------------------------------------------------------------------------------------------
+    class _OgreOdeExport BasicStepMode : public StepMode
+    {
+    public:
+        BasicStepMode(World *world) : StepMode(world) {};
+        virtual ~BasicStepMode(){};
+
+        inline void step(const Ogre::Real time){ dWorldStep(_world->getWorldID(), (dReal)time);};
+    };
+    //------------------------------------------------------------------------------------------------
+    class _OgreOdeExport QuickStepMode : public StepMode
+    {
+    public:
+        QuickStepMode(World *world) : StepMode(world) {};
+        virtual ~QuickStepMode(){};
+
+        inline void step(const Ogre::Real time){ dWorldQuickStep(_world->getWorldID(), (dReal)time);};
+    };
+    //------------------------------------------------------------------------------------------------
+    class _OgreOdeExport FastStepMode : public StepMode
+    {
+    public:
+        FastStepMode(World *world, int max_iteration = 40) : StepMode(world), _max_iteration(max_iteration) {};
+        virtual ~FastStepMode(){};
+
+        inline void step(const Ogre::Real time){ dWorldStepFast1(_world->getWorldID(), (dReal)time, _max_iteration);};
+    private:
+        int _max_iteration;
+    };
+    //------------------------------------------------------------------------------------------------
+	class _OgreOdeExport StepListener
+	{
+	public:
+		StepListener(){};
+		virtual ~StepListener(){};
+
+        virtual bool preStep(Ogre::Real time) { return true; };
+        virtual bool postStep(Ogre::Real time)  { return true; };
+        virtual bool middleStep(Ogre::Real time)  { return true; };
+    };
+    //------------------------------------------------------------------------------------------------
+	class _OgreOdeExport StepHandler:public Ogre::FrameListener
+    {
+	public:
+		enum AutoMode
+		{
+			AutoMode_NotAutomatic,
+			AutoMode_PreFrame,
+			AutoMode_PostFrame
+        };
+        enum StepModeType
+        {
+            BasicStep = 0,
+            QuickStep,
+            FastStep,
+            StepModeTypeCount
+        };
+
+	public:
+        StepHandler(World *world, 
+            StepModeType stepModeType = QuickStep,
+            const Ogre::Real step_size = Ogre::Real (0.01), 
+            const Ogre::Real max_interval = Ogre::Real(1.0 / 4), 
+            const Ogre::Real time_scale = Ogre::Real(1.0));
+		virtual ~StepHandler();
+
+		virtual bool step(const Ogre::Real time);
+
+		Ogre::Real getStepSize() const {return _step_size;}
+		void setStepSize (const Ogre::Real step_size){_step_size = step_size;}
+
+		void pause(bool pause);
+		bool isPaused();
+
+		void setStepListener(StepListener* listener);
+		void setAutomatic(StepHandler::AutoMode mode, Ogre::Root* root = 0);
+
+		bool frameStarted(const Ogre::FrameEvent& evt);
+		bool frameEnded(const Ogre::FrameEvent& evt);
+
+    protected:
+        bool isRunning(const Ogre::Real time);
+        bool prepareSteppingTime(const Ogre::Real time);
+        bool basicStep(const Ogre::Real time);
+
+	protected:
+		World* _world;
+		bool _paused,_auto_pre,_auto_post;
+		StepListener* _listener;
+		Ogre::Root* _root;
+		Ogre::Real _step_size;
+        Ogre::Real _total_time;
+        Ogre::Real _max_interval;
+        Ogre::Real _time_scale;
+
+        StepMode *_current_stepper;
+    };
+
+    //------------------------------------------------------------------------------------------------
+	class _OgreOdeExport ForwardFixedStepHandler:public StepHandler
+	{
+	public:
+        ForwardFixedStepHandler(World *world, 
+            StepModeType stepModeType = QuickStep,
+            const Ogre::Real step_size = Ogre::Real (0.01), 
+            const Ogre::Real max_interval = Ogre::Real(1.0 / 4), 
+            const Ogre::Real time_scale = Ogre::Real(1.0));
+		virtual ~ForwardFixedStepHandler();
+
+		virtual bool step(const Ogre::Real time);
+    };
+    //------------------------------------------------------------------------------------------------
+	class _OgreOdeExport ExactVariableStepHandler:public StepHandler
+	{
+	public:
+        ExactVariableStepHandler(World *world ,
+            StepModeType stepModeType = QuickStep,
+            const Ogre::Real step_size = Ogre::Real (0.01), 
+            const Ogre::Real max_interval = Ogre::Real(1.0 / 4), 
+            const Ogre::Real time_scale = Ogre::Real(1.0));
+		virtual ~ExactVariableStepHandler();
+
+		virtual bool step(const Ogre::Real time);
+    };
+    //------------------------------------------------------------------------------------------------
+	// Fix your timestep Gaffer implementation.
+	// http://www.gaffer.org/articles/Timestep.html
+	// Gaffer :"If you implement this interpolation technique you ensure that there will
+	// not be any visual stuttering when your display and physics framerates 
+	// are out of sync. It will also perfectly handle the undersampling case so 
+	// your objects will move smoothly when you view your simulation in slow 
+	// motion or ten years from now on that Sexium." 
+	class _OgreOdeExport ForwardFixedInterpolatedStepHandler :public StepHandler
+	{
+	public:
+        ForwardFixedInterpolatedStepHandler(World *world, 
+            StepModeType stepModeType = QuickStep,
+            const Ogre::Real step_size = Ogre::Real (0.01), 
+            const Ogre::Real frame_rate = Ogre::Real (1.0 / 60),
+            const Ogre::Real max_interval = Ogre::Real(1.0 / 4), 
+            const Ogre::Real time_scale = Ogre::Real(1.0));
+		virtual ~ForwardFixedInterpolatedStepHandler();
+
+		virtual bool step(const Ogre::Real time);
+    private :
+        Ogre::Real _dbl_step_size;
+        Ogre::Real _inv_step_size;
+
+        Ogre::Real _next_total_time;
+        unsigned int _next_frame_step_count;
+        Ogre::Real _inv_next_total_time;
+        bool _fixed_frame_rate;
+        Ogre::Real _frame_rate;
+	};
+
+}
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOdeTriangleMeshData.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeTriangleMeshData.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeTriangleMeshData.cpp	(revision 2122)
@@ -0,0 +1,59 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeTriangleMeshData.h"
+
+#include "OgreOdeTriangleMeshDataManager.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+
+//------------------------------------------------------------------------------------------------
+TriangleMeshData::TriangleMeshData(String name,
+								   Vector3 scale,
+								   const Ogre::Vector3* vertices,
+								   unsigned int vertex_count,
+								   const TriangleIndex* indices,
+								   unsigned int index_count
+								   ) : 
+    _vertex_count (vertex_count),
+    _index_count (index_count)
+{
+	_name = name;
+	_scale = scale;
+	_vertex_count = vertex_count;
+	_index_count = index_count;
+	_vertices = new dVector3[vertex_count];
+	_indices = new TriangleIndex[index_count];
+
+	for(unsigned int i = 0;i < vertex_count;i++)
+	{
+		_vertices[i][0] = (dReal)vertices[i].x;
+		_vertices[i][1] = (dReal)vertices[i].y;
+		_vertices[i][2] = (dReal)vertices[i].z;
+	}
+
+	memcpy(_indices, indices, sizeof(unsigned int) * index_count);
+
+	_data = dGeomTriMeshDataCreate(); 
+	dGeomTriMeshDataBuildSimple(_data, (const dReal*)_vertices, (int)vertex_count, (dTriIndex*)_indices, (int)index_count); 
+	
+}
+
+
+
+
+//------------------------------------------------------------------------------------------------
+TriangleMeshData::~TriangleMeshData()
+{
+
+	//printf ("destroy TriangleMeshData\n");
+	
+	dGeomTriMeshDataDestroy(_data);
+	
+	TriangleMeshDataManager::getSingleton().removeTriangleMeshData(_name, _scale);
+	
+	delete[] _vertices;
+	delete[] _indices;
+}
+
+
Index: /code/branches/physics/src/ogreode/OgreOdeTriangleMeshData.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeTriangleMeshData.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeTriangleMeshData.h	(revision 2122)
@@ -0,0 +1,60 @@
+#ifndef __OgreOdeTriangleMeshData_H__
+#define __OgreOdeTriangleMeshData_H__
+
+#include "OgreOdePreReqs.h"
+
+#include <OgreSharedPtr.h>
+#include <OgreVector3.h>
+
+namespace OgreOde
+{
+	/** Stores triangle mesh data once and shares it between all geoms that require it
+	*/
+	class _OgreOdeExport TriangleMeshData
+	{
+	public:
+
+		TriangleMeshData(Ogre::String name, Ogre::Vector3 scale, const Ogre::Vector3* vertices, unsigned int vertex_count, const TriangleIndex* indices, unsigned int index_count);
+
+		virtual ~TriangleMeshData();
+		
+		Ogre::String getMeshName(){ return _name; }
+		
+		Ogre::Vector3 getScale(){ return _scale; }
+
+		dTriMeshDataID getData(){ return _data; }
+
+		dVector3* getVertices(){ return _vertices; }
+
+		TriangleIndex* getIndices(){ return _indices; }
+	
+		unsigned int getVertexCount(){ return _vertex_count; }
+
+		unsigned int getIndexCount(){ return _index_count; }		
+		
+	protected:
+	
+		Ogre::String _name;
+		Ogre::Vector3 _scale;
+		dTriMeshDataID _data;
+		dVector3* _vertices;
+		TriangleIndex* _indices;
+		unsigned int _vertex_count;
+        unsigned int _index_count;
+	};
+
+	/** SharedPtr of TriangleMeshData
+	*/
+	class _OgreOdeExport TriangleMeshDataPtr : public Ogre::SharedPtr<TriangleMeshData> 
+	{
+	public:
+		TriangleMeshDataPtr() : Ogre::SharedPtr<TriangleMeshData>() {}
+		TriangleMeshDataPtr(TriangleMeshData* rep) : Ogre::SharedPtr<TriangleMeshData>(rep) {}
+		TriangleMeshDataPtr(const TriangleMeshDataPtr& r) : Ogre::SharedPtr<TriangleMeshData>(r) {} 
+	};
+	
+}
+
+#endif //__OgreOdeTriangleMeshData_H__
+
+
Index: /code/branches/physics/src/ogreode/OgreOdeTriangleMeshDataManager.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeTriangleMeshDataManager.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeTriangleMeshDataManager.cpp	(revision 2122)
@@ -0,0 +1,111 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeTriangleMeshDataManager.h"
+
+#include "OgreOdeTriangleMeshData.h"
+
+using namespace Ogre;
+using namespace OgreOde;
+
+namespace Ogre
+{
+	template<> TriangleMeshDataManager *Ogre::Singleton<TriangleMeshDataManager>::ms_Singleton = 0;
+}
+
+namespace OgreOde
+{
+
+	
+	//-----------------------------------------------------------------------
+	TriangleMeshDataManager::TriangleMeshDataManager()
+	{
+	}
+
+	//-----------------------------------------------------------------------
+	TriangleMeshDataManager::~TriangleMeshDataManager()
+	{
+		//mTriangleMeshDataMap.clear();
+	}
+	
+	//-----------------------------------------------------------------------
+	TriangleMeshDataManager *TriangleMeshDataManager::getSingletonPtr () 
+	{
+		return ms_Singleton;
+	}
+
+	//-----------------------------------------------------------------------
+	TriangleMeshDataManager &TriangleMeshDataManager::getSingleton ()
+	{  
+		assert (ms_Singleton);  
+		return (*ms_Singleton);
+	}
+
+
+	//-----------------------------------------------------------------------
+	void TriangleMeshDataManager::addTriangleMeshData(const String& name, TriangleMeshDataPtr shape, Vector3 scale)
+	{
+
+		mTriangleMeshDataMap[name][scale] = shape;
+		
+		// reduce count so when Ode::Geometry changes its dataPtr or is deleted we arn't
+		// left with this one on a referance count of 1
+		unsigned int* count = shape.useCountPointer();
+		(*count)--;
+		
+	}
+
+
+	//-----------------------------------------------------------------------
+	void TriangleMeshDataManager::removeTriangleMeshData(const String& name, Vector3 scale)
+	{
+		
+		TriangleMeshDataPtrMap::iterator itr = mTriangleMeshDataMap.find(name);
+		if(itr != mTriangleMeshDataMap.end())
+		{
+		
+			std::map<Ogre::Vector3, TriangleMeshDataPtr, vectorLess>::iterator itr2;
+			
+			itr2 = itr->second.find(scale);
+			
+			if ( itr2 != itr->second.end() )
+			{
+				//printf ("no TriangleMeshData for scale so erase it\n");
+				itr->second.erase(itr2);
+				itr2->second.setNull();
+			}
+			
+			if (itr->second.size() == 0) 
+			{
+				//printf ("have no TriangleMeshData for this mesh so erase it from map\n");
+				mTriangleMeshDataMap.erase(itr); 
+			}
+		}
+			
+	}
+	
+	
+	/** looks for mesh name then size or returns a NULL TriangleMeshDataPtr
+	*/
+	//-----------------------------------------------------------------------
+	TriangleMeshDataPtr TriangleMeshDataManager::getTriangleMeshData(const String& name, Vector3 scale)
+	{
+	
+		TriangleMeshDataPtrMap::iterator itr = mTriangleMeshDataMap.find(name);
+		if(itr != mTriangleMeshDataMap.end())
+		{
+			std::map<Ogre::Vector3, TriangleMeshDataPtr, vectorLess>::iterator itr2;
+			
+			itr2 = itr->second.find(scale);
+			
+			if ( itr2 != itr->second.end() )
+			{
+				return itr2->second;
+			}
+		}
+		
+		//printf ("TriangleMeshDataManager::getTriangleMeshData not found\n");
+		
+		return NULL;
+	
+	}
+
+}
Index: /code/branches/physics/src/ogreode/OgreOdeTriangleMeshDataManager.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeTriangleMeshDataManager.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeTriangleMeshDataManager.h	(revision 2122)
@@ -0,0 +1,78 @@
+#ifndef __OgreOdeTriangleMeshDataManager_H__
+#define __OgreOdeTriangleMeshDataManager_H__
+
+#include "OgreOdePreReqs.h"
+
+#include <map>
+#include <OgreSingleton.h>
+#include <OgreVector3.h>
+
+namespace OgreOde
+{
+
+	/** Each time a new TriangleMeshData is created it is added to this mananger, in TriangleMeshData's
+		destructor it is removed from the manager
+	*/
+	class TriangleMeshDataManager : public Ogre::Singleton<TriangleMeshDataManager>
+	{
+	
+	protected:
+
+		struct vectorLess {
+			bool operator()(const Ogre::Vector3& a, const Ogre::Vector3& b) const
+			{
+				if (a.x < b.x) return true;
+				if (a.x > b.x) return false;
+				if (a.y < b.y) return true;
+				if (a.y > b.y) return false;
+				return a.z < b.z;
+			}
+		};
+		
+	public:
+	
+        typedef std::map<Ogre::String, std::map<Ogre::Vector3, TriangleMeshDataPtr, vectorLess > > TriangleMeshDataPtrMap;
+
+		/** 
+		*/
+		TriangleMeshDataManager();
+
+		/**
+		*/
+		virtual ~TriangleMeshDataManager();
+		
+		/**
+		*/
+		static TriangleMeshDataManager* getSingletonPtr();
+		
+		/**
+		*/
+		static TriangleMeshDataManager& getSingleton();
+		
+		/** 
+		*/
+		void addTriangleMeshData(const Ogre::String& name, TriangleMeshDataPtr shape, Ogre::Vector3 scale);
+		
+		/** 
+		*/
+		void removeTriangleMeshData(const Ogre::String& name, Ogre::Vector3 scale);
+		
+		/** 
+		*/
+		TriangleMeshDataPtr getTriangleMeshData(const Ogre::String& name, Ogre::Vector3 scale);
+		
+		/** 
+		*/
+		const TriangleMeshDataPtrMap getTriangleMeshDataPtrMap(){ return mTriangleMeshDataMap; }
+		
+	protected:
+
+		// mesh name, scale, TriangleMeshDataPtr
+		TriangleMeshDataPtrMap mTriangleMeshDataMap;
+
+	};
+}
+
+#endif //__OgreOdeTriangleMeshDataManager_H__
+
+
Index: /code/branches/physics/src/ogreode/OgreOdeUtility.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeUtility.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeUtility.cpp	(revision 2122)
@@ -0,0 +1,47 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeUtility.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+const Ogre::Real Utility::Infinity = dInfinity;
+
+Real Utility::randomReal()
+{
+	return (Real)dRandReal();
+}
+
+/**
+According to the ODE docs;
+	
+By adjusting the values of ERP and CFM, you can achieve various effects. 
+For example you can simulate springy constraints, where the two bodies oscillate 
+as though connected by springs. Or you can simulate more spongy constraints, without 
+the oscillation. In fact, ERP and CFM can be selected to have the same effect as any 
+desired spring and damper constants. If you have a spring constant kp and damping constant kd, 
+then the corresponding ODE constants are:
+	
+ERP = h kp / (h kp + kd)
+CFM = 1 / (h kp + kd)
+	
+where h is the stepsize. These values will give the same effect as a spring-and-damper 
+system simulated with implicit first order integration.
+*/
+//-----------------------------------------------------------------------
+Real Utility::getCFM(Real spring, Real dampening, Real timeStep)
+{
+	return 1 / ((timeStep * spring) + dampening);
+}
+
+//-----------------------------------------------------------------------
+Real Utility::getERP(Real spring, Real dampening, Real timeStep)
+{
+	return  (timeStep * spring) / ((timeStep * spring) + dampening);
+}
+	
+//-----------------------------------------------------------------------
+void Utility::getSpringConstants(Real CFM, Real ERP, Real timeStep, Real &spring, Real &dampening)
+{
+	spring = (ERP / CFM) / timeStep;
+	dampening = (1 / CFM) - timeStep * spring;
+}
Index: /code/branches/physics/src/ogreode/OgreOdeUtility.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeUtility.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeUtility.h	(revision 2122)
@@ -0,0 +1,34 @@
+#ifndef _OGREODEUTILITY_H_
+#define _OGREODEUTILITY_H_
+
+#include "OgreOdePreReqs.h"
+
+namespace OgreOde
+{
+	class _OgreOdeExport Utility
+	{
+	public:
+		Utility(){}
+		~Utility(){}
+
+		static Ogre::Real randomReal();
+
+		static const Ogre::Real Infinity;
+
+		/** returns a CFM value for use on joints or contacts
+			@param timeStep is the the stepping time for the world, see Steppers
+		*/
+		static Ogre::Real getCFM(Ogre::Real spring, Ogre::Real dampening, Ogre::Real timeStep);
+
+		/** returns a ERP value for use on joints or contacts
+		*/
+		static Ogre::Real getERP(Ogre::Real spring, Ogre::Real dampening, Ogre::Real timeStep);
+		
+		/** can be used to get spring constants out of a ERP and CFM value
+		*/
+		static void getSpringConstants(Ogre::Real CFM, Ogre::Real ERP, Ogre::Real timeStep, Ogre::Real &spring, Ogre::Real &dampening);
+	};
+}
+
+#endif
+
Index: /code/branches/physics/src/ogreode/OgreOdeWorld.cpp
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeWorld.cpp	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeWorld.cpp	(revision 2122)
@@ -0,0 +1,288 @@
+#include "OgreOdePrecompiledHeaders.h"
+#include "OgreOdeWorld.h"
+
+#include <OgreSceneNode.h>
+#include <OgreMovableObject.h>
+
+#include "OgreOdeBody.h"
+#include "OgreOdeGeometry.h"
+#include "OgreOdeSpace.h"
+
+using namespace OgreOde;
+using namespace Ogre;
+
+CollisionListener* World::_collision_listener = 0;
+//------------------------------------------------------------------------------------------------
+void World::setCollisionListener(CollisionListener* collision_listener)
+{
+	_collision_listener = collision_listener;
+}
+//------------------------------------------------------------------------------------------------
+CollisionListener* World::getCollisionListener()
+{
+	return _collision_listener;
+}
+//------------------------------------------------------------------------------------------------
+World::World(SceneManager* manager) :
+    _show_debug_geoms (false),
+    _show_debug_contact (false),
+    _manager (manager)
+{
+#if ODE_VERSION_MINOR > 9
+	dInitODE2(0);
+	dAllocateODEDataForThread(dAllocateMaskAll);
+#endif
+
+
+	_world = dWorldCreate();
+	_contacts = dJointGroupCreate(0);
+
+	_default_space = new HashTableSpace(this);
+	_default_space->setAutoCleanup(false);
+	_default_space->setInternalCollisions(true);
+
+	setDamping(0.0,0.0);
+	setHistorySize (1);
+
+
+}
+//------------------------------------------------------------------------------------------------
+void World::setHistorySize(size_t historySize)
+{
+	_history_size = historySize;
+
+	MaintainedItemIterator<Body> it = _body_list.getIterator();
+	while(!it.end ())
+	{
+		Body * const b = (Body *) (it.getNext ());
+		b->_historyResize(historySize);
+	}
+
+}
+//------------------------------------------------------------------------------------------------
+size_t World::getHistorySize() const 
+{
+	return _history_size;
+}
+//------------------------------------------------------------------------------------------------
+void World::setGravity(const Ogre::Vector3& gravity)
+{
+	dWorldSetGravity(_world,(dReal)gravity.x,(dReal)gravity.y,(dReal)gravity.z);
+}
+//------------------------------------------------------------------------------------------------
+const Ogre::Vector3& World::getGravity()
+{
+	dVector3 g;
+	dWorldGetGravity(_world,g);
+	_gravity.x = (Real)g[0];
+	_gravity.y = (Real)g[1];
+	_gravity.z = (Real)g[2];
+	return _gravity;
+}
+//------------------------------------------------------------------------------------------------
+void World::setERP(Real erp)
+{
+	dWorldSetERP(_world,(dReal)erp);
+}
+//------------------------------------------------------------------------------------------------
+Real World::getERP()
+{
+	return (Real)dWorldGetERP(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setCFM(Real cfm)
+{
+	dWorldSetCFM(_world,(dReal)cfm);
+}
+//------------------------------------------------------------------------------------------------
+Real World::getCFM()
+{
+	return (Real)dWorldGetCFM(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setAutoSleep(bool auto_sleep)
+{
+	dWorldSetAutoDisableFlag(_world,(auto_sleep)?1:0);
+}
+//------------------------------------------------------------------------------------------------
+bool World::getAutoSleep()
+{
+	return (dWorldGetAutoDisableFlag(_world))?true:false;
+}
+//------------------------------------------------------------------------------------------------
+void World::setAutoSleepLinearThreshold(Real linear_threshold)
+{
+	dWorldSetAutoDisableLinearThreshold(_world,(dReal)linear_threshold);
+}
+//------------------------------------------------------------------------------------------------
+Real World::getAutoSleepLinearThreshold()
+{
+	return (Real)dWorldGetAutoDisableLinearThreshold(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setAutoSleepAngularThreshold(Real angular_threshold)
+{
+	dWorldSetAutoDisableAngularThreshold(_world,(dReal)angular_threshold);
+}
+//------------------------------------------------------------------------------------------------
+Real World::getAutoSleepAngularThreshold()
+{
+	return (Real)dWorldGetAutoDisableAngularThreshold(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setAutoSleepSteps(int steps)
+{
+	dWorldSetAutoDisableSteps(_world,steps);
+}
+//------------------------------------------------------------------------------------------------
+int World::getAutoSleepSteps()
+{
+	return dWorldGetAutoDisableSteps(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setAutoSleepTime(Real time)
+{
+	dWorldSetAutoDisableTime(_world,(dReal)time);
+}
+//------------------------------------------------------------------------------------------------
+Real World::getAutoSleepTime()
+{
+	return (Real)dWorldGetAutoDisableTime(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setAutoSleepAverageSamplesCount(unsigned int time)
+{
+    dWorldSetAutoDisableAverageSamplesCount(_world, time);
+}
+//------------------------------------------------------------------------------------------------
+size_t World::getAutoSleepAverageSamplesCount()
+{
+    return dWorldGetAutoDisableAverageSamplesCount(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setContactCorrectionVelocity(Real velocity)
+{
+	dWorldSetContactMaxCorrectingVel(_world,(dReal)velocity);
+}
+//------------------------------------------------------------------------------------------------
+void World::setContactSurfaceLayer(Real layer)
+{
+	dWorldSetContactSurfaceLayer(_world,(dReal)layer);
+}
+
+//------------------------------------------------------------------------------------------------
+void World::collisionCallback(void *data,dGeomID geom_a,dGeomID geom_b)
+{
+	const bool a_space = (dGeomIsSpace(geom_a))?true:false;
+	const bool b_space = (dGeomIsSpace(geom_b))?true:false;
+	
+	void* const ptr_a = dGeomGetData(geom_a);
+	void* const ptr_b = dGeomGetData(geom_b);
+
+	if(a_space  || b_space )
+	{
+		// Collide a space with a space
+		if(a_space && b_space) 
+			static_cast<Space*>(ptr_a)->collide(static_cast<Space*>(ptr_b),data);
+		else if(a_space) 
+			static_cast<Space*>(ptr_a)->collide(static_cast<Geometry*>(ptr_b),data);
+		else 
+			static_cast<Space*>(ptr_b)->collide(static_cast<Geometry*>(ptr_a),data);
+
+		// Collide geometries internal to the spaces
+		if(a_space) 
+            static_cast<Space*>(ptr_a)->collide(data);
+
+		if(b_space) 
+            static_cast<Space*>(ptr_b)->collide(data);
+	}
+    else
+	{
+		// Collide a geom with a geom, i.e. generate contacts
+		static_cast<Geometry*>(ptr_a)->collide(static_cast<Geometry*>(ptr_b),_collision_listener);
+	}
+}
+//------------------------------------------------------------------------------------------------
+Body* World::findBody(SceneNode* node)
+{
+	Body* body = 0;
+	for(int i = 0;i < node->numAttachedObjects();i++)
+	{
+		MovableObject* obj = node->getAttachedObject(i);
+		if(obj)
+		{
+			if(obj->getMovableType() == Ogre::String("OgreOde::Body"))
+			{
+				body = static_cast<Body*>(obj);
+				break;
+			}
+		}
+	}
+	return body;
+}
+//------------------------------------------------------------------------------------------------
+Body* World::findBody(const Ogre::String& name)
+{
+	Body *b = 0;
+	MaintainedItemIterator<Body> it = _body_list.getIterator();
+	while(!it.end ())
+	{
+		b = (Body*) (it.getNext ());
+		if(b->getName() == name) 
+			return b;
+	}
+	return 0;
+}
+//------------------------------------------------------------------------------------------------
+void World::setDefaultSpace(Space* space)
+{
+	delete _default_space;
+	_default_space = space;
+}
+//------------------------------------------------------------------------------------------------
+void World::setQuickStepIterations(int iterations)
+{
+	dWorldSetQuickStepNumIterations(_world,iterations);
+}
+//------------------------------------------------------------------------------------------------
+int World::getQuickStepIterations()
+{
+	return dWorldGetQuickStepNumIterations(_world);
+}
+//------------------------------------------------------------------------------------------------
+void World::setShowDebugGeometries(bool show)
+{
+	_body_list.setDebug(show);
+	_geometry_list.setDebug(show);
+	_show_debug_geoms = show;
+}
+//------------------------------------------------------------------------------------------------
+void World::setShowDebugContact(bool show)
+{
+    _geometry_list.setDebugContact(show);
+    _show_debug_contact = show;
+}
+//------------------------------------------------------------------------------------------------
+void World::setDamping(Real linear_damping,Real angular_damping)
+{
+	_linear_damping = -(dReal)linear_damping;
+	_angular_damping = -(dReal)angular_damping;
+}
+//------------------------------------------------------------------------------------------------
+Real World::getLinearDamping()
+{
+	return -(Real)_linear_damping;
+}
+//------------------------------------------------------------------------------------------------
+Real World::getAngularDamping()
+{
+	return -(Real)_angular_damping;
+}
+//------------------------------------------------------------------------------------------------
+World::~World()
+{
+	delete _default_space;
+	dJointGroupDestroy(_contacts);
+    dWorldDestroy(_world);
+    dCloseODE();
+}
Index: /code/branches/physics/src/ogreode/OgreOdeWorld.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOdeWorld.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOdeWorld.h	(revision 2122)
@@ -0,0 +1,221 @@
+#ifndef _OGREODEWORLD_H_
+#define _OGREODEWORLD_H_
+
+#include "OgreOdePreReqs.h"
+
+#include <map>
+#include <OgreVector3.h>
+
+#include "OgreOdeMaintainedList.h"
+#include "OgreOdeBody.h"
+#include "OgreOdeJoint.h"
+#include "OgreOdeGeometry.h"
+#include "OgreOdeSpace.h"
+
+namespace OgreOde 
+{
+	/** The main class which you will use to simulate your world.
+     * 
+	 * This is the core class of OgreOde, it is directly analogous to the ODE world except that
+	 * in OgreOde you can have only one world, which is why it is Singleton.
+	 *
+	 * A World is a container for all the bodies and geometries in you simulation. You also
+	 * use it to set global options for things like gravity, ERP, CFM and automatic sleeping.
+	 * Also, the World is what you step when you want to advance your simulation by a certain time
+	 * period.
+	 */
+	class _OgreOdeExport World
+    {
+        friend class Body;
+		friend class JointGroup;
+		friend class Joint;
+		friend class Space;
+		friend class Geometry;
+		friend class StepHandler;
+
+	public:
+		/** Construct a new World.
+		 * 
+		 * You will need to call this to create the World into which you cabn place your physical objects.
+		 * The World requires a reference to the scene manager you are using in order to create things
+		 * like nodes for debug objects and to obtain configuration options for world geometry.
+		 * 
+		 * \param manager The scene manager you are using.
+		 */
+		World(Ogre::SceneManager* manager);
+		~World();
+
+		void setGravity(const Ogre::Vector3& gravity = Ogre::Vector3::ZERO);
+		const Ogre::Vector3& getGravity();
+
+		void setHistorySize (size_t historySize);
+		size_t getHistorySize () const;
+
+		void setERP(Ogre::Real erp = 0.2);
+		Ogre::Real getERP();
+		void setCFM(Ogre::Real cfm = 10e-5);
+		Ogre::Real getCFM();
+
+		void setContactCorrectionVelocity(Ogre::Real velocity = 0.1);
+		void setContactSurfaceLayer(Ogre::Real layer = 0.001);
+
+		void setAutoSleep(bool auto_sleep = false);
+		bool getAutoSleep();
+		void setAutoSleepLinearThreshold(Ogre::Real linear_threshold = 0.01);
+		Ogre::Real getAutoSleepLinearThreshold();
+		void setAutoSleepAngularThreshold(Ogre::Real angular_threshold = 0.01);
+		Ogre::Real getAutoSleepAngularThreshold();
+		void setAutoSleepSteps(int steps = 10);
+		int getAutoSleepSteps();
+		void setAutoSleepTime(Ogre::Real time = 0);
+		Ogre::Real getAutoSleepTime(); 
+        void setAutoSleepAverageSamplesCount(unsigned int  time = 10);
+        size_t getAutoSleepAverageSamplesCount();
+		inline void step(Ogre::Real stepsize); 
+        inline void quickStep(Ogre::Real stepsize);
+        inline void fastStep(Ogre::Real stepsize);
+
+		void setQuickStepIterations(int iterations);
+		int getQuickStepIterations();
+
+		Body* findBody(Ogre::SceneNode* node);
+		Body* findBody(const Ogre::String& name);
+
+		inline void clearContacts();
+
+		void setCollisionListener(CollisionListener* collision_listener);
+		CollisionListener* getCollisionListener();
+
+		void setShowDebugGeometries(bool show);
+        bool getShowDebugGeometries(){return _show_debug_geoms;}
+
+        void setShowDebugContact(bool show);
+        bool getShowDebugContact(){return _show_debug_contact;}
+
+		inline void notifyGeometry(Body* body);
+
+		Space* getDefaultSpace(){return _default_space;}
+		void setDefaultSpace(Space* space);
+
+		inline Ogre::SceneManager* getSceneManager(){return _manager;}
+
+		void setDamping(Ogre::Real linear_damping,Ogre::Real angular_damping);
+		Ogre::Real getLinearDamping();
+		Ogre::Real getAngularDamping();
+
+		inline void synchronise();
+	
+		inline void updateDrawState();
+		inline void updatePreviousState();
+		inline void updateCurrentState();
+		inline void interpolateDrawState(const Ogre::Real alpha);
+
+
+		inline MaintainedList<Body>			&getBodyList()		{return _body_list;}
+		inline MaintainedList<Joint>		&getJointList()		{return _joint_list;}
+		inline MaintainedList<JointGroup>	&getJointGroupList(){return _joint_group_list;}
+		inline MaintainedList<Geometry>		&getGeometryList()	{return _geometry_list;}
+		inline MaintainedList<Space>		&getSpaceList()		{return _space_list;}
+
+        inline dWorldID                            getWorldID();
+	protected:
+
+        inline dJointGroupID                       getContactGroupID();
+		static void                         collisionCallback(void *data,
+                                                            dGeomID geom_a,
+                                                            dGeomID geom_b);
+
+	protected:
+		dWorldID		            _world;
+		dJointGroupID	            _contacts;
+
+		Space*		                _default_space;
+		
+		static CollisionListener*   _collision_listener;
+
+		MaintainedList<Body>		_body_list;
+		MaintainedList<Joint>		_joint_list;
+		MaintainedList<JointGroup>	_joint_group_list;
+		MaintainedList<Geometry>	_geometry_list;
+		MaintainedList<Space>		_space_list;
+
+        bool			            _show_debug_geoms;
+        bool			            _show_debug_contact;
+
+		Ogre::SceneManager*        	_manager;
+
+		Ogre::Vector3               _gravity;
+		dReal	                    _linear_damping,_angular_damping;
+		size_t                      _history_size;
+	};
+
+
+    //------------------------------------------------------------------------------------------------
+    //INLINED Methods
+    //------------------------------------------------------------------------------------------------
+    //------------------------------------------------------------------------------------------------
+    inline dWorldID World::getWorldID()
+    {
+        return _world;
+    }
+    //------------------------------------------------------------------------------------------------
+    inline dJointGroupID World::getContactGroupID()
+    {
+        return _contacts;
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::notifyGeometry(Body* body)
+    {
+        _geometry_list.notify(body);
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::synchronise()
+    {
+        _body_list.synchronise ();
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::updateDrawState()
+    {
+        _body_list.updateDrawState ();
+        if (_show_debug_contact)
+            _geometry_list.updateDebugContact();
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::interpolateDrawState(const Ogre::Real alpha)
+    {
+        _body_list.interpolateDrawState(alpha);
+        if (_show_debug_contact)
+            _geometry_list.updateDebugContact();
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::updatePreviousState()
+    {
+        _body_list.updatePreviousState();
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::updateCurrentState()
+    {
+        _body_list.updateCurrentState ();
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::clearContacts()
+    {
+        dJointGroupEmpty(_contacts);
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::step(Ogre::Real stepsize)
+    {
+        dWorldStep(_world,(dReal)stepsize); 
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::quickStep(Ogre::Real stepsize)
+    {
+        dWorldQuickStep(_world,(dReal)stepsize);
+    }
+    //------------------------------------------------------------------------------------------------
+    inline void World::fastStep(Ogre::Real stepsize)
+    {
+        dWorldStepFast1(_world,(dReal)stepsize,20);
+    }
+}
+#endif
Index: /code/branches/physics/src/ogreode/OgreOde_Core.h
===================================================================
--- /code/branches/physics/src/ogreode/OgreOde_Core.h	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOde_Core.h	(revision 2122)
@@ -0,0 +1,17 @@
+#ifndef _OGREODE_CORE_H_
+#define _OGREODE_CORE_H_
+
+#include "OgreOdePreReqs.h"
+#include "OgreOdeUtility.h"
+#include "OgreOdeWorld.h"
+#include "OgreOdeBody.h"
+#include "OgreOdeMass.h"
+#include "OgreOdeJoint.h"
+#include "OgreOdeSpace.h"
+#include "OgreOdeGeometry.h"
+#include "OgreOdeCollision.h"
+#include "OgreOdeStepper.h"
+#include "OgreOdeEntityInformer.h"
+#include "OgreOdeDebugObject.h"
+
+#endif
Index: /code/branches/physics/src/ogreode/OgreOde_LGPL.txt
===================================================================
--- /code/branches/physics/src/ogreode/OgreOde_LGPL.txt	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOde_LGPL.txt	(revision 2122)
@@ -0,0 +1,514 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
+
Index: /code/branches/physics/src/ogreode/OgreOde_licence.txt
===================================================================
--- /code/branches/physics/src/ogreode/OgreOde_licence.txt	(revision 2122)
+++ /code/branches/physics/src/ogreode/OgreOde_licence.txt	(revision 2122)
@@ -0,0 +1,25 @@
+Licence for OgreOde
+===================
+
+Copyright 2004-2005 Ed "Green Eyed Monster" Jones.
+Copyright 2006 Paul "Tuan Kuranes" Cheyrou-Lagrèze.
+
+This file is part of OgreOde an integration layer between the OGRE 3D 
+graphics engine and the ODE rigid body dynamics library.
+
+OgreOde is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+OgreOde is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OgreOde; see the file OgreOde_LGPL.txt If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+
+
Index: /code/branches/physics/src/ogreode/Revision.txt
===================================================================
--- /code/branches/physics/src/ogreode/Revision.txt	(revision 2122)
+++ /code/branches/physics/src/ogreode/Revision.txt	(revision 2122)
@@ -0,0 +1,3 @@
+This source code was taken from revision
+2497
+of the ogreaddons SVN repositories.
Index: /code/branches/physics/src/ois/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/ois/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/ois/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,49 @@
+INCLUDE_DIRECTORIES(.)
+
+SET( OIS_SRC_FILES
+  OISEffect.cpp
+  OISException.cpp
+  OISForceFeedback.cpp
+  OISInputManager.cpp
+  OISJoyStick.cpp
+  OISKeyboard.cpp
+  OISObject.cpp
+)
+
+IF(WIN32)
+  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
+    win32/Win32ForceFeedback.cpp
+    win32/Win32InputManager.cpp
+    win32/Win32JoyStick.cpp
+    win32/Win32KeyBoard.cpp
+    win32/Win32Mouse.cpp
+  )
+ELSEIF (APPLE)
+  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
+    mac/MacHelpers.cpp
+    mac/MacHIDManager.cpp
+    mac/MacInputManager.cpp
+    mac/MacKeyboard.cpp
+    mac/MacMouse.cpp
+  )
+ELSEIF (UNIX)
+  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
+    linux/EventHelpers.cpp
+    linux/LinuxForceFeedback.cpp
+    linux/LinuxInputManager.cpp
+    linux/LinuxJoyStickEvents.cpp
+    linux/LinuxKeyboard.cpp
+    linux/LinuxMouse.cpp
+  )
+ENDIF (WIN32)
+
+ADD_LIBRARY( ois_orxonox SHARED ${OIS_SRC_FILES} )
+
+IF(WIN32)
+  LINK_DIRECTORIES(${DirectX_LIB_DIR})
+  TARGET_LINK_LIBRARIES( ois_orxonox
+    dxguid
+    dinput8
+  )
+ENDIF(WIN32)
+
Index: /code/branches/physics/src/ois/OIS.h
===================================================================
--- /code/branches/physics/src/ois/OIS.h	(revision 2122)
+++ /code/branches/physics/src/ois/OIS.h	(revision 2122)
@@ -0,0 +1,40 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_OISALL_H
+#define OIS_OISALL_H
+
+#include "OISPrereqs.h"
+#include "OISObject.h"
+#include "OISMouse.h"
+#include "OISKeyboard.h"
+#include "OISJoyStick.h"
+#include "OISInputManager.h"
+#include "OISFactoryCreator.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include "OISEffect.h"
+#include "OISInterface.h"
+#include "OISForceFeedback.h"
+
+#endif
Index: /code/branches/physics/src/ois/OISConfig.h
===================================================================
--- /code/branches/physics/src/ois/OISConfig.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISConfig.h	(revision 2122)
@@ -0,0 +1,77 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_CONFIG_HEADER
+#define OIS_CONFIG_HEADER
+
+//----------------------------------------------------------------------------//
+//* This file contains defines for building certain parts of this Lib
+//*	This file is not meant for External inclusion. However, you can edit this 
+//* file before a build to effect what features are used internally
+//----------------------------------------------------------------------------//
+
+/** 
+@remarks
+	These lines have no bearing on internal build of OIS. This is here for
+	external build settings. Meaning, changing this does not require a
+	rebuild of OIS. This just affects VC dll import settings, as the DLL
+	build already defines this during its build for setting dll exports.
+	The undefine here is here just incase you decide to only use
+	DLL, and want to set it permently and recompile OIS too.. Avoid redefinition
+	from DLL build of OIS.
+
+	So, if wanting to link against DLL version, just uncomment these lines.
+*/
+//#ifdef OIS_DYNAMIC_LIB
+//#  undef OIS_DYNAMIC_LIB
+//#endif
+//#define OIS_DYNAMIC_LIB
+
+/**
+@remarks
+	Build in support for LIRC / WinLIRC - remote control support.
+	Requires Boost::asio
+@notes
+	Experimental - Supports connecting and enumerating. Control does not
+	yet return state or events
+*/
+//#define OIS_LIRC_SUPPORT
+
+/**
+@remarks
+	Build in support for PC Nintendo WiiMote Win32 HID interface.
+	Requires Boost::threads
+@notes
+	Useable, but not quite finished - supports rumble, all buttons, & main orientation axis.
+	Still needs Nunchuck, IR, and LED/Battery support.
+*/
+//#define OIS_WIN32_WIIMOTE_SUPPORT
+
+/**
+@remarks
+	Build in support for Win32 XInput (Xbox 360 Controller)
+@notes
+	Not Yet Implemented
+*/
+//#define OIS_WIN32_XINPUT_SUPPORT
+
+#endif
Index: /code/branches/physics/src/ois/OISEffect.cpp
===================================================================
--- /code/branches/physics/src/ois/OISEffect.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/OISEffect.cpp	(revision 2122)
@@ -0,0 +1,93 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISEffect.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//VC7.1 had a problem with these not getting included.. 
+//Perhaps a case of a crazy extreme optimizer :/ (moved to header)
+//const unsigned int Effect::OIS_INFINITE = 0xFFFFFFFF;
+
+//------------------------------------------------------------------------------//
+Effect::Effect() : 
+	force(UnknownForce), 
+	type(Unknown),
+	effect(0),
+	axes(1)
+{
+}
+
+//------------------------------------------------------------------------------//
+Effect::Effect(EForce ef, EType et) : 
+	force(ef), 
+	type(et),
+	direction(North), 
+	trigger_button(-1),
+	trigger_interval(0),
+	replay_length(Effect::OIS_INFINITE),
+	replay_delay(0),
+	_handle(-1),
+	axes(1)
+{
+	effect = 0;
+
+	switch( ef )
+	{
+	case ConstantForce:    effect = new ConstantEffect(); break;
+	case RampForce:	       effect = new RampEffect(); break;
+	case PeriodicForce:    effect = new PeriodicEffect(); break;
+	case ConditionalForce: effect = new ConditionalEffect(); break;
+	default: break;
+	}
+}
+
+//------------------------------------------------------------------------------//
+Effect::~Effect()
+{
+	delete effect;
+}
+
+//------------------------------------------------------------------------------//
+ForceEffect* Effect::getForceEffect() const
+{
+	//If no effect was created in constructor, then we raise an error here
+	if( effect == 0 )
+		OIS_EXCEPT( E_NotSupported, "Requested ForceEffect is null!" );
+
+	return effect;
+}
+
+//------------------------------------------------------------------------------//
+void Effect::setNumAxes(short nAxes)
+{
+	//Can only be set before a handle was assigned (effect created)
+	if( _handle != -1 )
+        axes = nAxes;
+}
+
+//------------------------------------------------------------------------------//
+short Effect::getNumAxes() const
+{
+	return axes;
+}
Index: /code/branches/physics/src/ois/OISEffect.h
===================================================================
--- /code/branches/physics/src/ois/OISEffect.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISEffect.h	(revision 2122)
@@ -0,0 +1,260 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Effect_H
+#define OIS_Effect_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	//Predeclare some Effect Property structs
+	class ForceEffect;
+	class ConstantEffect;
+	class RampEffect;
+	class PeriodicEffect;
+	class ConditionalEffect;
+
+	/**
+		Force Feedback is a relatively complex set of properties to upload to a device.
+		The best place for information on the different properties, effects, etc is in
+		the DX Documentation and MSDN - there are even pretty graphs ther =)
+		As this class is modeled on the the DX interface you can apply that same
+		knowledge to creating effects via this class on any OS supported by OIS.
+
+		In anycase, this is the main class you will be using. There is *absolutely* no
+		need to instance any of the supporting ForceEffect classes yourself.
+	*/
+	class _OISExport Effect
+	{
+		/**
+			hidden so this class cannot be instanced with default constructor
+		*/
+		Effect();
+	public:
+		//! Type of force
+		enum EForce
+		{
+			UnknownForce = 0,
+			ConstantForce,
+			RampForce,
+			PeriodicForce,
+			ConditionalForce,
+			CustomForce
+		};
+
+		//! Type of effect
+		enum EType
+		{
+			//Type ----- Pairs with force:
+			Unknown = 0, //UnknownForce
+			Constant,    //ConstantForce
+			Ramp,        //RampForce
+			Square,      //PeriodicForce
+			Triangle,    //PeriodicForce
+            Sine,        //PeriodicForce
+			SawToothUp,  //PeriodicForce
+			SawToothDown,//PeriodicForce
+			Friction,    //ConditionalForce
+			Damper,      //ConditionalForce
+			Inertia,     //ConditionalForce
+			Spring,      //ConditionalForce
+			Custom       //CustomForce
+		};
+
+		//! Direction of the Force
+		enum EDirection
+		{
+			NorthWest,
+			North,
+			NorthEast,
+			East,
+			SouthEast,
+			South,
+			SouthWest,
+			West
+		};
+
+		/**
+			This constructor allows you to set the force type and effect.
+		*/
+		Effect(EForce ef, EType et);
+		virtual ~Effect();
+
+		const EForce force;
+		const EType type;
+
+		//Infinite Time
+		static const unsigned int OIS_INFINITE = 0xFFFFFFFF;
+
+		//-------------------------------------------------------------------//
+		//--- Set these variables before uploading or modifying an effect ---//
+
+		//Direction to apply to the force - affects two axes+ effects
+		EDirection direction;
+
+		//Number of button triggering an effect (-1 means no trigger)
+		short trigger_button;
+
+		//Time to wait before an effect can be re-triggered (microseconds)
+		unsigned int trigger_interval;
+
+		//Duration of an effect (microseconds)
+		unsigned int replay_length;
+
+		//Time to wait before to start playing an effect (microseconds)
+		unsigned int replay_delay;
+
+		//Get the specific Force Effect. This should be cast depending on the EForce
+		ForceEffect* getForceEffect() const;
+
+		/**
+		@remarks
+			Set the number of Axes to use before the initial creation of the effect.
+			Can only be done prior to creation! Use the FF interface to determine
+			how many axes can be used (are availiable)
+		*/
+		void setNumAxes(short nAxes);
+
+		/**
+		@remarks
+			Returns the number of axes used in this effect
+		*/
+		short getNumAxes() const;
+
+		//------------- Library Internal -------------------------------------//
+		/**
+			set internally.. do not change or you will not be able to upload/stop
+			this effect any more. It will become lost. It is mutable so even
+			with const reference it can/will be changed by this lib
+		*/
+		mutable int _handle;
+	protected:
+		ForceEffect* effect; //Properties depend on EForce
+		short axes;          //Number of axes to use in effect
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Base class of all effect property classes
+	*/
+	class _OISExport ForceEffect
+	{
+	public:
+		virtual ~ForceEffect() {}
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		An optional envelope to be applied to the start/end of an effect. If any of
+		these values are nonzero, then the envelope will be used in setting up the
+		effect. Not currently utilised.. But, will be soon.
+	*/
+	class _OISExport Envelope : public ForceEffect
+	{
+	public:
+		Envelope() : attackLength(0), attackLevel(0), fadeLength(0), fadeLevel(0) {}
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (push)
+  #pragma warning (disable : 4800)
+#endif
+		bool isUsed() { return attackLength | attackLevel | fadeLength | fadeLevel; }
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (pop)
+#endif
+
+		unsigned short attackLength;
+		unsigned short attackLevel;
+		unsigned short fadeLength;
+		unsigned short fadeLevel;
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Constant
+	*/
+	class _OISExport ConstantEffect : public ForceEffect
+	{
+	public:
+		ConstantEffect() : level(5000) {}
+
+		class Envelope envelope; //Optional envolope
+		signed short level;       //-10K to +10k
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Ramp
+	*/
+	class _OISExport RampEffect : public ForceEffect
+	{
+	public:
+		RampEffect() : startLevel(0), endLevel(0) {}
+
+        class Envelope envelope; //Optional envolope
+		signed short startLevel;  //-10K to +10k
+		signed short endLevel;    //-10K to +10k
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Periodic
+	*/
+	class _OISExport PeriodicEffect : public ForceEffect
+	{
+	public:
+		PeriodicEffect() : magnitude(0), offset(0), phase(0), period(0) {}
+
+		class Envelope envelope;  //Optional Envelope
+
+		unsigned short magnitude;  //0 to 10,0000
+		signed short   offset;
+		unsigned short phase;      //Position at which playback begins 0 to 35,999
+		unsigned int   period;     //Period of effect (microseconds)
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Condional
+	*/
+	class _OISExport ConditionalEffect : public ForceEffect
+	{
+	public:
+		ConditionalEffect() :
+            rightCoeff(0), leftCoeff(0), rightSaturation(0), leftSaturation(0),
+			deadband(0), center(0) {}
+
+		signed short   rightCoeff;      //-10k to +10k (Positive Coeff)
+		signed short   leftCoeff;       //-10k to +10k (Negative Coeff)
+
+		unsigned short rightSaturation; //0 to 10k (Pos Saturation)
+		unsigned short leftSaturation;  //0 to 10k (Neg Saturation)
+
+		//Region around center in which the condition is not active, in the range
+		//from 0 through 10,000
+		unsigned short deadband;
+
+		//(Offset in DX) -10k and 10k
+		signed short center;
+	};
+}
+#endif //OIS_Effect_H
Index: /code/branches/physics/src/ois/OISEvents.h
===================================================================
--- /code/branches/physics/src/ois/OISEvents.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISEvents.h	(revision 2122)
@@ -0,0 +1,43 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _OIS_EVENTHEADERS_
+#define _OIS_EVENTHEADERS_
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	/**
+		Base class of all events
+	*/
+	class _OISExport EventArg
+	{
+	public:
+		EventArg( Object* obj ) : device(obj) {}
+		virtual ~EventArg() {}
+
+		//! Pointer to the Input Device
+		const Object* device;
+	};
+}
+
+#endif //_OIS_EVENTHEADERS_
Index: /code/branches/physics/src/ois/OISException.cpp
===================================================================
--- /code/branches/physics/src/ois/OISException.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/OISException.cpp	(revision 2122)
@@ -0,0 +1,32 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISException.h"
+
+using namespace OIS;
+
+//----------------------------------------------------------------------------//
+/*const char* Exception::what() const throw()
+{
+	return eText;
+}
+*/
Index: /code/branches/physics/src/ois/OISException.h
===================================================================
--- /code/branches/physics/src/ois/OISException.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISException.h	(revision 2122)
@@ -0,0 +1,77 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _OIS_EXCEPTION_HEADER_
+#define _OIS_EXCEPTION_HEADER_
+#include "OISPrereqs.h"
+#include <exception>
+
+namespace OIS
+{
+	//! Simple enum's for dealing with exceptions
+    enum OIS_ERROR
+	{
+		E_InputDisconnected,
+		E_InputDeviceNonExistant,
+		E_InputDeviceNotSupported,
+		E_DeviceFull,
+		E_NotSupported,
+		E_NotImplemented,
+		E_Duplicate,
+		E_InvalidParam,
+		E_General
+	};
+
+	/**
+	@remarks
+		Class for handling OIS exceptions. Much cleaner than checking every method for reurn value.
+		Inherits from std::exception so you can simply log those messages if you want to be generic.
+		Also note that this has a source file now since OSX was not finding the OIS::Exception symbol
+		which would cause program abortion with now correponding exception type.
+	*/
+	class _OISExport Exception : public std::exception
+	{
+		//! Hidden default
+		Exception() : eType(E_General), eLine(0), eFile(0) {}
+	public:
+		//! Creates exception object
+		Exception( OIS_ERROR err, const char* str, int line, const char *file )
+			: eType(err), eLine(line), eFile(file), eText(str) {}
+
+		virtual const char* what() const throw()
+            { return eText; }
+
+		//! The type of exception raised
+		const OIS_ERROR eType;
+		//! The line number it occurred on
+		const int eLine;
+		//! The source file
+		const char* eFile;
+		//! A message passed along when the exception was raised
+		const char* eText;
+	};
+}
+
+//! Use this macro to handle exceptions easily
+#define OIS_EXCEPT( err, str ) throw( OIS::Exception(err, str, __LINE__, __FILE__) )
+
+#endif //_OIS_EXCEPTION_HEADER_
Index: /code/branches/physics/src/ois/OISFactoryCreator.h
===================================================================
--- /code/branches/physics/src/ois/OISFactoryCreator.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISFactoryCreator.h	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_FactoryCreator_H
+#define OIS_FactoryCreator_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	/**
+		Interface for creating devices - all devices ultimately get enumerated/created via a factory.
+		A factory can create multiple types of objects.
+	*/
+	class _OISExport FactoryCreator
+	{
+	public:
+		/**
+			@remarks Virtual Destructor
+		*/
+		virtual ~FactoryCreator() {};
+
+		/**
+			@remarks Return a list of all unused devices the factory maintains
+		*/
+		virtual DeviceList freeDeviceList() = 0;
+
+		/**
+			@remarks Number of total devices of requested type
+			@param iType Type of devices to check
+		*/
+		virtual int totalDevices(Type iType) = 0;
+
+		/**
+			@remarks Number of free devices of requested type
+			@param iType Type of devices to check
+		*/
+		virtual int freeDevices(Type iType) = 0;
+
+		/**
+			@remarks Does a Type exist with the given vendor name
+			@param iType Type to check
+			@param vendor Vendor name to test
+		*/
+		virtual bool vendorExist(Type iType, const std::string & vendor) = 0;
+
+		/**
+			@remarks Creates the object
+			@param iType Type to create
+			@param bufferMode True to setup for buffered events
+			@param vendor Create a device with the vendor name, "" means vendor name is unimportant
+		*/
+		virtual Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "") = 0;
+
+		/**
+			@remarks Destroys object
+			@param obj Object to destroy
+		*/
+		virtual void destroyObject(Object* obj) = 0;
+	};
+}
+#endif //OIS_FactoryCreator_H
Index: /code/branches/physics/src/ois/OISForceFeedback.cpp
===================================================================
--- /code/branches/physics/src/ois/OISForceFeedback.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/OISForceFeedback.cpp	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISForceFeedback.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//-------------------------------------------------------------//
+void ForceFeedback::_addEffectTypes( Effect::EForce force, Effect::EType type )
+{
+	if( force == Effect::UnknownForce || type == Effect::Unknown )
+		OIS_EXCEPT( E_General, "Unknown Force||Type was added too effect list..." );
+
+	mSupportedEffects[force] = type;
+}
+
+//-------------------------------------------------------------//
+const ForceFeedback::SupportedEffectList& 
+						ForceFeedback::getSupportedEffects() const
+{
+	return mSupportedEffects;
+}
Index: /code/branches/physics/src/ois/OISForceFeedback.h
===================================================================
--- /code/branches/physics/src/ois/OISForceFeedback.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISForceFeedback.h	(revision 2122)
@@ -0,0 +1,102 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_ForceFeedBack_H
+#define OIS_ForceFeedBack_H
+
+#include "OISPrereqs.h"
+#include "OISInterface.h"
+#include "OISEffect.h"
+
+namespace OIS
+{
+	/**
+		Interface class for dealing with Force Feedback devices
+	*/
+	class _OISExport ForceFeedback : public Interface
+	{
+	public:
+		ForceFeedback() {}
+		virtual ~ForceFeedback() {}
+
+		/**
+		@remarks
+			This is like setting the master volume of an audio device.
+			Individual effects have gain levels; however, this affects all
+			effects at once.
+		@param level
+			A value between 0.0 and 1.0 represent the percentage of gain. 1.0
+			being the highest possible force level (means no scaling).
+		*/
+		virtual void setMasterGain( float level ) = 0;
+		
+		/**
+		@remarks
+			If using Force Feedback effects, this should be turned off
+			before uploading any effects. Auto centering is the motor moving
+			the joystick back to center. DirectInput only has an on/off setting,
+			whereas linux has levels.. Though, we go with DI's on/off mode only
+		@param auto_on
+			true to turn auto centering on, false to turn off.
+		*/
+		virtual void setAutoCenterMode( bool auto_on ) = 0;
+
+		/**
+		@remarks
+			Creates and Plays the effect immediately. If the device is full
+			of effects, it will fail to be uploaded. You will know this by
+			an invalid Effect Handle
+		*/
+		virtual void upload( const Effect* effect ) = 0;
+
+		/**
+		@remarks
+			Modifies an effect that is currently playing
+		*/
+		virtual void modify( const Effect* effect ) = 0;
+
+		/**
+		@remarks
+			Remove the effect from the device
+		*/
+		virtual void remove( const Effect* effect ) = 0;
+
+		/**
+		@remarks
+			Get the number of supported Axes for FF usage
+		*/
+        virtual short getFFAxesNumber() = 0;
+
+		typedef std::map<Effect::EForce, Effect::EType> SupportedEffectList;
+		/**
+		@remarks
+			Get a list of all supported effects
+		*/
+		const SupportedEffectList& getSupportedEffects() const;
+
+		void _addEffectTypes( Effect::EForce force, Effect::EType type );
+
+	protected:
+		SupportedEffectList mSupportedEffects;
+	};
+}
+#endif //OIS_ForceFeedBack_H
Index: /code/branches/physics/src/ois/OISInputManager.cpp
===================================================================
--- /code/branches/physics/src/ois/OISInputManager.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/OISInputManager.cpp	(revision 2122)
@@ -0,0 +1,284 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISInputManager.h"
+#include "OISException.h"
+#include "OISFactoryCreator.h"
+#include "OISObject.h"
+#include <sstream>
+#include <algorithm>
+
+//Bring in correct Header / InputManager for current build platform
+#if defined OIS_SDL_PLATFORM
+#  include "SDL/SDLInputManager.h"
+#elif defined OIS_WIN32_PLATFORM
+#  include "win32/Win32InputManager.h"
+#elif defined OIS_LINUX_PLATFORM
+#  include "linux/LinuxInputManager.h"
+#elif defined OIS_APPLE_PLATFORM
+#  include "mac/MacInputManager.h"
+#elif defined OIS_XBOX_PLATFORM
+#  include "xbox/XBoxInputManager.h"
+#endif
+
+//Bring in extra controls
+#if defined OIS_LIRC_SUPPORT
+#  include "extras/LIRC/OISLIRCFactoryCreator.h"
+#endif
+#if defined OIS_WIN32_WIIMOTE_SUPPORT
+#  include "win32/extras/WiiMote/OISWiiMoteFactoryCreator.h"
+#endif
+
+
+using namespace OIS;
+
+//----------------------------------------------------------------------------//
+InputManager::InputManager(const std::string& name) :
+	m_VersionName(OIS_VERSION_NAME),
+	mInputSystemName(name),
+	m_lircSupport(0),
+	m_wiiMoteSupport(0)
+{
+}
+
+//----------------------------------------------------------------------------//
+InputManager::~InputManager()
+{
+#if defined OIS_LIRC_SUPPORT
+	delete m_lircSupport;
+#endif
+
+#if defined OIS_WIN32_WIIMOTE_SUPPORT
+	delete m_wiiMoteSupport;
+#endif
+}
+
+//----------------------------------------------------------------------------//
+unsigned int InputManager::getVersionNumber()
+{
+	return OIS_VERSION;
+}
+
+//----------------------------------------------------------------------------//
+const std::string &InputManager::getVersionName()
+{
+	return m_VersionName;
+}
+
+//----------------------------------------------------------------------------//
+InputManager* InputManager::createInputSystem( std::size_t windowhandle )
+{
+	ParamList pl;
+	std::ostringstream wnd;
+	wnd << windowhandle;
+	pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() ));
+
+	return createInputSystem( pl );
+}
+
+//----------------------------------------------------------------------------//
+InputManager* InputManager::createInputSystem( ParamList &paramList )
+{
+	InputManager* im = 0;
+
+#if defined OIS_SDL_PLATFORM
+	im = new SDLInputManager();
+#elif defined OIS_WIN32_PLATFORM
+	im = new Win32InputManager();
+#elif defined OIS_XBOX_PLATFORM
+	im = new XBoxInputManager();
+#elif defined OIS_LINUX_PLATFORM
+	im = new LinuxInputManager();
+#elif defined OIS_APPLE_PLATFORM
+	im = new MacInputManager();
+#else
+	OIS_EXCEPT(E_General, "No platform library.. check build platform defines!");
+#endif 
+
+	try
+	{
+		im->_initialize(paramList);
+	}
+	catch(...)
+	{
+		delete im;
+		throw; //rethrow
+	}
+
+	return im;
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::destroyInputSystem(InputManager* manager)
+{
+	if( manager == 0 )
+		return;
+
+	//Cleanup before deleting...
+	for( FactoryCreatedObject::iterator i = manager->mFactoryObjects.begin(); 
+		i != manager->mFactoryObjects.end(); ++i )
+	{
+		i->second->destroyObject( i->first );
+	}
+
+	manager->mFactoryObjects.clear();
+	delete manager;
+}
+
+//--------------------------------------------------------------------------------//
+const std::string& InputManager::inputSystemName()
+{
+	return mInputSystemName;
+}
+
+//--------------------------------------------------------------------------------//
+int InputManager::getNumberOfDevices( Type iType )
+{
+	//Count up all the factories devices
+	int factoyObjects = 0;
+	FactoryList::iterator i = mFactories.begin(), e = mFactories.end();
+	for( ; i != e; ++i )
+		factoyObjects += (*i)->totalDevices(iType);
+
+	return factoyObjects;
+}
+
+//----------------------------------------------------------------------------//
+DeviceList InputManager::listFreeDevices()
+{
+	DeviceList list;
+	FactoryList::iterator i = mFactories.begin(), e = mFactories.end();
+	for( ; i != e; ++i )
+	{
+		DeviceList temp = (*i)->freeDeviceList();
+		list.insert(temp.begin(), temp.end());
+	}
+
+	return list;
+}
+
+//----------------------------------------------------------------------------//
+Object* InputManager::createInputObject( Type iType, bool bufferMode, const std::string &vendor )
+{
+	Object* obj = 0;
+	FactoryList::iterator i = mFactories.begin(), e = mFactories.end();
+	for( ; i != e; ++i)
+	{
+		if( (*i)->freeDevices(iType) > 0 )
+		{
+			if( vendor == "" || (*i)->vendorExist(iType, vendor) )
+			{
+				obj = (*i)->createObject(this, iType, bufferMode, vendor);
+				mFactoryObjects[obj] = (*i);
+				break;
+			}
+		}
+	}
+
+	if(!obj)
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	try
+	{	//Intialize device
+		obj->_initialize();
+	}
+	catch(...)
+	{	//Somekind of error, cleanup and rethrow
+		destroyInputObject(obj);
+		throw;
+	}
+
+	return obj;
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::destroyInputObject( Object* obj )
+{
+	if( obj == 0 )
+		return;
+
+	FactoryCreatedObject::iterator i = mFactoryObjects.find(obj);
+	if( i != mFactoryObjects.end() )
+	{
+		i->second->destroyObject(obj);
+		mFactoryObjects.erase(i);
+	}
+	else
+	{
+		OIS_EXCEPT(E_General, "Object creator not known.");
+	}
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::addFactoryCreator( FactoryCreator* factory )
+{
+	if(factory != 0)
+		mFactories.push_back(factory);
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::removeFactoryCreator( FactoryCreator* factory )
+{
+	if(factory != 0)
+	{
+		//First, destroy all devices created with the factory
+		for( FactoryCreatedObject::iterator i = mFactoryObjects.begin(); i != mFactoryObjects.end(); ++i )
+		{
+			if( i->second == factory )
+			{
+				i->second->destroyObject(i->first);
+				mFactoryObjects.erase(i++);
+			}
+		}
+
+		//Now, remove the factory itself
+		FactoryList::iterator fact = std::find(mFactories.begin(), mFactories.end(), factory);
+		if( fact != mFactories.end() )
+			mFactories.erase(fact);
+	}
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::enableAddOnFactory(AddOnFactories factory)
+{
+#if defined OIS_LIRC_SUPPORT
+	if( factory == AddOn_LIRC || factory == AddOn_All )
+	{
+		if( m_lircSupport == 0 )
+		{
+			m_lircSupport = new LIRCFactoryCreator();
+			addFactoryCreator(m_lircSupport);
+		}
+	}
+#endif
+
+#if defined OIS_WIN32_WIIMOTE_SUPPORT
+	if( factory == AddOn_WiiMote || factory == AddOn_All )
+	{
+		if( m_wiiMoteSupport == 0 )
+		{
+			m_wiiMoteSupport = new WiiMoteFactoryCreator();
+			addFactoryCreator(m_wiiMoteSupport);
+		}
+	}
+#endif
+}
Index: /code/branches/physics/src/ois/OISInputManager.h
===================================================================
--- /code/branches/physics/src/ois/OISInputManager.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISInputManager.h	(revision 2122)
@@ -0,0 +1,205 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_InputManager_H
+#define OIS_InputManager_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	//Forward declare a couple of classes we might use later
+	class LIRCFactoryCreator;
+	class WiiMoteFactoryCreator;
+
+	/**
+		Base Manager class. No longer a Singleton; so feel free to create as many InputManager's as you have
+		windows.
+	*/
+	class _OISExport InputManager
+	{
+	public:
+		/**
+		@remarks
+			Returns version number (useful in DLL/SO libs)
+		@returns
+			Bits: 1-8 Patch number, 9-16 Minor version, 17-32 Major version
+		*/
+		static unsigned int getVersionNumber();
+
+		/**
+		@remarks
+			Returns version string (useful in DLL/SO libs)
+		@returns
+			Version name
+		*/
+		const std::string &getVersionName();
+
+		/**
+		@remarks
+			Creates appropriate input system dependent on platform. 
+		@param winHandle
+			Contains OS specific window handle (such as HWND or X11 Window)
+		@returns
+			A pointer to the created manager, or raises Exception
+		*/
+		static InputManager* createInputSystem( std::size_t winHandle );
+
+		/**
+		@remarks
+			Creates appropriate input system dependent on platform. 
+		@param paramList
+			ParamList contains OS specific info (such as HWND and HINSTANCE for window apps),
+			and access mode.
+		@returns
+			A pointer to the created manager, or raises Exception
+		*/
+		static InputManager* createInputSystem( ParamList &paramList );
+
+		/**
+		@remarks
+			Destroys the InputManager
+		@param manager
+			Manager to destroy
+		*/
+		static void destroyInputSystem(InputManager* manager);
+
+		/**
+		@remarks Gets the name of the current platform input system
+		*/
+		const std::string& inputSystemName();
+
+		/**
+		@remarks
+			Returns the number of the specified OIS::Type devices discovered by OIS
+		@param iType
+			Type that you are interested in
+		*/
+		int getNumberOfDevices( Type iType );
+
+		/**
+		@remarks
+			Lists all unused devices
+		@returns
+			DeviceList which contains Type and vendor of device
+		*/
+		DeviceList listFreeDevices();
+
+		/**
+		@remarks
+			Tries to create an object with the specified vendor. If you have no
+			preference of vendor, leave vender as default (""). Raises exception on failure
+		*/
+		Object* createInputObject( Type iType, bool bufferMode, const std::string &vendor = "");
+
+		/**
+		@remarks Destroys Input Object
+		*/
+		void destroyInputObject( Object* obj );
+
+		/**
+		@remarks
+			Add a custom object factory to allow for user controls.
+		@param factory
+			Factory instance to add
+		@notes
+			Make sure you do not delete the factory before devices created from
+			the factory are destroyed (either by calling RemoveFactoryCreator, or shutting down
+			the input system). Order should be something like the following:
+				* Create Input System
+				* Create Factory Instance
+				* AddFactoryCreator(factory)
+				* Create a device from the InputManager (device created by factory)
+				* One of the follwoing:
+					* removeFactoryCreator(factory)
+					* inputManager->destroyInputObject(obj)
+				* destroyInputSystem(inputManager)
+				* destroy Factory Instance
+			You can safely delete the factory instance once you have removed it or shut down the
+			input manager.
+		*/
+		void addFactoryCreator( FactoryCreator* factory );
+
+		/**
+		@remarks
+			Remove a previously added object factory
+		@param factory
+			Factory object to remove.
+		@notes
+			Removing a factory will automatically destroy any Objects created from the factory
+		*/
+		void removeFactoryCreator( FactoryCreator* factory );
+
+		//! All generic devices OIS supports internally (if they are compiled in)
+		enum AddOnFactories
+		{
+			AddOn_All = 0,		//All Devices
+			AddOn_LIRC = 1,		//PC Linux Infrared Remote Control
+			AddOn_WiiMote = 2	//PC WiiMote Support
+		};
+
+		/**
+		@remarks
+			Enable an addon FactoryCreator extension. By default, none are activated.
+			If the desired support was not compiled in, this has no effect. Calling
+			multiple times has no effect. Once activated, there is no way to deactivate -
+			simply destroy and recreate input manager.
+		*/
+		void enableAddOnFactory(AddOnFactories factory);
+
+	protected:
+		/**
+		@remarks
+			Called from createInputSystem, gives derived input class a chance to setup after it is created
+		*/
+		virtual void _initialize(ParamList &paramList) = 0;
+
+		/**
+		@remarks
+			Derived classes must provide input system name
+		*/
+		InputManager(const std::string& name);
+
+		/**
+		@remarks
+			Virtual Destructor - this base class will clean up all devices still opened in mFactoryObjects list
+		*/
+		virtual ~InputManager();
+
+		//! OIS Version name
+		const std::string m_VersionName;
+
+		//! FactoryCreator list	
+		FactoryList mFactories;
+
+		//! Factory created objects - useful so we can find creator to send destruction request to
+		FactoryCreatedObject mFactoryObjects;
+
+		//! Name of the input system
+		const std::string mInputSystemName;
+
+		//! Extra factory (not enabled by default)
+		LIRCFactoryCreator *m_lircSupport;
+		WiiMoteFactoryCreator *m_wiiMoteSupport;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/OISInterface.h
===================================================================
--- /code/branches/physics/src/ois/OISInterface.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISInterface.h	(revision 2122)
@@ -0,0 +1,47 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Interface_H
+#define OIS_Interface_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	/**
+		An Object's interface is a way to gain write access to devices which support
+		it. For example, force feedack.
+	*/
+	class _OISExport Interface
+	{
+	public:
+		virtual ~Interface() {};
+
+		//! Type of Interface
+		enum IType
+		{
+			ForceFeedback,
+			Reserved
+		};
+	};
+}
+#endif //OIS_Interface_H
Index: /code/branches/physics/src/ois/OISJoyStick.cpp
===================================================================
--- /code/branches/physics/src/ois/OISJoyStick.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/OISJoyStick.cpp	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISJoyStick.h"
+
+using namespace OIS;
+
+//----------------------------------------------------------------------------//
+JoyStick::JoyStick(const std::string &vendor, bool buffered, int devID, InputManager* creator) :
+	Object(vendor, OISJoyStick, buffered, devID, creator),
+	mSliders(0),
+	mPOVs(0),
+	mListener(0),
+	mVector3Sensitivity(OIS_JOYSTICK_VECTOR3_DEFAULT)
+{
+}
+
+//----------------------------------------------------------------------------//
+int JoyStick::getNumberOfComponents(ComponentType cType) const
+{
+	switch( cType )
+	{
+	case OIS_Button:	return (int)mState.mButtons.size();
+	case OIS_Axis:		return (int)mState.mAxes.size();
+	case OIS_Slider:	return mSliders;
+	case OIS_POV:		return mPOVs;
+	case OIS_Vector3:	return (int)mState.mVectors.size();
+	default:			return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+void JoyStick::setVector3Sensitivity(float degrees)
+{
+	mVector3Sensitivity = degrees;
+}
+
+//----------------------------------------------------------------------------//
+float JoyStick::getVector3Sensitivity() const
+{
+	return mVector3Sensitivity;
+}
+
+//----------------------------------------------------------------------------//
+void JoyStick::setEventCallback( JoyStickListener *joyListener )
+{
+	mListener = joyListener;
+}
+
+//----------------------------------------------------------------------------//
+JoyStickListener* JoyStick::getEventCallback() const
+{
+	return mListener;
+}
Index: /code/branches/physics/src/ois/OISJoyStick.h
===================================================================
--- /code/branches/physics/src/ois/OISJoyStick.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISJoyStick.h	(revision 2122)
@@ -0,0 +1,228 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Joystick_H
+#define OIS_Joystick_H
+#include "OISObject.h"
+#include "OISEvents.h"
+
+namespace OIS
+{
+	/** @remarks default sensitivity for vector3 component of joystick */
+	#define OIS_JOYSTICK_VECTOR3_DEFAULT 2.28f
+
+	//! POV / HAT Joystick component
+	class _OISExport Pov : Component
+	{
+	public:
+		Pov() : Component(OIS_POV), direction(0) {}
+
+		static const int Centered  = 0x00000000;
+		static const int North     = 0x00000001;
+		static const int South     = 0x00000010;
+		static const int East      = 0x00000100;
+		static const int West      = 0x00001000;
+		static const int NorthEast = 0x00000101;
+		static const int SouthEast = 0x00000110;
+		static const int NorthWest = 0x00001001;
+		static const int SouthWest = 0x00001010;
+
+		int direction;
+	};
+
+	//! A sliding axis - only used in Win32 Right Now
+	class _OISExport Slider : Component
+	{
+	public:
+		Slider() : Component(OIS_Slider), abX(0), abY(0) {};
+		//! true if pushed, false otherwise
+		int abX, abY;
+	};
+
+	/**
+		Represents the state of the joystick
+		All members are valid for both buffered and non buffered mode
+		Sticks with zero values are not present on the device
+	*/
+	class _OISExport JoyStickState
+	{
+	public:
+		//! Constructor
+		JoyStickState() { clear(); }
+
+		//! Represents all the buttons (uses a bitset)
+		std::vector<bool> mButtons;
+
+		//! Represents all the single axes on the device
+		std::vector<Axis> mAxes;
+
+		//! Represents the value of a POV. Maximum of 4
+		Pov mPOV[4];
+
+		//! Represent the max sliders
+		Slider mSliders[4];
+
+		//! Represents all Vector type controls the device exports
+		std::vector<Vector3> mVectors;
+
+		//! internal method to reset all variables to initial values
+		void clear()
+		{
+			for( std::vector<bool>::iterator i = mButtons.begin(), e = mButtons.end(); i != e; ++i )
+			{
+				(*i) = false;
+			}
+
+			for( std::vector<Axis>::iterator i = mAxes.begin(), e = mAxes.end(); i != e; ++i )
+			{
+				i->absOnly = true; //Currently, joysticks only report Absolute values
+				i->clear();
+			}
+
+			for( std::vector<Vector3>::iterator i = mVectors.begin(), e = mVectors.end(); i != e; ++i )
+			{
+				i->clear();
+			}
+
+			for( int i = 0; i < 4; ++i )
+			{
+				mPOV[i].direction = Pov::Centered;
+				mSliders[i].abX = mSliders[i].abY = 0;
+			}
+		}
+	};
+
+	/** Specialised for joystick events */
+	class _OISExport JoyStickEvent : public EventArg
+	{
+	public:
+		JoyStickEvent( Object* obj, const JoyStickState &st ) : EventArg(obj), state(st) {}
+		virtual ~JoyStickEvent() {}
+
+		const JoyStickState &state;
+	};
+
+	/**
+		To recieve buffered joystick input, derive a class from this, and implement the
+		methods here. Then set the call back to your JoyStick instance with JoyStick::setEventCallback
+		Each JoyStick instance can use the same callback class, as a devID number will be provided
+		to differentiate between connected joysticks. Of course, each can have a seperate
+		callback instead.
+	*/
+	class _OISExport JoyStickListener
+	{
+	public:
+		virtual ~JoyStickListener() {}
+		/** @remarks Joystick button down event */
+		virtual bool buttonPressed( const JoyStickEvent &arg, int button ) = 0;
+		
+		/** @remarks Joystick button up event */
+		virtual bool buttonReleased( const JoyStickEvent &arg, int button ) = 0;
+
+		/** @remarks Joystick axis moved event */
+		virtual bool axisMoved( const JoyStickEvent &arg, int axis ) = 0;
+
+		//-- Not so common control events, so are not required --//
+		//! Joystick Event, and sliderID
+		virtual bool sliderMoved( const JoyStickEvent &, int index) {return true;}
+		
+		//! Joystick Event, and povID
+		virtual bool povMoved( const JoyStickEvent &arg, int index) {return true;}
+
+		//! Joystick Event, and Vector3ID
+		virtual bool vector3Moved( const JoyStickEvent &arg, int index) {return true;}
+	};
+
+	/**
+		Joystick base class. To be implemented by specific system (ie. DirectX joystick)
+		This class is useful as you remain OS independent using this common interface.
+	*/
+	class _OISExport JoyStick : public Object
+	{
+	public:
+		virtual ~JoyStick() {}
+
+		/**
+		@remarks
+			Returns the number of requested components
+		@param cType
+			The ComponentType you are interested in knowing about
+		*/
+		int getNumberOfComponents(ComponentType cType) const;
+
+		/**
+		@remarks
+			Sets a cutoff limit for changes in the Vector3 component for movement to 
+			be ignored. Helps reduce much event traffic for frequent small/sensitive
+			changes
+		@param degrees
+			The degree under which Vector3 events should be discarded
+		*/
+		void setVector3Sensitivity(float degrees = OIS_JOYSTICK_VECTOR3_DEFAULT);
+
+		/**
+		@remarks
+			Returns the sensitivity cutoff for Vector3 Component
+		*/
+		float getVector3Sensitivity() const;
+
+		/**
+		@remarks
+			Register/unregister a JoyStick Listener - Only one allowed for simplicity. If broadcasting
+			is neccessary, just broadcast from the callback you registered.
+		@param joyListener
+			Send a pointer to a class derived from JoyStickListener or 0 to clear the callback
+		*/
+		virtual void setEventCallback( JoyStickListener *joyListener );
+
+		/** @remarks Returns currently set callback.. or null */
+		JoyStickListener* getEventCallback() const;
+
+		/** @remarks Returns the state of the joystick - is valid for both buffered and non buffered mode */
+		const JoyStickState& getJoyStickState() const { return mState; }
+
+		//! The minimal axis value
+		static const int MIN_AXIS = -32768;
+
+		//! The maximum axis value
+		static const int MAX_AXIS = 32767;
+
+	protected:
+		JoyStick(const std::string &vendor, bool buffered, int devID, InputManager* creator);
+
+		//! Number of sliders
+		int mSliders;
+
+		//! Number of POVs
+		int mPOVs;
+
+		//! The JoyStickState structure (contains all component values)
+		JoyStickState mState;
+
+		//! The callback listener
+		JoyStickListener *mListener;
+
+		//! Adjustment factor for orientation vector accuracy
+		float mVector3Sensitivity;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/OISKeyboard.cpp
===================================================================
--- /code/branches/physics/src/ois/OISKeyboard.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/OISKeyboard.cpp	(revision 2122)
@@ -0,0 +1,45 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISKeyboard.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//----------------------------------------------------------------------//
+void Keyboard::setTextTranslation( TextTranslationMode mode )
+{
+	mTextMode = mode;
+}
+
+//----------------------------------------------------------------------//
+bool Keyboard::isModifierDown( Modifier mod ) const
+{
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (push)
+  #pragma warning (disable : 4800)
+#endif
+	return (mModifiers & mod);
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (pop)
+#endif
+}
Index: /code/branches/physics/src/ois/OISKeyboard.h
===================================================================
--- /code/branches/physics/src/ois/OISKeyboard.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISKeyboard.h	(revision 2122)
@@ -0,0 +1,312 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Keyboard_H
+#define OIS_Keyboard_H
+#include "OISObject.h"
+#include "OISEvents.h"
+
+namespace OIS
+{
+	//! Keyboard scan codes
+	enum KeyCode
+	{
+		KC_UNASSIGNED  = 0x00,
+		KC_ESCAPE      = 0x01,
+		KC_1           = 0x02,
+		KC_2           = 0x03,
+		KC_3           = 0x04,
+		KC_4           = 0x05,
+		KC_5           = 0x06,
+		KC_6           = 0x07,
+		KC_7           = 0x08,
+		KC_8           = 0x09,
+		KC_9           = 0x0A,
+		KC_0           = 0x0B,
+		KC_MINUS       = 0x0C,    // - on main keyboard
+		KC_EQUALS      = 0x0D,
+		KC_BACK        = 0x0E,    // backspace
+		KC_TAB         = 0x0F,
+		KC_Q           = 0x10,
+		KC_W           = 0x11,
+		KC_E           = 0x12,
+		KC_R           = 0x13,
+		KC_T           = 0x14,
+		KC_Y           = 0x15,
+		KC_U           = 0x16,
+		KC_I           = 0x17,
+		KC_O           = 0x18,
+		KC_P           = 0x19,
+		KC_LBRACKET    = 0x1A,
+		KC_RBRACKET    = 0x1B,
+		KC_RETURN      = 0x1C,    // Enter on main keyboard
+		KC_LCONTROL    = 0x1D,
+		KC_A           = 0x1E,
+		KC_S           = 0x1F,
+		KC_D           = 0x20,
+		KC_F           = 0x21,
+		KC_G           = 0x22,
+		KC_H           = 0x23,
+		KC_J           = 0x24,
+		KC_K           = 0x25,
+		KC_L           = 0x26,
+		KC_SEMICOLON   = 0x27,
+		KC_APOSTROPHE  = 0x28,
+		KC_GRAVE       = 0x29,    // accent
+		KC_LSHIFT      = 0x2A,
+		KC_BACKSLASH   = 0x2B,
+		KC_Z           = 0x2C,
+		KC_X           = 0x2D,
+		KC_C           = 0x2E,
+		KC_V           = 0x2F,
+		KC_B           = 0x30,
+		KC_N           = 0x31,
+		KC_M           = 0x32,
+		KC_COMMA       = 0x33,
+		KC_PERIOD      = 0x34,    // . on main keyboard
+		KC_SLASH       = 0x35,    // / on main keyboard
+		KC_RSHIFT      = 0x36,
+		KC_MULTIPLY    = 0x37,    // * on numeric keypad
+		KC_LMENU       = 0x38,    // left Alt
+		KC_SPACE       = 0x39,
+		KC_CAPITAL     = 0x3A,
+		KC_F1          = 0x3B,
+		KC_F2          = 0x3C,
+		KC_F3          = 0x3D,
+		KC_F4          = 0x3E,
+		KC_F5          = 0x3F,
+		KC_F6          = 0x40,
+		KC_F7          = 0x41,
+		KC_F8          = 0x42,
+		KC_F9          = 0x43,
+		KC_F10         = 0x44,
+		KC_NUMLOCK     = 0x45,
+		KC_SCROLL      = 0x46,    // Scroll Lock
+		KC_NUMPAD7     = 0x47,
+		KC_NUMPAD8     = 0x48,
+		KC_NUMPAD9     = 0x49,
+		KC_SUBTRACT    = 0x4A,    // - on numeric keypad
+		KC_NUMPAD4     = 0x4B,
+		KC_NUMPAD5     = 0x4C,
+		KC_NUMPAD6     = 0x4D,
+		KC_ADD         = 0x4E,    // + on numeric keypad
+		KC_NUMPAD1     = 0x4F,
+		KC_NUMPAD2     = 0x50,
+		KC_NUMPAD3     = 0x51,
+		KC_NUMPAD0     = 0x52,
+		KC_DECIMAL     = 0x53,    // . on numeric keypad
+		KC_OEM_102     = 0x56,    // < > | on UK/Germany keyboards
+		KC_F11         = 0x57,
+		KC_F12         = 0x58,
+		KC_F13         = 0x64,    //                     (NEC PC98)
+		KC_F14         = 0x65,    //                     (NEC PC98)
+		KC_F15         = 0x66,    //                     (NEC PC98)
+		KC_KANA        = 0x70,    // (Japanese keyboard)
+		KC_ABNT_C1     = 0x73,    // / ? on Portugese (Brazilian) keyboards
+		KC_CONVERT     = 0x79,    // (Japanese keyboard)
+		KC_NOCONVERT   = 0x7B,    // (Japanese keyboard)
+		KC_YEN         = 0x7D,    // (Japanese keyboard)
+		KC_ABNT_C2     = 0x7E,    // Numpad . on Portugese (Brazilian) keyboards
+		KC_NUMPADEQUALS= 0x8D,    // = on numeric keypad (NEC PC98)
+		KC_PREVTRACK   = 0x90,    // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
+		KC_AT          = 0x91,    //                     (NEC PC98)
+		KC_COLON       = 0x92,    //                     (NEC PC98)
+		KC_UNDERLINE   = 0x93,    //                     (NEC PC98)
+		KC_KANJI       = 0x94,    // (Japanese keyboard)
+		KC_STOP        = 0x95,    //                     (NEC PC98)
+		KC_AX          = 0x96,    //                     (Japan AX)
+		KC_UNLABELED   = 0x97,    //                        (J3100)
+		KC_NEXTTRACK   = 0x99,    // Next Track
+		KC_NUMPADENTER = 0x9C,    // Enter on numeric keypad
+		KC_RCONTROL    = 0x9D,
+		KC_MUTE        = 0xA0,    // Mute
+		KC_CALCULATOR  = 0xA1,    // Calculator
+		KC_PLAYPAUSE   = 0xA2,    // Play / Pause
+		KC_MEDIASTOP   = 0xA4,    // Media Stop
+		KC_VOLUMEDOWN  = 0xAE,    // Volume -
+		KC_VOLUMEUP    = 0xB0,    // Volume +
+		KC_WEBHOME     = 0xB2,    // Web home
+		KC_NUMPADCOMMA = 0xB3,    // , on numeric keypad (NEC PC98)
+		KC_DIVIDE      = 0xB5,    // / on numeric keypad
+		KC_SYSRQ       = 0xB7,
+		KC_RMENU       = 0xB8,    // right Alt
+		KC_PAUSE       = 0xC5,    // Pause
+		KC_HOME        = 0xC7,    // Home on arrow keypad
+		KC_UP          = 0xC8,    // UpArrow on arrow keypad
+		KC_PGUP        = 0xC9,    // PgUp on arrow keypad
+		KC_LEFT        = 0xCB,    // LeftArrow on arrow keypad
+		KC_RIGHT       = 0xCD,    // RightArrow on arrow keypad
+		KC_END         = 0xCF,    // End on arrow keypad
+		KC_DOWN        = 0xD0,    // DownArrow on arrow keypad
+		KC_PGDOWN      = 0xD1,    // PgDn on arrow keypad
+		KC_INSERT      = 0xD2,    // Insert on arrow keypad
+		KC_DELETE      = 0xD3,    // Delete on arrow keypad
+		KC_LWIN        = 0xDB,    // Left Windows key
+		KC_RWIN        = 0xDC,    // Right Windows key
+		KC_APPS        = 0xDD,    // AppMenu key
+		KC_POWER       = 0xDE,    // System Power
+		KC_SLEEP       = 0xDF,    // System Sleep
+		KC_WAKE        = 0xE3,    // System Wake
+		KC_WEBSEARCH   = 0xE5,    // Web Search
+		KC_WEBFAVORITES= 0xE6,    // Web Favorites
+		KC_WEBREFRESH  = 0xE7,    // Web Refresh
+		KC_WEBSTOP     = 0xE8,    // Web Stop
+		KC_WEBFORWARD  = 0xE9,    // Web Forward
+		KC_WEBBACK     = 0xEA,    // Web Back
+		KC_MYCOMPUTER  = 0xEB,    // My Computer
+		KC_MAIL        = 0xEC,    // Mail
+		KC_MEDIASELECT = 0xED     // Media Select
+	};
+
+	/**
+		Specialised for key events
+	*/
+	class _OISExport KeyEvent : public EventArg
+	{
+	public:
+		KeyEvent( Object* obj, KeyCode kc, unsigned int txt ) : EventArg(obj), key(kc), text(txt) {}
+		virtual ~KeyEvent() {}
+
+		//! KeyCode of event
+		const KeyCode key;
+		//! Text character, depends on current TextTranslationMode
+		unsigned int text;
+	};
+
+	/**
+		To recieve buffered keyboard input, derive a class from this, and implement the
+		methods here. Then set the call back to your Keyboard instance with Keyboard::setEventCallback
+	*/
+	class _OISExport KeyListener
+	{
+	public:
+		virtual ~KeyListener() {}
+		virtual bool keyPressed( const KeyEvent &arg ) = 0;
+		virtual bool keyReleased( const KeyEvent &arg ) = 0;		
+	};
+
+	/**
+		Keyboard base class. To be implemented by specific system (ie. DirectX Keyboard)
+		This class is useful as you remain OS independent using this common interface.
+	*/
+	class _OISExport Keyboard : public Object
+	{
+	public:
+		virtual ~Keyboard() {};
+		
+		/**
+		@remarks
+			Returns true if key is donwn
+		@param key
+			A KeyCode to check
+		*/
+		virtual bool isKeyDown( KeyCode key ) const = 0;
+
+		/**
+		@remarks
+			Register/unregister a Keyboard Listener - Only one allowed for simplicity. If broadcasting
+			is neccessary, just broadcast from the callback you registered.
+		@param keyListener
+			Send a pointer to a class derived from KeyListener or 0 to clear the callback
+		*/
+		virtual void setEventCallback( KeyListener *keyListener ) { mListener = keyListener;}
+
+		/**
+		@remarks
+			Returns currently set callback.. or 0
+		*/
+		KeyListener* getEventCallback() const {return mListener;}
+
+		//! TextTranslation Mode
+		enum TextTranslationMode
+		{
+			Off,
+			Unicode,
+			Ascii
+		};
+
+		/**
+		@remarks
+			Enable extra processing to translate KC_*** to an
+			actual text character based off of locale. Different 
+			managers may implement none or all. Check the 
+			translation mode after setting to be sure
+		@param mode
+			Off, Unicode, Ascii
+		*/
+		virtual void setTextTranslation( TextTranslationMode mode );
+
+		/**
+		@remarks
+			Returns current translation mode
+		*/
+		TextTranslationMode getTextTranslation() const {return mTextMode;}
+		
+		/**
+		@remarks
+			Translates KeyCode to string representation.
+			For example, KC_ENTER will be "Enter" - Locale
+			specific of course.
+		@param kc
+			KeyCode to convert
+		@returns
+			The string as determined from the current locale
+		*/
+		virtual const std::string& getAsString( KeyCode kc ) = 0;
+
+		//! Enum of bit position of modifer
+		enum Modifier
+		{
+			Shift = 0x0000001,
+			Ctrl  = 0x0000010,
+			Alt   = 0x0000100
+		};
+
+		/**
+		@remarks
+			Check modifier status
+		*/
+		bool isModifierDown( Modifier mod ) const;
+
+		/**
+		@remarks
+			Copies the state of the keys into the sent buffer
+			(in the form of 1 is down and 0 is up)
+		*/
+		virtual void copyKeyStates( char keys[256] ) const = 0;
+		
+	protected:
+		Keyboard(const std::string &vendor, bool buffered, int devID, InputManager* creator)
+			: Object(vendor, OISKeyboard, buffered, devID, creator),
+			mModifiers(0), mListener(0), mTextMode(Unicode) {}
+
+		//! Bit field that holds status of Alt, Ctrl, Shift
+		unsigned int mModifiers;
+
+		//! Used for buffered/actionmapping callback
+		KeyListener *mListener;
+
+		//! The current translation mode
+		TextTranslationMode mTextMode;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/OISMouse.h
===================================================================
--- /code/branches/physics/src/ois/OISMouse.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISMouse.h	(revision 2122)
@@ -0,0 +1,138 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Mouse_H
+#define OIS_Mouse_H
+#include "OISObject.h"
+#include "OISEvents.h"
+
+namespace OIS
+{
+	//! Button ID for mouse devices
+	enum MouseButtonID
+	{
+		MB_Left = 0, MB_Right, MB_Middle,
+		MB_Button3, MB_Button4,	MB_Button5, MB_Button6,	MB_Button7
+	};
+
+	/**
+		Represents the state of the mouse
+		All members are valid for both buffered and non buffered mode
+	*/
+	class _OISExport MouseState
+	{
+	public:
+		MouseState() : width(50), height(50), buttons(0) {};
+
+		/** Represents the height/width of your display area.. used if mouse clipping
+		or mouse grabbed in case of X11 - defaults to 50.. Make sure to set this
+		and change when your size changes.. */
+		mutable int width, height;
+
+		//! X Axis component
+		Axis X;
+
+		//! Y Axis Component
+		Axis Y;
+
+		//! Z Axis Component
+		Axis Z;
+
+		//! represents all buttons - bit position indicates button down
+		int buttons;
+
+		//! Button down test
+		inline bool buttonDown( MouseButtonID button ) const
+		{
+			return ((buttons & ( 1L << button )) == 0) ? false : true;
+		}
+
+		//! Clear all the values
+		void clear()
+		{
+			X.clear();
+			Y.clear();
+			Z.clear();
+			buttons = 0;
+		}
+	};
+
+	/** Specialised for mouse events */
+	class _OISExport MouseEvent : public EventArg
+	{
+	public:
+		MouseEvent( Object *obj, const MouseState &ms )	: EventArg(obj), state(ms) {}
+		virtual ~MouseEvent() {}
+
+		//! The state of the mouse - including buttons and axes
+		const MouseState &state;
+	};
+
+	/**
+		To recieve buffered mouse input, derive a class from this, and implement the
+		methods here. Then set the call back to your Mouse instance with Mouse::setEventCallback
+	*/
+	class _OISExport MouseListener
+	{
+	public:
+		virtual ~MouseListener() {}
+		virtual bool mouseMoved( const MouseEvent &arg ) = 0;
+		virtual bool mousePressed( const MouseEvent &arg, MouseButtonID id ) = 0;
+		virtual bool mouseReleased( const MouseEvent &arg, MouseButtonID id ) = 0;
+	};
+
+	/**
+		Mouse base class. To be implemented by specific system (ie. DirectX Mouse)
+		This class is useful as you remain OS independent using this common interface.
+	*/
+	class _OISExport Mouse : public Object
+	{
+	public:
+		virtual ~Mouse() {}
+
+		/**
+		@remarks
+			Register/unregister a Mouse Listener - Only one allowed for simplicity. If broadcasting
+			is neccessary, just broadcast from the callback you registered.
+		@param mouseListener
+			Send a pointer to a class derived from MouseListener or 0 to clear the callback
+		*/
+		virtual void setEventCallback( MouseListener *mouseListener ) {mListener = mouseListener;}
+
+		/** @remarks Returns currently set callback.. or 0 */
+		MouseListener* getEventCallback() const {return mListener;}
+
+		/** @remarks Returns the state of the mouse - is valid for both buffered and non buffered mode */
+		const MouseState& getMouseState() const { return mState; }
+
+	protected:
+		Mouse(const std::string &vendor, bool buffered, int devID, InputManager* creator)
+			: Object(vendor, OISMouse, buffered, devID, creator), mListener(0) {}
+
+		//! The state of the mouse
+		MouseState mState;
+
+		//! Used for buffered/actionmapping callback
+		MouseListener *mListener;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/OISObject.cpp
===================================================================
--- /code/branches/physics/src/ois/OISObject.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/OISObject.cpp	(revision 2122)
@@ -0,0 +1,23 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+//#include "OISObject.h"
Index: /code/branches/physics/src/ois/OISObject.h
===================================================================
--- /code/branches/physics/src/ois/OISObject.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISObject.h	(revision 2122)
@@ -0,0 +1,95 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Object_H
+#define OIS_Object_H
+
+#include "OISPrereqs.h"
+#include "OISInterface.h"
+
+namespace OIS
+{
+	/**	The base class of all input types. */
+	class _OISExport Object
+	{
+	public:
+		virtual ~Object() {}
+
+		/**	@remarks Get the type of device	*/
+		Type type() const { return mType; }
+
+		/**	@remarks Get the vender string name	*/
+		const std::string& vendor() const { return mVendor; }
+
+		/**	@remarks Get buffered mode - true is buffered, false otherwise */
+		virtual bool buffered() const { return mBuffered; }
+
+		/** @remarks Returns this input object's creator */
+		InputManager* getCreator() const { return mCreator; }
+
+		/** @remarks Sets buffered mode	*/
+		virtual void setBuffered(bool buffered) = 0;
+
+		/**	@remarks Used for updating call once per frame before checking state or to update events */
+		virtual void capture() = 0;
+
+		/**	@remarks This may/may not) differentiate the different controllers based on (for instance) a port number (useful for console InputManagers) */
+		virtual int getID() const {return mDevID;}
+
+		/**
+		@remarks
+			If available, get an interface to write to some devices.
+			Examples include, turning on and off LEDs, ForceFeedback, etc
+		@param type
+			The type of interface you are looking for
+		*/
+		virtual Interface* queryInterface(Interface::IType type) = 0;
+
+		/**	@remarks Internal... Do not call this directly. */
+		virtual void _initialize() = 0;
+
+	protected:
+		Object(const std::string &vendor, Type iType, bool buffered,
+			   int devID, InputManager* creator) :
+					mVendor(vendor),
+					mType(iType),
+					mBuffered(buffered),
+					mDevID(devID),
+					mCreator(creator) {}
+
+		//! Vendor name if applicable/known
+		std::string mVendor;
+
+		//! Type of controller object
+		Type mType;
+
+		//! Buffered flag
+		bool mBuffered;
+
+		//! Not fully implemented yet
+		int mDevID;
+
+		//! The creator who created this object
+		InputManager* mCreator;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/OISPrereqs.h
===================================================================
--- /code/branches/physics/src/ois/OISPrereqs.h	(revision 2122)
+++ /code/branches/physics/src/ois/OISPrereqs.h	(revision 2122)
@@ -0,0 +1,217 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Prereqs_H
+#define OIS_Prereqs_H
+//----------------------------------------------------------------------------//
+// This Header File contains: forward declared classes
+//  * Forward Declarations of all public API classes
+//  * Several typedef's used around the library
+//  * Base class component types
+//  * Preprocessor definitons
+//----------------------------------------------------------------------------//
+
+//-------------- Common STL Containers ---------------------------------------//
+#include <vector>
+#include <string>
+#include <map>
+#include "OISConfig.h"
+
+// Default is blank for most OS's
+#define _OISExport
+
+//-------------- Determine Compiler ---------------------------------
+#if defined( _MSC_VER )
+#	define OIS_MSVC_COMPILER
+#elif defined( __GNUC__ )
+#	if defined( __WIN32__ ) || defined( _WIN32 )
+#		define OIS_MINGW_COMPILER
+#	else
+#		define OIS_GCC_COMPILER
+#	endif
+#elif defined( __BORLANDC__ )
+#	define OIS_BORLAND_COMPILER
+#else
+#	error No Recognized Compiler!
+#endif
+
+// --------------- Determine Operating System Platform ---------------
+#if defined( __WIN32__ ) || defined( _WIN32 ) // Windows 2000, XP, ETC
+#	if defined ( _XBOX )
+#		define OIS_XBOX_PLATFORM
+#	else
+#		define OIS_WIN32_PLATFORM
+#		if defined( OIS_DYNAMIC_LIB )
+#			undef _OISExport
+			//Ignorable Dll interface warning...
+#           if !defined(OIS_MINGW_COMPILER)
+#			    pragma warning (disable : 4251)
+#           endif
+#			if defined( OIS_NONCLIENT_BUILD )
+#				define _OISExport __declspec( dllexport )
+#			else
+#               if defined(OIS_MINGW_COMPILER)
+#                   define _OISExport
+#               else
+#				    define _OISExport __declspec( dllimport )
+#               endif
+#			endif
+#		endif
+#	endif
+#elif defined( __APPLE_CC__ ) // Apple OS X
+#	define OIS_APPLE_PLATFORM
+#	undef _OISExport
+#	define _OISExport __attribute__((visibility("default")))
+#else //Probably Linux
+#	define OIS_LINUX_PLATFORM
+#endif
+
+//Is Processor 32 or 64 bits...
+#if defined(__x86_64__)
+#	define OIS_ARCH_64
+#else
+#	define OIS_ARCH_32
+#endif
+
+//-------------- Common Classes, Enums, and Typdef's -------------------------//
+#define OIS_VERSION_MAJOR 1
+#define OIS_VERSION_MINOR 2 
+#define OIS_VERSION_PATCH 0
+#define OIS_VERSION_NAME "Smash"
+
+#define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
+
+namespace OIS
+{
+	//Forward Declarations
+	class InputManager;
+	class FactoryCreator;
+	class Object;
+	class Keyboard;
+	class Mouse;
+	class JoyStick;
+	class KeyListener;
+	class MouseListener;
+	class JoyStickListener;
+	class Interface;
+	class ForceFeedback;
+	class Effect;
+	class Exception;
+
+	//! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags
+	typedef std::multimap<std::string, std::string> ParamList;
+
+	//! List of FactoryCreator's
+	typedef std::vector<FactoryCreator*> FactoryList;
+
+	//! Map of FactoryCreator created Objects
+	typedef std::map<Object*, FactoryCreator*> FactoryCreatedObject;
+
+	//! Each Input class has a General Type variable, a form of RTTI
+    enum Type
+	{
+		OISUnknown   = 0,
+		OISKeyboard  = 1,
+		OISMouse     = 2,
+		OISJoyStick  = 3,
+		OISTablet    = 4
+	};
+
+	//! Map of device objects connected and their respective vendors
+	typedef std::multimap<Type, std::string> DeviceList;
+
+	//--------     Shared common components    ------------------------//
+
+	//! Base type for all device components (button, axis, etc)
+    enum ComponentType
+	{
+		OIS_Unknown = 0,
+		OIS_Button  = 1, //ie. Key, mouse button, joy button, etc
+		OIS_Axis    = 2, //ie. A joystick or mouse axis
+		OIS_Slider  = 3, //
+		OIS_POV     = 4, //ie. Arrow direction keys
+		OIS_Vector3 = 5  //ie. WiiMote orientation
+	};
+
+	//! Base of all device components (button, axis, etc)
+	class _OISExport Component
+	{
+	public:
+		Component() : cType(OIS_Unknown) {};
+		Component(ComponentType type) : cType(type) {};
+		//! Indicates what type of coponent this is
+		ComponentType cType;
+	};
+
+	//! Button can be a keyboard key, mouse button, etc
+	class _OISExport Button : public Component
+	{
+	public:
+		Button() {}
+		Button(bool bPushed) : Component(OIS_Button), pushed(bPushed) {};
+		//! true if pushed, false otherwise
+		bool pushed;
+	};
+
+	//! Axis component
+	class _OISExport Axis : public Component
+	{
+	public:
+		Axis() : Component(OIS_Axis), abs(0), rel(0), absOnly(false) {};
+
+		//! Absoulte and Relative value components
+		int abs, rel;
+
+		//! Indicates if this Axis only supports Absoulte (ie JoyStick)
+		bool absOnly;
+
+		//! Used internally by OIS
+		void clear()
+		{
+			abs = rel = 0;
+		}
+	};
+
+	//! A 3D Vector component (perhaps an orientation, as in the WiiMote)
+	class _OISExport Vector3 : public Component
+	{
+	public:
+		Vector3() {}
+		Vector3(float _x, float _y, float _z) : Component(OIS_Vector3), x(_x), y(_y), z(_z) {};
+		
+		//! X component of vector
+		float x;
+		
+		//! Y component of vector
+		float y;
+
+		//! Z component of vector
+		float z;
+
+		void clear()
+		{
+			x = y = z = 0.0f;
+		}
+	};
+}
+
+#endif //end if prereq header defined
Index: /code/branches/physics/src/ois/ReadMe.txt
===================================================================
--- /code/branches/physics/src/ois/ReadMe.txt	(revision 2122)
+++ /code/branches/physics/src/ois/ReadMe.txt	(revision 2122)
@@ -0,0 +1,87 @@
+======================================================================================
+================ LICENSE =============================================================
+======================================================================================
+
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no 
+event will the authors be held liable for any damages arising from the use of this 
+software.
+
+Permission is granted to anyone to use this software for any purpose, including 
+commercial applications, and to alter it and redistribute it freely, subject to the 
+following restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated 
+		but is not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+
+
+======================================================================================
+================ LICENSE EXPLAINED ===================================================
+======================================================================================
+In case the license was not clear enough... Basically, you can link with this lib 
+which puts no restrictions on what you have to license your code as. You can modify 
+this lib, and not have release your changes. Though, as explained above, <bold> 
+Altered source versions must be plainly marked as such, and must not be misrepresented
+as being the original software </bold>
+
+This is to allow users the greatest flexibility in what you can use this lib for.
+
+======================================================================================
+================ INFO ================================================================
+======================================================================================
+
+Cross Platform Object Oriented Input Lib System. Meant to be very robust and 
+compatiable with many systems and operating systems
+
+Win32/
+	Contains Visual Studio .Net Solution Files
+	Contains CodeBlocks + MinGW + StlPort project files for OIS
+	
+	---- Dependencies ------------------------------------------------------
+	DirectInput 8
+	Ogre & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
+
+	SDL/
+		A test bed for an OIS InputManager with SDL as the backend. Not recommended;
+		however, useful for platforms with non-native OIS ports for temporary use.
+
+Linux/
+	---- Dependencies ------------------------------------------------------
+	X11
+	Ogre (GLX Platform) & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
+        Newer Linux Kernel (2.6+ ?) for Event API - else, use --disable-joyevents
+
+	Steps to build on Linux:
+	./bootstrap
+	./configure
+	./make && make install
+
+	---- Configure build options --------------------------------------------
+	./configure --help              --- List all configure options
+	./configure --disable-ogre      --- Disables CEGUIOgre ActionMapping Demo
+	./configure --disable-joyevents --- Uses /dev/input/jsX instead of 
+	                                    /dev/input/eventX
+
+LinuxCB/
+        Contains CodeBlock files for building OIS and Demos with codeblocks
+        This project file looks for Ogre and other dependencies in /usr/local/lib
+        and /usr/local/include. If installed elsewhere, modify the project
+        settings. It also installs libOIS to ~/libs
+
+Mac/
+	
+	XCode-1.5/
+		Non-complete native OIS port.
+
+	XCode-2.2/
+		Working, complete, OIS port to OSX using SDL as a backend.
Index: /code/branches/physics/src/ois/linux/EventHelpers.cpp
===================================================================
--- /code/branches/physics/src/ois/linux/EventHelpers.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/linux/EventHelpers.cpp	(revision 2122)
@@ -0,0 +1,242 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/EventHelpers.h"
+#include "linux/LinuxPrereqs.h"
+#include "linux/LinuxForceFeedback.h"
+#include "OISException.h"
+#include "OISJoyStick.h"
+
+#include <linux/input.h>
+#include <cstring>
+
+//#define OIS_LINUX_JOY_DEBUG
+
+#ifdef OIS_LINUX_JOY_DEBUG
+# include <iostream>
+  using namespace std;
+#endif
+
+using namespace OIS;
+
+class DeviceComponentInfo
+{
+public:
+	std::vector<int> buttons, relAxes, absAxes, hats;
+};
+
+bool inline isBitSet(unsigned long bits[], unsigned int bit)
+{
+	return (bits[bit/(sizeof(long)*8)] >> ((bit)%(sizeof(long)*8))) & 1;
+}
+//-----------------------------------------------------------------------------//
+DeviceComponentInfo getComponentInfo( int deviceID )
+{
+	unsigned long info[2][((KEY_MAX-1)/(sizeof(long)*8)) +1];
+	memset( info, 0, sizeof(info) );
+
+	DeviceComponentInfo components;
+
+	//Read "all" (hence 0) components of the device - read into first entry
+	ioctl(deviceID, EVIOCGBIT(0, EV_MAX), info[0]);
+
+	for (int i = 0; i < EV_MAX; i++)
+	{
+		if( isBitSet(info[0], i) )
+		{
+			memset( info[1], 0, sizeof(info) / 2 );
+			ioctl(deviceID, EVIOCGBIT(i, KEY_MAX), info[1]);
+			for (int j = 0; j < KEY_MAX; j++)
+			{
+				if( isBitSet(info[1], j) )
+				{
+					if(i == EV_ABS)
+					{
+						//input_absinfo abInfo;
+						//ioctl( fd, EVIOCGABS(j), abInfo );
+						if( j >= ABS_HAT0X && j <= ABS_HAT3Y )
+						{
+							components.hats.push_back(j);
+						}
+						else
+						{
+							components.absAxes.push_back(j);
+							//input_absinfo absinfo;
+							//ioctl(deviceID, EVIOCGABS(j), &absinfo);
+							//We cannot actually change these values :|
+							//absinfo.minimum = JoyStick::MIN_AXIS;
+							//absinfo.maximum = JoyStick::MAX_AXIS;
+							//ioctl(deviceID, EVIOCSABS(j), &absinfo);
+						}
+					}
+					else if(i == EV_REL)
+					{
+						components.relAxes.push_back(j);
+					}
+					else if(i == EV_KEY)
+					{
+						components.buttons.push_back(j);
+					}
+				}
+			}
+		}
+	}
+
+	return components;
+}
+
+//-----------------------------------------------------------------------------//
+bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
+{
+	if( deviceID == -1 ) OIS_EXCEPT( E_General, "Error with File Descriptor" );
+
+	DeviceComponentInfo info = getComponentInfo( deviceID );
+
+	int buttons = 0;
+	bool joyButtonFound = false;
+	js.button_map.clear();
+
+	#ifdef OIS_LINUX_JOY_DEBUG
+	  cout << "\n\nDisplaying ButtonMapping Status:";
+	#endif
+	for(std::vector<int>::iterator i = info.buttons.begin(), e = info.buttons.end(); i != e; ++i )
+	{
+		//Check to ensure we find at least one joy only button
+		if( (*i >= BTN_JOYSTICK && *i <= BTN_THUMBR) || (*i >= BTN_WHEEL && *i <= BTN_GEAR_UP ) )
+			joyButtonFound = true;
+
+		js.button_map[*i] = buttons++;
+
+		#ifdef OIS_LINUX_JOY_DEBUG
+		  cout << "\nButton Mapping ID (hex): " << hex << *i << " OIS Button Num: " << dec << (buttons-1);
+		#endif
+	}
+
+	//Joy Buttons found, so it must be a joystick or pad
+	if( joyButtonFound )
+	{
+		js.joyFileD = deviceID;
+		js.vendor = getName(deviceID);
+		js.buttons = buttons;
+		js.axes = info.relAxes.size() + info.absAxes.size();
+		js.hats = info.hats.size();
+
+		//Map the Axes
+		#ifdef OIS_LINUX_JOY_DEBUG
+		  cout << "\n\nDisplaying AxisMapping Status:";
+		#endif
+		int axes = 0;
+		for(std::vector<int>::iterator i = info.absAxes.begin(), e = info.absAxes.end(); i != e; ++i )
+		{
+			js.axis_map[*i] = axes;
+
+			input_absinfo absinfo;
+			ioctl(deviceID, EVIOCGABS(*i), &absinfo);
+			js.axis_range[axes] = Range(absinfo.minimum, absinfo.maximum);
+
+			#ifdef OIS_LINUX_JOY_DEBUG
+			  cout << "\nAxis Mapping ID (hex): " << hex << *i << " OIS Axis Num: " << dec << axes;
+			#endif
+
+			++axes;
+		}
+	}
+
+	return joyButtonFound;
+}
+
+//-----------------------------------------------------------------------------//
+std::string EventUtils::getName( int deviceID )
+{
+	char name[OIS_DEVICE_NAME];
+	ioctl(deviceID, EVIOCGNAME(OIS_DEVICE_NAME), name);
+	return std::string(name);
+}
+
+//-----------------------------------------------------------------------------//
+void EventUtils::enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff )
+{
+	//Linux Event to OIS Event Mappings
+	std::map<int, Effect::EType> typeMap;
+	typeMap[FF_CONSTANT] = Effect::Constant;
+	typeMap[FF_RAMP]     = Effect::Ramp;
+	typeMap[FF_SPRING]   = Effect::Spring;
+	typeMap[FF_FRICTION] = Effect::Friction;
+	typeMap[FF_SQUARE]   = Effect::Square;
+	typeMap[FF_TRIANGLE] = Effect::Triangle;
+	typeMap[FF_SINE]     = Effect::Sine;
+	typeMap[FF_SAW_UP]   = Effect::SawToothUp;
+	typeMap[FF_SAW_DOWN] = Effect::SawToothDown;
+	typeMap[FF_DAMPER]   = Effect::Damper;
+	typeMap[FF_INERTIA]  = Effect::Inertia;
+	typeMap[FF_CUSTOM]   = Effect::Custom;
+
+	std::map<int, Effect::EForce> forceMap;
+	forceMap[FF_CONSTANT] = Effect::ConstantForce;
+	forceMap[FF_RAMP] = Effect::RampForce;
+	forceMap[FF_PERIODIC] = Effect::PeriodicForce;
+	forceMap[FF_CUSTOM] = Effect::CustomForce;
+
+	//Remove any previously existing memory and create fresh
+	removeForceFeedback( ff );
+	*ff = new LinuxForceFeedback();
+
+	unsigned long info[4] = {0,0,0,0};
+	unsigned long subinfo[4]= {0,0,0,0};
+
+	//Read overall force feedback components of the device
+	ioctl(deviceID, EVIOCGBIT(EV_FF, sizeof(long)*4), info);
+
+	//FF Axes
+	//if( isBitSet(info, ABS_X) ) //X Axis
+	//if( isBitSet(info, ABS_Y) ) //Y Axis
+	//if( isBitSet(info, ABS_WHEEL) ) //Wheel
+
+	//FF Effects
+	for( int effect = ABS_WHEEL+1; effect < FF_MAX; effect++ )
+	{
+		if(isBitSet(info, effect))
+		{
+			//std::cout << "\tEffect Type: " << effect << std::endl;
+			memset(subinfo, 0, sizeof(subinfo));
+			//Read any info about this supported effect
+			ioctl(deviceID, EVIOCGBIT(effect, sizeof(long)*4), subinfo);
+			for( int force = 0; force < FF_MAX; force++ )
+			{
+				if(isBitSet(subinfo, force))
+					(*ff)->_addEffectTypes( forceMap[force], typeMap[effect] );
+			}
+		}
+	}
+
+	//Check to see if any effects were added, else destroy the pointer
+	const ForceFeedback::SupportedEffectList &list = (*ff)->getSupportedEffects();
+	if( list.size() == 0 )
+		removeForceFeedback( ff );
+}
+
+//-----------------------------------------------------------------------------//
+void EventUtils::removeForceFeedback( LinuxForceFeedback** ff )
+{
+	delete *ff;
+	*ff = 0;
+}
Index: /code/branches/physics/src/ois/linux/EventHelpers.h
===================================================================
--- /code/branches/physics/src/ois/linux/EventHelpers.h	(revision 2122)
+++ /code/branches/physics/src/ois/linux/EventHelpers.h	(revision 2122)
@@ -0,0 +1,47 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_OISEVENT_HEADER_
+#define _LINUX_OISEVENT_HEADER_
+
+#include "linux/LinuxPrereqs.h"
+
+#define OIS_MAX_DEVICES 32
+#define OIS_DEVICE_NAME 128
+
+namespace OIS
+{
+	class EventUtils
+	{
+	public:
+		static bool isJoyStick( int deviceID, JoyStickInfo &js );
+		static bool isMouse( int ) {return false;}
+		static bool isKeyboard( int ) {return false;}
+
+		//Double pointer is so that we can set the value of the sent pointer
+		static void enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff );
+		static void removeForceFeedback( LinuxForceFeedback** ff );
+
+		static std::string getName( int deviceID );
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/linux/LinuxForceFeedback.cpp
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxForceFeedback.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxForceFeedback.cpp	(revision 2122)
@@ -0,0 +1,61 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/LinuxForceFeedback.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//--------------------------------------------------------------//
+LinuxForceFeedback::LinuxForceFeedback()
+{
+}
+//--------------------------------------------------------------//
+LinuxForceFeedback::~LinuxForceFeedback()
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::setMasterGain(float)
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::setAutoCenterMode(bool)
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::upload( const Effect* /*effect*/ )
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::modify( const Effect* /*effect*/ )
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::remove( const Effect* /*effect*/ )
+{
+}
+
Index: /code/branches/physics/src/ois/linux/LinuxForceFeedback.h
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxForceFeedback.h	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxForceFeedback.h	(revision 2122)
@@ -0,0 +1,56 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_LinuxForceFeedBack_H
+#define OIS_LinuxForceFeedBack_H
+
+#include "linux/LinuxPrereqs.h"
+#include "OISForceFeedback.h"
+
+namespace OIS
+{
+	class LinuxForceFeedback : public ForceFeedback
+	{
+	public:
+		LinuxForceFeedback();
+		~LinuxForceFeedback();
+
+		/** @copydoc ForceFeedback::setMasterGain */
+		void setMasterGain(float);
+		
+		/** @copydoc ForceFeedback::setAutoCenterMode */
+		void setAutoCenterMode(bool);
+
+		/** @copydoc ForceFeedback::upload */
+		void upload( const Effect* effect );
+
+		/** @copydoc ForceFeedback::modify */
+		void modify( const Effect* effect );
+
+		/** @copydoc ForceFeedback::remove */
+		void remove( const Effect* effect );
+
+		/** FF is not yet implemented fully on Linux.. just retun 0 for now. todo, xxx */
+		short int getFFAxesNumber() { return 0; }
+	};
+}
+#endif //OIS_LinuxForceFeedBack_H
Index: /code/branches/physics/src/ois/linux/LinuxInputManager.cpp
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxInputManager.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxInputManager.cpp	(revision 2122)
@@ -0,0 +1,218 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/LinuxInputManager.h"
+#include "linux/LinuxKeyboard.h"
+#include "linux/LinuxJoyStickEvents.h"
+#include "linux/LinuxMouse.h"
+#include "OISException.h"
+#include <cstdlib>
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------//
+LinuxInputManager::LinuxInputManager() : InputManager("X11InputManager")
+{
+	window = 0;
+
+	//Default settings
+	grabMouse = true;
+	grabKeyboard = true;
+	hideMouse = true;
+	mGrabs = true;
+	useXRepeat = false;
+	keyboardUsed = mouseUsed = false;
+
+	//Setup our internal factories
+	mFactories.push_back(this);
+}
+
+//--------------------------------------------------------------------------------//
+LinuxInputManager::~LinuxInputManager()
+{
+	//Close all joysticks
+	LinuxJoyStick::_clearJoys(unusedJoyStickList);
+}
+
+//--------------------------------------------------------------------------------//
+void LinuxInputManager::_initialize( ParamList &paramList )
+{
+	_parseConfigSettings( paramList );
+
+	//Enumerate all devices attached
+	_enumerateDevices();
+}
+
+//--------------------------------------------------------------------------------//
+void LinuxInputManager::_parseConfigSettings( ParamList &paramList )
+{
+	ParamList::iterator i = paramList.find("WINDOW");
+	if( i == paramList.end() ) 
+		OIS_EXCEPT( E_InvalidParam, "LinuxInputManager >> No WINDOW!" );
+
+	//TODO 64 bit proof this little conversion xxx wip
+	window  = strtoul(i->second.c_str(), 0, 10);
+
+	//--------- Keyboard Settings ------------//
+	i = paramList.find("XAutoRepeatOn");
+	if( i != paramList.end() )
+		if( i->second == "true" )
+			useXRepeat = true;
+
+	i = paramList.find("x11_keyboard_grab");
+	if( i != paramList.end() )
+		if( i->second == "false" )
+			grabKeyboard = false;
+
+	//--------- Mouse Settings ------------//
+	i = paramList.find("x11_mouse_grab");
+	if( i != paramList.end() )
+		if( i->second == "false" )
+			grabMouse = false;
+
+	i = paramList.find("x11_mouse_hide");
+	if( i != paramList.end() )
+		if( i->second == "false" )
+			hideMouse = false;
+}
+
+//--------------------------------------------------------------------------------//
+void LinuxInputManager::_enumerateDevices()
+{
+	//Enumerate all attached devices
+	unusedJoyStickList = LinuxJoyStick::_scanJoys();
+	joySticks = unusedJoyStickList.size();
+}
+
+//----------------------------------------------------------------------------//
+DeviceList LinuxInputManager::freeDeviceList()
+{
+	DeviceList ret;
+
+	if( keyboardUsed == false )
+		ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
+
+	if( mouseUsed == false )
+		ret.insert(std::make_pair(OISMouse, mInputSystemName));
+
+	for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		ret.insert(std::make_pair(OISJoyStick, i->vendor));
+
+	return ret;
+}
+
+//----------------------------------------------------------------------------//
+int LinuxInputManager::totalDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return 1;
+	case OISMouse: return 1;
+	case OISJoyStick: return joySticks;
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+int LinuxInputManager::freeDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return keyboardUsed ? 0 : 1;
+	case OISMouse: return mouseUsed ? 0 : 1;
+	case OISJoyStick: return (int)unusedJoyStickList.size();
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+bool LinuxInputManager::vendorExist(Type iType, const std::string & vendor)
+{
+	if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
+	{
+		return true;
+	}
+	else if( iType == OISJoyStick )
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+			if(i->vendor == vendor)
+				return true;
+	}
+
+	return false;
+}
+
+//----------------------------------------------------------------------------//
+Object* LinuxInputManager::createObject(InputManager *creator, Type iType, bool bufferMode, const std::string & vendor)
+{
+	Object *obj = 0;
+
+	switch(iType)
+	{
+	case OISKeyboard:
+	{
+		if( keyboardUsed == false )
+			obj = new LinuxKeyboard(this, bufferMode, grabKeyboard, useXRepeat);
+		break;
+	}
+	case OISMouse:
+	{
+		if( mouseUsed == false )
+			obj = new LinuxMouse(this, bufferMode, grabMouse, hideMouse);
+		break;
+	}
+	case OISJoyStick:
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		{
+			if(vendor == "" || i->vendor == vendor)
+			{
+				obj = new LinuxJoyStick(this, bufferMode, *i);
+				unusedJoyStickList.erase(i);
+				break;
+			}
+		}
+		break;
+	}
+	default:
+		break;
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//----------------------------------------------------------------------------//
+void LinuxInputManager::destroyObject( Object* obj )
+{
+	if( obj )
+	{
+		if( obj->type() == OISJoyStick )
+		{
+			unusedJoyStickList.push_back( ((LinuxJoyStick*)obj)->_getJoyInfo() );
+		}
+
+		delete obj;
+	}
+}
Index: /code/branches/physics/src/ois/linux/LinuxInputManager.h
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxInputManager.h	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxInputManager.h	(revision 2122)
@@ -0,0 +1,108 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_LinuxInputManager_H
+#define OIS_LinuxInputManager_H
+
+#include "linux/LinuxPrereqs.h"
+#include "OISFactoryCreator.h"
+#include "OISInputManager.h"
+#include <X11/Xlib.h>
+
+namespace OIS
+{
+	/**
+		Linux X11 InputManager specialization - Using lowlevel joys
+	*/
+	class LinuxInputManager : public InputManager, public FactoryCreator
+	{
+	public:
+		LinuxInputManager();
+		virtual ~LinuxInputManager();
+
+		//InputManager Overrides
+		/** @copydoc InputManager::_initialize */
+		void _initialize( ParamList &paramList );
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager *creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+		//Internal Items
+		//! Method for retrieving the XWindow Handle
+		Window _getWindow() {return window;}
+
+		//! Internal method for checking if regrabbing is needed
+		void _setGrabState(bool grab) {mGrabs = grab;}
+		bool _getGrabState() {return mGrabs;}
+
+		//! Internal method, used for flaggin keyboard as available/unavailable for creation
+		void _setKeyboardUsed(bool used) {keyboardUsed = used; }
+
+		//! Internal method, used for flaggin mouse as available/unavailable for creation
+		void _setMouseUsed(bool used) { mouseUsed = used; }
+		
+	protected:
+		//! internal class method for dealing with param list
+		void _parseConfigSettings( ParamList &paramList );
+		//! internal class method for finding attached devices
+		void _enumerateDevices();
+
+		//! List of unused joysticks ready to be used
+		JoyStickInfoList unusedJoyStickList;
+		//! Number of joysticks found
+		char joySticks;
+
+		//! Used to know if we used up keyboard
+		bool keyboardUsed;
+
+		//! Used to know if we used up mouse
+		bool mouseUsed;
+
+		//! X11 Stuff
+		Window window;
+		
+		/// Keyboard, Mouse Settings
+		bool grabMouse, grabKeyboard;
+		bool mGrabs;
+		bool hideMouse;
+
+		//! By default, keyboard disables XRepeatRate
+		bool useXRepeat;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/linux/LinuxJoyStickEvents.cpp
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxJoyStickEvents.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxJoyStickEvents.cpp	(revision 2122)
@@ -0,0 +1,299 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISConfig.h"
+
+#include "linux/LinuxJoyStickEvents.h"
+#include "linux/LinuxInputManager.h"
+#include "linux/LinuxForceFeedback.h"
+#include "linux/EventHelpers.h"
+
+#include "OISEvents.h"
+#include "OISException.h"
+
+#include <fcntl.h>        //Needed to Open a file descriptor
+#include <cassert>	
+#include <linux/input.h>
+
+
+#include <sstream>
+
+using namespace OIS;
+
+//#define OIS_LINUX_JOY_DEBUG
+
+#ifdef OIS_LINUX_JOY_DEBUG
+# include <iostream>
+  using namespace std;
+#endif
+
+//-------------------------------------------------------------------//
+LinuxJoyStick::LinuxJoyStick(InputManager* creator, bool buffered, const JoyStickInfo& js)
+	: JoyStick(js.vendor, buffered, js.devId, creator)
+{
+	mJoyStick = js.joyFileD;
+
+	mState.mAxes.clear();
+	mState.mAxes.resize(js.axes);
+	mState.mButtons.clear();
+	mState.mButtons.resize(js.buttons);
+
+	mPOVs = js.hats;
+
+	mButtonMap = js.button_map;
+	mAxisMap = js.axis_map;
+	mRanges = js.axis_range;
+
+	ff_effect = 0;
+}
+
+//-------------------------------------------------------------------//
+LinuxJoyStick::~LinuxJoyStick()
+{
+	EventUtils::removeForceFeedback( &ff_effect );
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::_initialize()
+{
+	//Clear old joy state
+	mState.mAxes.resize(mAxisMap.size());
+	mState.clear();
+
+	//This will create and new us a force feedback structure if it exists
+	EventUtils::enumerateForceFeedback( mJoyStick, &ff_effect );
+
+	if( mJoyStick == -1 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "LinuxJoyStick::_initialize() >> JoyStick Not Found!");
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::capture()
+{
+	static const short POV_MASK[8] = {0,0,1,1,2,2,3,3};
+
+	//Used to determine if an axis has been changed and needs an event
+	bool axisMoved[32] = {false, false, false, false, false, false, false, false, false, false, false, false, false,
+						  false, false, false, false, false, false, false, false, false, false, false, false, false,
+						  false, false, false, false, false, false};
+
+	//We are in non blocking mode - we just read once, and try to fill up buffer
+	input_event js[JOY_BUFFERSIZE];
+	int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
+	if( ret <= 0 )
+		return;
+
+	//Determine how many whole events re read up
+	ret /= sizeof(struct input_event);
+	for(int i = 0; i < ret; ++i)
+	{
+		switch(js[i].type)
+		{
+		case EV_KEY:  //Button
+		{
+			int button = mButtonMap[js[i].code];
+
+			#ifdef OIS_LINUX_JOY_DEBUG
+			  std::cout << "\nButton Code: " << js[i].code << ", OIS Value: " << button << std::endl;
+			#endif
+
+			//Check to see whether push or released event...
+			if(js[i].value)
+			{
+				mState.mButtons[button] = true;
+				if( mBuffered && mListener )
+					if(!mListener->buttonPressed(JoyStickEvent(this,mState), button)) return;
+			}
+			else
+			{
+				mState.mButtons[button] = false;
+				if( mBuffered && mListener )
+					if(!mListener->buttonReleased(JoyStickEvent(this,mState), button)) return;
+			}
+			break;
+		}
+		case EV_ABS:  //Absoulte Axis
+		{
+			//A Stick (BrakeDefine is the highest possible Axis)
+			if( js[i].code <= ABS_BRAKE )
+			{
+				int axis = mAxisMap[js[i].code];
+				assert( axis < 32 && "Too many axes, not supported. Report this to OIS forums!" );
+				
+				axisMoved[axis] = true;
+
+				//check for rescaling:
+				if( mRanges[axis].min == JoyStick::MIN_AXIS && mRanges[axis].max != JoyStick::MAX_AXIS )
+				{	//Scale is perfect
+					mState.mAxes[axis].abs = js[i].value;
+				}
+				else
+				{	//Rescale
+					float proportion = (float)(js[i].value-mRanges[axis].max)/(float)(mRanges[axis].min-mRanges[axis].max);
+					mState.mAxes[axis].abs = (int)(32767.0f - (65535.0f * proportion));
+				}
+			}
+			else if( js[i].code <= ABS_HAT3Y ) //A POV - Max four POVs allowed
+			{
+				//Normalise the POV to between 0-7
+				//Even is X Axis, Odd is Y Axis
+				unsigned char LinuxPovNumber = js[i].code - 16;
+				short OIS_POVIndex = POV_MASK[LinuxPovNumber];
+
+				//Handle X Axis first (Even) (left right)
+				if((LinuxPovNumber & 0x0001) == 0)
+				{
+					//Why do this? Because, we use a bit field, and when this axis is east,
+					//it can't possibly be west too. So clear out the two X axes, then refil
+					//it in with the new direction bit.
+					//Clear the East/West Bit Flags first
+					mState.mPOV[OIS_POVIndex].direction &= 0x11110011;
+					if( js[i].value == -1 )	//Left
+						mState.mPOV[OIS_POVIndex].direction |= Pov::West;
+					else if( js[i].value == 1 ) //Right
+						mState.mPOV[OIS_POVIndex].direction |= Pov::East;
+				}
+				//Handle Y Axis (Odd) (up down)
+				else
+				{
+					//Clear the North/South Bit Flags first
+					mState.mPOV[OIS_POVIndex].direction &= 0x11111100;
+					if( js[i].value == -1 )	//Up
+						mState.mPOV[OIS_POVIndex].direction |= Pov::North;
+					else if( js[i].value == 1 ) //Down
+						mState.mPOV[OIS_POVIndex].direction |= Pov::South;
+				}
+
+				if( mBuffered && mListener )
+					if( mListener->povMoved( JoyStickEvent(this,mState), OIS_POVIndex) == false )
+						return;
+			}
+			break;
+		}
+		//Relative Axes (Do any joysticks actually have a relative axis?)
+		case EV_REL:
+		default: break;
+		}
+	}
+
+	//All axes and POVs are combined into one movement per pair per captured frame
+	if( mBuffered && mListener )
+	{
+		for( int i = 0; i < 32; ++i )
+			if( axisMoved[i] )
+				if( mListener->axisMoved( JoyStickEvent(this,mState), i) == false )
+					return;
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::setBuffered(bool buffered)
+{
+	if( buffered != mBuffered )
+	{
+		mBuffered = buffered;
+		_initialize();
+	}
+}
+
+//-------------------------------------------------------------------//
+JoyStickInfo LinuxJoyStick::_getJoyInfo()
+{
+	JoyStickInfo js;
+
+	js.devId = mDevID;
+	js.joyFileD = mJoyStick;
+	js.vendor = mVendor;
+	js.axes = (int)mState.mAxes.size();
+	js.buttons = (int)mState.mButtons.size();
+	js.hats = mPOVs;
+	js.button_map = mButtonMap;
+	js.axis_map = mAxisMap;
+	js.axis_range = mRanges;
+
+	return js;
+}
+
+//-------------------------------------------------------------------//
+JoyStickInfoList LinuxJoyStick::_scanJoys()
+{
+	JoyStickInfoList joys;
+
+	//Search through all of the event devices.. and identify which ones are joysticks
+	//xxx move this to InputManager, as it can also scan all other events
+	for(int i = 0; i < 64; ++i )
+	{
+		std::stringstream s;
+		s << "/dev/input/event" << i;
+		int fd = open( s.str().c_str(), O_RDONLY |O_NONBLOCK );
+		if(fd == -1)
+			continue;
+		
+        #ifdef OIS_LINUX_JOY_DEBUG
+          std::cout << "\nOpening " << s.str() << "...";
+        #endif
+		try
+		{
+			JoyStickInfo js;
+			if( EventUtils::isJoyStick(fd, js) )
+			{
+				joys.push_back(js);
+                #ifdef OIS_LINUX_JOY_DEBUG
+                  std::cout << "\n__Joystick added to list";
+                #endif
+			}
+			else
+			{
+                #ifdef OIS_LINUX_JOY_DEBUG
+                  std::cout << "\n__Not a joystick!!";
+                #endif
+				close(fd);
+			}
+		}
+		catch(...)
+		{
+            #ifdef OIS_LINUX_JOY_DEBUG
+              std::cout << "\nException caught!!";
+            #endif
+			close(fd);
+		}
+	}
+
+	return joys;
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::_clearJoys(JoyStickInfoList &joys)
+{
+	for(JoyStickInfoList::iterator i = joys.begin(); i != joys.end(); ++i)
+		close(i->joyFileD);
+	joys.clear();
+}
+
+//-------------------------------------------------------------------//
+Interface* LinuxJoyStick::queryInterface(Interface::IType type)
+{
+	if( ff_effect && type == Interface::ForceFeedback )
+		return ff_effect;
+
+	return 0;
+}
Index: /code/branches/physics/src/ois/linux/LinuxJoyStickEvents.h
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxJoyStickEvents.h	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxJoyStickEvents.h	(revision 2122)
@@ -0,0 +1,72 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_JOYSTICK_H_EADER_
+#define _LINUX_JOYSTICK_H_EADER_
+
+#include "linux/LinuxPrereqs.h"
+#include "OISJoyStick.h"
+
+namespace OIS
+{
+	/**
+		Linux specialization of JoyStick class.. This version is favored over the other.. and has the
+		*possibility* of Force Feedback.. notice I say possibility, i make no gaurantees under linux,
+		as FF support is sketchy at best AFAIK.
+	*/
+	class LinuxJoyStick : public JoyStick
+	{
+	public:
+		LinuxJoyStick(InputManager* creator, bool buffered, const JoyStickInfo& js);
+		virtual ~LinuxJoyStick();
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type);
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+		/**
+		@remarks
+			For internal use only... Returns a structure to the manager, to make the device
+			availiable for use again
+		*/
+		JoyStickInfo _getJoyInfo();
+
+		static JoyStickInfoList _scanJoys();
+		static void _clearJoys(JoyStickInfoList &joys);
+	protected:
+
+		int mJoyStick;
+		LinuxForceFeedback* ff_effect;
+		std::map <int, int> mButtonMap;
+		std::map <int, int> mAxisMap;
+		std::map <int, Range> mRanges;
+	};
+}
+#endif //_LINUX_JOYSTICK_H_EADER_
Index: /code/branches/physics/src/ois/linux/LinuxKeyboard.cpp
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxKeyboard.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxKeyboard.cpp	(revision 2122)
@@ -0,0 +1,449 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/LinuxInputManager.h"
+#include "linux/LinuxKeyboard.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include <X11/keysym.h>
+#include <X11/Xutil.h>
+#include <cstring>
+
+using namespace OIS;
+#include <iostream>
+//-------------------------------------------------------------------//
+LinuxKeyboard::LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bool useXRepeat)
+	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
+{
+	setlocale(LC_CTYPE, ""); //Set the locale to (hopefully) the users LANG UTF-8 Env var
+
+	display = 0;
+	window = 0;
+
+	grabKeyboard = grab;
+	keyFocusLost = false;
+
+	xAutoRepeat = useXRepeat;
+	oldXAutoRepeat = false;
+
+	//X Key Map to KeyCode
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_1, KC_1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_2, KC_2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_3, KC_3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_4, KC_4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_5, KC_5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_6, KC_6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_7, KC_7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_8, KC_8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_9, KC_9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_0, KC_0));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_BackSpace, KC_BACK));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_minus, KC_MINUS));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_equal, KC_EQUALS));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_space, KC_SPACE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_comma, KC_COMMA));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_period, KC_PERIOD));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_backslash, KC_BACKSLASH));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_slash, KC_SLASH));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_bracketleft, KC_LBRACKET));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_bracketright, KC_RBRACKET));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Escape,KC_ESCAPE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Caps_Lock, KC_CAPITAL));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Tab, KC_TAB));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Return, KC_RETURN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Control_L, KC_LCONTROL));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Control_R, KC_RCONTROL));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_colon, KC_COLON));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_semicolon, KC_SEMICOLON));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_apostrophe, KC_APOSTROPHE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_grave, KC_GRAVE));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_b, KC_B));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_a, KC_A));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_c, KC_C));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_d, KC_D));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_e, KC_E));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_f, KC_F));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_g, KC_G));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_h, KC_H));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_i, KC_I));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_j, KC_J));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_k, KC_K));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_l, KC_L));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_m, KC_M));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_n, KC_N));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_o, KC_O));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_p, KC_P));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_q, KC_Q));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_r, KC_R));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_s, KC_S));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_t, KC_T));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_u, KC_U));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_v, KC_V));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_w, KC_W));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_x, KC_X));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_y, KC_Y));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_z, KC_Z));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F1, KC_F1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F2, KC_F2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F3, KC_F3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F4, KC_F4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F5, KC_F5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F6, KC_F6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F7, KC_F7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F8, KC_F8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F9, KC_F9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F10, KC_F10));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F11, KC_F11));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F12, KC_F12));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F13, KC_F13));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F14, KC_F14));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F15, KC_F15));
+
+	//Keypad
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_0, KC_NUMPAD0));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_1, KC_NUMPAD1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_2, KC_NUMPAD2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_3, KC_NUMPAD3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_4, KC_NUMPAD4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_5, KC_NUMPAD5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_6, KC_NUMPAD6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_7, KC_NUMPAD7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_8, KC_NUMPAD8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_9, KC_NUMPAD9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Add, KC_ADD));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Subtract, KC_SUBTRACT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Decimal, KC_DECIMAL));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Equal, KC_NUMPADEQUALS));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Divide, KC_DIVIDE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Multiply, KC_MULTIPLY));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Enter, KC_NUMPADENTER));
+
+	//Keypad with numlock off
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Home, KC_NUMPAD7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Page_Up, KC_NUMPAD9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Left, KC_NUMPAD4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Begin, KC_NUMPAD5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Right, KC_NUMPAD6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_End, KC_NUMPAD1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Down, KC_NUMPAD2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Up, KC_UP));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Down, KC_DOWN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Left, KC_LEFT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Right, KC_RIGHT));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Page_Up, KC_PGUP));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Page_Down, KC_PGDOWN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Home, KC_HOME));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_End, KC_END));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Num_Lock, KC_NUMLOCK));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Shift_R, KC_RSHIFT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Shift_L, KC_LSHIFT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Alt_R, KC_RMENU));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Alt_L, KC_LMENU));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Delete, KC_DELETE));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Super_L, KC_LWIN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Super_R, KC_RWIN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Menu, KC_APPS));
+
+	static_cast<LinuxInputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::_initialize()
+{
+	//Clear our keyboard state buffer
+	memset( &KeyBuffer, 0, 256 );
+	mModifiers = 0;
+
+	if( display ) XCloseDisplay(display);
+	display = 0;
+	window = static_cast<LinuxInputManager*>(mCreator)->_getWindow();
+
+	//Create our local X mListener connection
+	if( !(display = XOpenDisplay(0)) )
+		OIS_EXCEPT(E_General, "LinuxKeyboard::_initialize >> Error opening X!");
+
+	//Set it to recieve Input events
+	if( XSelectInput(display, window, KeyPressMask | KeyReleaseMask) == BadWindow )
+		OIS_EXCEPT(E_General, "LinuxKeyboard::_initialize: X error!");
+
+	if( grabKeyboard )
+		XGrabKeyboard(display,window,True,GrabModeAsync,GrabModeAsync,CurrentTime);
+
+	keyFocusLost = false;
+
+	if( xAutoRepeat == false )
+	{
+		//We do not want to blindly turn on autorepeat later when quiting if
+		//it was not on to begin with.. So, let us check and see first
+		XKeyboardState old;
+		XGetKeyboardControl( display, &old );
+		oldXAutoRepeat = false;
+
+		if( old.global_auto_repeat == AutoRepeatModeOn )
+			oldXAutoRepeat = true;
+
+		XAutoRepeatOff( display );
+	}
+}
+
+//-------------------------------------------------------------------//
+LinuxKeyboard::~LinuxKeyboard()
+{
+	if( display )
+	{
+		if( oldXAutoRepeat )
+			XAutoRepeatOn(display);
+
+		if( grabKeyboard )
+			XUngrabKeyboard(display, CurrentTime);
+
+		XCloseDisplay(display);
+	}
+
+	static_cast<LinuxInputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//-------------------------------------------------------------------//
+unsigned int UTF8ToUTF32(unsigned char* buf)
+{
+	unsigned char &FirstChar = buf[0];
+
+	if(FirstChar < 128)
+		return FirstChar;
+
+	unsigned int val = 0;
+	unsigned int len = 0;
+
+	if((FirstChar & 0xE0) == 0xC0) //2 Chars
+	{
+		len = 2;
+		val = FirstChar & 0x1F;
+	}
+	else if((FirstChar & 0xF0) == 0xE0) //3 Chars
+	{
+		len = 3;
+		val = FirstChar & 0x0F;
+	}
+	else if((FirstChar & 0xF8) == 0xF0) //4 Chars
+	{
+		len = 4;
+		val = FirstChar & 0x07;
+	}
+	else if((FirstChar & 0xFC) == 0xF8) //5 Chars
+	{
+		len = 5;
+		val = FirstChar & 0x03;
+	}
+	else // if((FirstChar & 0xFE) == 0xFC) //6 Chars
+	{
+		len = 6;
+		val = FirstChar & 0x01;
+	}
+
+	for(unsigned int i = 1; i < len; i++)
+		val = (val << 6) | (buf[i] & 0x3F);
+
+	return val;
+}
+
+//-------------------------------------------------------------------//
+bool LinuxKeyboard::isKeyDown( KeyCode key ) const
+{
+	return (KeyBuffer[key]);
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::capture()
+{
+	KeySym key;
+	XEvent event;
+	LinuxInputManager* linMan = static_cast<LinuxInputManager*>(mCreator);
+
+	while( XPending(display) > 0 )
+	{
+		XNextEvent(display, &event);
+
+		if( KeyPress == event.type )
+		{
+			unsigned int character = 0;
+
+			if( mTextMode != Off )
+			{
+				unsigned char buffer[6] = {0,0,0,0,0,0};
+				XLookupString(&event.xkey, (char*)buffer, 6, &key, 0);
+
+				if( mTextMode == Unicode )
+					character = UTF8ToUTF32(buffer);
+				else if( mTextMode == Ascii)
+					character = buffer[0];
+			}
+
+			//Mask out the modifier states X11 sets and read again
+			event.xkey.state &= ~ShiftMask;
+			event.xkey.state &= ~LockMask;
+			XLookupString(&event.xkey, 0, 0,&key, 0);
+
+			_injectKeyDown(key, character);
+
+			//Just printing out some debugging info.. to verify all chars are mapped
+			//std::cout << "KEY PRESSED X=" << event.xkey.keycode;
+			//std::cout << "\n KeySym=" << key << std::endl;
+
+			//Check for Alt-Tab
+			if( event.xkey.state & Mod1Mask && key == XK_Tab )
+				linMan->_setGrabState(false);
+		}
+		else if( KeyRelease == event.type )
+		{
+			//Mask out the modifier states X sets.. or we will get improper values
+			event.xkey.state &= ~ShiftMask;
+			event.xkey.state &= ~LockMask;
+
+			//Else, it is a valid key release
+			XLookupString(&event.xkey,NULL,0,&key,NULL);
+			_injectKeyUp(key);
+		}
+	}
+
+	//If grabbing mode is on.. Handle focus lost/gained via Alt-Tab and mouse clicks
+	if( grabKeyboard )
+	{
+		if( linMan->_getGrabState() == false )
+		{
+			// are no longer grabbing
+			if( keyFocusLost == false )
+			{
+				//UnGrab KeyBoard
+				XUngrabKeyboard(display, CurrentTime);
+				keyFocusLost = true;
+			}
+		}
+		else
+		{
+			//We are grabbing - and regained focus
+			if( keyFocusLost == true )
+			{
+				//ReGrab KeyBoard
+				XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
+				keyFocusLost = false;
+			}
+		}
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
+
+//-------------------------------------------------------------------//
+bool LinuxKeyboard::_injectKeyDown( KeySym key, int text )
+{
+	KeyCode kc = keyConversion[key];
+	KeyBuffer[kc] = 1;
+
+	//Turn on modifier flags
+	if( kc == KC_LCONTROL || kc == KC_RCONTROL)
+		mModifiers |= Ctrl;
+	else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+		mModifiers |= Shift;
+	else if( kc == KC_LMENU || kc == KC_RMENU )
+		mModifiers |= Alt;
+
+	if( mBuffered && mListener )
+		return mListener->keyPressed(KeyEvent(this,kc,text));
+
+	return true;
+}
+
+//-------------------------------------------------------------------//
+bool LinuxKeyboard::_injectKeyUp( KeySym key )
+{
+	KeyCode kc = keyConversion[key];
+	KeyBuffer[kc] = 0;
+
+	//Turn off modifier flags
+	if( kc == KC_LCONTROL || kc == KC_RCONTROL)
+		mModifiers &= ~Ctrl;
+	else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+		mModifiers &= ~Shift;
+	else if( kc == KC_LMENU || kc == KC_RMENU )
+		mModifiers &= ~Alt;
+
+	if( mBuffered && mListener )
+		return mListener->keyReleased(KeyEvent(this, kc, 0));
+
+	return true;
+}
+
+//-------------------------------------------------------------------//
+const std::string& LinuxKeyboard::getAsString( KeyCode kc )
+{
+	mGetString = "Unknown";
+	char *temp = 0;
+
+	XtoOIS_KeyMap::iterator i = keyConversion.begin(),
+				e = keyConversion.end();
+
+	for( ; i != e; ++i )
+	{
+		if( i->second == kc )
+		{
+			temp = XKeysymToString(i->first);
+			if( temp )
+				mGetString = temp;
+			break;
+		}
+	}
+
+	return mGetString;
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::copyKeyStates( char keys[256] ) const
+{
+	memcpy( keys, KeyBuffer, 256 );
+}
Index: /code/branches/physics/src/ois/linux/LinuxKeyboard.h
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxKeyboard.h	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxKeyboard.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_KEYBOARD_H_EADER_
+#define _LINUX_KEYBOARD_H_EADER_
+
+#include "linux/LinuxPrereqs.h"
+#include "OISKeyboard.h"
+#include <X11/Xlib.h>
+
+namespace OIS
+{
+	/** Linux implementation of Keyboard object - uses x11 */
+	class LinuxKeyboard : public Keyboard
+	{
+	public:
+		LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bool useXRepeat );
+		virtual ~LinuxKeyboard();
+
+		/** @copydoc Keyboard::isKeyDown */
+		virtual bool isKeyDown( KeyCode key ) const;
+
+		/** @copydoc Keyboard::getAsString */
+		virtual const std::string& getAsString( KeyCode kc );
+
+		/** @copydoc Keyboard::copyKeyStates */
+		virtual void copyKeyStates( char keys[256] ) const;
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+	protected:
+		bool _injectKeyDown( KeySym key, int text );
+		bool _injectKeyUp( KeySym key );
+
+		//! 1:1 Conversion Map between X Key Events and OIS KeyCodes
+		typedef std::map<KeySym, KeyCode> XtoOIS_KeyMap;
+		XtoOIS_KeyMap keyConversion;
+
+		//! Depressed Key List
+		char KeyBuffer[256];
+
+		//! X11 Stuff
+		Window window;
+		Display *display;
+		bool grabKeyboard;
+		bool keyFocusLost;
+
+		bool xAutoRepeat;
+		bool oldXAutoRepeat;
+
+		std::string mGetString;
+	};
+}
+
+#endif //_LINUX_KEYBOARD_H_EADER_
Index: /code/branches/physics/src/ois/linux/LinuxMouse.cpp
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxMouse.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxMouse.cpp	(revision 2122)
@@ -0,0 +1,270 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered friosom any source distribution.
+*/
+#include "linux/LinuxMouse.h"
+#include "linux/LinuxInputManager.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+using namespace OIS;
+
+//-------------------------------------------------------------------//
+LinuxMouse::LinuxMouse(InputManager* creator, bool buffered, bool grab, bool hide)
+	: Mouse(creator->inputSystemName(), buffered, 0, creator)
+{
+	display = 0;
+	window = 0;
+	cursor = 0;
+
+	grabMouse = grab;
+	hideMouse = hide;
+
+	static_cast<LinuxInputManager*>(mCreator)->_setMouseUsed(true);
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::_initialize()
+{
+	//Clear old state
+	mState.clear();
+	mMoved  = false;
+	mWarped = false;
+
+	//6 is just some random value... hardly ever would anyone have a window smaller than 6
+	oldXMouseX = oldXMouseY = 6;
+	oldXMouseZ = 0;
+
+	if( display ) XCloseDisplay(display);
+	display = 0;
+	window = static_cast<LinuxInputManager*>(mCreator)->_getWindow();
+
+	//Create our local X mListener connection
+	if( !(display = XOpenDisplay(0)) )
+		OIS_EXCEPT(E_General, "LinuxMouse::_initialize >> Error opening X!");
+
+	//Set it to recieve Mouse Input events
+	if( XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask) == BadWindow )
+		OIS_EXCEPT(E_General, "LinuxMouse::_initialize >> X error!");
+
+	//Warp mouse inside window
+	XWarpPointer(display,None,window,0,0,0,0, 6,6);
+
+	//Create a blank cursor:
+	Pixmap bm_no;
+	XColor black, dummy;
+	Colormap colormap;
+	static char no_data[] = { 0,0,0,0,0,0,0,0 };
+
+	colormap = DefaultColormap( display, DefaultScreen(display) );
+	XAllocNamedColor( display, colormap, "black", &black, &dummy );
+	bm_no = XCreateBitmapFromData( display, window, no_data, 8, 8 );
+	cursor = XCreatePixmapCursor( display, bm_no, bm_no, &black, &black, 0, 0 );
+
+	grab( grabMouse );
+	hide( hideMouse );
+
+	mouseFocusLost = false;
+}
+
+//-------------------------------------------------------------------//
+LinuxMouse::~LinuxMouse()
+{
+	if( display )
+	{
+		grab(false);
+		hide(false);
+		XFreeCursor(display, cursor);
+		XCloseDisplay(display);
+	}
+
+	static_cast<LinuxInputManager*>(mCreator)->_setMouseUsed(false);
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::capture()
+{
+	//Clear out last frames values
+	mState.X.rel = 0;
+	mState.Y.rel = 0;
+	mState.Z.rel = 0;
+
+	_processXEvents();
+
+	mWarped = false;
+
+	if( mMoved == true )
+	{
+		if( mBuffered && mListener )
+			mListener->mouseMoved( MouseEvent( this, mState ) );
+
+		mMoved = false;
+	}
+
+	//Check for losing/gaining mouse grab focus (alt-tab, etc)
+	if( grabMouse )
+	{
+		if( static_cast<LinuxInputManager*>(mCreator)->_getGrabState() )
+		{
+			if( mouseFocusLost )	//We just regained mouse grab focus
+			{
+				grab( true );
+				hide( hideMouse );
+				mouseFocusLost = false;
+			}
+		}
+		else
+		{
+			if( mouseFocusLost == false )	//We just lost mouse grab focus
+			{
+				grab( false );
+				hide( false );
+				mouseFocusLost = true;
+			}
+		}
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::_processXEvents()
+{
+	//X11 Button Events: 1=left 2=middle 3=right; Our Bit Postion: 1=Left 2=Right 3=Middle
+	char mask[4] = {0,1,4,2};
+	XEvent event;
+
+	//Poll x11 for events mouse events
+	while( XPending(display) > 0 ) 
+	{
+		XNextEvent(display, &event);
+
+		if( event.type == MotionNotify )
+		{	//Mouse moved
+			//Ignore out of bounds mouse if we just warped
+			if( mWarped )
+			{
+				if(event.xmotion.x < 5 || event.xmotion.x > mState.width - 5 ||
+				   event.xmotion.y < 5 || event.xmotion.y > mState.height - 5)
+					continue;
+			}
+
+			//Compute this frames Relative X & Y motion
+			mState.X.rel = event.xmotion.x - oldXMouseX;
+			mState.Y.rel = event.xmotion.y - oldXMouseY;
+		
+			//Store old values for next time to compute relative motion
+			oldXMouseX = event.xmotion.x;
+			oldXMouseY = event.xmotion.y;
+
+			mState.X.abs += mState.X.rel;
+			mState.Y.abs += mState.Y.rel;
+
+			//Check to see if we are grabbing the mouse to the window (requires clipping and warping)
+			if( grabMouse )
+			{
+				if( mState.X.abs < 0 )
+					mState.X.abs = 0;
+				else if( mState.X.abs > mState.width )
+					mState.X.abs = mState.width;
+
+				if( mState.Y.abs < 0 )
+					mState.Y.abs = 0;
+				else if( mState.Y.abs > mState.height )
+					mState.Y.abs = mState.height;
+
+				if( mouseFocusLost == false )
+				{
+					//Keep mouse in window (fudge factor)
+					if(event.xmotion.x < 5 || event.xmotion.x > mState.width - 5 ||
+					   event.xmotion.y < 5 || event.xmotion.y > mState.height - 5 )
+					{
+						oldXMouseX = mState.width >> 1;  //center x
+						oldXMouseY = mState.height >> 1; //center y
+						XWarpPointer(display, None, window, 0, 0, 0, 0, oldXMouseX, oldXMouseY);
+						mWarped = true;
+					}
+				}
+			}
+			mMoved = true;
+		}
+		else if( event.type == ButtonPress )
+		{	//Button down
+			static_cast<LinuxInputManager*>(mCreator)->_setGrabState(true);
+
+			if( event.xbutton.button < 4 )
+			{
+				mState.buttons |= mask[event.xbutton.button];
+				if( mBuffered && mListener )
+					if( mListener->mousePressed( MouseEvent( this, mState ),
+						(MouseButtonID)(mask[event.xbutton.button] >> 1)) == false )
+						return;
+			}
+		}
+		else if( event.type == ButtonRelease )
+		{	//Button up
+			if( event.xbutton.button < 4 )
+			{
+				mState.buttons &= ~mask[event.xbutton.button];
+				if( mBuffered && mListener )
+					if( mListener->mouseReleased( MouseEvent( this, mState ),
+						(MouseButtonID)(mask[event.xbutton.button] >> 1)) == false )
+						return;
+			}
+			//The Z axis gets pushed/released pair message (this is up)
+			else if( event.xbutton.button == 4 )
+			{
+				mState.Z.rel += 120;
+				mState.Z.abs += 120;
+				mMoved = true;
+			}
+			//The Z axis gets pushed/released pair message (this is down)
+			else if( event.xbutton.button == 5 )
+			{
+				mState.Z.rel -= 120;
+				mState.Z.abs -= 120;
+				mMoved = true;
+			}
+		}
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::grab(bool grab)
+{
+	if( grab )
+		XGrabPointer(display, window, True, 0, GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
+	else
+		XUngrabPointer(display, CurrentTime);
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::hide(bool hide)
+{
+	if( hide )
+		XDefineCursor(display, window, cursor);
+	else
+		XUndefineCursor(display, window);
+}
Index: /code/branches/physics/src/ois/linux/LinuxMouse.h
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxMouse.h	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxMouse.h	(revision 2122)
@@ -0,0 +1,75 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_MOUSE_H_EADER_
+#define _LINUX_MOUSE_H_EADER_
+
+#include "linux/LinuxPrereqs.h"
+#include "OISMouse.h"
+#include <X11/Xlib.h>
+
+namespace OIS
+{
+	class LinuxMouse : public Mouse
+	{
+	public:
+		LinuxMouse(InputManager* creator, bool buffered, bool grab, bool hide);
+		virtual ~LinuxMouse();
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/**
+		@remarks
+			Note: Calling this will also update the keyboard (X11 updates in a single
+			event queue). Updates State and/or raises event for buffered mode..
+		*/
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+		void grab(bool grab);
+		void hide(bool hide);
+
+	protected:
+		void _processXEvents();
+
+		bool mMoved, mWarped;
+
+		//Since X11 provides us with absolute values, we need to keep track of relative values
+		long oldXMouseX, oldXMouseY, oldXMouseZ;
+
+		Window window;		//The X Window
+		Display *display;	//The X display
+		Cursor cursor;		//A blank cursor
+
+		bool grabMouse;		//Are we grabbing the mouse to the window?
+		bool hideMouse;		//Are we hiding OS mouse?
+		bool mouseFocusLost;//Has the mouse just lost focus?
+	};
+}
+
+#endif //_LINUX_MOUSE_H_EADER_
Index: /code/branches/physics/src/ois/linux/LinuxPrereqs.h
===================================================================
--- /code/branches/physics/src/ois/linux/LinuxPrereqs.h	(revision 2122)
+++ /code/branches/physics/src/ois/linux/LinuxPrereqs.h	(revision 2122)
@@ -0,0 +1,82 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_INPUTSYSTEM_PREREQS_H
+#define _LINUX_INPUTSYSTEM_PREREQS_H
+
+//Bring in any auto generated config files
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "OISPrereqs.h"
+
+//! Max number of elements to collect from buffered input
+#define JOY_BUFFERSIZE 10
+
+namespace OIS
+{
+	class LinuxInputManager;
+	class LinuxKeyboard;
+	class LinuxJoyStick;
+	class LinuxMouse;
+	
+	class LinuxForceFeedback;
+
+	class Range
+	{
+	public:
+		Range() {};
+		Range(int _min, int _max) : min(_min), max(_max) {};
+		int min, max;
+	};
+
+	class JoyStickInfo
+	{
+	public:
+		JoyStickInfo(): devId(-1),joyFileD(-1),version(0),axes(0),buttons(0),hats(0) {}
+		//! Device number (/dev/input/j#) or /dev/input/event#
+		int devId;
+		//! File descriptor
+		int joyFileD;
+		//! Driver version
+		int version;
+		//! Joy vendor
+		std::string vendor;
+		//! Number of axes
+		unsigned char axes;
+		//! Number of buttons
+		unsigned char buttons;
+		//! Number of hats
+		unsigned char hats;
+		//! Maps Linux button values to OIS buttons values
+		std::map<int, int> button_map;
+		//! Maps Linux axis values to OIS axis
+		std::map<int, int> axis_map;
+		//! Maps OIS axis values to it's range
+		std::map<int, Range> axis_range;
+	};
+
+	typedef std::vector< JoyStickInfo > JoyStickInfoList;
+}
+
+#endif //_LINUX_INPUTSYSTEM_PREREQS_H
Index: /code/branches/physics/src/ois/mac/MacHIDManager.cpp
===================================================================
--- /code/branches/physics/src/ois/mac/MacHIDManager.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacHIDManager.cpp	(revision 2122)
@@ -0,0 +1,392 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Phillip Castaneda
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "mac/MacHIDManager.h"
+#include "OISException.h"
+#include "OISObject.h"
+
+#include <iostream>
+using namespace std;
+
+using namespace OIS;
+
+//------------------------------------------------------------------------------------------------------//
+//------------------------------------------------------------------------------------------------------//
+template<typename T>
+T getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	return CFDictionaryGetValue(dict, OIS_CFString(keyName));
+}
+
+template<>
+CFArrayRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
+
+	if(temp && CFGetTypeID(temp) == CFArrayGetTypeID())
+		return (CFArrayRef)temp;
+	else
+		return 0;
+}
+
+template<>
+CFStringRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
+
+	if(temp && CFGetTypeID(temp) == CFStringGetTypeID())
+		return (CFStringRef)temp;
+	else
+		return 0;
+}
+
+template<>
+CFNumberRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
+
+	if(temp && CFGetTypeID(temp) == CFNumberGetTypeID())
+		return (CFNumberRef)temp;
+	else
+		return 0;
+}
+
+//------------------------------------------------------------------------------------------------------//
+//------------------------------------------------------------------------------------------------------//
+template<typename T>
+T getArrayItemAsRef(CFArrayRef array, CFIndex idx)
+{
+	return CFArrayGetValueAtIndex(array, idx);
+}
+
+template<>
+CFDictionaryRef getArrayItemAsRef(CFArrayRef array, CFIndex idx)
+{
+	CFTypeRef temp = CFArrayGetValueAtIndex(array, idx);
+
+	if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID())
+		return (CFDictionaryRef)temp;
+	else
+		return 0;
+}
+
+//------------------------------------------------------------------------------------------------------//
+int getInt32(CFNumberRef ref)
+{
+   int r = 0;
+   if (r) 
+      CFNumberGetValue(ref, kCFNumberIntType, &r);
+   return r;
+}
+
+//--------------------------------------------------------------------------------//
+MacHIDManager::MacHIDManager()
+{
+}
+
+//--------------------------------------------------------------------------------//
+MacHIDManager::~MacHIDManager()
+{
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::initialize()
+{
+	CFMutableDictionaryRef deviceLookupMap = IOServiceMatching(kIOHIDDeviceKey);
+	if(!deviceLookupMap)
+		OIS_EXCEPT(E_General, "Could not setup HID device search parameters");
+
+	//Make the search more specific by adding usage flags
+	int usage = kHIDUsage_GD_GamePad | kHIDUsage_GD_Joystick,
+	    page  = kHIDPage_GenericDesktop;
+
+	CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage),
+				pageRef  = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
+
+	CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsageKey), usageRef);
+	CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsagePageKey), pageRef);
+
+	//IOServiceGetMatchingServices consumes the map so we do not have to release it ourself
+	io_iterator_t iterator = 0;
+	IOReturn result = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceLookupMap, &iterator);
+	if (result == kIOReturnSuccess && iterator)
+	{
+		io_object_t hidDevice = 0;
+		while ((hidDevice = IOIteratorNext(iterator)) !=0)
+		{
+			//Get the current registry items property map
+			CFMutableDictionaryRef propertyMap = 0;
+			if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
+			{
+				//Go through device to find all needed info
+				HidInfo* hid = enumerateDeviceProperties(propertyMap);
+				if(hid)
+					mDeviceList.push_back(hid);
+					
+				//todo - we need to hold an open interface so we do not have to enumerate again later
+				//should be able to watch for device removals also
+
+				/// Testing opening / closing interface
+				//IOCFPlugInInterface **pluginInterface = NULL;
+				//SInt32 score = 0;
+				//if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
+				//{
+				//	IOHIDDeviceInterface **interface;
+				//	HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
+				//	if(pluginResult == S_OK)
+				//		cout << "Successfully created plugin interface for device\n";
+				//	else
+				//		cout << "Not able to create plugin interface\n";
+
+				//	IODestroyPlugInInterface(pluginInterface);
+
+				//	if ((*interface)->open(interface, 0) == KERN_SUCCESS)
+				//		cout << "Opened interface.\n";
+				//	else
+				//		cout << "Failed to open\n";
+
+				//	(*interface)->close(interface);
+				//}
+				//
+			}
+		}
+
+		IOObjectRelease(iterator);
+	}
+
+	CFRelease(usageRef);
+	CFRelease(pageRef);
+}
+
+//------------------------------------------------------------------------------------------------------//
+HidInfo* MacHIDManager::enumerateDeviceProperties(CFMutableDictionaryRef propertyMap)
+{
+	HidInfo* info = new HidInfo();
+	
+	info->type = OISJoyStick;
+	
+	CFStringRef str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDManufacturerKey);
+	if (str)
+		info->vendor = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
+
+	str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDProductKey);
+	if (str)
+		info->productKey = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
+		
+	info->combinedKey = info->vendor + " " + info->productKey;
+
+	//Go through all items in this device (i.e. buttons, hats, sticks, axes, etc)
+	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(propertyMap, kIOHIDElementKey);
+	if (array)
+		for (int i = 0; i < CFArrayGetCount(array); i++)
+			parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i));
+
+	return info;
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::parseDeviceProperties(CFDictionaryRef properties)
+{
+	if(!properties)
+		return;
+
+	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
+	if (array)
+	{
+		for (int i = 0; i < CFArrayGetCount(array); i++)
+		{
+			CFDictionaryRef element = getArrayItemAsRef<CFDictionaryRef>(array, i);
+			if (element)
+			{
+				if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementTypeKey)) == kIOHIDElementTypeCollection) 
+				{	//Check if we need to recurse further intoi another collection
+					if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)) == kHIDPage_GenericDesktop)
+						parseDeviceProperties(element);
+				}
+				else
+				{
+					switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
+					{
+					case kHIDPage_GenericDesktop:
+						switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+						{
+						case kHIDUsage_GD_Pointer:
+							cout << "\tkHIDUsage_GD_Pointer\n";
+							parseDevicePropertiesGroup(element);
+							break;
+						case kHIDUsage_GD_X:
+						case kHIDUsage_GD_Y:
+						case kHIDUsage_GD_Z:
+						case kHIDUsage_GD_Rx:
+						case kHIDUsage_GD_Ry:
+						case kHIDUsage_GD_Rz:
+							cout << "\tAxis\n";
+							break;
+						case kHIDUsage_GD_Slider:
+						case kHIDUsage_GD_Dial:
+						case kHIDUsage_GD_Wheel:
+							cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
+							break;
+						case kHIDUsage_GD_Hatswitch:
+							cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+							break;
+						}
+						break;
+					case kHIDPage_Button:
+						cout << "\tkHIDPage_Button\n";
+						break;
+					}
+				}
+			}
+		}
+	}
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::parseDevicePropertiesGroup(CFDictionaryRef properties)
+{
+	if(!properties)
+		return;
+
+	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
+	if(array)
+	{
+		for (int i = 0; i < CFArrayGetCount(array); i++)
+		{
+			CFDictionaryRef element = getArrayItemAsRef<CFDictionaryRef>(array, i);
+			if (element)
+			{
+				switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
+				{
+				case kHIDPage_GenericDesktop:
+					switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+					{
+					case kHIDUsage_GD_X:
+					case kHIDUsage_GD_Y:
+					case kHIDUsage_GD_Z:
+					case kHIDUsage_GD_Rx:
+					case kHIDUsage_GD_Ry:
+					case kHIDUsage_GD_Rz:
+						cout << "\t\tAxis\n";
+						break;
+					case kHIDUsage_GD_Slider:
+					case kHIDUsage_GD_Dial:
+					case kHIDUsage_GD_Wheel:
+						cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
+						break;
+					case kHIDUsage_GD_Hatswitch:
+						cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+						break;
+					}
+					break;
+				case kHIDPage_Button:
+					break;
+				}
+			}
+		}
+	}
+}
+
+//--------------------------------------------------------------------------------//
+DeviceList MacHIDManager::freeDeviceList()
+{
+	DeviceList ret;
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+	for(; it != end; ++it)
+	{
+		if((*it)->inUse == false)
+			ret.insert(std::make_pair((*it)->type, (*it)->combinedKey));
+	}
+
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+int MacHIDManager::totalDevices(Type iType)
+{
+	int ret = 0;
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+
+	for(; it != end; ++it)
+	{
+		if((*it)->type == iType)
+			ret++;
+	}
+	
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+int MacHIDManager::freeDevices(Type iType)
+{
+	int ret = 0;
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+
+	for(; it != end; ++it)
+	{
+		if((*it)->inUse == false && (*it)->type == iType)
+			ret++;
+	}
+
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+bool MacHIDManager::vendorExist(Type iType, const std::string & vendor)
+{
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+
+	for(; it != end; ++it)
+	{
+		if((*it)->type == iType && (*it)->combinedKey == vendor)
+			return true;
+	}
+	
+	return false;
+}
+
+//--------------------------------------------------------------------------------//
+Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool bufferMode, 
+									  const std::string & vendor)
+{
+	Object *obj = 0;
+
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+	for(; it != end; ++it)
+	{
+		if((*it)->inUse == false && (*it)->type == iType && (vendor == "" || (*it)->combinedKey == vendor))
+		{
+			//create device
+		}
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//--------------------------------------------------------------------------------//
+void MacHIDManager::destroyObject(Object* obj)
+{
+	delete obj;
+}
Index: /code/branches/physics/src/ois/mac/MacHIDManager.h
===================================================================
--- /code/branches/physics/src/ois/mac/MacHIDManager.h	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacHIDManager.h	(revision 2122)
@@ -0,0 +1,100 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2007 Phillip
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacHIDManager_Header
+#define OIS_MacHIDManager_Header
+
+#include "OISPrereqs.h"
+#include "mac/MacPrereqs.h"
+#include "OISFactoryCreator.h"
+
+#import <CoreFoundation/CFString.h>
+#import <IOKit/IOKitLib.h>
+#import <IOKit/IOCFPlugIn.h>
+#import <IOKit/hid/IOHIDLib.h>
+#import <IOKit/hid/IOHIDKeys.h>
+#import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
+
+namespace OIS
+{
+	//Information needed to create Mac HID Devices
+	class HidInfo
+	{
+	public:
+		HidInfo() : type(OISUnknown), numButtons(0), numHats(0), numAxes(0), inUse(false), interface(0)
+		{
+		}
+
+		//Useful tracking information
+		Type type;
+		std::string vendor;
+		std::string productKey;
+		std::string combinedKey;
+
+		//Retain some count information for recreating devices without having to reparse
+		int numButtons;
+		int numHats;
+		int numAxes;
+		bool inUse;
+
+		//Used for opening a read/write/tracking interface to device
+		IOHIDDeviceInterface **interface;
+	};
+
+	typedef std::vector<HidInfo*> HidInfoList;
+		
+	class MacHIDManager : public FactoryCreator
+	{
+	public:
+		MacHIDManager();
+		~MacHIDManager();
+
+		void initialize();
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+	private:
+		HidInfo* enumerateDeviceProperties(CFMutableDictionaryRef propertyMap);
+		void parseDeviceProperties(CFDictionaryRef properties);
+		void parseDevicePropertiesGroup(CFDictionaryRef properties);
+
+		HidInfoList mDeviceList;		
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/mac/MacHelpers.cpp
===================================================================
--- /code/branches/physics/src/ois/mac/MacHelpers.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacHelpers.cpp	(revision 2122)
@@ -0,0 +1,158 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "mac/MacHelpers.h"
+#include "mac/MacKeyboard.h"
+#include "mac/MacMouse.h"
+#include "OISException.h"
+
+#include <Carbon/Carbon.h>
+
+using namespace OIS;
+    
+//-------------------------------------------------------------------//
+OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler,
+                        EventRef               theEvent,
+                        void*                  callClass )
+{
+    // TODO find a better way. This cast isn't very safe
+    if (callClass != NULL) {
+        ((MacKeyboard*)callClass)->_keyDownCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+    }
+    else {
+        OIS_EXCEPT(E_General, "KeyDownWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler,
+                       EventRef               theEvent,
+                       void*                  callClass )
+{
+    if (callClass != NULL) {
+        ((MacKeyboard*)callClass)->_keyUpCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+    }
+    else {
+        OIS_EXCEPT(E_General, "KeyUpWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus KeyModWrapper( EventHandlerCallRef nextHandler,
+                        EventRef               theEvent,
+                        void*                  callClass )
+{
+    if (callClass != NULL) {
+        ((MacKeyboard*)callClass)->_modChangeCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "KeyModWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+/*
+//-------------------------------------------------------------------//
+OSStatus MouseMoveWrapper( EventHandlerCallRef nextHandler,
+                           EventRef            theEvent,
+                           void*               callClass )
+{
+    if (callClass != NULL) {
+        ((MacMouse*)callClass)->_mouseMoveCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "MouseMoveWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus MouseScrollWrapper( EventHandlerCallRef nextHandler,
+                             EventRef            theEvent,
+                             void*               callClass )
+{
+    if (callClass != NULL) {
+        ((MacMouse*)callClass)->_mouseScrollCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "MouseScrollWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus MouseButtonWrapper( EventHandlerCallRef nextHandler,
+                             EventRef            theEvent,
+                             void*               callClass )
+{
+    if (callClass != NULL) {
+        ((MacMouse*)callClass)->_mouseButtonCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "MouseButtonWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+*/
+
+//-------------------------------------------------------------------//
+OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass )
+{
+    if (callClass != NULL)
+	{
+        ((MacMouse*)callClass)->_mouseCallback( theEvent );
+
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );        
+    }
+    else
+        OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!");
+}
Index: /code/branches/physics/src/ois/mac/MacHelpers.h
===================================================================
--- /code/branches/physics/src/ois/mac/MacHelpers.h	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacHelpers.h	(revision 2122)
@@ -0,0 +1,94 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacHelpers_H
+#define OIS_MacHelpers_H
+
+#include "mac/MacPrereqs.h"
+#include "OISEvents.h"
+#include "OISKeyboard.h"
+#include "OISMouse.h"
+
+#include <Carbon/Carbon.h>
+
+// This is a hack needed to get the event handler working. 
+// The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
+// so I cannot give it a class member function (unless it is static which is pointless)
+// Instead, I just pass the class* through the last paramter that gets passed to the
+// callback every time an event occurs. Then I dereference it and call the member function.
+OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+
+// This is needed for keeping an event stack for keyboard and mouse
+namespace OIS
+{
+    
+    // used in the eventStack to store the type
+    enum Mac_EventType { MAC_KEYUP = 0,
+                         MAC_KEYDOWN = 1,
+                         MAC_KEYREPEAT,
+                         MAC_MOUSEDOWN,
+                         MAC_MOUSEUP,
+                         MAC_MOUSEMOVED,
+                         MAC_MOUSESCROLL};
+    typedef enum Mac_EventType MacEventType;
+    
+    
+    // only used by MacKeyboard
+    typedef class Mac_KeyStackEvent
+    {
+        friend class MacKeyboard;
+        
+        
+    private:
+        Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {}
+        
+        MacEventType Type;
+        KeyEvent Event;
+    } MacKeyStackEvent;
+ 
+    
+
+    // only used by MacMouse
+    typedef class Mac_MouseStackEvent
+    {
+        friend class MacMouse;
+        
+    private:
+        Mac_MouseStackEvent( MouseEvent event, MacEventType type,  MouseButtonID button) : Event(event), Type(type), Button(button) {}
+        
+        MacEventType Type;
+        MouseEvent Event;
+		MouseButtonID Button;
+        
+    } MacMouseStackEvent;
+        
+}
+
+
+#endif
Index: /code/branches/physics/src/ois/mac/MacInputManager.cpp
===================================================================
--- /code/branches/physics/src/ois/mac/MacInputManager.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacInputManager.cpp	(revision 2122)
@@ -0,0 +1,203 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "mac/MacInputManager.h"
+#include "mac/MacKeyboard.h"
+#include "mac/MacMouse.h"
+#include "mac/MacHIDManager.h"
+#include "OISException.h"
+
+#include <Carbon/Carbon.h>
+
+#include <iostream>
+using namespace std;
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------//
+MacInputManager::MacInputManager() : InputManager("Mac OSX Input Manager")
+{
+    mHideMouse = true;
+    mUseRepeat = false;
+    mEventTargetRef = NULL;
+	mWindow = NULL;
+
+	keyboardUsed = mouseUsed = false;
+
+	//Setup our internal factories
+	mFactories.push_back(this);
+
+	mHIDManager = new MacHIDManager();
+	mFactories.push_back(mHIDManager);
+}
+
+//--------------------------------------------------------------------------------//
+MacInputManager::~MacInputManager()
+{
+	delete mHIDManager;
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::_initialize( ParamList &paramList )
+{
+	_parseConfigSettings( paramList );
+    
+	//Enumerate all devices attached
+	_enumerateDevices();
+	
+	mHIDManager->initialize();
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::_parseConfigSettings( ParamList &paramList )
+{
+    // Some carbon apps are running in a window, however full screen apps
+	// do not have a window, so we need to account for that too.
+	ParamList::iterator i = paramList.find("WINDOW");
+	if(i != paramList.end())
+	{
+		mWindow = (WindowRef)strtoul(i->second.c_str(), 0, 10);
+		if(mWindow == 0)
+		{
+			mWindow = NULL;
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+		else
+		{
+			//mEventTargetRef = GetWindowEventTarget(mWindow);
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+    }
+	else
+	{
+		// else get the main active window.. user might not have access to it through some
+		// graphics libraries, if that fails then try at the application level.
+		mWindow = ActiveNonFloatingWindow();
+		if(mWindow == NULL)
+		{
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+		else
+		{
+			//mEventTargetRef = GetWindowEventTarget(mWindow);
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+	}
+	
+	if(mEventTargetRef == NULL)
+		OIS_EXCEPT( E_General, "MacInputManager::_parseConfigSettings >> Unable to find a window or event target" );
+    
+    // Keyboard
+    if(paramList.find("MacAutoRepeatOn") != paramList.end())
+	{
+        if(paramList.find("MacAutoRepeatOn")->second == "true")
+		{
+            mUseRepeat = true;
+        }
+    }
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::_enumerateDevices()
+{
+}
+
+//--------------------------------------------------------------------------------//
+DeviceList MacInputManager::freeDeviceList()
+{
+	DeviceList ret;
+
+	if( keyboardUsed == false )
+		ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
+
+	if( mouseUsed == false )
+		ret.insert(std::make_pair(OISMouse, mInputSystemName));
+
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+int MacInputManager::totalDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return 1;
+	case OISMouse: return 1;
+	default: return 0;
+	}
+}
+
+//--------------------------------------------------------------------------------//
+int MacInputManager::freeDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return keyboardUsed ? 0 : 1;
+	case OISMouse: return mouseUsed ? 0 : 1;
+	default: return 0;
+	}
+}
+
+//--------------------------------------------------------------------------------//
+bool MacInputManager::vendorExist(Type iType, const std::string & vendor)
+{
+	if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
+		return true;
+
+	return false;
+}
+
+//--------------------------------------------------------------------------------//
+Object* MacInputManager::createObject(InputManager* creator, Type iType, bool bufferMode, 
+									  const std::string & vendor)
+{
+	Object *obj = 0;
+
+	switch(iType)
+	{
+	case OISKeyboard: 
+	{
+		if( keyboardUsed == false )
+			obj = new MacKeyboard(this, bufferMode, mUseRepeat);
+		break;
+	}
+	case OISMouse:
+	{
+		if( mouseUsed == false )
+			obj = new MacMouse(this, bufferMode);
+		break;
+	}
+	default:
+		break;
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::destroyObject(Object* obj)
+{
+	delete obj;
+}
Index: /code/branches/physics/src/ois/mac/MacInputManager.h
===================================================================
--- /code/branches/physics/src/ois/mac/MacInputManager.h	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacInputManager.h	(revision 2122)
@@ -0,0 +1,101 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacInputManager_H
+#define OIS_MacInputManager_H
+
+#include "OISInputManager.h"
+#include "OISFactoryCreator.h"
+#include "mac/MacPrereqs.h"
+#include <Carbon/Carbon.h>
+
+namespace OIS
+{
+    
+    class MacInputManager : public InputManager, public FactoryCreator
+    {
+    public:
+        MacInputManager();
+        virtual ~MacInputManager();
+        
+		//InputManager Overrides
+		/** @copydoc InputManager::_initialize */
+		void _initialize( ParamList &paramList );
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+		//Internal Items
+		//! Internal method, used for flaggin keyboard as available/unavailable for creation
+		void _setKeyboardUsed(bool used) {keyboardUsed = used; }
+
+		//! Internal method, used for flaggin mouse as available/unavailable for creation
+		void _setMouseUsed(bool used) { mouseUsed = used; }
+        
+        //! methodfor getting the event target
+        EventTargetRef _getEventTarget() {return mEventTargetRef;}
+        
+        //! method for getting window
+        WindowRef _getWindow() {return mWindow;}
+        
+    protected:        
+        void _parseConfigSettings( ParamList& paramList );
+        
+        void _enumerateDevices();
+        
+        static const std::string iName;
+        
+        // Mac stuff
+		EventTargetRef mEventTargetRef;
+		WindowRef mWindow;
+        
+        // settings
+        bool mHideMouse;
+        bool mUseRepeat;
+
+		//! Used to know if we used up keyboard
+		bool keyboardUsed;
+
+		//! Used to know if we used up mouse
+		bool mouseUsed;
+		
+		//! HID Manager class handling devices other than keyboard/mouse
+		MacHIDManager *mHIDManager;
+    };
+}
+#endif
Index: /code/branches/physics/src/ois/mac/MacKeyboard.cpp
===================================================================
--- /code/branches/physics/src/ois/mac/MacKeyboard.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacKeyboard.cpp	(revision 2122)
@@ -0,0 +1,467 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "mac/MacKeyboard.h"
+#include "mac/MacInputManager.h"
+#include "mac/MacHelpers.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include <Carbon/Carbon.h>
+
+#include <list>
+#include <string>
+
+const EventTypeSpec DownSpec[] = {{kEventClassKeyboard, kEventRawKeyDown},	//non - repeats
+							{kEventClassKeyboard, kEventRawKeyRepeat}}; //repeats
+const EventTypeSpec UpSpec = {kEventClassKeyboard, kEventRawKeyUp},
+			  ModSpec = {kEventClassKeyboard, kEventRawKeyModifiersChanged};
+
+const EventTypeSpec AllSpecs[] = {{kEventClassKeyboard, kEventRawKeyDown},
+						  {kEventClassKeyboard, kEventRawKeyRepeat},
+						  {kEventClassKeyboard, kEventRawKeyUp},
+						  {kEventClassKeyboard, kEventRawKeyModifiersChanged}};
+
+using namespace OIS;
+
+//-------------------------------------------------------------------//
+MacKeyboard::MacKeyboard( InputManager* creator, bool buffered, bool repeat )
+	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
+{
+	keyDownEventRef = NULL;
+	keyUpEventRef = NULL;
+	keyModEventRef = NULL;
+	
+	useRepeat = repeat;
+
+	// Get a so-called "Univeral procedure pointer" for our callback
+	keyDownUPP = NewEventHandlerUPP( KeyDownWrapper );
+	keyUpUPP   = NewEventHandlerUPP( KeyUpWrapper );
+	keyModUPP  = NewEventHandlerUPP( KeyModWrapper );
+	
+	// populate the conversion map
+	populateKeyConversion();
+
+	static_cast<MacInputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//-------------------------------------------------------------------//
+MacKeyboard::~MacKeyboard()
+{
+	// Remove our handlers so that this instance doesn't get called
+	// after it is deleted
+	if (keyDownEventRef != NULL)
+		RemoveEventHandler(keyDownEventRef);
+		
+	if (keyUpEventRef != NULL)
+		RemoveEventHandler(keyUpEventRef);
+	
+	if (keyModEventRef != NULL)
+		RemoveEventHandler(keyModEventRef);
+	
+	// dispose of our UPPs
+	DisposeEventHandlerUPP(keyDownUPP);
+	DisposeEventHandlerUPP(keyUpUPP);
+	DisposeEventHandlerUPP(keyModUPP);
+
+	//Free the input managers keyboard
+	static_cast<MacInputManager*>(mCreator)->_setKeyboardUsed(false);
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::_initialize()
+{
+	EventTargetRef event = ((MacInputManager*)mCreator)->_getEventTarget();
+
+	memset( &KeyBuffer, 0, 256 );
+	mModifiers = 0;
+	prevModMask = 0;
+	
+	// just in case this gets called after the first time.. better safe
+	if (keyDownEventRef != NULL)
+		RemoveEventHandler(keyDownEventRef);
+		
+	if (keyUpEventRef != NULL)
+		RemoveEventHandler(keyUpEventRef);
+		
+	if (keyModEventRef != NULL)
+		RemoveEventHandler(keyModEventRef);
+   
+	keyDownEventRef = NULL;
+	keyUpEventRef = NULL;
+	keyModEventRef = NULL;
+
+	OSStatus status;
+	// send both elements of downspec array... second index is for repeat events
+	if ( useRepeat )
+		status = InstallEventHandler( event, keyDownUPP, 2, DownSpec, this, &keyDownEventRef );
+	else
+		status = InstallEventHandler( event, keyDownUPP, 1, DownSpec, this, &keyDownEventRef );
+		
+	if (status != noErr)
+		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyDown event handler" );
+
+	if (InstallEventHandler( event, keyUpUPP, 1, &UpSpec, this, &keyUpEventRef ) != noErr)
+		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyUp event handler" );
+
+	if (InstallEventHandler( event, keyModUPP, 1, &ModSpec, this, &keyModEventRef ) != noErr )
+		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading Keymods event handler" );
+}
+
+//-------------------------------------------------------------------//
+bool MacKeyboard::isKeyDown( KeyCode key ) const
+{
+	return (bool)KeyBuffer[key];
+}
+
+
+//-------------------------------------------------------------------//
+void MacKeyboard::capture()
+{
+	// if not buffered just return, we update the unbuffered automatically
+	if ( !mBuffered || !mListener )
+		return;
+	
+	//If the mListener returns false, that means that we are probably deleted...
+	//send no more events and just leave as the this pointer is invalid now...
+	bool ret = true;
+	
+	// run through our event stack
+	eventStack::iterator cur_it;
+	
+	for (cur_it = pendingEvents.begin(); cur_it != pendingEvents.end(); cur_it++)
+	{
+		
+		if ( (*cur_it).Type == MAC_KEYDOWN || (*cur_it).Type == MAC_KEYREPEAT)
+			mListener->keyPressed( (*cur_it).Event );
+		else if ( (*cur_it).Type == MAC_KEYUP )
+			mListener->keyReleased( (*cur_it).Event );
+	}
+	
+	pendingEvents.clear();
+}
+
+
+//-------------------------------------------------------------------//
+std::string& MacKeyboard::getAsString( KeyCode key )
+{
+	getString = "";
+	
+	return getString;
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::setBuffered( bool buffered )
+{
+	mBuffered = buffered;
+}
+
+#include <iostream>
+//-------------------------------------------------------------------//
+void MacKeyboard::_keyDownCallback( EventRef theEvent )
+{
+	
+	UInt32 virtualKey;
+	OSStatus status;
+	
+	unsigned int time = (unsigned int)GetEventTime(theEvent);
+	
+	status = GetEventParameter(theEvent,
+					'kcod',			// get it in virtual keycode
+					typeUInt32, NULL,	// desired return type
+					sizeof(UInt32), NULL, 	// bufsize
+					&virtualKey );
+	
+	KeyCode kc = keyConversion[virtualKey];
+
+	// record what kind of text we should pass the KeyEvent
+	UniChar text[10];
+	char macChar;
+	
+	// TODO clean this up
+	if (mTextMode == Unicode)
+	{
+		//get string size
+		UInt32 stringsize;
+		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, 0, &stringsize, NULL);
+		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text );
+		status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text );
+		std::cout << "String length: " << stringsize << std::endl;
+		
+		//wstring unitext;
+		//for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
+		//wcout << "Unicode out: " << unitext << endl;
+		
+		if(stringsize > 0)
+		{
+			// for each unicode char, send an event
+			stringsize--; // no termination char
+			for ( int i = 0; i < stringsize; i++ )
+			{
+				injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)text[i] );
+			}
+		}
+	} 
+	else if (mTextMode == Ascii)
+	{
+		 
+		status = GetEventParameter( theEvent, 'kchr', typeChar, NULL, sizeof(char), NULL, &macChar );
+		injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)macChar );
+	}
+	else
+	{
+		injectEvent( kc, time, MAC_KEYDOWN );
+	}
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::_keyUpCallback( EventRef theEvent )
+{
+	UInt32 virtualKey;
+	
+	OSStatus status;
+	status = GetEventParameter( theEvent, kEventParamKeyCode, typeUInt32,
+								NULL, sizeof(UInt32), NULL, &virtualKey );
+	
+	KeyCode kc = keyConversion[virtualKey];
+	injectEvent( kc, (int)GetEventTime(theEvent), MAC_KEYUP );
+	
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::_modChangeCallback( EventRef theEvent )
+{
+	UInt32 mods;
+	
+	OSStatus status;
+	status = GetEventParameter( theEvent, kEventParamKeyModifiers,
+								typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
+	
+	// find the changed bit
+	UInt32 change = prevModMask ^ mods;
+	MacEventType newstate = ((change & prevModMask) > 0) ? MAC_KEYUP : MAC_KEYDOWN;
+	unsigned int time = (int)GetEventTime( theEvent );
+	
+	//cout << "preMask: " << hex << prevModMask << endl;
+	//cout << "ModMask: " << hex << mods << endl;
+	//cout << "Change:  " << hex << (change & prevModMask) << endl << endl;
+	
+	// TODO test modifiers on a full keyboard to check if different mask for left/right
+	switch (change)
+	{
+		case (shiftKey): // shift
+			mModifiers &= (newstate == MAC_KEYDOWN) ? Shift : ~Shift;
+			injectEvent( KC_LSHIFT, time, newstate );
+			//injectEvent( KC_RSHIFT, time, newstate );
+			break;
+			
+		case (optionKey): // option (alt)
+			mModifiers &= (newstate == MAC_KEYDOWN) ? Alt : -Alt;
+			//injectEvent( KC_RMENU, time, newstate );
+			injectEvent( KC_LMENU, time, newstate );
+			break;
+			
+		case (controlKey): // Ctrl
+			mModifiers += (newstate == MAC_KEYDOWN) ? Ctrl : -Ctrl;
+			//injectEvent( KC_RCONTROL, time, newstate );
+			injectEvent( KC_LCONTROL, time, newstate );
+			break;
+	
+		case (cmdKey): // apple
+			//injectEvent( KC_RWIN, time, newstate );
+			injectEvent( KC_LWIN, time, newstate );
+			break;
+	
+		case (kEventKeyModifierFnMask): // fn key
+			injectEvent( KC_APPS, time, newstate );
+			break;
+			
+		case (kEventKeyModifierNumLockMask): // numlock
+			injectEvent( KC_NUMLOCK, time, newstate );
+			break;
+			
+		case (alphaLock): // caps lock
+			injectEvent( KC_CAPITAL, time, newstate );
+			break;
+	}
+	
+	prevModMask = mods;
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::injectEvent( KeyCode kc, unsigned int time, MacEventType type, unsigned int txt )
+{
+	// set to 1 if this is either a keydown or repeat
+	KeyBuffer[kc] = ( type == MAC_KEYUP ) ? 0 : 1;
+	
+	if ( mBuffered && mListener )
+		pendingEvents.push_back( MacKeyStackEvent( KeyEvent(this, kc, txt), type) );
+}
+
+
+//-------------------------------------------------------------------//
+void MacKeyboard::copyKeyStates( char keys[256] ) const
+{
+	memcpy( keys, KeyBuffer, 256 );
+}
+
+
+
+//-------------------------------------------------------------------//
+void MacKeyboard::populateKeyConversion()
+{
+	// TODO finish the key mapping
+	
+	// Virtual Key Map to KeyCode
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x12, KC_1));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x13, KC_2));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x14, KC_3));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x15, KC_4));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x17, KC_5));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x16, KC_6));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1A, KC_7));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1C, KC_8));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x19, KC_9));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1D, KC_0));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x33, KC_BACK));  // might be wrong
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1B, KC_MINUS));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x18, KC_EQUALS));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x31, KC_SPACE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2B, KC_COMMA));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2F, KC_PERIOD));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2A, KC_BACKSLASH));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2C, KC_SLASH));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x21, KC_LBRACKET));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1E, KC_RBRACKET));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x35, KC_ESCAPE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x39, KC_CAPITAL));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x30, KC_TAB));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x24, KC_RETURN));  // double check return/enter
+	
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_colon, KC_COLON));	 // no colon?
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x29, KC_SEMICOLON));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x27, KC_APOSTROPHE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x32, KC_GRAVE));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0B, KC_B));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x00, KC_A));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x08, KC_C));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x02, KC_D));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0E, KC_E));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x03, KC_F));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x05, KC_G));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x04, KC_H));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x22, KC_I));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x26, KC_J));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x28, KC_K));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x25, KC_L));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2E, KC_M));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2D, KC_N));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1F, KC_O));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x23, KC_P));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0C, KC_Q));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0F, KC_R));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x01, KC_S));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x11, KC_T));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x20, KC_U));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x09, KC_V));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0D, KC_W));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x07, KC_X));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x10, KC_Y));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x06, KC_Z));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7A, KC_F1));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x78, KC_F2));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x63, KC_F3));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x76, KC_F4));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x60, KC_F5));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x61, KC_F6));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x62, KC_F7));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x64, KC_F8));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x65, KC_F9));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6D, KC_F10));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x67, KC_F11));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6F, KC_F12));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x69, KC_F13));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6B, KC_F14));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x71, KC_F15));
+	
+	//Keypad
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x52, KC_NUMPAD0));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x53, KC_NUMPAD1));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x54, KC_NUMPAD2));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x55, KC_NUMPAD3));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x56, KC_NUMPAD4));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x57, KC_NUMPAD5));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x58, KC_NUMPAD6));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x59, KC_NUMPAD7));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5B, KC_NUMPAD8));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5C, KC_NUMPAD9));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x45, KC_ADD));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4E, KC_SUBTRACT));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x41, KC_DECIMAL));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x51, KC_NUMPADEQUALS));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4B, KC_DIVIDE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x43, KC_MULTIPLY));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4C, KC_NUMPADENTER));
+	
+	//Keypad with numlock off
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_NUMPAD7));  // not sure of these
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8)); // check on a non-laptop
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Up, KC_NUMPAD9));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Left, KC_NUMPAD4));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Begin, KC_NUMPAD5));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Right, KC_NUMPAD6));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_End, KC_NUMPAD1));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Down, KC_NUMPAD2));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7E, KC_UP));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7D, KC_DOWN));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7B, KC_LEFT));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7C, KC_RIGHT));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x74, KC_PGUP));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x79, KC_PGDOWN));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_HOME));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x77, KC_END));
+	
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ));		// ??
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL)); // ??
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE));		// ??
+	
+	
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT));	  // ??
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key?
+}
+
+
+
+
Index: /code/branches/physics/src/ois/mac/MacKeyboard.h
===================================================================
--- /code/branches/physics/src/ois/mac/MacKeyboard.h	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacKeyboard.h	(revision 2122)
@@ -0,0 +1,102 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacKeyboard_H
+#define OIS_MacKeyboard_H
+
+#include "OISKeyboard.h"
+#include "mac/MacHelpers.h"
+#include "mac/MacPrereqs.h"
+
+#include <Carbon/Carbon.h>
+
+namespace OIS
+{
+    
+    class MacKeyboard : public Keyboard
+    {
+    public:
+        MacKeyboard( InputManager* creator, bool buffered, bool repeat );
+        virtual ~MacKeyboard();
+        
+        // Sets buffered mode
+        virtual void setBuffered( bool buffered );
+        
+        // unbuffered keydown check
+        virtual bool isKeyDown( KeyCode key ) const;
+        
+        // This will send listener events if buffered is on.
+        // Note that in the mac implementation, unbuffered input is
+        // automatically updated without calling this.
+        virtual void capture();
+        
+        // Copies the current key buffer
+        virtual void copyKeyStates( char keys[256] ) const;
+        
+        // Returns a description of the given key
+        virtual std::string& getAsString( KeyCode key );
+        
+        virtual Interface* queryInterface( Interface::IType type ) { return 0; }
+        
+        
+        // Public but reserved for internal use:
+        virtual void _initialize();
+        void _keyDownCallback( EventRef theEvent );
+        void _keyUpCallback( EventRef theEvent );
+        void _modChangeCallback( EventRef theEvent );
+        
+
+    protected:
+        // just to get this out of the way
+        void populateKeyConversion();
+        
+        // updates the keybuffer and optionally the eventStack
+        void injectEvent(KeyCode kc, unsigned int time, MacEventType type, unsigned int txt = 0 );
+                
+        typedef std::map<UInt32, KeyCode> VirtualtoOIS_KeyMap;
+        VirtualtoOIS_KeyMap keyConversion;
+        
+        std::string getString;
+        
+        char KeyBuffer[256];
+        UInt32 prevModMask;
+        
+        
+        // "universal procedure pointers" - required reference for callbacks
+        EventHandlerUPP keyDownUPP;
+        EventHandlerUPP keyUpUPP;
+        EventHandlerUPP keyModUPP;
+        
+        // so we can delete the handlers on destruction
+        EventHandlerRef keyDownEventRef;
+        EventHandlerRef keyUpEventRef;
+        EventHandlerRef keyModEventRef;
+        
+        // buffered events, fifo stack
+        typedef std::list<MacKeyStackEvent> eventStack;
+        eventStack pendingEvents;
+        
+        bool useRepeat;
+        
+    };
+}
+#endif
Index: /code/branches/physics/src/ois/mac/MacMouse.cpp
===================================================================
--- /code/branches/physics/src/ois/mac/MacMouse.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacMouse.cpp	(revision 2122)
@@ -0,0 +1,346 @@
+#include "mac/MacMouse.h"
+#include "mac/MacInputManager.h"
+#include "mac/MacHelpers.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include <Carbon/Carbon.h>
+
+#include <list>
+
+#include <iostream>
+
+using namespace OIS;
+
+//Events we subscribe to and remove from queue
+const EventTypeSpec mouseEvents[] = {
+	{ kEventClassMouse, kEventMouseDown },
+	{ kEventClassMouse, kEventMouseUp },
+	{ kEventClassMouse, kEventMouseMoved },
+	{ kEventClassMouse, kEventMouseDragged },
+	{ kEventClassMouse, kEventMouseWheelMoved }		
+};
+
+const EventTypeSpec WinFocusAcquired [] = {{kEventClassApplication, kEventAppDeactivated}};
+
+//-------------------------------------------------------------------//
+MacMouse::MacMouse( InputManager* creator, bool buffered )
+	: Mouse(creator->inputSystemName(), buffered, 0, creator), mNeedsToRegainFocus( false )
+{
+    mouseEventRef = NULL;
+	mWindowFocusHandler = NULL;
+
+    // Get a "Univeral procedure pointer" for our callback
+    mouseUPP = NewEventHandlerUPP(MouseWrapper);
+	mWindowFocusListener = NewEventHandlerUPP(WindowFocusChanged);
+
+	static_cast<MacInputManager*>(mCreator)->_setMouseUsed(true);
+}
+
+MacMouse::~MacMouse()
+{
+    if(mouseEventRef != NULL)
+		RemoveEventHandler(mouseEventRef);
+
+	if(mWindowFocusHandler != NULL)
+		RemoveEventHandler(mWindowFocusHandler);
+	
+	DisposeEventHandlerUPP(mouseUPP);
+	DisposeEventHandlerUPP(mWindowFocusListener);
+	
+	// Restore Mouse
+	CGAssociateMouseAndMouseCursorPosition(TRUE);
+	CGDisplayShowCursor(kCGDirectMainDisplay);
+
+	static_cast<MacInputManager*>(mCreator)->_setMouseUsed(false);
+}
+
+void MacMouse::_initialize()
+{
+	mState.clear();
+	mTempState.clear();
+	mMouseWarped = false;
+	
+	// Hide OS Mouse
+ 	CGDisplayHideCursor(kCGDirectMainDisplay);
+
+	MacInputManager* im = static_cast<MacInputManager*>(mCreator);
+	WindowRef win = im->_getWindow();
+	
+	if(win)
+	{
+		Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
+		GetWindowBounds(win, kWindowContentRgn, &clipRect);
+		
+		CGPoint warpPoint;
+		warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left;
+		warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top;
+		CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin
+		
+		mMouseWarped = true;
+	}
+
+	//Now that mouse is warped, start listening for events
+	EventTargetRef event = ((MacInputManager*)mCreator)->_getEventTarget();
+    
+	if(mouseEventRef != NULL)
+		RemoveEventHandler(mouseEventRef);
+		
+	if(mWindowFocusHandler != NULL)
+		RemoveEventHandler(mWindowFocusHandler);
+
+	mouseEventRef = mWindowFocusHandler = NULL;
+
+	if(InstallEventHandler(event, mouseUPP, GetEventTypeCount(mouseEvents), mouseEvents, this, &mouseEventRef) != noErr)
+		OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" );
+
+	if(InstallEventHandler(event, mWindowFocusListener, GetEventTypeCount(WinFocusAcquired), WinFocusAcquired, this, &mWindowFocusHandler) != noErr)
+		OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" );		
+
+	//Lock OS Mouse movement
+	mNeedsToRegainFocus = false;
+	CGAssociateMouseAndMouseCursorPosition(FALSE);
+}
+
+OSStatus MacMouse::WindowFocusChanged(EventHandlerCallRef nextHandler, EventRef event, void* macMouse)
+{
+	//std::cout << "Window Focus Changed\n";
+
+	MacMouse* _this = static_cast<MacMouse*>(macMouse);
+    if (_this)
+	{
+		_this->mNeedsToRegainFocus = true;
+		CGAssociateMouseAndMouseCursorPosition(TRUE);
+
+        // propagate the event down the chain
+        return CallNextEventHandler(nextHandler, event);
+    }
+    else
+        OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!");
+}
+
+void MacMouse::setBuffered( bool buffered )
+{
+	mBuffered = buffered;
+}
+
+void MacMouse::capture()
+{
+	mState.X.rel = 0;
+	mState.Y.rel = 0;
+	mState.Z.rel = 0;
+	    
+	if(mTempState.X.rel || mTempState.Y.rel || mTempState.Z.rel)
+	{
+		//printf("%i %i %i\n\n", mTempState.X.rel, mTempState.Y.rel, mTempState.Z.rel);
+
+		//Set new relative motion values
+		mState.X.rel = mTempState.X.rel;
+		mState.Y.rel = mTempState.Y.rel;
+		mState.Z.rel = mTempState.Z.rel;
+		
+		//Update absolute position
+		mState.X.abs += mTempState.X.rel;
+		mState.Y.abs += mTempState.Y.rel;
+		
+		if(mState.X.abs > mState.width)
+			mState.X.abs = mState.width;
+		else if(mState.X.abs < 0)
+			mState.X.abs = 0;
+
+		if(mState.Y.abs > mState.height)
+			mState.Y.abs = mState.height;
+		else if(mState.Y.abs < 0)
+			mState.Y.abs = 0;
+			
+		mState.Z.abs += mTempState.Z.rel;
+		
+		//Fire off event
+		if(mListener && mBuffered)
+			mListener->mouseMoved(MouseEvent(this, mState));
+	}
+
+	mTempState.clear();
+}
+
+void MacMouse::_mouseCallback( EventRef theEvent )
+{
+	OSStatus result = eventNotHandledErr;
+    UInt32 kind = GetEventKind (theEvent);
+
+	switch(kind)
+	{
+		case kEventMouseDragged:
+		case kEventMouseMoved:
+		{
+			//HIPoint location = {0.0f, 0.0f};
+			HIPoint delta = {0.0f, 0.0f};
+			//Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
+			
+			if(mNeedsToRegainFocus)
+				break;
+
+			// Capture the parameters
+			// TODO: Look into HIViewNewTrackingArea
+			//GetEventParameter(theEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location);
+			GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &delta);
+			
+			// Mouse X and Y are the position on the screen, 
+			// startng from top-left at 0,0 caps at full monitor resolution
+			
+			// If we have a window we need to return adjusted coordinates
+			// If not, just use raw coordinates - only do this if showing OS mouse
+			//MacInputManager* im = static_cast<MacInputManager*>(mCreator);
+			//WindowRef win = im->_getWindow();
+			
+			//if(win != NULL)
+			//{
+			//	GetWindowBounds(win, kWindowContentRgn, &clipRect);
+			//}
+            //else
+            //{
+            //    clipRect.right = mState.width;
+            //    clipRect.bottom = mState.height;
+            //}
+                
+            // clip the mouse, absolute positioning
+            //if (location.x <= clipRect.left)
+			//	mState.X.abs = 0;
+			//else if(location.x >= clipRect.right)
+			//	mState.X.abs = clipRect.right - clipRect.left;
+			//else
+			//	mState.X.abs = location.x - clipRect.left;
+			
+			//if (location.y <= clipRect.top)
+			//	mState.Y.abs = 0;
+			//else if(location.y >= clipRect.bottom)
+			//	mState.Y.abs = clipRect.bottom - clipRect.top;
+			//else
+			//	mState.Y.abs = location.y - clipRect.top;
+			
+			// relative positioning
+			if(!mMouseWarped)
+			{
+				mTempState.X.rel += delta.x;
+				mTempState.Y.rel += delta.y;
+			}
+			
+			mMouseWarped = false;
+
+			break;
+		}
+		case kEventMouseDown:
+		{
+			EventMouseButton button = 0;
+			int mouseButton = 3;
+			UInt32 modifiers = 0;
+			
+			if(mNeedsToRegainFocus)
+				break;
+
+			// Capture parameters
+			GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
+			GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
+			
+			if((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey)))
+			{
+				mouseButton = 2;
+				mState.buttons |= 1 << mouseButton;
+			}
+            else if((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey)))
+            {	
+                mouseButton = 1;
+                mState.buttons |= 1 << mouseButton;
+            }
+            else if(button == kEventMouseButtonPrimary)
+            {
+                mouseButton = 0;
+                mState.buttons |= 1 << mouseButton;
+            }
+
+            if( mListener && mBuffered )
+                mListener->mousePressed( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+
+            break;
+		}
+		case kEventMouseUp:
+		{
+			EventMouseButton button = 0;
+			int mouseButton = 3;
+			UInt32 modifiers = 0;
+			
+			if(mNeedsToRegainFocus)
+			{
+				mNeedsToRegainFocus = false;
+				CGAssociateMouseAndMouseCursorPosition(false);
+				
+				MacInputManager* im = static_cast<MacInputManager*>(mCreator);
+				WindowRef win = im->_getWindow();
+				
+				if(win)
+				{
+					Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
+					GetWindowBounds(win, kWindowContentRgn, &clipRect);
+					
+					CGPoint warpPoint;
+					warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left;
+					warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top;
+					CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin
+					
+					CGDisplayHideCursor(kCGDirectMainDisplay);
+					
+					mMouseWarped = true;
+				}
+				
+				//Once we regain focus, we do not really know what state all the buttons are in - for now, set to not pressed. todo, check current status
+				//compare against old status, and send off any needed events
+				mState.buttons = 0;
+				
+				break;
+			}
+			
+			// Capture parameters
+			GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
+			GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
+			
+			if ((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey)))
+			{
+				mouseButton = 2;
+				mState.buttons &= ~(1 << mouseButton);
+			}
+            else if ((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey)))
+            {	
+                mouseButton = 1;
+                mState.buttons &= ~(1 << mouseButton);
+            }
+            else if (button == kEventMouseButtonPrimary)
+            {
+                mouseButton = 0;
+                mState.buttons &= ~(1 << mouseButton);
+            }
+
+            if( mListener && mBuffered )
+                mListener->mouseReleased( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+
+            break;
+		}
+		case kEventMouseWheelMoved:
+		{
+			SInt32 wheelDelta = 0;
+			EventMouseWheelAxis	wheelAxis = 0; 
+
+			// Capture parameters
+			GetEventParameter(theEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &wheelAxis);
+			GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(SInt32), NULL, &wheelDelta);
+			
+			// If the Y axis of the wheel changed, then update the Z
+			// Does OIS care about the X wheel axis?
+			if(wheelAxis == kEventMouseWheelAxisY)
+				mTempState.Z.rel += (wheelDelta * 60);
+
+            break;
+		}
+		default:
+			break;
+	}    
+}
Index: /code/branches/physics/src/ois/mac/MacMouse.h
===================================================================
--- /code/branches/physics/src/ois/mac/MacMouse.h	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacMouse.h	(revision 2122)
@@ -0,0 +1,51 @@
+#ifndef OIS_MacMouse_H
+#define OIS_MacMouse_H
+
+#include "OISMouse.h"
+#include "mac/MacHelpers.h"
+#include "mac/MacPrereqs.h"
+
+#include <Carbon/Carbon.h>
+
+namespace OIS
+{
+	class MacMouse : public Mouse
+    {
+	public:
+		MacMouse( InputManager* creator, bool buffered );
+		virtual ~MacMouse();
+		
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+        
+	public:
+        void _mouseCallback( EventRef theEvent );
+
+	protected:
+		static OSStatus WindowFocusChanged(EventHandlerCallRef nextHandler, EventRef event, void* macMouse);
+        
+        // "universal procedure pointers" - required reference for callbacks
+		EventHandlerUPP mouseUPP;
+		EventHandlerRef mouseEventRef;
+		
+		EventHandlerUPP mWindowFocusListener;
+		EventHandlerRef mWindowFocusHandler;
+		
+		bool mNeedsToRegainFocus;
+		bool mMouseWarped;
+		
+		MouseState mTempState;
+	};
+}
+
+
+#endif // OIS_MacMouse_H
Index: /code/branches/physics/src/ois/mac/MacPrereqs.h
===================================================================
--- /code/branches/physics/src/ois/mac/MacPrereqs.h	(revision 2122)
+++ /code/branches/physics/src/ois/mac/MacPrereqs.h	(revision 2122)
@@ -0,0 +1,57 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacPrereqs_H
+#define OIS_MacPrereqs_H
+
+#include <string>
+#include <list>
+#include <CoreFoundation/CoreFoundation.h>
+
+namespace OIS
+{
+    class MacInputManager;
+	class MacHIDManager;
+	class MacMouse;
+    class MacKeyboard;
+
+	/** 
+		Simple wrapper class for CFString which will create a valid CFString and retain ownership until class instance is outof scope
+		To Access the CFStringRef instance, simply cast to void*, pass into a function expecting a void* CFStringRef object, or access via cf_str() method
+	*/
+	class OIS_CFString
+	{
+	public:
+		OIS_CFString() { m_StringRef = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); }
+		OIS_CFString(const char* c_str) { m_StringRef = CFStringCreateWithCString(NULL, c_str, kCFStringEncodingUTF8); }
+		OIS_CFString(const std::string &s_str) { m_StringRef = CFStringCreateWithCString(NULL, s_str.c_str(), kCFStringEncodingUTF8); }
+		~OIS_CFString() { CFRelease(m_StringRef); }
+
+		//Allow this class to be autoconverted to base class of StringRef (void*)
+		operator void*() { return (void*)m_StringRef; }
+		CFStringRef cf_str() { return m_StringRef; }
+	
+	private:
+		CFStringRef m_StringRef;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/win32/Win32ForceFeedback.cpp
===================================================================
--- /code/branches/physics/src/ois/win32/Win32ForceFeedback.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32ForceFeedback.cpp	(revision 2122)
@@ -0,0 +1,334 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32ForceFeedback.h"
+#include "OISException.h"
+#include <Math.h>
+
+#if defined (_DEBUG)
+  #include <sstream>
+#endif
+
+using namespace OIS;
+
+//--------------------------------------------------------------//
+Win32ForceFeedback::Win32ForceFeedback(IDirectInputDevice8* joy) :
+	mHandles(0), mJoyStick(joy)
+{
+}
+
+//--------------------------------------------------------------//
+Win32ForceFeedback::~Win32ForceFeedback()
+{
+	//Get the effect - if it exists
+	for(EffectList::iterator i = mEffectList.begin(); i != mEffectList.end(); ++i )
+	{
+		LPDIRECTINPUTEFFECT dxEffect = i->second;
+		if( dxEffect )
+			dxEffect->Unload();
+	}
+
+	mEffectList.clear();
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::upload( const Effect* effect )
+{
+	switch( effect->force )
+	{
+		case OIS::Effect::ConstantForce: _updateConstantEffect(effect);	break;
+		case OIS::Effect::RampForce: _updateRampEffect(effect);	break;
+		case OIS::Effect::PeriodicForce: _updatePeriodicEffect(effect);	break;
+		case OIS::Effect::ConditionalForce:	_updateConditionalEffect(effect); break;
+		//case OIS::Effect::CustomForce: _updateCustomEffect(effect); break;
+		default: OIS_EXCEPT(E_NotImplemented, "Requested Force not Implemented yet, sorry!"); break;
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::modify( const Effect* eff )
+{
+	//Modifying is essentially the same as an upload, so, just reuse that function
+	upload(eff);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::remove( const Effect* eff )
+{
+	//Get the effect - if it exists
+	EffectList::iterator i = mEffectList.find(eff->_handle);
+	if( i != mEffectList.end() )
+	{
+		LPDIRECTINPUTEFFECT dxEffect = i->second;
+		if( dxEffect )
+		{
+			dxEffect->Stop();
+			//We care about the return value - as the effect might not
+			//have been unlaoded
+			if( SUCCEEDED(dxEffect->Unload()) )
+				mEffectList.erase(i);
+		}
+		else
+			mEffectList.erase(i);
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::setMasterGain( float level )
+{
+	//Between 0 - 10,000
+	int gain_level = (int)(10000.0f * level);
+
+	if( gain_level > 10000 )
+		gain_level = 10000;
+	else if( gain_level < 0 )
+		gain_level = 0;
+
+	DIPROPDWORD DIPropGain;
+	DIPropGain.diph.dwSize       = sizeof(DIPropGain);
+	DIPropGain.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	DIPropGain.diph.dwObj        = 0;
+	DIPropGain.diph.dwHow        = DIPH_DEVICE;
+	DIPropGain.dwData            = gain_level;
+
+	mJoyStick->SetProperty(DIPROP_FFGAIN, &DIPropGain.diph);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::setAutoCenterMode( bool auto_on )
+{
+	//DI Property DIPROPAUTOCENTER_OFF = 0, 1 is on
+	DIPROPDWORD DIPropAutoCenter;
+	DIPropAutoCenter.diph.dwSize       = sizeof(DIPropAutoCenter);
+	DIPropAutoCenter.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	DIPropAutoCenter.diph.dwObj        = 0;
+	DIPropAutoCenter.diph.dwHow        = DIPH_DEVICE;
+	DIPropAutoCenter.dwData            = auto_on;
+
+	//hr =
+	mJoyStick->SetProperty(DIPROP_AUTOCENTER, &DIPropAutoCenter.diph);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateConstantEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DICONSTANTFORCE cf;
+	DIEFFECT        diEffect;
+
+	//Currently only support 1 axis
+	//if( effect->getNumAxes() == 1 )
+	cf.lMagnitude = static_cast<ConstantEffect*>(effect->getForceEffect())->level;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DICONSTANTFORCE), &cf, effect);
+	_upload(GUID_ConstantForce, &diEffect, effect);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateRampEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DIRAMPFORCE     rf;
+	DIEFFECT        diEffect;
+
+	//Currently only support 1 axis
+	rf.lStart = static_cast<RampEffect*>(effect->getForceEffect())->startLevel;
+	rf.lEnd = static_cast<RampEffect*>(effect->getForceEffect())->endLevel;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DIRAMPFORCE), &rf, effect);
+	_upload(GUID_RampForce, &diEffect, effect);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updatePeriodicEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DIPERIODIC      pf;
+	DIEFFECT        diEffect;
+
+	//Currently only support 1 axis
+	pf.dwMagnitude = static_cast<PeriodicEffect*>(effect->getForceEffect())->magnitude;
+	pf.lOffset = static_cast<PeriodicEffect*>(effect->getForceEffect())->offset;
+	pf.dwPhase = static_cast<PeriodicEffect*>(effect->getForceEffect())->phase;
+	pf.dwPeriod = static_cast<PeriodicEffect*>(effect->getForceEffect())->period;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DIPERIODIC), &pf, effect);
+
+	switch( effect->type )
+	{
+	case OIS::Effect::Square: _upload(GUID_Square, &diEffect, effect); break;
+	case OIS::Effect::Triangle: _upload(GUID_Triangle, &diEffect, effect); break;
+	case OIS::Effect::Sine: _upload(GUID_Sine, &diEffect, effect); break;
+	case OIS::Effect::SawToothUp: _upload(GUID_SawtoothUp, &diEffect, effect); break;
+	case OIS::Effect::SawToothDown:	_upload(GUID_SawtoothDown, &diEffect, effect); break;
+	default: break;
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateConditionalEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DICONDITION     cf;
+	DIEFFECT        diEffect;
+
+	cf.lOffset = static_cast<ConditionalEffect*>(effect->getForceEffect())->deadband;
+	cf.lPositiveCoefficient = static_cast<ConditionalEffect*>(effect->getForceEffect())->rightCoeff;
+	cf.lNegativeCoefficient = static_cast<ConditionalEffect*>(effect->getForceEffect())->leftCoeff;
+	cf.dwPositiveSaturation = static_cast<ConditionalEffect*>(effect->getForceEffect())->rightSaturation;
+	cf.dwNegativeSaturation = static_cast<ConditionalEffect*>(effect->getForceEffect())->leftSaturation;
+	cf.lDeadBand = static_cast<ConditionalEffect*>(effect->getForceEffect())->deadband;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DICONDITION), &cf, effect);
+
+	switch( effect->type )
+	{
+	case OIS::Effect::Friction:	_upload(GUID_Friction, &diEffect, effect); break;
+	case OIS::Effect::Damper: _upload(GUID_Damper, &diEffect, effect); break;
+	case OIS::Effect::Inertia: _upload(GUID_Inertia, &diEffect, effect); break;
+	case OIS::Effect::Spring: _upload(GUID_Spring, &diEffect, effect); break;
+	default: break;
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateCustomEffect( const Effect* /*effect*/ )
+{
+	//DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	//LONG            rglDirection[2] = { 0, 0 };
+	//DICUSTOMFORCE cf;
+	//DIEFFECT        diEffect;
+	//cf.cChannels = 0;
+	//cf.dwSamplePeriod = 0;
+	//cf.cSamples = 0;
+	//cf.rglForceData = 0;
+	//_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DICUSTOMFORCE), &cf, effect);
+	//_upload(GUID_CustomForce, &diEffect, effect);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_setCommonProperties(
+		DIEFFECT* diEffect, DWORD* rgdwAxes,
+		LONG* rglDirection, DWORD struct_size,
+		LPVOID struct_type, const Effect* effect )
+{
+	ZeroMemory(diEffect, sizeof(DIEFFECT));
+
+	diEffect->dwSize                  = sizeof(DIEFFECT);
+	diEffect->dwFlags                 = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
+	diEffect->dwDuration              = effect->replay_length;
+	diEffect->dwSamplePeriod          = 0;
+	diEffect->dwGain                  = DI_FFNOMINALMAX;
+	diEffect->dwTriggerButton         = DIEB_NOTRIGGER;
+	diEffect->dwTriggerRepeatInterval = 0;
+	diEffect->cAxes                   = effect->getNumAxes();
+	diEffect->rgdwAxes                = rgdwAxes;
+	diEffect->rglDirection            = rglDirection;
+	diEffect->lpEnvelope              = 0;
+	diEffect->cbTypeSpecificParams    = struct_size;
+	diEffect->lpvTypeSpecificParams   = struct_type;
+	diEffect->dwStartDelay            = effect->replay_delay;
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_upload( GUID guid, DIEFFECT* diEffect, const Effect* effect)
+{
+	LPDIRECTINPUTEFFECT dxEffect = 0;
+
+	//Get the effect - if it exists
+	EffectList::iterator i = mEffectList.find(effect->_handle);
+	//It has been created already
+	if( i != mEffectList.end() )
+		dxEffect = i->second;
+	else //This effect has not yet been created - generate a handle
+		effect->_handle = mHandles++;
+
+	if( dxEffect == 0 )
+	{
+		//This effect has not yet been created, so create it
+		HRESULT hr = mJoyStick->CreateEffect(guid, diEffect, &dxEffect, NULL);
+		if(SUCCEEDED(hr))
+		{
+			mEffectList[effect->_handle] = dxEffect;
+			dxEffect->Start(INFINITE,0);
+		}
+		else if( hr == DIERR_DEVICEFULL )
+			OIS_EXCEPT(E_DeviceFull, "Remove an effect before adding more!");
+		else
+			OIS_EXCEPT(E_General, "Unknown error creating effect->..");
+	}
+	else
+	{
+		//ToDo -- Update the Effect
+		HRESULT hr = dxEffect->SetParameters( diEffect, DIEP_DIRECTION |
+			DIEP_DURATION | DIEP_ENVELOPE | DIEP_STARTDELAY | DIEP_TRIGGERBUTTON |
+			DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS | DIEP_START );
+
+		if(FAILED(hr)) OIS_EXCEPT(E_InvalidParam, "Error updating device!");
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_addEffectSupport( LPCDIEFFECTINFO pdei )
+{
+	//Determine what the effect is and how it corresponds to our OIS's Enums
+	//We could save the GUIDs too, however, we will just use the predefined
+	//ones later
+	if( pdei->guid == GUID_ConstantForce )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Constant );
+	else if( pdei->guid == GUID_Triangle )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Triangle );
+	else if( pdei->guid == GUID_Spring )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Spring );
+	else if( pdei->guid == GUID_Friction )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Friction );
+	else if( pdei->guid == GUID_Square )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Square );
+	else if( pdei->guid == GUID_Sine )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Sine );
+	else if( pdei->guid == GUID_SawtoothUp )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::SawToothUp );
+	else if( pdei->guid == GUID_SawtoothDown )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::SawToothDown );
+	else if( pdei->guid == GUID_Damper )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Damper );
+	else if( pdei->guid == GUID_Inertia )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Inertia );
+	else if( pdei->guid == GUID_CustomForce )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Custom );
+	else if( pdei->guid == GUID_RampForce )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Ramp );
+#if defined (_DEBUG)
+	//Only care about this for Debugging Purposes
+	//else
+	//{
+	//	std::ostringstream ss;
+	//	ss << "Win32ForceFeedback, DirectInput8 Effect not found. Reported as: "
+	//	   << pdei->tszName;
+	//	OIS_EXCEPT( E_General, ss.str().c_str());
+	//}
+#endif
+}
Index: /code/branches/physics/src/ois/win32/Win32ForceFeedback.h
===================================================================
--- /code/branches/physics/src/ois/win32/Win32ForceFeedback.h	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32ForceFeedback.h	(revision 2122)
@@ -0,0 +1,89 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Win32ForceFeedBack_H
+#define OIS_Win32ForceFeedBack_H
+
+#include "OISPrereqs.h"
+#include "OISForceFeedback.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32ForceFeedback : public ForceFeedback
+	{
+		Win32ForceFeedback() {}
+	public:
+		Win32ForceFeedback(IDirectInputDevice8* joy);
+		~Win32ForceFeedback();
+
+		/** @copydoc ForceFeedback::upload */
+		void upload( const Effect* effect );
+
+		/** @copydoc ForceFeedback::modify */
+		void modify( const Effect* effect );
+
+		/** @copydoc ForceFeedback::remove */
+		void remove( const Effect* effect );
+
+		/** @copydoc ForceFeedback::setMasterGain */
+		void setMasterGain( float level );
+		
+		/** @copydoc ForceFeedback::setAutoCenterMode */
+		void setAutoCenterMode( bool auto_on );
+
+		/** @copydoc ForceFeedback::getFFAxesNumber 
+			xxx todo - Actually return correct number
+		*/
+		short getFFAxesNumber() {return 1;}
+
+		/**
+			@remarks
+			Internal use.. Used during enumeration to build a list of a devices
+			support effects.
+		*/
+		void _addEffectSupport( LPCDIEFFECTINFO pdei );
+
+	protected:
+		//Specific Effect Settings
+		void _updateConstantEffect( const Effect* effect );
+		void _updateRampEffect( const Effect* effect );
+		void _updatePeriodicEffect( const Effect* effect );
+		void _updateConditionalEffect( const Effect* effect );
+		void _updateCustomEffect( const Effect* effect );
+		//Sets the common properties to all effects
+		void _setCommonProperties( DIEFFECT* diEffect, DWORD* rgdwAxes,
+									LONG* rglDirection, DWORD struct_size, 
+									LPVOID struct_type, const Effect* effect );
+		//Actually do the upload
+		void _upload( GUID, DIEFFECT*, const Effect* );
+
+		typedef std::map<int,LPDIRECTINPUTEFFECT> EffectList;
+		EffectList mEffectList;
+		//Simple unique handle creation - allows for upto 2+ million effects
+		//during the lifetime of application. Hopefully, that is enough.
+		int mHandles;
+
+		IDirectInputDevice8* mJoyStick;
+	};
+}
+#endif //OIS_Win32ForceFeedBack_H
Index: /code/branches/physics/src/ois/win32/Win32InputManager.cpp
===================================================================
--- /code/branches/physics/src/ois/win32/Win32InputManager.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32InputManager.cpp	(revision 2122)
@@ -0,0 +1,254 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32InputManager.h"
+#include "Win32/Win32Keyboard.h"
+#include "Win32/Win32Mouse.h"
+#include "Win32/Win32JoyStick.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------//
+Win32InputManager::Win32InputManager() : InputManager("Win32InputManager")
+{
+	hWnd = 0;
+	mDirectInput = 0;
+
+	kbSettings    = 0;
+	mouseSettings = 0;
+	joySettings   = 0;
+
+	joySticks = 0;
+	keyboardUsed = mouseUsed = false;
+
+	//Setup our internal factories
+	mFactories.push_back(this);
+}
+
+//--------------------------------------------------------------------------------//
+Win32InputManager::~Win32InputManager()
+{
+	if( mDirectInput )
+	{
+		mDirectInput->Release();
+		mDirectInput = 0;
+	}
+}
+
+//--------------------------------------------------------------------------------//
+void Win32InputManager::_initialize( ParamList &paramList )
+{
+	HINSTANCE hInst = 0;
+	HRESULT hr;
+
+	//TODO 64 bit proof this little conversion xxx wip
+	//First of all, get the Windows Handle and Instance
+	ParamList::iterator i = paramList.find("WINDOW");
+	if( i == paramList.end() ) 
+		OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" );
+
+	hWnd  = (HWND)strtoul(i->second.c_str(), 0, 10);
+
+	if( IsWindow(hWnd) == 0 )
+		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> The sent HWND is not valid!");
+
+	hInst = GetModuleHandle(0);
+
+	//Create the device
+	hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
+    if (FAILED(hr))	
+		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!");
+
+	//Ok, now we have DirectInput, parse whatever extra settings were sent to us
+	_parseConfigSettings( paramList );
+	_enumerateDevices();
+}
+
+//--------------------------------------------------------------------------------//
+void Win32InputManager::_parseConfigSettings( ParamList &paramList )
+{
+	//Here we pick up settings such as a device's cooperation mode
+	std::map<std::string, DWORD> temp;
+	temp["DISCL_BACKGROUND"]	= DISCL_BACKGROUND;
+	temp["DISCL_EXCLUSIVE"]		= DISCL_EXCLUSIVE;
+	temp["DISCL_FOREGROUND"]	= DISCL_FOREGROUND;
+	temp["DISCL_NONEXCLUSIVE"]	= DISCL_NONEXCLUSIVE;
+	temp["DISCL_NOWINKEY"]		= DISCL_NOWINKEY;
+
+	//Check for pairs: ie. ("w32_keyboard","DISCL_NOWINKEY")("w32_keyboard","DISCL_FOREGROUND")
+	ParamList::iterator i = paramList.begin(), e = paramList.end();
+	for( ; i != e; ++i ) 
+	{
+		if( i->first == "w32_keyboard" )
+				kbSettings |= temp[i->second];
+		else if( i->first == "w32_mouse" )
+				mouseSettings |= temp[i->second];
+		else if( i->first == "w32_joystick" )
+				joySettings |= temp[i->second];
+	}
+	if( kbSettings == 0 ) kbSettings = DISCL_FOREGROUND | DISCL_NONEXCLUSIVE | DISCL_NOWINKEY;
+	if( mouseSettings == 0 ) mouseSettings = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
+	if( joySettings == 0 ) joySettings = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
+}
+
+//--------------------------------------------------------------------------------//
+void Win32InputManager::_enumerateDevices()
+{
+	//Enumerate all attached devices
+	mDirectInput->EnumDevices(NULL, _DIEnumKbdCallback, this, DIEDFL_ATTACHEDONLY); 
+}
+
+//--------------------------------------------------------------------------------//
+BOOL CALLBACK Win32InputManager::_DIEnumKbdCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
+{
+	Win32InputManager *_this_ = static_cast<Win32InputManager*>(pvRef);
+	if( GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_JOYSTICK ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_GAMEPAD ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_1STPERSON ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_DRIVING ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_FLIGHT)
+	{
+		JoyStickInfo jsInfo;
+		jsInfo.deviceID = lpddi->guidInstance;
+		jsInfo.vendor = lpddi->tszInstanceName;
+		jsInfo.devId = _this_->joySticks;
+
+		_this_->joySticks++;
+		
+		_this_->unusedJoyStickList.push_back( jsInfo );
+	}
+
+	return DIENUM_CONTINUE;
+}
+
+//----------------------------------------------------------------------------//
+void Win32InputManager::_returnJoyStick(const JoyStickInfo& joystick)
+{
+	unusedJoyStickList.push_back(joystick);
+}
+
+//----------------------------------------------------------------------------//
+DeviceList Win32InputManager::freeDeviceList()
+{
+	DeviceList ret;
+
+	if( keyboardUsed == false )
+		ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
+
+	if( mouseUsed == false )
+		ret.insert(std::make_pair(OISMouse, mInputSystemName));
+
+	for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		ret.insert(std::make_pair(OISJoyStick, i->vendor));
+
+	return ret;
+}
+
+//----------------------------------------------------------------------------//
+int Win32InputManager::totalDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return 1;
+	case OISMouse: return 1;
+	case OISJoyStick: return joySticks;
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+int Win32InputManager::freeDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return keyboardUsed ? 0 : 1;
+	case OISMouse: return mouseUsed ? 0 : 1;
+	case OISJoyStick: return (int)unusedJoyStickList.size();
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+bool Win32InputManager::vendorExist(Type iType, const std::string & vendor)
+{
+	if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
+	{
+		return true;
+	}
+	else if( iType == OISJoyStick )
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+			if(i->vendor == vendor)
+				return true;
+	}
+
+	return false;
+}
+
+//----------------------------------------------------------------------------//
+Object* Win32InputManager::createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor)
+{
+	Object *obj = 0;
+
+	switch(iType)
+	{
+	case OISKeyboard: 
+	{
+		if( keyboardUsed == false )
+			obj = new Win32Keyboard(this, mDirectInput, bufferMode, kbSettings);
+		break;
+	}
+	case OISMouse:
+	{
+		if( mouseUsed == false )
+			obj = new Win32Mouse(this, mDirectInput, bufferMode, mouseSettings);
+		break;
+	}
+	case OISJoyStick:
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		{
+			if(vendor == "" || i->vendor == vendor)
+			{
+				obj = new Win32JoyStick(this, mDirectInput, bufferMode, joySettings, *i);
+				unusedJoyStickList.erase(i);
+				break;
+			}
+		}
+		break;
+	}
+	default:
+		break;
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//----------------------------------------------------------------------------//
+void Win32InputManager::destroyObject(Object* obj)
+{
+	delete obj;
+}
Index: /code/branches/physics/src/ois/win32/Win32InputManager.h
===================================================================
--- /code/branches/physics/src/ois/win32/Win32InputManager.h	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32InputManager.h	(revision 2122)
@@ -0,0 +1,113 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Win32InputManager_H
+#define OIS_Win32InputManager_H
+
+#include "OISInputManager.h"
+#include "OISFactoryCreator.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	/**	Win32InputManager specialization - Using DirectInput8 */
+	class Win32InputManager : public InputManager, public FactoryCreator
+	{
+	public:
+		Win32InputManager();
+		virtual ~Win32InputManager();
+
+		//InputManager Overrides
+		/** @copydoc InputManager::_initialize */
+		void _initialize( ParamList &paramList );
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+		//Internal Items
+		//! Internal method, used for flaggin keyboard as available/unavailable for creation
+		void _setKeyboardUsed(bool used) {keyboardUsed = used; }
+
+		//! Internal method, used for flaggin mouse as available/unavailable for creation
+		void _setMouseUsed(bool used) { mouseUsed = used; }
+		
+		//! Internal method, return unused joystick to queue
+		void _returnJoyStick(const JoyStickInfo& joystick);
+
+		//! Returns HWND needed by DirectInput Device Object
+		HWND getWindowHandle() { return hWnd; }
+
+	protected:
+		//! internal class method for dealing with param list
+		void _parseConfigSettings( ParamList &paramList );
+		
+		//! internal class method for finding attached devices
+		void _enumerateDevices();
+
+		//! Used during device enumeration
+		static BOOL CALLBACK _DIEnumKbdCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
+
+		//! Keep a list of all joysticks enumerated, but not in use
+		JoyStickInfoList unusedJoyStickList;
+
+		//! The window handle we are using
+		HWND hWnd;
+
+		//! Direct Input Interface
+		IDirectInput8* mDirectInput;
+
+		//! Used for keyboard device settings
+		DWORD kbSettings;
+
+		//! Used for mouse device settings
+		DWORD mouseSettings;
+
+		//! Used for joystick device settings
+		DWORD joySettings;
+
+		//! Number of total joysticks (inuse or not)
+		char joySticks;
+
+		//! Used to know if we used up keyboard
+		bool keyboardUsed;
+
+		//! Used to know if we used up mouse
+		bool mouseUsed;
+	};
+}
+#endif
Index: /code/branches/physics/src/ois/win32/Win32JoyStick.cpp
===================================================================
--- /code/branches/physics/src/ois/win32/Win32JoyStick.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32JoyStick.cpp	(revision 2122)
@@ -0,0 +1,403 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32JoyStick.h"
+#include "Win32/Win32InputManager.h"
+#include "Win32/Win32ForceFeedback.h"
+#include "OISEvents.h"
+#include "OISException.h"
+
+#include <cassert>
+
+//DX Only defines macros for the JOYSTICK not JOYSTICK2, so fix it
+#undef DIJOFS_BUTTON
+#undef DIJOFS_POV
+
+#define DIJOFS_BUTTON(n)  (FIELD_OFFSET(DIJOYSTATE2, rgbButtons) + (n))
+#define DIJOFS_POV(n)     (FIELD_OFFSET(DIJOYSTATE2, rgdwPOV)+(n)*sizeof(DWORD))
+#define DIJOFS_SLIDER0(n) (FIELD_OFFSET(DIJOYSTATE2, rglSlider)+(n) * sizeof(LONG))
+#define DIJOFS_SLIDER1(n) (FIELD_OFFSET(DIJOYSTATE2, rglVSlider)+(n) * sizeof(LONG))
+#define DIJOFS_SLIDER2(n) (FIELD_OFFSET(DIJOYSTATE2, rglASlider)+(n) * sizeof(LONG))
+#define DIJOFS_SLIDER3(n) (FIELD_OFFSET(DIJOYSTATE2, rglFSlider)+(n) * sizeof(LONG))
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+Win32JoyStick::Win32JoyStick( InputManager* creator, IDirectInput8* pDI,
+	bool buffered, DWORD coopSettings, const JoyStickInfo &info )
+	: JoyStick(info.vendor, buffered, info.devId, creator)
+{
+	mDirectInput = pDI;
+	coopSetting = coopSettings;
+	mJoyStick = 0;
+
+	deviceGuid = info.deviceID;
+
+	ff_device = 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+Win32JoyStick::~Win32JoyStick()
+{
+	delete ff_device;
+
+	if(mJoyStick)
+	{
+		mJoyStick->Unacquire();
+		mJoyStick->Release();
+		mJoyStick = 0;
+	}
+
+	//Return joystick to pool
+	JoyStickInfo js;
+	js.deviceID = deviceGuid;
+	js.devId = mDevID;
+	js.vendor = mVendor;
+	static_cast<Win32InputManager*>(mCreator)->_returnJoyStick(js);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::_initialize()
+{
+	//Clear old state
+	mState.mAxes.clear();
+
+	delete ff_device;
+	ff_device = 0;
+
+	DIPROPDWORD dipdw;
+
+	dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
+	dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	dipdw.diph.dwObj        = 0;
+	dipdw.diph.dwHow        = DIPH_DEVICE;
+	dipdw.dwData            = JOYSTICK_DX_BUFFERSIZE;
+
+	if(FAILED(mDirectInput->CreateDevice(deviceGuid, &mJoyStick, NULL)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
+
+	if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
+
+	HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
+
+	if(FAILED(mJoyStick->SetCooperativeLevel( hwin, coopSetting)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> failed to set cooperation level!");
+
+	if( FAILED(mJoyStick->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set buffer size property" );
+
+	//Enumerate all axes/buttons/sliders/etc before aquiring
+	_enumerate();
+
+	mState.clear();
+
+	capture();
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::_enumerate()
+{
+	//We can check force feedback here too
+	DIDEVCAPS  DIJoyCaps;
+	DIJoyCaps.dwSize = sizeof(DIDEVCAPS);
+	mJoyStick->GetCapabilities(&DIJoyCaps);
+
+	mPOVs = (short)DIJoyCaps.dwPOVs;
+
+	mState.mButtons.resize(DIJoyCaps.dwButtons);
+	mState.mAxes.resize(DIJoyCaps.dwAxes);
+
+	//Reset the axis mapping enumeration value
+	_AxisNumber = 0;
+
+	//Enumerate Force Feedback (if any)
+	mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);
+
+	//Enumerate and set axis constraints (and check FF Axes)
+	mJoyStick->EnumObjects(DIEnumDeviceObjectsCallback, this, DIDFT_AXIS);
+}
+
+//--------------------------------------------------------------------------------------------------//
+BOOL CALLBACK Win32JoyStick::DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
+{
+	Win32JoyStick* _this = (Win32JoyStick*)pvRef;
+
+	//Setup mappings
+	DIPROPPOINTER diptr;
+	diptr.diph.dwSize       = sizeof(DIPROPPOINTER);
+	diptr.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	diptr.diph.dwHow        = DIPH_BYID;
+	diptr.diph.dwObj        = lpddoi->dwType;
+	//Add a magic number to recognise we set seomthing
+	diptr.uData             = 0x13130000 | _this->_AxisNumber;
+
+	//Check if axis is slider, if so, do not treat as regular axis
+	if(GUID_Slider == lpddoi->guidType)
+	{
+		++_this->mSliders;
+
+		//Decrease Axes, since this slider shows up in a different place
+		_this->mState.mAxes.pop_back();
+	}
+	else if (FAILED(_this->mJoyStick->SetProperty(DIPROP_APPDATA, &diptr.diph)))
+	{	//If for some reason we could not set needed user data, just ignore this axis
+		return DIENUM_CONTINUE;
+	}
+
+	//Increase for next time through
+	if(GUID_Slider != lpddoi->guidType)
+		_this->_AxisNumber += 1;
+
+	//Set range
+	DIPROPRANGE diprg;
+	diprg.diph.dwSize       = sizeof(DIPROPRANGE);
+	diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	diprg.diph.dwHow        = DIPH_BYID;
+	diprg.diph.dwObj        = lpddoi->dwType;
+	diprg.lMin              = MIN_AXIS;
+	diprg.lMax              = MAX_AXIS;
+
+	if (FAILED(_this->mJoyStick->SetProperty(DIPROP_RANGE, &diprg.diph)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_DIEnumDeviceObjectsCallback >> Failed to set min/max range property" );
+
+	//Check if FF Axes
+	if((lpddoi->dwFlags & DIDOI_FFACTUATOR) != 0 )
+	{
+		if( _this->ff_device )
+		{
+			//todo - increment force feedback axis count
+		}
+	}
+
+	return DIENUM_CONTINUE;
+}
+
+//--------------------------------------------------------------------------------------------------//
+BOOL CALLBACK Win32JoyStick::DIEnumEffectsCallback(LPCDIEFFECTINFO pdei, LPVOID pvRef)
+{
+	Win32JoyStick* _this = (Win32JoyStick*)pvRef;
+
+	//Create the FF class after we know there is at least one effect type
+	if( _this->ff_device == 0 )
+		_this->ff_device = new Win32ForceFeedback(_this->mJoyStick);
+
+	_this->ff_device->_addEffectSupport( pdei );
+
+	return DIENUM_CONTINUE;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::capture()
+{
+	DIDEVICEOBJECTDATA diBuff[JOYSTICK_DX_BUFFERSIZE];
+	DWORD entries = JOYSTICK_DX_BUFFERSIZE;
+
+	// Poll the device to read the current state
+	HRESULT hr = mJoyStick->Poll();
+	if( hr == DI_OK )
+		hr = mJoyStick->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+
+	if( hr != DI_OK )
+	{
+		hr = mJoyStick->Acquire();
+		while( hr == DIERR_INPUTLOST )
+			hr = mJoyStick->Acquire();
+
+		// Poll the device to read the current state
+	    mJoyStick->Poll();
+		hr = mJoyStick->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+		//Perhaps the user just tabbed away
+		if( FAILED(hr) )
+			return;
+	}
+
+	bool axisMoved[24] = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
+						  false,false,false,false,false,false,false,false};
+	bool sliderMoved[4] = {false,false,false,false};
+
+	//Loop through all the events
+	for(unsigned int i = 0; i < entries; ++i)
+	{
+		//This may seem outof order, but is in order of the way these variables
+		//are declared in the JoyStick State 2 structure.
+		switch(diBuff[i].dwOfs)
+		{
+		//------ slider -//
+		case DIJOFS_SLIDER0(0):
+			sliderMoved[0] = true;
+			mState.mSliders[0].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER0(1):
+			sliderMoved[0] = true;
+			mState.mSliders[0].abY = diBuff[i].dwData;
+			break;
+		//----- Max 4 POVs Next ---------------//
+		case DIJOFS_POV(0):
+			if(!_changePOV(0,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(1):
+			if(!_changePOV(1,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(2):
+			if(!_changePOV(2,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(3):
+			if(!_changePOV(3,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_SLIDER1(0):
+			sliderMoved[1] = true;
+			mState.mSliders[1].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER1(1):
+			sliderMoved[1] = true;
+			mState.mSliders[1].abY = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER2(0):
+			sliderMoved[2] = true;
+			mState.mSliders[2].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER2(1):
+			sliderMoved[2] = true;
+			mState.mSliders[2].abY = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER3(0):
+			sliderMoved[3] = true;
+			mState.mSliders[3].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER3(1):
+			sliderMoved[3] = true;
+			mState.mSliders[3].abY = diBuff[i].dwData;
+			break;
+		//-----------------------------------------//
+		default:
+			//Handle Button Events Easily using the DX Offset Macros
+			if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
+			{
+				if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
+					return;
+			}
+			else if((short)(diBuff[i].uAppData >> 16) == 0x1313)
+			{	//If it was nothing else, might be axis enumerated earlier (determined by magic number)
+				int axis = (int)(0x0000FFFF & diBuff[i].uAppData); //Mask out the high bit
+				assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
+
+				if(axis >= 0 && axis < (int)mState.mAxes.size())
+				{
+					mState.mAxes[axis].abs = diBuff[i].dwData;
+					axisMoved[axis] = true;
+				}
+			}
+
+			break;
+		} //end case
+	} //end for
+
+	//Check to see if any of the axes values have changed.. if so send events
+	if( mBuffered && mListener && entries > 0 )
+	{
+		JoyStickEvent temp(this, mState);
+
+		//Update axes
+		for( int i = 0; i < 24; ++i )
+			if( axisMoved[i] )
+				if( mListener->axisMoved( temp, i ) == false )
+					return;
+
+		//Now update sliders
+		for( int i = 0; i < 4; ++i )
+			if( sliderMoved[i] )
+				if( mListener->sliderMoved( temp, i ) == false )
+					return;
+	}
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32JoyStick::_doButtonClick( int button, DIDEVICEOBJECTDATA& di )
+{
+	if( di.dwData & 0x80 )
+	{
+		mState.mButtons[button] = true;
+		if( mBuffered && mListener )
+			return mListener->buttonPressed( JoyStickEvent( this, mState ), button );
+	}
+	else
+	{
+		mState.mButtons[button] = false;
+		if( mBuffered && mListener )
+			return mListener->buttonReleased( JoyStickEvent( this, mState ), button );
+	}
+
+	return true;
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32JoyStick::_changePOV( int pov, DIDEVICEOBJECTDATA& di )
+{
+	//Some drivers report a value of 65,535, instead of 1,
+	//for the center position
+	if(LOWORD(di.dwData) == 0xFFFF)
+	{
+		mState.mPOV[pov].direction = Pov::Centered;
+	}
+	else
+	{
+		switch(di.dwData)
+		{
+			case 0: mState.mPOV[pov].direction = Pov::North; break;
+			case 4500: mState.mPOV[pov].direction = Pov::NorthEast; break;
+			case 9000: mState.mPOV[pov].direction = Pov::East; break;
+			case 13500: mState.mPOV[pov].direction = Pov::SouthEast; break;
+			case 18000: mState.mPOV[pov].direction = Pov::South; break;
+			case 22500: mState.mPOV[pov].direction = Pov::SouthWest; break;
+			case 27000: mState.mPOV[pov].direction = Pov::West; break;
+			case 31500: mState.mPOV[pov].direction = Pov::NorthWest; break;
+		}
+	}
+
+	if( mBuffered && mListener )
+		return mListener->povMoved( JoyStickEvent( this, mState ), pov );
+
+	return true;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
+
+//--------------------------------------------------------------------------------------------------//
+Interface* Win32JoyStick::queryInterface(Interface::IType type)
+{
+	//Thought about using covariant return type here.. however,
+	//some devices may allow LED light changing, or other interface stuff
+
+	if( ff_device && type == Interface::ForceFeedback )
+		return ff_device;
+	else
+		return 0;
+}
Index: /code/branches/physics/src/ois/win32/Win32JoyStick.h
===================================================================
--- /code/branches/physics/src/ois/win32/Win32JoyStick.h	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32JoyStick.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_JOYSTICK_H_EADER_
+#define _WIN32_JOYSTICK_H_EADER_
+
+#include "OISJoyStick.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32JoyStick : public JoyStick
+	{
+	public:
+		Win32JoyStick( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings, const JoyStickInfo &info );
+		virtual ~Win32JoyStick();
+		
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+		
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type);
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+	protected:
+		//! Enumerates all things
+		void _enumerate();
+		//! Enumerate axis callback
+		static BOOL CALLBACK DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
+		//! Enumerate Force Feedback callback
+		static BOOL CALLBACK DIEnumEffectsCallback(LPCDIEFFECTINFO pdei, LPVOID pvRef);
+
+		bool _doButtonClick( int button, DIDEVICEOBJECTDATA& di );
+		bool _changePOV( int pov, DIDEVICEOBJECTDATA& di );
+
+		IDirectInput8* mDirectInput;
+		IDirectInputDevice8* mJoyStick;
+		DWORD coopSetting;
+		GUID deviceGuid;
+
+		//! A force feedback device
+		Win32ForceFeedback* ff_device;
+
+		//! Mapping
+		int _AxisNumber;
+	};
+}
+
+#endif //_WIN32_JOYSTICK_H_EADER_
Index: /code/branches/physics/src/ois/win32/Win32KeyBoard.cpp
===================================================================
--- /code/branches/physics/src/ois/win32/Win32KeyBoard.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32KeyBoard.cpp	(revision 2122)
@@ -0,0 +1,334 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32InputManager.h"
+#include "Win32/Win32KeyBoard.h"
+#include "OISException.h"
+#include "OISEvents.h"
+#include <sstream>
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+Win32Keyboard::Win32Keyboard( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings )
+	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
+{
+	mKeyboard = 0;
+	mDirectInput = pDI;
+	coopSetting = coopSettings;
+
+	//Clear our keyboard state buffer
+	memset( &KeyBuffer, 0, 256 );
+	deadKey = '\0';
+	static_cast<Win32InputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::_initialize()
+{
+	mModifiers = 0;
+	deadKey = '\0';
+
+	if(FAILED(mDirectInput->CreateDevice(GUID_SysKeyboard, &mKeyboard, NULL)))
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> Could not init device!");
+
+	if(FAILED(mKeyboard->SetDataFormat(&c_dfDIKeyboard)))
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> format error!");
+
+	HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
+
+	if(FAILED(mKeyboard->SetCooperativeLevel( hwin, coopSetting)))
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> coop error!");
+
+	if( mBuffered )
+	{
+		DIPROPDWORD dipdw;
+		dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
+		dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+		dipdw.diph.dwObj        = 0;
+		dipdw.diph.dwHow        = DIPH_DEVICE;
+		dipdw.dwData            = KEYBOARD_DX_BUFFERSIZE;
+
+		if (FAILED(mKeyboard->SetProperty( DIPROP_BUFFERSIZE, &dipdw.diph )))
+			OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> buffer error!");
+	}
+
+	HRESULT hr = mKeyboard->Acquire();
+	if(FAILED(hr) && hr != DIERR_OTHERAPPHASPRIO)
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> aquire error!");
+}
+
+//--------------------------------------------------------------------------------------------------//
+Win32Keyboard::~Win32Keyboard()
+{
+	if(mKeyboard)
+	{
+		mKeyboard->Unacquire();
+		mKeyboard->Release();
+		mKeyboard = 0;
+	}
+	static_cast<Win32InputManager*>(mCreator)->_setKeyboardUsed(false);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::capture()
+{
+	if( mBuffered )
+		_readBuffered();
+	else
+		_read();
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::_readBuffered()
+{
+	DIDEVICEOBJECTDATA diBuff[KEYBOARD_DX_BUFFERSIZE];
+	DWORD entries = KEYBOARD_DX_BUFFERSIZE;
+	HRESULT hr;
+	//Only one keyboard allowed per app, so static is ok
+	static bool verifyAfterAltTab = false;
+
+	hr = mKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+	if( hr != DI_OK )
+	{
+		hr = mKeyboard->Acquire();
+		if (hr == E_ACCESSDENIED)
+			verifyAfterAltTab = true;
+
+		while( hr == DIERR_INPUTLOST )
+			hr = mKeyboard->Acquire();
+
+		return;
+	}
+
+	if( FAILED(hr) )
+		OIS_EXCEPT( E_General, "Win32Keyboard::_readBuffered() >> Problem with Device!" );
+
+	//Update keyboard and modifier states.. And, if mListener, fire events
+	for(unsigned int i = 0; i < entries; ++i )
+	{
+		//If the listener returns false, that means that we are probably deleted...
+		//send no more events and just leave as the this pointer is invalid now...
+		bool ret = true;
+		KeyCode kc = (KeyCode)diBuff[ i ].dwOfs;
+			
+		//Store result in our keyBuffer too
+		KeyBuffer[kc] = static_cast<unsigned char>(diBuff[ i ].dwData);
+			
+		if( diBuff[ i ].dwData & 0x80 )
+		{
+			//Turn on modifier
+			if( kc == KC_LCONTROL || kc == KC_RCONTROL )
+				mModifiers |= Ctrl;
+			else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+				mModifiers |= Shift;
+			else if( kc == KC_LMENU || kc == KC_RMENU )
+				mModifiers |= Alt;
+
+			if( mListener )
+				ret = mListener->keyPressed( KeyEvent( this, kc, _translateText(kc) ) );
+		}
+		else
+		{
+			//Turn off modifier
+			if( kc == KC_LCONTROL || kc == KC_RCONTROL )
+				mModifiers &= ~Ctrl;
+			else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+				mModifiers &= ~Shift;
+			else if( kc == KC_LMENU || kc == KC_RMENU )
+				mModifiers &= ~Alt;
+
+			//Fire off event
+			if( mListener )
+				ret = mListener->keyReleased( KeyEvent( this, kc, 0 ) );
+		}
+
+		if(ret == false)
+			break;
+	}
+
+	// If a lost device/access denied was detected, recover gracefully with new events
+	if(verifyAfterAltTab)
+	{
+		bool ret = true;
+		
+		//Copy old buffer to temp location to compare against
+		unsigned char keyBufferCopy[256];
+		memcpy(keyBufferCopy, KeyBuffer, 256);
+
+		//Update new state
+		_read();
+
+		for (unsigned i = 0; i < 256; i++)
+		{
+			if (keyBufferCopy[i] != KeyBuffer[i])
+			{
+				if (mListener)
+				{
+					if (KeyBuffer[i])
+						ret = mListener->keyPressed( KeyEvent( this, (KeyCode)i, _translateText((KeyCode)i) ) );
+					else
+						ret = mListener->keyReleased( KeyEvent( this, (KeyCode)i, 0 ) );
+				}
+			}
+
+			//If user returned false from callback, return immediately
+			if(ret == false)
+				return;
+		}
+
+		verifyAfterAltTab = false;
+	}
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::_read()
+{
+    HRESULT  hr = mKeyboard->GetDeviceState( sizeof(KeyBuffer), &KeyBuffer );
+
+	if( hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED )
+	{
+		hr = mKeyboard->Acquire();
+		if (hr != DIERR_OTHERAPPHASPRIO)
+			mKeyboard->GetDeviceState(sizeof(KeyBuffer), &KeyBuffer);
+	}
+
+	//Set Shift, Ctrl, Alt
+	mModifiers = 0;
+	if( isKeyDown(KC_LCONTROL) || isKeyDown(KC_RCONTROL) )
+		mModifiers |= Ctrl;
+	if( isKeyDown(KC_LSHIFT) || isKeyDown(KC_RSHIFT) )
+		mModifiers |= Shift;
+	if( isKeyDown(KC_LMENU) || isKeyDown(KC_RMENU) )
+		mModifiers |= Alt;
+}
+
+//--------------------------------------------------------------------------------------------------//
+int Win32Keyboard::_translateText( KeyCode kc )
+{
+	if( mTextMode == Off )
+		return 0;
+
+	BYTE keyState[256];
+	HKL  layout = GetKeyboardLayout(0);
+	if( GetKeyboardState(keyState) == 0 )
+		return 0;
+
+	unsigned int vk = MapVirtualKeyEx(kc, 3, layout);
+	if( vk == 0 )
+		return 0;
+
+	unsigned char buff[3] = {0,0,0};
+	int ascii = ToAsciiEx(vk, kc, keyState, (LPWORD) buff, 0, layout);
+	//WCHAR wide[3];
+	//int ascii = ToUnicodeEx(vk, kc, keyState, wide, 3, 0, layout);
+	if(ascii == 1 && deadKey != '\0' )
+	{
+		// A dead key is stored and we have just converted a character key
+		// Combine the two into a single character
+		WCHAR wcBuff[3] = {buff[0], deadKey, '\0'};
+		WCHAR out[3];
+		
+		deadKey = '\0';
+		if(FoldStringW(MAP_PRECOMPOSED, (LPWSTR)wcBuff, 3, (LPWSTR)out, 3))
+			return out[0];
+	}
+	else if (ascii == 1)
+	{	// We have a single character
+		deadKey = '\0';
+		return buff[0];
+	}
+	else if(ascii == 2)
+	{	// Convert a non-combining diacritical mark into a combining diacritical mark
+		// Combining versions range from 0x300 to 0x36F; only 5 (for French) have been mapped below
+		// http://www.fileformat.info/info/unicode/block/combining_diacritical_marks/images.htm
+		switch(buff[0])	{
+		case 0x5E: // Circumflex accent: â
+			deadKey = 0x302; break;
+		case 0x60: // Grave accent: à
+			deadKey = 0x300; break;
+		case 0xA8: // Diaeresis: ü
+			deadKey = 0x308; break;
+		case 0xB4: // Acute accent: é
+			deadKey = 0x301; break;
+		case 0xB8: // Cedilla: ç
+			deadKey = 0x327; break;
+		default:
+			deadKey = buff[0]; break;
+		}
+	}
+
+	return 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32Keyboard::isKeyDown( KeyCode key ) const
+{
+	return (KeyBuffer[key] & 0x80) != 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+const std::string& Win32Keyboard::getAsString( KeyCode kc )
+{
+	char temp[256];
+
+	DIPROPSTRING prop;
+	prop.diph.dwSize = sizeof(DIPROPSTRING);
+	prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	prop.diph.dwObj = static_cast<DWORD>(kc);
+	prop.diph.dwHow = DIPH_BYOFFSET;
+
+	if ( SUCCEEDED( mKeyboard->GetProperty( DIPROP_KEYNAME, &prop.diph ) ) )
+	{
+		// convert the WCHAR in "wsz" to multibyte
+		if ( WideCharToMultiByte( CP_ACP, 0, prop.wsz, -1, temp, sizeof(temp), NULL, NULL) )
+			return mGetString.assign( temp );
+	}
+
+	std::stringstream ss;
+	ss << "Key_" << (int)kc;
+	return mGetString.assign( ss.str() );
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::copyKeyStates( char keys[256] ) const
+{
+	for(int i = 0; i < 256; ++i)
+		keys[i] = KeyBuffer[i] > 0; //Normalise the DX values (0x80)
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::setBuffered(bool buffered)
+{
+	if( buffered != mBuffered )
+	{
+		if(mKeyboard)
+		{
+			mKeyboard->Unacquire();
+			mKeyboard->Release();
+			mKeyboard = 0;
+		}
+		
+		mBuffered = buffered;
+		_initialize();
+	}
+}
Index: /code/branches/physics/src/ois/win32/Win32KeyBoard.h
===================================================================
--- /code/branches/physics/src/ois/win32/Win32KeyBoard.h	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32KeyBoard.h	(revision 2122)
@@ -0,0 +1,87 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_KEYBOARD_H_EADER_
+#define _WIN32_KEYBOARD_H_EADER_
+
+#include "OISKeyboard.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32Keyboard : public Keyboard
+	{
+	public:
+		/**
+		@remarks
+			Constructor
+		@param pDI
+			Valid DirectInput8 Interface
+		@param buffered
+			True for buffered input mode
+		@param coopSettings
+			A combination of DI Flags (see DX Help for info on input device settings)
+		*/
+		Win32Keyboard( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings );
+		virtual ~Win32Keyboard();
+
+		/** @copydoc Keyboard::isKeyDown */
+		virtual bool isKeyDown( KeyCode key ) const;
+		
+		/** @copydoc Keyboard::getAsString */
+		virtual const std::string& getAsString( KeyCode kc );
+
+		/** @copydoc Keyboard::copyKeyStates */
+		virtual void copyKeyStates( char keys[256] ) const;
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+		
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type) {return 0;}
+		
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+	protected:
+		void _readBuffered();
+		void _read();
+
+		IDirectInput8* mDirectInput;
+		IDirectInputDevice8* mKeyboard;
+		DWORD coopSetting;
+
+		unsigned char KeyBuffer[256];
+		
+		//! Internal method for translating KeyCodes to Text
+		int _translateText( KeyCode kc );
+
+		//! Stored dead key from last translation
+		WCHAR deadKey;
+
+		//! used for getAsString
+		std::string mGetString;
+	};
+}
+#endif //_WIN32_KEYBOARD_H_EADER_
Index: /code/branches/physics/src/ois/win32/Win32Mouse.cpp
===================================================================
--- /code/branches/physics/src/ois/win32/Win32Mouse.cpp	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32Mouse.cpp	(revision 2122)
@@ -0,0 +1,216 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32Mouse.h"
+#include "Win32/Win32InputManager.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+Win32Mouse::Win32Mouse( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings )
+	: Mouse(creator->inputSystemName(), buffered, 0, creator)
+{
+	mMouse = 0;
+	mDirectInput = pDI;
+	coopSetting = coopSettings;
+	mHwnd = 0;
+
+	static_cast<Win32InputManager*>(mCreator)->_setMouseUsed(true);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Mouse::_initialize()
+{
+	DIPROPDWORD dipdw;
+
+	//Clear old state
+	mState.clear();
+
+    dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
+    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+    dipdw.diph.dwObj        = 0;
+    dipdw.diph.dwHow        = DIPH_DEVICE;
+	dipdw.dwData            = MOUSE_DX_BUFFERSIZE;
+	
+	if( FAILED(mDirectInput->CreateDevice(GUID_SysMouse, &mMouse, NULL)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to create device" );
+
+	if( FAILED(mMouse->SetDataFormat(&c_dfDIMouse2)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set format" );
+	
+	mHwnd = ((Win32InputManager*)mCreator)->getWindowHandle();
+
+	if( FAILED(mMouse->SetCooperativeLevel(mHwnd, coopSetting)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set coop level" );
+	
+	if( FAILED(mMouse->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph )) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set property" );
+
+	HRESULT hr = mMouse->Acquire();
+	if (FAILED(hr) && hr != DIERR_OTHERAPPHASPRIO)
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to aquire mouse!" );
+}
+
+//--------------------------------------------------------------------------------------------------//
+Win32Mouse::~Win32Mouse()
+{
+	if (mMouse)
+	{
+		mMouse->Unacquire();
+		mMouse->Release();
+		mMouse = 0;
+	}
+
+	static_cast<Win32InputManager*>(mCreator)->_setMouseUsed(false);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Mouse::capture()
+{
+	//Clear old relative values
+	mState.X.rel = mState.Y.rel = mState.Z.rel = 0;
+
+	DIDEVICEOBJECTDATA diBuff[MOUSE_DX_BUFFERSIZE];
+	DWORD entries = MOUSE_DX_BUFFERSIZE;
+
+	HRESULT hr = mMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+	if( hr != DI_OK )
+	{
+		hr = mMouse->Acquire();
+		while( hr == DIERR_INPUTLOST ) 
+			hr = mMouse->Acquire();
+
+		hr = mMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+		
+		//Perhaps the user just tabbed away, and coop settings
+		//are nonexclusive..so just ignore
+		if( FAILED(hr) )
+			return;
+	}
+
+	bool axesMoved = false;
+	//Accumulate all axis movements for one axesMove message..
+	//Buttons are fired off as they are found
+	for(unsigned int i = 0; i < entries; ++i )
+	{
+		switch( diBuff[i].dwOfs )
+		{
+			case DIMOFS_BUTTON0:
+				if(!_doMouseClick(0, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON1:
+				if(!_doMouseClick(1, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON2:
+				if(!_doMouseClick(2, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON3:
+				if(!_doMouseClick(3, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON4:
+				if(!_doMouseClick(4, diBuff[i])) return;
+				break;	
+			case DIMOFS_BUTTON5:
+				if(!_doMouseClick(5, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON6:
+				if(!_doMouseClick(6, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON7:
+				if(!_doMouseClick(7, diBuff[i])) return;
+				break;
+			case DIMOFS_X:
+				mState.X.rel += diBuff[i].dwData;
+				axesMoved = true;
+				break;
+			case DIMOFS_Y:
+				mState.Y.rel += diBuff[i].dwData;
+				axesMoved = true;
+				break;
+			case DIMOFS_Z:
+				mState.Z.rel += diBuff[i].dwData;
+				axesMoved = true;
+				break;
+			default: break;
+		} //end switch
+	}//end for
+
+	if( axesMoved )
+	{
+		if( coopSetting & DISCL_NONEXCLUSIVE )
+		{
+			//DirectInput provides us with meaningless values, so correct that
+			POINT point;
+			GetCursorPos(&point);
+			ScreenToClient(mHwnd, &point);
+			mState.X.abs = point.x;
+			mState.Y.abs = point.y;
+		}
+		else
+		{
+			mState.X.abs +=  mState.X.rel;
+			mState.Y.abs +=  mState.Y.rel;
+		}
+		mState.Z.abs +=  mState.Z.rel;
+
+		//Clip values to window
+		if( mState.X.abs < 0 )
+			mState.X.abs = 0;
+		else if( mState.X.abs > mState.width )
+			mState.X.abs = mState.width;
+		if( mState.Y.abs < 0 )
+			mState.Y.abs = 0;
+		else if( mState.Y.abs > mState.height )
+			mState.Y.abs = mState.height;
+
+		//Do the move
+		if( mListener && mBuffered )
+			mListener->mouseMoved( MouseEvent( this, mState ) );
+	}
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32Mouse::_doMouseClick( int mouseButton, DIDEVICEOBJECTDATA& di )
+{
+	if( di.dwData & 0x80 )
+	{
+		mState.buttons |= 1 << mouseButton; //turn the bit flag on
+		if( mListener && mBuffered )
+			return mListener->mousePressed( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+	}
+	else
+	{
+		mState.buttons &= ~(1 << mouseButton); //turn the bit flag off
+		if( mListener && mBuffered )
+			return mListener->mouseReleased( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+	}
+
+	return true;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Mouse::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
Index: /code/branches/physics/src/ois/win32/Win32Mouse.h
===================================================================
--- /code/branches/physics/src/ois/win32/Win32Mouse.h	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32Mouse.h	(revision 2122)
@@ -0,0 +1,59 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+	1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+	2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+	3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_MOUSE_H_EADER_
+#define _WIN32_MOUSE_H_EADER_
+
+#include "OISMouse.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32Mouse : public Mouse
+	{
+	public:
+		Win32Mouse( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings );
+		virtual ~Win32Mouse();
+		
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+	protected:
+		bool _doMouseClick( int mouseButton, DIDEVICEOBJECTDATA& di );
+
+		IDirectInput8* mDirectInput;
+		IDirectInputDevice8* mMouse;
+		DWORD coopSetting;
+		HWND mHwnd;
+	};
+}
+
+#endif //_WIN32_MOUSE_H_EADER_
Index: /code/branches/physics/src/ois/win32/Win32Prereqs.h
===================================================================
--- /code/branches/physics/src/ois/win32/Win32Prereqs.h	(revision 2122)
+++ /code/branches/physics/src/ois/win32/Win32Prereqs.h	(revision 2122)
@@ -0,0 +1,63 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_INPUTSYSTEM_PREREQS_H
+#define _WIN32_INPUTSYSTEM_PREREQS_H
+
+#define WIN32_LEAN_AND_MEAN
+#define DIRECTINPUT_VERSION 0x0800
+#include <windows.h>
+#include <dinput.h>
+
+//Max number of elements to collect from buffered DirectInput
+#define KEYBOARD_DX_BUFFERSIZE 17
+#define MOUSE_DX_BUFFERSIZE 64
+#define JOYSTICK_DX_BUFFERSIZE 124
+
+//MinGW defines
+#if defined(OIS_MINGW_COMPILER)
+#	undef FIELD_OFFSET
+#	define FIELD_OFFSET offsetof
+#endif
+
+namespace OIS
+{
+	//Local Forward declarations
+	class Win32InputManager;
+	class Win32Keyboard;
+	class Win32JoyStick;
+	class Win32Mouse;
+	class Win32ForceFeedback;
+
+	//Information needed to create DirectInput joysticks
+	class JoyStickInfo
+	{
+	public:
+		int devId;
+		GUID deviceID;
+		std::string vendor;
+	};
+
+	typedef std::vector< JoyStickInfo > JoyStickInfoList;
+}
+
+#endif //_WIN32_INPUTSYSTEM_PREREQS_H
Index: /code/branches/physics/src/orxonox/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/orxonox/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/orxonox/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,159 @@
+SET( ORXONOX_SRC_FILES
+  CameraManager.cc
+  GraphicsEngine.cc
+  LevelManager.cc
+  Main.cc
+  Settings.cc
+
+  gamestates/GSClient.cc
+  gamestates/GSDedicated.cc
+  gamestates/GSGraphics.cc
+  gamestates/GSGUI.cc
+  gamestates/GSIOConsole.cc
+  gamestates/GSLevel.cc
+  gamestates/GSRoot.cc
+  gamestates/GSServer.cc
+  gamestates/GSStandalone.cc
+
+  gui/GUIManager.cc
+  gui/OgreCEGUIRenderer.cpp
+  gui/OgreCEGUIResourceProvider.cpp
+  gui/OgreCEGUITexture.cpp
+
+  overlays/OrxonoxOverlay.cc
+  overlays/OverlayGroup.cc
+  overlays/OverlayText.cc
+
+  overlays/console/InGameConsole.cc
+
+  overlays/debug/DebugFPSText.cc
+  overlays/debug/DebugRTRText.cc
+
+  overlays/hud/HUDBar.cc
+  overlays/hud/HUDNavigation.cc
+  overlays/hud/HUDRadar.cc
+  overlays/hud/HUDSpeedBar.cc
+  overlays/hud/ChatOverlay.cc
+
+  tools/BillboardSet.cc
+  tools/Mesh.cc
+  tools/ParticleInterface.cc
+  tools/TextureGenerator.cc
+  tools/Timer.cc
+  tools/WindowEventListener.cc
+
+  objects/EventListener.cc
+  objects/EventDispatcher.cc
+  objects/EventTarget.cc
+#  objects/PhysicsTest.cc
+  objects/HelloBullet.cc
+  objects/Radar.cc
+  objects/RadarListener.cc
+  objects/RadarViewable.cc
+  objects/Tickable.cc
+  objects/Test.cc
+  objects/Script.cc
+
+  objects/Scene.cc
+  objects/worldentities/WorldEntity.cc
+  objects/worldentities/PositionableEntity.cc
+  objects/worldentities/MovableEntity.cc
+  objects/worldentities/ControllableEntity.cc
+  objects/worldentities/Model.cc
+  objects/worldentities/Billboard.cc
+  objects/worldentities/BlinkingBillboard.cc
+  objects/worldentities/Light.cc
+  objects/worldentities/Camera.cc
+  objects/worldentities/CameraPosition.cc
+  objects/worldentities/SpawnPoint.cc
+  objects/worldentities/ParticleEmitter.cc
+  objects/worldentities/ParticleSpawner.cc
+#  objects/worldentities/Backlight.cc
+
+  objects/quest/AddQuest.cc
+  objects/quest/AddQuestHint.cc
+  objects/quest/AddReward.cc
+  objects/quest/ChangeQuestStatus.cc
+  objects/quest/CompleteQuest.cc
+  objects/quest/FailQuest.cc
+  objects/quest/GlobalQuest.cc
+  objects/quest/LocalQuest.cc
+  objects/quest/Quest.cc
+  objects/quest/QuestDescription.cc
+  objects/quest/QuestEffect.cc
+  objects/quest/QuestHint.cc
+  objects/quest/QuestItem.cc
+  objects/quest/QuestManager.cc
+  objects/quest/Rewardable.cc
+
+  objects/weaponSystem/WeaponSystem.cc
+  objects/weaponSystem/WeaponSet.cc
+  objects/weaponSystem/WeaponSlot.cc
+  objects/weaponSystem/Weapon.cc
+  objects/weaponSystem/Munition.cc
+
+  objects/worldentities/triggers/Trigger.cc
+  objects/worldentities/triggers/DistanceTrigger.cc
+  objects/worldentities/triggers/EventTrigger.cc
+
+  objects/worldentities/pawns/Spectator.cc
+  objects/worldentities/pawns/Pawn.cc
+  objects/worldentities/pawns/SpaceShip.cc
+
+  objects/controllers/Controller.cc
+  objects/controllers/HumanController.cc
+
+  objects/infos/Info.cc
+  objects/infos/Level.cc
+  objects/infos/PlayerInfo.cc
+  objects/infos/HumanPlayer.cc
+
+  objects/gametypes/Gametype.cc
+
+  tolua/tolua_bind.cc
+)
+
+GET_TARGET_PROPERTY(TOLUA_EXE tolua_orxonox LOCATION)
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.cc ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.h
+  COMMAND ${TOLUA_EXE} -n Orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg
+  DEPENDS
+    tolua_orxonox
+    tolua/tolua.pkg
+    gui/GUIManager.h
+  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
+)
+
+
+ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
+
+IF(NETWORKTRAFFIC_TESTING_ENABLED)
+
+  SET( ORXONOXS_SRC_FILES
+    GraphicsEngine.cc
+    objects/Camera.cc
+    CameraManager.cc
+  )
+
+  ADD_LIBRARY(orxonoxs SHARED ${ORXONOX_SRC_FILES})
+ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)
+
+TARGET_LINK_LIBRARIES( orxonox
+  ${OGRE_LIBRARIES}
+  ${CEGUI_LIBRARIES}
+  lua_orxonox
+  ceguilua_orxonox
+  tinyxml_orxonox
+  tolualib_orxonox
+  LibLinearMath
+  LibBulletCollision
+  LibBulletDynamics
+  LibBulletSoftBody
+  ogrebullet_collisions_orxonox
+  ogrebullet_dynamics_orxonox
+  util
+  core
+  audio
+  network
+)
+
Index: /code/branches/physics/src/orxonox/CameraManager.cc
===================================================================
--- /code/branches/physics/src/orxonox/CameraManager.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/CameraManager.cc	(revision 2122)
@@ -0,0 +1,103 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+#include "OrxonoxStableHeaders.h"
+#include "CameraManager.h"
+
+#include <OgreViewport.h>
+
+#include "core/Core.h"
+#include "objects/worldentities/Camera.h"
+
+
+namespace orxonox
+{
+    CameraManager* CameraManager::singletonRef_s = 0;
+
+    CameraManager::CameraManager(Ogre::Viewport* viewport)
+        : viewport_(viewport)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+    }
+
+    CameraManager::~CameraManager()
+    {
+        assert(singletonRef_s != 0);
+        singletonRef_s = 0;
+    }
+
+    Camera* CameraManager::getActiveCamera() const
+    {
+        if (this->cameraList_.size() > 0)
+            return this->cameraList_.front();
+        else
+            return 0;
+    }
+
+    void CameraManager::requestFocus(Camera* camera)
+    {
+        if (!Core::showsGraphics())
+            return;
+
+        // notify old camera (if it exists)
+        if (this->cameraList_.size() > 0)
+            this->cameraList_.front()->removeFocus();
+
+        camera->setFocus(this->viewport_);
+
+        // add to list
+        std::list<Camera*>::iterator it;
+        for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
+        {
+            if ((*it) == camera)
+                return; // make sure we don't add it twice
+        }
+        this->cameraList_.push_front(camera);
+    }
+
+    void CameraManager::releaseFocus(Camera* camera)
+    {
+        if (!Core::showsGraphics())
+            return;
+
+        // notify the cam of releasing the focus
+        if (this->cameraList_.front() == camera)
+        {
+            camera->removeFocus();
+            this->cameraList_.pop_front();
+
+            // set new focus if necessary
+            if (cameraList_.size() > 0)
+                cameraList_.front()->setFocus(this->viewport_);
+        }
+        else
+        {
+            this->cameraList_.remove(camera);
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/CameraManager.h
===================================================================
--- /code/branches/physics/src/orxonox/CameraManager.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/CameraManager.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+ /**
+ @file  CameraManager.h
+ @brief Handles the instances of Camera class
+ @author Benjamin Knecht <beni_at_orxonox.net>
+  */
+
+#ifndef _CameraManager_H__
+#define _CameraManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <cassert>
+#include <list>
+#include <OgrePrerequisites.h>
+
+namespace orxonox
+{
+    class _OrxonoxExport CameraManager
+    {
+        public:
+            CameraManager(Ogre::Viewport* viewport);
+            ~CameraManager();
+
+            Camera* getActiveCamera() const;
+
+            void requestFocus(Camera* camera);
+            void releaseFocus(Camera* camera);
+
+            static CameraManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+        private:
+            CameraManager(const CameraManager&);
+
+            std::list<Camera*> cameraList_;
+            Ogre::Viewport* viewport_;
+
+            static CameraManager* singletonRef_s;
+    };
+}
+
+#endif /* _CameraManager_H__ */
Index: /code/branches/physics/src/orxonox/GraphicsEngine.cc
===================================================================
--- /code/branches/physics/src/orxonox/GraphicsEngine.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/GraphicsEngine.cc	(revision 2122)
@@ -0,0 +1,104 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of an partial interface to Ogre.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "GraphicsEngine.h"
+
+#include <OgreRenderWindow.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "util/Debug.h"
+
+#include "tools/ParticleInterface.h"
+
+namespace orxonox
+{
+    //SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
+
+    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
+
+    /**
+    @brief
+        Returns the singleton instance.
+    @return
+        The only instance of GraphicsEngine.
+    */
+    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
+    {
+        assert(singletonRef_s);
+        return *singletonRef_s;
+    }
+
+    /**
+    @brief
+        Non-initialising constructor.
+    */
+    GraphicsEngine::GraphicsEngine()
+//        : root_(0)
+//        , renderWindow_(0)
+//        , viewport_(0)
+    {
+        RegisterObject(GraphicsEngine);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->detailLevelParticle_ = 0;
+
+        this->setConfigValues();
+        CCOUT(4) << "Constructed" << std::endl;
+    }
+
+    void GraphicsEngine::setConfigValues()
+    {
+        SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged);
+    }
+
+    void GraphicsEngine::detailLevelParticleChanged()
+    {
+        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
+            it->detailLevelChanged(this->detailLevelParticle_);
+    }
+
+    /**
+    @brief
+        Destroys all the Ogre related objects
+    */
+    GraphicsEngine::~GraphicsEngine()
+    {
+        singletonRef_s = 0;
+    }
+}
Index: /code/branches/physics/src/orxonox/GraphicsEngine.h
===================================================================
--- /code/branches/physics/src/orxonox/GraphicsEngine.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/GraphicsEngine.h	(revision 2122)
@@ -0,0 +1,89 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+  @file
+  @brief Declaration of GraphicsEngine Singleton.
+  @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _GraphicsEngine_H__
+#define _GraphicsEngine_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    /**
+    @brief Graphics engine manager class
+    */
+    class _OrxonoxExport GraphicsEngine : public OrxonoxClass
+    {
+        // HACK: temporary means
+        friend class GSGraphics;
+
+    public:
+        GraphicsEngine();
+        ~GraphicsEngine();
+
+        void setConfigValues();
+        void detailLevelParticleChanged();
+
+        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
+        float getAverageTickTime() const          { return this->avgTickTime_; }
+        void setAverageTickTime(float tickTime)   { this->avgTickTime_ = tickTime; }
+        void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
+
+        inline unsigned int getDetailLevelParticle() const
+        { return this->detailLevelParticle_; }
+
+        static GraphicsEngine& getInstance();
+        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
+
+    private:
+        // don't mess with singletons
+        GraphicsEngine(GraphicsEngine&);
+
+        // stats
+        float               avgTickTime_;           //!< time in ms to tick() one frame
+        float               avgFramesPerSecond_;    //!< number of frames processed in one second
+
+        // config values
+        unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
+
+        static GraphicsEngine* singletonRef_s;      //!< Pointer to the Singleton
+    };
+}
+
+#endif /* _GraphicsEngine_H__ */
Index: /code/branches/physics/src/orxonox/LevelManager.cc
===================================================================
--- /code/branches/physics/src/orxonox/LevelManager.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/LevelManager.cc	(revision 2122)
@@ -0,0 +1,144 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "LevelManager.h"
+
+#include "core/CoreIncludes.h"
+
+#include "objects/infos/Level.h"
+#include "objects/infos/HumanPlayer.h"
+
+namespace orxonox
+{
+    LevelManager* LevelManager::singletonRef_s = 0;
+
+    LevelManager::LevelManager()
+    {
+        RegisterRootObject(LevelManager);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->getConnectedClients();
+    }
+
+    LevelManager::~LevelManager()
+    {
+        assert(singletonRef_s != 0);
+        singletonRef_s = 0;
+    }
+
+    void LevelManager::requestActivity(Level* level)
+    {
+        this->levels_s.push_back(level);
+        if (this->levels_s.size() == 1)
+            this->activateNextLevel();
+    }
+
+    void LevelManager::releaseActivity(Level* level)
+    {
+        if (this->levels_s.size() > 0)
+        {
+            if (this->levels_s.front() == level)
+            {
+                level->setActive(false);
+                this->levels_s.pop_front();
+                this->activateNextLevel();
+            }
+            else
+            {
+                for (std::list<Level*>::iterator it = this->levels_s.begin(); it != this->levels_s.end(); ++it)
+                    if ((*it) == level)
+                        this->levels_s.erase(it);
+            }
+        }
+    }
+
+    Level* LevelManager::getActiveLevel()
+    {
+        if (this->levels_s.size() > 0)
+            return this->levels_s.front();
+        else
+            return 0;
+    }
+
+    void LevelManager::activateNextLevel()
+    {
+        if (this->levels_s.size() > 0)
+        {
+            this->levels_s.front()->setActive(true);
+            for (std::map<unsigned int, PlayerInfo*>::iterator it = this->clients_.begin(); it != this->clients_.end(); ++it)
+                this->levels_s.front()->playerEntered(it->second);
+        }
+    }
+
+
+    void LevelManager::clientConnected(unsigned int clientID)
+    {
+        COUT(3) << "client connected" << std::endl;
+
+        // create new HumanPlayer instance
+        HumanPlayer* player = new HumanPlayer(0);
+        player->setClientID(clientID);
+
+        // add to clients-map
+        assert(!this->clients_[clientID]);
+        this->clients_[clientID] = player;
+
+        if (this->getActiveLevel())
+            this->getActiveLevel()->playerEntered(player);
+    }
+
+    void LevelManager::clientDisconnected(unsigned int clientID)
+    {
+        COUT(3) << "client disconnected" << std::endl;
+
+        // remove from clients-map
+        PlayerInfo* player = this->clients_[clientID];
+        this->clients_.erase(clientID);
+
+        if (this->getActiveLevel())
+            this->getActiveLevel()->playerLeft(player);
+
+        // delete PlayerInfo instance
+        if (player)
+            delete player;
+    }
+
+
+    PlayerInfo* LevelManager::getClient(unsigned int clientID) const
+    {
+        std::map<unsigned int, PlayerInfo*>::const_iterator it = this->clients_.find(clientID);
+        if (it != this->clients_.end())
+            return it->second;
+        else
+            return 0;
+    }
+}
Index: /code/branches/physics/src/orxonox/LevelManager.h
===================================================================
--- /code/branches/physics/src/orxonox/LevelManager.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/LevelManager.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _LevelManager_H__
+#define _LevelManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+#include <map>
+#include <cassert>
+
+#include "network/ClientConnectionListener.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport LevelManager : public network::ClientConnectionListener
+    {
+        public:
+            LevelManager();
+            virtual ~LevelManager();
+
+            void requestActivity(Level* level);
+            void releaseActivity(Level* level);
+            Level* getActiveLevel();
+
+            PlayerInfo* getClient(unsigned int clientID) const;
+            inline const std::map<unsigned int, PlayerInfo*>& getClients() const
+                { return this->clients_; }
+
+            static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+        private:
+            LevelManager(const LevelManager&);
+
+            void clientConnected(unsigned int clientID);
+            void clientDisconnected(unsigned int clientID);
+
+            void activateNextLevel();
+
+            std::list<Level*> levels_s;
+            std::map<unsigned int, PlayerInfo*> clients_;
+
+            static LevelManager* singletonRef_s;
+    };
+}
+
+#endif /* _LevelManager_H__ */
Index: /code/branches/physics/src/orxonox/Main.cc
===================================================================
--- /code/branches/physics/src/orxonox/Main.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/Main.cc	(revision 2122)
@@ -0,0 +1,142 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+ /**
+ @file
+ @brief Entry point of the program. Platform specific code.
+  */
+
+#include "OrxonoxStableHeaders.h"
+
+#include <exception>
+#include <cassert>
+
+#include "util/OrxonoxPlatform.h"
+#include "util/Debug.h"
+#include "util/SignalHandler.h"
+#include "core/ConfigFileManager.h"
+#include "core/CommandLine.h"
+
+#include "gamestates/GSRoot.h"
+#include "gamestates/GSGraphics.h"
+#include "gamestates/GSStandalone.h"
+#include "gamestates/GSServer.h"
+#include "gamestates/GSClient.h"
+#include "gamestates/GSDedicated.h"
+#include "gamestates/GSGUI.h"
+#include "gamestates/GSIOConsole.h"
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+#include <CoreFoundation/CoreFoundation.h>
+
+// This function will locate the path to our application on OS X,
+// unlike windows you can not rely on the curent working directory
+// for locating your configuration files and resources.
+             std::string macBundlePath()
+{
+    char path[1024];
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    assert(mainBundle);
+
+    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+    assert(mainBundleURL);
+
+    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
+    assert(cfStringRef);
+
+    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
+
+    CFRelease(mainBundleURL);
+    CFRelease(cfStringRef);
+
+    return std::string(path);
+}
+#endif
+
+
+//#ifdef __cplusplus
+//extern "C" {
+//#endif
+
+SetCommandLineArgument(settingsFile, "orxonox.ini");
+
+int main(int argc, char** argv)
+{
+    using namespace orxonox;
+
+    // create a signal handler (only works for linux)
+    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
+
+    // Parse command line arguments
+    try
+    {
+        CommandLine::parseAll(argc, argv);
+    }
+    catch (ArgumentException& ex)
+    {
+        COUT(1) << ex.what() << std::endl;
+        COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
+    }
+
+    // Create the ConfigFileManager before creating the GameStates in order to have
+    // setConfigValues() in the constructor (required).
+    ConfigFileManager* configFileManager = new ConfigFileManager();
+    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
+
+    // create the gamestates
+    GSRoot root;
+    GSGraphics graphics;
+    GSStandalone standalone;
+    GSServer server;
+    GSClient client;
+    GSDedicated dedicated;
+    GSGUI gui;
+    GSIOConsole ioConsole;
+
+    // make the hierarchy
+    root.addChild(&graphics);
+    graphics.addChild(&standalone);
+    graphics.addChild(&server);
+    graphics.addChild(&client);
+    graphics.addChild(&gui);
+    root.addChild(&ioConsole);
+    root.addChild(&dedicated);
+
+    // Here happens the game
+    root.start();
+
+    // Destroy ConfigFileManager again.
+    delete configFileManager;
+
+    return 0;
+}
+
+//#ifdef __cplusplus
+//}
+//#endif
Index: /code/branches/physics/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/physics/src/orxonox/OrxonoxPrereqs.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/OrxonoxPrereqs.h	(revision 2122)
@@ -0,0 +1,207 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _OrxonoxPrereqs_H__
+#define _OrxonoxPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !(defined(ORXONOX_STATIC_BUILD) || defined(ORXONOX_NO_EXPORTS))
+#  ifdef ORXONOX_SHARED_BUILD
+#    define _OrxonoxExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _OrxonoxExport
+#    else
+#      define _OrxonoxExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _OrxonoxExport  __attribute__ ((visibility("default")))
+#else
+#  define _OrxonoxExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+    namespace LODParticle
+    {
+        enum LOD
+        {
+            off = 0,
+            low = 1,
+            normal = 2,
+            high = 3
+        };
+    }
+
+    class GraphicsEngine;
+    class Settings;
+
+    class RadarViewable;
+    class Radar;
+    class RadarListener;
+
+    class CameraManager;
+    class LevelManager;
+
+    // objects
+    class Scene;
+
+    class AddQuest;
+    class AddQuestHint;
+    class AddReward;
+    class ChangeQuestStatus;
+    class CompleteQuest;
+    class FailQuest;
+    class GlobalQuest;
+    class LocalQuest;
+    class Quest;
+    class QuestDescription;
+    class QuestEffect;
+    class QuestHint;
+    class QuestItem;
+    class QuestManager;
+    class Rewardable;
+
+    class WorldEntity;
+    class PositionableEntity;
+    class MovableEntity;
+    class ControllableEntity;
+    class Sublevel;
+
+    class Model;
+    class Billboard;
+    class BlinkingBillboard;
+    class Light;
+    class Backlight;
+    class ParticleEmitter;
+    class ParticleSpawner;
+
+    class Camera;
+    class CameraPosition;
+    class SpawnPoint;
+
+    class Spectator;
+    class Pawn;
+    class SpaceShip;
+
+    class Trigger;
+    class DistanceTrigger;
+    class EventTrigger;
+
+    class WeaponSystem;
+    class WeaponSet;
+    class WeaponSlot;
+    class Weapon;
+    class Munition;
+
+    class EventListener;
+    class EventDispatcher;
+    class EventTarget;
+
+    class Controller;
+    class HumanController;
+
+    class Info;
+    class Level;
+    class PlayerInfo;
+    class HumanPlayer;
+
+    class Gametype;
+
+    class Scores;
+
+    // tools
+    class BillboardSet;
+    class Light;
+    class Mesh;
+    class ParticleInterface;
+    template <class T>
+    class Timer;
+
+    // overlays
+    class BarColour;
+    class DebugFPSText;
+    class DebugRTRText;
+    class HUDBar;
+    class HUDNavigation;
+    class HUDRadar;
+    class HUDSpeedBar;
+    class InGameConsole;
+    class OrxonoxOverlay;
+    class OverlayGroup;
+    class OverlayText;
+
+    //gui
+    class GUIManager;
+
+    // game states
+    class GSRoot;
+    class GSGraphics;
+    class GSIO;
+    class GSIOConsole;
+    class GSLevel;
+    class GSStandalone;
+    class GSServer;
+    class GSClient;
+    class GSGUI;
+}
+
+namespace Ogre
+{
+    // some got forgotten in OgrePrerequisites
+    class BorderPanelOverlayElement;
+    class PanelOverlayElement;
+    class TextAreaOverlayElement;
+}
+
+namespace CEGUI
+{
+    class LuaScriptModule;
+
+    class OgreCEGUIRenderer;
+    class OgreCEGUIResourceProvider;
+    class OgreCEGUITexture;
+}
+
+struct lua_State;
+
+#endif /* _OrxonoxPrereqs_H__ */
Index: /code/branches/physics/src/orxonox/OrxonoxStableHeaders.h
===================================================================
--- /code/branches/physics/src/orxonox/OrxonoxStableHeaders.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/OrxonoxStableHeaders.h	(revision 2122)
@@ -0,0 +1,105 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Contains the frequently used header files of our own writing
+ */
+
+#ifndef _OrxonoxStableHeaders_H__
+#define _OrxonoxStableHeaders_H__
+
+#include "util/OrxonoxPlatform.h"
+
+#if defined(ORXONOX_ENABLE_PCH)
+
+// including std headers here is useless since they're already precompiled
+
+#ifndef WIN32_LEAN_AND_MEAN
+// prevent Ogre from including winsock.h that messes with winsock2.h from enet
+#  define WIN32_LEAN_AND_MEAN
+#endif
+#include <Ogre.h>
+#include <CEGUI.h>
+#include "ois/OIS.h"
+#include <boost/thread/recursive_mutex.hpp>
+//#include <boost/thread/mutex.hpp>
+//#include <boost/thread/condition.hpp>
+//#include <boost/thread/thread.hpp>
+#include <boost/static_assert.hpp>
+#include "tinyxml/ticpp.h"
+#include "tinyxml/tinyxml.h"
+#include "tolua/tolua++.h"
+
+//Get around Windows hackery (windows.h is included by Ogre.h)
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 
+#  ifdef max
+#    undef max
+#  endif
+#  ifdef min
+#    undef min
+#  endif
+#endif
+
+//----------- Our files ----------
+//--------------------------------
+//// only include when not debugging so that we may find issues with missing headers quicker
+//#if defined(NDEBUG)
+
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "util/Math.h"
+#include "util/Multitype.h"
+#include "util/Sleep.h"
+#include "util/String.h"
+#include "util/SubString.h"
+
+#include "core/BaseObject.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CommandExecutor.h"
+#include "core/Core.h"
+#include "core/Executor.h"
+#include "core/ObjectList.h"
+#include "core/Super.h"
+#include "core/XMLIncludes.h"
+#include "core/XMLPort.h"
+#include "core/input/SimpleInputState.h"
+#include "core/input/InputManager.h"
+
+#include "network/Synchronisable.h"
+
+#include "Settings.h"
+
+//#endif /* ifdef NDEBUG */
+
+#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
+
+#endif /* _OrxonoxStableHeaders_H__ */
Index: /code/branches/physics/src/orxonox/PrecompiledHeaderFiles.cc
===================================================================
--- /code/branches/physics/src/orxonox/PrecompiledHeaderFiles.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/PrecompiledHeaderFiles.cc	(revision 2122)
@@ -0,0 +1,34 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief This file actually generates the precompiled header file
+ */
+
+#include "OrxonoxStableHeaders.h"
Index: /code/branches/physics/src/orxonox/Settings.cc
===================================================================
--- /code/branches/physics/src/orxonox/Settings.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/Settings.cc	(revision 2122)
@@ -0,0 +1,99 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the Settings class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "Settings.h"
+
+#include "util/String.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/LuaBind.h"
+
+namespace orxonox
+{
+    Settings* Settings::singletonRef_s = 0;
+
+    /**
+    @brief
+        Constructor: Registers the object and sets the config-values.
+    */
+    Settings::Settings()
+    {
+        RegisterRootObject(Settings);
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+        setConfigValues();
+    }
+
+    /**
+    @brief
+        Function to collect the SetConfigValue-macro calls.
+    */
+    void Settings::setConfigValues()
+    {
+        SetConfigValue(dataPath_, "../../media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);
+    }
+
+    /**
+    @brief
+        Callback function if the datapath has changed.
+    */
+    void Settings::dataPathChanged()
+    {
+        if (dataPath_ != "" && dataPath_[dataPath_.size() - 1] != '/')
+        {
+            ModifyConfigValue(dataPath_, set, dataPath_ + "/");
+        }
+
+        if (dataPath_ == "")
+        {
+            ModifyConfigValue(dataPath_, set, "/");
+            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
+        }
+
+        LuaBind::getInstance()->setIncludePath(this->dataPath_);
+    }
+
+    /**
+    @brief
+        Temporary sets the data path
+    @param path
+        The new data path
+    */
+    void Settings::_tsetDataPath(const std::string& path)
+    {
+        ModifyConfigValue(dataPath_, tset, path);
+    }
+
+}
Index: /code/branches/physics/src/orxonox/Settings.h
===================================================================
--- /code/branches/physics/src/orxonox/Settings.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/Settings.h	(revision 2122)
@@ -0,0 +1,77 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Core.h
+    @brief Declaration of the Settings class.
+
+    The static Settings class is only used to configure some variables
+    through the config-file.
+*/
+
+#ifndef _Settings_H__
+#define _Settings_H__
+
+#include "OrxonoxPrereqs.h"
+#include <string>
+#include "core/OrxonoxClass.h"
+#include "util/Debug.h"
+#include "util/MultiType.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Settings : public OrxonoxClass
+    {
+        friend class ClassIdentifier<Settings>;
+        friend class GSRoot;
+
+    public:
+        static const std::string& getDataPath()
+        { assert(singletonRef_s); return singletonRef_s->dataPath_; }
+        static void tsetDataPath(const std::string& path)
+        { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); }
+
+    private:
+        Settings();
+        Settings(const Settings& instance);
+        ~Settings() { singletonRef_s = 0; }
+
+        static Settings& _getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+        void _tsetDataPath(const std::string& path);
+        void dataPathChanged();
+
+        void setConfigValues();
+
+        std::string dataPath_;                                 //!< Path to the game data
+
+        static Settings* singletonRef_s;                       //!< Static pointer to the only instance.
+    };
+
+}
+
+#endif /* _Settings_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSClient.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSClient.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSClient.cc	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSClient.h"
+
+#include "core/input/InputManager.h"
+#include "core/CommandLine.h"
+#include "core/Core.h"
+#include "network/Client.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
+
+    GSClient::GSClient()
+        : GameState<GSGraphics>("client")
+        , client_(0)
+    {
+    }
+
+    GSClient::~GSClient()
+    {
+    }
+
+    void GSClient::enter()
+    {
+        Core::setIsClient(true);
+
+        this->client_ = new network::Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
+
+        if(!client_->establishConnection())
+            ThrowException(InitialisationFailed, "Could not establish connection with server.");
+
+        GSLevel::enter(this->getParent()->getViewport());
+
+        client_->tick(0);
+    }
+
+    void GSClient::leave()
+    {
+        GSLevel::leave();
+
+        client_->closeConnection();
+
+        // destroy client
+        delete this->client_;
+
+        Core::setIsClient(false);
+    }
+
+    void GSClient::ticked(const Clock& time)
+    {
+        GSLevel::ticked(time);
+        client_->tick(time.getDeltaTime());
+
+        this->tickChild(time);
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSClient.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSClient.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSClient.h	(revision 2122)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSClient_H__
+#define _GSClient_H__
+
+#include "OrxonoxPrereqs.h"
+#include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
+    {
+    public:
+        GSClient();
+        ~GSClient();
+
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        network::Client* client_;
+    };
+}
+
+#endif /* _GSClient_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSDedicated.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSDedicated.cc	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSDedicated.h"
+
+#include "core/CommandLine.h"
+#include "core/Core.h"
+#include "network/Server.h"
+
+namespace orxonox
+{
+    GSDedicated::GSDedicated()
+        : GameState<GSRoot>("dedicated")
+        , server_(0)
+    {
+    }
+
+    GSDedicated::~GSDedicated()
+    {
+    }
+
+    void GSDedicated::enter()
+    {
+        Core::setHasServer(true);
+
+        this->server_ = new network::Server(CommandLine::getValue("port"));
+        COUT(0) << "Loading scene in server mode" << std::endl;
+
+        GSLevel::enter(0);
+
+        server_->open();
+    }
+
+    void GSDedicated::leave()
+    {
+        GSLevel::leave();
+
+        this->server_->close();
+        delete this->server_;
+
+        Core::setHasServer(false);
+    }
+
+    void GSDedicated::ticked(const Clock& time)
+    {
+        GSLevel::ticked(time);
+        server_->tick(time.getDeltaTime());
+        this->tickChild(time);
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSDedicated.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSDedicated.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSDedicated_H__
+#define _GSDedicated_H__
+
+#include "OrxonoxPrereqs.h"
+#include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+#include "GSRoot.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
+    {
+    public:
+        GSDedicated();
+        ~GSDedicated();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        network::Server*      server_;
+    };
+}
+
+#endif /* _GSDedicated_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSGUI.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSGUI.cc	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSGUI.h"
+
+#include <OgreViewport.h>
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "gui/GUIManager.h"
+
+namespace orxonox
+{
+    GSGUI::GSGUI()
+        : GameState<GSGraphics>("gui")
+    {
+    }
+
+    GSGUI::~GSGUI()
+    {
+    }
+
+    void GSGUI::enter()
+    {
+        guiManager_ = getParent()->getGUIManager();
+
+        // show main menu
+        guiManager_->showGUI("MainMenu", 0);
+        getParent()->getViewport()->setCamera(guiManager_->getCamera());
+    }
+
+    void GSGUI::leave()
+    {
+        guiManager_->hideGUI();
+    }
+
+    void GSGUI::ticked(const Clock& time)
+    {
+        // tick CEGUI
+        guiManager_->tick(time.getDeltaTime());
+
+        this->tickChild(time);
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSGUI.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSGUI.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSGUI.h	(revision 2122)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSGUI_H__
+#define _GSGUI_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/GameState.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSGUI : public GameState<GSGraphics>
+    {
+    public:
+        GSGUI();
+        ~GSGUI();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        GUIManager* guiManager_;
+    };
+}
+
+#endif /* _GSGUI_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSGraphics.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSGraphics.cc	(revision 2122)
@@ -0,0 +1,562 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSGraphics.h"
+
+#include <fstream>
+#include <OgreConfigFile.h>
+#include <OgreFrameListener.h>
+#include <OgreRoot.h>
+#include <OgreLogManager.h>
+#include <OgreException.h>
+#include <OgreRenderWindow.h>
+#include <OgreRenderSystem.h>
+#include <OgreTextureManager.h>
+#include <OgreViewport.h>
+#include <OgreWindowEventUtilities.h>
+
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+#include "core/input/InputManager.h"
+#include "core/input/KeyBinder.h"
+#include "core/input/ExtendedInputState.h"
+#include "core/Loader.h"
+#include "core/XMLFile.h"
+#include "overlays/console/InGameConsole.h"
+#include "gui/GUIManager.h"
+#include "tools/WindowEventListener.h"
+#include "objects/Tickable.h"
+#include "Settings.h"
+
+// for compatibility
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    GSGraphics::GSGraphics()
+        : GameState<GSRoot>("graphics")
+        , renderWindow_(0)
+        , viewport_(0)
+        , bWindowEventListenerUpdateRequired_(false)
+        , inputManager_(0)
+        , console_(0)
+        , guiManager_(0)
+        , ogreRoot_(0)
+        , ogreLogger_(0)
+        , graphicsEngine_(0)
+        , masterKeyBinder_(0)
+        , frameCount_(0)
+        , statisticsRefreshCycle_(0)
+        , statisticsStartTime_(0)
+        , statisticsStartCount_(0)
+        , tickTime_(0)
+        , debugOverlay_(0)
+    {
+        RegisterRootObject(GSGraphics);
+        setConfigValues();
+    }
+
+    GSGraphics::~GSGraphics()
+    {
+    }
+
+    void GSGraphics::setConfigValues()
+    {
+        SetConfigValue(resourceFile_,    "resources.cfg")
+            .description("Location of the resources file in the data path.");
+        SetConfigValue(ogreConfigFile_,  "ogre.cfg")
+            .description("Location of the Ogre config file");
+        SetConfigValue(ogrePluginsFile_, "plugins.cfg")
+            .description("Location of the Ogre plugins file");
+        SetConfigValue(ogreLogFile_,     "ogre.log")
+            .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
+        SetConfigValue(ogreLogLevelTrivial_ , 5)
+            .description("Corresponding orxonox debug level for ogre Trivial");
+        SetConfigValue(ogreLogLevelNormal_  , 4)
+            .description("Corresponding orxonox debug level for ogre Normal");
+        SetConfigValue(ogreLogLevelCritical_, 2)
+            .description("Corresponding orxonox debug level for ogre Critical");
+        SetConfigValue(statisticsRefreshCycle_, 200000)
+            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+        SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini")
+            .description("Filename of default master keybindings.");
+    }
+
+    void GSGraphics::enter()
+    {
+        Core::setShowsGraphics(true);
+
+        // initialise graphics engine. Doesn't load the render window yet!
+        graphicsEngine_ = new GraphicsEngine();
+
+        // Ogre setup procedure
+        setupOgre();
+        this->declareResources();
+        this->loadRenderer();    // creates the render window
+        // TODO: Spread this so that this call only initialises things needed for the Console and GUI
+        this->initialiseResources();
+
+        // We want to get informed whenever an object of type WindowEventListener is created
+        // in order to later update the window size.
+        bWindowEventListenerUpdateRequired_ = false;
+        RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate);
+
+        // load debug overlay
+        COUT(3) << "Loading Debug Overlay..." << std::endl;
+        this->debugOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/debug.oxo");
+        Loader::open(debugOverlay_);
+
+        // Calls the InputManager which sets up the input devices.
+        // The render window width and height are used to set up the mouse movement.
+        inputManager_ = new InputManager();
+        size_t windowHnd = 0;
+        this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
+        inputManager_->initialise(windowHnd, renderWindow_->getWidth(), renderWindow_->getHeight(), true);
+        // Configure master input state with a KeyBinder
+        masterKeyBinder_ = new KeyBinder();
+        masterKeyBinder_->loadBindings("masterKeybindings.ini", defaultMasterKeybindings_);
+        inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
+
+        // Load the InGameConsole
+        console_ = new InGameConsole();
+        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
+
+        // load the CEGUI interface
+        guiManager_ = new GUIManager();
+        guiManager_->initialise(this->renderWindow_);
+
+        // reset frame counter
+        this->frameCount_ = 0;
+        this->tickTime_ = 0;
+        statisticsStartTime_ = 0;
+        statisticsStartCount_ = 0;
+
+        // add console commands
+        FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
+        functor1->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen"));
+    }
+
+    void GSGraphics::leave()
+    {
+        using namespace Ogre;
+
+        // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
+        Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
+
+        delete this->guiManager_;
+
+        delete this->console_;
+
+        //inputManager_->getMasterInputState()->removeKeyHandler(this->masterKeyBinder_);
+        delete this->masterKeyBinder_;
+        delete this->inputManager_;
+
+        Loader::unload(this->debugOverlay_);
+        delete this->debugOverlay_;
+
+        // destroy render window
+        RenderSystem* renderer = this->ogreRoot_->getRenderSystem();
+        renderer->destroyRenderWindow("Orxonox");
+
+        /*** CODE SNIPPET, UNUSED ***/
+        // Does the opposite of initialise()
+        //ogreRoot_->shutdown();
+        // Remove all resources and resource groups
+        //StringVector groups = ResourceGroupManager::getSingleton().getResourceGroups();
+        //for (StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
+        //{
+        //    ResourceGroupManager::getSingleton().destroyResourceGroup(*it);
+        //}
+
+        //ParticleSystemManager::getSingleton().removeAllTemplates();
+
+        // Shutdown the render system
+        //this->ogreRoot_->setRenderSystem(0);
+
+        delete this->ogreRoot_;
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // delete the ogre log and the logManager (since we have created it).
+        this->ogreLogger_->getDefaultLog()->removeListener(this);
+        this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
+        delete this->ogreLogger_;
+#endif
+
+        delete graphicsEngine_;
+
+        Core::setShowsGraphics(false);
+    }
+
+    /**
+        Main loop of the orxonox game.
+        We use the Ogre::Timer to measure time since it uses the most precise
+        method an a platform (however the windows timer lacks time when under
+        heavy kernel load!).
+        There is a simple mechanism to measure the average time spent in our
+        ticks as it may indicate performance issues.
+        A note about the Ogre::FrameListener: Even though we don't use them,
+        they still get called. However, the delta times are not correct (except
+        for timeSinceLastFrame, which is the most important). A little research
+        as shown that there is probably only one FrameListener that doesn't even
+        need the time. So we shouldn't run into problems.
+    */
+    void GSGraphics::ticked(const Clock& time)
+    {
+        unsigned long long timeBeforeTick = time.getRealMicroseconds();
+        float dt = time.getDeltaTime();
+
+        this->inputManager_->tick(dt);
+        // tick console
+        this->console_->tick(dt);
+        this->tickChild(time);
+
+        /*** HACK *** HACK ***/
+        // Call the Tickable objects
+        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
+            it->tick(time.getDeltaTime());
+        /*** HACK *** HACK ***/
+
+        if (this->bWindowEventListenerUpdateRequired_)
+        {
+            // Update all WindowEventListeners for the case a new one was created.
+            this->windowResized(this->renderWindow_);
+            this->bWindowEventListenerUpdateRequired_ = false;
+        }
+
+        unsigned long long timeAfterTick = time.getRealMicroseconds();
+
+        tickTime_ += (unsigned int)(timeAfterTick - timeBeforeTick);
+        if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
+        {
+            GraphicsEngine::getInstance().setAverageTickTime(
+                (float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_));
+            float avgFPS = (float)(frameCount_ - statisticsStartCount_)
+                / (timeAfterTick - statisticsStartTime_) * 1000000.0;
+            GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
+
+            tickTime_ = 0;
+            statisticsStartCount_ = frameCount_;
+            statisticsStartTime_  = timeAfterTick;
+        }
+
+        // don't forget to call _fireFrameStarted in ogre to make sure
+        // everything goes smoothly
+        Ogre::FrameEvent evt;
+        evt.timeSinceLastFrame = dt;
+        evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
+        ogreRoot_->_fireFrameStarted(evt);
+
+        // Pump messages in all registered RenderWindows
+        // This calls the WindowEventListener objects.
+        Ogre::WindowEventUtilities::messagePump();
+        // make sure the window stays active even when not focused
+        // (probably only necessary on windows)
+        this->renderWindow_->setActive(true);
+
+        // render
+        ogreRoot_->_updateAllRenderTargets();
+
+        // again, just to be sure ogre works fine
+        ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
+
+        ++frameCount_;
+    }
+
+    /**
+    @brief
+        Creates the Ogre Root object and sets up the ogre log.
+    */
+    void GSGraphics::setupOgre()
+    {
+        COUT(3) << "Setting up Ogre..." << std::endl;
+
+        // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // create a new logManager
+        ogreLogger_ = new Ogre::LogManager();
+        COUT(4) << "Ogre LogManager created" << std::endl;
+
+        // create our own log that we can listen to
+        Ogre::Log *myLog;
+        if (this->ogreLogFile_ == "")
+            myLog = ogreLogger_->createLog("ogre.log", true, false, true);
+        else
+            myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false);
+        COUT(4) << "Ogre Log created" << std::endl;
+
+        myLog->setLogDetail(Ogre::LL_BOREME);
+        myLog->addListener(this);
+#endif
+
+        // Root will detect that we've already created a Log
+        COUT(4) << "Creating Ogre Root..." << std::endl;
+
+        if (ogrePluginsFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre plugins file set to \"\". Defaulting to plugins.cfg" << std::endl;
+            ModifyConfigValue(ogrePluginsFile_, tset, "plugins.cfg");
+        }
+        if (ogreConfigFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
+            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
+        }
+        if (ogreLogFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
+            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
+        }
+
+        // check for config file existence because Ogre displays (caught) exceptions if not
+        std::ifstream probe;
+        probe.open(ogreConfigFile_.c_str());
+        if (!probe)
+        {
+            // create a zero sized file
+            std::ofstream creator;
+            creator.open(ogreConfigFile_.c_str());
+            creator.close();
+        }
+        else
+            probe.close();
+
+        ogreRoot_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
+
+#if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
+#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
+        // tame the ogre ouput so we don't get all the mess in the console
+        Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
+        defaultLog->setDebugOutputEnabled(false);
+        defaultLog->setLogDetail(Ogre::LL_BOREME);
+        defaultLog->addListener(this);
+#endif
+#endif
+
+        COUT(3) << "Ogre set up done." << std::endl;
+    }
+
+    void GSGraphics::declareResources()
+    {
+        CCOUT(4) << "Declaring Resources" << std::endl;
+        //TODO: Specify layout of data file and maybe use xml-loader
+        //TODO: Work with ressource groups (should be generated by a special loader)
+
+        if (resourceFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl;
+            ModifyConfigValue(resourceFile_, tset, "resources.cfg");
+        }
+
+        // Load resource paths from data file using configfile ressource type
+        Ogre::ConfigFile cf;
+        try
+        {
+            cf.load(Settings::getDataPath() + resourceFile_);
+        }
+        catch (...)
+        {
+            //COUT(1) << ex.getFullDescription() << std::endl;
+            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
+            throw;
+        }
+
+        // Go through all sections & settings in the file
+        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
+
+        std::string secName, typeName, archName;
+        while (seci.hasMoreElements())
+        {
+            try
+            {
+                secName = seci.peekNextKey();
+                Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
+                Ogre::ConfigFile::SettingsMultiMap::iterator i;
+                for (i = settings->begin(); i != settings->end(); ++i)
+                {
+                    typeName = i->first; // for instance "FileSystem" or "Zip"
+                    archName = i->second; // name (and location) of archive
+
+                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
+                        std::string(Settings::getDataPath() + archName), typeName, secName);
+                }
+            }
+            catch (Ogre::Exception& ex)
+            {
+                COUT(1) << ex.getFullDescription() << std::endl;
+            }
+        }
+    }
+
+    void GSGraphics::loadRenderer()
+    {
+        CCOUT(4) << "Configuring Renderer" << std::endl;
+
+        if (!ogreRoot_->restoreConfig())
+            if (!ogreRoot_->showConfigDialog())
+                ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
+
+        CCOUT(4) << "Creating render window" << std::endl;
+
+        this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
+
+        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
+
+        Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);
+
+        // create a full screen default viewport
+        this->viewport_ = this->renderWindow_->addViewport(0, 0);
+    }
+
+    void GSGraphics::initialiseResources()
+    {
+        CCOUT(4) << "Initialising resources" << std::endl;
+        //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
+        //try
+        //{
+            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+            /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+            for (unsigned int i = 0; i < str.size(); i++)
+            {
+            Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
+            }*/
+        //}
+        //catch (...)
+        //{
+        //    CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
+        //    throw;
+        //}
+    }
+
+    /**
+    @brief
+        Method called by the LogListener interface from Ogre.
+        We use it to capture Ogre log messages and handle it ourselves.
+    @param message
+        The message to be logged
+    @param lml
+        The message level the log is using
+    @param maskDebug
+        If we are printing to the console or not
+    @param logName
+        The name of this log (so you can have several listeners
+        for different logs, and identify them)
+    */
+    void GSGraphics::messageLogged(const std::string& message,
+        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
+    {
+        int orxonoxLevel;
+        switch (lml)
+        {
+        case Ogre::LML_TRIVIAL:
+            orxonoxLevel = this->ogreLogLevelTrivial_;
+            break;
+        case Ogre::LML_NORMAL:
+            orxonoxLevel = this->ogreLogLevelNormal_;
+            break;
+        case Ogre::LML_CRITICAL:
+            orxonoxLevel = this->ogreLogLevelCritical_;
+            break;
+        default:
+            orxonoxLevel = 0;
+        }
+        OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+            << "Ogre: " << message << std::endl;
+    }
+
+    /**
+    @brief
+        Window has moved.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowMoved(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowMoved();
+    }
+
+    /**
+    @brief
+        Window has resized.
+    @param rw
+        The render window it occured in
+    @note
+        GraphicsEngine has a render window stored itself. This is the same
+        as rw. But we have to be careful when using multiple render windows!
+    */
+    void GSGraphics::windowResized(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
+
+        // OIS needs this under linux even if we only use relative input measurement.
+        if (this->inputManager_)
+            this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight());
+    }
+
+    /**
+    @brief
+        Window focus has changed.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowFocusChange(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowFocusChanged();
+
+        // instruct InputManager to clear the buffers (core library so we cannot use the interface)
+        if (this->inputManager_)
+            this->inputManager_->clearBuffers();
+    }
+
+    /**
+    @brief
+        Window was closed.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
+    {
+        this->requestState("root");
+    }
+
+    void GSGraphics::printScreen()
+    {
+        if (this->renderWindow_)
+        {
+            this->renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSGraphics.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSGraphics.h	(revision 2122)
@@ -0,0 +1,117 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSGraphics_H__
+#define _GSGraphics_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <OgreWindowEventUtilities.h>
+#include "core/GameState.h"
+#include "core/OrxonoxClass.h"
+#include "GSRoot.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass,
+                                      public Ogre::WindowEventListener, public Ogre::LogListener
+    {
+        friend class ClassIdentifier<GSGraphics>;
+
+    public:
+        GSGraphics();
+        ~GSGraphics();
+
+        Ogre::Root*     getOgreRoot()   { return this->ogreRoot_  ; }
+        Ogre::Viewport* getViewport()   { return this->viewport_  ; }
+        GUIManager*     getGUIManager() { return this->guiManager_; }
+
+    private: // functions
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        void setConfigValues();
+
+        void setupOgre();
+        void declareResources();
+        void loadRenderer();
+        void initialiseResources();
+
+        // console commands
+        void printScreen();
+
+        // event from Ogre::LogListener
+        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
+            bool maskDebug, const std::string& logName);
+
+        // window events from Ogre::WindowEventListener
+        void windowMoved       (Ogre::RenderWindow* rw);
+        void windowResized     (Ogre::RenderWindow* rw);
+        void windowFocusChange (Ogre::RenderWindow* rw);
+        void windowClosed      (Ogre::RenderWindow* rw);
+
+        void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; }
+
+    private: // variables
+        Ogre::RenderWindow*   renderWindow_;          //!< the current render window
+        Ogre::Viewport*       viewport_;              //!< default full size viewport
+        bool bWindowEventListenerUpdateRequired_;     //!< True if a new WindowEventListener was created but not yet updated.
+
+        // managed singletons
+        InputManager*         inputManager_;
+        InGameConsole*        console_;
+        GUIManager*           guiManager_;
+        Ogre::Root*           ogreRoot_;                  //!< Ogre's root
+        Ogre::LogManager*     ogreLogger_;
+        GraphicsEngine*       graphicsEngine_;   //!< Interface to Ogre
+
+        KeyBinder*            masterKeyBinder_;
+
+        // variables for time statistics
+        unsigned long         frameCount_;
+        unsigned int          statisticsRefreshCycle_;
+        unsigned long long    statisticsStartTime_;
+        unsigned long         statisticsStartCount_;
+        unsigned int          tickTime_;
+        XMLFile*              debugOverlay_;
+
+        // config values
+        std::string           resourceFile_;             //!< resources file name
+        std::string           ogreConfigFile_;           //!< ogre config file name
+        std::string           ogrePluginsFile_;          //!< ogre plugins file name
+        std::string           ogreLogFile_;              //!< log file name for Ogre log messages
+        int                   ogreLogLevelTrivial_;      //!< Corresponding Orxonx debug level for LL_TRIVIAL
+        int                   ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
+        int                   ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
+        unsigned int          detailLevelParticle_;      //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
+        std::string           defaultMasterKeybindings_; //!< Filename of default master keybindings.
+    };
+}
+
+#endif /* _GSGraphics_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSIOConsole.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSIOConsole.cc	(revision 2122)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSIOConsole.h"
+
+#include <iostream>
+#include <OgreFrameListener.h>
+#include <OgreRoot.h>
+#include <OgreTimer.h>
+
+#include "core/ConsoleCommand.h"
+
+namespace orxonox
+{
+    GSIOConsole::GSIOConsole()
+        : GameState<GSRoot>("ioConsole")
+    {
+    }
+
+    GSIOConsole::~GSIOConsole()
+    {
+    }
+
+    void GSIOConsole::enter()
+    {
+    }
+
+    void GSIOConsole::leave()
+    {
+    }
+
+    void GSIOConsole::ticked(const Clock& time)
+    {
+        std::string command;
+        std::getline(std::cin, command);
+        CommandExecutor::execute(command, true);
+        
+        tickChild(time);
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSIOConsole.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSIOConsole.h	(revision 2122)
@@ -0,0 +1,52 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSIOConsole_H__
+#define _GSIOConsole_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include "core/GameState.h"
+#include "GSRoot.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSIOConsole : public GameState<GSRoot>
+    {
+    public:
+        GSIOConsole();
+        ~GSIOConsole();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+    };
+}
+
+#endif /* _GSIOConsole_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSLevel.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSLevel.cc	(revision 2122)
@@ -0,0 +1,270 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSLevel.h"
+
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/input/KeyBinder.h"
+#include "core/Loader.h"
+#include "core/XMLFile.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandLine.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+//#include "objects/Backlight.h"
+#include "objects/Tickable.h"
+#include "objects/Radar.h"
+//#include "tools/ParticleInterface.h"
+#include "CameraManager.h"
+#include "LevelManager.h"
+#include "Settings.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(level, "physicstest2.oxw").shortcut("l");
+
+    GSLevel::GSLevel()
+//        : GameState<GSGraphics>(name)
+        : timeFactor_(1.0f)
+        , keyBinder_(0)
+        , inputState_(0)
+        , radar_(0)
+        , startFile_(0)
+        , cameraManager_(0)
+        , levelManager_(0)
+    {
+        RegisterObject(GSLevel);
+        setConfigValues();
+    }
+
+    GSLevel::~GSLevel()
+    {
+    }
+
+    void GSLevel::setConfigValues()
+    {
+        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
+        SetConfigValue(defaultKeybindings_, "def_keybindings.ini")
+            .description("Filename of default keybindings.");
+    }
+
+    void GSLevel::enter(Ogre::Viewport* viewport)
+    {
+        if (Core::showsGraphics())
+        {
+            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
+            keyBinder_ = new KeyBinder();
+            keyBinder_->loadBindings("keybindings.ini", defaultKeybindings_);
+            inputState_->setHandler(keyBinder_);
+
+            // create the global CameraManager
+            assert(viewport);
+            this->cameraManager_ = new CameraManager(viewport);
+
+            // Start the Radar
+            this->radar_ = new Radar();
+        }
+
+        if (Core::isMaster())
+        {
+            // create the global LevelManager
+            this->levelManager_ = new LevelManager();
+
+            // reset game speed to normal
+            timeFactor_ = 1.0f;
+
+            this->loadLevel();
+        }
+
+        if (Core::showsGraphics())
+        {
+            // TODO: insert slomo console command with
+            // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
+
+            // keybind console command
+            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
+            functor1->setObject(this);
+            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
+            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
+            functor2->setObject(this);
+            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
+            // set our console command as callback for the key detector
+            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
+
+            // level is loaded: we can start capturing the input
+            InputManager::getInstance().requestEnterState("game");
+        }
+
+        if (Core::isMaster())
+        {
+            // time factor console command
+            FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
+            functor->setObject(this);
+            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
+        }
+    }
+
+    void GSLevel::leave()
+    {
+        // this call will delete every BaseObject!
+        // But currently this will call methods of objects that exist no more
+        // The only 'memory leak' is the ParticleSpawer. They would be deleted here
+        // and call a sceneNode method that has already been destroy by the corresponding space ship.
+        //Loader::close();
+
+        if (Core::showsGraphics())
+            InputManager::getInstance().requestLeaveState("game");
+
+        if (Core::isMaster())
+            this->unloadLevel();
+
+        if (this->radar_)
+            delete this->radar_;
+
+        if (this->cameraManager_)
+            delete this->cameraManager_;
+
+        if (this->levelManager_)
+            delete this->levelManager_;
+
+        if (Core::showsGraphics())
+        {
+            inputState_->setHandler(0);
+            InputManager::getInstance().requestDestroyState("game");
+            if (this->keyBinder_)
+                delete this->keyBinder_;
+        }
+    }
+
+    void GSLevel::ticked(const Clock& time)
+    {
+        // Commented by 1337: Temporarily moved to GSGraphics.
+        //// Call the scene objects
+        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
+        //    it->tick(time.getDeltaTime() * this->timeFactor_);
+    }
+
+    /**
+    @brief
+        Changes the speed of Orxonox
+    */
+    void GSLevel::setTimeFactor(float factor)
+    {
+/*
+        float change = factor / this->timeFactor_;
+*/
+        this->timeFactor_ = factor;
+/*
+        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
+            it->setSpeedFactor(it->getSpeedFactor() * change);
+
+        for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
+            it->setTimeFactor(timeFactor_);
+*/
+    }
+
+    void GSLevel::loadLevel()
+    {
+        // call the loader
+        COUT(0) << "Loading level..." << std::endl;
+        std::string levelName;
+        CommandLine::getValue("level", &levelName);
+        startFile_ = new XMLFile(Settings::getDataPath() + std::string("levels/") + levelName);
+        Loader::open(startFile_);
+    }
+
+    void GSLevel::unloadLevel()
+    {
+        //////////////////////////////////////////////////////////////////////////////////////////
+        // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO //
+        //////////////////////////////////////////////////////////////////////////////////////////
+        // Loader::unload(startFile_); // TODO: REACTIVATE THIS IF LOADER::UNLOAD WORKS PROPERLY /
+        //////////////////////////////////////////////////////////////////////////////////////////
+
+        delete this->startFile_;
+    }
+
+    void GSLevel::keybind(const std::string &command)
+    {
+        this->keybindInternal(command, false);
+    }
+
+    void GSLevel::tkeybind(const std::string &command)
+    {
+        this->keybindInternal(command, true);
+    }
+
+    /**
+    @brief
+        Assigns a command string to a key/button/axis. The name is determined via KeyDetector.
+    @param command
+        Command string that can be executed by the CommandExecutor
+        OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
+        the key/button/axis that has been activated. This is configured above in enter().
+    */
+    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
+    {
+        if (Core::showsGraphics())
+        {
+            static std::string bindingString = "";
+            static bool bTemporarySaved = false;
+            static bool bound = true;
+            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
+            // Howerver there will be no real issue if it happens anyway.
+            if (command.find(keyDetectorCallbackCode_) != 0)
+            {
+                if (bound)
+                {
+                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+                    InputManager::getInstance().requestEnterState("detector");
+                    bindingString = command;
+                    bTemporarySaved = bTemporary;
+                    bound = false;
+                }
+                //else:  We're still in a keybind command. ignore this call.
+            }
+            else
+            {
+                if (!bound)
+                {
+                    // user has pressed the key
+                    std::string name = command.substr(this->keyDetectorCallbackCode_.size());
+                    COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
+                    this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
+                    InputManager::getInstance().requestLeaveState("detector");
+                    bound = true;
+                }
+                // else: A key was pressed within the same tick, ignore it.
+            }
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSLevel.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSLevel.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSLevel.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSLevel_H__
+#define _GSLevel_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include "core/GameState.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>
+    {
+        friend class ClassIdentifier<GSLevel>;
+    public:
+        GSLevel();
+        ~GSLevel();
+
+        // this has to be public because proteced triggers a bug in msvc
+        // when taking the function address.
+        void setTimeFactor(float factor);
+        float getTimeFactor() { return this->timeFactor_; }
+
+    protected:
+        void enter(Ogre::Viewport* viewport);
+        void leave();
+        void ticked(const Clock& time);
+
+        void loadLevel();
+        void unloadLevel();
+
+        float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
+
+        // console commands
+        void keybind(const std::string& command);
+        void tkeybind(const std::string& command);
+        void keybindInternal(const std::string& command, bool bTemporary);
+
+        KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
+        SimpleInputState*     inputState_;
+        Radar*                radar_;            //!< represents the Radar (not the HUD part)
+        XMLFile*              startFile_;        //!< current hard coded default level
+        CameraManager*        cameraManager_;
+        LevelManager*         levelManager_;
+
+        //##### ConfigValues #####
+        std::string           keyDetectorCallbackCode_;
+        //! Filename of default keybindings.
+        std::string           defaultKeybindings_;
+
+    private:
+        void setConfigValues();
+
+    };
+}
+
+#endif /* _GSLevel_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSRoot.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSRoot.cc	(revision 2122)
@@ -0,0 +1,188 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSRoot.h"
+
+#include "util/Exception.h"
+#include "util/Debug.h"
+#include "core/Factory.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandLine.h"
+#include "core/Shell.h"
+#include "core/TclBind.h"
+#include "core/TclThreadManager.h"
+#include "tools/Timer.h"
+#include "Settings.h"
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include "windows.h"
+
+   //Get around Windows hackery
+#  ifdef max
+#    undef max
+#  endif
+#  ifdef min
+#    undef min
+#  endif
+#endif
+
+namespace orxonox
+{
+    SetCommandLineArgument(dataPath, "").information("PATH");
+    SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
+
+    GSRoot::GSRoot()
+        : RootGameState("root")
+        , settings_(0)
+        , tclBind_(0)
+        , tclThreadManager_(0)
+        , shell_(0)
+    {
+        RegisterRootObject(GSRoot);
+        setConfigValues();
+    }
+
+    GSRoot::~GSRoot()
+    {
+    }
+
+    void GSRoot::setConfigValues()
+    {
+    }
+
+    void GSRoot::enter()
+    {
+        // creates the class hierarchy for all classes with factories
+        Factory::createClassHierarchy();
+
+        // instantiate Settings class
+        this->settings_ = new Settings();
+
+        std::string dataPath = CommandLine::getValue("dataPath");
+        if (dataPath != "")
+        {
+            if (*dataPath.end() != '/' && *dataPath.end() != '\\')
+                Settings::tsetDataPath(dataPath + "/");
+            else
+                Settings::tsetDataPath(dataPath);
+        }
+
+        // initialise TCL
+        this->tclBind_ = new TclBind(Settings::getDataPath());
+        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
+
+        // create a shell
+        this->shell_ = new Shell();
+
+        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
+        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
+        // the timer though).
+        int limitToCPU = CommandLine::getValue("limitToCPU");
+        if (limitToCPU > 0)
+            setThreadAffinity((unsigned int)(limitToCPU - 1));
+
+        // add console commands
+        FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame);
+        functor1->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit"));
+
+        // add console commands
+        FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState);
+        functor2->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState"));
+    }
+
+    void GSRoot::leave()
+    {
+        // TODO: remove and destroy console commands
+
+        delete this->shell_;
+        delete this->tclThreadManager_;
+        delete this->tclBind_;
+
+        delete settings_;
+
+    }
+
+    void GSRoot::ticked(const Clock& time)
+    {
+        TclThreadManager::getInstance().tick(time.getDeltaTime());
+
+        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
+            it->tick(time);
+
+        this->tickChild(time);
+    }
+
+    /**
+    @note
+        The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
+            (Object-oriented Graphics Rendering Engine)
+        For the latest info, see http://www.ogre3d.org/
+
+        Copyright (c) 2000-2008 Torus Knot Software Ltd
+        
+        OGRE is licensed under the LGPL. For more info, see OGRE license.
+    */
+    void GSRoot::setThreadAffinity(unsigned int limitToCPU)
+    {
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // Get the current process core mask
+	    DWORD procMask;
+	    DWORD sysMask;
+#  if _MSC_VER >= 1400 && defined (_M_X64)
+	    GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
+#  else
+	    GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
+#  endif
+
+	    // If procMask is 0, consider there is only one core available
+	    // (using 0 as procMask will cause an infinite loop below)
+	    if (procMask == 0)
+		    procMask = 1;
+
+        // if the core specified with limitToCPU is not available, take the lowest one
+        if (!(procMask & (1 << limitToCPU)))
+            limitToCPU = 0;
+
+	    // Find the lowest core that this process uses and limitToCPU suggests
+        DWORD threadMask = 1;
+	    while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
+		    threadMask <<= 1;
+
+	    // Set affinity to the first core
+	    SetThreadAffinityMask(GetCurrentThread(), threadMask);
+#endif
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSRoot.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSRoot.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSRoot.h	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSRoot_H__
+#define _GSRoot_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgreLog.h>
+#include "core/RootGameState.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass
+    {
+        friend class ClassIdentifier<GSRoot>;
+    public:
+        GSRoot();
+        ~GSRoot();
+
+        void exitGame()
+        { requestState("root"); }
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        void setConfigValues();
+        void setThreadAffinity(unsigned int limitToCPU);
+
+        Settings*             settings_;
+        TclBind*              tclBind_;
+        TclThreadManager*     tclThreadManager_;
+        Shell*                shell_;
+    };
+}
+
+#endif /* _GSRoot_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSServer.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSServer.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSServer.cc	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSServer.h"
+
+#include "core/CommandLine.h"
+#include "core/Core.h"
+#include "network/Server.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
+
+    GSServer::GSServer()
+        : GameState<GSGraphics>("server")
+        , server_(0)
+    {
+    }
+
+    GSServer::~GSServer()
+    {
+    }
+
+    void GSServer::enter()
+    {
+        Core::setHasServer(true);
+
+        this->server_ = new network::Server(CommandLine::getValue("port"));
+        COUT(0) << "Loading scene in server mode" << std::endl;
+
+        GSLevel::enter(this->getParent()->getViewport());
+
+        server_->open();
+    }
+
+    void GSServer::leave()
+    {
+        GSLevel::leave();
+
+        this->server_->close();
+        delete this->server_;
+
+        Core::setHasServer(false);
+    }
+
+    void GSServer::ticked(const Clock& time)
+    {
+        GSLevel::ticked(time);
+        server_->tick(time.getDeltaTime());
+        this->tickChild(time);
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSServer.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSServer.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSServer.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSServer_H__
+#define _GSServer_H__
+
+#include "OrxonoxPrereqs.h"
+#include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
+    {
+    public:
+        GSServer();
+        ~GSServer();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        network::Server*      server_;
+    };
+}
+
+#endif /* _GSServer_H__ */
Index: /code/branches/physics/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSStandalone.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSStandalone.cc	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSStandalone.h"
+
+#include "core/Core.h"
+
+namespace orxonox
+{
+    GSStandalone::GSStandalone()
+        : GameState<GSGraphics>("standalone")
+    {
+    }
+
+    GSStandalone::~GSStandalone()
+    {
+    }
+
+    void GSStandalone::enter()
+    {
+        Core::setIsStandalone(true);
+
+        GSLevel::enter(this->getParent()->getViewport());
+    }
+
+    void GSStandalone::leave()
+    {
+        GSLevel::leave();
+
+        Core::setIsStandalone(false);
+    }
+
+    void GSStandalone::ticked(const Clock& time)
+    {
+        GSLevel::ticked(time);
+        this->tickChild(time);
+    }
+}
Index: /code/branches/physics/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- /code/branches/physics/src/orxonox/gamestates/GSStandalone.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gamestates/GSStandalone.h	(revision 2122)
@@ -0,0 +1,51 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSStandalone_H__
+#define _GSStandalone_H__
+
+#include "OrxonoxPrereqs.h"
+#include "GSLevel.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
+    {
+    public:
+        GSStandalone();
+        ~GSStandalone();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+    };
+}
+
+#endif /* _GSStandalone_H__ */
Index: /code/branches/physics/src/orxonox/gui/GUIManager.cc
===================================================================
--- /code/branches/physics/src/orxonox/gui/GUIManager.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/GUIManager.cc	(revision 2122)
@@ -0,0 +1,330 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief
+        Implementation of the GUIManager class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "GUIManager.h"
+
+#include <OgreRenderWindow.h>
+#include <OgreRoot.h>
+#include <CEGUI.h>
+#include "ceguilua/CEGUILua.h"
+#include "util/Exception.h"
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/tolua/tolua_bind.h"
+#include "core/ConsoleCommand.h"
+#include "core/Core.h"
+#include "tolua/tolua_bind.h"
+#include "OgreCEGUIRenderer.h"
+
+#include "lua/lua.hpp"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress);
+
+    GUIManager* GUIManager::singletonRef_s = 0;
+
+    GUIManager::GUIManager()
+        //: emptySceneManager_(0)
+        : backgroundSceneManager_(0)
+        //, emptyCamera_(0)
+        , backgroundCamera_(0)
+        //, viewport_(0)
+        , renderWindow_(0)
+        , guiRenderer_(0)
+        , resourceProvider_(0)
+        , scriptModule_(0)
+        , guiSystem_(0)
+        , state_(Uninitialised)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+    }
+
+    GUIManager::~GUIManager()
+    {
+        if (backgroundCamera_)
+            backgroundSceneManager_->destroyCamera(backgroundCamera_);
+
+        if (backgroundSceneManager_)
+        {
+            // We have to make sure the SceneManager is not anymore referenced.
+            // For the case that the target SceneManager was yet another one, it
+            // wouldn't matter anyway since this is the destructor.
+            guiRenderer_->setTargetSceneManager(0);
+            Ogre::Root::getSingleton().destroySceneManager(backgroundSceneManager_);
+        }
+
+        InputManager::getInstance().requestDestroyState("gui");
+
+        if (guiSystem_)
+            delete guiSystem_;
+
+        if (scriptModule_)
+        {
+            // destroy our own tolua interfaces
+	        //lua_pushnil(luaState_);
+	        //lua_setglobal(luaState_, "Orxonox");
+	        //lua_pushnil(luaState_);
+	        //lua_setglobal(luaState_, "Core");
+            // TODO: deleting the script module fails an assertation.
+            // However there is not much we can do about it since it occurs too when
+            // we don't open Core or Orxonox. Might be a CEGUI issue.
+            // The memory leak is not a problem anyway..
+            //delete scriptModule_;
+        }
+
+        if (guiRenderer_)
+            delete guiRenderer_;
+
+        singletonRef_s = 0;
+    }
+
+    bool GUIManager::initialise(Ogre::RenderWindow* renderWindow)
+    {
+        using namespace CEGUI;
+        if (state_ == Uninitialised)
+        {
+            COUT(3) << "Initialising CEGUI." << std::endl;
+
+            try
+            {
+                // save the render window
+                renderWindow_ = renderWindow;
+
+                // Full screen viewport with Z order = 0 (top most). Don't yet feed a camera (so nothing gets rendered)
+                //this->viewport_ = renderWindow_->addViewport(0, 3);
+                //this->viewport_->setOverlaysEnabled(false);
+                //this->viewport_->setShadowsEnabled(false);
+                //this->viewport_->setSkiesEnabled(false);
+                //this->viewport_->setClearEveryFrame(false);
+
+                // Note: No SceneManager specified yet
+                this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_MAIN, true, 3000);
+                this->resourceProvider_ = guiRenderer_->createResourceProvider();
+                this->resourceProvider_->setDefaultResourceGroup("GUI");
+
+                // setup scripting
+                this->scriptModule_ = new LuaScriptModule();
+                this->luaState_ = this->scriptModule_->getLuaState();
+
+                // create the CEGUI system singleton
+                this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_);
+
+                // set the log level according to ours (translate by subtracting 1)
+                Logger::getSingleton().setLoggingLevel(
+                    (LoggingLevel)(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));
+
+                // do this after 'new CEGUI::Sytem' because that creates the lua state in the first place
+                tolua_Core_open(this->scriptModule_->getLuaState());
+                tolua_Orxonox_open(this->scriptModule_->getLuaState());
+
+                // register us as input handler
+                SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui", 30);
+                state->setHandler(this);
+                state->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
+
+                // load the background scene
+                loadScenes();
+                //CEGUI::KeyEventArgs e;
+                //e.codepoint
+            }
+            catch (CEGUI::Exception& ex)
+            {
+#if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6
+                throw GeneralException(ex.getMessage().c_str());
+#else
+                throw GeneralException(ex.getMessage().c_str(), ex.getLine(),
+                    ex.getFileName().c_str(), ex.getName().c_str());
+#endif
+            }
+
+            state_ = Ready;
+        }
+
+        return true;
+    }
+
+    void GUIManager::loadScenes()
+    {
+        // first of all, we need to have our own SceneManager for the GUI. The reason
+        // is that we might have multiple viewports when in play mode (e.g. the view of
+        // a camera fixed at the back of the ship). That forces us to create our own
+        // full screen viewport that is on top of all the others, but doesn't clear the
+        // port before rendering, so everything from the GUI gets on top eventually.
+        // But in order to realise that, we also need a SceneManager with an empty scene,
+        // because the SceneManager is responsible for the render queue.
+        //this->emptySceneManager_ = Ogre::Root::getSingleton()
+        //    .createSceneManager(Ogre::ST_GENERIC, "GUI/EmptySceneManager");
+
+        // we also need a camera or we won't see anything at all.
+        // The camera settings don't matter at all for an empty scene since the GUI
+        // gets rendered on top of the screen rather than into the scene.
+        //this->emptyCamera_ = this->emptySceneManager_->createCamera("GUI/EmptyCamera");
+
+        // Create another SceneManager that enables to display some 3D
+        // scene in the background of the main menu.
+        this->backgroundSceneManager_ = Ogre::Root::getSingleton()
+            .createSceneManager(Ogre::ST_GENERIC, "GUI/BackgroundSceneManager");
+        this->backgroundCamera_ = backgroundSceneManager_->createCamera("GUI/BackgroundCamera");
+
+        // TODO: create something 3D
+        try
+        {
+            this->scriptModule_->executeScriptFile("loadGUI.lua", "GUI");
+        }
+        catch (CEGUI::Exception& ex)
+        {
+#if CEGUI_VERSION_MINOR < 6
+            throw GeneralException(ex.getMessage().c_str());
+#else
+            throw GeneralException(ex.getMessage().c_str(), ex.getLine(),
+                ex.getFileName().c_str(), ex.getName().c_str());
+#endif
+        }
+    }
+
+    void GUIManager::showGUI(const std::string& name, Ogre::SceneManager* sceneManager)// bool showBackground)
+    {
+        if (state_ != Uninitialised)
+        {
+            if (state_ == OnDisplay)
+                hideGUI();
+
+            COUT(3) << "Loading GUI " << name << std::endl;
+            try
+            {
+                if (!sceneManager)
+                {
+                    // currently, only an image is loaded. We could do 3D, see loadBackground.
+                    //this->viewport_->setClearEveryFrame(true);
+                    this->guiRenderer_->setTargetSceneManager(this->backgroundSceneManager_);
+                    //this->viewport_->setCamera(this->backgroundCamera_);
+
+                    lua_pushboolean(this->scriptModule_->getLuaState(), true);
+                    lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
+                }
+                else
+                {
+                    //this->viewport_->setClearEveryFrame(false);
+                    this->guiRenderer_->setTargetSceneManager(sceneManager);
+                    //this->viewport_->setCamera(this->emptyCamera_);
+
+                    lua_pushboolean(this->scriptModule_->getLuaState(), false);
+                    lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
+                }
+
+                this->scriptModule_->executeScriptGlobal("showMainMenu");
+
+                InputManager::getInstance().requestEnterState("gui");
+
+                this->state_ = OnDisplay;
+            }
+            catch (CEGUI::Exception& ex)
+            {
+                COUT(2) << "Error while executing lua script. Message:\n" << ex.getMessage() << std::endl;
+            }
+            catch (...)
+            {
+                COUT(2) << "Could show a menu due to unknown reasons." << std::endl;
+            }
+        }
+        else
+        {
+            COUT(2) << "Warning: GUI Manager not yet initialised, cannot load a GUI" << std::endl;
+        }
+    }
+
+    void GUIManager::hideGUI()
+    {
+        if (this->state_ != OnDisplay)
+            return;
+        //this->viewport_->setCamera(0);
+        this->guiRenderer_->setTargetSceneManager(0);
+        this->state_ = Ready;
+        InputManager::getInstance().requestLeaveState("gui");
+    }
+
+    void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id)
+    {
+        try
+        {
+            guiSystem_->injectMouseButtonDown(convertButton(id));
+        }
+        catch (CEGUI::ScriptException& ex)
+        {
+            // We simply ignore the exception and proceed
+            COUT(1) << ex.getMessage() << std::endl;
+        }
+    }
+
+    void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id)
+    {
+        try
+        {
+            guiSystem_->injectMouseButtonUp(convertButton(id));
+        }
+        catch (CEGUI::ScriptException& ex)
+        {
+            // We simply ignore the exception and proceed
+            COUT(1) << ex.getMessage() << std::endl;
+        }
+    }
+
+
+    inline CEGUI::MouseButton GUIManager::convertButton(MouseButtonCode::ByEnum button)
+    {
+        switch (button)
+        {
+        case MouseButtonCode::Left:
+            return CEGUI::LeftButton;
+
+        case MouseButtonCode::Right:
+            return CEGUI::RightButton;
+
+        case MouseButtonCode::Middle:
+            return CEGUI::MiddleButton;
+
+        case MouseButtonCode::Button3:
+            return CEGUI::X1Button;
+
+        case MouseButtonCode::Button4:
+            return CEGUI::X2Button;
+
+        default:
+            return CEGUI::NoButton;
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/gui/GUIManager.h
===================================================================
--- /code/branches/physics/src/orxonox/gui/GUIManager.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/GUIManager.h	(revision 2122)
@@ -0,0 +1,131 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Declaration of the GUIManager class.
+*/
+
+#ifndef _GUIManager_H__
+#define _GUIManager_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <CEGUIForwardRefs.h>
+#include <CEGUIInputEvent.h>
+#include <CEGUISystem.h>
+#include "core/input/InputInterfaces.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+    /**
+    @brief
+        Provides a simple interface to CEGUI with tolua methods and console commands
+    */
+    class _OrxonoxExport GUIManager : public KeyHandler, public MouseHandler
+    /*
+    class GUIManager { // tolua_export
+    */
+    {
+    public:
+        enum State
+        {
+            Uninitialised,
+            Ready,
+            OnDisplay
+        };
+
+        GUIManager();
+        ~GUIManager();
+
+        bool initialise(Ogre::RenderWindow* renderWindow);
+        void tick(float dt)
+        {
+            assert(guiSystem_);
+            guiSystem_->injectTimePulse(dt);
+        }
+        void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export
+        void hideGUI(); // tolua_export
+
+        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
+
+        static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
+        {
+            getInstance().showGUI(name, sceneManager);
+        }
+
+        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
+        static GUIManager* getInstancePtr() { return singletonRef_s; }
+
+    private:
+        GUIManager(const GUIManager& instance);
+
+        void keyPressed (const KeyEvent& evt)
+        { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
+        void keyReleased(const KeyEvent& evt)
+        { guiSystem_->injectKeyUp(evt.key); }
+        void keyHeld    (const KeyEvent& evt)
+        { }
+
+        void mouseButtonPressed (MouseButtonCode::ByEnum id);
+        void mouseButtonReleased(MouseButtonCode::ByEnum id);
+        void mouseButtonHeld    (MouseButtonCode::ByEnum id)
+        { }
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
+        { guiSystem_->injectMouseMove(rel.x, rel.y); }
+        void mouseScrolled      (int abs, int rel)
+        { guiSystem_->injectMouseWheelChange(rel);}
+
+        void tickInput(float dt) { }
+        void tickKey(float dt) { }
+        void tickMouse(float dt) { }
+
+        void loadScenes();
+
+        //Ogre::SceneManager*       emptySceneManager_;
+        Ogre::SceneManager*       backgroundSceneManager_;
+        //Ogre::Camera*             emptyCamera_;
+        Ogre::Camera*             backgroundCamera_;
+        //Ogre::Viewport*           viewport_;
+        Ogre::RenderWindow*       renderWindow_;
+        CEGUI::OgreCEGUIRenderer* guiRenderer_;
+        CEGUI::ResourceProvider*  resourceProvider_;
+        CEGUI::LuaScriptModule*   scriptModule_;
+        CEGUI::System*            guiSystem_;
+        CEGUI::Imageset*          backgroundImage_;
+        lua_State*                luaState_;
+
+        State state_;
+
+        static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
+
+        static GUIManager*        singletonRef_s;
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _GUIManager_H__ */
Index: /code/branches/physics/src/orxonox/gui/OgreCEGUIRenderer.cpp
===================================================================
--- /code/branches/physics/src/orxonox/gui/OgreCEGUIRenderer.cpp	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/OgreCEGUIRenderer.cpp	(revision 2122)
@@ -0,0 +1,803 @@
+/************************************************************************
+    filename: 	OgreCEGUIRenderer.cpp
+    created:	11/5/2004
+    author:		Paul D Turner
+    
+    purpose:	Implementation of Renderer class for Ogre engine
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+
+#include "OrxonoxStableHeaders.h"
+#include <CEGUIImagesetManager.h>
+#include <CEGUIImageset.h>
+#include <CEGUIImage.h>
+#include <CEGUIExceptions.h>
+#include <CEGUISystem.h>
+
+#include "OgreCEGUIRenderer.h"
+#include "OgreCEGUITexture.h"
+#include "OgreCEGUIResourceProvider.h"
+
+#include <OgreRenderSystem.h>
+#include <OgreRoot.h>
+#include <OgreHardwareBufferManager.h>
+#include <OgreRenderWindow.h>
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*************************************************************************
+    Constants definitions
+*************************************************************************/
+const size_t	OgreCEGUIRenderer::VERTEX_PER_QUAD			= 6;
+const size_t	OgreCEGUIRenderer::VERTEX_PER_TRIANGLE		= 3;
+const size_t	OgreCEGUIRenderer::VERTEXBUFFER_INITIAL_CAPACITY	= 256;
+const size_t    OgreCEGUIRenderer::UNDERUSED_FRAME_THRESHOLD = 50000; // halfs buffer every 8 minutes on 100fps
+
+/*************************************************************************
+    Utility function to create a render operation and vertex buffer to render quads
+*************************************************************************/
+static void createQuadRenderOp(Ogre::RenderOperation &d_render_op, 
+    Ogre::HardwareVertexBufferSharedPtr &d_buffer, size_t nquads)
+{
+    using namespace Ogre;
+    // Create and initialise the Ogre specific parts required for use in rendering later.
+    d_render_op.vertexData = new VertexData;
+    d_render_op.vertexData->vertexStart = 0;
+
+    // setup vertex declaration for the vertex format we use
+    VertexDeclaration* vd = d_render_op.vertexData->vertexDeclaration;
+    size_t vd_offset = 0;
+    vd->addElement(0, vd_offset, VET_FLOAT3, VES_POSITION);
+    vd_offset += VertexElement::getTypeSize(VET_FLOAT3);
+    vd->addElement(0, vd_offset, VET_COLOUR, VES_DIFFUSE);
+    vd_offset += VertexElement::getTypeSize(VET_COLOUR);
+    vd->addElement(0, vd_offset, VET_FLOAT2, VES_TEXTURE_COORDINATES);
+
+    // create hardware vertex buffer
+    d_buffer = HardwareBufferManager::getSingleton().createVertexBuffer(vd->getVertexSize(0), nquads,  
+        HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE, false);
+
+    // bind vertex buffer
+    d_render_op.vertexData->vertexBufferBinding->setBinding(0, d_buffer);
+
+    // complete render operation basic initialisation
+    d_render_op.operationType = RenderOperation::OT_TRIANGLE_LIST;
+    d_render_op.useIndexes = false;
+}
+
+static void destroyQuadRenderOp(Ogre::RenderOperation &d_render_op, 
+    Ogre::HardwareVertexBufferSharedPtr &d_buffer)
+{
+    delete d_render_op.vertexData;
+    d_render_op.vertexData = 0;
+    d_buffer.setNull();
+}
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+OgreCEGUIRenderer::OgreCEGUIRenderer(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads)
+{
+    constructor_impl(window, queue_id, post_queue, max_quads);
+}
+
+
+/*************************************************************************
+    Constructor (specifying scene manager)
+*************************************************************************/
+OgreCEGUIRenderer::OgreCEGUIRenderer(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads, Ogre::SceneManager* scene_manager)
+{
+    constructor_impl(window, queue_id, post_queue, max_quads);
+
+    // hook into ogre rendering system
+    setTargetSceneManager(scene_manager);
+}
+
+
+/*************************************************************************
+    Destructor
+*************************************************************************/
+OgreCEGUIRenderer::~OgreCEGUIRenderer(void)
+{
+    setTargetSceneManager(NULL);
+
+    if (d_ourlistener)
+    {
+        delete d_ourlistener;
+    }
+
+    // cleanup vertex data we allocated in constructor
+    destroyQuadRenderOp(d_render_op, d_buffer);
+    destroyQuadRenderOp(d_direct_render_op, d_direct_buffer);
+
+    destroyAllTextures();
+}
+
+
+/*************************************************************************
+    add's a quad to the list to be rendered
+*************************************************************************/
+void OgreCEGUIRenderer::addQuad(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode)
+{
+    // if not queueing, render directly (as in, right now!). This is used for the mouse cursor.
+    if (!d_queueing)
+    {
+        renderQuadDirect(dest_rect, z, tex, texture_rect, colours, quad_split_mode);
+    }
+    else
+    {
+        d_sorted = false;
+        QuadInfo quad;
+        
+        // set quad position, flipping y co-ordinates, and applying appropriate texel origin offset
+        quad.position.d_left	= dest_rect.d_left;
+        quad.position.d_right	= dest_rect.d_right;
+        quad.position.d_top		= d_display_area.getHeight() - dest_rect.d_top;
+        quad.position.d_bottom	= d_display_area.getHeight() - dest_rect.d_bottom;
+        quad.position.offset(d_texelOffset);
+
+        // convert quad co-ordinates for a -1 to 1 co-ordinate system.
+        quad.position.d_left	/= (d_display_area.getWidth() * 0.5f);
+        quad.position.d_right	/= (d_display_area.getWidth() * 0.5f);
+        quad.position.d_top		/= (d_display_area.getHeight() * 0.5f);
+        quad.position.d_bottom	/= (d_display_area.getHeight() * 0.5f);
+        quad.position.offset(Point(-1.0f, -1.0f));
+
+        quad.z				= -1 + z;
+        quad.texture		= ((OgreCEGUITexture*)tex)->getOgreTexture();
+        quad.texPosition	= texture_rect;
+
+        // covert colours for ogre, note that top / bottom are switched.
+        quad.topLeftCol		= colourToOgre(colours.d_bottom_left);
+        quad.topRightCol	= colourToOgre(colours.d_bottom_right);
+        quad.bottomLeftCol	= colourToOgre(colours.d_top_left);
+        quad.bottomRightCol	= colourToOgre(colours.d_top_right);
+        
+        // set quad split mode
+        quad.splitMode = quad_split_mode;
+
+        d_quadlist.insert(quad);
+    }
+}
+
+
+
+/*************************************************************************
+perform final rendering for all queued renderable quads.
+*************************************************************************/
+void OgreCEGUIRenderer::doRender(void)
+{
+    // Render if overlays enabled and the quad list is not empty
+
+    // ORXONOX CHANGE: Even render when OverlaysEnabled is deactivated
+    // The reason is that we don't want the HUD to be shown in the viewport of the
+    // GUI (uses its own viewport to be able render on top of all viewports).
+    // But since we don't use overlays in the GUI, it doesn't matter.
+    // ORXONOX REVERT: Changes are not in place anymore, but might be in the future!
+    if (d_render_sys->_getViewport()->getOverlaysEnabled() && !d_quadlist.empty())
+    //if (!d_quadlist.empty())
+    {
+        /// Quad list needs to be sorted and thus the vertex buffer rebuilt. If not, we can
+        /// reuse the vertex buffer resulting in a nice speed gain.
+        if(!d_sorted)
+        {
+            sortQuads();
+            /// Resize vertex buffer if it is too small
+            size_t size = d_buffer->getNumVertices();
+            size_t requestedSize = d_quadlist.size()*VERTEX_PER_QUAD;
+            if(size < requestedSize)
+            {
+                /// Double buffer size until smaller than requested size
+                while(size < requestedSize)
+                    size = size * 2;
+                /// Reallocate the buffer
+                destroyQuadRenderOp(d_render_op, d_buffer);
+                createQuadRenderOp(d_render_op, d_buffer, size);
+            }
+            else if(requestedSize < size/2 && d_underused_framecount >= UNDERUSED_FRAME_THRESHOLD)
+            {
+                /// Resize vertex buffer if it has been to big for too long
+                size = size / 2;
+                destroyQuadRenderOp(d_render_op, d_buffer);
+                createQuadRenderOp(d_render_op, d_buffer, size);
+                /// Reset underused framecount so it takes another UNDERUSED_FRAME_THRESHOLD to half again
+                d_underused_framecount = 0;
+            }
+            /// Fill the buffer
+            QuadVertex*	buffmem;
+            buffmem = (QuadVertex*)d_buffer->lock(Ogre::HardwareVertexBuffer::HBL_DISCARD);
+            // iterate over each quad in the list
+            for (QuadList::iterator i = d_quadlist.begin(); i != d_quadlist.end(); ++i)
+            {
+                const QuadInfo& quad = (*i);
+                // setup Vertex 1...
+                buffmem->x = quad.position.d_left;
+                buffmem->y = quad.position.d_bottom;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.topLeftCol;
+                buffmem->tu1 = quad.texPosition.d_left;
+                buffmem->tv1 = quad.texPosition.d_bottom;
+                ++buffmem;
+    
+                // setup Vertex 2...
+                
+                // top-left to bottom-right diagonal
+                if (quad.splitMode == TopLeftToBottomRight)
+                {
+                    buffmem->x = quad.position.d_right;
+                    buffmem->y = quad.position.d_bottom;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.topRightCol;
+                    buffmem->tu1 = quad.texPosition.d_right;
+                    buffmem->tv1 = quad.texPosition.d_bottom;
+                }
+                // bottom-left to top-right diagonal
+                else
+                {
+                    buffmem->x = quad.position.d_right;
+                    buffmem->y = quad.position.d_top;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.bottomRightCol;
+                    buffmem->tu1 = quad.texPosition.d_right;
+                    buffmem->tv1 = quad.texPosition.d_top;
+                }
+                ++buffmem;
+    
+                // setup Vertex 3...
+                buffmem->x = quad.position.d_left;
+                buffmem->y = quad.position.d_top;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.bottomLeftCol;
+                buffmem->tu1 = quad.texPosition.d_left;
+                buffmem->tv1 = quad.texPosition.d_top;
+                ++buffmem;
+    
+                // setup Vertex 4...
+                buffmem->x = quad.position.d_right;
+                buffmem->y = quad.position.d_bottom;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.topRightCol;
+                buffmem->tu1 = quad.texPosition.d_right;
+                buffmem->tv1 = quad.texPosition.d_bottom;
+                ++buffmem;
+    
+                // setup Vertex 5...
+                buffmem->x = quad.position.d_right;
+                buffmem->y = quad.position.d_top;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.bottomRightCol;
+                buffmem->tu1 = quad.texPosition.d_right;
+                buffmem->tv1 = quad.texPosition.d_top;
+                ++buffmem;
+    
+                // setup Vertex 6...
+                
+                // top-left to bottom-right diagonal
+                if (quad.splitMode == TopLeftToBottomRight)
+                {
+                    buffmem->x = quad.position.d_left;
+                    buffmem->y = quad.position.d_top;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.bottomLeftCol;
+                    buffmem->tu1 = quad.texPosition.d_left;
+                    buffmem->tv1 = quad.texPosition.d_top;
+                }
+                // bottom-left to top-right diagonal
+                else
+                {
+                    buffmem->x = quad.position.d_left;
+                    buffmem->y = quad.position.d_bottom;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.topLeftCol;
+                    buffmem->tu1 = quad.texPosition.d_left;
+                    buffmem->tv1 = quad.texPosition.d_bottom;
+                }
+                ++buffmem;
+            }
+    
+            // ensure we leave the buffer in the unlocked state
+            d_buffer->unlock();
+        }
+        
+        /// Render the buffer
+        d_bufferPos = 0;
+        bool first = true;
+
+        // Iterate over each quad in the list and render it
+        QuadList::iterator i = d_quadlist.begin();
+        while(i != d_quadlist.end())
+        {
+            
+            d_currTexture = i->texture;
+            d_render_op.vertexData->vertexStart = d_bufferPos;
+            for (; i != d_quadlist.end(); ++i)
+            {
+                const QuadInfo& quad = (*i);
+                if (d_currTexture != quad.texture)
+                {
+                    /// If it has a different texture, render this quad in next operation
+                    /// also need to reset render states
+                    first = true;
+                    break;
+                }
+                d_bufferPos += VERTEX_PER_QUAD;
+            }
+            d_render_op.vertexData->vertexCount = d_bufferPos - d_render_op.vertexData->vertexStart;
+            /// Set texture, and do the render
+            d_render_sys->_setTexture(0, true, d_currTexture);
+            if (first)
+            {
+                initRenderStates();
+                first = false;
+            }
+            d_render_sys->_render(d_render_op);
+        }
+
+    }
+    /// Count frames to check if utilization of vertex buffer was below half the capacity for 500,000 frames
+    if(d_bufferPos < d_buffer->getNumVertices()/2)
+       d_underused_framecount++;
+    else
+       d_underused_framecount = 0;
+}
+
+
+/*************************************************************************
+    clear the queue
+*************************************************************************/
+void OgreCEGUIRenderer::clearRenderList(void)
+{
+    d_sorted = true;
+    d_quadlist.clear();
+}
+
+
+/*************************************************************************
+    create an empty texture
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(void)
+{
+    OgreCEGUITexture* tex = new OgreCEGUITexture(this);
+    d_texturelist.push_back(tex);
+    return tex;
+}
+
+
+/*************************************************************************
+    create a texture and load it with the specified file.
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(const String& filename, const String& resourceGroup)
+{
+    OgreCEGUITexture* tex = (OgreCEGUITexture*)createTexture();
+    tex->loadFromFile(filename, resourceGroup);
+
+    return tex;
+}
+
+
+/*************************************************************************
+    create a texture and set it to the specified size
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(float size)
+{
+    OgreCEGUITexture* tex = (OgreCEGUITexture*)createTexture();
+    tex->setOgreTextureSize((uint)size);
+
+    return tex;
+}
+
+
+/*************************************************************************
+    destroy the given texture
+*************************************************************************/
+void OgreCEGUIRenderer::destroyTexture(Texture* texture)
+{
+    if (texture != NULL)
+    {
+        OgreCEGUITexture* tex = (OgreCEGUITexture*)texture;
+
+        d_texturelist.remove(tex);
+        delete tex;
+    }
+}
+
+
+/*************************************************************************
+    destroy all textures still active
+*************************************************************************/
+void OgreCEGUIRenderer::destroyAllTextures(void)
+{
+    while (!d_texturelist.empty())
+    {
+        destroyTexture(*(d_texturelist.begin()));
+    }
+}
+
+
+/*************************************************************************
+    setup states etc	
+*************************************************************************/
+void OgreCEGUIRenderer::initRenderStates(void)
+{
+    using namespace Ogre;
+
+    // set-up matrices
+    d_render_sys->_setWorldMatrix(Matrix4::IDENTITY);
+    d_render_sys->_setViewMatrix(Matrix4::IDENTITY);
+    d_render_sys->_setProjectionMatrix(Matrix4::IDENTITY);
+
+    // initialise render settings
+    d_render_sys->setLightingEnabled(false);
+    d_render_sys->_setDepthBufferParams(false, false);
+    d_render_sys->_setDepthBias(0, 0);
+    d_render_sys->_setCullingMode(CULL_NONE);
+    d_render_sys->_setFog(FOG_NONE);
+    d_render_sys->_setColourBufferWriteEnabled(true, true, true, true);
+    d_render_sys->unbindGpuProgram(GPT_FRAGMENT_PROGRAM);
+    d_render_sys->unbindGpuProgram(GPT_VERTEX_PROGRAM);
+    d_render_sys->setShadingType(SO_GOURAUD);
+    d_render_sys->_setPolygonMode(PM_SOLID);
+
+    // initialise texture settings
+    d_render_sys->_setTextureCoordCalculation(0, TEXCALC_NONE);
+    d_render_sys->_setTextureCoordSet(0, 0);
+    d_render_sys->_setTextureUnitFiltering(0, FO_LINEAR, FO_LINEAR, FO_POINT);
+    d_render_sys->_setTextureAddressingMode(0, d_uvwAddressMode);
+    d_render_sys->_setTextureMatrix(0, Matrix4::IDENTITY);
+    d_render_sys->_setAlphaRejectSettings(CMPF_ALWAYS_PASS, 0);
+    d_render_sys->_setTextureBlendMode(0, d_colourBlendMode);
+    d_render_sys->_setTextureBlendMode(0, d_alphaBlendMode);
+    d_render_sys->_disableTextureUnitsFrom(1);
+
+    // enable alpha blending
+    d_render_sys->_setSceneBlending(SBF_SOURCE_ALPHA, SBF_ONE_MINUS_SOURCE_ALPHA);
+}
+
+
+ 
+/*************************************************************************
+    sort quads list according to texture	
+*************************************************************************/
+void OgreCEGUIRenderer::sortQuads(void)
+{
+    if (!d_sorted)
+    {
+        d_sorted = true;
+    }
+
+}
+
+/*************************************************************************
+render a quad directly to the display
+*************************************************************************/
+void OgreCEGUIRenderer::renderQuadDirect(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode)
+{
+    // ORXONOX CHANGE: Even render when OverlaysEnabled is deactivated
+    // The reason is that we don't want the HUD to be shown in the viewport of the
+    // GUI (uses its own viewport to be able render on top of all viewports).
+    // But since we don't use overlays in the GUI, it doesn't matter.
+    // ORXONOX REVERT: Changes are not in place anymore, but might be in the future!
+    if (d_render_sys->_getViewport()->getOverlaysEnabled())
+    //if (true)
+    {
+        z = -1 + z;
+
+        Rect final_rect;
+
+        // set quad position, flipping y co-ordinates, and applying appropriate texel origin offset
+        final_rect.d_left	= dest_rect.d_left;
+        final_rect.d_right	= dest_rect.d_right;
+        final_rect.d_top	= d_display_area.getHeight() - dest_rect.d_top;
+        final_rect.d_bottom	= d_display_area.getHeight() - dest_rect.d_bottom;
+        final_rect.offset(d_texelOffset);
+
+        // convert quad co-ordinates for a -1 to 1 co-ordinate system.
+        final_rect.d_left	/= (d_display_area.getWidth() * 0.5f);
+        final_rect.d_right	/= (d_display_area.getWidth() * 0.5f);
+        final_rect.d_top	/= (d_display_area.getHeight() * 0.5f);
+        final_rect.d_bottom	/= (d_display_area.getHeight() * 0.5f);
+        final_rect.offset(Point(-1.0f, -1.0f));
+
+        // convert colours for ogre, note that top / bottom are switched.
+        uint32 topLeftCol	= colourToOgre(colours.d_bottom_left);
+        uint32 topRightCol	= colourToOgre(colours.d_bottom_right);
+        uint32 bottomLeftCol	= colourToOgre(colours.d_top_left);
+        uint32 bottomRightCol= colourToOgre(colours.d_top_right);
+
+        QuadVertex*	buffmem = (QuadVertex*)d_direct_buffer->lock(Ogre::HardwareVertexBuffer::HBL_DISCARD);
+
+        // setup Vertex 1...
+        buffmem->x	= final_rect.d_left;
+        buffmem->y	= final_rect. d_bottom;
+        buffmem->z	= z;
+        buffmem->diffuse = topLeftCol;
+        buffmem->tu1	= texture_rect.d_left;
+        buffmem->tv1	= texture_rect.d_bottom;
+        ++buffmem;
+
+        // setup Vertex 2...
+        
+        // top-left to bottom-right diagonal
+        if (quad_split_mode == TopLeftToBottomRight)
+        {
+            buffmem->x	= final_rect.d_right;
+            buffmem->y = final_rect.d_bottom;
+            buffmem->z	= z;
+            buffmem->diffuse = topRightCol;
+            buffmem->tu1	= texture_rect.d_right;
+            buffmem->tv1	= texture_rect.d_bottom;
+            ++buffmem;
+        }
+        // bottom-left to top-right diagonal
+        else
+        {
+            buffmem->x	= final_rect.d_right;
+            buffmem->y = final_rect.d_top;
+            buffmem->z	= z;
+            buffmem->diffuse = bottomRightCol;
+            buffmem->tu1	= texture_rect.d_right;
+            buffmem->tv1	= texture_rect.d_top;
+            ++buffmem;
+        }
+
+        // setup Vertex 3...
+        buffmem->x	= final_rect.d_left;
+        buffmem->y	= final_rect.d_top;
+        buffmem->z	= z;
+        buffmem->diffuse = bottomLeftCol;
+        buffmem->tu1	= texture_rect.d_left;
+        buffmem->tv1	= texture_rect.d_top;
+        ++buffmem;
+
+        // setup Vertex 4...
+        buffmem->x	= final_rect.d_right;
+        buffmem->y	= final_rect.d_bottom;
+        buffmem->z	= z;
+        buffmem->diffuse = topRightCol;
+        buffmem->tu1	= texture_rect.d_right;
+        buffmem->tv1	= texture_rect.d_bottom;
+        ++buffmem;
+
+        // setup Vertex 5...
+        buffmem->x	= final_rect.d_right;
+        buffmem->y	= final_rect.d_top;
+        buffmem->z	= z;
+        buffmem->diffuse = bottomRightCol;
+        buffmem->tu1	= texture_rect.d_right;
+        buffmem->tv1	= texture_rect.d_top;
+        ++buffmem;
+
+        // setup Vertex 6...
+        
+        // top-left to bottom-right diagonal
+        if (quad_split_mode == TopLeftToBottomRight)
+        {
+            buffmem->x	= final_rect.d_left;
+            buffmem->y = final_rect.d_top;
+            buffmem->z	= z;
+            buffmem->diffuse = bottomLeftCol;
+            buffmem->tu1	= texture_rect.d_left;
+            buffmem->tv1	= texture_rect.d_top;
+        }
+        // bottom-left to top-right diagonal
+        else
+        {
+            buffmem->x	= final_rect.d_left;
+            buffmem->y = final_rect.d_bottom;
+            buffmem->z	= z;
+            buffmem->diffuse = topLeftCol;
+            buffmem->tu1	= texture_rect.d_left;
+            buffmem->tv1	= texture_rect.d_bottom;
+        }
+
+        d_direct_buffer->unlock();
+
+        //
+        // perform rendering...
+        //
+        d_render_sys->_setTexture(0, true, ((OgreCEGUITexture*)tex)->getOgreTexture()->getName());
+        initRenderStates();
+        d_direct_render_op.vertexData->vertexCount = VERTEX_PER_QUAD;
+        d_render_sys->_render(d_direct_render_op);
+    }
+
+}
+
+/*************************************************************************
+    convert ARGB colour value to whatever the Ogre render system is
+    expecting.	
+*************************************************************************/
+uint32 OgreCEGUIRenderer::colourToOgre(const colour& col) const
+{
+    Ogre::ColourValue cv(col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
+
+    uint32 final;
+    d_render_sys->convertColourValue(cv, &final);
+
+    return final;
+}
+
+
+/*************************************************************************
+    Set the scene manager to be used for rendering the GUI.	
+*************************************************************************/
+void OgreCEGUIRenderer::setTargetSceneManager(Ogre::SceneManager* scene_manager)
+{
+    // unhook from current scene manager.
+    if (d_sceneMngr != NULL)
+    {
+        d_sceneMngr->removeRenderQueueListener(d_ourlistener);
+        d_sceneMngr = NULL;
+    }
+
+    // hook new scene manager if that is not NULL
+    if (scene_manager != NULL)
+    {
+        d_sceneMngr = scene_manager;
+        d_sceneMngr->addRenderQueueListener(d_ourlistener);
+    }
+
+}
+
+
+/*************************************************************************
+    Set the target render queue for GUI rendering.	
+*************************************************************************/
+void OgreCEGUIRenderer::setTargetRenderQueue(Ogre::uint8 queue_id, bool post_queue)
+{
+    d_queue_id		= queue_id;
+    d_post_queue	= post_queue;
+
+    if (d_ourlistener != NULL)
+    {
+        d_ourlistener->setTargetRenderQueue(queue_id);
+        d_ourlistener->setPostRenderQueue(post_queue);
+    }
+
+}
+
+
+/*************************************************************************
+    perform main work of the constructor
+*************************************************************************/
+void OgreCEGUIRenderer::constructor_impl(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads)
+{
+    using namespace Ogre;
+
+    // initialise the renderer fields
+    d_queueing		= true;
+    d_queue_id		= queue_id;
+    d_currTexture.isNull();
+    d_post_queue	= post_queue;
+    d_sceneMngr		= NULL;
+    d_bufferPos		= 0;
+    d_sorted		= true;
+    d_ogre_root		= Root::getSingletonPtr();
+    d_render_sys	= d_ogre_root->getRenderSystem();
+    // set ID string
+    d_identifierString = "CEGUI::OgreRenderer - Official Ogre based renderer module for CEGUI";
+
+    // Create and initialise the Ogre specific parts required for use in rendering later.
+    // Main GUI
+    createQuadRenderOp(d_render_op, d_buffer, VERTEXBUFFER_INITIAL_CAPACITY);
+    d_underused_framecount = 0;
+
+    // Mouse cursor
+    createQuadRenderOp(d_direct_render_op, d_direct_buffer, VERTEX_PER_QUAD);
+
+    // Discover display settings and setup d_display_area
+    d_display_area.d_left	= 0;
+    d_display_area.d_top	= 0;
+    d_display_area.d_right	= window->getWidth();
+    d_display_area.d_bottom	= window->getHeight();
+
+    // initialise required texel offset
+    d_texelOffset = Point((float)d_render_sys->getHorizontalTexelOffset(), -(float)d_render_sys->getVerticalTexelOffset());
+
+    // create listener which will handler the rendering side of things for us.
+    d_ourlistener = new CEGUIRQListener(this, queue_id, post_queue);
+
+    // Initialise blending modes to be used.
+    d_colourBlendMode.blendType	= Ogre::LBT_COLOUR;
+    d_colourBlendMode.source1	= Ogre::LBS_TEXTURE;
+    d_colourBlendMode.source2	= Ogre::LBS_DIFFUSE;
+    d_colourBlendMode.operation	= Ogre::LBX_MODULATE;
+
+    d_alphaBlendMode.blendType	= Ogre::LBT_ALPHA;
+    d_alphaBlendMode.source1	= Ogre::LBS_TEXTURE;
+    d_alphaBlendMode.source2	= Ogre::LBS_DIFFUSE;
+    d_alphaBlendMode.operation	= Ogre::LBX_MODULATE;
+
+    d_uvwAddressMode.u = Ogre::TextureUnitState::TAM_CLAMP;
+    d_uvwAddressMode.v = Ogre::TextureUnitState::TAM_CLAMP;
+    d_uvwAddressMode.w = Ogre::TextureUnitState::TAM_CLAMP;
+}
+
+
+/*************************************************************************
+    Create a texture from an existing Ogre::TexturePtr object	
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(Ogre::TexturePtr& texture)
+{
+    OgreCEGUITexture* t = (OgreCEGUITexture*)createTexture();
+
+    if (!texture.isNull())
+    {
+        t->setOgreTexture(texture);
+    }
+
+    return t;
+
+}
+
+/*************************************************************************
+    Create a resource provider object
+*************************************************************************/
+ResourceProvider* OgreCEGUIRenderer::createResourceProvider(void)
+{
+    d_resourceProvider = new OgreCEGUIResourceProvider();
+    return d_resourceProvider;
+}
+
+/*************************************************************************
+Set the size of the display in pixels.	
+*************************************************************************/
+void OgreCEGUIRenderer::setDisplaySize(const Size& sz)
+{
+    if (d_display_area.getSize() != sz)
+    {
+        d_display_area.setSize(sz);
+
+        EventArgs args;
+        fireEvent(EventDisplaySizeChanged, args, EventNamespace);
+    }
+
+}
+
+/*************************************************************************
+    Callback from Ogre invoked before other stuff in our target queue
+    is rendered
+*************************************************************************/
+void CEGUIRQListener::renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, 
+                                         bool& skipThisQueue)
+{
+    if ((!d_post_queue) && (d_queue_id == id))
+    {
+        CEGUI::System::getSingleton().renderGUI();
+    }
+
+}
+
+
+/*************************************************************************
+Callback from Ogre invoked after other stuff in our target queue
+is rendered
+*************************************************************************/
+void CEGUIRQListener::renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& repeatThisQueue)
+{
+    if ((d_post_queue) && (d_queue_id == id))
+    {
+        CEGUI::System::getSingleton().renderGUI();
+    }
+
+}
+
+} // End of  CEGUI namespace section
Index: /code/branches/physics/src/orxonox/gui/OgreCEGUIRenderer.h
===================================================================
--- /code/branches/physics/src/orxonox/gui/OgreCEGUIRenderer.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/OgreCEGUIRenderer.h	(revision 2122)
@@ -0,0 +1,465 @@
+/************************************************************************
+    filename: 	OgreCEGUIRenderer.h
+    created:	11/5/2004
+    author:		Paul D Turner
+
+    purpose:	Interface for main Ogre GUI renderer class
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+/*************************************************************************
+    This file contains code that is specific to Ogre (http://www.ogre3d.org)
+*************************************************************************/
+#ifndef _OgreCEGUIRenderer_H__
+#define _OgreCEGUIRenderer_H__
+
+#include <CEGUIBase.h>
+#include <CEGUIRenderer.h>
+#include <CEGUITexture.h>
+
+#include <OgreRenderQueueListener.h>
+#include <OgreSceneManagerEnumerator.h>
+#include <OgreTextureUnitState.h>
+
+/** CHANGES MADE BY ORXONOX TO FIT DLL IMPORT/EXPORT **/
+#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !(defined(ORXONOX_STATIC_BUILD) || defined(ORXONOX_NO_EXPORTS))
+#   ifdef ORXONOX_SHARED_BUILD
+#       define OGRE_GUIRENDERER_API __declspec(dllexport)
+#   else
+#       if defined(__MINGW32__)
+#           define OGRE_GUIRENDERER_API
+#       else
+#           define OGRE_GUIRENDERER_API __declspec(dllimport)
+#       endif
+#   endif
+#elif defined ( OGRE_GCC_VISIBILITY )
+#    define OGRE_GUIRENDERER_API  __attribute__ ((visibility("default")))
+#else
+#    define OGRE_GUIRENDERER_API
+#endif
+
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*************************************************************************
+    Forward refs
+*************************************************************************/
+class OgreCEGUITexture;
+class OgreCEGUIRenderer;
+
+
+/*!
+\brief
+    RenderQueueListener based class used to hook into the ogre rendering system
+*/
+class _OgrePrivate CEGUIRQListener : public Ogre::RenderQueueListener
+{
+public:
+    CEGUIRQListener(OgreCEGUIRenderer* renderer, Ogre::uint8 queue_id, bool post_queue)
+    {
+        d_renderer		= renderer;
+        d_queue_id		= queue_id;
+        d_post_queue	= post_queue;
+    }
+
+    virtual ~CEGUIRQListener() {}
+
+    virtual void	renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue);
+    virtual void	renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& repeatThisQueue);
+
+    // methods for adjusting target queue settings
+    void	setTargetRenderQueue(Ogre::uint8 queue_id)		{d_queue_id = queue_id;}
+    void	setPostRenderQueue(bool post_queue)		{d_post_queue = post_queue;}
+
+private:
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    OgreCEGUIRenderer*				d_renderer;		//!< CEGUI renderer object for Ogre.
+    Ogre::uint8	d_queue_id;		//!< ID of the queue that we are hooked into
+    bool						d_post_queue;	//!< true if we render after everything else in our queue.
+};
+
+
+/*!
+\brief
+    Renderer class to interface with Ogre engine.
+*/
+class OGRE_GUIRENDERER_API OgreCEGUIRenderer : public Renderer
+{
+public:
+    /*!
+    \brief
+        Constructor for renderer class that uses Ogre for rendering. Note that if
+        you use this option you must call setTargetSceneManager before rendering.
+
+    \param window
+        Pointer to an Ogre::RenderWindow object.
+
+    \param queue_id
+        Ogre::uint8 value that specifies where the GUI should appear in the ogre rendering output.
+
+    \param post_queue
+        set to true to have GUI rendered after render queue \a queue_id, or false to have the GUI rendered before render queue
+        \a queue_id.
+
+    \param max_quads
+        Obsolete.  Set to 0.
+
+    */
+    OgreCEGUIRenderer(Ogre::RenderWindow* window,
+        Ogre::uint8 queue_id = Ogre::RENDER_QUEUE_OVERLAY,
+        bool post_queue = false, uint max_quads = 0);
+
+
+    /*!
+    \brief
+        Constructor for renderer class that uses Ogre for rendering.
+
+    \param window
+        Pointer to an Ogre::RenderWindow object.
+
+    \param queue_id
+        Ogre::uint8 value that specifies where the GUI should appear in the ogre rendering output.
+
+    \param post_queue
+        set to true to have GUI rendered after render queue \a queue_id, or false to have the GUI rendered before render queue
+        \a queue_id.
+
+    \param max_quads
+        Obsolete.  Set to 0.
+
+    \param scene_manager
+        Pointer to an Ogre::SceneManager object that is to be used for GUI rendering.
+    */
+    OgreCEGUIRenderer(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads, Ogre::SceneManager* scene_manager);
+
+
+    /*!
+    \brief
+        Destructor for Ogre renderer.
+    */
+    virtual ~OgreCEGUIRenderer(void);
+
+
+
+    // add's a quad to the list to be rendered
+    virtual	void	addQuad(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
+
+    // perform final rendering for all queued renderable quads.
+    virtual	void	doRender(void);
+
+    // clear the queue
+    virtual	void	clearRenderList(void);
+
+
+    /*!
+    \brief
+        Enable or disable the queueing of quads from this point on.
+
+        This only affects queueing.  If queueing is turned off, any calls to addQuad will cause the quad to be rendered directly.  Note that
+        disabling queueing will not cause currently queued quads to be rendered, nor is the queue cleared - at any time the queue can still
+        be drawn by calling doRender, and the list can be cleared by calling clearRenderList.  Re-enabling the queue causes subsequent quads
+        to be added as if queueing had never been disabled.
+
+    \param setting
+        true to enable queueing, or false to disable queueing (see notes above).
+
+    \return
+        Nothing
+    */
+    virtual void	setQueueingEnabled(bool setting)		{d_queueing = setting;}
+
+
+    // create an empty texture
+    virtual	Texture*	createTexture(void);
+
+    // create a texture and load it with the specified file.
+    virtual	Texture*	createTexture(const String& filename, const String& resourceGroup = "General");
+
+    // create a texture and set it to the specified size
+    virtual	Texture*	createTexture(float size);
+
+    // create an OGRE resource provider.
+    virtual ResourceProvider* createResourceProvider(void);
+
+    // destroy the given texture
+    virtual	void		destroyTexture(Texture* texture);
+
+    // destroy all textures still active
+    virtual void		destroyAllTextures(void);
+
+
+    /*!
+    \brief
+        Return whether queueing is enabled.
+
+    \return
+        true if queueing is enabled, false if queueing is disabled.
+    */
+    virtual bool	isQueueingEnabled(void) const	{return d_queueing;}
+
+
+    /*!
+    \brief
+    Return the current width of the display in pixels
+
+    \return
+    float value equal to the current width of the display in pixels.
+    */
+    virtual float	getWidth(void) const		{return d_display_area.getWidth();}
+
+
+    /*!
+    \brief
+    Return the current height of the display in pixels
+
+    \return
+    float value equal to the current height of the display in pixels.
+    */
+    virtual float	getHeight(void) const		{return d_display_area.getHeight();}
+
+
+    /*!
+    \brief
+    Return the size of the display in pixels
+
+    \return
+    Size object describing the dimensions of the current display.
+    */
+    virtual Size	getSize(void) const			{return d_display_area.getSize();}
+
+
+    /*!
+    \brief
+    Return a Rect describing the screen
+
+    \return
+    A Rect object that describes the screen area.  Typically, the top-left values are always 0, and the size of the area described is
+    equal to the screen resolution.
+    */
+    virtual Rect	getRect(void) const			{return d_display_area;}
+
+
+    /*!
+    \brief
+        Return the maximum texture size available
+
+    \return
+        Size of the maximum supported texture in pixels (textures are always assumed to be square)
+    */
+    virtual	uint	getMaxTextureSize(void) const		{return 2048;}		// TODO: Change to proper value
+
+
+    /*!
+    \brief
+        Return the horizontal display resolution dpi
+
+    \return
+        horizontal resolution of the display in dpi.
+    */
+    virtual	uint	getHorzScreenDPI(void) const	{return 96;}
+
+
+    /*!
+    \brief
+        Return the vertical display resolution dpi
+
+    \return
+        vertical resolution of the display in dpi.
+    */
+    virtual	uint	getVertScreenDPI(void) const	{return 96;}
+
+
+    /*!
+    \brief
+        Set the scene manager to be used for rendering the GUI.
+
+        The GUI system will be unhooked from the current scene manager and attached to what ever
+        is specified here.
+
+    \param scene_manager
+        Pointer to an Ogre::SceneManager object that is the new target Ogre::SceneManager to be
+        used for GUI rendering.
+
+    \return
+        Nothing.
+    */
+    void	setTargetSceneManager(Ogre::SceneManager* scene_manager);
+
+
+    /*!
+    \brief
+        Set the target render queue for GUI rendering.
+
+    \param queue_id
+        Ogre::uint8 value specifying the render queue that the GUI system should attach to.
+
+    \param post_queue
+        - true to specify that the GUI should render after everything else in render queue \a queue_id.
+        - false to specify the GUI should render before everything else in render queue \a queue_id.
+
+    \return
+        Nothing.
+    */
+    void	setTargetRenderQueue(Ogre::uint8 queue_id, bool post_queue);
+
+
+    /*!
+    \brief
+        Create a texture from an existing Ogre::TexturePtr object.
+
+    \note
+        If you want to use an Ogre::RenderTexture (for putting rendered output onto Gui elements or other
+        advanced techniques), you can get the Ogre::TexturePtr to be used by calling Ogre::TextureManager::getByName()
+        passing the name returned from Ogre::RenderTexture::getName() (and casting the result as necessary).
+
+    \param texture
+        pointer to an Ogre::TexturePtr object to be used as the basis for the new CEGUI::Texture
+
+    \return
+        Pointer to the newly created CEGUI::TexturePtr object.
+    */
+    Texture*	createTexture(Ogre::TexturePtr& texture);
+
+
+    /*!
+    \brief
+    Set the size of the display in pixels.
+
+    You do not have to call this method under normal operation as the system
+    will automatically extract the size from the current view port.
+
+    \note
+    This method will cause the EventDisplaySizeChanged event to fire if the
+    display size has changed.
+
+    \param sz
+    Size object describing the size of the display.
+
+    \return
+    Nothing.
+    */
+    void	setDisplaySize(const Size& sz);
+
+
+private:
+    /************************************************************************
+        Implementation Constants
+    ************************************************************************/
+    static const size_t    VERTEX_PER_QUAD;						 //!< number of vertices per quad
+    static const size_t    VERTEX_PER_TRIANGLE;					 //!< number of vertices for a triangle
+    static const size_t    VERTEXBUFFER_INITIAL_CAPACITY;		 //!< initial capacity of the allocated vertex buffer
+    static const size_t    UNDERUSED_FRAME_THRESHOLD;            //!< number of frames to wait before shrinking buffer
+
+    /*************************************************************************
+        Implementation Structs & classes
+    *************************************************************************/
+    /*!
+    \brief
+        structure used for all vertices.
+    */
+    struct QuadVertex {
+        float x, y, z;			//!< The position for the vertex.
+        Ogre::RGBA diffuse;		//!< colour of the vertex
+        float tu1, tv1;			//!< texture coordinates
+    };
+
+    /*!
+    \brief
+        structure holding details about a quad to be drawn
+    */
+    struct QuadInfo
+    {
+        Ogre::TexturePtr		texture;
+        Rect				position;
+        float				z;
+        Rect				texPosition;
+        uint32		        topLeftCol;
+        uint32		        topRightCol;
+        uint32		        bottomLeftCol;
+        uint32		        bottomRightCol;
+
+        QuadSplitMode		splitMode;
+
+        bool operator<(const QuadInfo& other) const
+        {
+            // this is intentionally reversed.
+            return z > other.z;
+        }
+    };
+
+
+    /*************************************************************************
+        Implementation Methods
+    *************************************************************************/
+    // setup states etc
+    void	initRenderStates(void);
+
+    // sort quads list according to texture
+    void	sortQuads(void);
+
+    // render a quad directly to the display
+    void	renderQuadDirect(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
+
+    // convert colour value to whatever the Ogre render system is expecting.
+    uint32    colourToOgre(const colour& col) const;
+
+    // perform main work of the constructor.  This does everything except the final hook into the render system.
+    void	constructor_impl(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads);
+
+
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    Rect				d_display_area;
+
+    typedef std::multiset<QuadInfo>		QuadList;
+    QuadList d_quadlist;
+    bool	 d_queueing;		//!< setting for queueing control.
+
+    // Ogre specific bits.
+    Ogre::Root*					d_ogre_root;		//!< pointer to the Ogre root object that we attach to
+    Ogre::RenderSystem*			d_render_sys;		//!< Pointer to the render system for Ogre.
+    Ogre::uint8	d_queue_id;			//!< ID of the queue that we are hooked into
+    Ogre::TexturePtr			d_currTexture;		//!< currently set texture;
+    Ogre::RenderOperation		d_render_op;		//!< Ogre render operation we use to do our stuff.
+    Ogre::HardwareVertexBufferSharedPtr	d_buffer;	//!< vertex buffer to queue sprite rendering
+    size_t d_underused_framecount;                  //!< Number of frames elapsed since buffer utilization was above half the capacity
+    Ogre::RenderOperation		d_direct_render_op;		//!< Renderop for cursor
+    Ogre::HardwareVertexBufferSharedPtr	d_direct_buffer;	//!< Renderop for cursor
+    Ogre::SceneManager*			d_sceneMngr;		//!< The scene manager we are hooked into.
+    Ogre::LayerBlendModeEx		d_colourBlendMode;	//!< Controls colour blending mode used.
+    Ogre::LayerBlendModeEx		d_alphaBlendMode;	//!< Controls alpha blending mode used.
+    Ogre::TextureUnitState::UVWAddressingMode d_uvwAddressMode;
+
+    CEGUIRQListener*			d_ourlistener;
+    bool						d_post_queue;		//!< true if we render after everything else in our queue.
+    size_t						d_bufferPos;		//!< index into buffer where next vertex should be put.
+    bool						d_sorted;			//!< true when data in quad list is sorted.
+    Point						d_texelOffset;		//!< Offset required for proper texel mapping.
+
+    std::list<OgreCEGUITexture*> d_texturelist;		//!< List used to track textures.
+};
+
+} // End of  CEGUI namespace section
+
+
+#endif	// end of guard _OgreCEGUIRenderer_H__
Index: /code/branches/physics/src/orxonox/gui/OgreCEGUIResourceProvider.cpp
===================================================================
--- /code/branches/physics/src/orxonox/gui/OgreCEGUIResourceProvider.cpp	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/OgreCEGUIResourceProvider.cpp	(revision 2122)
@@ -0,0 +1,98 @@
+/************************************************************************
+    filename: 	OgreCEGUIResourceProvider.cpp
+    created:	8/7/2004
+    author:		James '_mental_' O'Sullivan
+
+    purpose:	Implements the Resource Provider common functionality
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+#include "OrxonoxStableHeaders.h"
+#include "OgreCEGUIResourceProvider.h"
+
+#include <CEGUIExceptions.h>
+#include <OgreArchiveManager.h>
+
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+    OgreCEGUIResourceProvider::OgreCEGUIResourceProvider() : ResourceProvider()
+    {
+        // set deafult resource group for Ogre
+        d_defaultResourceGroup = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str();
+    }
+
+//    void OgreResourceProvider::loadInputSourceContainer(const String& filename, InputSourceContainer& output)
+//   {
+//        Ogre::DataStreamPtr input = Ogre::ResourceGroupManager::getSingleton().openResource(filename.c_str());
+//
+//		if (input.isNull())
+//		{
+//			throw InvalidRequestException((utf8*)
+//				"Scheme::Scheme - Filename supplied for Scheme loading must be valid");
+//		}
+//
+//       XERCES_CPP_NAMESPACE_USE
+//        size_t buffsz = input->size();
+//        unsigned char* mem = reinterpret_cast<unsigned char*>(XMLPlatformUtils::fgArrayMemoryManager->allocate(buffsz));
+//        memcpy(mem, input.getPointer()->getAsString().c_str(), buffsz);
+//        InputSource* mInputSource = new MemBufInputSource(mem, buffsz, filename.c_str(), true);
+//        input.setNull();
+//
+//       output.setData(mInputSource);
+//    }
+
+    void OgreCEGUIResourceProvider::loadRawDataContainer(const String& filename, RawDataContainer& output,  const String& resourceGroup)
+    {
+        String orpGroup;
+        if (resourceGroup.empty())
+            orpGroup = d_defaultResourceGroup.empty() ? Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str() : d_defaultResourceGroup;
+        else
+            orpGroup = resourceGroup;
+
+        Ogre::DataStreamPtr input =
+            Ogre::ResourceGroupManager::getSingleton().openResource(filename.c_str(), orpGroup.c_str());
+
+        if (input.isNull())
+        {
+            throw InvalidRequestException((utf8*)
+                "OgreCEGUIResourceProvider::loadRawDataContainer - Unable to open resource file '" + filename + (utf8*)"' in resource group '" + orpGroup + (utf8*)"'.");
+        }
+
+        Ogre::String buf = input->getAsString();
+        const size_t memBuffSize = buf.length();
+
+        unsigned char* mem = new unsigned char[memBuffSize];
+        memcpy(mem, buf.c_str(), memBuffSize);
+
+        output.setData(mem);
+        output.setSize(memBuffSize);
+    }
+
+    void OgreCEGUIResourceProvider::unloadRawDataContainer(RawDataContainer& data)
+    {
+        if (data.getDataPtr())
+        {
+            delete[] data.getDataPtr();
+            data.setData(0);
+            data.setSize(0);
+        }
+    }
+} // End of  CEGUI namespace section
Index: /code/branches/physics/src/orxonox/gui/OgreCEGUIResourceProvider.h
===================================================================
--- /code/branches/physics/src/orxonox/gui/OgreCEGUIResourceProvider.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/OgreCEGUIResourceProvider.h	(revision 2122)
@@ -0,0 +1,52 @@
+/************************************************************************
+    filename: 	CEGUIOgreResourceProvider.h
+    created:	8/7/2004
+    author:		James '_mental_' O'Sullivan
+    
+    purpose:	Defines abstract base class for CEGUIData objects
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+#ifndef _OgreCEGUIResourceProvider_H__
+#define _OgreCEGUIResourceProvider_H__
+
+#include <CEGUIResourceProvider.h>
+#include "OgreCEGUIRenderer.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+class _OgrePrivate OgreCEGUIResourceProvider : public ResourceProvider
+{
+public:
+    /*************************************************************************
+        Construction and Destruction
+    *************************************************************************/
+    OgreCEGUIResourceProvider();
+
+    ~OgreCEGUIResourceProvider(void) {}
+
+//    void loadInputSourceContainer(const String& filename, InputSourceContainer& output);
+    void loadRawDataContainer(const String& filename, RawDataContainer& output, const String& resourceGroup);
+    void unloadRawDataContainer(RawDataContainer& output);
+};
+
+} // End of  CEGUI namespace section
+
+#endif	// end of guard _OgreCEGUIResourceProvider_H__
Index: /code/branches/physics/src/orxonox/gui/OgreCEGUITexture.cpp
===================================================================
--- /code/branches/physics/src/orxonox/gui/OgreCEGUITexture.cpp	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/OgreCEGUITexture.cpp	(revision 2122)
@@ -0,0 +1,269 @@
+/************************************************************************
+    filename: 	OgreCEGUITexture.cpp
+    created:	11/5/2004
+    author:		Paul D Turner
+    
+    purpose:	Implementation of Texture using Ogre engine
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+
+#include "OrxonoxStableHeaders.h"
+#include <CEGUISystem.h>
+#include <CEGUIExceptions.h>
+#include "OgreCEGUITexture.h"
+#include "OgreCEGUIRenderer.h"
+
+#include <OgreTextureManager.h>
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*************************************************************************
+    Static data definition / initialisation
+*************************************************************************/
+uint32 OgreCEGUITexture::d_texturenumber		= 0;
+
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+OgreCEGUITexture::OgreCEGUITexture(Renderer* owner) :
+    Texture(owner)
+{
+    d_ogre_texture.setNull();
+    d_isLinked = false;
+}
+
+
+/*************************************************************************
+    Destructor
+*************************************************************************/
+OgreCEGUITexture::~OgreCEGUITexture(void)
+{
+    freeOgreTexture();
+}
+
+
+/*************************************************************************
+    Loads the specified image file into the texture.  The texture is
+    resized as required to hold the image.	
+*************************************************************************/
+void OgreCEGUITexture::loadFromFile(const String& filename, const String& resourceGroup)
+{
+    using namespace Ogre;
+
+    // unload old ogre texture
+    freeOgreTexture();
+
+    // create / load a new ogre texture from the specified image
+    try
+    {
+        TextureManager& textureManager = TextureManager::getSingleton();
+
+        // see if texture already exists
+        Ogre::TexturePtr ogreTexture = (Ogre::TexturePtr)textureManager.getByName(filename.c_str());
+
+        if (!ogreTexture.isNull())
+        {
+            // texture already exists, so create a 'linked' texture (ensures texture is not destroyed twice)
+            d_ogre_texture = ogreTexture;
+            d_isLinked = true;
+        }
+        // texture does not already exist, so load it in
+        else
+        {
+            String orpGroup;
+            if (resourceGroup.empty())
+            {
+                const String& defGrp = CEGUI::System::getSingleton().getResourceProvider()->getDefaultResourceGroup();
+                orpGroup = defGrp.empty() ? Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str() : defGrp;
+            }
+            else
+            {
+                orpGroup = resourceGroup;
+            }
+
+            d_ogre_texture = TextureManager::getSingleton().load(filename.c_str(), orpGroup.c_str(), TEX_TYPE_2D, 0, 1.0f);
+            d_isLinked = false;
+        }
+
+    }
+    catch(Ogre::Exception e)
+    {
+        throw RendererException((utf8*)"Failed to create Texture object from file '" + filename + "'. Additional Information:\n" + e.getFullDescription().c_str());
+    }
+
+    // if we got a pointer cache some details
+    if (!d_ogre_texture.isNull())
+    {
+        d_width		= d_ogre_texture->getWidth();
+        d_height	= d_ogre_texture->getHeight();
+    }
+    // no texture from image so throw.
+    else
+    {
+        throw RendererException((utf8*)"Failed to create Texture object from file '" + filename + "'.  Ogre returned a NULL pointer.");
+    }
+
+}
+
+
+/*************************************************************************
+    Loads (copies) an image in memory into the texture.  The texture is
+    resized as required to hold the image.	
+*************************************************************************/
+
+void _byteSwap(unsigned char* b, int n)
+{
+    register int i = 0;
+    register int j = n-1;
+    while (i<j)
+    {
+        std::swap(b[i], b[j]);
+        i++, j--;
+    }
+}
+#define byteSwap(x) _byteSwap((unsigned char*) &x,sizeof(x))
+
+void OgreCEGUITexture::loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat)
+{
+    using namespace Ogre;
+
+    // get rid of old texture
+    freeOgreTexture();
+
+    // wrap input buffer with an Ogre DataChunk
+    uint32 bytesize = ((buffWidth * sizeof(uint32)) * buffHeight);
+
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    uint32* swappedBuffer = new uint32[bytesize/4];
+    memcpy(swappedBuffer, buffPtr, bytesize);
+
+    for (int i=0; i < bytesize/4; i++)
+        byteSwap(swappedBuffer[i]);
+
+    DataStreamPtr odc(new MemoryDataStream(static_cast<void*>(swappedBuffer), bytesize, false));
+#else
+    DataStreamPtr odc(new MemoryDataStream(const_cast<void*>(buffPtr), bytesize, false));
+#endif
+
+    // get pixel type for the target texture - the elements here might look wrong, but is just
+    // differences in definition (at the core level, between GL and D3D).
+    Ogre::PixelFormat targetFmt =
+        (pixelFormat == PF_RGBA) ? Ogre::PF_A8R8G8B8 : Ogre::PF_R8G8B8;
+
+    // try to create a Ogre::Texture from the input data
+    d_ogre_texture = TextureManager::getSingleton().loadRawData(getUniqueName(), "General", odc, buffWidth, buffHeight, targetFmt , TEX_TYPE_2D, 0, 1.0f);
+
+    // if we got a pointer cache some details
+    if (!d_ogre_texture.isNull())
+    {
+        d_width		= d_ogre_texture->getWidth();
+        d_height	= d_ogre_texture->getHeight();
+    }
+    // no texture from memory so throw.
+    else
+    {
+        throw RendererException((utf8*)"Failed to create Texture object from memory:  Ogre returned a NULL Ogre::Texture pointer.");
+    }
+
+}
+
+
+/*************************************************************************
+    set the size of the internal Ogre texture.  Previous Ogre texture
+    is lost.	
+*************************************************************************/
+void OgreCEGUITexture::setOgreTextureSize(uint size)
+{
+    using namespace Ogre;
+
+    // unload any current Ogre::Texture
+    freeOgreTexture();
+
+    // Try to create an empty texture of the given size
+    d_ogre_texture = TextureManager::getSingleton().createManual(getUniqueName(), "General", TEX_TYPE_2D, size, size, 0, PF_A8R8G8B8, TU_DEFAULT);
+
+    // if we got a pointer cache some details
+    if (!d_ogre_texture.isNull())
+    {
+        d_width		= d_ogre_texture->getWidth();
+        d_height	= d_ogre_texture->getHeight();
+    }
+    // no texture so throw.
+    else
+    {
+        throw RendererException((utf8*)"Failed to create texture of specified size: Ogre::Texture creation failed.");
+    }
+
+}
+
+
+/*************************************************************************
+    safely free Ogre::Texture texture (can be called multiple times with
+    no ill effect)
+*************************************************************************/
+void OgreCEGUITexture::freeOgreTexture(void)
+{
+    if ((!d_ogre_texture.isNull()) && !d_isLinked)
+    {
+        Ogre::TextureManager::getSingleton().remove(d_ogre_texture->getHandle());
+    }
+    d_ogre_texture.setNull();
+}
+
+
+/*************************************************************************
+    return a Ogre::string that contains a unique name.	
+*************************************************************************/
+Ogre::String OgreCEGUITexture::getUniqueName(void)
+{
+    Ogre::String str;
+
+#ifdef CEGUI_USEOLDOGRESTRING
+    str << "_cegui_ogre_" << d_texturenumber;
+#else
+    Ogre::StringUtil::StrStreamType strstream;
+    strstream << "_cegui_ogre_" << d_texturenumber;
+    str = strstream.str();
+#endif
+
+    ++d_texturenumber;
+
+    return str;
+}
+
+
+/*************************************************************************
+    Set the internal Ogre::Texture object.
+*************************************************************************/
+void OgreCEGUITexture::setOgreTexture(Ogre::TexturePtr& texture)
+{
+    freeOgreTexture();
+
+    d_ogre_texture = texture;
+    d_width	 = d_ogre_texture->getWidth();
+    d_height = d_ogre_texture->getHeight();
+    d_isLinked = true;
+}
+
+
+} // End of  CEGUI namespace section
+
Index: /code/branches/physics/src/orxonox/gui/OgreCEGUITexture.h
===================================================================
--- /code/branches/physics/src/orxonox/gui/OgreCEGUITexture.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/gui/OgreCEGUITexture.h	(revision 2122)
@@ -0,0 +1,179 @@
+/************************************************************************
+    filename: 	OgreCEGUITexture.h
+    created:	11/5/2004
+    author:		Paul D Turner
+    
+    purpose:	Interface to Texture implemented via Ogre engine
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+#ifndef _OgreCEGUITexture_H__
+#define _OgreCEGUITexture_H__
+
+#include <CEGUIBase.h>
+#include <CEGUIRenderer.h>
+#include <CEGUITexture.h>
+#include "OgreCEGUIRenderer.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*!
+\brief
+    Texture class that is created by OgreCEGUIRenderer objects
+*/
+class _OgrePrivate OgreCEGUITexture : public Texture
+{
+private:
+    /*************************************************************************
+        Friends (to allow construction and destruction)
+    *************************************************************************/
+    friend	Texture* OgreCEGUIRenderer::createTexture(void);
+    friend	Texture* OgreCEGUIRenderer::createTexture(const String& filename, const String& resourceGroup);
+    friend	Texture* OgreCEGUIRenderer::createTexture(float size);
+    friend	void	 OgreCEGUIRenderer::destroyTexture(Texture* texture);
+
+
+    /*************************************************************************
+        Construction & Destruction (by Renderer object only)
+    *************************************************************************/
+    OgreCEGUITexture(Renderer* owner);
+    virtual ~OgreCEGUITexture(void);
+
+public:
+    /*!
+    \brief
+        Returns the current pixel width of the texture
+
+    \return
+        ushort value that is the current width of the texture in pixels
+    */
+    virtual	ushort	getWidth(void) const		{return d_width;}
+
+
+    /*!
+    \brief
+        Returns the current pixel height of the texture
+
+    \return
+        ushort value that is the current height of the texture in pixels
+    */
+    virtual	ushort	getHeight(void) const		{return d_height;}
+
+
+    /*!
+    \brief
+        Loads the specified image file into the texture.  The texture is resized as required to hold the image.
+
+    \param filename
+        The filename of the image file that is to be loaded into the texture
+
+    \return
+        Nothing.
+    */
+    virtual void	loadFromFile(const String& filename, const String& resourceGroup);
+
+
+    /*!
+    \brief
+        Loads (copies) an image in memory into the texture.  The texture is resized as required to hold the image.
+    
+    \param buffPtr
+        Pointer to the buffer containing the image data
+    
+    \param buffWidth
+        Width of the buffer (in pixels as specified by \a pixelFormat )
+    
+    \param buffHeight
+        Height of the buffer (in pixels as specified by \a pixelFormat )
+    
+    \param pixelFormat
+    PixelFormat value describing the format contained in \a buffPtr
+    
+    \return
+        Nothing.
+    */
+    virtual void	loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
+
+
+    /*!
+    \brief
+        Return a pointer to the internal Ogre::Texture object
+
+    \return
+        Pointer to the Ogre::Texture object currently being used by this Texture object
+    */
+    Ogre::TexturePtr	getOgreTexture(void) const		{return d_ogre_texture;}
+
+
+    /*!
+    \brief
+        set the size of the internal Ogre texture.  Previous Ogre texture is lost.
+
+    \param size
+        pixel size of the new internal texture.  This will be rounded up to a power of 2.
+
+    \return
+        Nothing.
+    */
+    void	setOgreTextureSize(uint size);
+
+
+    /*!
+    \brief
+        Set the internal Ogre::TexturePtr object.
+
+    \param texture
+        Reference to an Ogre::TexturePtr object that is to be used by this Texture object.
+
+    \return
+        Nothing.
+    */
+    void	setOgreTexture(Ogre::TexturePtr& texture);
+
+
+private:
+    /*************************************************************************
+        Implementation Functions
+    *************************************************************************/
+    // safely free Ogre::Texture texture (can be called multiple times with no ill effect)
+    void	freeOgreTexture(void);
+
+    // return a Ogre::string that contains a unique name.
+    Ogre::String	getUniqueName(void);
+
+
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    static	uint32          d_texturenumber;	//!< Counter used to provide unique texture names.
+
+    Ogre::TexturePtr		d_ogre_texture;		//!< The 'real' texture.
+
+    ushort					d_width;			//!< cached width of the texture
+    ushort					d_height;			//!< cached height of the texture
+
+    bool	d_isLinked;		//!< True if we are linked to a texture we did not actually create.
+};
+
+
+} // End of  CEGUI namespace section
+
+
+#endif	// end of guard _OgreCEGUITexture_H__
Index: /code/branches/physics/src/orxonox/objects/EventDispatcher.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/EventDispatcher.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/EventDispatcher.cc	(revision 2122)
@@ -0,0 +1,83 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "EventDispatcher.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/XMLPort.h"
+#include "core/EventIncludes.h"
+#include "EventTarget.h"
+
+namespace orxonox
+{
+    CreateFactory(EventDispatcher);
+
+    EventDispatcher::EventDispatcher(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(EventDispatcher);
+    }
+
+    EventDispatcher::~EventDispatcher()
+    {
+        if (this->isInitialized())
+            for (std::list<EventTarget*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
+                delete (*it);
+    }
+
+    void EventDispatcher::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(EventDispatcher, XMLPort, xmlelement, mode);
+
+        XMLPortObject(EventDispatcher, EventTarget, "targets", addTarget, getTarget, xmlelement, mode);
+    }
+
+    void EventDispatcher::processEvent(Event& event)
+    {
+        for (std::list<EventTarget*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
+            (*it)->fireEvent(event);
+    }
+
+    void EventDispatcher::addTarget(EventTarget* target)
+    {
+        this->targets_.push_back(target);
+    }
+
+    EventTarget* EventDispatcher::getTarget(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::list<EventTarget*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/EventDispatcher.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/EventDispatcher.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/EventDispatcher.h	(revision 2122)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _EventDispatcher_H__
+#define _EventDispatcher_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport EventDispatcher : public BaseObject
+    {
+        public:
+            EventDispatcher(BaseObject* creator);
+            virtual ~EventDispatcher();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual void processEvent(Event& event);
+
+            void addTarget(EventTarget* target);
+            EventTarget* getTarget(unsigned int index) const;
+
+        private:
+            std::list<EventTarget*> targets_;
+    };
+}
+
+#endif /* _EventDispatcher_H__ */
Index: /code/branches/physics/src/orxonox/objects/EventListener.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/EventListener.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/EventListener.cc	(revision 2122)
@@ -0,0 +1,98 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "EventListener.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(EventListener);
+
+    EventListener::EventListener(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(EventListener);
+
+        this->bActive_ = false;
+    }
+
+    EventListener::~EventListener()
+    {
+    }
+
+    void EventListener::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(EventListener, XMLPort, xmlelement, mode);
+
+        XMLPortParam(EventListener, "event", setEventName, getEventName, xmlelement, mode);
+    }
+
+    void EventListener::processEvent(Event& event)
+    {
+        if (this->bActive_)
+        {
+            COUT(2) << "Warning: Detected Event loop in EventListener \"" << this->getName() << "\"" << std::endl;
+            return;
+        }
+
+        this->bActive_ = true;
+
+        this->fireEvent(event.activate_, event.originator_);
+
+        this->bActive_ = false;
+    }
+
+    void EventListener::setEventName(const std::string& eventname)
+    {
+        this->eventName_ = eventname;
+
+        if (this->eventName_ == "")
+            return;
+
+        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
+            if (it->getName() == this->eventName_)
+                this->registerAsListener(*it);
+    }
+
+    void EventListener::loadedNewXMLName(BaseObject* object)
+    {
+        if (this->eventName_ == "")
+            return;
+
+        if (object->getName() == this->eventName_)
+            this->registerAsListener(object);
+    }
+
+    void EventListener::registerAsListener(BaseObject* object)
+    {
+        object->registerEventListener(this, "");
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/EventListener.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/EventListener.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/EventListener.h	(revision 2122)
@@ -0,0 +1,61 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _EventListener_H__
+#define _EventListener_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+#include "core/XMLNameListener.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport EventListener : public BaseObject, public XMLNameListener
+    {
+        public:
+            EventListener(BaseObject* creator);
+            virtual ~EventListener();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual void processEvent(Event& event);
+
+            void setEventName(const std::string& eventname);
+            inline const std::string& getEventName() const
+                { return this->eventName_; }
+
+        private:
+            virtual void loadedNewXMLName(BaseObject* object);
+            void registerAsListener(BaseObject* object);
+
+            std::string eventName_;
+            bool bActive_;
+    };
+}
+
+#endif /* _EventListener_H__ */
Index: /code/branches/physics/src/orxonox/objects/EventTarget.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/EventTarget.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/EventTarget.cc	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "EventTarget.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(EventTarget);
+
+    EventTarget::EventTarget(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(EventTarget);
+    }
+
+    EventTarget::~EventTarget()
+    {
+    }
+
+    void EventTarget::changedName()
+    {
+        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
+            if (it->getName() == this->getName())
+                this->addAsEvent(*it);
+    }
+
+    void EventTarget::loadedNewXMLName(BaseObject* object)
+    {
+        if (this->getName() == "")
+            return;
+
+        if (object->getName() == this->getName())
+            this->addAsEvent(object);
+    }
+
+    void EventTarget::addAsEvent(BaseObject* object)
+    {
+        if (object != (BaseObject*)this)
+            object->addEvent(this, "");
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/EventTarget.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/EventTarget.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/EventTarget.h	(revision 2122)
@@ -0,0 +1,52 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _EventTarget_H__
+#define _EventTarget_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+#include "core/XMLNameListener.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport EventTarget : public BaseObject, public XMLNameListener
+    {
+        public:
+            EventTarget(BaseObject* creator);
+            virtual ~EventTarget();
+
+            virtual void changedName();
+
+        private:
+            virtual void loadedNewXMLName(BaseObject* object);
+            void addAsEvent(BaseObject* object);
+    };
+}
+
+#endif /* _EventTarget_H__ */
Index: /code/branches/physics/src/orxonox/objects/HelloBullet.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/HelloBullet.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/HelloBullet.cc	(revision 2122)
@@ -0,0 +1,191 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Stypinski
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HelloBullet.h"
+
+#include <OgreStaticGeometry.h>
+#include <OgreSceneManager.h>
+#include <OgreEntity.h>
+
+#include "ogreode/OgreOde_Core.h"
+#include "ogreode/OgreOdeGeometry.h"
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/XMLPort.h"
+#include "GraphicsEngine.h"
+
+#include "util/Sleep.h"
+
+
+namespace orxonox
+{
+    CreateFactory(HelloBullet);
+    
+    HelloBullet::HelloBullet()
+    {
+ 	   RegisterObject(HelloBullet);
+  	   COUT(0) << "HelloBullet loaded" << std::endl ;
+           int maxProxies = 1024;
+
+
+        btVector3 worldAabbMin(-10000,-10000,-10000);
+        btVector3 worldAabbMax(10000,10000,10000);
+        btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
+
+        btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
+        btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
+
+        btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
+
+        dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
+
+        dynamicsWorld->setGravity(btVector3(0,-10,0));
+
+
+        btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),10);
+
+        btCollisionShape* fallShape = new btSphereShape(1);
+
+
+        btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-1,0)));
+        btRigidBody::btRigidBodyConstructionInfo
+                groundRigidBodyCI(0,groundMotionState,groundShape,btVector3(0,0,0));
+        btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
+        dynamicsWorld->addRigidBody(groundRigidBody);
+
+
+        btDefaultMotionState* fallMotionState =
+                new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,100,0)));
+        btScalar mass = 1000;
+        btVector3 fallInertia(0,0,0);
+        fallShape->calculateLocalInertia(mass,fallInertia);
+        btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,fallMotionState,fallShape,fallInertia);
+        fallRigidBody = new btRigidBody(fallRigidBodyCI);
+        dynamicsWorld->addRigidBody(fallRigidBody);
+
+ 
+
+//load floor mash
+        Ogre::SceneManager* sceneMgr = GraphicsEngine::getInstance().getLevelSceneManager();
+
+        int i = 0;
+        Ogre::StaticGeometry* floor;
+        floor = sceneMgr->createStaticGeometry("StaticFloor");
+        floor->setRegionDimensions(Ogre::Vector3(160.0, 100.0, 160.0));
+        // Set the region origin so the center is at 0 world
+        floor->setOrigin(Ogre::Vector3::ZERO);
+        for (Real z = -80.0; z <= 80.0; z += 20.0)
+        {
+            for (Real x = -80.0; x <= 80.0; x += 20.0)
+            {
+                std::string name = std::string("Ground") + convertToString(i++);
+                Ogre::Entity* entity = sceneMgr->createEntity(name, "plane.mesh");
+                entity->setQueryFlags (1<<4);
+                entity->setCastShadows(false);
+                floor->addEntity(entity, Ogre::Vector3(x,0,z));
+            }
+        }       
+
+        floor->build();
+
+
+// crate
+
+        entity_ = sceneMgr->createEntity("crate","crate.mesh");
+        entity_->setQueryFlags (1<<2);
+        sceneNode_ = sceneMgr->getRootSceneNode()->createChildSceneNode("crate");
+        sceneNode_->attachObject(entity_);
+        entity_->setNormaliseNormals(true);
+        entity_->setCastShadows(true);
+	sceneNode_ -> setPosition(Vector3(0,100,0));
+
+
+      
+
+
+    }
+
+    HelloBullet::~HelloBullet()
+    {
+     //  dynamicsWorld->removeRigidBody(fallRigidBody);
+     //   delete fallRigidBody->getMotionState();
+     //   delete fallRigidBody;
+
+     //   dynamicsWorld->removeRigidBody(groundRigidBody);
+     //   delete groundRigidBody->getMotionState();
+     //   delete groundRigidBody;
+
+
+     //   delete fallShape;
+
+     //   delete groundShape;
+
+
+     //   delete dynamicsWorld;
+     //   delete solver;
+     //   delete collisionConfiguration;
+     //   delete dispatcher;
+     //   delete broadphase;
+
+    }
+
+    void HelloBullet::setConfigValues()
+    {
+
+    }
+
+    /**
+    @brief
+        XML loading and saving.
+    @param
+        xmlelement The XML-element
+    @param	
+        loading Loading (true) or saving (false)
+    @return
+        The XML-element
+    */
+    void HelloBullet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+      SUPER(HelloBullet, XMLPort, xmlelement, mode);
+    }
+
+    void HelloBullet::tick(float dt)
+    {
+                dynamicsWorld->stepSimulation(1/60.f,10);
+                btTransform trans;
+                fallRigidBody->getMotionState()->getWorldTransform(trans);
+	        COUT(0) << "sphere height: " << trans.getOrigin().getY() << std::endl;
+		sceneNode_ -> setPosition(Vector3(0,trans.getOrigin().getY(),0));
+	//	msleep(20);
+		
+		
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/HelloBullet.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/HelloBullet.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/HelloBullet.h	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Stypinski
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HelloBullet_H__
+#define _HelloBullet_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+
+#include "ogrebullet/Dynamics/OgreBulletDynamics.h"
+
+#include "Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HelloBullet : public BaseObject, public Tickable
+    {
+    public:
+        HelloBullet();
+        virtual ~HelloBullet();
+        void setConfigValues();
+
+        virtual void tick(float dt);
+
+        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+    private:
+        Ogre::SceneNode*                sceneNode_;
+        Ogre::Entity*                   entity_;
+	btRigidBody* fallRigidBody;
+  	btDiscreteDynamicsWorld* dynamicsWorld;
+    };
+
+
+}
+
+
+
+#endif /* _HelloBullet_H__ */
Index: /code/branches/physics/src/orxonox/objects/PhysicsTest.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/PhysicsTest.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/PhysicsTest.cc	(revision 2122)
@@ -0,0 +1,226 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "PhysicsTest.h"
+
+#include <OgreStaticGeometry.h>
+#include <OgreSceneManager.h>
+#include <OgreEntity.h>
+#include "ogreode/OgreOde_Core.h"
+#include "ogreode/OgreOdeGeometry.h"
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/XMLPort.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(PhysicsTest);
+
+    PhysicsTest::PhysicsTest()
+        : odeWorld_(0)
+        , odeSpace_(0)
+        , odeStepper_(0)
+        , odeGround_(0)   
+        , odeBody_(0)
+        , odeGeom_(0)
+        , sceneNode_(0)
+        , entity_(0)
+        , bRunning_(false)
+    {
+        RegisterObject(PhysicsTest);
+        setConfigValues();
+        ModifyConfigValue(bRunning_, tset, false);
+    }
+
+    PhysicsTest::~PhysicsTest()
+    {
+    }
+
+    void PhysicsTest::setConfigValues()
+    {
+        SetConfigValue(bRunning_, false);
+    }
+
+    /**
+    @brief
+        XML loading and saving.
+    @param
+        xmlelement The XML-element
+    @param
+        loading Loading (true) or saving (false)
+    @return
+        The XML-element
+    */
+    void PhysicsTest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PhysicsTest, XMLPort, xmlelement, mode);
+
+        Ogre::SceneManager* sceneMgr = GraphicsEngine::getInstance().getLevelSceneManager();
+
+        // set up OgreOde
+
+        odeWorld_ = new OgreOde::World(sceneMgr);
+        odeWorld_->setGravity(Vector3(0,-9.80665,0));
+        odeWorld_->setCFM(10e-5);
+        odeWorld_->setERP(0.8);
+        odeWorld_->setAutoSleep(true);
+        odeWorld_->setAutoSleepAverageSamplesCount(10);
+        odeWorld_->setContactCorrectionVelocity(1.0);
+        odeSpace_ = odeWorld_->getDefaultSpace();
+
+
+        // set up stepper
+
+        const Ogre::Real _time_step = 0.5;http://isg.ee.ethz.ch/
+        const Ogre::Real time_scale = Ogre::Real(1.7);
+        const Ogre::Real max_frame_time = Ogre::Real(1.0 / 4);
+        odeStepper_ = new OgreOde::StepHandler(odeWorld_, OgreOde::StepHandler::QuickStep,_time_step,
+            max_frame_time, time_scale);
+
+
+        // Create a hanging crate
+
+        odeGround_ = new OgreOde::InfinitePlaneGeometry(Ogre::Plane(Ogre::Vector3(0,1,0),0),
+            odeWorld_, odeWorld_->getDefaultSpace());
+
+	CollidingObject* collidingObject = new CollidingObject();
+       
+	odeGround_->setUserObject(static_cast<CollisionTestedObject*>(collidingObject));
+
+        // Use a load of meshes to represent the floor
+        int i = 0;
+        Ogre::StaticGeometry* floor;
+        floor = sceneMgr->createStaticGeometry("StaticFloor");
+        floor->setRegionDimensions(Ogre::Vector3(160.0, 100.0, 160.0));
+        // Set the region origin so the center is at 0 world
+        floor->setOrigin(Ogre::Vector3::ZERO);
+        for (Real z = -80.0; z <= 80.0; z += 20.0)
+        {
+            for (Real x = -80.0; x <= 80.0; x += 20.0)
+            {
+                std::string name = std::string("Ground") + convertToString(i++);
+                Ogre::Entity* entity = sceneMgr->createEntity(name, "plane.mesh");
+                entity->setQueryFlags (1<<4);
+                entity->setUserObject(odeGround_);
+                entity->setCastShadows(false);
+                floor->addEntity(entity, Ogre::Vector3(x,0,z));
+            }
+        }       
+
+        floor->build();
+
+
+        // create a plane in x-z dimensions.
+
+        entity_ = sceneMgr->createEntity("crate","crate.mesh");
+        entity_->setQueryFlags (1<<2);
+        sceneNode_ = sceneMgr->getRootSceneNode()->createChildSceneNode("crate");
+        sceneNode_->attachObject(entity_);
+        entity_->setNormaliseNormals(true);
+        entity_->setCastShadows(true);
+
+
+        odeBody_ = new OgreOde::Body(odeWorld_);
+        sceneNode_->attachObject(odeBody_);
+
+        
+        // set size and mass of the crate
+
+        Vector3 size(10.0, 10.0, 10.0);
+        odeMass_ = OgreOde::BoxMass(0.5, size);
+        odeMass_.setDensity(5.0, size);
+        odeGeom_ = new OgreOde::BoxGeometry(size, odeWorld_, odeSpace_);
+        sceneNode_->setScale(size.x * 0.1, size.y * 0.1, size.z * 0.1);
+        odeBody_->setMass(odeMass_);
+        odeGeom_->setBody(odeBody_);
+        entity_->setUserObject(odeGeom_);
+        odeGeom_->setUserObject(static_cast<CollisionTestedObject*>(this));
+
+
+        odeBody_->setOrientation(Quaternion(Degree(30.0), Vector3(0,0,0)));
+        odeBody_->setPosition(Vector3(0,120,-20));
+
+    }
+
+    void PhysicsTest::tick(float dt)
+    {
+        // only update physics in a certain interval
+        if (this->bRunning_ && odeStepper_->step(dt))
+            odeWorld_->synchronise();
+    }
+
+    bool PhysicsTest::collision(OgreOde::Contact *Contact)
+    {
+    	// Check for collisions between things that are connected and ignore them
+       	OgreOde::Geometry * const g1 = Contact->getFirstGeometry();
+       	OgreOde::Geometry * const g2 = Contact->getSecondGeometry();
+
+       	if (g1 && g2)
+       	{
+       		const OgreOde::Body * const b1 = g2->getBody();
+       		const OgreOde::Body * const  b2 = g1->getBody();
+       		if (b1 && b2 && OgreOde::Joint::areConnected(b1, b2)) 
+                  return false; 
+       	}
+       
+       	//set contact parameters:
+       	Contact->setBouncyness(1.0);
+       	Contact->setCoulombFriction(OgreOde::Utility::Infinity);
+       	Contact->setForceDependentSlip(1.0);
+       	Contact->setAdditionalFDS(1.0);
+       
+       	/*we have 2 collidable objects from our object system, if one of the Collide function returns false, e return false in this method, too, else we return true, so ode computes a normal collision.
+        true means ode will treat this like a normal collison => rigid body behavior
+        false means ode will not treat this collision at all => objects ignore each other*/
+        	
+        bool Return = true;
+        	
+        if (g1->getUserObject())
+        	if (!static_cast<CollisionTestedObject*>(g1->getUserObject())->Collide(true, Contact))
+        		Return = false;
+        
+        if (g2->getUserObject())
+        	if (!static_cast<CollisionTestedObject*>(g2->getUserObject())->Collide(false, Contact))
+        		Return = false;
+        
+        return Return;
+    }
+
+        bool CollidingObject::Collide(bool MineIsFirst, OgreOde::Contact *Contact)
+        {
+        	Contact->setForceDependentSlip(Contact->getForceDependentSlip() * ForceDependentSlip);
+        	Contact->setAdditionalFDS(Contact->getForceDependentSlip2() * ForceDependentSlip);
+        	Contact->setCoulombFriction(Contact->getCoulombFrictionMu() * Friction);
+        	Contact->setBouncyness(Contact->getBouncyness() * Bouncyness, Contact->getBouncynessVelocity() * BounceVelocity);
+        	return true;
+        }
+
+}
Index: /code/branches/physics/src/orxonox/objects/PhysicsTest.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/PhysicsTest.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/PhysicsTest.h	(revision 2122)
@@ -0,0 +1,113 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _PhysicsTest_H__
+#define _PhysicsTest_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "ogreode/OgreOdePreReqs.h"
+#include "ogreode/OgreOdeMass.h"
+#include "core/BaseObject.h"
+#include "Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport PhysicsTest : public BaseObject, public Tickable
+    {
+    public:
+        PhysicsTest();
+        virtual ~PhysicsTest();
+        void setConfigValues();
+
+        virtual void tick(float dt);
+
+        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+    private:
+        OgreOde::World*                 odeWorld_;
+        OgreOde::Space*                 odeSpace_;
+        OgreOde::StepHandler*           odeStepper_;
+
+        OgreOde::InfinitePlaneGeometry* odeGround_;    
+        OgreOde::Body*                  odeBody_;
+        OgreOde::Geometry*              odeGeom_;
+        OgreOde::BoxMass                odeMass_;
+        Ogre::SceneNode*                sceneNode_;
+        Ogre::Entity*                   entity_;
+
+        bool                            bRunning_;
+    };
+
+
+   class _OrxonoxExport CollisionTestedObject
+   {
+        public:
+        	CollisionTestedObject(void);
+        	virtual ~CollisionTestedObject(void);
+        	virtual bool Collide(bool MineIsFirst, OgreOde::Contact *Contact) = 0;
+   };
+
+   class _OrxonoxExport CollidingObject : public virtual CollisionTestedObject
+   {
+        protected:
+               float Friction;
+        	float Bouncyness;
+        	float BounceVelocity;
+        	float ForceDependentSlip;
+        
+        public:
+        	CollidingObject(void);
+        	virtual ~CollidingObject(void);
+        
+        //	bool virtual WriteToIni(IniFile& Ini)	const;
+        //	bool virtual LoadFromIni(const std::basic_string<wchar_t>& ObjectID, IniFile& Ini);
+        
+        	float GetFriction(void)			const	{return Friction;}
+        	float GetBouncyness(void)		const	{return Bouncyness;}
+        	float GetBounceVelocity(void)		const	{return BounceVelocity;}
+        	float GetFDS(void)			const	{return ForceDependentSlip;}
+        
+        	virtual bool Collide(bool MineIsFirst, OgreOde::Contact *Contact);
+        
+        private:
+        	static const wchar_t* KEY_FRICTION;
+        	static const float DEF_FRICTION;
+        	static const wchar_t* KEY_BOUNCYNESS;
+        	static const float DEF_BOUNCYNESS;
+        	static const wchar_t* KEY_FDS;
+        	static const float DEF_FDS;
+        	static const wchar_t* KEY_BOUNCE_VELO;
+        	static const float DEF_BOUNCE_VELO;
+   };
+
+}
+
+
+
+#endif /* _PhysicsTest_H__ */
Index: /code/branches/physics/src/orxonox/objects/Radar.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/Radar.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Radar.cc	(revision 2122)
@@ -0,0 +1,214 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+    @file
+    @brief
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "Radar.h"
+#include <cfloat>
+#include <cassert>
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/Iterator.h"
+#include "RadarListener.h"
+
+namespace orxonox
+{
+    SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);
+    SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);
+
+    Radar* Radar::instance_s = 0;
+
+    Radar::Radar()
+        : focus_(0)
+        , objectTypeCounter_(0)
+    {
+        assert(instance_s == 0);
+        instance_s = this;
+
+        // TODO: make this mapping configurable. Maybe there's a possibility with self configured
+        //       configValues..
+        this->objectTypes_["Asteroid"] = RadarViewable::Dot;
+        this->objectTypes_["SpaceShip"] = RadarViewable::Square;
+        this->objectTypes_["AsdfQwerty"] = RadarViewable::Triangle;
+
+        /*WorldEntity* object;
+        object = new WorldEntity();
+        object->setPosition(2000.0, 0.0, 0.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(0.0, 2000.0, 0.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(0.0, 0.0, 2000.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(10000.0,16000.0,0.0);
+        addRadarObject(object);*/
+
+    }
+
+    Radar::~Radar()
+    {
+        instance_s = 0;
+    }
+
+    const RadarViewable* Radar::getFocus()
+    {
+        return *(this->itFocus_);
+    }
+
+    RadarViewable::Shape Radar::addObjectDescription(const std::string name)
+    {
+        std::map<std::string, RadarViewable::Shape>::iterator it = this->objectTypes_.find(name);
+        if (it == this->objectTypes_.end())
+            return this->objectTypes_[name] = RadarViewable::Square; // default, configure!!
+        else
+            return this->objectTypes_[name];
+    }
+
+
+    void Radar::tick(float dt)
+    {
+        if (this->focus_ != *(this->itFocus_))
+        {
+            // focus object was deleted, release focus
+            this->focus_ = 0;
+            this->itFocus_ = 0;
+        }
+
+        for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
+        {
+            (*itListener)->radarTick(dt);
+
+            for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
+            {
+/*
+                if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
+                    (*itListener)->displayObject(*itElement, *itElement == this->focus_);
+*/
+            }
+        }
+    }
+
+    void Radar::cycleFocus()
+    {
+        if (ObjectList<RadarViewable>::begin() == 0)
+        {
+            // list is empty
+            this->itFocus_ = 0;
+            this->focus_ = 0;
+        }
+        else
+        {
+            Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition();
+            Vector3 targetPosition = localPosition;
+            if (*(this->itFocus_))
+                targetPosition = this->itFocus_->getWorldPosition();
+
+            // find the closed object further away than targetPosition
+            float currentDistance = localPosition.squaredDistance(targetPosition);
+            float nextDistance = FLT_MAX;
+            float minimumDistance = FLT_MAX;
+            ObjectList<RadarViewable>::iterator itFallback = 0;
+
+            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
+            {
+/*
+                if (*it == SpaceShip::getLocalShip())
+                    continue;
+*/
+                float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition());
+                if (targetDistance > currentDistance && targetDistance < nextDistance)
+                {
+                    this->itFocus_ = it;
+                    nextDistance = targetDistance;
+                }
+                if (targetDistance < minimumDistance)
+                {
+                    itFallback = it;
+                    minimumDistance = targetDistance;
+                }
+            }
+
+            if (nextDistance == FLT_MAX)
+            {
+                // we already had the furthest object
+                this->itFocus_ = itFallback;
+                this->focus_ = *itFallback;
+            }
+            else
+            {
+                this->focus_ = *(this->itFocus_);
+            }
+        }
+    }
+
+    void Radar::releaseFocus()
+    {
+        this->itFocus_ = 0;
+        this->focus_ = 0;
+    }
+
+    void Radar::listObjects() const
+    {
+        COUT(3) << "List of RadarObjects:\n";
+        // iterate through all Radar Objects
+        unsigned int i = 0;
+        for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i)
+        {
+            COUT(3) << i++ << ": " << (*it)->getWorldPosition() << std::endl;
+        }
+    }
+
+
+    /*static*/ Radar& Radar::getInstance()
+    {
+        assert(instance_s);
+        return *instance_s;
+    }
+
+    /*static*/ void Radar::cycleNavigationFocus()
+    {
+        // avoid using getInstance because of the assert().
+        // User might call this fuction even if HUDNavigation doesn't exist.
+        if (instance_s)
+            instance_s->cycleFocus();
+    }
+
+    /*static*/ void Radar::releaseNavigationFocus()
+    {
+        // avoid using getInstance because of the assert().
+        // User might call this fuction even if HUDNavigation doesn't exist.
+        if (instance_s)
+            instance_s->releaseFocus();
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/Radar.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/Radar.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Radar.h	(revision 2122)
@@ -0,0 +1,92 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+    @file
+    @brief
+*/
+
+#ifndef _Radar_H__
+#define _Radar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <string>
+#include "core/Iterator.h"
+#include "core/OrxonoxClass.h"
+#include "objects/Tickable.h"
+#include "RadarViewable.h"
+
+namespace orxonox
+{
+    /**
+    @brief This class merely ensures that no one can inherit from Radar.
+    */
+    class _OrxonoxExport RadarBase
+    {
+    private:
+        friend class Radar;
+        RadarBase() { }
+    };
+
+    class _OrxonoxExport Radar : public Tickable, private virtual RadarBase
+    {
+    public:
+        Radar();
+        ~Radar();
+
+        virtual void tick(float dt);
+
+        const RadarViewable* getFocus();
+        RadarViewable::Shape addObjectDescription(const std::string name);
+
+        void listObjects() const;
+
+        static Radar& getInstance();
+        static Radar* getInstancePtr() { return instance_s; }
+
+        static void cycleNavigationFocus();
+        static void releaseNavigationFocus();
+
+    private:
+        Radar(Radar& instance);
+
+        void releaseFocus();
+        void updateFocus();
+        void cycleFocus();
+
+        ObjectListIterator<RadarViewable> itFocus_;
+        RadarViewable* focus_;
+        std::map<std::string, RadarViewable::Shape> objectTypes_;
+        int objectTypeCounter_;
+
+        static Radar* instance_s;
+    };
+}
+#endif /* _Radar_H__ */
Index: /code/branches/physics/src/orxonox/objects/RadarListener.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/RadarListener.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/RadarListener.cc	(revision 2122)
@@ -0,0 +1,39 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "RadarListener.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RadarListener::RadarListener()
+    {
+        RegisterRootObject(RadarListener);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/RadarListener.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/RadarListener.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/RadarListener.h	(revision 2122)
@@ -0,0 +1,49 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _RadarListener_H__
+#define _RadarListener_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RadarListener : virtual public OrxonoxClass
+    {
+    public:
+        RadarListener();
+        virtual ~RadarListener() { }
+
+        virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0;
+        virtual float getRadarSensitivity() const = 0;
+        virtual void radarTick(float dt) = 0;
+    };
+}
+
+#endif /* _RadarListener_H__ */
Index: /code/branches/physics/src/orxonox/objects/RadarViewable.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/RadarViewable.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/RadarViewable.cc	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "RadarViewable.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+//#include "objects/WorldEntity.h"
+#include "Radar.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor.
+    */
+    RadarViewable::RadarViewable()
+        : radarObject_(0)
+        , radarObjectCamouflage_(0.0f)
+        , radarObjectType_(Dot)
+        , radarObjectDescription_("staticObject")
+    {
+        RegisterRootObject(RadarViewable);
+    }
+
+    void RadarViewable::setRadarObjectDescription(const std::string& str)
+    {
+        Radar* radar = Radar::getInstancePtr();
+        if (radar)
+            this->radarObjectType_ = radar->addObjectDescription(str);
+        else
+        {
+            CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
+        }
+        this->radarObjectDescription_ = str;
+    }
+
+    const Vector3& RadarViewable::getWorldPosition() const
+    {
+        validate();
+        return Vector3::ZERO;//this->radarObject_->getWorldPosition();
+    }
+
+    Vector3 RadarViewable::getOrientedVelocity() const
+    {
+        validate();
+        return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/RadarViewable.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/RadarViewable.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/RadarViewable.h	(revision 2122)
@@ -0,0 +1,89 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _RadarViewable_H__
+#define _RadarViewable_H__
+
+#include "OrxonoxPrereqs.h"
+#include <string>
+#include <cassert>
+#include "util/Math.h"
+#include "util/Debug.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    /**
+    @brief Interface for receiving window events.
+    */
+    class _OrxonoxExport RadarViewable : virtual public OrxonoxClass
+    {
+    class WorldEntity;
+
+    public:
+        enum Shape
+        {
+            Square,
+            Dot,
+            Triangle
+        };
+
+    public:
+        RadarViewable();
+        virtual ~RadarViewable() { }
+
+        float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; }
+        void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; }
+
+        const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; }
+        void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; }
+
+        const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; }
+        void setRadarObjectDescription(const std::string& str);
+
+        const WorldEntity* getWorldEntity() const { return this->radarObject_; }
+        const Vector3& getWorldPosition() const;
+        Vector3 getOrientedVelocity() const;
+
+        Shape getRadarObjectType() const { return this->radarObjectType_; }
+
+    protected:
+        WorldEntity* radarObject_;
+
+    private:
+        void validate() const { if (!this->radarObject_)
+        { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } }
+
+        float radarObjectCamouflage_;
+        Shape radarObjectType_;
+        std::string radarObjectDescription_;
+        ColourValue radarObjectColour_;
+    };
+}
+
+#endif /* _RadarViewable_H__ */
Index: /code/branches/physics/src/orxonox/objects/Scene.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/Scene.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Scene.cc	(revision 2122)
@@ -0,0 +1,166 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Scene.h"
+
+#include <OgreRoot.h>
+#include <OgreSceneManagerEnumerator.h>
+#include <OgreSceneNode.h>
+#include <OgreLight.h>
+
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(Scene);
+
+    Scene::Scene(BaseObject* creator) : BaseObject(creator), network::Synchronisable(creator)
+    {
+        RegisterObject(Scene);
+
+        this->setScene(this);
+        this->bShadows_ = false;
+
+        if (Core::showsGraphics())
+        {
+            if (Ogre::Root::getSingletonPtr())
+            {
+                this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
+                this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+            }
+            else
+            {
+                this->sceneManager_ = 0;
+                this->rootSceneNode_ = 0;
+            }
+        }
+        else
+        {
+            // create a dummy SceneManager of our own since we don't have Ogre::Root.
+            this->sceneManager_ = new Ogre::DefaultSceneManager("");
+            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+        }
+
+        // test test test
+        if (Core::showsGraphics() && this->sceneManager_)
+        {
+            Ogre::Light* light;
+            light = this->sceneManager_->createLight("Light-1");
+            light->setType(Ogre::Light::LT_DIRECTIONAL);
+            light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0));
+            light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0));
+            light->setDirection(1, -0.3, 0.3);
+        }
+        // test test test
+
+        this->registerVariables();
+    }
+
+    Scene::~Scene()
+    {
+        if (this->isInitialized())
+        {
+            if (Ogre::Root::getSingletonPtr())
+            {
+//                this->sceneManager_->destroySceneNode(this->rootSceneNode_->getName()); // TODO: remove getName() for newer versions of Ogre
+                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
+            }
+            else if (!Core::showsGraphics())
+            {
+                delete this->sceneManager_;
+            }
+        }
+    }
+
+    void Scene::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Scene, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Scene, "skybox", setSkybox, getSkybox, xmlelement, mode);
+        XMLPortParam(Scene, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2, 0.2, 0.2, 1));
+        XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true);
+
+        XMLPortObjectExtended(Scene, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
+    }
+
+    void Scene::registerVariables()
+    {
+        REGISTERSTRING(this->skybox_,     network::direction::toclient, new network::NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
+        REGISTERDATA(this->ambientLight_, network::direction::toclient, new network::NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
+    }
+
+    void Scene::setSkybox(const std::string& skybox)
+    {
+        if (Core::showsGraphics() && this->sceneManager_)
+            this->sceneManager_->setSkyBox(true, skybox);
+
+        this->skybox_ = skybox;
+    }
+
+    void Scene::setAmbientLight(const ColourValue& colour)
+    {
+        if (Core::showsGraphics() && this->sceneManager_)
+            this->sceneManager_->setAmbientLight(colour);
+
+        this->ambientLight_ = colour;
+    }
+
+    void Scene::setShadow(bool bShadow)
+    {
+        if (Core::showsGraphics() && this->sceneManager_)
+        {
+            if (bShadow)
+                this->sceneManager_->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
+            else
+                this->sceneManager_->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
+        }
+
+        this->bShadows_ = bShadow;
+    }
+
+    void Scene::addObject(BaseObject* object)
+    {
+        this->objects_.push_back(object);
+        object->setScene(this);
+    }
+
+    BaseObject* Scene::getObject(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/Scene.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/Scene.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Scene.h	(revision 2122)
@@ -0,0 +1,84 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Scene_H__
+#define _Scene_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "network/Synchronisable.h"
+#include "core/BaseObject.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Scene : public BaseObject, public network::Synchronisable
+    {
+        public:
+            Scene(BaseObject* creator);
+            virtual ~Scene();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            inline Ogre::SceneManager* getSceneManager() const
+                { return this->sceneManager_; }
+            inline Ogre::SceneNode* getRootSceneNode() const
+                { return this->rootSceneNode_; }
+
+            void setSkybox(const std::string& skybox);
+            inline const std::string& getSkybox() const
+                { return this->skybox_; }
+
+            void setAmbientLight(const ColourValue& colour);
+            inline const ColourValue& getAmbientLight() const
+                { return this->ambientLight_; }
+
+            void setShadow(bool bShadow);
+            inline bool getShadow() const
+                { return this->bShadows_; }
+
+        private:
+            void addObject(BaseObject* object);
+            BaseObject* getObject(unsigned int index) const;
+
+            void networkcallback_applySkybox()
+                { this->setSkybox(this->skybox_); }
+            void networkcallback_applyAmbientLight()
+                { this->setAmbientLight(this->ambientLight_); }
+
+            Ogre::SceneManager*    sceneManager_;
+            Ogre::SceneNode*       rootSceneNode_;
+            std::string            skybox_;
+            ColourValue            ambientLight_;
+            std::list<BaseObject*> objects_;
+            bool                   bShadows_;
+    };
+}
+
+#endif /* _Scene_H__ */
Index: /code/branches/physics/src/orxonox/objects/Script.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/Script.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Script.cc	(revision 2122)
@@ -0,0 +1,70 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Script.h"
+
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/LuaBind.h"
+
+namespace orxonox
+{
+  CreateFactory(Script);
+
+  Script::Script(BaseObject* creator) : BaseObject(creator)
+  {
+    RegisterObject(Script);
+
+    code_ = "";
+  }
+
+  Script::~Script()
+  {
+  }
+
+  /**
+  @brief XML loading and saving.
+  @param xmlelement The XML-element
+  @param loading Loading (true) or saving (false)
+   */
+  void Script::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+  {
+    BaseObject::XMLPort(xmlelement, mode);
+
+    code_ = xmlelement.GetText(false);
+  }
+
+  void Script::execute()
+  {
+    LuaBind* lua = LuaBind::getInstance();
+    lua->loadString(this->code_);
+    lua->run();
+  }
+}
Index: /code/branches/physics/src/orxonox/objects/Script.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/Script.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Script.h	(revision 2122)
@@ -0,0 +1,51 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Script_H__
+#define _Script_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport Script : public BaseObject
+  {
+    public:
+      Script(BaseObject* creator);
+      ~Script();
+      void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+      void execute();
+
+    private:
+      std::string code_;
+  };
+}
+
+#endif /* _Script_H__ */
Index: /code/branches/physics/src/orxonox/objects/Test.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/Test.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Test.cc	(revision 2122)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oli Scheuss
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "Test.h"
+
+namespace orxonox
+{
+	CreateFactory ( Test );
+
+	Test::Test(BaseObject* creator) : BaseObject(creator), network::Synchronisable(creator)
+	{
+		RegisterObject ( Test );
+                setConfigValues();
+                registerVariables();
+		setObjectMode(0x3);
+	}
+
+	Test::~Test()
+	{
+
+	}
+
+	void Test::setConfigValues()
+	{
+		SetConfigValue ( v1, 1 ).callback ( this, &Test::checkV1 );
+                SetConfigValue ( v2, 2 ).callback ( this, &Test::checkV2 );
+                SetConfigValue ( v3, 3 ).callback ( this, &Test::checkV3 );
+	}
+
+
+	void Test::registerVariables()
+	{
+		REGISTERDATA ( v1,network::direction::toclient, new network::NetworkCallback<Test> ( this, &Test::checkV1 ) );
+                REGISTERDATA ( v2,network::direction::toserver, new network::NetworkCallback<Test> ( this, &Test::checkV2 ) );
+		REGISTERDATA ( v3,network::direction::bidirectional, new network::NetworkCallback<Test> ( this, &Test::checkV3 ) );
+	}
+
+        void Test::checkV1(){
+                COUT(1) << "V1 changed: " << v1 << std::endl;
+        }
+
+        void Test::checkV2(){
+                COUT(1) << "V2 changed: " << v2 << std::endl;
+        }
+
+        void Test::checkV3(){
+                COUT(1) << "V3 changed: " << v3 << std::endl;
+        }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/Test.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/Test.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Test.h	(revision 2122)
@@ -0,0 +1,62 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oli Scheuss
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Test_H__
+#define _Test_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+#include "network/Synchronisable.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport Test: public BaseObject, public network::Synchronisable
+  {
+    public:
+      Test(BaseObject* creator);
+      virtual ~Test();
+
+      void setConfigValues();
+      void registerVariables();
+
+      void setV1(unsigned int value){ v1 = value; }
+      void setV2(unsigned int value){ v2 = value; }
+      void setV3(unsigned int value){ v3 = value; }
+
+      void checkV1();
+      void checkV2();
+      void checkV3();
+
+    private:
+      unsigned int v1;
+      unsigned int v2;
+      unsigned int v3;
+  };
+}
+
+#endif /* _Test_H__ */
Index: /code/branches/physics/src/orxonox/objects/Tickable.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/Tickable.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Tickable.cc	(revision 2122)
@@ -0,0 +1,43 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Tickable.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Registers the object in the Tickable-list
+    */
+    Tickable::Tickable()
+    {
+        RegisterRootObject(Tickable);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/Tickable.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/Tickable.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/Tickable.h	(revision 2122)
@@ -0,0 +1,68 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*!
+    @file Tickable.h
+    @brief Declaration of the Tickable interface.
+
+    The Tickable interface provides a tick(dt) function, that gets called every frame.
+    float dt is the time since the last frame in seconds.
+
+    Attention:
+    Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
+    parent::tick(dt) function explicitly in their implementation of tick(dt) because it's a virtual function.
+*/
+
+#ifndef _Tickable_H__
+#define _Tickable_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+#include "core/Super.h"
+
+namespace orxonox
+{
+    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
+    class _OrxonoxExport Tickable : virtual public OrxonoxClass
+    {
+        public:
+            /**
+                @brief Gets called every frame.
+                @param dt The time since the last frame in seconds
+            */
+            virtual void tick(float dt) = 0;
+
+        protected:
+            Tickable();
+    };
+
+    SUPER_FUNCTION(1, Tickable, tick, true);
+}
+
+#endif /* _Tickable_H__ */
Index: /code/branches/physics/src/orxonox/objects/controllers/Controller.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/controllers/Controller.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/controllers/Controller.cc	(revision 2122)
@@ -0,0 +1,49 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Controller.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    CreateUnloadableFactory(Controller);
+
+    Controller::Controller(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(Controller);
+
+        this->player_ = 0;
+        this->controllableEntity_ = 0;
+    }
+
+    Controller::~Controller()
+    {
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/controllers/Controller.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/controllers/Controller.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/controllers/Controller.h	(revision 2122)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Controller_H__
+#define _Controller_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Controller : public BaseObject
+    {
+        public:
+            Controller(BaseObject* creator);
+            virtual ~Controller();
+
+            inline void setPlayer(PlayerInfo* player)
+                { this->player_ = player; }
+            inline PlayerInfo* getPlayer() const
+                { return this->player_; }
+
+            virtual inline void setControllableEntity(ControllableEntity* entity)
+                { this->controllableEntity_ = entity; }
+            virtual inline ControllableEntity* getControllableEntity() const
+                { return this->controllableEntity_; }
+
+        protected:
+            PlayerInfo* player_;
+            ControllableEntity* controllableEntity_;
+    };
+}
+
+#endif /* _Controller_H__ */
Index: /code/branches/physics/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/controllers/HumanController.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/controllers/HumanController.cc	(revision 2122)
@@ -0,0 +1,131 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HumanController.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "objects/worldentities/ControllableEntity.h"
+
+namespace orxonox
+{
+    SetConsoleCommand(HumanController, moveFrontBack, true).setAsInputCommand();
+    SetConsoleCommand(HumanController, moveRightLeft, true).setAsInputCommand();
+    SetConsoleCommand(HumanController, moveUpDown,    true).setAsInputCommand();
+    SetConsoleCommand(HumanController, rotateYaw,     true).setAsInputCommand();
+    SetConsoleCommand(HumanController, rotatePitch,   true).setAsInputCommand();
+    SetConsoleCommand(HumanController, rotateRoll,    true).setAsInputCommand();
+    SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(HumanController, greet,         true);
+    SetConsoleCommand(HumanController, use,           true);
+    SetConsoleCommand(HumanController, switchCamera,  true);
+
+    CreateUnloadableFactory(HumanController);
+
+    HumanController* HumanController::localController_s = 0;
+
+    HumanController::HumanController(BaseObject* creator) : Controller(creator)
+    {
+        RegisterObject(HumanController);
+
+        HumanController::localController_s = this;
+    }
+
+    HumanController::~HumanController()
+    {
+        HumanController::localController_s = 0;
+    }
+
+    void HumanController::moveFrontBack(const Vector2& value)
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->moveFrontBack(value);
+    }
+
+    void HumanController::moveRightLeft(const Vector2& value)
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->moveRightLeft(value);
+    }
+
+    void HumanController::moveUpDown(const Vector2& value)
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->moveUpDown(value);
+    }
+
+    void HumanController::rotateYaw(const Vector2& value)
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->rotateYaw(value);
+    }
+
+    void HumanController::rotatePitch(const Vector2& value)
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->rotatePitch(value);
+    }
+
+    void HumanController::rotateRoll(const Vector2& value)
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->rotateRoll(value);
+    }
+
+    void HumanController::fire()
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->fire();
+    }
+
+    void HumanController::altFire()
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->altFire();
+    }
+
+    void HumanController::greet()
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->greet();
+    }
+
+    void HumanController::use()
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->use();
+    }
+
+    void HumanController::switchCamera()
+    {
+        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+            HumanController::localController_s->controllableEntity_->switchCamera();
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/controllers/HumanController.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/controllers/HumanController.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/controllers/HumanController.h	(revision 2122)
@@ -0,0 +1,65 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HumanController_H__
+#define _HumanController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "util/Math.h"
+#include "Controller.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HumanController : public Controller
+    {
+        public:
+            HumanController(BaseObject* creator);
+            virtual ~HumanController();
+
+            static void moveFrontBack(const Vector2& value);
+            static void moveRightLeft(const Vector2& value);
+            static void moveUpDown(const Vector2& value);
+
+            static void rotateYaw(const Vector2& value);
+            static void rotatePitch(const Vector2& value);
+            static void rotateRoll(const Vector2& value);
+
+            static void fire();
+            static void altFire();
+
+            static void greet();
+            static void use();
+            static void switchCamera();
+
+        private:
+            static HumanController* localController_s;
+    };
+}
+
+#endif /* _HumanController_H__ */
Index: /code/branches/physics/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/gametypes/Gametype.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/gametypes/Gametype.cc	(revision 2122)
@@ -0,0 +1,255 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Gametype.h"
+
+#include <cstdlib>
+#include <ctime>
+
+#include "core/CoreIncludes.h"
+#include "objects/infos/PlayerInfo.h"
+#include "objects/worldentities/pawns/Spectator.h"
+#include "objects/worldentities/SpawnPoint.h"
+
+#include "network/Host.h"
+
+namespace orxonox
+{
+    CreateUnloadableFactory(Gametype);
+
+    Gametype::Gametype(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(Gametype);
+
+        this->defaultControllableEntity_ = Class(Spectator);
+
+        this->bStarted_ = false;
+        this->bEnded_ = false;
+        this->bAutoStart_ = false;
+        this->bForceSpawn_ = false;
+
+        this->initialStartCountdown_ = 3;
+        this->startCountdown_ = 0;
+        this->bStartCountdownRunning_ = false;
+    }
+
+    void Gametype::tick(float dt)
+    {
+        if (this->bStartCountdownRunning_ && !this->bStarted_)
+            this->startCountdown_ -= dt;
+
+        if (!this->bStarted_)
+            this->checkStart();
+
+        this->assignDefaultPawnsIfNeeded();
+        this->spawnDeadPlayersIfRequested();
+    }
+
+    void Gametype::start()
+    {
+        COUT(0) << "game started" << std::endl;
+        this->bStarted_ = true;
+
+        this->spawnPlayersIfRequested();
+    }
+
+    void Gametype::end()
+    {
+        COUT(0) << "game ended" << std::endl;
+        this->bEnded_ = true;
+    }
+
+    void Gametype::playerEntered(PlayerInfo* player)
+    {
+        this->players_.insert(player);
+
+        std::string message = player->getName() + " entered the game";
+        COUT(0) << message << std::endl;
+        network::Host::Broadcast(message);
+    }
+
+    void Gametype::playerLeft(PlayerInfo* player)
+    {
+        std::set<PlayerInfo*>::iterator it = this->players_.find(player);
+        if (it != this->players_.end())
+        {
+            this->players_.erase(it);
+
+            std::string message = player->getName() + " left the game";
+            COUT(0) << message << std::endl;
+            network::Host::Broadcast(message);
+        }
+    }
+
+    void Gametype::playerSwitched(PlayerInfo* player, Gametype* newgametype)
+    {
+    }
+
+    void Gametype::playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype)
+    {
+    }
+
+    void Gametype::playerChangedName(PlayerInfo* player)
+    {
+        if (this->players_.find(player) != this->players_.end())
+        {
+            if (player->getName() != player->getOldName())
+            {
+                std::string message = player->getOldName() + " changed name to " + player->getName();
+                COUT(0) << message << std::endl;
+                network::Host::Broadcast(message);
+            }
+        }
+    }
+
+    void Gametype::pawnPreSpawn(Pawn* pawn)
+    {
+    }
+
+    void Gametype::pawnPostSpawn(Pawn* pawn)
+    {
+    }
+
+    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
+    {
+    }
+
+    void Gametype::playerScored(PlayerInfo* player)
+    {
+    }
+
+    SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const
+    {
+        if (this->spawnpoints_.size() > 0)
+        {
+            srand(time(0));
+            rnd();
+
+            unsigned int randomspawn = (unsigned int)rnd(this->spawnpoints_.size());
+            unsigned int index = 0;
+            for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
+            {
+                if (index == randomspawn)
+                    return (*it);
+
+                ++index;
+            }
+        }
+        return 0;
+    }
+
+    void Gametype::assignDefaultPawnsIfNeeded() const
+    {
+        for (std::set<PlayerInfo*>::const_iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+        {
+            if (!(*it)->getControllableEntity() && (!(*it)->isReadyToSpawn() || !this->bStarted_))
+            {
+                SpawnPoint* spawn = this->getBestSpawnPoint(*it);
+                if (spawn)
+                {
+                    // force spawn at spawnpoint with default pawn
+                    ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
+                    spawn->spawn(entity);
+                    (*it)->startControl(entity);
+                }
+                else
+                {
+                    COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
+                    abort();
+                }
+            }
+        }
+    }
+
+    void Gametype::checkStart()
+    {
+        if (!this->bStarted_)
+        {
+            if (this->bStartCountdownRunning_)
+            {
+                if (this->startCountdown_ <= 0)
+                {
+                    this->bStartCountdownRunning_ = false;
+                    this->startCountdown_ = 0;
+                    this->start();
+                }
+            }
+            else if (this->players_.size() > 0)
+            {
+                if (this->bAutoStart_)
+                {
+                    this->start();
+                }
+                else
+                {
+                    bool allplayersready = true;
+                    for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+                    {
+                        if (!(*it)->isReadyToSpawn())
+                            allplayersready = false;
+                    }
+                    if (allplayersready)
+                    {
+                        this->startCountdown_ = this->initialStartCountdown_;
+                        this->bStartCountdownRunning_ = true;
+                    }
+                }
+            }
+        }
+    }
+
+    void Gametype::spawnPlayersIfRequested()
+    {
+        for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+            if ((*it)->isReadyToSpawn() || this->bForceSpawn_)
+                this->spawnPlayer(*it);
+    }
+
+    void Gametype::spawnDeadPlayersIfRequested()
+    {
+        for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+            if (!(*it)->getControllableEntity())
+                if ((*it)->isReadyToSpawn() || this->bForceSpawn_)
+                    this->spawnPlayer(*it);
+    }
+
+    void Gametype::spawnPlayer(PlayerInfo* player)
+    {
+        SpawnPoint* spawnpoint = this->getBestSpawnPoint(player);
+        if (spawnpoint)
+        {
+            player->startControl(spawnpoint->spawn());
+        }
+        else
+        {
+            COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
+            abort();
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/gametypes/Gametype.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/gametypes/Gametype.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/gametypes/Gametype.h	(revision 2122)
@@ -0,0 +1,110 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Gametype_H__
+#define _Gametype_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+
+#include "core/BaseObject.h"
+#include "core/Identifier.h"
+#include "objects/worldentities/ControllableEntity.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Gametype : public BaseObject, public Tickable
+    {
+        friend class PlayerInfo;
+
+        public:
+            Gametype(BaseObject* creator);
+            virtual ~Gametype() {}
+
+            virtual void tick(float dt);
+
+            inline bool hasStarted() const
+                { return this->bStarted_; }
+            inline bool hasEnded() const
+                { return this->bEnded_; }
+
+            virtual void start();
+            virtual void end();
+            virtual void playerEntered(PlayerInfo* player);
+            virtual void playerLeft(PlayerInfo* player);
+            virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype);
+            virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype);
+            virtual void playerChangedName(PlayerInfo* player);
+
+            virtual void playerScored(PlayerInfo* player);
+
+            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
+            virtual void pawnPreSpawn(Pawn* pawn);
+            virtual void pawnPostSpawn(Pawn* pawn);
+
+            inline const std::set<PlayerInfo*>& getPlayers() const
+                { return this->players_; }
+
+            inline void registerSpawnPoint(SpawnPoint* spawnpoint)
+                { this->spawnpoints_.insert(spawnpoint); }
+
+            inline bool isStartCountdownRunning() const
+                { return this->bStartCountdownRunning_; }
+            inline float getStartCountdown() const
+                { return this->startCountdown_; }
+
+        private:
+            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
+
+            void addPlayer(PlayerInfo* player);
+            void removePlayer(PlayerInfo* player);
+
+            void assignDefaultPawnsIfNeeded() const;
+            void checkStart();
+            void spawnPlayer(PlayerInfo* player);
+            void spawnPlayersIfRequested();
+            void spawnDeadPlayersIfRequested();
+
+            bool bStarted_;
+            bool bEnded_;
+            bool bAutoStart_;
+            bool bForceSpawn_;
+
+            float initialStartCountdown_;
+            float startCountdown_;
+            bool bStartCountdownRunning_;
+
+            std::set<PlayerInfo*> players_;
+            std::set<SpawnPoint*> spawnpoints_;
+            SubclassIdentifier<ControllableEntity> defaultControllableEntity_;
+    };
+}
+
+#endif /* _Gametype_H__ */
Index: /code/branches/physics/src/orxonox/objects/infos/HumanPlayer.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/HumanPlayer.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/HumanPlayer.cc	(revision 2122)
@@ -0,0 +1,140 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HumanPlayer.h"
+
+#include "core/Core.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "network/ClientInformation.h"
+#include "network/Host.h"
+#include "objects/controllers/HumanController.h"
+#include "objects/gametypes/Gametype.h"
+
+namespace orxonox
+{
+    CreateUnloadableFactory(HumanPlayer);
+
+    HumanPlayer::HumanPlayer(BaseObject* creator) : PlayerInfo(creator)
+    {
+        RegisterObject(HumanPlayer);
+
+        this->server_ready_ = Core::isMaster();
+        this->client_ready_ = false;
+
+        this->bHumanPlayer_ = true;
+        this->defaultController_ = Class(HumanController);
+
+        this->setConfigValues();
+        this->registerVariables();
+    }
+
+    HumanPlayer::~HumanPlayer()
+    {
+    }
+
+    void HumanPlayer::setConfigValues()
+    {
+        SetConfigValue(nick_, "Player").callback(this, &HumanPlayer::configvaluecallback_changednick);
+    }
+
+    void HumanPlayer::registerVariables()
+    {
+        REGISTERSTRING(this->synchronize_nick_, network::direction::toserver, new network::NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
+
+        REGISTERDATA(this->clientID_,     network::direction::toclient, new network::NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
+        REGISTERDATA(this->server_ready_, network::direction::toclient, new network::NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_ready));
+        REGISTERDATA(this->client_ready_, network::direction::toserver, new network::NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_ready));
+    }
+
+    void HumanPlayer::configvaluecallback_changednick()
+    {
+        if (this->isLocalPlayer())
+        {
+            this->synchronize_nick_ = this->nick_;
+
+            if (Core::isMaster())
+                this->setName(this->nick_);
+        }
+    }
+
+    void HumanPlayer::networkcallback_changednick()
+    {
+        this->setName(this->synchronize_nick_);
+    }
+
+    void HumanPlayer::networkcallback_clientIDchanged()
+    {
+        if (this->clientID_ == network::Host::getPlayerID())
+        {
+            this->bLocalPlayer_ = true;
+            this->synchronize_nick_ = this->nick_;
+            this->client_ready_ = true;
+
+            if (!Core::isMaster())
+                this->setObjectMode(network::direction::bidirectional);
+            else
+                this->setName(this->nick_);
+
+            this->createController();
+        }
+    }
+
+    void HumanPlayer::networkcallback_server_ready()
+    {
+        this->client_ready_ = true;
+    }
+
+    void HumanPlayer::networkcallback_client_ready()
+    {
+        if (this->getGametype())
+            this->getGametype()->playerEntered(this);
+    }
+
+    bool HumanPlayer::isReady() const
+    {
+        return (this->server_ready_ && this->client_ready_);
+    }
+
+    float HumanPlayer::getPing() const
+    {
+        return network::ClientInformation::findClient(this->getClientID())->getRTT();
+    }
+
+    float HumanPlayer::getPacketLossRatio() const
+    {
+        return network::ClientInformation::findClient(this->getClientID())->getPacketLoss();
+    }
+
+    void HumanPlayer::setClientID(unsigned int clientID)
+    {
+        this->clientID_ = clientID;
+        this->networkcallback_clientIDchanged();
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/infos/HumanPlayer.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/HumanPlayer.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/HumanPlayer.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HumanPlayer_H__
+#define _HumanPlayer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "PlayerInfo.h"
+#include "core/Identifier.h"
+#include "objects/controllers/Controller.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HumanPlayer : public PlayerInfo
+    {
+        public:
+            HumanPlayer(BaseObject* creator);
+            virtual ~HumanPlayer();
+
+            void registerVariables();
+            void setConfigValues();
+
+            bool isReady() const;
+            float getPing() const;
+            float getPacketLossRatio() const;
+
+            void setClientID(unsigned int clientID);
+
+        protected:
+            void configvaluecallback_changednick();
+            void networkcallback_changednick();
+            void networkcallback_clientIDchanged();
+            void networkcallback_server_ready();
+            void networkcallback_client_ready();
+
+            std::string nick_;
+            std::string synchronize_nick_;
+            bool server_ready_;
+            bool client_ready_;
+    };
+}
+
+#endif /* _HumanPlayer_H__ */
Index: /code/branches/physics/src/orxonox/objects/infos/Info.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/Info.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/Info.cc	(revision 2122)
@@ -0,0 +1,40 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Info.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    Info::Info(BaseObject* creator) : BaseObject(creator), network::Synchronisable(creator)
+    {
+        RegisterObject(Info);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/infos/Info.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/Info.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/Info.h	(revision 2122)
@@ -0,0 +1,47 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Info_H__
+#define _Info_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "network/Synchronisable.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Info : public BaseObject, public network::Synchronisable
+    {
+        public:
+            Info(BaseObject* creator);
+            virtual ~Info() {}
+    };
+}
+
+#endif /* _Info_H__ */
Index: /code/branches/physics/src/orxonox/objects/infos/Level.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/Level.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/Level.cc	(revision 2122)
@@ -0,0 +1,148 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Level.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Loader.h"
+#include "core/XMLFile.h"
+#include "core/Template.h"
+
+#include "Settings.h"
+#include "LevelManager.h"
+#include "PlayerInfo.h"
+#include "objects/gametypes/Gametype.h"
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    CreateFactory(Level);
+
+    Level::Level(BaseObject* creator) : Info(creator)
+    {
+        RegisterObject(Level);
+
+        this->registerVariables();
+        this->xmlfilename_ = this->getFilename();
+
+        if (this->xmlfilename_.length() >= Settings::getDataPath().length())
+            this->xmlfilename_ = this->xmlfilename_.substr(Settings::getDataPath().length());
+    }
+
+    Level::~Level()
+    {
+        if (this->isInitialized())
+        {
+            LevelManager::getInstance().releaseActivity(this);
+
+            if (this->xmlfile_)
+                Loader::unload(this->xmlfile_);
+        }
+    }
+
+    void Level::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Level, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
+        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
+
+        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
+    }
+
+    void Level::registerVariables()
+    {
+        REGISTERSTRING(this->xmlfilename_, network::direction::toclient, new network::NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
+        REGISTERSTRING(this->name_,        network::direction::toclient, new network::NetworkCallback<Level>(this, &Level::changedName));
+        REGISTERSTRING(this->description_, network::direction::toclient);
+    }
+
+    void Level::networkcallback_applyXMLFile()
+    {
+        COUT(0) << "Loading level \"" << this->xmlfilename_ << "\"..." << std::endl;
+
+        ClassTreeMask mask;
+        mask.exclude(Class(BaseObject));
+        mask.include(Class(Template));
+
+        this->xmlfile_ = new XMLFile(Settings::getDataPath() + this->xmlfilename_, mask);
+
+        Loader::open(this->xmlfile_);
+    }
+
+    void Level::setGametypeString(const std::string& gametype)
+    {
+        Identifier* identifier = ClassByString(gametype);
+        if (identifier && identifier->isA(Class(Gametype)))
+        {
+            this->gametype_ = gametype;
+
+            Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
+            this->setGametype(rootgametype);
+
+            for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+                (*it)->setGametype(rootgametype);
+
+            LevelManager::getInstance().requestActivity(this);
+        }
+    }
+
+
+    void Level::addObject(BaseObject* object)
+    {
+        this->objects_.push_back(object);
+        object->setGametype(this->getGametype());
+    }
+
+    BaseObject* Level::getObject(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
+
+    void Level::playerEntered(PlayerInfo* player)
+    {
+        COUT(3) << "player entered level" << std::endl;
+        player->setGametype(this->getGametype());
+    }
+
+    void Level::playerLeft(PlayerInfo* player)
+    {
+        COUT(3) << "player left level" << std::endl;
+        player->setGametype(0);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/infos/Level.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/Level.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/Level.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Level_H__
+#define _Level_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Info.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Level : public Info
+    {
+        public:
+            Level(BaseObject* creator);
+            virtual ~Level();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            inline void setDescription(const std::string& description)
+                { this->description_ = description; }
+            inline const std::string& getDescription() const
+                { return this->description_; }
+
+            void playerEntered(PlayerInfo* player);
+            void playerLeft(PlayerInfo* player);
+
+        private:
+            void addObject(BaseObject* object);
+            BaseObject* getObject(unsigned int index) const;
+
+            void setGametypeString(const std::string& gametype);
+            inline const std::string& getGametypeString() const
+                { return this->gametype_; }
+
+            void networkcallback_applyXMLFile();
+
+            std::string            description_;
+            std::string            gametype_;
+            std::string            xmlfilename_;
+            XMLFile*               xmlfile_;
+            std::list<BaseObject*> objects_;
+    };
+}
+
+#endif /* _Level_H__ */
Index: /code/branches/physics/src/orxonox/objects/infos/PlayerInfo.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/PlayerInfo.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/PlayerInfo.cc	(revision 2122)
@@ -0,0 +1,164 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <cassert>
+
+#include "OrxonoxStableHeaders.h"
+#include "PlayerInfo.h"
+
+#include "core/CoreIncludes.h"
+#include "network/ClientInformation.h"
+#include "objects/gametypes/Gametype.h"
+
+namespace orxonox
+{
+    PlayerInfo::PlayerInfo(BaseObject* creator) : Info(creator)
+    {
+        RegisterObject(PlayerInfo);
+
+        this->clientID_ = network::CLIENTID_UNKNOWN;
+        this->bHumanPlayer_ = false;
+        this->bLocalPlayer_ = false;
+        this->bReadyToSpawn_ = false;
+        this->controller_ = 0;
+        this->controllableEntity_ = 0;
+        this->controllableEntityID_ = network::CLIENTID_UNKNOWN;
+
+        this->registerVariables();
+    }
+
+    PlayerInfo::~PlayerInfo()
+    {
+        if (this->isInitialized())
+        {
+            this->stopControl(this->controllableEntity_);
+
+            if (this->controller_)
+            {
+                delete this->controller_;
+                this->controller_ = 0;
+            }
+        }
+    }
+
+    void PlayerInfo::registerVariables()
+    {
+        REGISTERSTRING(this->name_,                 network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
+        REGISTERDATA  (this->controllableEntityID_, network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
+        REGISTERDATA  (this->bReadyToSpawn_,        network::direction::toserver);
+    }
+
+    void PlayerInfo::changedName()
+    {
+        if (this->isReady() && this->getGametype())
+            this->getGametype()->playerChangedName(this);
+    }
+
+    void PlayerInfo::changedGametype()
+    {
+        if (this->isReady())
+        {
+            if (this->getOldGametype())
+            {
+                if (this->getGametype())
+                    this->getOldGametype()->playerSwitched(this, this->getGametype());
+                else
+                    this->getOldGametype()->playerLeft(this);
+            }
+
+            if (this->getGametype())
+            {
+                if (this->getOldGametype())
+                    this->getGametype()->playerSwitchedBack(this, this->getOldGametype());
+                else
+                    this->getGametype()->playerEntered(this);
+            }
+        }
+    }
+
+    void PlayerInfo::createController()
+    {
+        this->controller_ = this->defaultController_.fabricate(this);
+        assert(this->controller_);
+        this->controller_->setPlayer(this);
+        if (this->controllableEntity_)
+            this->controller_->setControllableEntity(this->controllableEntity_);
+    }
+
+    void PlayerInfo::startControl(ControllableEntity* entity)
+    {
+        if (this->controllableEntity_)
+            this->stopControl(this->controllableEntity_);
+
+        this->controllableEntity_ = entity;
+
+        if (entity)
+        {
+            this->controllableEntityID_ = entity->getObjectID();
+            entity->setPlayer(this);
+            this->bReadyToSpawn_ = false;
+        }
+        else
+        {
+            this->controllableEntityID_ = network::OBJECTID_UNKNOWN;
+        }
+
+        if (this->controller_)
+            this->controller_->setControllableEntity(entity);
+    }
+
+    void PlayerInfo::stopControl(ControllableEntity* entity, bool callback)
+    {
+        if (entity && this->controllableEntity_ == entity)
+        {
+            this->controllableEntity_ = 0;
+            this->controllableEntityID_ = network::OBJECTID_UNKNOWN;
+
+            if (this->controller_)
+                this->controller_->setControllableEntity(0);
+
+            if (callback)
+                entity->removePlayer();
+        }
+    }
+
+    void PlayerInfo::networkcallback_changedcontrollableentityID()
+    {
+        if (this->controllableEntityID_ != network::OBJECTID_UNKNOWN)
+        {
+            Synchronisable* temp = Synchronisable::getSynchronisable(this->controllableEntityID_);
+            ControllableEntity* entity = dynamic_cast<ControllableEntity*>(temp);
+
+            this->startControl(entity);
+        }
+        else
+        {
+            this->stopControl(this->controllableEntity_);
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/infos/PlayerInfo.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/infos/PlayerInfo.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/infos/PlayerInfo.h	(revision 2122)
@@ -0,0 +1,88 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _PlayerInfo_H__
+#define _PlayerInfo_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Info.h"
+#include "core/Identifier.h"
+#include "objects/controllers/Controller.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport PlayerInfo : public Info
+    {
+        public:
+            PlayerInfo(BaseObject* creator);
+            virtual ~PlayerInfo();
+
+            void registerVariables();
+
+            virtual void changedName();
+            virtual void changedGametype();
+
+            inline bool isHumanPlayer() const
+                { return this->bHumanPlayer_; }
+            inline bool isLocalPlayer() const
+                { return this->bLocalPlayer_; }
+            inline unsigned int getClientID() const
+                { return this->clientID_; }
+            inline bool isReadyToSpawn() const
+                { return this->bReadyToSpawn_; }
+
+            virtual bool isReady() const = 0;
+            virtual float getPing() const = 0;
+            virtual float getPacketLossRatio() const = 0;
+
+            inline void setReadyToSpawn(bool bReady)
+                { this->bReadyToSpawn_ = bReady; }
+
+            void startControl(ControllableEntity* entity);
+            void stopControl(ControllableEntity* entity, bool callback = true);
+
+            inline ControllableEntity* getControllableEntity() const
+                { return this->controllableEntity_; }
+
+        protected:
+            void createController();
+            void networkcallback_changedcontrollableentityID();
+
+            bool bHumanPlayer_;
+            bool bLocalPlayer_;
+            bool bReadyToSpawn_;
+            SubclassIdentifier<Controller> defaultController_;
+            Controller* controller_;
+            ControllableEntity* controllableEntity_;
+            unsigned int controllableEntityID_;
+            unsigned int clientID_;
+    };
+}
+
+#endif /* _PlayerInfo_H__ */
Index: /code/branches/physics/src/orxonox/objects/pickup/ShipEquipment.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/pickup/ShipEquipment.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/pickup/ShipEquipment.h	(revision 2122)
@@ -0,0 +1,45 @@
+
+#ifndef _ShipEquipment_H__
+#define _ShipEquipment_H__
+#include <string>
+#include <multimap>
+
+
+/*
+multimap<std::string, Item*> equipment_;
+equipment_.insert(pair<std::string, Item*>("Weapon", new Item()));*/
+
+
+namespace orxonox
+{
+    class _OrxonoxExport ShipEquipment
+    {
+        public:
+            void AddItem(Shipitem toAddItem);
+            void RemoveItem(Shipitem toRemoveItem);
+            bool CheckifValid(Shipitem toBeChecked);
+            int
+
+        private:
+            std::multimap<std::string, Item*> Equipment;
+    };
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif
Index: /code/branches/physics/src/orxonox/objects/pickup/ShipEquipmentClasses.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/pickup/ShipEquipmentClasses.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/pickup/ShipEquipmentClasses.cc	(revision 2122)
@@ -0,0 +1,92 @@
+namespace orxonox
+{
+    const int maxweapons_ =2; //Weaponslots	 (provisorisch)
+    const int maxslots_= 50; //Inventoryslots (provisorisch)
+
+
+    bool ShipEquipment::CheckifSpace()
+    {
+        if((Usable.size()+Trunk.size())>=maxslots_)
+            return false;
+        return true;
+    }
+
+    /* Checks if the Ship can pick an Item up. Permanents will give a "false" back unless the Ship doesnt carry a Item for that Slot (2 Weaponslots) yet.Others will be picked up unless there is no Space in the Trunk.*/
+
+    bool ShipEquipment::CheckifValid(Shipitem* toBeChecked)
+    {
+        switch(toBeChecked.CheckType())
+        {
+        case Powerups:
+            activatePowerUp(); //gibts noch nicht
+            return true;
+        case Permanent:
+            switch (toBeChecked.CheckSubType())
+            {
+            case Weapon:
+                int weaponcheck=0;
+                multimap<string, ShipItem*>::iterator it;
+                for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
+                    if((*it).second->CheckSubType()==Weapon)
+                        weaponcheck++;
+                };
+                if (weaponcheck>=maxweapons_){
+                    weaponcheck=0;
+                    return false;
+                }
+                break;
+            case Thrusters:
+                multimap<string, ShipItem*>::iterator it;
+                for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
+                    if((*it).second->CheckSubType()==Thrusters)
+                        return false;
+                }
+                break;
+            case Shields:
+                multimap<string, ShipItem*>::iterator it;
+                for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
+                    if((*it).second->CheckSubType()==Shields)
+                        return false;
+                }
+                break;
+            case Armor:
+                multimap<string, ShipItem*>::iterator it;
+                for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
+                    if((*it).second->CheckSubType()==Armor)
+                        return false;
+                }
+                break;
+            default:;
+            }
+        case Useable:
+            return CheckifSpace();
+        case default:;
+        }
+        return true;
+    }
+
+    /*Adds the Item to the Ship*/
+    void ShipEquipment::AddItem(Shipitem* toAddItem)
+    {
+        if(CheckifValid(toAddItem)==true)
+        {
+            switch(toAddItem.CheckType())
+            {
+                case Permanent:
+                    Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
+                    break;
+                case Usable:
+                    Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
+                    break;
+                case Trunk:
+                    Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
+                    break;
+            }
+        }
+        else if(toAddItem.CheckType()==Permanent)
+        {
+            if(CheckifSpace()==true)
+                Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/pickup/ShipEquipmentClasses.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/pickup/ShipEquipmentClasses.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/pickup/ShipEquipmentClasses.h	(revision 2122)
@@ -0,0 +1,50 @@
+
+#ifndef _ShipEquipment_H__
+#define _ShipEquipment_H__
+#include <string>
+#include "SpaceShip.h"
+#include <map>
+
+
+/*
+multimap<std::string, Item*> equipment_;
+equipment_.insert(pair<std::string, Item*>("Weapon", new Item()));*/
+
+
+/*          std::map<std::itemtype, Item*> EQClasses;
+            EQClasses["jacke"] = 0;
+            Item* item = itemMap_["jacke"];
+
+           if (itemMap_["jacke"])
+           if (itemMap_.find("jacke") != itemMap_.end()) */
+namespace orxonox
+{
+    class _OrxonoxExport ShipEquipment
+    {
+        public:
+            void AddItem(Shipitem* toAddItem);
+            void RemoveItem(Shipitem* toRemoveItem);
+            bool CheckifValid(Shipitem* toBeChecked);
+            bool CheckifSpace();
+
+        private:
+            multimap<std::string, ShipItem*> Equipment;
+            multimap<std::string, ShipItem*> Usable;
+            multimap<std::string, ShipItem*> Trunk;
+    };
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif
Index: /code/branches/physics/src/orxonox/objects/pickup/ShipItem.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/pickup/ShipItem.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/pickup/ShipItem.cc	(revision 2122)
@@ -0,0 +1,14 @@
+#include "Shipitem.h"
+
+namespace orxonox
+{
+    itemtype ShipItem::CheckType()
+    {
+        return this.type;
+    }
+
+    subItemTypePermanent CheckSubType()
+    {
+        return this.subtype_permanent;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/pickup/ShipItem.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/pickup/ShipItem.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/pickup/ShipItem.h	(revision 2122)
@@ -0,0 +1,92 @@
+#ifndef _ShipItems_H__
+#define _ShipItems_H__
+#include <string>
+#include "SpaceShip.h"
+#include <map>
+#include "ShipEquipmentClasses.h"
+
+
+
+namespace orxonox
+{
+    class _OrxonoxExport ShipItem
+    {
+        enum itemType //Diffrent Types of Items
+        {
+            Useable,
+            Powerups,
+            Permanent
+        };
+
+        public:
+            itemType CheckType();
+            virtual
+
+        private:
+            itemType type;
+            string itemname;
+    };
+
+
+    /* Useables are Items the Player can choose when to activate and then show an instant action/effect
+     * or for a certain duration */
+    class _OrxonoxExport Useable : public ShipItem
+    {
+        enum subItemTypeUseable //Diffrent Types of Items of the Type Useable
+        {
+            Rockets,
+            Repairkits,
+            Triggers,		//trigger events usable by the player (Quests f.exp.)
+            Boosters,
+            Shields,
+            Appearance,
+        };
+
+        public:
+            //subItemTypeUseable CheckSubType();
+
+        private:
+            subItemTypeUseable subtype_usable;
+    };
+
+    /* Permanents are Items, that effect the Player or his Ship from the instance he picks them up
+       until he drops them again */
+    class _OrxonoxExport Permanent : public ShipItem
+    {
+        enum subItemTypePermanent //Diffrent Types of Items of the Type Permanent
+        {
+            Weapon,
+            Thrusters,
+            Shields,
+            Armor
+        };
+
+        public:
+            subItemTypePermanent CheckSubType();
+
+        private:
+            subItemTypePermanent subtype_permanent;
+    };
+
+    // Powerups effect the Player right after he picks them up for a certain Duration /or permanently.
+    class _OrxonoxExport Powerups : public ShipItem
+    {
+        enum subItem TypePowerups //Diffrent Types of Items of the Type Powerups
+        {
+            Weapon,
+            Boosters,
+            Shields,
+            Repairkits,
+            Appearance,
+            Trigger
+        };
+
+        public:
+            //subItemTypePowerups CheckSubType();
+
+        private:
+            subItemTypePowerups subtype_powerups;
+    };
+}
+
+#endif
Index: /code/branches/physics/src/orxonox/objects/pickup/Usable.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/pickup/Usable.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/pickup/Usable.h	(revision 2122)
@@ -0,0 +1,12 @@
+/*enum subItemType{ Subtypes (thrusters etc)*/
+
+namespace orxonox
+{
+    class _OrxonoxExport Usable: public ShipItem
+    {
+        public:
+            subtypeusable CheckSubType();
+        private:
+            subtypeusable subtype;
+    };
+}
Index: /code/branches/physics/src/orxonox/objects/quest/AddQuest.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/AddQuest.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/AddQuest.cc	(revision 2122)
@@ -0,0 +1,97 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "AddQuest.h"
+
+#include <string>
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+#include "QuestManager.h"
+#include "Quest.h"
+
+namespace orxonox {
+
+    CreateFactory(AddQuest);
+
+
+    AddQuest::AddQuest(BaseObject* creator) : ChangeQuestStatus(creator)
+    {
+        RegisterObject(AddQuest);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    AddQuest::~AddQuest()
+    {
+    }
+
+    void AddQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(AddQuest, XMLPort, xmlelement, mode);
+
+    }
+
+    /**
+    @brief
+        Invokes the effect.
+    @param player
+        The player the effect is invoked on.
+    @return
+        Returns true if the effect was successfully invoked.
+    */
+    bool AddQuest::invoke(Player* player)
+    {
+        if(player == NULL)
+        {
+            COUT(2) << "Input player is NULL." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            Quest* quest = QuestManager::findQuest(this->getQuestId());
+            if(!quest->start(player))
+            {
+               return false;
+            }
+        }
+        catch(const orxonox::Exception& ex)
+        {
+            COUT(2) << ex.getFullDescription() << std::endl;
+            return false;
+        }
+
+        return true;
+    }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/AddQuest.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/AddQuest.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/AddQuest.h	(revision 2122)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AddQuest_H__
+#define _AddQuest_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "core/XMLPort.h"
+#include "ChangeQuestStatus.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Adds a quest, resp. changes the quests status to active.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport AddQuest : public ChangeQuestStatus
+    {
+        public:
+            AddQuest(BaseObject* creator);
+            virtual ~AddQuest();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual bool invoke(Player* player); //!< Invokes the effect.
+
+    };
+
+}
+
+#endif /* _AddQuest_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/AddQuestHint.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/AddQuestHint.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/AddQuestHint.cc	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "AddQuestHint.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+#include "QuestManager.h"
+#include "QuestItem.h"
+#include "QuestHint.h"
+
+namespace orxonox {
+
+    CreateFactory(AddQuestHint);
+
+    AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator)
+    {
+        RegisterObject(AddQuestHint);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    AddQuestHint::~AddQuestHint()
+    {
+    }
+
+    void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(AddQuestHint, XMLPort, xmlelement, mode);
+
+        XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
+
+    }
+
+    inline void AddQuestHint::setHintId(const std::string & id)
+    {
+        if(!QuestItem::isId(id))
+        {
+            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
+            return;
+        }
+        this->hintId_ = id;
+    }
+
+    /**
+    @brief
+        Invokes the effect.
+    @param player
+        The player.
+    @return
+        Returns true if the effect was successfully invoked.
+    */
+    bool AddQuestHint::invoke(Player* player)
+    {
+        if(player == NULL)
+        {
+            COUT(2) << "The input player is NULL." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            QuestHint* hint = QuestManager::findHint(this->hintId_);
+            if(!hint->activate(player))
+            {
+                return false;
+            }
+        }
+        catch(const Exception& e)
+        {
+           COUT(2) << e.getFullDescription() << std::endl;
+           return false;
+        }
+
+        return true;
+
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/quest/AddQuestHint.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/AddQuestHint.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/AddQuestHint.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AddQuestHint_H__
+#define _AddQuestHint_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "QuestEffect.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Adds a QuestHint, resp. Activates the QuestHint.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport AddQuestHint : public QuestEffect
+    {
+        public:
+            AddQuestHint(BaseObject* creator);
+            virtual ~AddQuestHint();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual bool invoke(Player* player); //!< Invokes the effect.
+
+        private:
+            std::string hintId_;
+
+            inline const std::string & getHintId(void) const
+                { return this->hintId_; }
+            void setHintId(const std::string & id);
+
+    };
+
+}
+
+#endif /* _AddQuestHint_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/AddReward.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/AddReward.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/AddReward.cc	(revision 2122)
@@ -0,0 +1,105 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "AddReward.h"
+
+#include "core/CoreIncludes.h"
+
+#include "Rewardable.h"
+
+namespace orxonox {
+
+    CreateFactory(AddReward);
+
+    AddReward::AddReward(BaseObject* creator) : QuestEffect(creator)
+    {
+        RegisterObject(AddReward);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    AddReward::~AddReward()
+    {
+    }
+
+    void AddReward::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(AddReward, XMLPort, xmlelement, mode);
+
+        XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
+
+    }
+
+    /**
+    @brief
+        Initializes the object. Needs to be called first by every constructor of this class.
+    */
+    void AddReward::initialize(void)
+    {
+        RegisterObject(AddReward);
+    }
+
+    const Rewardable* AddReward::getRewardables(unsigned int index) const
+    {
+        int i = index;
+        for (std::list<Rewardable*>::const_iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward)
+        {
+            if(i == 0)
+            {
+               return *reward;
+            }
+            i--;
+        }
+        return NULL;
+    }
+
+    /**
+    @brief
+        Invokes the effect.
+    @param player
+        The player.
+    @return
+        Returns true if the effect was invoked successfully.
+    */
+    bool AddReward::invoke(Player* player)
+    {
+        bool check = true;
+        for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
+        {
+            check = check && (*reward)->reward(player);
+        }
+
+        return check;
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/AddReward.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/AddReward.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/AddReward.h	(revision 2122)
@@ -0,0 +1,72 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AddReward_H__
+#define _AddReward_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+
+#include "core/XMLPort.h"
+#include "QuestEffect.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Adds a list of rewards to a player.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport AddReward : public QuestEffect
+    {
+        public:
+            AddReward(BaseObject* creator);
+            virtual ~AddReward();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual bool invoke(Player* player); //!< Invokes the effect.
+
+        private:
+            std::list<Rewardable*> rewards_;
+
+            void initialize(void); //!< Initializes the object.
+
+            inline void addRewardable(Rewardable* reward)
+                { this->rewards_.push_back(reward); }
+            const Rewardable* getRewardables(unsigned int index) const;
+
+    };
+
+}
+
+#endif /* _AddReward_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/ChangeQuestStatus.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/ChangeQuestStatus.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/ChangeQuestStatus.cc	(revision 2122)
@@ -0,0 +1,68 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ChangeQuestStatus.h"
+
+#include "core/CoreIncludes.h"
+
+#include "QuestItem.h"
+
+namespace orxonox {
+
+    ChangeQuestStatus::ChangeQuestStatus(BaseObject* creator) : QuestEffect(creator)
+    {
+        RegisterObject(ChangeQuestStatus);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    ChangeQuestStatus::~ChangeQuestStatus()
+    {
+    }
+
+    void ChangeQuestStatus::setQuestId(const std::string & id)
+    {
+        if(!QuestItem::isId(id))
+        {
+            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
+            return;
+        }
+        this->questId_ = id;
+    }
+
+    void ChangeQuestStatus::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(ChangeQuestStatus, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ChangeQuestStatus, "questId", setQuestId, getQuestId, xmlelement, mode);
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/ChangeQuestStatus.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/ChangeQuestStatus.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/ChangeQuestStatus.h	(revision 2122)
@@ -0,0 +1,72 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ChangeQuestStatus_H__
+#define _ChangeQuestStatus_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "core/XMLPort.h"
+#include "QuestEffect.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        An effect which changes a quests status.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport ChangeQuestStatus : public QuestEffect
+    {
+        public:
+            ChangeQuestStatus(BaseObject* creator);
+            virtual ~ChangeQuestStatus();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual bool invoke(Player* player) = 0; //!< Invokes the effect.
+
+        protected:
+            inline const std::string & getQuestId(void) const //!< Returns the quest id.
+                { return this->questId_; }
+
+            std::string questId_; //!< The id of the quest the status should be changed of.
+
+        private:
+            void setQuestId(const std::string & id);
+
+    };
+
+}
+
+#endif /* _ChangeQuestStatus_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/CompleteQuest.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/CompleteQuest.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/CompleteQuest.cc	(revision 2122)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "CompleteQuest.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+#include "QuestManager.h"
+#include "Quest.h"
+
+namespace orxonox {
+
+    CreateFactory(CompleteQuest);
+
+    CompleteQuest::CompleteQuest(BaseObject* creator) : ChangeQuestStatus(creator)
+    {
+        RegisterObject(CompleteQuest);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    CompleteQuest::~CompleteQuest()
+    {
+    }
+
+    void CompleteQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(CompleteQuest, XMLPort, xmlelement, mode);
+    }
+
+    /**
+    @brief
+        Invokes the effect.
+    @param player
+        The player the effect is invoked on.
+    @return
+        Returns true if the effect was invoked successfully.
+    */
+    bool CompleteQuest::invoke(Player* player)
+    {
+        if(player == NULL)
+        {
+            COUT(2) << "Input player is NULL." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            Quest* quest = QuestManager::findQuest(this->getQuestId());
+            if(!quest->complete(player))
+            {
+               return false;
+            }
+        }
+        catch(const Exception& e)
+        {
+            COUT(2) << e.getFullDescription() << std::endl;
+            return false;
+        }
+
+        return true;
+    }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/CompleteQuest.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/CompleteQuest.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/CompleteQuest.h	(revision 2122)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CompleteQuest_H__
+#define _CompleteQuest_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "core/XMLPort.h"
+#include "ChangeQuestStatus.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Completes a quest.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport CompleteQuest : public ChangeQuestStatus
+    {
+        public:
+            CompleteQuest(BaseObject* creator);
+            virtual ~CompleteQuest();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual bool invoke(Player* player); //!< Invokes the effect.
+
+    };
+
+}
+
+#endif /* _CompleteQuest_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/FailQuest.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/FailQuest.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/FailQuest.cc	(revision 2122)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "FailQuest.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+#include "QuestManager.h"
+#include "Quest.h"
+
+namespace orxonox {
+
+    CreateFactory(FailQuest);
+
+    FailQuest::FailQuest(BaseObject* creator) : ChangeQuestStatus(creator)
+    {
+        RegisterObject(FailQuest);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    FailQuest::~FailQuest()
+    {
+    }
+
+    void FailQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(FailQuest, XMLPort, xmlelement, mode);
+    }
+
+    /**
+    @brief
+        Invokes the effect.
+    @param player
+        The player the effect is invoked on.
+    @return
+        Returns true if the effect was invoked successfully.
+    */
+    bool FailQuest::invoke(Player* player)
+    {
+        if(player == NULL)
+        {
+            COUT(2) << "Input player is NULL." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            Quest* quest = QuestManager::findQuest(this->getQuestId());
+            if(!quest->fail(player))
+            {
+               return false;
+            }
+        }
+        catch(const Exception& e)
+        {
+            COUT(2) << e.getFullDescription() << std::endl;
+            return false;
+        }
+
+        return true;
+    }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/FailQuest.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/FailQuest.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/FailQuest.h	(revision 2122)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _FailQuest_H__
+#define _FailQuest_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "core/XMLPort.h"
+#include "ChangeQuestStatus.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Fails a quest.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport FailQuest : public ChangeQuestStatus
+    {
+        public:
+            FailQuest(BaseObject* creator);
+            virtual ~FailQuest();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual bool invoke(Player* player); //!< Invokes the effect.
+
+    };
+
+}
+
+#endif /* _FailQuest_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/GlobalQuest.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/GlobalQuest.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/GlobalQuest.cc	(revision 2122)
@@ -0,0 +1,173 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GlobalQuest.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+namespace orxonox {
+
+    CreateFactory(GlobalQuest);
+
+    /**
+    @brief
+        Constructor.
+    */
+    GlobalQuest::GlobalQuest(BaseObject* creator) : Quest(creator)
+    {
+        RegisterObject(GlobalQuest);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    GlobalQuest::~GlobalQuest()
+    {
+
+    }
+
+    void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(GlobalQuest, XMLPort, xmlelement, mode);
+
+        COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
+    }
+
+    void GlobalQuest::initialize(void)
+    {
+        RegisterObject(GlobalQuest);
+    }
+
+    /**
+    @brief
+        Checks whether the quest can be started.
+    @param player
+        The player for whom is to be checked.
+    @return
+        Returns true if the quest can be started, false if not.
+    @throws
+        Throws an exception if either isInactive() of isActive() throws one.
+    */
+    bool GlobalQuest::isStartable(const Player* player) const
+    {
+        return this->isInactive(player) ||  this->isActive(player);
+    }
+
+    /**
+    @brief
+        Checks whether the quest can be failed.
+    @param player
+        The player for whom is to be checked.
+    @return
+        Returns true if the quest can be failed, false if not.
+    @throws
+        Throws an Exception if isActive() throws one.
+    */
+    bool GlobalQuest::isFailable(const Player* player) const
+    {
+        return this->isActive(player);
+
+    }
+
+    /**
+    @brief
+        Checks whether the quest can be completed.
+    @param player
+        The player for whom is to be checked.
+    @return
+        Returns true if the quest can be completed, false if not.
+    @throws
+        Throws an Exception if isActive() throws one.
+    */
+    bool GlobalQuest::isCompletable(const Player* player) const
+    {
+        return this->isActive(player);
+    }
+
+    /**
+    @brief
+        Returns the status of the quest for a specific player.
+    @param player
+        The player.
+    @throws
+        Throws an Exception if player is NULL.
+    */
+    questStatus::Enum GlobalQuest::getStatus(const Player* player) const
+    {
+        if(player == NULL)
+        {
+            ThrowException(Argument, "The input Player* is NULL.");
+        }
+
+        //TDO: Does this really work???
+        std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player);
+        if (it != this->players_.end())
+        {
+            return this->status_;
+        }
+        else
+        {
+           return questStatus::inactive;
+        }
+
+    }
+
+    /**
+    @brief
+        Sets the status for a specific player.
+        But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing.
+    @param player
+        The player.
+    @param status
+        The status to be set.
+    @return
+        Returns false if player is NULL.
+    */
+    bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status)
+    {
+        if(player == NULL)
+        {
+            return false;
+        }
+
+        std::set<Player*>::const_iterator it = this->players_.find(player);
+        if (it == this->players_.end()) //!< Player is not yet in the list.
+        {
+            this->players_.insert(player);
+        }
+        this->status_ = status;
+        return true;
+    }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/GlobalQuest.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/GlobalQuest.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/GlobalQuest.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GlobalQuest_H__
+#define _GlobalQuest_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <set>
+
+#include "core/XMLPort.h"
+#include "Quest.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Global quests are quests, that have the same status for all players.
+        This means, that when a player successfully completes this quest, it is completed for all players that have it.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport GlobalQuest : public Quest
+    {
+        public:
+            GlobalQuest(BaseObject* creator);
+            virtual ~GlobalQuest();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+        protected:
+            virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started.
+            virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed.
+            virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed.
+
+            virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player.
+            virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
+
+        private:
+            std::set<Player*> players_; //!< The set of players which possess this quest.
+            questStatus::Enum status_; //!< The status of this quest.
+
+            void initialize(void);
+
+    };
+
+}
+
+#endif /* _GlobalQuest_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/LocalQuest.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/LocalQuest.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/LocalQuest.cc	(revision 2122)
@@ -0,0 +1,158 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "LocalQuest.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+namespace orxonox {
+
+    CreateFactory(LocalQuest);
+
+    LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator)
+    {
+        RegisterObject(LocalQuest);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    LocalQuest::~LocalQuest()
+    {
+
+    }
+
+    void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(LocalQuest, XMLPort, xmlelement, mode);
+
+        COUT(3) << "New LocalQuest {" << this->getId() << "} created." << std::endl;
+    }
+
+    void LocalQuest::initialize(void)
+    {
+        RegisterObject(LocalQuest);
+    }
+
+    /**
+    @brief
+        Checks whether the quest can be started.
+    @param player
+        The player for whom is to be checked.
+    @return
+        Returns true if the quest can be started, false if not.
+    @throws
+        Throws an exception if isInactive(Player*) throws one.
+    */
+    bool LocalQuest::isStartable(const Player* player) const
+    {
+        return this->isInactive(player);
+    }
+
+    /**
+    @brief
+        Checks whether the quest can be failed.
+    @param player
+        The player for whom is to be checked.
+    @return
+        Returns true if the quest can be failed, false if not.
+    @throws
+        Throws an exception if isActive(Player*) throws one.
+    */
+    bool LocalQuest::isFailable(const Player* player) const
+    {
+        return this->isActive(player);
+    }
+
+    /**
+    @brief
+        Checks whether the quest can be completed.
+    @param player
+        The player for whom is to be checked.
+    @return
+        Returns true if the quest can be completed, false if not.
+    @throws
+        Throws an exception if isInactive(Player*) throws one.
+    */
+    bool LocalQuest::isCompletable(const Player* player) const
+    {
+        return this->isActive(player);
+    }
+
+    /**
+    @brief
+        Returns the status of the quest for a specific player.
+    @param player
+        The player.
+    @return
+        Returns the status of the quest for the input player.
+    @throws
+        Throws an Exception if player is NULL.
+    */
+    questStatus::Enum LocalQuest::getStatus(const Player* player) const
+    {
+        if(player == NULL)
+        {
+            ThrowException(Argument, "The input Player* is NULL.");
+        }
+
+        std::map<Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'.
+        if (it != this->playerStatus_.end())
+        {
+            return it->second;
+        }
+        return questStatus::inactive;
+    }
+
+    /**
+    @brief
+        Sets the status for a specific player.
+        But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing.
+    @param player
+        The player.
+    @param status
+        The status.
+    @return
+        Returns false if player is NULL.
+    */
+    bool LocalQuest::setStatus(Player* player, const questStatus::Enum & status)
+    {
+        if(player == NULL)
+        {
+            return false;
+        }
+        this->playerStatus_[player] = status;
+        return true;
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/LocalQuest.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/LocalQuest.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/LocalQuest.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _LocalQuest_H__
+#define _LocalQuest_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <string>
+
+#include "core/XMLPort.h"
+#include "Quest.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Handles quests which have different states for different players.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport LocalQuest : public Quest
+    {
+        public:
+            LocalQuest(BaseObject* creator);
+            virtual ~LocalQuest();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+        protected:
+            virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started.
+            virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed.
+            virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed.
+
+            virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player.
+            virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
+
+        private:
+            std::map<Player*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
+
+            void initialize(void);
+
+    };
+
+
+}
+
+#endif /* _LocalQuest_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/Quest.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/Quest.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/Quest.cc	(revision 2122)
@@ -0,0 +1,386 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Quest.h"
+
+#include "core/CoreIncludes.h"
+
+#include "QuestManager.h"
+#include "QuestDescription.h"
+#include "QuestHint.h"
+#include "QuestEffect.h"
+
+namespace orxonox {
+
+    Quest::Quest(BaseObject* creator) : QuestItem(creator)
+    {
+        RegisterObject(Quest);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    Quest::~Quest()
+    {
+
+    }
+
+    void Quest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Quest, XMLPort, xmlelement, mode);
+
+        XMLPortObject(Quest, Quest, "", addSubQuest, getSubQuests, xmlelement, mode);
+        XMLPortObject(Quest, QuestHint, "", addHint, getHints, xmlelement, mode);
+        XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffects, xmlelement, mode);
+        XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffects, xmlelement, mode);
+
+        QuestManager::registerQuest(this); //Registers the quest with the QuestManager.
+    }
+
+    /**
+    @brief
+        Initializes the object. Needs to be called first in every constructor of this class.
+    */
+    void Quest::initialize(void)
+    {
+        RegisterObject(Quest);
+
+        this->parentQuest_ = NULL;
+    }
+
+    /**
+    @brief
+        Sets the parent quest of the quest.
+    @param quest
+        A pointer to the quest to be set as parent quest.
+    @return
+        Returns true if the parentQuest could be set.
+    */
+    bool Quest::setParentQuest(Quest* quest)
+    {
+        if(quest == NULL)
+        {
+            COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl;
+            return false;
+        }
+
+        this->parentQuest_ = quest;
+
+        COUT(3) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+        return true;
+    }
+
+    /**
+    @brief
+        Adds a sub quest to the quest.
+    @param quest
+        A pointer to the quest to be set as sub quest.
+    @return
+        Returns true if the subQuest vould be set.
+    */
+    bool Quest::addSubQuest(Quest* quest)
+    {
+        if(quest == NULL)
+        {
+            COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl;
+            return false;
+        }
+
+        quest->setParentQuest(this);
+        this->subQuests_.push_back(quest);
+
+        COUT(3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+        return true;
+    }
+
+
+    /**
+    @brief
+        Adds a Hint to the list of hints
+    @param hint
+        The hint that should be added to the list of hints.
+    @return
+        Returns true if the hint was successfully added.
+    */
+    bool Quest::addHint(QuestHint* hint)
+    {
+        if(hint == NULL)
+        {
+            COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl;
+            return false;
+        }
+
+        this->hints_.push_back(hint);
+        hint->setQuest(this);
+
+        COUT(3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+        return true;
+    }
+
+    /**
+    @brief
+
+    */
+    bool Quest::addFailEffect(QuestEffect* effect)
+    {
+        if(effect == NULL)
+        {
+            COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl;
+            return false;
+        }
+
+        this->failEffects_.push_back(effect);
+
+        COUT(3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl;
+        return true;
+    }
+
+    /**
+    @brief
+
+    */
+    bool Quest::addCompleteEffect(QuestEffect* effect)
+    {
+        if(effect == NULL)
+        {
+            COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl;
+            return false;
+        }
+
+        this->completeEffects_.push_back(effect);
+
+        COUT(3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl;
+        return true;
+    }
+
+    /**
+    @brief
+
+    */
+    const Quest* Quest::getParentQuest(void)
+    {
+        return this->parentQuest_;
+    }
+
+    /**
+    @brief
+
+    */
+    const Quest* Quest::getSubQuests(unsigned int index) const
+    {
+        int i = index;
+        for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest)
+        {
+            if(i == 0)
+            {
+               return *subQuest;
+            }
+            i--;
+        }
+        return NULL;
+    }
+
+    /**
+    @brief
+
+    */
+    const QuestHint* Quest::getHints(unsigned int index) const
+    {
+        int i = index;
+        for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint)
+        {
+            if(i == 0)
+            {
+               return *hint;
+            }
+            i--;
+        }
+        return NULL;
+    }
+
+    /**
+    @brief
+
+    */
+    const QuestEffect* Quest::getFailEffects(unsigned int index) const
+    {
+        int i = index;
+        for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect)
+        {
+            if(i == 0)
+            {
+               return *effect;
+            }
+            i--;
+        }
+        return NULL;
+    }
+
+    /**
+    @brief
+
+    */
+    const QuestEffect* Quest::getCompleteEffects(unsigned int index) const
+    {
+        int i = index;
+        for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect)
+        {
+            if(i == 0)
+            {
+               return *effect;
+            }
+            i--;
+        }
+        return NULL;
+    }
+
+    /**
+    @brief
+        Returns true if the quest status for the specific player is 'inactive'.
+    @param player
+        The player.
+    @return
+        Returns true if the quest status for the specific player is 'inactive'.
+    @throws
+        Throws an exception if getStatus throws one.
+    */
+    bool Quest::isInactive(const Player* player) const
+    {
+        return this->getStatus(player) == questStatus::inactive;
+    }
+
+    /**
+    @brief
+        Returns true if the quest status for the specific player is 'active'.
+    @param player
+        The player.
+    @return
+        Returns true if the quest status for the specific player is 'active'.
+    @throws
+        Throws an exception if getStatus throws one.
+    */
+    bool Quest::isActive(const Player* player) const
+    {
+
+        return this->getStatus(player) == questStatus::active;
+    }
+
+    /**
+    @brief
+        Returns true if the quest status for the specific player is 'failed'.
+    @param player
+        The player.
+    @return
+        Returns true if the quest status for the specific player is 'failed'.
+    @throws
+        Throws an exception if getStatus throws one.
+    */
+    bool Quest::isFailed(const Player* player) const
+    {
+        return this->getStatus(player) == questStatus::failed;
+    }
+
+    /**
+    @brief
+        Returns true if the quest status for the specific player is 'completed'.
+    @param player
+        The player.
+    @return
+        Returns true if the quest status for the specific player is 'completed'.
+    @throws
+        Throws an exception if getStatus throws one.
+    */
+    bool Quest::isCompleted(const Player* player) const
+    {
+        return this->getStatus(player) == questStatus::completed;
+    }
+
+    /**
+    @brief
+        Starts the quest.
+    @param player
+        The player.
+    @return
+        Returns true if the quest could be started, false if not.
+    */
+    bool Quest::start(Player* player)
+    {
+        if(this->isStartable(player))
+        {
+            this->setStatus(player, questStatus::active);
+            return true;
+        }
+        COUT(2) << "A non-startable quest was trying to be started." << std::endl;
+        return false;
+    }
+
+    /**
+    @brief
+        Fails the quest.
+    @param player
+        The player.
+    @return
+        Returns true if the quest could be failed, false if not.
+    */
+    bool Quest::fail(Player* player)
+    {
+        if(this->isFailable(player))
+        {
+            this->setStatus(player, questStatus::failed);
+            QuestEffect::invokeEffects(player, this->failEffects_);
+            return true;
+        }
+        COUT(2) << "A non-failable quest was trying to be failed." << std::endl;
+        return false;
+    }
+
+    /**
+    @brief
+        Completes the quest.
+    @param player
+        The player.
+    @return
+        Returns true if the quest could be completed, false if not.
+    */
+    bool Quest::complete(Player* player)
+    {
+        if(this->isCompletable(player))
+        {
+            this->setStatus(player, questStatus::completed);
+            QuestEffect::invokeEffects(player, this->completeEffects_);
+            return true;
+        }
+        COUT(2) << "A non-completable quest was trying to be completed." << std::endl;
+        return false;
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/Quest.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/Quest.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/Quest.h	(revision 2122)
@@ -0,0 +1,121 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Quest_H__
+#define _Quest_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+#include <string>
+
+#include "core/XMLPort.h"
+#include "QuestItem.h"
+
+namespace questStatus
+{
+
+    enum Enum
+    {
+        inactive,
+        active,
+        failed,
+        completed
+    };
+
+}
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Represents a quest in the game.
+        A quest has a list of subquests and a parentquest (if it is not a rootquest).
+        Each quest exists only once but it has a different status (inactive, active, failed or completed) for each player.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport Quest : public QuestItem
+    {
+        public:
+            Quest(BaseObject* creator);
+            virtual ~Quest();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest.
+                { return this->parentQuest_; }
+            inline const std::list<Quest*> & getSubQuestList(void) const //!< Returns the list of sub quests.
+                { return this->subQuests_; }
+
+            bool isInactive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
+            bool isActive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'active'.
+            bool isFailed(const Player* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
+            bool isCompleted(const Player* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
+
+            bool start(Player* player); //!< Sets a quest to active.
+            bool fail(Player* player); //!< Fails the quest.
+            bool complete(Player* player); //!< Completes the quest.
+
+        protected:
+            void initialize(void); //!< Initialized the object.
+
+            virtual bool isStartable(const Player* player) const = 0; //!< Checks whether the quest can be started.
+            virtual bool isFailable(const Player* player) const = 0; //!< Checks whether the quest can be failed.
+            virtual bool isCompletable(const Player* player) const = 0; //!< Checks whether the quest can be completed.
+
+            bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest.
+            bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest.
+            bool addHint(QuestHint* hint); //!< Add a hint to the list of hints.
+            bool addFailEffect(QuestEffect* effect);
+            bool addCompleteEffect(QuestEffect* effect);
+
+            const Quest* getParentQuest(void);
+            const Quest* getSubQuests(unsigned int index) const;
+            const QuestHint* getHints(unsigned int index) const;
+            const QuestEffect* getFailEffects(unsigned int index) const;
+            const QuestEffect* getCompleteEffects(unsigned int index) const;
+
+            virtual questStatus::Enum getStatus(const Player* player) const = 0; //!< Returns the status of the quest for a specific player.
+            virtual bool setStatus(Player* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
+
+            Quest* parentQuest_; //!< Pointer to the parent quest.
+            std::list<Quest*> subQuests_; //!< List of all the sub quests.
+
+            std::list<QuestHint*> hints_; //!< A list of all the hints tied to this quest.
+
+            std::list<QuestEffect*> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed.
+            std::list<QuestEffect*> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed.
+
+    };
+
+}
+
+#endif /* _Quest_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/QuestDescription.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestDescription.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestDescription.cc	(revision 2122)
@@ -0,0 +1,70 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "QuestDescription.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox {
+
+    CreateFactory(QuestDescription);
+
+    QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(QuestDescription);
+
+        this->initialize();
+    }
+
+    QuestDescription::~QuestDescription()
+    {
+
+    }
+
+    void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(QuestDescription, XMLPort, xmlelement, mode);
+
+        XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode);
+        XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode);
+
+        COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
+    }
+
+    /**
+    @brief
+        Initializes the object. Has to be called first in every constructor of this class.
+    */
+    void QuestDescription::initialize(void)
+    {
+        RegisterObject(QuestDescription);
+    }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/QuestDescription.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestDescription.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestDescription.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _QuestDescription_H__
+#define _QuestDescription_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "core/BaseObject.h"
+#include "core/XMLPort.h"
+
+namespace orxonox {
+
+    /**
+    @brief
+        This class is a description of a QuestItem.
+        It holds a title and a description.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport QuestDescription : public BaseObject {
+
+        public:
+            QuestDescription(BaseObject* creator);
+            virtual ~QuestDescription();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            inline const std::string & getTitle(void) const //!< Returns the title.
+                { return this->title_; }
+            inline const std::string & getDescription(void) const //!< Returns the description text.
+                { return this->description_; }
+
+        private:
+            void initialize(void);
+
+            inline void setTitle(const std::string & title) //!< Sets the title.
+                { this->title_ = title; }
+            inline void setDescription(const std::string & description) //!< Sets the description text.
+                { this->description_ = description; }
+
+            std::string title_; //!< The title.
+            std::string description_; //!< The description.
+
+    };
+
+}
+
+#endif /* _QuestDescription_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/QuestEffect.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestEffect.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestEffect.cc	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "QuestEffect.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox {
+
+    /**
+    @brief
+        Constructor. Creates a new QuestEffect.
+        Is not meant to be invoked directly, since this is only an interface.
+    */
+    QuestEffect::QuestEffect(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(QuestEffect);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    QuestEffect::~QuestEffect()
+    {
+
+    }
+
+    /**
+    @brief
+        Static method. Invoke all effects of an effect list.
+    @param player
+        The player the effects are invoked on.
+    @param effects
+        A list of all the effects to be invoked.
+    @return
+        Returns false if there was an error, view console of log for further detail.
+    */
+    bool QuestEffect::invokeEffects(Player* player, std::list<QuestEffect*> & effects)
+    {
+        bool check = true;
+
+        for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
+        {
+            check = check && (*effect)->invoke(player);
+        }
+        return check;
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/QuestEffect.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestEffect.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestEffect.h	(revision 2122)
@@ -0,0 +1,62 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _QuestEffect_H__
+#define _QuestEffect_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+
+#include "core/BaseObject.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Handles effects for quests.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport QuestEffect : public BaseObject
+    {
+        public:
+            QuestEffect(BaseObject* creator);
+            virtual ~QuestEffect();
+
+            virtual bool invoke(Player* player) = 0; //!< Invokes the effect.
+            static bool invokeEffects(Player* player, std::list<QuestEffect*> & effects); //!< Invokes all effects in the list.
+
+
+    };
+
+}
+
+#endif /* _QuestEffect_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/QuestHint.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestHint.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestHint.cc	(revision 2122)
@@ -0,0 +1,145 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "QuestHint.h"
+
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+#include "Quest.h"
+
+namespace orxonox {
+
+    CreateFactory(QuestHint);
+
+    /**
+    @brief
+        Constructor.
+    */
+    QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator)
+    {
+        RegisterObject(QuestHint);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    QuestHint::~QuestHint()
+    {
+
+    }
+
+    void QuestHint::initialize(void)
+    {
+        RegisterObject(QuestHint);
+    }
+
+    void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(QuestHint, XMLPort, xmlelement, mode);
+
+        COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
+    }
+
+
+    /**
+    @brief
+        Checks whether the hint is active for a specific player.
+    @param player
+        The player.
+    @throws
+        Throws an Argument Exception if the input Player-pointer is NULL.
+    @return
+        Returns true if the hint is active for the specified player.
+    */
+    bool QuestHint::isActive(Player* player)
+    {
+        if(player == NULL)
+        {
+            ThrowException(Argument, "The input Player* is NULL.");
+            return false;
+        }
+
+        std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player);
+        if (it != this->playerStatus_.end())
+        {
+            return it->second;
+        }
+        return questStatus::inactive;
+    }
+
+    /**
+    @brief
+        Activates a QuestHint for a given player.
+    @param player
+        The player.
+    @return
+        Returns true if the activation was successful, false if there were problems.
+    */
+    bool QuestHint::activate(Player* player)
+    {
+        if(this->quest_->isActive(player))
+        {
+            if(!(this->isActive(player)))
+            {
+                this->playerStatus_[player] = questHintStatus::active;
+                return true;
+            }
+            else
+            {
+                COUT(2) << "An already active questHint was trying to get activated." << std::endl;
+                return false;
+            }
+        }
+        COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
+        return false;
+    }
+
+    /**
+    @brief
+        Sets the quest the QuestHitn belongs to.
+    @param quest
+    @return
+    */
+    bool QuestHint::setQuest(Quest* quest)
+    {
+        if(quest == NULL)
+        {
+            COUT(2) << "The input Quest* is NULL." << std::endl;
+            return false;
+        }
+
+        this->quest_ = quest;
+        return true;
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/QuestHint.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestHint.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestHint.h	(revision 2122)
@@ -0,0 +1,93 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _QuestHint_H__
+#define _QuestHint_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <string>
+
+#include "core/XMLPort.h"
+#include "QuestItem.h"
+
+namespace questHintStatus
+{
+
+    enum Enum
+    {
+        inactive,
+        active
+    };
+
+}
+
+namespace orxonox
+{
+
+    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
+
+    /**
+    @brief
+        Represents a hint in the game towards completing a Quest.
+        Consists of title and description in textual form and must belong to a quest.
+        A QuestHit has a defined status (inactive or active, where inactive is default) for each player, which means each QuestHint exists only once for all players, it doesn't belong to a player, it just has different stati for each of them.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport QuestHint : public QuestItem
+    {
+
+        public:
+            QuestHint(BaseObject* creator);
+            virtual ~QuestHint();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            bool isActive(Player* player); //!< Returns true if the hint is active for the input player.
+
+            bool activate(Player* player); //!< Activates the hint for the input player.
+
+            bool setQuest(Quest* quest); //!< Sets the quest the hint belongs to.
+
+            inline Quest* getQuest(void)
+               { return this->quest_; }
+
+        private:
+
+            void initialize(void);
+
+            Quest* quest_; //!< The quest the hint belongs to.
+            std::map<Player*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
+
+    };
+
+}
+
+#endif /* _QuestHint_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/QuestItem.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestItem.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestItem.cc	(revision 2122)
@@ -0,0 +1,110 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "QuestItem.h"
+
+#include "core/CoreIncludes.h"
+
+#include "QuestDescription.h"
+
+namespace orxonox {
+
+    QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(QuestItem);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    QuestItem::~QuestItem()
+    {
+
+    }
+
+    void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(QuestItem, XMLPort, xmlelement, mode);
+
+        XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode);
+        //Doesn't getDescription have to be of type getDescription(unsigned int) ?
+        //XMLPortObjectTemplate(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode, unsigned int);
+        XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode);
+
+    }
+
+
+    /**
+    @brief
+        Initializes the object.
+        Should be called first in every constructor of this class.
+    */
+    void QuestItem::initialize(void)
+    {
+        RegisterObject(QuestItem);
+
+        this->id_ = "";
+    }
+
+    void QuestItem::setId(const std::string & id)
+    {
+        if(!isId(id))
+        {
+            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
+            return;
+        }
+        this->id_ = id;
+    }
+
+    //const QuestDescription* QuestItem::getDescription(unsigned int index) const //!< Returns the description of the QuestItem.
+    //{
+    //    if(index != 0)
+    //        return NULL;
+    //    return this->description_;
+    //}
+
+    /**
+    @brief
+        Checks whether an input id is of the required form.
+    @param id
+        The id to be checked.
+    @return
+        Returns true if the string is likely to be of the required form.
+    @todo
+        Clarify form, more vigorous checks.
+    */
+    bool QuestItem::isId(const std::string & id)
+    {
+        return id.size() >= 32;
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/QuestItem.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestItem.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestItem.h	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _QuestItem_H__
+#define _QuestItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "core/BaseObject.h"
+#include "core/XMLPort.h"
+
+namespace orxonox {
+
+
+    /**
+    @brief
+        Functions as a base class for Quest classes such as Quest or QuestHint.
+        Has a unique identifier and a description.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport QuestItem : public BaseObject
+    {
+
+        public:
+            QuestItem(BaseObject* creator);
+            virtual ~QuestItem();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            inline const std::string & getId(void) const //!< Returns the id of this quest.
+                { return this->id_; }
+            inline const QuestDescription* getDescription(void) const //!< Returns the description of the QuestItem.
+                { return this->description_; }
+            //const QuestDescription* getDescription(unsigned int index) const; //!< Returns the description of the QuestItem.
+
+            static bool isId(const std::string & id); //!< Checks whether a given id is valid.
+
+        protected:
+            void setId(const std::string & id);
+            inline void setDescription(QuestDescription* description)
+                { this->description_ = description; }
+
+        private:
+            std::string id_; //!< Identifier. Should be of GUID form: http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure
+            QuestDescription* description_; //!< The description of the QuestItem.
+
+            void initialize(void); //!< Initializes the object.
+
+    };
+
+}
+
+#endif /* _QuestItem_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/QuestManager.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestManager.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestManager.cc	(revision 2122)
@@ -0,0 +1,185 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "QuestManager.h"
+
+#include "core/CoreIncludes.h"
+
+#include "util/Exception.h"
+#include "Quest.h"
+#include "QuestHint.h"
+
+namespace orxonox {
+
+    std::map<std::string, Quest*> QuestManager::questMap_;
+    std::map<std::string, QuestHint*> QuestManager::hintMap_;
+
+    QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(QuestManager);
+    }
+
+
+    QuestManager::~QuestManager()
+    {
+
+    }
+
+    /**
+    @brief
+        Registers a quest with the QuestManager to make it globally accessable.
+    @param quest
+        The quest that is to be registered.
+    @return
+        Returns true if successful, false if not.
+    */
+    bool QuestManager::registerQuest(Quest* quest)
+    {
+        if(quest == NULL)
+        {
+            COUT(2) << "Registration of Quest in QuestManager failed, because inserted Quest-pointer was NULL." << std::endl;
+            return false;
+        }
+
+        std::pair<std::map<std::string, Quest*>::iterator,bool> ret;
+        ret = questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) );
+
+        if(ret.second)
+        {
+            COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl;
+            return true;
+        }
+        else
+        {
+           COUT(2) << "Quest with the same id was already present." << std::endl;
+           return false;
+        }
+    }
+
+    /**
+    @brief
+        Registers a QuestHint with the QuestManager to make it globally accessable.
+    @param hint
+        The QuestHint to be registered.
+    @return
+        Returns true if successful, false if not.
+    */
+    bool QuestManager::registerHint(QuestHint* hint)
+    {
+        if(hint == NULL)
+        {
+            COUT(2) << "Registration of QuestHint in QuestManager failed, because inserted QuestHint-pointer was NULL." << std::endl;
+            return false;
+        }
+
+        std::pair<std::map<std::string, QuestHint*>::iterator,bool> ret;
+        ret = hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) );
+
+        if(ret.second)
+        {
+            COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl;
+            return true;
+        }
+        else
+        {
+           COUT(2) << "QuestHint with the same id was already present." << std::endl;
+           return false;
+        }
+    }
+
+    /**
+    @brief
+        Finds a quest with the given id.
+    @param questId
+        The id of the quest sought for.
+    @return
+        Returns a reference to the quest with the input id.
+        Returns NULL if there is no quest with the given questId.
+    @throws
+        Throws an exception if the given questId is invalid.
+    */
+    Quest* QuestManager::findQuest(const std::string & questId)
+    {
+        if(!QuestItem::isId(questId))
+        {
+            ThrowException(Argument, "Invalid questId.");
+        }
+
+        Quest* quest;
+        std::map<std::string, Quest*>::iterator it = questMap_.find(questId);
+        if (it != questMap_.end())
+        {
+            quest = it->second;
+        }
+        else
+        {
+           quest = NULL;
+           COUT(2) << "The quest with id {" << questId << "} is nowhere to be found." << std::endl;
+        }
+
+        return quest;
+
+    }
+
+    /**
+    @brief
+        Finds a hint with the given id.
+    @param hintId
+        The id of the hint sought for.
+    @return
+        Returns a reference to the hint with the input id.
+        Returns NULL if there is no hint with the given hintId.
+    @throws
+        Throws an exception if the given hintId is invalid.
+    */
+    QuestHint* QuestManager::findHint(const std::string & hintId)
+    {
+        if(!QuestItem::isId(hintId))
+        {
+            ThrowException(Argument, "Invalid hintId.");
+        }
+
+        QuestHint* hint;
+        std::map<std::string, QuestHint*>::iterator it = hintMap_.find(hintId);
+        if (it != hintMap_.end())
+        {
+            hint = it->second;
+        }
+        else
+        {
+           hint = NULL;
+           COUT(2) << "The hint with id {" << hintId << "} is nowhere to be found." << std::endl;
+        }
+
+        return hint;
+
+    }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/QuestManager.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/QuestManager.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/QuestManager.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _QuestManager_H__
+#define _QuestManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <string>
+
+#include "core/BaseObject.h"
+
+namespace orxonox {
+
+    /**
+    @brief
+        Manages quests, by making them globally accessable.
+        Quests (and Hints) are registered in the QuestManager trough their id, and can be accessed in the same way.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport QuestManager : public BaseObject
+    {
+
+        public:
+            QuestManager(BaseObject* creator);
+            virtual ~QuestManager();
+
+            static bool registerQuest(Quest* quest); //!< Registers a quest in the QuestManager.
+            static bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager.
+
+            static Quest* findQuest(const std::string & questId); //!< Returns the quest with the input id.
+            static QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id.
+
+        private:
+            static std::map<std::string, Quest*> questMap_; //!< All quests registered by their id's.
+            static std::map<std::string, QuestHint*> hintMap_; //!< All hints registered by their id's.
+
+    };
+
+}
+
+#endif /* _QuestManager_H__ */
Index: /code/branches/physics/src/orxonox/objects/quest/Rewardable.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/Rewardable.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/Rewardable.cc	(revision 2122)
@@ -0,0 +1,48 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Rewardable.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox {
+
+
+    Rewardable::Rewardable(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(Rewardable);
+    }
+
+
+    Rewardable::~Rewardable()
+    {
+    }
+
+
+}
Index: /code/branches/physics/src/orxonox/objects/quest/Rewardable.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/quest/Rewardable.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/quest/Rewardable.h	(revision 2122)
@@ -0,0 +1,59 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Rewardable_H__
+#define _Rewardable_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+namespace orxonox {
+
+    class Player; //Forward declaration, remove when fully integrated in objecthirarchy.
+
+    /**
+    @brief
+        Rewardable is an Interface, that can be implemented by any object to enable it to be given as reward to a player through QuestEffects.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport Rewardable : public BaseObject
+    {
+
+        public:
+            Rewardable(BaseObject* creator);
+            virtual ~Rewardable();
+
+            virtual bool reward(Player* player) = 0; //!<Method to transcribe a rewardable object to the player.
+
+    };
+
+}
+
+#endif /* _Rewardable_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/Munition.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/Munition.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/Munition.cc	(revision 2122)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+#include "Munition.h"
+
+namespace orxonox
+{
+    Munition::Munition(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(Munition);
+    }
+
+    Munition::~Munition()
+    {
+    }
+
+    void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/Munition.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/Munition.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/Munition.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Munition_H__
+#define _Munition_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport Munition : public BaseObject
+    {
+        public:
+            Munition(BaseObject* creator);
+            virtual ~Munition();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+
+        private:
+
+
+    };
+}
+
+#endif /* _Munition_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/Weapon.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/Weapon.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/Weapon.cc	(revision 2122)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+#include "Weapon.h"
+
+namespace orxonox
+{
+    Weapon::Weapon(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(Weapon);
+
+        this->loadingTime_ = 0;
+        this->munition_ = 0;
+
+    }
+
+    Weapon::~Weapon()
+    {
+    }
+
+    void Weapon::addMunition()
+    {
+
+    }
+
+    void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+
+    void Weapon::fire()
+    {
+
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/Weapon.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/Weapon.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/Weapon.h	(revision 2122)
@@ -0,0 +1,59 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Weapon_H__
+#define _Weapon_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport Weapon : public BaseObject
+    {
+        public:
+            Weapon(BaseObject* creator);
+            virtual ~Weapon();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void addMunition();
+            virtual void fire();
+
+        private:
+            int loadingTime_;
+            Munition *munition_;
+
+
+
+    };
+}
+
+#endif /* _Weapon_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSet.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSet.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSet.cc	(revision 2122)
@@ -0,0 +1,86 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ... *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include <vector>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+#include "WeaponSet.h"
+
+namespace orxonox
+{
+    WeaponSet::WeaponSet(BaseObject* creator, int k) : BaseObject(creator)
+    {
+        RegisterObject(WeaponSet);
+
+        this->parentWeaponSystem_ = 0;
+
+        for (int i=0;i<k;i++)
+        {
+            attachWeaponSlot(new WeaponSlot(this));
+        }
+    }
+
+    WeaponSet::~WeaponSet()
+    {
+    }
+
+    //Vorwärtsdeklaration
+    WeaponSystem * parentWeaponSystem_;
+
+    void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot)
+    {
+        this->weaponSlots_.push_back(wSlot);
+    }
+
+    void WeaponSet::fire()
+    {
+        for (int i=0; i < (int) this->weaponSlots_.size(); i++)
+        {
+            this->weaponSlots_[i]->fire();
+        }
+    }
+
+    WeaponSlot * WeaponSet::getWeaponSlotPointer(unsigned int n)
+    {
+        if (n < this->weaponSlots_.size())
+            return this->weaponSlots_[n];
+        else
+            return 0;
+    }
+
+
+    void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSet.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSet.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSet.h	(revision 2122)
@@ -0,0 +1,65 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _WeaponSet_H__
+#define _WeaponSet_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+#include "WeaponSlot.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport WeaponSet : public BaseObject
+    {
+        public:
+            WeaponSet(BaseObject* creator, int k = 0);
+            virtual ~WeaponSet();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void attachWeaponSlot(WeaponSlot *wSlot);
+            void fire();
+            WeaponSlot * getWeaponSlotPointer(unsigned int n);
+
+            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
+                { parentWeaponSystem_=parentWeaponSystem; }
+            inline WeaponSystem * getParentWeaponSystem()
+                { return parentWeaponSystem_; }
+
+        private:
+            std::vector<WeaponSlot *> weaponSlots_;
+            WeaponSystem *parentWeaponSystem_;
+    };
+}
+
+#endif /* _WeaponSet_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSlot.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSlot.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSlot.cc	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+#include "WeaponSlot.h"
+
+
+
+namespace orxonox
+{
+    WeaponSlot::WeaponSlot(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(WeaponSlot);
+
+        this->unlimitedAmmo_ = false;
+
+        this->attachedWeapon_ = 0;
+        this->parentWeaponSet_ = 0;
+    }
+
+    WeaponSlot::~WeaponSlot()
+    {
+    }
+
+    void WeaponSlot::attachWeapon(Weapon *weaponName)
+    {
+
+    }
+
+    /*sets the munition type
+     *unlimited: true
+     *limited:   false  (in this case there will be munition)
+     */
+    void WeaponSlot::setAmmoType(bool isUnlimited)
+    {
+        unlimitedAmmo_ = isUnlimited;
+    }
+
+    void WeaponSlot::fire()
+    {
+
+    }
+
+    void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSlot.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSlot.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSlot.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _WeaponSlot_H__
+#define _WeaponSlot_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+
+#include "Weapon.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport WeaponSlot : public BaseObject
+    {
+        public:
+            WeaponSlot(BaseObject* creator);
+            virtual ~WeaponSlot();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void attachWeapon(Weapon *weaponName);
+            void setAmmoType(bool isUnlimited);
+            void fire();
+
+            inline void setParentWeaponSet(WeaponSet *parentWeaponSet)
+                { parentWeaponSet_=parentWeaponSet; }
+            inline WeaponSet * getParentWeaponSet()
+                { return parentWeaponSet_; }
+
+
+
+        private:
+            Weapon *attachedWeapon_;
+            bool unlimitedAmmo_;
+
+            WeaponSet *parentWeaponSet_;
+    };
+}
+
+#endif /* _WeaponSlot_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSystem.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSystem.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSystem.cc	(revision 2122)
@@ -0,0 +1,100 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include <vector>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+#include "WeaponSystem.h"
+
+/* WEAPONSYSTEM
+ * creates the WeaponSystem and the ability to use weapons and munition
+ * loads the weapon the whole weaponSystem setting from an xml file
+ *
+ */
+
+namespace orxonox
+{
+    WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(WeaponSystem);
+
+        this->activeWeaponSet_ = 0;
+        this->parentSpaceShip_ = 0;
+    }
+
+    WeaponSystem::~WeaponSystem()
+    {
+    }
+
+    //creates empty weaponSet
+    void WeaponSystem::attachWeaponSet(WeaponSet *wSet)
+    {
+        this->weaponSets_.push_back(wSet);
+        wSet->setParentWeaponSystem(this);
+    }
+
+    //the first weaponSet is at n=0
+    void WeaponSystem::setActiveWeaponSet(unsigned int n)
+    {
+        if (n < this->weaponSets_.size())
+            this->activeWeaponSet_ = this->weaponSets_[n];
+    }
+
+    //n is the n'th weaponSet, starting with zero
+    //Spaceship.cc only needs to have the keybinding to a specific Set-number n
+    void WeaponSystem::fire(unsigned int n)
+    {
+        if (n < this->weaponSets_.size())
+            this->weaponSets_[n]->fire();
+    }
+
+    void WeaponSystem::fire()
+    {
+        if (this->activeWeaponSet_)
+            this->activeWeaponSet_->fire();
+    }
+
+    WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n)
+    {
+        if (n < this->weaponSets_.size())
+            return this->weaponSets_[n];
+        else
+            return 0;
+    }
+
+    void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSystem.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSystem.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSystem.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _WeaponSystem_H__
+#define _WeaponSystem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+#include "WeaponSet.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport WeaponSystem : public BaseObject
+    {
+        public:
+            WeaponSystem(BaseObject* creator);
+            virtual ~WeaponSystem();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void attachWeaponSet(WeaponSet *wSet);
+            void fire();
+            void fire(unsigned int n);
+            void setActiveWeaponSet(unsigned int n);
+            WeaponSet * getWeaponSetPointer(unsigned int n);
+
+            inline void setParentSpaceShip(SpaceShip *parentSpaceShip)
+                { parentSpaceShip_=parentSpaceShip; }
+            inline SpaceShip * getParentSpaceShip()
+                { return parentSpaceShip_; }
+
+
+        private:
+            std::vector<WeaponSet *> weaponSets_;
+            WeaponSet *activeWeaponSet_;
+
+            SpaceShip *parentSpaceShip_;
+    };
+}
+
+#endif /* _WeaponSystem_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	(revision 2122)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+#include "LaserGunMunition.h"
+
+namespace orxonox
+{
+    LaserGunMunition::LaserGunMunition(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(LaserGunMunition);
+    }
+
+    LaserGunMunition::~LaserGunMunition()
+    {
+    }
+
+    void LaserGunMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h	(revision 2122)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _LaserGunMunition_H__
+#define _LaserGunMunition_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport LaserGunMunition : public BaseObject
+    {
+        public:
+            LaserGunMunition(BaseObject* creator);
+            virtual ~LaserGunMunition();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+
+        private:
+            int bullets_;
+            int magazines_;
+            int maxBullets_;
+            int maxMagazines_;
+
+
+    };
+}
+
+#endif /* _LaserGunMunition_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc	(revision 2122)
@@ -0,0 +1,65 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BillboardProjectile.h"
+
+#include <OgreBillboard.h>
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(BillboardProjectile);
+
+    BillboardProjectile::BillboardProjectile(BaseObject* creator, Weapon* owner) : Projectile(creator, owner)
+    {
+        RegisterObject(BillboardProjectile);
+
+        this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
+        this->attachObject(this->billboard_.getBillboardSet());
+        this->scale(0.5);
+    }
+
+    BillboardProjectile::~BillboardProjectile()
+    {
+        if (this->isInitialized() && this->owner_)
+            this->detachObject(this->billboard_.getBillboardSet());
+    }
+
+    void BillboardProjectile::setColour(const ColourValue& colour)
+    {
+        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+    }
+
+    void BillboardProjectile::changedVisibility()
+    {
+        SUPER(BillboardProjectile, changedVisibility);
+        this->billboard_.setVisible(this->isVisible());
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _BillboardProjectile_H__
+#define _BillboardProjectile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Projectile.h"
+#include "tools/BillboardSet.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BillboardProjectile : public Projectile
+    {
+        public:
+            BillboardProjectile(BaseObject* creator, Weapon* owner = 0);
+            virtual ~BillboardProjectile();
+
+            virtual void setColour(const ColourValue& colour);
+            virtual void changedVisibility();
+
+        private:
+            BillboardSet billboard_;
+    };
+}
+
+#endif /* _BillboardProjectile_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ParticleProjectile.h"
+
+#include "SpaceShip.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(ParticleProjectile);
+
+    ParticleProjectile::ParticleProjectile(BaseObject* creator, Weapon* owner) : BillboardProjectile(creator, owner)
+    {
+        RegisterObject(ParticleProjectile);
+
+        this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
+        this->particles_->addToSceneNode(this->getNode());
+        this->particles_->setKeepParticlesInLocalSpace(true);
+        if (this->owner_)
+        {
+        }
+//        else
+//        {
+//            this->particles_ = 0;
+//        }
+
+        this->setConfigValues();
+    }
+
+    ParticleProjectile::~ParticleProjectile()
+    {
+        if (this->isInitialized() && this->particles_)
+            delete this->particles_;
+    }
+
+    void ParticleProjectile::setConfigValues()
+    {
+        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged);
+    }
+
+    void ParticleProjectile::changedVisibility()
+    {
+        SUPER(ParticleProjectile, changedVisibility);
+        this->particles_->setEnabled(this->isVisible());
+    }
+
+    bool ParticleProjectile::create(){
+      if(!Projectile::create())
+        return false;
+      this->particles_->getAllEmitters()->setDirection(-this->getOrientation()*Vector3(1,0,0));
+      return true;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h	(revision 2122)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleProjectile_H__
+#define _ParticleProjectile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BillboardProjectile.h"
+#include "tools/ParticleInterface.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ParticleProjectile : public BillboardProjectile
+    {
+        public:
+            ParticleProjectile(BaseObject* creator, Weapon* owner = 0);
+            virtual ~ParticleProjectile();
+            virtual void changedVisibility();
+            void setConfigValues();
+
+            virtual bool create();
+
+        private:
+            ParticleInterface* particles_;
+    };
+}
+
+#endif /* _ParticleProjectile_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc	(revision 2122)
@@ -0,0 +1,127 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Projectile.h"
+
+#include <OgreBillboard.h>
+
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Iterator.h"
+#include "tools/ParticleInterface.h"
+
+#include "objects/worldentities/Model.h"
+#include "objects/worldentities/ParticleSpawner.h"
+#include "Settings.h"
+
+namespace orxonox
+{
+    float Projectile::speed_s = 5000;
+
+    Projectile::Projectile(BaseObject* creator, Weapon* owner) : MovableEntity(creator), owner_(owner)
+    {
+        RegisterObject(Projectile);
+
+        this->setConfigValues();
+        this->explosionTemplateName_ = "Orxonox/explosion3";
+        this->smokeTemplateName_ = "Orxonox/smoke4";
+
+        this->setStatic(false);
+        this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
+
+        if (this->owner_)
+        {
+            this->setOrientation(this->owner_->getOrientation());
+            this->setPosition(this->owner_->getPosition());
+            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
+        }
+
+        if(!orxonox::Settings::isClient()) //only if not on client
+          this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
+    }
+
+    Projectile::~Projectile()
+    {
+    }
+
+    void Projectile::setConfigValues()
+    {
+        SetConfigValue(damage_, 15.0).description("The damage caused by the projectile");
+        SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive");
+        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(this, &Projectile::speedChanged);
+    }
+
+    void Projectile::speedChanged()
+    {
+        Projectile::speed_s = this->speed_;
+        if (this->owner_)
+            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
+    }
+
+    void Projectile::tick(float dt)
+    {
+        SUPER(Projectile, tick, dt);
+
+        if (!this->isActive())
+            return;
+
+        float radius;
+        for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it)
+        {
+//            if ((*it) != this->owner_)
+            {
+                radius = it->getScale3D().x * 3.0;
+
+                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
+                {
+                    // hit
+                    ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0);
+                    explosion->setPosition(this->getPosition());
+                    explosion->create();
+                    ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0);
+                    smoke->setPosition(this->getPosition());
+//                    smoke->getParticleInterface()->setSpeedFactor(3.0);
+                    smoke->create();
+                    delete this;
+                    return;
+                }
+            }
+        }
+    }
+
+    void Projectile::destroyObject()
+    {
+        delete this;
+    }
+
+    bool Projectile::create(){
+      return WorldEntity::create();
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/Projectile.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/projectiles/Projectile.h	(revision 2122)
@@ -0,0 +1,70 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Projectile_H__
+#define _Projectile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/worldentities/MovableEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Projectile : public MovableEntity
+    {
+        public:
+            virtual ~Projectile();
+            void setConfigValues();
+            void speedChanged();
+            void destroyObject();
+            virtual void tick(float dt);
+
+            virtual bool create();
+
+            static float getSpeed()
+                { return Projectile::speed_s; }
+
+        protected:
+            Projectile(BaseObject* creator, Weapon* owner = 0);
+            SpaceShip* owner_;
+
+        private:
+            std::string explosionTemplateName_;
+            std::string smokeTemplateName_;
+        protected:
+            static float speed_s;
+            float speed_;
+        private:
+            float lifetime_;
+            float damage_;
+            Timer<Projectile> destroyTimer_;
+    };
+}
+
+#endif /* _Projectile_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc	(revision 2122)
@@ -0,0 +1,77 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+
+namespace orxonox
+{
+    LaserGun::LaserGun(BaseObject* creator) : Weapon(creator)
+    {
+        RegisterObject(LaserGun);
+
+        projectileColor_ = ColourValue(1.0, 1.0, 0.5)
+    }
+
+    LaserGun::~LaserGun()
+    {
+    }
+
+    LaserGun::fire()
+    {
+            BillboardProjectile* projectile = new ParticleProjectile(this);
+            projectile->setColour(this->projectileColor_);
+            projectile->create();
+            if (projectile->getClassID() == 0)
+            {
+              COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
+            }
+
+            projectile->setObjectMode(0x3);
+    }
+
+    LaserGun::addMunition()
+    {
+        //this->munition_ = ;
+    }
+
+    void LaserGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+
+    ColorValue LaserGun::getProjectileColor()
+    {
+        return projectileColor_;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.h	(revision 2122)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _LaserGun_H__
+#define _LaserGun_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+#include "LaserGunMunition.h"
+#include "tools/BillboardSet.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport LaserGun : public Weapon
+    {
+        public:
+            LaserGun(BaseObject* creator);
+            virtual ~LaserGun();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            ColourValue LaserGun::getProjectileColour();
+
+        private:
+            ColorValue projectileColor_;
+
+
+
+    };
+}
+
+#endif /* _LaserGun_H__ */
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/Missile.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/Missile.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/Missile.cc	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include <list>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+
+namespace orxonox
+{
+    Missile::Missile(BaseObject* creator) : Weapon(creator)
+    {
+        RegisterObject(Missile);
+    }
+
+    Missile::~Missile()
+    {
+    }
+
+    void Missile::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+
+    }
+
+}
Index: /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/Missile.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/Missile.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/weaponSystem/weapons/Missile.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Missile_H__
+#define _Missile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/weaponSystem/Weapon.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport Missile : public Weapon
+    {
+        public:
+            Missile(BaseObject* creator);
+            virtual ~Missile();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+
+        private:
+
+
+    };
+}
+
+#endif /* _Missile_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/Backlight.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Backlight.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Backlight.cc	(revision 2122)
@@ -0,0 +1,170 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Backlight.h"
+
+#include <OgreBillboard.h>
+#include <OgreRibbonTrail.h>
+#include <OgreSceneManager.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Executor.h"
+#include "util/Math.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(Backlight);
+
+    float Backlight::timeFactor_s = 1.0;
+
+    Backlight::Backlight(float maxspeed, float brakingtime, float scale)
+    {
+        RegisterObject(Backlight);
+
+        this->setConfigValues();
+        this->traillength_ = 1;
+
+        this->configure(maxspeed, brakingtime, scale);
+    }
+    
+    bool Backlight::create(){
+      if(!WorldEntity::create())
+        return false;
+      
+      this->getNode()->setInheritScale(false);
+
+      this->billboard_.setBillboardSet("Flares/backlightflare");
+      this->attachObject(this->billboard_.getBillboardSet());
+
+      this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
+      this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
+      this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
+      this->ribbonTrail_->addNode(this->getNode());
+
+
+      this->ribbonTrail_->setTrailLength(this->maxTraillength_);
+      this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
+
+        //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
+      this->setTimeFactor(1.0f);
+      
+      this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
+      this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
+      this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());
+      this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);
+      return true;
+    }
+
+    Backlight::~Backlight()
+    {
+        if (this->isInitialized())
+        {
+            this->detachObject(this->billboard_.getBillboardSet());
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
+        }
+    }
+
+    void Backlight::setConfigValues()
+    {
+        SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");
+        SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");
+        SetConfigValue(width_, 7.0).description("The width of the trail");
+    }
+
+    void Backlight::setTimeFactor(float factor)
+    {
+        Backlight::timeFactor_s = factor;
+        float change = Backlight::timeFactor_s / this->maxLifeTime_;
+        this->ribbonTrail_->setWidthChange(0, this->width_ * change);
+        this->updateColourChange();
+    }
+
+    void Backlight::updateColourChange()
+    {
+        this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
+    }
+    
+    
+    void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){
+      SUPER(Backlight, XMLPort, xmlelement, mode);
+      
+      Backlight::create();
+    }
+
+    void Backlight::tick(float dt)
+    {
+        SUPER(Backlight, tick, dt);
+
+        if (this->isActive())
+        {
+            if (this->traillength_ < this->maxTraillength_)
+            {
+                this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);
+                this->updateColourChange();
+            }
+        }
+        else
+        {
+            if (this->traillength_ > 1)
+            {
+                this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);
+                this->updateColourChange();
+            }
+        }
+
+        this->ribbonTrail_->setTrailLength(this->traillength_);
+    }
+
+    void Backlight::setColour(const ColourValue& colour)
+    {
+        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+        this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75));
+    }
+
+    void Backlight::configure(float maxspeed, float brakingtime, float scale)
+    {
+        this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
+        this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
+
+        this->brakefactor_ = this->maxLifeTime_ / brakingtime;
+
+        this->scale(scale);
+    }
+
+    void Backlight::changedVisibility()
+    {
+        SUPER(Backlight, changedVisibility);
+
+        this->billboard_.setVisible(this->isVisible());
+        this->ribbonTrail_->setVisible(this->isVisible());
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/Backlight.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Backlight.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Backlight.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Backlight_H__
+#define _Backlight_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "PositionableEntity.h"
+#include "tools/BillboardSet.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Backlight : public PositionableEntity
+    {
+        public:
+            Backlight(float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);
+            virtual ~Backlight();
+
+            void setConfigValues();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            virtual void changedVisibility();
+            virtual bool create();
+
+            void setColour(const ColourValue& colour);
+            void setTimeFactor(float factor);
+
+        private:
+            void configure(float maxspeed, float brakingtime, float scale = 1);
+            void updateColourChange();
+
+            static float timeFactor_s;
+            BillboardSet billboard_;
+            Ogre::SceneNode* ribbonTrailNode_;
+            Ogre::RibbonTrail* ribbonTrail_;
+
+            float maxLifeTime_;
+            float trailSegmentLength_;
+            float width_;
+
+            float brakefactor_;
+
+            float maxTraillength_;
+            float traillength_;
+
+            size_t maxTrailsegments_;
+    };
+}
+
+#endif /* _Backlight_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/Billboard.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Billboard.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Billboard.cc	(revision 2122)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Billboard.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+    CreateFactory(Billboard);
+
+    Billboard::Billboard(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(Billboard);
+
+        this->registerVariables();
+    }
+
+    Billboard::~Billboard()
+    {
+        if (this->isInitialized())
+        {
+            if (this->isInitialized() && this->billboard_.getBillboardSet())
+                this->getNode()->detachObject(this->billboard_.getName());
+        }
+    }
+
+    void Billboard::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Billboard, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Billboard, "material", setMaterial, getMaterial, xmlelement, mode);
+        XMLPortParam(Billboard, "colour",   setColour,   getColour,   xmlelement, mode).defaultValues(ColourValue::White);
+    }
+
+    void Billboard::registerVariables()
+    {
+        REGISTERSTRING(this->material_, network::direction::toclient, new network::NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
+        REGISTERDATA  (this->colour_,   network::direction::toclient, new network::NetworkCallback<Billboard>(this, &Billboard::changedColour));
+    }
+
+    void Billboard::changedMaterial()
+    {
+        if (!this->billboard_.getBillboardSet())
+        {
+            if (this->getScene() && this->getScene()->getSceneManager())
+            {
+                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
+                this->getNode()->attachObject(this->billboard_.getBillboardSet());
+                this->billboard_.setVisible(this->isVisible());
+            }
+        }
+        else
+            this->billboard_.setMaterial(this->material_);
+    }
+
+    void Billboard::changedColour()
+    {
+        if (!this->billboard_.getBillboardSet())
+        {
+            if (this->getScene() && this->getScene()->getSceneManager())
+            {
+                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
+                this->getNode()->attachObject(this->billboard_.getBillboardSet());
+                this->billboard_.setVisible(this->isVisible());
+            }
+        }
+        else
+            this->billboard_.setColour(this->colour_);
+    }
+
+    void Billboard::changedVisibility()
+    {
+        SUPER(Billboard, changedVisibility);
+
+        this->billboard_.setVisible(this->isVisible());
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/Billboard.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Billboard.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Billboard.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Billboard_H__
+#define _Billboard_H__
+
+#include "OrxonoxPrereqs.h"
+#include "PositionableEntity.h"
+#include "util/Math.h"
+#include "tools/BillboardSet.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Billboard : public PositionableEntity
+    {
+        public:
+            Billboard(BaseObject* creator);
+            virtual ~Billboard();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            virtual void changedVisibility();
+
+            inline const BillboardSet& getBillboardSet() const
+                { return this->billboard_; }
+
+            inline void setMaterial(const std::string& material)
+                { this->material_ = material; this->changedMaterial(); }
+            inline const std::string& getMaterial() const
+                { return this->material_; }
+
+            inline void setColour(const ColourValue& colour)
+                { this->colour_ = colour; this->changedColour(); }
+            inline const ColourValue& getColour() const
+                { return this->colour_; }
+
+        private:
+            void changedMaterial();
+            void changedColour();
+
+            BillboardSet billboard_;
+            std::string material_;
+            ColourValue colour_;
+    };
+}
+
+#endif /* _Billboard_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/BlinkingBillboard.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/BlinkingBillboard.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/BlinkingBillboard.cc	(revision 2122)
@@ -0,0 +1,86 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BlinkingBillboard.h"
+
+#include "core/Core.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    CreateFactory(BlinkingBillboard);
+
+    BlinkingBillboard::BlinkingBillboard(BaseObject* creator) : Billboard(creator)
+    {
+        RegisterObject(BlinkingBillboard);
+
+        this->amplitude_ = 1.0f;
+        this->frequency_ = 1.0f;
+        this->phase_ = 0;
+        this->bQuadratic_ = false;
+        this->time_ = 0;
+
+        this->registerVariables();
+    }
+
+    BlinkingBillboard::~BlinkingBillboard()
+    {
+    }
+
+    void BlinkingBillboard::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(BlinkingBillboard, XMLPort, xmlelement, mode);
+
+        XMLPortParam(BlinkingBillboard, "amplitude", setAmplitude, getAmplitude, xmlelement, mode).defaultValues(1.0f);
+        XMLPortParam(BlinkingBillboard, "frequency", setFrequency, getFrequency, xmlelement, mode).defaultValues(1.0f);
+        XMLPortParam(BlinkingBillboard, "phase",     setPhase,     getPhase,     xmlelement, mode).defaultValues(Degree(0));
+        XMLPortParam(BlinkingBillboard, "quadratic", setQuadratic, isQuadratic,  xmlelement, mode).defaultValues(false);
+    }
+
+    void BlinkingBillboard::registerVariables()
+    {
+//        REGISTERDATA(this->amplitude_, network::direction::toclient);
+//        REGISTERDATA(this->frequency_, network::direction::toclient);
+//        REGISTERDATA(this->phase_,     network::direction::toclient);
+    }
+
+    void BlinkingBillboard::tick(float dt)
+    {
+        if (Core::isMaster() && this->isActive())
+        {
+            this->time_ += dt;
+            if (this->bQuadratic_)
+                this->setScale(this->amplitude_ * square(sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_)));
+            else
+                this->setScale(this->amplitude_ * sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_));
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/BlinkingBillboard.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/BlinkingBillboard.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/BlinkingBillboard.h	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _BlinkingBillboard_H__
+#define _BlinkingBillboard_H__
+
+#include "OrxonoxPrereqs.h"
+#include "Billboard.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BlinkingBillboard : public Billboard, public Tickable
+    {
+        public:
+            BlinkingBillboard(BaseObject* creator);
+            virtual ~BlinkingBillboard();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            virtual void tick(float dt);
+
+            inline void setAmplitude(float amplitude)
+                { this->amplitude_ = amplitude; }
+            inline float getAmplitude() const
+                { return this->amplitude_; }
+
+            inline void setFrequency(float frequency)
+                { this->frequency_ = frequency; }
+            inline float getFrequency() const
+                { return this->frequency_; }
+
+            inline void setPhase(const Degree& phase)
+                { this->phase_ = phase; }
+            inline const Degree& getPhase() const
+                { return this->phase_; }
+
+            inline void setQuadratic(bool bQuadratic)
+                { this->bQuadratic_ = bQuadratic; }
+            inline bool isQuadratic() const
+                { return this->bQuadratic_; }
+
+        private:
+            float amplitude_;
+            float frequency_;
+            Degree phase_;
+            bool bQuadratic_;
+            long double time_;
+    };
+}
+
+#endif /* _BlinkingBillboard_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/Camera.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Camera.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Camera.cc	(revision 2122)
@@ -0,0 +1,126 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Benjamin Knecht
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Camera.h"
+
+#include <string>
+#include <cassert>
+
+#include <OgreCamera.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreViewport.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "objects/Scene.h"
+#include "CameraManager.h"
+
+namespace orxonox
+{
+    CreateFactory(Camera);
+
+    Camera::Camera(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(Camera);
+
+        assert(this->getScene());
+        assert(this->getScene()->getSceneManager());
+
+        this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
+        this->getNode()->attachObject(this->camera_);
+
+        this->bHasFocus_ = false;
+        this->bDrag_ = false;
+        this->nearClipDistance_ = 1;
+
+        this->setObjectMode(0x0);
+
+        this->setConfigValues();
+        this->configvaluecallback_changedNearClipDistance();
+
+        this->requestFocus(); // ! HACK ! REMOVE THIS !
+    }
+
+    Camera::~Camera()
+    {
+        if (this->isInitialized())
+        {
+            this->releaseFocus();
+        }
+    }
+
+    void Camera::setConfigValues()
+    {
+        SetConfigValue(nearClipDistance_, 1.0f).callback(this, &Camera::configvaluecallback_changedNearClipDistance);
+    }
+
+    void Camera::configvaluecallback_changedNearClipDistance()
+    {
+        this->camera_->setNearClipDistance(this->nearClipDistance_);
+    }
+
+    void Camera::tick(float dt)
+    {
+/*
+        // this stuff here may need some adjustments
+        float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
+
+        Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition();
+        this->cameraNode_->translate(coeff * offset);
+
+        this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
+*/
+    }
+
+    void Camera::requestFocus()
+    {
+        CameraManager::getInstance().requestFocus(this);
+    }
+
+    void Camera::releaseFocus()
+    {
+        CameraManager::getInstance().releaseFocus(this);
+    }
+
+    /**
+        what to do when camera loses focus (do not request focus in this function!!)
+        this is called by the CameraManager singleton class to notify the camera
+    */
+    void Camera::removeFocus()
+    {
+        this->bHasFocus_ = false;
+    }
+
+    void Camera::setFocus(Ogre::Viewport* viewport)
+    {
+        this->bHasFocus_ = true;
+        viewport->setCamera(this->camera_);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/Camera.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Camera.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Camera.h	(revision 2122)
@@ -0,0 +1,74 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Benjamin Knecht
+ *
+ */
+
+#ifndef _Camera_H__
+#define _Camera_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "objects/worldentities/PositionableEntity.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Camera : public PositionableEntity, public Tickable
+    {
+        friend class CameraManager;
+
+        public:
+            Camera(BaseObject* creator);
+            virtual ~Camera();
+
+            void setConfigValues();
+            virtual void tick(float dt);
+
+            void requestFocus();
+            void releaseFocus();
+
+            inline bool hasFocus()
+                { return this->bHasFocus_; }
+
+            inline void setDrag(bool bDrag)
+                { this->bDrag_ = bDrag; }
+            inline bool getDrag() const
+                { return this->bDrag_; }
+
+        private:
+            void removeFocus();
+            void setFocus(Ogre::Viewport* viewport);
+            void configvaluecallback_changedNearClipDistance();
+
+            Ogre::Camera*   camera_;
+            float           nearClipDistance_;
+            bool            bHasFocus_;
+            bool            bDrag_;
+    };
+}
+
+#endif /* _Camera_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/CameraPosition.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/CameraPosition.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/CameraPosition.cc	(revision 2122)
@@ -0,0 +1,65 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "CameraPosition.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "Camera.h"
+
+namespace orxonox
+{
+    CreateFactory(CameraPosition);
+
+    CameraPosition::CameraPosition(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(CameraPosition);
+
+        this->bDrag_ = false;
+
+        this->setObjectMode(0x0);
+    }
+
+    CameraPosition::~CameraPosition()
+    {
+    }
+
+    void CameraPosition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(CameraPosition, XMLPort, xmlelement, mode);
+
+        XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false);
+    }
+
+    void CameraPosition::attachCamera(Camera* camera)
+    {
+        camera->setDrag(this->bDrag_);
+        this->attach(camera);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/CameraPosition.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/CameraPosition.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/CameraPosition.h	(revision 2122)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CameraPosition_H__
+#define _CameraPosition_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/worldentities/PositionableEntity.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport CameraPosition : public PositionableEntity
+    {
+        public:
+            CameraPosition(BaseObject* creator);
+            virtual ~CameraPosition();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            inline void setDrag(bool bDrag)
+                { this->bDrag_ = bDrag; }
+            inline bool getDrag() const
+                { return this->bDrag_; }
+
+            void attachCamera(Camera* camera);
+
+        private:
+            bool bDrag_;
+    };
+}
+
+#endif /* _CameraPosition_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2122)
@@ -0,0 +1,477 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ControllableEntity.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+#include "core/XMLPort.h"
+#include "core/Template.h"
+
+#include "objects/infos/PlayerInfo.h"
+#include "objects/worldentities/Camera.h"
+#include "objects/worldentities/CameraPosition.h"
+#include "overlays/OverlayGroup.h"
+
+namespace orxonox
+{
+    CreateFactory(ControllableEntity);
+
+    ControllableEntity::ControllableEntity(BaseObject* creator) : WorldEntity(creator)
+    {
+        RegisterObject(ControllableEntity);
+
+        this->bControlled_ = false;
+        this->server_overwrite_ = 0;
+        this->client_overwrite_ = 0;
+        this->player_ = 0;
+        this->playerID_ = network::OBJECTID_UNKNOWN;
+        this->hud_ = 0;
+        this->camera_ = 0;
+        this->bDestroyWhenPlayerLeft_ = false;
+
+        this->velocity_ = Vector3::ZERO;
+        this->acceleration_ = Vector3::ZERO;
+
+        this->server_position_ = Vector3::ZERO;
+        this->client_position_ = Vector3::ZERO;
+        this->server_velocity_ = Vector3::ZERO;
+        this->client_velocity_ = Vector3::ZERO;
+        this->server_orientation_ = Quaternion::IDENTITY;
+        this->client_orientation_ = Quaternion::IDENTITY;
+
+        this->registerVariables();
+    }
+
+    ControllableEntity::~ControllableEntity()
+    {
+        if (this->isInitialized())
+        {
+            if (this->bControlled_)
+                this->stopLocalControl();
+
+            if (this->hud_)
+                delete this->hud_;
+
+            if (this->camera_)
+                delete this->camera_;
+
+            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
+                this->getPlayer()->stopControl(this, false);
+        }
+    }
+
+    void ControllableEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(ControllableEntity, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ControllableEntity, "hudtemplate", setHudTemplate, getHudTemplate, xmlelement, mode);
+        XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemkplate, xmlelement, mode);
+
+        XMLPortObject(ControllableEntity, CameraPosition, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode);
+    }
+
+    void ControllableEntity::addCameraPosition(CameraPosition* position)
+    {
+        this->attach(position);
+        this->cameraPositions_.push_back(position);
+    }
+
+    CameraPosition* ControllableEntity::getCameraPosition(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
+
+    void ControllableEntity::switchCamera()
+    {
+        if (this->camera_)
+        {
+            if (this->camera_->getParent() == this && this->cameraPositions_.size() > 0)
+            {
+                this->cameraPositions_.front()->attachCamera(this->camera_);
+            }
+            else if (this->cameraPositions_.size() > 0)
+            {
+                for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+                {
+                    if ((*it) == this->camera_->getParent())
+                    {
+                        ++it;
+                        if (it != this->cameraPositions_.end())
+                            (*it)->attachCamera(this->camera_);
+                        else
+                            (*this->cameraPositions_.begin())->attachCamera(this->camera_);
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                this->attach(this->camera_);
+            }
+        }
+    }
+
+    void ControllableEntity::setPlayer(PlayerInfo* player)
+    {
+        if (!player)
+        {
+            this->removePlayer();
+            return;
+        }
+
+        this->player_ = player;
+        this->playerID_ = player->getObjectID();
+        this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer());
+        if (this->bControlled_)
+        {
+            this->startLocalControl();
+
+            if (!Core::isMaster())
+            {
+                this->client_overwrite_ = this->server_overwrite_;
+COUT(0) << "CE: bidirectional synchronization" << std::endl;
+                this->setObjectMode(network::direction::bidirectional);
+            }
+        }
+    }
+
+    void ControllableEntity::removePlayer()
+    {
+        if (this->bControlled_)
+            this->stopLocalControl();
+
+        this->player_ = 0;
+        this->playerID_ = network::OBJECTID_UNKNOWN;
+        this->bControlled_ = false;
+        this->setObjectMode(network::direction::toclient);
+
+        if (this->bDestroyWhenPlayerLeft_)
+            delete this;
+    }
+
+    void ControllableEntity::networkcallback_changedplayerID()
+    {
+        // just do this in case the entity wasn't yet synchronized when the corresponding PlayerInfo got our objectID
+        if (this->playerID_ != network::OBJECTID_UNKNOWN)
+        {
+            this->player_ = dynamic_cast<PlayerInfo*>(network::Synchronisable::getSynchronisable(this->playerID_));
+            if (this->player_ && (this->player_->getControllableEntity() != this))
+                this->player_->startControl(this);
+        }
+    }
+
+    void ControllableEntity::startLocalControl()
+    {
+//        std::cout << this->getObjectID() << " ###### start local control" << std::endl;
+        this->camera_ = new Camera(this);
+        this->camera_->requestFocus();
+        if (this->cameraPositionTemplate_ != "")
+            this->addTemplate(this->cameraPositionTemplate_);
+        if (this->cameraPositions_.size() > 0)
+            this->cameraPositions_.front()->attachCamera(this->camera_);
+        else
+            this->attach(this->camera_);
+
+        if (this->hudtemplate_ != "")
+        {
+            this->hud_ = new OverlayGroup(this);
+            this->hud_->addTemplate(this->hudtemplate_);
+        }
+    }
+
+    void ControllableEntity::stopLocalControl()
+    {
+//        std::cout << "###### stop local control" << std::endl;
+        this->camera_->detachFromParent();
+        delete this->camera_;
+        this->camera_ = 0;
+
+        delete this->hud_;
+        this->hud_ = 0;
+    }
+
+    void ControllableEntity::tick(float dt)
+    {
+        if (this->isActive())
+        {
+            this->velocity_ += (dt * this->acceleration_);
+            this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
+
+            if (Core::isMaster())
+            {
+                this->server_velocity_ = this->velocity_;
+                this->server_position_ = this->node_->getPosition();
+            }
+            else if (this->bControlled_)
+            {
+//                COUT(2) << "setting client position" << endl;
+                this->client_velocity_ = this->velocity_;
+                this->client_position_ = this->node_->getPosition();
+            }
+        }
+    }
+
+    void ControllableEntity::registerVariables()
+    {
+        REGISTERSTRING(this->cameraPositionTemplate_, network::direction::toclient);
+
+        REGISTERDATA(this->server_position_,    network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
+        REGISTERDATA(this->server_velocity_,    network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
+        REGISTERDATA(this->server_orientation_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
+
+        REGISTERDATA(this->server_overwrite_,   network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
+        REGISTERDATA(this->client_overwrite_,   network::direction::toserver);
+
+        REGISTERDATA(this->client_position_,    network::direction::toserver, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
+        REGISTERDATA(this->client_velocity_,    network::direction::toserver, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
+        REGISTERDATA(this->client_orientation_, network::direction::toserver, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
+
+
+        REGISTERDATA(this->playerID_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
+    }
+
+    void ControllableEntity::processServerPosition()
+    {
+        if (!this->bControlled_)
+            this->node_->setPosition(this->server_position_);
+    }
+
+    void ControllableEntity::processServerVelocity()
+    {
+        if (!this->bControlled_)
+            this->velocity_ = this->server_velocity_;
+    }
+
+    void ControllableEntity::processServerOrientation()
+    {
+        if (!this->bControlled_)
+            this->node_->setOrientation(this->server_orientation_);
+    }
+
+    void ControllableEntity::processOverwrite()
+    {
+        if (this->bControlled_)
+        {
+            this->setPosition(this->server_position_);
+            this->setVelocity(this->server_velocity_);
+            this->setOrientation(this->server_orientation_);
+
+            this->client_overwrite_ = this->server_overwrite_;
+        }
+    }
+
+    void ControllableEntity::processClientPosition()
+    {
+        if (this->server_overwrite_ == this->client_overwrite_)
+        {
+//            COUT(2) << "callback: setting client position" << endl;
+            this->node_->setPosition(this->client_position_);
+            this->server_position_ = this->client_position_;
+        }
+//        else
+//          COUT(2) << "callback: not setting client position" << endl;
+    }
+
+    void ControllableEntity::processClientVelocity()
+    {
+        if (this->server_overwrite_ == this->client_overwrite_)
+        {
+            this->velocity_ = this->client_velocity_;
+            this->server_velocity_ = this->client_velocity_;
+        }
+    }
+
+    void ControllableEntity::processClientOrientation()
+    {
+        if (this->server_overwrite_ == this->client_overwrite_)
+        {
+            this->node_->setOrientation(this->client_orientation_);
+            this->server_orientation_ = this->client_orientation_;
+        }
+    }
+
+
+    void ControllableEntity::setPosition(const Vector3& position)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->setPosition(position);
+            this->server_position_ = position;
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->setPosition(position);
+            this->client_position_ = position;
+        }
+    }
+
+    void ControllableEntity::setVelocity(const Vector3& velocity)
+    {
+        if (Core::isMaster())
+        {
+            this->velocity_ = velocity;
+            this->server_velocity_ = velocity;
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->velocity_ = velocity;
+            this->client_velocity_ = velocity;
+        }
+    }
+
+    void ControllableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->translate(distance, relativeTo);
+            this->server_position_ = this->node_->getPosition();
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->translate(distance, relativeTo);
+            this->client_position_ = this->node_->getPosition();
+        }
+    }
+
+    void ControllableEntity::setOrientation(const Quaternion& orientation)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->setOrientation(orientation);
+            this->server_orientation_ = orientation;
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->setOrientation(orientation);
+            this->client_orientation_ = orientation;
+        }
+    }
+
+    void ControllableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->rotate(rotation, relativeTo);
+            this->server_orientation_ = this->node_->getOrientation();
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->rotate(rotation, relativeTo);
+            this->client_orientation_ = this->node_->getOrientation();
+        }
+    }
+
+    void ControllableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->yaw(angle, relativeTo);
+            this->server_orientation_ = this->node_->getOrientation();
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->yaw(angle, relativeTo);
+            this->client_orientation_ = this->node_->getOrientation();
+        }
+    }
+
+    void ControllableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->pitch(angle, relativeTo);
+            this->server_orientation_ = this->node_->getOrientation();
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->pitch(angle, relativeTo);
+            this->client_orientation_ = this->node_->getOrientation();
+        }
+    }
+
+    void ControllableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->roll(angle, relativeTo);
+            this->server_orientation_ = this->node_->getOrientation();
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->roll(angle, relativeTo);
+            this->client_orientation_ = this->node_->getOrientation();
+        }
+    }
+
+    void ControllableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->lookAt(target, relativeTo, localDirectionVector);
+            this->server_orientation_ = this->node_->getOrientation();
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->lookAt(target, relativeTo, localDirectionVector);
+            this->client_orientation_ = this->node_->getOrientation();
+        }
+    }
+
+    void ControllableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
+    {
+        if (Core::isMaster())
+        {
+            this->node_->setDirection(direction, relativeTo, localDirectionVector);
+            this->server_orientation_ = this->node_->getOrientation();
+            ++this->server_overwrite_;
+        }
+        else if (this->bControlled_)
+        {
+            this->node_->setDirection(direction, relativeTo, localDirectionVector);
+            this->client_orientation_ = this->node_->getOrientation();
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h	(revision 2122)
@@ -0,0 +1,176 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ControllableEntity_H__
+#define _ControllableEntity_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable
+    {
+        public:
+            ControllableEntity(BaseObject* creator);
+            virtual ~ControllableEntity();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            void registerVariables();
+
+            virtual void setPlayer(PlayerInfo* player);
+            virtual void removePlayer();
+            inline PlayerInfo* getPlayer() const
+                { return this->player_; }
+
+            inline void setDestroyWhenPlayerLeft(bool bDestroy)
+                { this->bDestroyWhenPlayerLeft_ = bDestroy; }
+            inline bool getDestroyWhenPlayerLeft() const
+                { return this->bDestroyWhenPlayerLeft_; }
+
+            virtual void moveFrontBack(const Vector2& value) {}
+            virtual void moveRightLeft(const Vector2& value) {}
+            virtual void moveUpDown(const Vector2& value) {}
+
+            virtual void rotateYaw(const Vector2& value) {}
+            virtual void rotatePitch(const Vector2& value) {}
+            virtual void rotateRoll(const Vector2& value) {}
+
+            virtual void fire() {}
+            virtual void altFire() {}
+
+            virtual void greet() {}
+            virtual void use() {}
+            virtual void switchCamera();
+
+            inline const Vector3& getVelocity() const
+                { return this->velocity_; }
+            inline const Vector3& getAcceleration() const
+                { return this->acceleration_; }
+            inline const std::string& getHudTemplate() const
+                { return this->hudtemplate_; }
+
+            using WorldEntity::setPosition;
+            using WorldEntity::translate;
+            using WorldEntity::setOrientation;
+            using WorldEntity::rotate;
+            using WorldEntity::yaw;
+            using WorldEntity::pitch;
+            using WorldEntity::roll;
+            using WorldEntity::lookAt;
+            using WorldEntity::setDirection;
+
+            void setPosition(const Vector3& position);
+            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void setOrientation(const Quaternion& orientation);
+            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
+            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
+
+            void setVelocity(const Vector3& velocity);
+            inline void setVelocity(float x, float y, float z)
+                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
+
+            inline void setAcceleration(const Vector3& acceleration)
+                { this->acceleration_ = acceleration; }
+            inline void setAcceleration(float x, float y, float z)
+                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
+
+            inline Camera* getCamera() const
+                { return this->camera_; }
+            inline OverlayGroup* getHUD() const
+                { return this->hud_; }
+
+            void addCameraPosition(CameraPosition* position);
+            CameraPosition* getCameraPosition(unsigned int index) const;
+            inline const std::list<CameraPosition*>& getCameraPositions() const
+                { return this->cameraPositions_; }
+
+            inline void setCameraPositionTemplate(const std::string& name)
+                { this->cameraPositionTemplate_ = name; }
+            inline const std::string& getCameraPositionTemkplate() const
+                { return this->cameraPositionTemplate_; }
+
+        protected:
+            virtual void startLocalControl();
+            virtual void stopLocalControl();
+
+            inline void setHudTemplate(const std::string& name)
+                { this->hudtemplate_ = name; }
+
+            inline bool isLocallyControlled() const
+                { return this->bControlled_; }
+
+            Vector3 acceleration_;
+
+        private:
+            void overwrite();
+            void processOverwrite();
+
+            void processServerPosition();
+            void processServerVelocity();
+            void processServerOrientation();
+
+            void processClientPosition();
+            void processClientVelocity();
+            void processClientOrientation();
+
+            void networkcallback_changedplayerID();
+
+            unsigned int server_overwrite_;
+            unsigned int client_overwrite_;
+
+            Vector3 velocity_;
+
+            bool bControlled_;
+            Vector3 server_position_;
+            Vector3 client_position_;
+            Vector3 server_velocity_;
+            Vector3 client_velocity_;
+            Quaternion server_orientation_;
+            Quaternion client_orientation_;
+
+            PlayerInfo* player_;
+            unsigned int playerID_;
+            std::string hudtemplate_;
+            OverlayGroup* hud_;
+            Camera* camera_;
+            bool bDestroyWhenPlayerLeft_;
+
+            std::list<CameraPosition*> cameraPositions_;
+            std::string cameraPositionTemplate_;
+    };
+}
+
+#endif /* _ControllableEntity_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/Light.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Light.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Light.cc	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Light.h"
+
+#include <sstream>
+#include <cassert>
+
+#include <OgreSceneManager.h>
+
+#include "util/String.h"
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+    unsigned int Light::lightCounter_s = 0;
+
+    CreateFactory(Light);
+
+    Light::Light(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(Light);
+
+        if (this->getScene() && this->getScene()->getSceneManager())
+        this->light_ = this->getScene()->getSceneManager()->createLight("Light" + convertToString(Light::lightCounter_s++));
+        this->getNode()->attachObject(this->light_);
+
+        this->registerVariables();
+    }
+
+    Light::~Light()
+    {
+        if (this->isInitialized())
+        {
+            if (this->light_ && this->getScene() && this->getScene()->getSceneManager())
+                this->getScene()->getSceneManager()->destroyLight(this->light_);
+        }
+    }
+
+    void Light::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Light, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point");
+        XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "diffuse",   setDiffuseColour,  getDiffuseColour,  xmlelement, mode, const ColourValue&);
+        XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "specular",  setSpecularColour, getSpecularColour, xmlelement, mode, const ColourValue&);
+        XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "direction", setDirection,      getDirection,      xmlelement, mode, const Vector3&);
+    }
+
+    void Light::registerVariables()
+    {
+        REGISTERDATA(this->type_, network::direction::toclient, new network::NetworkCallback<Light>(this, &Light::changedType));
+        REGISTERDATA(this->light_->getDiffuseColour(), network::direction::toclient);
+        REGISTERDATA(this->light_->getSpecularColour(), network::direction::toclient);
+        REGISTERDATA(this->light_->getDirection(), network::direction::toclient);
+    }
+
+    const std::string& Light::getName() const
+    {
+        if (this->light_)
+            return this->light_->getName();
+        else
+            return BLANKSTRING;
+    }
+
+    void Light::setDiffuseColour(const ColourValue& colour)
+    {
+        if (this->light_)
+            this->light_->setDiffuseColour(colour);
+    }
+
+    const ColourValue& Light::getDiffuseColour() const
+    {
+        if (this->light_)
+            return this->light_->getDiffuseColour();
+        else
+            return ColourValue::White;
+    }
+
+    void Light::setSpecularColour(const ColourValue& colour)
+    {
+        if (this->light_)
+            this->light_->setSpecularColour(colour);
+    }
+
+    const ColourValue& Light::getSpecularColour() const
+    {
+        if (this->light_)
+            return this->light_->getSpecularColour();
+        else
+            return ColourValue::White;
+    }
+
+    void Light::setDirection(const Vector3& direction)
+    {
+        if (this->light_)
+            this->light_->setDirection(direction);
+    }
+
+    const Vector3& Light::getDirection() const
+    {
+        if (this->light_)
+            return this->light_->getDirection();
+        else
+            return Vector3::ZERO;
+    }
+
+    void Light::setTypeString(const std::string& type)
+    {
+        if (type == "point")
+            this->setType(Ogre::Light::LT_POINT);
+        else if (type == "directional")
+            this->setType(Ogre::Light::LT_DIRECTIONAL);
+        else if (type == "spotlight")
+            this->setType(Ogre::Light::LT_SPOTLIGHT);
+        else
+            this->setType(Ogre::Light::LT_POINT);
+    }
+
+    std::string Light::getTypeString() const
+    {
+        switch (this->type_)
+        {
+            case Ogre::Light::LT_DIRECTIONAL:
+                return "directional";
+            case Ogre::Light::LT_SPOTLIGHT:
+                return "spotlight";
+            case Ogre::Light::LT_POINT:
+            default:
+                return "poinT";
+        }
+    }
+
+    void Light::changedType()
+    {
+        this->light_->setType(this->type_);
+    }
+
+    void Light::changedVisibility()
+    {
+        SUPER(Light, changedVisibility);
+
+        this->light_->setVisible(this->isVisible());
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/Light.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Light.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Light.h	(revision 2122)
@@ -0,0 +1,85 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Light_H__
+#define _Light_H__
+
+#include "OrxonoxPrereqs.h"
+#include "PositionableEntity.h"
+
+#include <string>
+#include <OgreLight.h>
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Light : public PositionableEntity
+    {
+        public:
+            Light(BaseObject* creator);
+            virtual ~Light();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            virtual void changedVisibility();
+
+            inline Ogre::Light* getLight()
+                { return this->light_; }
+
+            const std::string& getName() const;
+
+            inline void setType(Ogre::Light::LightTypes type)
+                { this->type_ = type; this->changedType(); }
+            Ogre::Light::LightTypes getType() const
+                { return this->type_; }
+
+            void setDiffuseColour(const ColourValue& colour);
+            const ColourValue& getDiffuseColour() const;
+
+            void setSpecularColour(const ColourValue& colour);
+            const ColourValue& getSpecularColour() const;
+
+            void setDirection(const Vector3& direction);
+            const Vector3& getDirection() const;
+
+        private:
+            void setTypeString(const std::string& type);
+            std::string getTypeString() const;
+
+            void changedType();
+
+            static unsigned int lightCounter_s;
+            Ogre::Light* light_;
+            Ogre::Light::LightTypes type_;
+
+    };
+}
+
+#endif /* _Light_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/Model.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Model.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Model.cc	(revision 2122)
@@ -0,0 +1,93 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "Model.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+    CreateFactory(Model);
+
+    Model::Model(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(Model);
+
+        this->registerVariables();
+    }
+
+    Model::~Model()
+    {
+        if (this->isInitialized() && this->mesh_.getEntity())
+            this->getNode()->detachObject(this->mesh_.getEntity());
+    }
+
+    void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Model, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
+        XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
+    }
+
+    void Model::registerVariables()
+    {
+        REGISTERSTRING(this->meshSrc_,    network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedMesh));
+        REGISTERDATA(this->bCastShadows_, network::direction::toclient, new network::NetworkCallback<Model>(this, &Model::changedShadows));
+    }
+
+    void Model::changedMesh()
+    {
+        if (this->mesh_.getEntity())
+            this->getNode()->detachObject(this->mesh_.getEntity());
+
+        this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
+
+        if (this->mesh_.getEntity())
+        {
+            this->getNode()->attachObject(this->mesh_.getEntity());
+            this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
+            this->mesh_.setVisible(this->isVisible());
+        }
+    }
+
+    void Model::changedShadows()
+    {
+        this->mesh_.setCastShadows(this->bCastShadows_);
+    }
+
+    void Model::changedVisibility()
+    {
+        SUPER(Model, changedVisibility);
+
+        this->mesh_.setVisible(this->isVisible());
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/Model.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/Model.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/Model.h	(revision 2122)
@@ -0,0 +1,72 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Model_H__
+#define _Model_H__
+
+#include "OrxonoxPrereqs.h"
+#include "PositionableEntity.h"
+#include "tools/Mesh.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Model : public PositionableEntity
+    {
+        public:
+            Model(BaseObject* creator);
+            virtual ~Model();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            virtual void changedVisibility();
+
+            inline const Mesh& getMesh() const
+                { return this->mesh_; }
+
+            inline void setMeshSource(const std::string& meshname)
+                { this->meshSrc_ = meshname; this->changedMesh(); }
+            inline const std::string& getMeshSource() const
+                { return this->meshSrc_; }
+
+            inline void setCastShadows(bool bCastShadows)
+                { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
+            inline bool getCastShadows() const
+                { return this->bCastShadows_; }
+
+        private:
+            void changedMesh();
+            void changedShadows();
+
+            std::string meshSrc_;
+            Mesh mesh_;
+            bool bCastShadows_;
+    };
+}
+
+#endif /* _PositionableEntity_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc	(revision 2122)
@@ -0,0 +1,178 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "MovableEntity.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Executor.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    static const float MAX_RESYNCHRONIZE_TIME = 3.0f;
+
+    CreateFactory(MovableEntity);
+
+    MovableEntity::MovableEntity(BaseObject* creator) : WorldEntity(creator)
+    {
+        RegisterObject(MovableEntity);
+
+        this->velocity_ = Vector3::ZERO;
+        this->acceleration_ = Vector3::ZERO;
+        this->rotationAxis_ = Vector3::ZERO;
+        this->rotationRate_ = 0;
+        this->momentum_ = 0;
+
+        this->overwrite_position_ = Vector3::ZERO;
+        this->overwrite_orientation_ = Quaternion::IDENTITY;
+
+        this->registerVariables();
+    }
+
+    MovableEntity::~MovableEntity()
+    {
+    }
+
+    void MovableEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(MovableEntity, XMLPort, xmlelement, mode);
+
+        XMLPortParamTemplate(MovableEntity, "velocity", setVelocity, getVelocity, xmlelement, mode, const Vector3&);
+        XMLPortParamTemplate(MovableEntity, "rotationaxis", setRotationAxis, getRotationAxis, xmlelement, mode, const Vector3&);
+        XMLPortParamTemplate(MovableEntity, "rotationrate", setRotationRate, getRotationRate, xmlelement, mode, const Degree&);
+    }
+
+    void MovableEntity::tick(float dt)
+    {
+        if (this->isActive())
+        {
+            this->velocity_ += (dt * this->acceleration_);
+            this->node_->translate(dt * this->velocity_);
+
+            this->rotationRate_ += (dt * this->momentum_);
+            this->node_->rotate(this->rotationAxis_, this->rotationRate_  * dt);
+        }
+    }
+
+    void MovableEntity::registerVariables()
+    {
+        REGISTERDATA(this->velocity_.x, network::direction::toclient);
+        REGISTERDATA(this->velocity_.y, network::direction::toclient);
+        REGISTERDATA(this->velocity_.z, network::direction::toclient);
+
+        REGISTERDATA(this->rotationAxis_.x, network::direction::toclient);
+        REGISTERDATA(this->rotationAxis_.y, network::direction::toclient);
+        REGISTERDATA(this->rotationAxis_.z, network::direction::toclient);
+
+        REGISTERDATA(this->rotationRate_, network::direction::toclient);
+
+        REGISTERDATA(this->overwrite_position_,    network::direction::toclient, new network::NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
+        REGISTERDATA(this->overwrite_orientation_, network::direction::toclient, new network::NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
+    }
+
+    void MovableEntity::overwritePosition()
+    {
+        this->node_->setPosition(this->overwrite_position_);
+    }
+
+    void MovableEntity::overwriteOrientation()
+    {
+        this->node_->setOrientation(this->overwrite_orientation_);
+    }
+
+    void MovableEntity::clientConnected(unsigned int clientID)
+    {
+        new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), true);
+    }
+
+    void MovableEntity::clientDisconnected(unsigned int clientID)
+    {
+    }
+
+    void MovableEntity::resynchronize()
+    {
+        this->overwrite_position_ = this->getPosition();
+        this->overwrite_orientation_ = this->getOrientation();
+    }
+
+    void MovableEntity::setPosition(const Vector3& position)
+    {
+        this->node_->setPosition(position);
+        this->overwrite_position_ = this->node_->getPosition();
+    }
+
+    void MovableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
+    {
+        this->node_->translate(distance, relativeTo);
+        this->overwrite_position_ = this->node_->getPosition();
+    }
+
+    void MovableEntity::setOrientation(const Quaternion& orientation)
+    {
+        this->node_->setOrientation(orientation);
+        this->overwrite_orientation_ = this->node_->getOrientation();
+    }
+
+    void MovableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
+    {
+        this->node_->rotate(rotation, relativeTo);
+        this->overwrite_orientation_ = this->node_->getOrientation();
+    }
+
+    void MovableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
+    {
+        this->node_->yaw(angle, relativeTo);
+        this->overwrite_orientation_ = this->node_->getOrientation();
+    }
+
+    void MovableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
+    {
+        this->node_->pitch(angle, relativeTo);
+        this->overwrite_orientation_ = this->node_->getOrientation();
+    }
+
+    void MovableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
+    {
+        this->node_->roll(angle, relativeTo);
+        this->overwrite_orientation_ = this->node_->getOrientation();
+    }
+
+    void MovableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
+    {
+        this->node_->lookAt(target, relativeTo, localDirectionVector);
+        this->overwrite_orientation_ = this->node_->getOrientation();
+    }
+
+    void MovableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
+    {
+        this->node_->setDirection(direction, relativeTo, localDirectionVector);
+        this->overwrite_orientation_ = this->node_->getOrientation();
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h	(revision 2122)
@@ -0,0 +1,124 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _MovableEntity_H__
+#define _MovableEntity_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "objects/Tickable.h"
+#include "network/ClientConnectionListener.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport MovableEntity : public WorldEntity, public Tickable, public network::ClientConnectionListener
+    {
+        public:
+            MovableEntity(BaseObject* creator);
+            virtual ~MovableEntity();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            void registerVariables();
+
+            using WorldEntity::setPosition;
+            using WorldEntity::translate;
+            using WorldEntity::setOrientation;
+            using WorldEntity::rotate;
+            using WorldEntity::yaw;
+            using WorldEntity::pitch;
+            using WorldEntity::roll;
+            using WorldEntity::lookAt;
+            using WorldEntity::setDirection;
+
+            void setPosition(const Vector3& position);
+            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void setOrientation(const Quaternion& orientation);
+            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
+            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
+            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
+
+            inline void setVelocity(const Vector3& velocity)
+                { this->velocity_ = velocity; }
+            inline void setVelocity(float x, float y, float z)
+                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
+            inline const Vector3& getVelocity() const
+                { return this->velocity_; }
+
+            inline void setAcceleration(const Vector3& acceleration)
+                { this->acceleration_ = acceleration; }
+            inline void setAcceleration(float x, float y, float z)
+                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
+            inline const Vector3& getAcceleration() const
+                { return this->acceleration_; }
+
+            inline void setRotationAxis(const Vector3& axis)
+                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
+            inline void setRotationAxis(float x, float y, float z)
+                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
+            inline const Vector3& getRotationAxis() const
+                { return this->rotationAxis_; }
+
+            inline void setRotationRate(const Degree& angle)
+                { this->rotationRate_ = angle; }
+            inline void setRotationRate(const Radian& angle)
+                { this->rotationRate_ = angle; }
+            inline const Degree& getRotationRate() const
+                { return this->rotationRate_; }
+
+            inline void setMomentum(const Degree& angle)
+                { this->momentum_ = angle; }
+            inline void setMomentum(const Radian& angle)
+                { this->momentum_ = angle; }
+            inline const Degree& getMomentum() const
+                { return this->momentum_; }
+
+        private:
+            void clientConnected(unsigned int clientID);
+            void clientDisconnected(unsigned int clientID);
+            void resynchronize();
+
+            void overwritePosition();
+            void overwriteOrientation();
+
+            Vector3 velocity_;
+            Vector3 acceleration_;
+            Vector3 rotationAxis_;
+            Degree rotationRate_;
+            Degree momentum_;
+
+            Vector3 overwrite_position_;
+            Quaternion overwrite_orientation_;
+    };
+}
+
+#endif /* _MovableEntity_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/ParticleEmitter.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/ParticleEmitter.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/ParticleEmitter.cc	(revision 2122)
@@ -0,0 +1,125 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+* @file ParticleInterface.cc
+* @brief class to control praticle effects
+*/
+
+#include "OrxonoxStableHeaders.h"
+
+#include "ParticleEmitter.h"
+
+#include "tools/ParticleInterface.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+    CreateFactory(ParticleEmitter);
+
+    ParticleEmitter::ParticleEmitter(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(ParticleEmitter);
+
+        assert(this->getScene());
+        assert(this->getScene()->getSceneManager());
+
+        this->particles_ = 0;
+        this->LOD_ = LODParticle::normal;
+
+        this->registerVariables();
+    }
+
+    ParticleEmitter::~ParticleEmitter()
+    {
+        if (this->isInitialized() && this->particles_)
+            delete this->particles_;
+    }
+
+    void ParticleEmitter::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(ParticleEmitter, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ParticleEmitter, "lod",    setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::normal);
+        XMLPortParam(ParticleEmitter, "source", setSource, getSource, xmlelement, mode);
+    }
+
+    void ParticleEmitter::registerVariables()
+    {
+        REGISTERSTRING(this->source_, network::direction::toclient, new network::NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
+        REGISTERDATA  (this->LOD_,    network::direction::toclient, new network::NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
+    }
+
+    void ParticleEmitter::changedVisibility()
+    {
+        SUPER(ParticleEmitter, changedVisibility);
+
+        if (this->particles_)
+            this->particles_->setVisible(this->isVisible());
+    }
+
+    void ParticleEmitter::changedActivity()
+    {
+        SUPER(ParticleEmitter, changedActivity);
+
+        if (this->particles_)
+            this->particles_->setEnabled(this->isActive());
+    }
+
+    void ParticleEmitter::sourceChanged()
+    {
+        if (this->particles_)
+            delete this->particles_;
+
+        if (this->getScene() && this->getScene()->getSceneManager())
+        {
+            try
+            {
+                this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_);
+                this->particles_->addToSceneNode(this->getNode());
+                this->particles_->setVisible(this->isVisible());
+                this->particles_->setEnabled(this->isActive());
+            }
+            catch (...)
+            {
+                COUT(1) << "Error: Couln't load particle effect \"" << this->source_ << "\"" << std::endl;
+                this->particles_ = 0;
+            }
+        }
+        else
+            this->particles_ = 0;
+    }
+
+    void ParticleEmitter::LODchanged()
+    {
+        if (this->particles_)
+            this->particles_->setDetailLevel(this->LOD_);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/ParticleEmitter.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/ParticleEmitter.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/ParticleEmitter.h	(revision 2122)
@@ -0,0 +1,77 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleEmitter_H__
+#define _ParticleEmitter_H__
+
+#include "OrxonoxPrereqs.h"
+#include "PositionableEntity.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ParticleEmitter : public PositionableEntity
+    {
+        public:
+            ParticleEmitter(BaseObject* creator);
+            ~ParticleEmitter();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            virtual void changedVisibility();
+            virtual void changedActivity();
+
+            inline ParticleInterface* getParticleInterface() const
+                { return this->particles_; }
+
+            inline void setSource(const std::string& source)
+                { this->source_ = source; this->sourceChanged(); }
+            inline const std::string& getSource() const
+                { return this->source_; }
+
+            inline void setLOD(LODParticle::LOD level)
+                { this->LOD_ = level; this->LODchanged(); }
+            inline LODParticle::LOD getLOD() const
+                { return this->LOD_; }
+
+        protected:
+            inline void setLODxml(unsigned int level)
+                { this->LOD_ = (LODParticle::LOD)level; this->LODchanged(); }
+            inline unsigned int getLODxml() const
+                { return (unsigned int)this->LOD_; }
+
+            void sourceChanged();
+            void LODchanged();
+
+            ParticleInterface* particles_;
+            std::string        source_;
+            LODParticle::LOD   LOD_;
+    };
+}
+
+#endif /* _ParticleEmitter_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/ParticleSpawner.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/ParticleSpawner.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/ParticleSpawner.cc	(revision 2122)
@@ -0,0 +1,131 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ParticleSpawner.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/Executor.h"
+#include "core/XMLPort.h"
+#include "tools/ParticleInterface.h"
+
+namespace orxonox
+{
+    CreateFactory(ParticleSpawner);
+
+    ParticleSpawner::ParticleSpawner(BaseObject* creator) : ParticleEmitter(creator)
+    {
+        RegisterObject(ParticleSpawner);
+
+        this->bAutostart_ = true;
+        this->bSuppressStart_ = false;
+        this->bAutoDestroy_ = true;
+        this->bForceDestroy_ = false;
+        this->bLoop_ = false;
+        this->startdelay_ = 0;
+        this->lifetime_ = 0;
+        this->destroydelay_ = 0;
+
+        this->startParticleSpawner();
+    }
+
+    ParticleSpawner::~ParticleSpawner()
+    {
+    }
+
+    void ParticleSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(ParticleSpawner, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ParticleSpawner, "autostart",    setAutoStart,        getAutoStart,        xmlelement, mode).defaultValues(true);
+        XMLPortParam(ParticleSpawner, "autodestroy",  setDestroyAfterLife, getDestroyAfterLife, xmlelement, mode).defaultValues(false);
+        XMLPortParam(ParticleSpawner, "loop",         setLoop,             getLoop,             xmlelement, mode).defaultValues(false);
+        XMLPortParam(ParticleSpawner, "lifetime",     setLifetime,         getLifetime,         xmlelement, mode).defaultValues(0.0f);
+        XMLPortParam(ParticleSpawner, "startdelay",   setStartdelay,       getStartdelay,       xmlelement, mode).defaultValues(0.0f);
+        XMLPortParam(ParticleSpawner, "destroydelay", setDestroydelay,     getDestroydelay,     xmlelement, mode).defaultValues(0.0f);
+    }
+
+    void ParticleSpawner::processEvent(Event& event)
+    {
+        SUPER(ParticleSpawner, processEvent, event);
+
+        SetEvent(ParticleSpawner, "spawn", spawn, event);
+    }
+
+    void ParticleSpawner::configure(float lifetime, float startdelay, float destroydelay, bool autodestroy)
+    {
+        this->bAutoDestroy_ = autodestroy;
+        this->startdelay_ = startdelay;
+        this->lifetime_ = lifetime;
+        this->destroydelay_ = destroydelay;
+    }
+
+    void ParticleSpawner::startParticleSpawner()
+    {
+        if (!this->particles_)
+            return;
+
+        this->setActive(false);
+
+        if (this->bForceDestroy_ || this->bSuppressStart_)
+            return;
+
+        this->timer_.setTimer(this->startdelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner)));
+    }
+
+    void ParticleSpawner::fireParticleSpawner()
+    {
+        this->setActive(true);
+        if (this->lifetime_ != 0)
+            this->timer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&ParticleSpawner::stopParticleSpawner)));
+    }
+
+    void ParticleSpawner::stopParticleSpawner()
+    {
+        this->setActive(false);
+
+        if (this->bAutoDestroy_ || this->bForceDestroy_)
+        {
+            this->setPosition(this->getWorldPosition());
+            this->detachFromParent();
+
+            if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_)
+                this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
+        }
+        else if (this->bLoop_)
+        {
+            this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner)));
+        }
+    }
+
+    void ParticleSpawner::destroyParticleSpawner()
+    {
+        delete this;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/ParticleSpawner.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/ParticleSpawner.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/ParticleSpawner.h	(revision 2122)
@@ -0,0 +1,104 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleSpawner_H__
+#define _ParticleSpawner_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "ParticleEmitter.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ParticleSpawner : public ParticleEmitter
+    {
+        public:
+            ParticleSpawner(BaseObject* creator);
+            virtual ~ParticleSpawner();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void processEvent(Event& event);
+
+            inline void destroy()
+                { this->bForceDestroy_ = true; this->stopParticleSpawner(); }
+            inline void spawn()
+                { this->bSuppressStart_ = false; this->startParticleSpawner(); }
+
+            void configure(float lifetime = 0, float startdelay = 0, float destroydelay = 0, bool autodestroy = true);
+
+            inline void setAutoStart(bool autostart)
+                { this->bAutostart_ = autostart; this->bSuppressStart_ = !autostart; }
+            inline bool getAutoStart() const
+                { return this->bAutostart_; }
+
+            inline void setDestroyAfterLife(bool destroy)
+                { this->bAutoDestroy_ = destroy; }
+            inline bool getDestroyAfterLife() const
+                { return this->bAutoDestroy_; }
+
+            inline void setLoop(bool loop)
+                { this->bLoop_ = loop; }
+            inline bool getLoop() const
+                { return this->bLoop_; }
+
+            inline void setLifetime(float lifetime)
+                { this->lifetime_ = lifetime; this->startParticleSpawner(); }
+            inline float getLifetime() const
+                { return this->lifetime_; }
+
+            inline void setStartdelay(float startdelay)
+                { this->startdelay_ = startdelay; this->startParticleSpawner(); }
+            inline float getStartdelay() const
+                { return this->startdelay_; }
+
+            inline void setDestroydelay(float destroydelay)
+                { this->destroydelay_ = destroydelay; this->startParticleSpawner(); }
+            inline float getDestroydelay() const
+                { return this->destroydelay_; }
+
+        private:
+            void startParticleSpawner();
+            void fireParticleSpawner();
+            void stopParticleSpawner();
+            void destroyParticleSpawner();
+
+            Timer<ParticleSpawner> timer_;
+
+            bool  bSuppressStart_;
+            bool  bAutostart_;
+            bool  bForceDestroy_;
+            bool  bAutoDestroy_;
+            bool  bLoop_;
+            float startdelay_;
+            float lifetime_;
+            float destroydelay_;
+    };
+}
+
+#endif /* _ParticleSpawner_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.cc	(revision 2122)
@@ -0,0 +1,59 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "PositionableEntity.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(PositionableEntity);
+
+    PositionableEntity::PositionableEntity(BaseObject* creator) : WorldEntity(creator)
+    {
+        RegisterObject(PositionableEntity);
+
+        this->registerVariables();
+    }
+
+    PositionableEntity::~PositionableEntity()
+    {
+    }
+
+    void PositionableEntity::registerVariables()
+    {
+        REGISTERDATA(this->getPosition().x, network::direction::toclient);
+        REGISTERDATA(this->getPosition().y, network::direction::toclient);
+        REGISTERDATA(this->getPosition().z, network::direction::toclient);
+
+        REGISTERDATA(this->getOrientation().w, network::direction::toclient);
+        REGISTERDATA(this->getOrientation().x, network::direction::toclient);
+        REGISTERDATA(this->getOrientation().y, network::direction::toclient);
+        REGISTERDATA(this->getOrientation().z, network::direction::toclient);
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.h	(revision 2122)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _PositionableEntity_H__
+#define _PositionableEntity_H__
+
+#include "OrxonoxPrereqs.h"
+#include "WorldEntity.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport PositionableEntity : public WorldEntity
+    {
+        public:
+            PositionableEntity(BaseObject* creator);
+            virtual ~PositionableEntity();
+
+            void registerVariables();
+
+            using WorldEntity::setPosition;
+            using WorldEntity::translate;
+            using WorldEntity::setOrientation;
+            using WorldEntity::rotate;
+            using WorldEntity::yaw;
+            using WorldEntity::pitch;
+            using WorldEntity::roll;
+            using WorldEntity::lookAt;
+            using WorldEntity::setDirection;
+
+            inline void setPosition(const Vector3& position)
+                { this->node_->setPosition(position); }
+            inline void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->node_->translate(distance, relativeTo); }
+            inline void setOrientation(const Quaternion& orientation)
+                { this->node_->setOrientation(orientation); }
+            inline void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->node_->rotate(rotation, relativeTo); }
+            inline void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->node_->yaw(angle, relativeTo); }
+            inline void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->node_->pitch(angle, relativeTo); }
+            inline void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->node_->roll(angle, relativeTo); }
+            inline void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
+                { this->node_->lookAt(target, relativeTo, localDirectionVector); }
+            inline void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
+                { this->node_->setDirection(direction, relativeTo, localDirectionVector); }
+    };
+}
+
+#endif /* _PositionableEntity_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/SpawnPoint.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/SpawnPoint.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/SpawnPoint.cc	(revision 2122)
@@ -0,0 +1,100 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "SpawnPoint.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/gametypes/Gametype.h"
+
+namespace orxonox
+{
+    CreateFactory(SpawnPoint);
+
+    SpawnPoint::SpawnPoint(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(SpawnPoint);
+
+        this->template_ = 0;
+
+        if (this->getGametype())
+            this->getGametype()->registerSpawnPoint(this);
+        else
+            COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl;
+
+        this->setObjectMode(0x0);
+    }
+
+    void SpawnPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(SpawnPoint, XMLPort, xmlelement, mode);
+
+        XMLPortParam(SpawnPoint, "spawnclass", setSpawnClassName, getSpawnClassName, xmlelement, mode);
+        XMLPortParam(SpawnPoint, "pawndesign", setTemplateName, getTemplateName, xmlelement, mode);
+    }
+
+    void SpawnPoint::setSpawnClassName(const std::string& name)
+    {
+        this->spawnclassname_ = name;
+        this->spawnclass_ = ClassByString(name);
+    }
+
+    void SpawnPoint::setTemplateName(const std::string& name)
+    {
+        this->templatename_ = name;
+        this->template_ = Template::getTemplate(name);
+    }
+
+    Pawn* SpawnPoint::spawn()
+    {
+        Pawn* entity = this->spawnclass_.fabricate(this);
+        if (entity)
+        {
+            this->getGametype()->pawnPreSpawn(entity);
+
+            this->spawn(entity);
+
+            if (this->template_)
+                entity->addTemplate(this->template_);
+
+            entity->postSpawn();
+
+            this->getGametype()->pawnPostSpawn(entity);
+
+            this->fireEvent();
+        }
+        return entity;
+    }
+
+    void SpawnPoint::spawn(ControllableEntity* entity)
+    {
+        entity->setPosition(this->getPosition());
+        entity->setOrientation(this->getOrientation());
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/SpawnPoint.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/SpawnPoint.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/SpawnPoint.h	(revision 2122)
@@ -0,0 +1,78 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _SpawnPoint_H__
+#define _SpawnPoint_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/Identifier.h"
+#include "core/Template.h"
+#include "PositionableEntity.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport SpawnPoint : public PositionableEntity
+    {
+        public:
+            SpawnPoint(BaseObject* creator);
+            virtual ~SpawnPoint() {}
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            inline void setSpawnClass(Identifier* identifier)
+                { this->spawnclass_ = identifier; this->spawnclassname_ = identifier->getName(); }
+            inline Identifier* getSpawnClass() const
+                { return this->spawnclass_; }
+
+            inline void setTemplate(Template* temp)
+                { this->template_ = temp; this->templatename_ = temp->getName(); }
+            inline Template* getTemplate() const
+                { return this->template_; }
+
+            Pawn* spawn();
+            void spawn(ControllableEntity* entity);
+
+        private:
+            void setSpawnClassName(const std::string& name);
+            inline const std::string& getSpawnClassName() const
+                { return this->spawnclassname_; }
+
+            void setTemplateName(const std::string& name);
+            inline const std::string& getTemplateName() const
+                { return this->templatename_; }
+
+            SubclassIdentifier<Pawn> spawnclass_;
+            std::string spawnclassname_;
+            Template* template_;
+            std::string templatename_;
+    };
+}
+
+#endif /* _SpawnPoint_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2122)
@@ -0,0 +1,152 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "WorldEntity.h"
+
+#include <cassert>
+#include <OgreSceneManager.h>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+    const Vector3 WorldEntity::FRONT = Vector3::NEGATIVE_UNIT_Z;
+    const Vector3 WorldEntity::BACK  = Vector3::UNIT_Z;
+    const Vector3 WorldEntity::LEFT  = Vector3::NEGATIVE_UNIT_X;
+    const Vector3 WorldEntity::RIGHT = Vector3::UNIT_X;
+    const Vector3 WorldEntity::DOWN  = Vector3::NEGATIVE_UNIT_Y;
+    const Vector3 WorldEntity::UP    = Vector3::UNIT_Y;
+
+    WorldEntity::WorldEntity(BaseObject* creator) : BaseObject(creator), network::Synchronisable(creator)
+    {
+        RegisterObject(WorldEntity);
+
+        assert(this->getScene());
+        assert(this->getScene()->getRootSceneNode());
+
+        this->node_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
+
+        this->parent_ = 0;
+        this->parentID_ = (unsigned int)-1;
+
+        this->node_->setPosition(Vector3::ZERO);
+        this->node_->setOrientation(Quaternion::IDENTITY);
+
+        this->registerVariables();
+    }
+
+    WorldEntity::~WorldEntity()
+    {
+        if (this->isInitialized())
+        {
+            this->node_->detachAllObjects();
+            if (this->getScene()->getSceneManager())
+                this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
+        }
+    }
+
+    void WorldEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(WorldEntity, XMLPort, xmlelement, mode);
+
+        XMLPortParamTemplate(WorldEntity, "position", setPosition, getPosition, xmlelement, mode, const Vector3&);
+        XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&);
+        XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode);
+        XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode);
+        XMLPortParamLoadOnly(WorldEntity, "yaw", yaw_xmlport, xmlelement, mode);
+        XMLPortParamLoadOnly(WorldEntity, "pitch", pitch_xmlport, xmlelement, mode);
+        XMLPortParamLoadOnly(WorldEntity, "roll", roll_xmlport, xmlelement, mode);
+        XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&);
+        XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode);
+
+        XMLPortObject(WorldEntity, WorldEntity, "attached", attach, getAttachedObject, xmlelement, mode);
+    }
+
+    void WorldEntity::registerVariables()
+    {
+        REGISTERDATA(this->bActive_,  network::direction::toclient, new network::NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
+        REGISTERDATA(this->bVisible_, network::direction::toclient, new network::NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
+
+        REGISTERDATA(this->getScale3D().x, network::direction::toclient);
+        REGISTERDATA(this->getScale3D().y, network::direction::toclient);
+        REGISTERDATA(this->getScale3D().z, network::direction::toclient);
+
+        REGISTERDATA(this->parentID_, network::direction::toclient, new network::NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
+    }
+
+    void WorldEntity::updateParent()
+    {
+        WorldEntity* parent = dynamic_cast<WorldEntity*>(Synchronisable::getSynchronisable(this->parentID_));
+        if (parent)
+            this->attachToParent(parent);
+    }
+
+    void WorldEntity::attach(WorldEntity* object)
+    {
+        if (object->getParent())
+            object->detachFromParent();
+        else
+        {
+            Ogre::Node* parent = object->node_->getParent();
+            if (parent)
+                parent->removeChild(object->node_);
+        }
+
+        this->node_->addChild(object->node_);
+        this->children_.insert(object);
+        object->parent_ = this;
+        object->parentID_ = this->getObjectID();
+    }
+
+    void WorldEntity::detach(WorldEntity* object)
+    {
+        this->node_->removeChild(object->node_);
+        this->children_.erase(object);
+        object->parent_ = 0;
+        object->parentID_ = (unsigned int)-1;
+
+//        this->getScene()->getRootSceneNode()->addChild(object->node_);
+    }
+
+    WorldEntity* WorldEntity::getAttachedObject(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h	(revision 2122)
@@ -0,0 +1,163 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _WorldEntity_H__
+#define _WorldEntity_H__
+
+#include "OrxonoxPrereqs.h"
+
+#define OGRE_FORCE_ANGLE_TYPES
+
+#include <OgreSceneNode.h>
+
+#include "network/Synchronisable.h"
+#include "core/BaseObject.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport WorldEntity : public BaseObject, public network::Synchronisable
+    {
+        public:
+            WorldEntity(BaseObject* creator);
+            virtual ~WorldEntity();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void registerVariables();
+
+            inline Ogre::SceneNode* getNode() const
+                { return this->node_; }
+
+            static const Vector3 FRONT;
+            static const Vector3 BACK;
+            static const Vector3 LEFT;
+            static const Vector3 RIGHT;
+            static const Vector3 DOWN;
+            static const Vector3 UP;
+
+            virtual void setPosition(const Vector3& position) = 0;
+            inline void setPosition(float x, float y, float z)
+                { this->setPosition(Vector3(x, y, z)); }
+            inline const Vector3& getPosition() const
+                { return this->node_->getPosition(); }
+            inline const Vector3& getWorldPosition() const
+                { return this->node_->getWorldPosition(); }
+
+            virtual void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
+            inline void translate(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->translate(Vector3(x, y, z), relativeTo); }
+
+            virtual void setOrientation(const Quaternion& orientation) = 0;
+            inline void setOrientation(float w, float x, float y, float z)
+                { this->setOrientation(Quaternion(w, x, y, z)); }
+            inline void setOrientation(const Vector3& axis, const Radian& angle)
+                { this->setOrientation(Quaternion(angle, axis)); }
+            inline void setOrientation(const Vector3& axis, const Degree& angle)
+                { this->setOrientation(Quaternion(angle, axis)); }
+            inline const Quaternion& getOrientation() const
+                { return this->node_->getOrientation(); }
+            inline const Quaternion& getWorldOrientation() const
+                { return this->node_->getWorldOrientation(); }
+
+            virtual void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
+            inline void rotate(const Vector3& axis, const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->rotate(Quaternion(angle, axis), relativeTo); }
+            inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->rotate(Quaternion(angle, axis), relativeTo); }
+
+            virtual void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
+            inline void yaw(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->yaw(Degree(angle), relativeTo); }
+            virtual void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
+            inline void pitch(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->pitch(Degree(angle), relativeTo); }
+            virtual void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
+            inline void roll(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
+                { this->roll(Degree(angle), relativeTo); }
+
+            virtual void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
+            virtual void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
+            inline void setDirection(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
+                { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); }
+
+            inline void setScale3D(const Vector3& scale)
+                { this->node_->setScale(scale); }
+            inline void setScale3D(float x, float y, float z)
+                { this->node_->setScale(x, y, z); }
+            inline const Vector3& getScale3D(void) const
+                { return this->node_->getScale(); }
+
+            inline void setScale(float scale)
+                { this->node_->setScale(scale, scale, scale); }
+            inline float getScale() const
+                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
+
+            inline void scale3D(const Vector3& scale)
+                { this->node_->scale(scale); }
+            inline void scale3D(float x, float y, float z)
+                { this->node_->scale(x, y, z); }
+            inline void scale(float scale)
+                { this->node_->scale(scale, scale, scale); }
+
+            void attach(WorldEntity* object);
+            void detach(WorldEntity* object);
+            WorldEntity* getAttachedObject(unsigned int index) const;
+            inline const std::set<WorldEntity*>& getAttachedObjects() const
+                { return this->children_; }
+
+            inline void attachToParent(WorldEntity* parent)
+                { parent->attach(this); }
+            inline void detachFromParent()
+                { if (this->parent_) { this->parent_->detach(this); } }
+            inline WorldEntity* getParent() const
+                { return this->parent_; }
+
+        protected:
+            Ogre::SceneNode* node_;
+
+        private:
+            void updateParent();
+
+            inline void lookAt_xmlport(const Vector3& target)
+                { this->lookAt(target); }
+            inline void setDirection_xmlport(const Vector3& direction)
+                { this->setDirection(direction); }
+            inline void yaw_xmlport(const Degree& angle)
+                { this->yaw(angle); }
+            inline void pitch_xmlport(const Degree& angle)
+                { this->pitch(angle); }
+            inline void roll_xmlport(const Degree& angle)
+                { this->roll(angle); }
+
+            WorldEntity* parent_;
+            unsigned int parentID_;
+            std::set<WorldEntity*> children_;
+    };
+}
+
+#endif /* _WorldEntity_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2122)
@@ -0,0 +1,150 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Pawn.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Math.h"
+#include "objects/infos/PlayerInfo.h"
+#include "objects/gametypes/Gametype.h"
+#include "objects/weaponSystem/WeaponSystem.h"
+
+namespace orxonox
+{
+    CreateFactory(Pawn);
+
+    Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
+    {
+        RegisterObject(Pawn);
+
+        this->bAlive_ = false;
+
+        this->health_ = 0;
+        this->maxHealth_ = 0;
+        this->initialHealth_ = 0;
+
+        this->lastHitOriginator_ = 0;
+        this->weaponSystem_ = 0;
+
+        /*
+        //WeaponSystem
+        weaponSystem_ = new WeaponSystem();
+        WeaponSet * weaponSet1 = new WeaponSet(1);
+        this->weaponSystem_->attachWeaponSet(weaponSet1);
+        this->weaponSystem_->getWeaponSetPointer(0)->getWeaponSlotPointer(0)->setAmmoType(true);
+        */
+
+        this->registerVariables();
+    }
+
+    Pawn::~Pawn()
+    {
+    }
+
+    void Pawn::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Pawn, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Pawn, "health", setHealth, getHealht, xmlelement, mode).defaultValues(100);
+        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
+        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
+    }
+
+    void Pawn::registerVariables()
+    {
+        REGISTERDATA(this->bAlive_, network::direction::toclient);
+        REGISTERDATA(this->health_, network::direction::toclient);
+    }
+
+    void Pawn::tick(float dt)
+    {
+        SUPER(Pawn, tick, dt);
+
+        if (this->health_ <= 0)
+            this->death();
+    }
+
+    void Pawn::setHealth(float health)
+    {
+        this->health_ = min(health, this->maxHealth_);
+    }
+
+    void Pawn::damage(float damage, Pawn* originator)
+    {
+        this->setHealth(this->health_ - damage);
+        this->lastHitOriginator_ = originator;
+
+        // play damage effect
+    }
+
+    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
+    {
+        this->damage(damage, originator);
+        this->setVelocity(this->getVelocity() + force);
+
+        // play hit effect
+    }
+
+    void Pawn::kill()
+    {
+        this->damage(this->health_);
+        this->death();
+    }
+
+    void Pawn::spawn()
+    {
+        // play spawn effect
+    }
+
+    void Pawn::death()
+    {
+        this->bAlive_ = false;
+        if (this->getGametype())
+            this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
+        if (this->getPlayer())
+            this->getPlayer()->stopControl(this);
+
+        delete this;
+
+        // play death effect
+    }
+
+    void Pawn::fire()
+    {
+        if (this->weaponSystem_)
+            this->weaponSystem_->fire();
+    }
+
+    void Pawn::postSpawn()
+    {
+        this->setHealth(this->initialHealth_);
+        this->spawn();
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/pawns/Pawn.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/pawns/Pawn.h	(revision 2122)
@@ -0,0 +1,96 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Pawn_H__
+#define _Pawn_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/worldentities/ControllableEntity.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Pawn : public ControllableEntity
+    {
+        public:
+            Pawn(BaseObject* creator);
+            virtual ~Pawn();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            void registerVariables();
+
+            inline bool isAlive() const
+                { return this->bAlive_; }
+
+            virtual void setHealth(float health);
+            inline void addHealth(float health)
+                { this->setHealth(this->health_ + health); }
+            inline void removeHealth(float health)
+                { this->setHealth(this->health_ - health); }
+            inline float getHealht() const
+                { return this->health_; }
+
+            inline void setMaxHealth(float maxhealth)
+                { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
+            inline float getMaxHealth() const
+                { return this->maxHealth_; }
+
+            inline void setInitialHealth(float initialhealth)
+                { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
+            inline float getInitialHealth() const
+                { return this->initialHealth_; }
+
+            inline ControllableEntity* getLastHitOriginator() const
+                { return this->lastHitOriginator_; }
+
+            virtual void damage(float damage, Pawn* originator = 0);
+            virtual void hit(Pawn* originator, const Vector3& force, float damage);
+            virtual void kill();
+
+            virtual void fire();
+
+            virtual void postSpawn();
+
+        protected:
+            virtual void spawn();
+            virtual void death();
+
+            bool bAlive_;
+
+            float health_;
+            float maxHealth_;
+            float initialHealth_;
+
+            Pawn* lastHitOriginator_;
+
+            WeaponSystem* weaponSystem_;
+    };
+}
+
+#endif /* _Pawn_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.cc	(revision 2122)
@@ -0,0 +1,213 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "SpaceShip.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    CreateFactory(SpaceShip);
+
+    SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator)
+    {
+        RegisterObject(SpaceShip);
+
+        this->zeroDegree_ = 0;
+
+        this->maxSpeed_ = 0;
+        this->maxSecondarySpeed_ = 0;
+        this->maxRotation_ = 0;
+        this->translationAcceleration_ = 0;
+        this->rotationAcceleration_ = 0;
+        this->translationDamping_ = 0;
+
+        this->yawRotation_ = 0;
+        this->pitchRotation_ = 0;
+        this->rollRotation_ = 0;
+
+        this->bInvertYAxis_ = false;
+
+        this->setDestroyWhenPlayerLeft(true);
+
+        this->setConfigValues();
+        this->registerVariables();
+    }
+
+    SpaceShip::~SpaceShip()
+    {
+    }
+
+    void SpaceShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(SpaceShip, XMLPort, xmlelement, mode);
+
+        XMLPortParam(SpaceShip, "maxspeed",          setMaxSpeed,          getMaxSpeed,          xmlelement, mode);
+        XMLPortParam(SpaceShip, "maxsecondaryspeed", setMaxSecondarySpeed, getMaxSecondarySpeed, xmlelement, mode);
+        XMLPortParam(SpaceShip, "maxrotation",       setMaxRotation,       getMaxRotation,       xmlelement, mode);
+        XMLPortParam(SpaceShip, "transacc",          setTransAcc,          getTransAcc,          xmlelement, mode);
+        XMLPortParam(SpaceShip, "rotacc",            setRotAcc,            getRotAcc,            xmlelement, mode);
+        XMLPortParam(SpaceShip, "transdamp",         setTransDamp,         getTransDamp,         xmlelement, mode);
+    }
+
+    void SpaceShip::registerVariables()
+    {
+        REGISTERDATA(this->maxSpeed_,                network::direction::toclient);
+        REGISTERDATA(this->maxSecondarySpeed_,       network::direction::toclient);
+        REGISTERDATA(this->maxRotation_,             network::direction::toclient);
+        REGISTERDATA(this->translationAcceleration_, network::direction::toclient);
+        REGISTERDATA(this->rotationAcceleration_,    network::direction::toclient);
+        REGISTERDATA(this->translationDamping_,      network::direction::toclient);
+    }
+
+    void SpaceShip::setConfigValues()
+    {
+        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
+    }
+
+    void SpaceShip::tick(float dt)
+    {
+        if (this->isLocallyControlled())
+        {
+            // #####################################
+            // ############# STEERING ##############
+            // #####################################
+
+            Vector3 velocity = this->getVelocity();
+            if (velocity.x > this->maxSecondarySpeed_)
+                velocity.x = this->maxSecondarySpeed_;
+            if (velocity.x < -this->maxSecondarySpeed_)
+                velocity.x = -this->maxSecondarySpeed_;
+            if (velocity.y > this->maxSecondarySpeed_)
+                velocity.y = this->maxSecondarySpeed_;
+            if (velocity.y < -this->maxSecondarySpeed_)
+                velocity.y = -this->maxSecondarySpeed_;
+            if (velocity.z > this->maxSecondarySpeed_)
+                velocity.z = this->maxSecondarySpeed_;
+            if (velocity.z < -this->maxSpeed_)
+                velocity.z = -this->maxSpeed_;
+
+            // normalize velocity and acceleration
+            for (size_t dimension = 0; dimension < 3; ++dimension)
+            {
+                if (this->acceleration_[dimension] == 0)
+                {
+                    if (velocity[dimension] > 0)
+                    {
+                        velocity[dimension] -= (this->translationDamping_ * dt);
+                        if (velocity[dimension] < 0)
+                            velocity[dimension] = 0;
+                    }
+                    else if (velocity[dimension] < 0)
+                    {
+                        velocity[dimension] += (this->translationDamping_ * dt);
+                        if (velocity[dimension] > 0)
+                            velocity[dimension] = 0;
+                    }
+                }
+            }
+
+            this->setVelocity(velocity);
+        }
+
+
+        SUPER(SpaceShip, tick, dt);
+
+
+        if (this->isLocallyControlled())
+        {
+            this->yaw(this->yawRotation_ * dt);
+            if (this->bInvertYAxis_)
+                this->pitch(Degree(-this->pitchRotation_ * dt));
+            else
+                this->pitch(Degree( this->pitchRotation_ * dt));
+            this->roll(this->rollRotation_ * dt);
+
+            this->acceleration_.x = 0;
+            this->acceleration_.y = 0;
+            this->acceleration_.z = 0;
+
+            this->yawRotation_   = this->zeroDegree_;
+            this->pitchRotation_ = this->zeroDegree_;
+            this->rollRotation_  = this->zeroDegree_;
+        }
+    }
+
+    void SpaceShip::moveFrontBack(const Vector2& value)
+    {
+        this->acceleration_.z = -this->translationAcceleration_ * value.x;
+    }
+
+    void SpaceShip::moveRightLeft(const Vector2& value)
+    {
+        this->acceleration_.x = this->translationAcceleration_ * value.x;
+    }
+
+    void SpaceShip::moveUpDown(const Vector2& value)
+    {
+        this->acceleration_.y = this->translationAcceleration_ * value.x;
+    }
+
+    void SpaceShip::rotateYaw(const Vector2& value)
+    {
+        Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
+        if (temp > this->maxRotation_)
+            temp = this->maxRotation_;
+        if (temp < -this->maxRotation_)
+            temp = -this->maxRotation_;
+        this->yawRotation_ = Degree(temp);
+    }
+
+    void SpaceShip::rotatePitch(const Vector2& value)
+    {
+        Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
+        if (temp > this->maxRotation_)
+            temp = this->maxRotation_;
+        if (temp < -this->maxRotation_)
+            temp = -this->maxRotation_;
+        this->pitchRotation_ = Degree(temp);
+    }
+
+    void SpaceShip::rotateRoll(const Vector2& value)
+    {
+        Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
+        if (temp > this->maxRotation_)
+            temp = this->maxRotation_;
+        if (temp < -this->maxRotation_)
+            temp = -this->maxRotation_;
+        this->rollRotation_ = Degree(temp);
+    }
+
+    void SpaceShip::fire()
+    {
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.h	(revision 2122)
@@ -0,0 +1,103 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _SpaceShip_H__
+#define _SpaceShip_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Pawn.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport SpaceShip : public Pawn
+    {
+        public:
+            SpaceShip(BaseObject* creator);
+            virtual ~SpaceShip();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            void registerVariables();
+            void setConfigValues();
+
+            virtual void moveFrontBack(const Vector2& value);
+            virtual void moveRightLeft(const Vector2& value);
+            virtual void moveUpDown(const Vector2& value);
+
+            virtual void rotateYaw(const Vector2& value);
+            virtual void rotatePitch(const Vector2& value);
+            virtual void rotateRoll(const Vector2& value);
+
+            virtual void fire();
+
+            void setMaxSpeed(float value)
+                { this->maxSpeed_ = value; }
+            void setMaxSecondarySpeed(float value)
+                { this->maxSecondarySpeed_ = value; }
+            void setMaxRotation(const Degree& value)
+                { this->maxRotation_ = value; }
+            void setTransAcc(float value)
+                { this->translationAcceleration_ = value; }
+            void setRotAcc(const Degree& value)
+                { this->rotationAcceleration_ = value; }
+            void setTransDamp(float value)
+                { this->translationDamping_ = value; }
+
+            inline float getMaxSpeed() const
+                { return this->maxSpeed_; }
+            inline float getMaxSecondarySpeed() const
+                { return this->maxSecondarySpeed_; }
+            inline float getMaxRotation() const
+                { return this->maxRotation_.valueDegrees(); }
+            inline float getTransAcc() const
+                { return this->translationAcceleration_; }
+            inline float getRotAcc() const
+                { return this->rotationAcceleration_.valueDegrees(); }
+            inline float getTransDamp() const
+                { return this->translationDamping_; }
+
+        protected:
+            bool bInvertYAxis_;
+
+            float maxSpeed_;
+            float maxSecondarySpeed_;
+            float translationAcceleration_;
+            float translationDamping_;
+
+            Degree maxRotation_;
+            Degree rotationAcceleration_;
+
+            Degree zeroDegree_;
+            Degree pitchRotation_;
+            Degree yawRotation_;
+            Degree rollRotation_;
+    };
+}
+
+#endif /* _SpaceShip_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/pawns/Spectator.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/pawns/Spectator.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/pawns/Spectator.cc	(revision 2122)
@@ -0,0 +1,255 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Spectator.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+#include "objects/worldentities/Model.h"
+#include "objects/Scene.h"
+#include "objects/infos/PlayerInfo.h"
+#include "objects/gametypes/Gametype.h"
+#include "tools/BillboardSet.h"
+#include "overlays/OverlayText.h"
+#include "overlays/OverlayGroup.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    CreateFactory(Spectator);
+
+    Spectator::Spectator(BaseObject* creator) : ControllableEntity(creator)
+    {
+        RegisterObject(Spectator);
+
+        this->speed_ = 100;
+        this->rotationSpeed_ = 3;
+
+        this->yaw_ = 0;
+        this->pitch_ = 0;
+        this->roll_ = 0;
+        this->setHudTemplate("spectatorhud");
+        this->hudmode_ = 0;
+
+        this->setDestroyWhenPlayerLeft(true);
+
+        this->greetingFlare_ = new BillboardSet();
+        this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);
+        this->getNode()->attachObject(this->greetingFlare_->getBillboardSet());
+        this->greetingFlare_->setVisible(false);
+        this->bGreetingFlareVisible_ = false;
+        this->bGreeting_ = false;
+
+        this->registerVariables();
+    }
+
+    Spectator::~Spectator()
+    {
+        if (this->isInitialized())
+        {
+            if (this->greetingFlare_)
+            {
+                this->getNode()->detachObject(this->greetingFlare_->getBillboardSet());
+                delete this->greetingFlare_;
+            }
+        }
+    }
+
+    void Spectator::registerVariables()
+    {
+        REGISTERDATA(this->bGreetingFlareVisible_, network::direction::toclient, new network::NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
+        REGISTERDATA(this->bGreeting_,             network::direction::toserver, new network::NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
+        REGISTERDATA(this->hudmode_,               network::direction::toclient);
+    }
+
+    void Spectator::changedGreeting()
+    {
+        this->bGreetingFlareVisible_ = this->bGreeting_;
+        this->changedFlareVisibility();
+    }
+
+    void Spectator::changedFlareVisibility()
+    {
+        this->greetingFlare_->setVisible(this->bGreetingFlareVisible_);
+    }
+
+    void Spectator::tick(float dt)
+    {
+        this->updateHUD();
+
+        if (this->isLocallyControlled())
+        {
+            Vector3 velocity = this->getVelocity();
+            velocity.normalise();
+            this->setVelocity(velocity * this->speed_);
+
+            this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
+            this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
+            this->roll(Radian(this->roll_ * this->rotationSpeed_));
+
+            this->yaw_ = this->pitch_ = this->roll_ = 0;
+        }
+
+        SUPER(Spectator, tick, dt);
+
+        if (this->isLocallyControlled())
+        {
+            this->setVelocity(Vector3::ZERO);
+        }
+    }
+
+    void Spectator::setPlayer(PlayerInfo* player)
+    {
+        ControllableEntity::setPlayer(player);
+
+//        this->setObjectMode(network::direction::toclient);
+    }
+
+    void Spectator::startLocalControl()
+    {
+        ControllableEntity::startLocalControl();
+//        if (this->isLocallyControlled())
+//            this->testmesh_->setVisible(false);
+    }
+
+    void Spectator::moveFrontBack(const Vector2& value)
+    {
+        this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT);
+    }
+
+    void Spectator::moveRightLeft(const Vector2& value)
+    {
+        this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT);
+    }
+
+    void Spectator::moveUpDown(const Vector2& value)
+    {
+        this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP);
+    }
+
+    void Spectator::rotateYaw(const Vector2& value)
+    {
+        this->yaw_ = value.y;
+    }
+
+    void Spectator::rotatePitch(const Vector2& value)
+    {
+        this->pitch_ = value.y;
+    }
+
+    void Spectator::rotateRoll(const Vector2& value)
+    {
+        this->roll_ = value.y;
+    }
+
+    void Spectator::fire()
+    {
+        if (this->getPlayer())
+            this->getPlayer()->setReadyToSpawn(true);
+    }
+
+    void Spectator::greet()
+    {
+        this->bGreeting_ = !this->bGreeting_;
+
+        if (Core::isMaster())
+        {
+            this->bGreetingFlareVisible_ = this->bGreeting_;
+            this->changedFlareVisibility();
+        }
+    }
+
+    void Spectator::updateHUD()
+    {
+        // <hack>
+        if (Core::isMaster())
+        {
+            if (this->getPlayer() && this->getGametype())
+            {
+                if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())
+                {
+                    if (!this->getPlayer()->isReadyToSpawn())
+                        this->hudmode_ = 0;
+                    else
+                        this->hudmode_ = 1;
+                }
+                else if (!this->getGametype()->hasEnded())
+                {
+                    if (this->getGametype()->isStartCountdownRunning())
+                        this->hudmode_ = 2 + 10*ceil(this->getGametype()->getStartCountdown());
+                    else
+                        this->hudmode_ = 3;
+                }
+                else
+                    this->hudmode_ = 4;
+            }
+            else
+                return;
+        }
+
+        if (this->getHUD())
+        {
+            std::string text;
+            int hudmode = this->hudmode_ % 10;
+
+            switch (hudmode)
+            {
+                case 0:
+                    text = "Press [Fire] to start the match";
+                    break;
+                case 1:
+                    text = "Waiting for other players";
+                    break;
+                case 2:
+                    text = convertToString((this->hudmode_ - 2) / 10);
+                    break;
+                case 3:
+                    text = "Press [Fire] to respawn";
+                    break;
+                case 4:
+                    text = "Game has ended";
+                    break;
+                default:;
+            }
+
+            std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();
+            for (; it != this->getHUD()->getOverlays().end(); ++it)
+            {
+                if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")
+                {
+                    OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);
+                    if (overlay)
+                        overlay->setCaption(text);
+                    break;
+                }
+            }
+        }
+        // </hack>
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/pawns/Spectator.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/pawns/Spectator.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/pawns/Spectator.h	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Spectator_H__
+#define _Spectator_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/worldentities/ControllableEntity.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Spectator : public ControllableEntity
+    {
+        public:
+            Spectator(BaseObject* creator);
+            virtual ~Spectator();
+
+            void registerVariables();
+            virtual void tick(float dt);
+
+            virtual void setPlayer(PlayerInfo* player);
+            virtual void startLocalControl();
+
+            virtual void moveFrontBack(const Vector2& value);
+            virtual void moveRightLeft(const Vector2& value);
+            virtual void moveUpDown(const Vector2& value);
+
+            virtual void rotateYaw(const Vector2& value);
+            virtual void rotatePitch(const Vector2& value);
+            virtual void rotateRoll(const Vector2& value);
+
+            virtual void fire();
+            virtual void greet();
+
+        private:
+            void changedGreeting();
+            void changedFlareVisibility();
+            void updateHUD();
+
+            BillboardSet* greetingFlare_;
+            bool bGreetingFlareVisible_;
+            bool bGreeting_;
+
+            float speed_;
+            float rotationSpeed_;
+
+            float yaw_;
+            float pitch_;
+            float roll_;
+
+            int hudmode_;
+    };
+}
+
+#endif /* _Spectator_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc	(revision 2122)
@@ -0,0 +1,132 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "DistanceTrigger.h"
+
+#include <OgreNode.h>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+  CreateFactory(DistanceTrigger);
+
+  DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)
+  {
+    RegisterObject(DistanceTrigger);
+
+    this->distance_ = 100;
+    this->targetMask_.exclude(Class(BaseObject));
+  }
+
+  DistanceTrigger::~DistanceTrigger()
+  {
+  }
+
+  void DistanceTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+  {
+    SUPER(DistanceTrigger, XMLPort, xmlelement, mode);
+
+    XMLPortParam(DistanceTrigger, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(100.0f);
+    XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode).defaultValues("ControllableEntity");
+  }
+
+  void DistanceTrigger::addTarget(Ogre::Node* targetNode)
+  {
+    this->targetSet_.insert(targetNode);
+  }
+
+  void DistanceTrigger::removeTarget(Ogre::Node* targetNode)
+  {
+    int returnval = this->targetSet_.erase(targetNode);
+    if (returnval == 0)
+    {
+      COUT(2) << "Warning: Node " << targetNode << " did not exist in targetSet of trigger " << this << " !" << std::endl;
+      COUT(4) << "Content of targetSet of trigger " << this << " :" << std::endl;
+      std::set<Ogre::Node*>::iterator it;
+      for (it = this->targetSet_.begin(); it != this->targetSet_.end(); ++it)
+      {
+        COUT(4) << *it << std::endl;
+      }
+      COUT(4) << "End of targetSet of trigger " << this << std::endl;
+    }
+  }
+
+  void DistanceTrigger::addTargets(const std::string& targets)
+  {
+    Identifier* targetId = ClassByString(targets);
+    if (!targetId)
+    {
+        COUT(1) << "Error: \"" << targets << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << std::endl;
+        return;
+    }
+
+    this->targetMask_.include(targetId);
+
+    // trigger shouldn't react on itself or other triggers
+    this->targetMask_.exclude(Class(Trigger), true);
+
+    // we only want WorldEntities
+    ClassTreeMask WEMask;
+    WEMask.include(Class(WorldEntity));
+    this->targetMask_ *= WEMask;
+  }
+
+  void DistanceTrigger::removeTargets(const std::string& targets)
+  {
+    Identifier* targetId = ClassByString(targets);
+    this->targetMask_.exclude(targetId);
+  }
+
+  bool DistanceTrigger::checkDistance()
+  {
+    // Iterate through all objects
+    for (ClassTreeMaskObjectIterator it = this->targetMask_.begin(); it != this->targetMask_.end(); ++it)
+    {
+      WorldEntity* entity = dynamic_cast<WorldEntity*>(*it);
+      if (!entity)
+        continue;
+
+      Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
+      if (distanceVec.length() < this->distance_)
+        return true;
+    }
+    return false;
+
+  }
+
+  bool DistanceTrigger::isTriggered(TriggerMode mode)
+  {
+    if (Trigger::isTriggered(mode))
+      return checkDistance();
+    else
+      return false;
+  }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h	(revision 2122)
@@ -0,0 +1,71 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _DistanceTrigger_H__
+#define _DistanceTrigger_H__
+
+#include "Trigger.h"
+
+#include <set>
+
+#include "core/ClassTreeMask.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport DistanceTrigger : public Trigger
+  {
+    public:
+      DistanceTrigger(BaseObject* creator);
+      virtual ~DistanceTrigger();
+
+      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+      void addTarget(Ogre::Node* targetNode);
+      void addTargets(const std::string& targets);
+      void removeTarget(Ogre::Node* targetNode);
+      void removeTargets(const std::string& targets);
+
+      inline void setDistance(float distance)
+        { this->distance_ = distance; }
+      inline float getDistance() const
+        { return this->distance_; }
+
+      bool checkDistance();
+
+    protected:
+      virtual bool isTriggered(TriggerMode mode);
+
+    private:
+      ClassTreeMask targetMask_;
+      std::set<Ogre::Node*> targetSet_;
+      float distance_;
+  };
+}
+
+#endif /* _DistanceTrigger_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/triggers/EventTrigger.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/triggers/EventTrigger.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/triggers/EventTrigger.cc	(revision 2122)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "EventTrigger.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(EventTrigger);
+
+    EventTrigger::EventTrigger(BaseObject* creator) : Trigger(creator)
+    {
+        RegisterObject(EventTrigger);
+
+        this->bEventTriggered_ = false;
+    }
+
+    EventTrigger::~EventTrigger()
+    {
+    }
+
+    void EventTrigger::processEvent(Event& event)
+    {
+        SUPER(EventTrigger, processEvent, event);
+
+        SetEvent(EventTrigger, "trigger", trigger, event);
+    }
+
+    bool EventTrigger::isTriggered(TriggerMode mode)
+    {
+        if (Trigger::isTriggered(mode))
+            return this->bEventTriggered_;
+        else
+            return false;
+    }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/triggers/EventTrigger.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/triggers/EventTrigger.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/triggers/EventTrigger.h	(revision 2122)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _EventTrigger_H__
+#define _EventTrigger_H__
+
+#include "Trigger.h"
+
+#include "core/ClassTreeMask.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport EventTrigger : public Trigger
+    {
+        public:
+            EventTrigger(BaseObject* creator);
+            virtual ~EventTrigger();
+
+            virtual void processEvent(Event& event);
+
+            inline void trigger(bool bTriggered)
+                { this->bEventTriggered_ = bTriggered; this->tick(0); }
+
+        protected:
+            virtual bool isTriggered(TriggerMode mode);
+
+        private:
+            bool bEventTriggered_;
+    };
+}
+
+#endif /* _EventTrigger_H__ */
Index: /code/branches/physics/src/orxonox/objects/worldentities/triggers/Trigger.cc
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/triggers/Trigger.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/triggers/Trigger.cc	(revision 2122)
@@ -0,0 +1,321 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Trigger.h"
+
+#include <OgreBillboard.h>
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/XMLPort.h"
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+
+  SetConsoleCommand(Trigger, debugFlares, false).defaultValues(false);
+
+  CreateFactory(Trigger);
+
+  Trigger::Trigger(BaseObject* creator) : PositionableEntity(creator)
+  {
+    RegisterObject(Trigger);
+
+    this->mode_ = TM_EventTriggerAND;
+
+    this->bFirstTick_ = true;
+    this->bActive_ = false;
+    this->bTriggered_ = false;
+    this->latestState_ = 0x0;
+
+    this->bInvertMode_ = false;
+    this->bSwitch_ = false;
+    this->bStayActive_ = false;
+    this->delay_ = 0.0f;
+    this->remainingTime_ = 0.0f;
+    this->timeSinceLastEvent_ = 0.0f;
+    this->remainingActivations_ = -1;
+
+//    this->bUpdating_ = false;
+
+    if (this->getScene() && this->getScene()->getSceneManager())
+    {
+      this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
+      this->debugBillboard_.setVisible(false);
+    }
+
+    this->getNode()->attachObject(this->debugBillboard_.getBillboardSet());
+    this->setObjectMode(0x0);
+  }
+
+  Trigger::~Trigger()
+  {
+  }
+
+  void Trigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+  {
+    SUPER(Trigger, XMLPort, xmlelement, mode);
+
+    XMLPortParam(Trigger, "delay",       setDelay,       getDelay,       xmlelement, mode).defaultValues(0.0f);
+    XMLPortParam(Trigger, "switch",      setSwitch,      getSwitch,      xmlelement, mode).defaultValues(false);
+    XMLPortParam(Trigger, "stayactive",  setStayActive,  getStayActive,  xmlelement, mode).defaultValues(false);
+    XMLPortParam(Trigger, "activations", setActivations, getActivations, xmlelement, mode).defaultValues(-1);
+    XMLPortParam(Trigger, "invert",      setInvert,      getInvert,      xmlelement, mode).defaultValues(false);
+    XMLPortParamTemplate(Trigger, "mode", setMode, getModeString, xmlelement, mode, const std::string&).defaultValues("or");
+
+    XMLPortObject(Trigger, Trigger, "", addTrigger, getTrigger, xmlelement, mode);
+  }
+
+  void Trigger::tick(float dt)
+  {
+    if (this->bFirstTick_)
+    {
+      this->bFirstTick_ = false;
+      this->fireEvent(false);
+    }
+
+    // Check if the object is active (this is NOT Trigger::isActive()!)
+    if (!this->BaseObject::isActive())
+        return;
+
+    bool newTriggered = this->isTriggered() ^ this->bInvertMode_;
+
+    // check if new triggering event is really new
+    if ((this->latestState_ & 0x1) != newTriggered)
+    {
+      // create new state
+      if (newTriggered)
+      {
+        this->latestState_ |= 1; // set trigger bit to 1
+        this->switchState();
+      }
+      else
+      {
+        this->latestState_ &= 0xFE; // set trigger bit to 0
+        if (!this->bSwitch_)
+          this->switchState();
+      }
+    }
+
+    if (this->remainingTime_ > 0.0)
+    {
+      this->remainingTime_ -= dt;
+      // only increase when acctually waiting for a state in the queue
+      if (this->timeSinceLastEvent_ >= 0.0)
+        this->timeSinceLastEvent_ += dt;
+    }
+
+    while (this->remainingTime_ <= 0.0 && this->stateChanges_.size() > 0)
+    {
+      // time ran out, change state to new one
+      char newState = this->stateChanges_.front().second;
+      this->bTriggered_ = (newState & 0x1);
+      this->bActive_ = newState & 2;
+      this->fireEvent(this->bActive_);
+      this->stateChanges_.pop();
+      if (this->stateChanges_.size() != 0)
+        this->remainingTime_ = this->stateChanges_.front().first;
+      else
+        this->timeSinceLastEvent_ = this->delay_;
+    }
+
+    if (this->bTriggered_ && this->bActive_)
+      this->setBillboardColour(ColourValue(0.5, 1.0, 0.0));
+    else if (!this->bTriggered_ && this->bActive_)
+      this->setBillboardColour(ColourValue(0.0, 1.0, 0.0));
+    else if (this->bTriggered_ && !this->bActive_)
+      this->setBillboardColour(ColourValue(1.0, 0.5, 0.0));
+    else
+      this->setBillboardColour(ColourValue(1.0, 0.0, 0.0));
+  }
+
+  bool Trigger::isTriggered(TriggerMode mode)
+  {
+//    if (this->bUpdating_)
+//      return this->bTriggered_;
+
+//    this->bUpdating_ = true;
+    if (this->children_.size() != 0)
+    {
+      bool returnval = false;
+
+      switch (mode)
+      {
+        case TM_EventTriggerAND:
+          returnval = checkAnd();
+          break;
+        case TM_EventTriggerOR:
+          returnval = checkOr();
+          break;
+        case TM_EventTriggerXOR:
+          returnval = checkXor();
+          break;
+        default:
+          returnval = false;
+          break;
+      }
+//      this->bUpdating_ = false;
+
+      return returnval;
+    }
+    return true;
+  }
+
+  bool Trigger::checkAnd()
+  {
+    std::set<Trigger*>::iterator it;
+    for(it = this->children_.begin(); it != this->children_.end(); ++it)
+    {
+      if (!(*it)->isActive())
+        return false;
+    }
+    return true;
+  }
+
+  bool Trigger::checkOr()
+  {
+    std::set<Trigger*>::iterator it;
+    for(it = this->children_.begin(); it != this->children_.end(); ++it)
+    {
+      if ((*it)->isActive())
+        return true;
+    }
+    return false;
+  }
+
+  bool Trigger::checkXor()
+  {
+    std::set<Trigger*>::iterator it;
+    bool test = false;
+    for(it = this->children_.begin(); it != this->children_.end(); ++it)
+    {
+      if (test && (*it)->isActive())
+        return false;
+      if ((*it)->isActive())
+        test = true;
+    }
+    return test;
+  }
+
+  bool Trigger::switchState()
+  {
+    if (( (this->latestState_ & 2) && this->bStayActive_ && (this->remainingActivations_ <= 0))
+     || (!(this->latestState_ & 2))                      && (this->remainingActivations_ == 0))
+      return false;
+    else
+    {
+      this->latestState_ ^= 2; // toggle state bit
+
+      // increase activation count
+      if (this->latestState_ & 2 && this->remainingActivations_ > 0)
+        this->remainingActivations_--;
+
+      this->storeState();
+
+      return true;
+    }
+  }
+
+  void Trigger::storeState()
+  {
+    // put state change into queue
+    this->stateChanges_.push(std::pair<float, char>(this->timeSinceLastEvent_, this->latestState_));
+    // reset time since last event
+    this->timeSinceLastEvent_ = 0.0;
+
+    if (this->stateChanges_.size() == 1)
+      this->remainingTime_ = this->stateChanges_.front().first;
+  }
+
+  void Trigger::setDelay(float delay)
+  {
+    this->delay_ = delay;
+    this->timeSinceLastEvent_ = delay;
+  }
+
+  void Trigger::setMode(const std::string& modeName)
+  {
+    if (modeName == "and")
+      this->setMode(TM_EventTriggerAND);
+    else if (modeName == "or")
+      this->setMode(TM_EventTriggerOR);
+    else if (modeName == "xor")
+      this->setMode(TM_EventTriggerXOR);
+  }
+
+  std::string Trigger::getModeString() const
+  {
+    if (this->mode_ == TM_EventTriggerAND)
+      return std::string("and");
+    else if (this->mode_ == TM_EventTriggerOR)
+      return std::string("or");
+    else if (this->mode_ == TM_EventTriggerXOR)
+      return std::string("xor");
+    else
+      return std::string("and");
+  }
+
+  void Trigger::addTrigger(Trigger* trigger)
+  {
+    if (this != trigger)
+      this->children_.insert(trigger);
+  }
+
+  const Trigger* Trigger::getTrigger(unsigned int index) const
+  {
+    if (this->children_.size() <= index)
+      return NULL;
+
+    std::set<Trigger*>::const_iterator it;
+    it = this->children_.begin();
+
+    for (unsigned int i = 0; i != index; ++i)
+      ++it;
+
+    return (*it);
+  }
+
+  void Trigger::debugFlares(bool bVisible)
+  {
+    for (ObjectList<Trigger>::iterator it = ObjectList<Trigger>::begin(); it != ObjectList<Trigger>::end(); ++it)
+      it->setVisible(bVisible);
+  }
+
+  void Trigger::setBillboardColour(const ColourValue& colour)
+  {
+    this->debugBillboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+  }
+
+  void Trigger::changedVisibility()
+  {
+    SUPER(Trigger, changedVisibility);
+
+    this->debugBillboard_.setVisible(this->isVisible());
+  }
+}
Index: /code/branches/physics/src/orxonox/objects/worldentities/triggers/Trigger.h
===================================================================
--- /code/branches/physics/src/orxonox/objects/worldentities/triggers/Trigger.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/objects/worldentities/triggers/Trigger.h	(revision 2122)
@@ -0,0 +1,136 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Trigger_H__
+#define _Trigger_H__
+
+#include <set>
+#include <queue>
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/Tickable.h"
+#include "objects/worldentities/PositionableEntity.h"
+#include "tools/BillboardSet.h"
+
+namespace orxonox
+{
+  enum TriggerMode
+  {
+    TM_EventTriggerAND,
+    TM_EventTriggerOR,
+    TM_EventTriggerXOR,
+  };
+
+  class _OrxonoxExport Trigger : public PositionableEntity, public Tickable
+  {
+    public:
+      Trigger(BaseObject* creator);
+      virtual ~Trigger();
+
+      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+      virtual void tick(float dt);
+
+      inline bool isActive() const
+        { return bActive_; }
+
+      void addTrigger(Trigger* trigger);
+      const Trigger* getTrigger(unsigned int index) const;
+
+      void setMode(const std::string& modeName);
+      inline void setMode(TriggerMode mode)
+        { this->mode_ = mode; }
+      inline TriggerMode getMode() const
+        { return mode_; }
+
+      inline void setInvert(bool bInvert)
+        { this->bInvertMode_ = bInvert; }
+      inline bool getInvert() const
+        { return this->bInvertMode_; }
+
+      inline void setSwitch(bool bSwitch)
+        { this->bSwitch_ = bSwitch; }
+      inline bool getSwitch() const
+        { return this->bSwitch_; }
+
+      inline void setStayActive(bool bStayActive)
+        { this->bStayActive_ = bStayActive; }
+      inline bool getStayActive() const
+        { return this->bStayActive_; }
+
+      inline void setActivations(int activations)
+        { this->remainingActivations_ = activations; }
+      inline int getActivations() const
+        { return this->remainingActivations_; }
+
+      void setDelay(float delay);
+      inline float getDelay() const
+        { return this->delay_; }
+
+      bool switchState();
+
+      static void debugFlares(bool bVisible);
+      virtual void changedVisibility();
+
+    protected:
+      inline bool isTriggered() { return this->isTriggered(this->mode_); }
+      virtual bool isTriggered(TriggerMode mode);
+
+    private:
+      bool checkAnd();
+      bool checkOr();
+      bool checkXor();
+      void setBillboardColour(const ColourValue& colour);
+      void storeState();
+      std::string getModeString() const;
+
+      bool bActive_;
+      bool bTriggered_;
+      bool bFirstTick_;
+
+      TriggerMode mode_;
+      bool bInvertMode_;
+      bool bSwitch_;
+      bool bStayActive_;
+      float delay_;
+      int remainingActivations_;
+
+      char latestState_;
+      float remainingTime_;
+      float timeSinceLastEvent_;
+
+//      bool bUpdating_;
+      BillboardSet debugBillboard_;
+
+      std::set<Trigger*> children_;
+      std::queue<std::pair<float, char> > stateChanges_;
+  };
+
+}
+
+#endif /* _Trigger_H__ */
Index: /code/branches/physics/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 2122)
@@ -0,0 +1,332 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief Definition of the OrxonoxOverlay class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "OrxonoxOverlay.h"
+
+#include <cmath>
+#include <OgreOverlay.h>
+#include <OgreOverlayManager.h>
+#include <OgrePanelOverlayElement.h>
+#include "util/Convert.h"
+#include "util/String.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/ConsoleCommand.h"
+
+namespace orxonox
+{
+    unsigned int OrxonoxOverlay::hudOverlayCounter_s = 0;
+    std::map<std::string, OrxonoxOverlay*> OrxonoxOverlay::overlays_s;
+
+    SetConsoleCommand(OrxonoxOverlay, scaleOverlay, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OrxonoxOverlay, scrollOverlay, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User);
+
+    OrxonoxOverlay::OrxonoxOverlay(BaseObject* creator)
+        : BaseObject(creator)
+    {
+        RegisterObject(OrxonoxOverlay);
+
+        // add this overlay to the static map of OrxonoxOverlays
+        if (overlays_s.find(this->getName()) != overlays_s.end())
+        {
+            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
+        }
+        overlays_s[this->getName()] = this;
+
+        // create the Ogre::Overlay
+        overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"
+            + convertToString(hudOverlayCounter_s++));
+
+        // create background panel (can be used to show any picture)
+        this->background_ = static_cast<Ogre::PanelOverlayElement*>(
+            Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",
+            "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));
+        this->overlay_->add2D(this->background_);
+
+        // We'll have to set the aspect ratio to a default value first.
+        // GSGraphics gets informed about our construction here and can update us in the next tick.
+        this->windowAspectRatio_ = 1.0;
+        this->sizeCorrectionChanged();
+
+        this->changedVisibility();
+
+        setSize(Vector2(1.0f, 1.0f));
+        setPickPoint(Vector2(0.0f, 0.0f));
+        setPosition(Vector2(0.0f, 0.0f));
+        setRotation(Degree(0.0));
+        setAspectCorrection(true);
+        setBackgroundMaterial("");
+    }
+
+    /**
+    @brief
+        Make sure everything gets removed/destroyed.
+    @remark
+        We assume that the Ogre::OverlayManager exists (there is an assert in Ogre for that!)
+    */
+    OrxonoxOverlay::~OrxonoxOverlay()
+    {
+        if (this->isInitialized())
+        {
+            // erase ourself from the map with all overlays
+            std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName());
+            if (it != overlays_s.end())
+                overlays_s.erase(it);
+
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_);
+            Ogre::OverlayManager::getSingleton().destroy(this->overlay_);
+        }
+    }
+
+    /**
+    @brief
+        Loads the OrxonoxOverlay.
+
+        This has to be called before usage, otherwise strange behaviour is
+        guaranteed! (there should be no segfaults however).
+    @copydoc
+        BaseObject::XMLPort()
+    */
+    void OrxonoxOverlay::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode);
+
+        XMLPortParam(OrxonoxOverlay, "size",      setSize,      getSize,      xmlElement, mode);
+        XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode);
+        XMLPortParam(OrxonoxOverlay, "position",  setPosition,  getPosition,  xmlElement, mode);
+        XMLPortParam(OrxonoxOverlay, "rotation",  setRotation,  getRotation,  xmlElement, mode);
+        XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
+        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
+    }
+
+    void OrxonoxOverlay::changedName()
+    {
+        OrxonoxOverlay::overlays_s.erase(this->getOldName());
+
+        if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
+            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
+
+        OrxonoxOverlay::overlays_s[this->getName()] = this;
+    }
+
+    //! Only sets the background material name if not ""
+    void OrxonoxOverlay::setBackgroundMaterial(const std::string& material)
+    {
+        if (this->background_ && material != "")
+            this->background_->setMaterialName(material);
+    }
+
+    //! Returns the the material name of the background
+    const std::string& OrxonoxOverlay::getBackgroundMaterial() const
+    {
+        if (this->background_)
+            return this->background_->getMaterialName();
+        else
+            return BLANKSTRING;
+    }
+
+    //! Called by BaseObject when visibility has changed.
+    void OrxonoxOverlay::changedVisibility()
+    {
+        if (!this->overlay_)
+            return;
+
+        if (this->isVisible())
+            this->overlay_->show();
+        else
+            this->overlay_->hide();
+    }
+
+    /**
+    @brief
+        Called by the GraphicsEngine whenever the window size changes.
+        Calculates the aspect ratio only.
+    */
+    void OrxonoxOverlay::windowResized(int newWidth, int newHeight)
+    {
+        this->windowAspectRatio_ = newWidth/(float)newHeight;
+        this->sizeCorrectionChanged();
+    }
+
+    /**
+    @brief
+        Called whenever the rotation angle has changed.
+    */
+    void OrxonoxOverlay::angleChanged()
+    {
+        if (!this->overlay_)
+            return;
+
+        this->overlay_->setRotate(this->angle_);
+        this->sizeCorrectionChanged();
+    }
+
+    /**
+    @brief
+        Called whenever the aspect ratio or the angle has changed.
+        The method calculates a correction factor for the size to compensate
+        for aspect distortion if desired.
+    @remarks
+        This only works when the angle is about 0 or 90 degrees.
+    */
+    void OrxonoxOverlay::sizeCorrectionChanged()
+    {
+        if (this->bCorrectAspect_)
+        {
+            float angle = this->angle_.valueDegrees();
+            if (angle < 0.0)
+                angle = -angle;
+            angle -= 180.0 * (int)(angle / 180.0);
+
+            // take the reverse if angle is about 90 degrees
+            float tempAspect;
+            if (angle > 89.0 && angle < 91.0)
+            {
+                tempAspect = 1.0 / this->windowAspectRatio_;
+                rotState_ = Vertical;
+            }
+            else if (angle > 179 || angle < 1)
+            {
+                tempAspect = this->windowAspectRatio_;
+                rotState_ = Horizontal;
+            }
+            else
+            {
+                tempAspect = 1.0;
+                rotState_ = Inbetween;
+            }
+
+            // note: this is only an approximation that is mostly valid when the
+            // magnitude of the width is about the magnitude of the height.
+            // Correctly we would have to take the square root of width*height
+            this->sizeCorrection_.x = 2.0 / (tempAspect + 1.0);
+            this->sizeCorrection_.y = tempAspect * this->sizeCorrection_.x;
+        }
+        else
+        {
+            this->sizeCorrection_ = Vector2::UNIT_SCALE;
+        }
+
+        this->sizeChanged();
+    }
+
+    /**
+    @brief
+        Sets the overlay size using the actual corrected size.
+    */
+    void OrxonoxOverlay::sizeChanged()
+    {
+        if (!this->overlay_)
+            return;
+
+        this->overlay_->setScale(size_.x * sizeCorrection_.x, size_.y * sizeCorrection_.y);
+        positionChanged();
+    }
+
+    /**
+    @brief
+        Determines the position of the overlay.
+        This works also well when a rotation angle is applied. The overlay always
+        gets aligned correctly as well as possible.
+    */
+    void OrxonoxOverlay::positionChanged()
+    {
+        if (!this->overlay_)
+            return;
+
+        // transform the angle to a range of 0 - pi/2 first.
+        float angle = this->angle_.valueRadians();
+        if (angle < 0.0)
+            angle = -angle;
+        angle -= Ogre::Math::PI * (int)(angle / (Ogre::Math::PI));
+        if (angle > Ogre::Math::PI * 0.5)
+            angle = Ogre::Math::PI - angle;
+
+        // do some mathematical fiddling for a bounding box
+        Vector2 actualSize = size_ * sizeCorrection_;
+        float radius = actualSize.length();
+        float phi = atan(actualSize.y / actualSize.x);
+        Vector2 boundingBox(radius * cos(angle - phi), radius * sin(angle + phi));
+
+        // calculate the scrolling offset
+        Vector2 scroll = (position_ - 0.5 - boundingBox * (pickPoint_ - 0.5)) * 2.0;
+        this->overlay_->setScroll(scroll.x, -scroll.y);
+    }
+
+
+    //########### Console commands ############
+
+    /**
+    @brief
+        Scales an overlay by its name.
+    @param name
+        The name of the overlay defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OrxonoxOverlay::scaleOverlay(const std::string& name, float scale)
+    {
+        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
+        if (it != overlays_s.end())
+            (*it).second->scale(Vector2(scale, scale));
+    }
+
+    /**
+    @brief
+        Scrolls an overlay by its name.
+    @param name
+        The name of the overlay defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OrxonoxOverlay::scrollOverlay(const std::string& name, const Vector2& scroll)
+    {
+        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
+        if (it != overlays_s.end())
+            (*it).second->scroll(scroll);
+    }
+
+    /**
+    @brief
+        Rotates an overlay by its name.
+    @param name
+        The name of the overlay defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OrxonoxOverlay::rotateOverlay(const std::string& name, const Degree& angle)
+    {
+        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
+        if (it != overlays_s.end())
+            (*it).second->rotate(angle);
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/OrxonoxOverlay.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/OrxonoxOverlay.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/OrxonoxOverlay.h	(revision 2122)
@@ -0,0 +1,187 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief Declaration of the OrxonoxOverlay class.
+*/
+
+#ifndef _OrxonoxOverlay_H__
+#define _OrxonoxOverlay_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "tools/WindowEventListener.h"
+#include "util/Math.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Base class to display content directly onto the screen.
+        This is merely a wrapper of the Ogre::Overlay to implement more features and integrate it
+        in our class hierarchy for xml loading and config values.
+        The mentioned features are:
+        - Automatic positioning depending on the scale and the rotation angle.
+          You can specify a "pick point" relative to the overlay itself. This point will always be exactly
+          at the position (position_) of the overlay. That allows for margin/corner aligment.
+          It even works when a rotation angle is applied.
+        - Virtual methods for changedVisibilty() (BaseObject), angleChanged(), sizeCorrectionChanged(),
+          sizeChanged() and positionChanged(), that can be overridden by any derivative. This enables for
+          custom configurability of the size, position and rotation attributes. For intance, the HUDNavigation
+          should behave differently to sizeChanged() than a standard overlay.
+        - Console commands for scale, rotate and scroll (accessed by name)
+        - Standard Ogre::PanelOverlayElement for a background image (class doesn't have to be derived
+          only for displaying a picture).
+        - Reacts to changes of the window aspect
+        - Last but not least: On demand you can tell the overlay to automatically resale to correct for
+          aspect distortion. E.g. if you play 1024x768 you wouldn't want a round object to be oval.
+          Remark: This can (due to the Ogre::Overlay transformation order) only work for angle that are
+                  multiples of 90 degrees. But it's only a small drawback.
+    */
+    class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener
+    {
+    public:
+        /**
+        @brief
+            Describes the rotational state of a an overlay.
+            Horizontal means 0/180 degrees, Vertical is 90/270 degrees
+            and Inbetween is everything else.
+        */
+        enum RotationState
+        {
+            Horizontal,
+            Vertical,
+            Inbetween
+        };
+
+    public:
+        OrxonoxOverlay(BaseObject* creator);
+        virtual ~OrxonoxOverlay();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        virtual void changedName();
+
+        //! Shows the overlay with an detour to BaseObject::visibility_
+        void show() { this->setVisible(true); }
+        //! Hides the overlay with an detour to BaseObject::visibility_
+        void hide() { this->setVisible(false); }
+
+        /** Sets whether the aspect of the overlay is corrected.
+            This is for instance useful for round objects that should stay round no matter
+            what the screen resolution is. */
+        void setAspectCorrection(bool val)        { this->bCorrectAspect_ = val; this->sizeCorrectionChanged(); }
+        //! Returns whether the window aspect is corrected
+        bool getAspectCorrection() const          { return this->bCorrectAspect_; }
+
+        //! Sets the position of this overlay on the screen.
+        void setPosition(Vector2 pos)             { this->position_ = pos; this->positionChanged(); }
+
+        //! Returns the current position on the screen.
+        const Vector2& getPosition() const        { return this->position_; }
+
+        //! Scrolls the overlay. @param offset The offset given.
+        void scroll(const Vector2& offset)        { this->position_ += offset; this->positionChanged(); }
+
+        /** Sets the point in the overlay where to pick it when translating.
+            For instance setting it to (1.0,1.0) means that the lower right corner of the
+            overlay will be put at position_.
+            This primarily helps aligning an overlay to any corner/margin on the screen. */
+        void setPickPoint(const Vector2& position){ this->pickPoint_ = position; this->positionChanged(); }
+
+        //! Gets the pick point of this overlay. @see setPickPoint()
+        const Vector2& getPickPoint() const       { return this->pickPoint_; }
+
+        //! Sets the rotation angle applied to this overlay in degrees.
+        void setRotation(const Degree& angle)     { this->angle_ = angle; this->angleChanged(); }
+
+        //! Gets the rotation angle applied to this overlay in degrees.
+        const Radian& getRotation() const         { return this->angle_; }
+
+        //! Rotates the overlay by angle degrees.
+        void rotate(const Degree& angle)          { this->angle_ += angle; this->angleChanged(); }
+
+        //! Sets the size of this overlay.
+        void setSize(const Vector2& size)         { this->size_ = size; this->sizeChanged(); }
+
+        //! Gets the current size that was set (uncorrected)
+        const Vector2& getSize() const                   { return this->size_; }
+
+        //! Gets the actual size of the overlay on the screen (corrected)
+        Vector2 getActualSize() const      { return this->size_ * this->sizeCorrection_; }
+
+        //! Gets the current size correction (default: 1.0, 1.0)
+        const Vector2& getSizeCorrection() const  { return this->sizeCorrection_; }
+
+        //! Scales the overlay by scale.
+        void scale(const Vector2& scale)          { this->size_ *= scale; this->sizeChanged(); }
+
+        //! ConsoleCommand: Accesses the overlay by its name and scales it.
+        static void scaleOverlay(const std::string& name, float scale);
+        //! ConsoleCommand: Accesses the overlay by its name and scrolls it.
+        static void scrollOverlay(const std::string& name, const Vector2& scroll);
+        //! ConsoleCommand: Accesses the overlay by its name and rotates it.
+        static void rotateOverlay(const std::string& name, const Degree& angle);
+
+        virtual void changedVisibility();
+
+    protected:
+        virtual void angleChanged();
+        virtual void sizeCorrectionChanged();
+        virtual void sizeChanged();
+        virtual void positionChanged();
+
+        void setBackgroundMaterial(const std::string& material);
+        const std::string& getBackgroundMaterial() const;
+
+        Ogre::Overlay* overlay_;                   //!< The overlay the entire class is about.
+        Ogre::PanelOverlayElement* background_;    //!< Background image (blank per default).
+
+        float windowAspectRatio_;                  //!< Screen.width / screen.height
+        bool bCorrectAspect_;                      //!< Whether or not to correct the size. @see setAspectCorrection()
+        Vector2 size_;                             //!< Internal size of the overlay.
+        Vector2 sizeCorrection_;                   //!< Value to correct the size because of the window aspect.
+        Vector2 position_;                         //!< Position of the pickPoint on the screen.
+        Vector2 pickPoint_;                        //!< Point on the overlay to pick when translating
+        Radian angle_;                             //!< Rotation angle of the overlay
+        RotationState rotState_;             //!< horizontal, vertical or inbetween
+
+    private:
+        void windowResized(int newWidth, int newHeight);
+
+        static unsigned int hudOverlayCounter_s;   //!< Static counter for hud elements
+        /** Contains all the overlays in a map for quick access via console commands.
+            We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
+        static std::map<std::string, OrxonoxOverlay*> overlays_s;
+  };
+}
+
+#endif /* _OrxonoxOverlay_H__ */
Index: /code/branches/physics/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/OverlayGroup.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/OverlayGroup.cc	(revision 2122)
@@ -0,0 +1,189 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief Definition of the OverlayGroup class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "OverlayGroup.h"
+
+#include "util/Debug.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+#include "core/XMLPort.h"
+#include "OrxonoxOverlay.h"
+
+namespace orxonox
+{
+    CreateFactory(OverlayGroup);
+
+    SetConsoleCommand(OverlayGroup, toggleVisibility, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OverlayGroup, scaleGroup, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OverlayGroup, scrollGroup, false).accessLevel(AccessLevel::User);
+
+    OverlayGroup::OverlayGroup(BaseObject* creator)
+        : BaseObject(creator)
+    {
+        RegisterObject(OverlayGroup);
+
+        setScale(Vector2(1.0, 1.0));
+        setScroll(Vector2(0.0, 0.0));
+    }
+
+    OverlayGroup::~OverlayGroup()
+    {
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            delete it->second;
+    }
+
+    /**
+    @brief
+        Loads the group and all its children OrxonoxOverlays.
+    @copydoc
+        BaseObject::XMLPort()
+    */
+    void OverlayGroup::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(OverlayGroup, XMLPort, xmlElement, mode);
+
+        XMLPortParam(OverlayGroup, "scale",  setScale,  getScale,  xmlElement, mode);
+        XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode);
+        // loads all the child elements
+        XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode);
+    }
+
+    //! Scales every element in the map.
+    void OverlayGroup::setScale(const Vector2& scale)
+    {
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->scale(scale / this->scale_);
+        this->scale_ = scale;
+    }
+
+    //! Scrolls every element in the map.
+    void OverlayGroup::setScroll(const Vector2& scroll)
+    {
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->scroll(scroll - this->scroll_);
+        this->scroll_ = scroll;
+    }
+
+    /**
+    @brief
+        Adds an element to the map (used when loading with XMLPort).
+    @remarks
+        The names of the OrxonoxOverlays have to be unique!
+    */
+    void OverlayGroup::addElement(OrxonoxOverlay* element)
+    {
+        if (hudElements_.find(element->getName()) != hudElements_.end())
+        {
+            COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
+        }
+        else
+        {
+            hudElements_[element->getName()] = element;
+            element->setVisible(this->isVisible());
+        }
+    }
+
+    //! Returns a different element as long as index < hudElements_.size().
+    OrxonoxOverlay* OverlayGroup::getElement(unsigned int index)
+    {
+        if (index < this->hudElements_.size())
+        {
+            std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
+            for (unsigned int i = 0; i != index; ++it, ++i)
+                ;
+            return (*it).second;
+        }
+        else
+            return 0;
+    }
+
+    //! Changes the visibility of all elements
+    void OverlayGroup::changedVisibility()
+    {
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->setVisible(this->isVisible());
+    }
+
+
+    //########### Console commands ############
+
+    /**
+    @brief
+        Hides/shows an overlay group by its name.
+    @param name
+        The name of the group defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OverlayGroup::toggleVisibility(const std::string& name)
+    {
+        for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)
+        {
+            if ((*it)->getName() == name)
+                (*it)->setVisible(!((*it)->isVisible()));
+        }
+    }
+
+    /**
+    @brief
+        Scales an overlay group by its name.
+    @param name
+        The name of the group defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale)
+    {
+        for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)
+        {
+            if ((*it)->getName() == name)
+                (*it)->scale(Vector2(scale, scale));
+        }
+    }
+
+    /**
+    @brief
+        Scrolls an overlay group by its name.
+    @param name
+        The name of the group defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OverlayGroup::scrollGroup(const std::string& name, const Vector2& scroll)
+    {
+        for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)
+        {
+            if ((*it)->getName() == name)
+                (*it)->scroll(scroll);
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/OverlayGroup.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/OverlayGroup.h	(revision 2122)
@@ -0,0 +1,93 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief Declaration of the OverlayGroup class.
+*/
+
+#ifndef _OverlayGroup_H__
+#define _OverlayGroup_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <OgrePrerequisites.h>
+#include "core/BaseObject.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        OverlayGroup does almost exactly what it says: It groups OrxonoxOverlays together.
+        You can scroll the entire group by a certain amount. Scale however works differently
+        than expected: Each OrxonoxOverlay scales individually. That's quite useful when you
+        create your HUD with an OverlayGroup and then want to alter its size.
+    */
+    class _OrxonoxExport OverlayGroup : public BaseObject
+    {
+    public:
+        OverlayGroup(BaseObject* creator);
+        //! Empty destructor.
+        ~OverlayGroup();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        static void toggleVisibility(const std::string& name);
+        static void scaleGroup(const std::string& name, float scale);
+        static void scrollGroup(const std::string& name, const Vector2& scroll);
+
+        inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const
+            { return this->hudElements_; }
+
+        void changedVisibility();
+
+    private:
+        //! Scales each OrxonoxOverlay individually by scale.
+        void scale(const Vector2& scale) { this->setScale(scale * this->scale_); }
+        void setScale(const Vector2& scale);
+        //! Returns the current size of the group.
+        Vector2 getScale() const { return this->scale_; }
+
+        //! Scrolls each OrxonoxOverlay individually by scroll.
+        void scroll(const Vector2& scroll) { this->setScroll(scroll + this->scroll_); }
+        void setScroll(const Vector2& scroll);
+        //! Returns the current scrolling offset of the group.
+        Vector2 getScroll() const { return this->scale_; }
+
+        void addElement(OrxonoxOverlay* element);
+        OrxonoxOverlay* getElement(unsigned int index);
+
+        std::map<std::string, OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
+        Vector2 scale_;                                         //!< Current scale (independant of the elements).
+        Vector2 scroll_;                                        //!< Current scrolling offset.
+    };
+}
+
+#endif /* _OverlayGroup_H__ */
Index: /code/branches/physics/src/orxonox/overlays/OverlayText.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/OverlayText.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/OverlayText.cc	(revision 2122)
@@ -0,0 +1,122 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "OverlayText.h"
+
+#include <OgreOverlayManager.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/String.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(OverlayText);
+
+    OverlayText::OverlayText(BaseObject* creator)
+        : OrxonoxOverlay(creator)
+    {
+        RegisterObject(OverlayText);
+
+        this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberString()));
+        this->text_->setCharHeight(1.0);
+
+        setFont("Monofur");
+        setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
+        setCaption("");
+        setTextSize(1.0f);
+        setAlignmentString("left");
+
+        this->background_->addChild(this->text_);
+    }
+
+    OverlayText::~OverlayText()
+    {
+        if (this->isInitialized())
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_);
+    }
+
+    void OverlayText::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(OverlayText, XMLPort, xmlElement, mode);
+
+        XMLPortParam(OverlayText, "font",     setFont,            getFont,            xmlElement, mode);
+        XMLPortParam(OverlayText, "colour",   setColour,          getColour,          xmlElement, mode);
+        XMLPortParam(OverlayText, "caption",  setCaption,         getCaption,         xmlElement, mode);
+        XMLPortParam(OverlayText, "textSize", setTextSize,        getTextSize,        xmlElement, mode);
+        XMLPortParam(OverlayText, "align",    setAlignmentString, getAlignmentString, xmlElement, mode);
+    }
+
+    void OverlayText::setFont(const std::string& font)
+    {
+        if (font != "")
+            this->text_->setFontName(font);
+    }
+
+    void OverlayText::setAlignmentString(const std::string& alignment)
+    {
+        if (alignment == "right")
+            this->setAlignment(Ogre::TextAreaOverlayElement::Right);
+        else if (alignment == "center")
+            this->setAlignment(Ogre::TextAreaOverlayElement::Center);
+        else // "left" and default
+            this->setAlignment(Ogre::TextAreaOverlayElement::Left);
+    }
+
+    std::string OverlayText::getAlignmentString() const
+    {
+        Ogre::TextAreaOverlayElement::Alignment alignment = this->text_->getAlignment();
+
+        switch (alignment)
+        {
+            case Ogre::TextAreaOverlayElement::Right:
+                return "right";
+            case Ogre::TextAreaOverlayElement::Center:
+                return "center";
+            case Ogre::TextAreaOverlayElement::Left:
+                return "left";
+            default:
+                assert(false); return "";
+        }
+    }
+
+    void OverlayText::sizeChanged()
+    {
+        if (this->rotState_ == Horizontal)
+            this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y);
+        else if (this->rotState_ == Vertical)
+            this->overlay_->setScale(size_.y / (sizeCorrection_.y * sizeCorrection_.y), size_.y * sizeCorrection_.y);
+        else
+            this->overlay_->setScale(size_.y, size_.y);
+
+        positionChanged();
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/OverlayText.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/OverlayText.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/OverlayText.h	(revision 2122)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _OverlayText_H__
+#define _OverlayText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+#include "OrxonoxOverlay.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport OverlayText : public OrxonoxOverlay
+    {
+    public:
+        OverlayText(BaseObject* creator);
+        virtual ~OverlayText();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
+        std::string getCaption() const              { return this->text_->getCaption(); }
+
+        void setFont(const std::string& font);
+        const std::string& getFont() const { return this->text_->getFontName(); }
+
+        void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
+        const ColourValue& getColour() const      { return this->text_->getColour(); }
+
+        void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }
+        Ogre::TextAreaOverlayElement::Alignment getAlignment() const         { return this->text_->getAlignment(); }
+
+    protected:
+        virtual void sizeChanged();
+
+        void setAlignmentString(const std::string& alignment);
+        std::string getAlignmentString() const;
+
+        void setTextSize(float size) { this->setSize(Vector2(size, size)); }
+        float getTextSize() const    { return this->getSize().y; }
+
+        Ogre::TextAreaOverlayElement* text_;
+    };
+}
+#endif /* _OverlayText_H__ */
Index: /code/branches/physics/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/console/InGameConsole.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/console/InGameConsole.cc	(revision 2122)
@@ -0,0 +1,626 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "InGameConsole.h"
+
+#include <string>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
+#include <OgreFontManager.h>
+#include <OgreFont.h>
+
+#include "util/Math.h"
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/input/InputBuffer.h"
+
+namespace orxonox
+{
+    const int LINES = 30;
+    const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
+
+    SetConsoleCommand(InGameConsole, openConsole, true);
+    SetConsoleCommand(InGameConsole, closeConsole, true);
+
+    InGameConsole* InGameConsole::singletonRef_s = 0;
+
+    /**
+        @brief Constructor: Creates and initializes the InGameConsole.
+    */
+    InGameConsole::InGameConsole()
+        : consoleOverlay_(0)
+        , consoleOverlayContainer_(0)
+        , consoleOverlayNoise_(0)
+        , consoleOverlayCursor_(0)
+        , consoleOverlayBorder_(0)
+        , consoleOverlayTextAreas_(0)
+        , inputState_(0)
+    {
+        RegisterObject(InGameConsole);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->bActive_ = false;
+        this->cursor_ = 0.0f;
+        this->cursorSymbol_ = '|';
+        this->inputWindowStart_ = 0;
+        this->numLinesShifted_ = LINES - 1;
+        // for the beginning, don't scroll
+        this->scroll_ = 0;
+
+        this->setConfigValues();
+    }
+
+    /**
+        @brief Destructor: Destroys the TextAreas.
+    */
+    InGameConsole::~InGameConsole(void)
+    {
+        this->deactivate();
+
+        // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
+        InputManager::getInstance().requestDestroyState("console");
+
+        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+        if (ovMan)
+        {
+            if (this->consoleOverlayNoise_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
+            if (this->consoleOverlayCursor_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
+            Ogre::FontManager::getSingleton().remove("MonofurConsole");
+            if (this->consoleOverlayBorder_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
+            if (this->consoleOverlayTextAreas_)
+            {
+                for (int i = 0; i < LINES; i++)
+                {
+                    if (this->consoleOverlayTextAreas_[i])
+                      Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+                    this->consoleOverlayTextAreas_[i] = 0;
+                }
+
+            }
+            if (this->consoleOverlayContainer_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
+        }
+        if (this->consoleOverlayTextAreas_)
+        {
+            delete[] this->consoleOverlayTextAreas_;
+            this->consoleOverlayTextAreas_ = 0;
+        }
+
+        if (this->consoleOverlay_)
+            Ogre::OverlayManager::getSingleton().destroy(consoleOverlay_);
+
+        singletonRef_s = 0;
+    }
+
+    /**
+        @brief Sets the config values, describing the size of the console.
+    */
+    void InGameConsole::setConfigValues()
+    {
+        SetConfigValue(relativeWidth, 0.8);
+        SetConfigValue(relativeHeight, 0.4);
+        SetConfigValue(blinkTime, 0.5);
+        SetConfigValue(scrollSpeed_, 3.0f);
+        SetConfigValue(noiseSize_, 1.0f);
+        SetConfigValue(cursorSymbol_, '|');
+        SetConfigValue(bHidesAllInput_, false).callback(this, &InGameConsole::bHidesAllInputChanged);
+    }
+
+    /**
+        @brief Called whenever bHidesAllInput_ changes.
+    */
+    void InGameConsole::bHidesAllInputChanged()
+    {
+        if (inputState_)
+        {
+            if (bHidesAllInput_)
+            {
+                inputState_->setMouseHandler(&InputManager::EMPTY_HANDLER);
+                inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
+            }
+            else
+            {
+                inputState_->setMouseHandler(0);
+                inputState_->setJoyStickHandler(0);
+            }
+        }
+    }
+
+    /**
+        @brief Initializes the InGameConsole.
+    */
+    void InGameConsole::initialise(int windowWidth, int windowHeight)
+    {
+        // create the corresponding input state
+        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);
+        inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
+        bHidesAllInputChanged();
+
+        // create overlay and elements
+        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+
+        // create actual overlay
+        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
+
+        // create a container
+        this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
+        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
+        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
+        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
+        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
+
+        // create BorderPanel
+        this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
+        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
+        this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
+        this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
+        this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+        this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+        this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+        this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+        this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
+
+        // create a new font to match the requested size exactly
+        Ogre::FontPtr font = static_cast<Ogre::FontPtr>
+            (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
+        font->setType(Ogre::FT_TRUETYPE);
+        font->setSource("Monofur.ttf");
+        font->setTrueTypeSize(18);
+        // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
+        font->setTrueTypeResolution(192);
+        font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
+        font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
+
+        // create the text lines
+        this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
+            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
+            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
+            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
+            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
+            this->consoleOverlayTextAreas_[i]->setLeft(8);
+            this->consoleOverlayTextAreas_[i]->setCaption("");
+            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+        }
+
+        // create cursor (also a text area overlay element)
+        this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
+        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayCursor_->setFontName("MonofurConsole");
+        this->consoleOverlayCursor_->setCharHeight(18);
+        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
+        this->consoleOverlayCursor_->setLeft(7);
+        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
+
+        // create noise
+        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
+        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayNoise_->setPosition(5,0);
+        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
+        // comment following line to disable noise
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
+
+        this->windowResized(windowWidth, windowHeight);
+
+        // move overlay "above" the top edge of the screen
+        // we take -1.2 because the border makes the panel bigger
+        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+
+        Shell::getInstance().addOutputLevel(true);
+
+        COUT(4) << "Info: InGameConsole initialized" << std::endl;
+    }
+
+    // ###############################
+    // ###  ShellListener methods  ###
+    // ###############################
+
+    /**
+        @brief Called if all output-lines have to be redrawn.
+    */
+    void InGameConsole::linesChanged()
+    {
+        std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
+        int max = 0;
+        for (int i = 1; i < LINES; ++i)
+        {
+            if (it != Shell::getInstance().getEndIterator())
+            {
+                ++it;
+                max = i;
+            }
+            else
+                break;
+        }
+
+        for (int i = LINES - 1; i > max; --i)
+            this->print("", i, true);
+
+        for (int i = max; i >= 1; --i)
+        {
+            --it;
+            this->print(*it, i, true);
+        }
+    }
+
+    /**
+        @brief Called if only the last output-line has changed.
+    */
+    void InGameConsole::onlyLastLineChanged()
+    {
+        if (LINES > 1)
+            this->print(*Shell::getInstance().getNewestLineIterator(), 1);
+    }
+
+    /**
+        @brief Called if a new output-line was added.
+    */
+    void InGameConsole::lineAdded()
+    {
+        this->numLinesShifted_ = 0;
+        this->shiftLines();
+        this->onlyLastLineChanged();
+    }
+
+    /**
+        @brief Called if the text in the input-line has changed.
+    */
+    void InGameConsole::inputChanged()
+    {
+        if (LINES > 0)
+            this->print(Shell::getInstance().getInput(), 0);
+
+        if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
+            this->inputWindowStart_ = 0;
+    }
+
+    /**
+        @brief Called if the position of the cursor in the input-line has changed.
+    */
+    void InGameConsole::cursorChanged()
+    {
+        unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
+        if (pos > maxCharsPerLine_)
+            pos = maxCharsPerLine_;
+
+        this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
+        this->consoleOverlayCursor_->setTop((int) this->windowH_ * this->relativeHeight - 24);
+    }
+
+    /**
+        @brief Called if the console gets closed.
+    */
+    void InGameConsole::exit()
+    {
+        this->deactivate();
+    }
+
+    // ###############################
+    // ###  other external calls   ###
+    // ###############################
+
+    /**
+        @brief Used to control the actual scrolling and the cursor.
+    */
+    void InGameConsole::tick(float dt)
+    {
+        if (this->scroll_ != 0)
+        {
+            float oldTop = this->consoleOverlayContainer_->getTop();
+
+            if (this->scroll_ > 0)
+            {
+                // scrolling down
+                // enlarge oldTop a little bit so that this exponential function
+                // reaches 0 before infinite time has passed...
+                float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll >= 0)
+                {
+                    // window has completely scrolled down
+                    this->consoleOverlayContainer_->setTop(0);
+                    this->scroll_ = 0;
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+            }
+
+            else
+            {
+                // scrolling up
+                // note: +0.01 for the same reason as when scrolling down
+                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
+                {
+                    // window has completely scrolled up
+                    this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+                    this->scroll_ = 0;
+                    this->consoleOverlay_->hide();
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+            }
+        }
+
+        if (this->bActive_)
+        {
+            this->cursor_ += dt;
+            if (this->cursor_ >= this->blinkTime)
+            {
+                this->cursor_ = 0;
+                bShowCursor_ = !bShowCursor_;
+                if (bShowCursor_)
+                    this->consoleOverlayCursor_->show();
+                else
+                    this->consoleOverlayCursor_->hide();
+            }
+
+            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
+            float uRand = (rand() & 1023) / 1023.0f * 0.2f;
+            float vRand = (rand() & 1023) / 1023.0f * 0.2f;
+            this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
+        }
+    }
+
+    /**
+        @brief Resizes the console elements. Call if window size changes.
+    */
+    void InGameConsole::windowResized(int newWidth, int newHeight)
+    {
+        this->windowW_ = newWidth;
+        this->windowH_ = newHeight;
+        this->consoleOverlayBorder_->setWidth((int) this->windowW_* this->relativeWidth);
+        this->consoleOverlayBorder_->setHeight((int) this->windowH_ * this->relativeHeight);
+        this->consoleOverlayNoise_->setWidth((int) this->windowW_ * this->relativeWidth - 10);
+        this->consoleOverlayNoise_->setHeight((int) this->windowH_ * this->relativeHeight - 5);
+        this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
+
+        // now adjust the text lines...
+        this->desiredTextWidth_ = (int) (this->windowW_ * this->relativeWidth) - 12;
+
+        if (LINES > 0)
+            this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
+        else
+            this->maxCharsPerLine_ = 10;
+
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
+            this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * this->relativeHeight - 24 - 14*i);
+        }
+
+        this->linesChanged();
+        this->cursorChanged();
+    }
+
+    // ###############################
+    // ###    internal methods     ###
+    // ###############################
+
+    /**
+        @brief Prints string to bottom line.
+        @param s String to be printed
+    */
+    void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
+    {
+        char level = 0;
+        if (text.size() > 0)
+            level = text[0];
+
+        std::string output = text;
+
+        if (level >= -1 && level <= 5)
+            output.erase(0, 1);
+
+        if (LINES > index)
+        {
+            this->colourLine(level, index);
+
+            if (index > 0)
+            {
+                unsigned int linesUsed = 1;
+                while (output.size() > this->maxCharsPerLine_)
+                {
+                    ++linesUsed;
+                    this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output.substr(0, this->maxCharsPerLine_)));
+                    output.erase(0, this->maxCharsPerLine_);
+                    output.insert(0, 1, ' ');
+                    if (linesUsed > numLinesShifted_ || alwaysShift)
+                        this->shiftLines();
+                    this->colourLine(level, index);
+                }
+                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+                this->displayedText_ = output;
+                this->numLinesShifted_ = linesUsed;
+            }
+            else
+            {
+                if (output.size() > this->maxCharsPerLine_)
+                {
+                    if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
+                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
+                    else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
+                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
+
+                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
+                }
+                else
+                  this->inputWindowStart_ = 0;
+                this->displayedText_ = output;
+                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+            }
+        }
+    }
+
+    /**
+        @brief Shows the InGameConsole.
+    */
+    void InGameConsole::activate()
+    {
+        if (!this->bActive_)
+        {
+            this->bActive_ = true;
+            InputManager::getInstance().requestEnterState("console");
+            Shell::getInstance().registerListener(this);
+
+            this->windowResized(this->windowW_, this->windowH_);
+            this->linesChanged();
+            this->cursorChanged();
+            this->consoleOverlay_->show();
+
+            // scroll down
+            this->scroll_ = 1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+    @brief Hides the InGameConsole.
+    */
+    void InGameConsole::deactivate()
+    {
+        if (this->bActive_)
+        {
+            this->bActive_ = false;
+            InputManager::getInstance().requestLeaveState("console");
+            Shell::getInstance().unregisterListener(this);
+
+            // scroll up
+            this->scroll_ = -1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+        @brief Shifts all output lines one line up
+    */
+    void InGameConsole::shiftLines()
+    {
+        for (unsigned int i = LINES - 1; i > 1; --i)
+        {
+            this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
+            this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
+            this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
+        }
+    }
+
+    void InGameConsole::colourLine(int colourcode, int index)
+    {
+        if (colourcode == -1)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.90, 0.90, 0.90, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
+        }
+        else if (colourcode == 1)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.25, 0.25, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
+        }
+        else if (colourcode == 2)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.50, 0.20, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
+        }
+        else if (colourcode == 3)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.50, 0.50, 0.95, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
+        }
+        else if (colourcode == 4)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.65, 0.48, 0.44, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
+        }
+        else if (colourcode == 5)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.40, 0.20, 0.40, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
+        }
+        else
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.21, 0.69, 0.21, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
+        }
+    }
+
+    // ###############################
+    // ###      satic methods      ###
+    // ###############################
+
+    /**
+        @brief Activates the console.
+    */
+    /*static*/ void InGameConsole::openConsole()
+    {
+        InGameConsole::getInstance().activate();
+    }
+
+    /**
+        @brief Deactivates the console.
+    */
+    /*static*/ void InGameConsole::closeConsole()
+    {
+        InGameConsole::getInstance().deactivate();
+    }
+
+    /**
+        @brief Converts a string into an Ogre::UTFString.
+        @param s The string to convert
+        @return The converted string
+    */
+    /*static*/ Ogre::UTFString InGameConsole::convert2UTF(const std::string& text)
+    {
+        Ogre::UTFString utf;
+        Ogre::UTFString::code_point cp;
+        for (unsigned int i = 0; i < text.size(); ++i)
+        {
+          cp = text[i];
+          cp &= 0xFF;
+          utf.append(1, cp);
+        }
+        return utf;
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/console/InGameConsole.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/console/InGameConsole.h	(revision 2122)
@@ -0,0 +1,123 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _InGameConsole_H__
+#define _InGameConsole_H__
+
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+
+#include "core/Shell.h"
+#include "core/OrxonoxClass.h"
+#include "tools/WindowEventListener.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport InGameConsole : virtual public OrxonoxClass, public ShellListener, public WindowEventListener
+    {
+    public: // functions
+        InGameConsole();
+        ~InGameConsole();
+
+        void initialise(int windowWidth, int windowHeight);
+        void destroy();
+        void setConfigValues();
+
+        virtual void tick(float dt);
+
+        static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+        static InGameConsole* getInstancePtr() { return singletonRef_s; }
+
+        static void openConsole();
+        static void closeConsole();
+
+        static Ogre::UTFString convert2UTF(const std::string& text);
+
+    private: // functions
+        InGameConsole(const InGameConsole& other);
+
+        void activate();
+        void deactivate();
+
+        void linesChanged();
+        void onlyLastLineChanged();
+        void lineAdded();
+        void inputChanged();
+        void cursorChanged();
+        void exit();
+
+        void shiftLines();
+        void colourLine(int colourcode, int index);
+        void setCursorPosition(unsigned int pos);
+        void print(const std::string& text, int index, bool alwaysShift = false);
+
+        void windowResized(int newWidth, int newHeight);
+
+        // config value related
+        void bHidesAllInputChanged();
+
+    private: // variables
+        bool bActive_;
+        int windowW_;
+        int windowH_;
+        int desiredTextWidth_;
+        unsigned int maxCharsPerLine_;
+        unsigned int numLinesShifted_;
+        int scroll_;
+        float cursor_;
+        unsigned int inputWindowStart_;
+        bool bShowCursor_;
+        std::string displayedText_;
+        Ogre::Overlay* consoleOverlay_;
+        Ogre::OverlayContainer* consoleOverlayContainer_;
+        Ogre::PanelOverlayElement* consoleOverlayNoise_;
+        Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
+        Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
+        Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+
+        // input related
+        SimpleInputState* inputState_;
+
+        // config values
+        float relativeWidth;
+        float relativeHeight;
+        float blinkTime;
+        float scrollSpeed_;
+        float noiseSize_;
+        char cursorSymbol_;
+        bool bHidesAllInput_;
+
+        static InGameConsole* singletonRef_s;
+    };
+}
+
+#endif /* _InGameConsole_H__ */
Index: /code/branches/physics/src/orxonox/overlays/debug/DebugFPSText.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "DebugFPSText.h"
+#include <OgreTextAreaOverlayElement.h>
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    CreateFactory(DebugFPSText);
+
+    DebugFPSText::DebugFPSText(BaseObject* creator) : OverlayText(creator)
+    {
+        RegisterObject(DebugFPSText);
+    }
+
+    DebugFPSText::~DebugFPSText()
+    {
+    }
+
+    void DebugFPSText::tick(float dt)
+    {
+        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
+        this->setCaption(convertToString(fps));
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/debug/DebugFPSText.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/debug/DebugFPSText.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/debug/DebugFPSText.h	(revision 2122)
@@ -0,0 +1,48 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _DebugFPSText_H__
+#define _DebugFPSText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/OverlayText.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport DebugFPSText : public OverlayText, public Tickable
+    {
+    public:
+        DebugFPSText(BaseObject* creator);
+        ~DebugFPSText();
+
+        virtual void tick(float dt);
+    };
+}
+#endif /* _DebugFPSText_H__ */
Index: /code/branches/physics/src/orxonox/overlays/debug/DebugRTRText.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "DebugRTRText.h"
+#include <OgreTextAreaOverlayElement.h>
+#include "core/CoreIncludes.h"
+#include "util/Convert.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(DebugRTRText);
+
+    DebugRTRText::DebugRTRText(BaseObject* creator) : OverlayText(creator)
+    {
+        RegisterObject(DebugRTRText);
+    }
+
+    DebugRTRText::~DebugRTRText()
+    {
+    }
+
+    void DebugRTRText::tick(float dt)
+    {
+        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
+        this->setCaption(convertToString(rtr));
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/debug/DebugRTRText.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/debug/DebugRTRText.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/debug/DebugRTRText.h	(revision 2122)
@@ -0,0 +1,48 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _DebugRTRText_H__
+#define _DebugRTRText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/OverlayText.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport DebugRTRText : public OverlayText, public Tickable
+    {
+    public:
+        DebugRTRText(BaseObject* creator);
+        ~DebugRTRText();
+
+        virtual void tick(float dt);
+    };
+}
+#endif /* _DebugRTRText_H__ */
Index: /code/branches/physics/src/orxonox/overlays/hud/ChatOverlay.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/ChatOverlay.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/ChatOverlay.cc	(revision 2122)
@@ -0,0 +1,113 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ChatOverlay.h"
+
+#include <OgreTextAreaOverlayElement.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Executor.h"
+
+#include "network/ClientInformation.h"
+
+#include "LevelManager.h"
+#include "objects/infos/PlayerInfo.h"
+#include "overlays/console/InGameConsole.h"
+#include "tools/Timer.h"
+
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    CreateFactory(ChatOverlay);
+
+    ChatOverlay::ChatOverlay(BaseObject* creator)
+        : OverlayText(creator)
+    {
+        RegisterObject(ChatOverlay);
+
+        this->displayTime_ = 0.0;
+
+        this->setConfigValues();
+    }
+
+    ChatOverlay::~ChatOverlay()
+    {
+    }
+
+    void ChatOverlay::setConfigValues()
+    {
+        SetConfigValue(displayTime_, 6.0f);
+    }
+
+    void ChatOverlay::incomingChat(const std::string& message, unsigned int senderID)
+    {
+        std::string text;
+
+        if (senderID != network::CLIENTID_UNKNOWN)
+        {
+            std::string name = "unknown";
+
+            PlayerInfo* player = LevelManager::getInstance().getClient(senderID);
+            if (player)
+                name = player->getName();
+
+            text = name + ": " + message;
+        }
+        else
+        {
+            text = message;
+        }
+
+        this->messages_.push_back(InGameConsole::convert2UTF(text));
+        COUT(0) << "Chat: " << text << std::endl;
+
+        new Timer<ChatOverlay>(this->displayTime_, false, this, createExecutor(createFunctor(&ChatOverlay::dropMessage)), true);
+
+        this->updateOverlayText();
+    }
+
+    void ChatOverlay::dropMessage()
+    {
+        if (this->messages_.size() > 0)
+            this->messages_.pop_front();
+        this->updateOverlayText();
+    }
+
+    void ChatOverlay::updateOverlayText()
+    {
+        this->text_->setCaption("");
+
+        for (std::list<Ogre::UTFString>::reverse_iterator it = this->messages_.rbegin(); it != this->messages_.rend(); ++it)
+        {
+            this->text_->setCaption(this->text_->getCaption() + "\n" + (*it));
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/hud/ChatOverlay.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/ChatOverlay.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/ChatOverlay.h	(revision 2122)
@@ -0,0 +1,61 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ChatOverlay_H__
+#define _ChatOverlay_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgreTextAreaOverlayElement.h>
+
+#include "network/ChatListener.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ChatOverlay : public OverlayText, public network::ChatListener
+    {
+        public:
+            ChatOverlay(BaseObject* creator);
+            ~ChatOverlay();
+
+            void setConfigValues();
+
+        protected:
+            virtual void incomingChat(const std::string& message, unsigned int senderID);
+
+            std::list<Ogre::UTFString> messages_;
+
+        private:
+            void updateOverlayText();
+            void dropMessage();
+
+            float displayTime_;
+    };
+}
+#endif /* _DebugFPSText_H__ */
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDBar.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDBar.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDBar.cc	(revision 2122)
@@ -0,0 +1,183 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Yuning Chai
+ *   Co-authors:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDBar.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Convert.h"
+#include "util/String.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(BarColour);
+
+    BarColour::BarColour(BaseObject* creator)
+        : BaseObject(creator)
+    {
+        RegisterObject(BarColour);
+
+        setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
+        setPosition(0.0);
+    }
+
+    void BarColour::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(BarColour, XMLPort, xmlElement, mode);
+
+        XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode);
+        XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode);
+    }
+
+
+    unsigned int HUDBar::materialcount_s = 0;
+
+    HUDBar::HUDBar(BaseObject* creator)
+        : OrxonoxOverlay(creator)
+    {
+        RegisterObject(HUDBar);
+
+        // create new material
+        std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
+        Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
+        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+        this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
+        this->textureUnitState_->setTextureName("bar2.tga");
+        // use the default colour
+        this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
+
+        this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString()));
+        this->bar_->setMaterialName(materialname);
+
+        setValue(0.4567654f);
+        setRightToLeft(false);
+        setAutoColour(true);
+
+        this->background_->addChild(bar_);
+    }
+
+    HUDBar::~HUDBar()
+    {
+        if (this->isInitialized())
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
+    }
+
+    void HUDBar::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(HUDBar, XMLPort, xmlElement, mode);
+
+        XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode);
+        XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode);
+        XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode);
+        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode);
+    }
+
+    void HUDBar::valueChanged()
+    {
+        if (this->autoColour_ && this->textureUnitState_)
+        {
+            // set colour
+            if (this->colours_.size() > 0)
+            {
+                ColourValue colour1, colour2 = (*this->colours_.rbegin()).second;
+                float value1, value2 = (*this->colours_.rbegin()).first;
+                for (std::map<float, ColourValue>::reverse_iterator it = this->colours_.rbegin(); it != this->colours_.rend(); ++it)
+                {
+                    colour1 = colour2;
+                    value1 = value2;
+                    colour2 = (*it).second;
+                    value2 = (*it).first;
+
+                    if (value2 < this->value_)
+                        break;
+                }
+
+                if (value2 > this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
+                }
+                else if (value1 < this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
+                }
+                else
+                {
+                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
+                    float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f);
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor));
+                }
+            }
+        }
+
+        // set value
+        if (this->right2Left_)
+        {
+            // backward casew
+            this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f);
+            this->bar_->setDimensions(0.88f * this->value_, 1.0f);
+        }
+        else
+        {
+            // default case
+            this->bar_->setPosition(0.06f, 0.0f);
+            this->bar_->setDimensions(0.88f * this->value_, 1.0f);
+        }
+        if (this->value_ != 0)
+            this->bar_->setTiling(this->value_, 1.0);
+    }
+
+    void HUDBar::addColour(BarColour* colour)
+    {
+        float value = clamp<float>(colour->getPosition(), 0.0, 1.0);
+        this->colours_[value] = colour->getColour();
+
+        this->barColours_.push_back(colour);
+    }
+
+    BarColour* HUDBar::getColour(unsigned int index)
+    {
+        if (index < this->barColours_.size())
+            return barColours_[index];
+        else
+            return 0;
+    }
+
+    void HUDBar::clearColours()
+    {
+        this->colours_.clear();
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDBar.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDBar.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDBar.h	(revision 2122)
@@ -0,0 +1,101 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Yuning Chai
+ *   Co-authors:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDBar_H__
+#define _HUDBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <OgrePrerequisites.h>
+#include "util/Math.h"
+#include "overlays/OrxonoxOverlay.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BarColour : public BaseObject
+    {
+    public:
+        BarColour(BaseObject* creator);
+        ~BarColour() { }
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        void setColour(const ColourValue& colour) { this->colour_ = colour; }
+        const ColourValue& getColour() const { return this->colour_; }
+
+        void setPosition(float pos) { this->position_ = pos; }
+        float getPosition() const    { return this->position_; }
+
+    private:
+        ColourValue colour_;
+        float position_;
+    };
+
+
+    class _OrxonoxExport HUDBar : public OrxonoxOverlay
+    {
+    public:
+        HUDBar(BaseObject* creator);
+        virtual ~HUDBar();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        void clearColours();
+
+        void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); }
+        bool getRightToLeft() const   { return this->right2Left_; }
+
+        void setValue(float value)    { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); }
+        float getValue() const        { return this->value_; }
+
+        void setAutoColour(bool val)  { this->autoColour_ = val; this->valueChanged(); }
+        bool getAutoColour() const    { return this->autoColour_; }
+
+    protected:
+        virtual void valueChanged();
+
+    private:
+        void addColour(BarColour* colour);
+        BarColour* getColour(unsigned int index);
+
+        bool right2Left_;
+        bool autoColour_;                   //!< whether bar changes colour automatically
+        float value_;                       //!< progress of bar
+
+        Ogre::PanelOverlayElement* bar_;
+        Ogre::TextureUnitState* textureUnitState_;
+        std::map<float, ColourValue> colours_;
+        std::vector<BarColour*> barColours_;
+
+        static unsigned int materialcount_s;
+    };
+}
+#endif /* _HUDBar_H__ */
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDNavigation.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDNavigation.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDNavigation.cc	(revision 2122)
@@ -0,0 +1,274 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDNavigation.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "util/String.h"
+#include "util/Convert.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/Radar.h"
+
+namespace orxonox
+{
+    CreateFactory(HUDNavigation);
+
+    HUDNavigation::HUDNavigation(BaseObject* creator)
+        : OrxonoxOverlay(creator)
+    {
+        RegisterObject(HUDNavigation);
+
+        // create nav text
+        navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
+
+        // create nav marker
+        navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
+        navMarker_->setMaterialName("Orxonox/NavArrows");
+
+        // create aim marker
+        aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));
+        aimMarker_->setMaterialName("Orxonox/NavCrosshair");
+        this->wasOutOfView_ = true; // Ensure the material is changed right the first time..
+
+        setFont("Monofur");
+        setTextSize(0.05f);
+        setNavMarkerSize(0.05f);
+        setAimMarkerSize(0.04f);
+
+        background_->addChild(navMarker_);
+        background_->addChild(aimMarker_);
+        background_->addChild(navText_);
+
+        // hide at first
+        this->setVisible(false);
+    }
+
+    HUDNavigation::~HUDNavigation()
+    {
+        if (this->isInitialized())
+        {
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
+        }
+    }
+
+    void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(HUDNavigation, XMLPort, xmlElement, mode);
+
+        XMLPortParam(HUDNavigation, "font",     setFont,     getFont,     xmlElement, mode);
+        XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode);
+        XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
+        XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
+    }
+
+    void HUDNavigation::setFont(const std::string& font)
+    {
+        if (this->navText_ && font != "")
+            this->navText_->setFontName(font);
+    }
+
+    const std::string& HUDNavigation::getFont() const
+    {
+        if (this->navText_)
+            return this->navText_->getFontName();
+        else
+            return BLANKSTRING;
+    }
+
+    void HUDNavigation::setTextSize(float size)
+    {
+        if (this->navText_ && size >= 0.0f)
+            this->navText_->setCharHeight(size);
+    }
+
+    float HUDNavigation::getTextSize() const
+    {
+        if (this->navText_)
+            return this->navText_->getCharHeight();
+        else
+            return 0.0f;
+    }
+
+    void HUDNavigation::tick(float dt)
+    {
+        if (!Radar::getInstance().getFocus())
+        {
+            this->overlay_->hide();
+            return;
+        }
+        else
+        {
+            this->overlay_->show();
+        }
+
+        // set text
+        int dist = (int) getDist2Focus();
+        navText_->setCaption(convertToString(dist));
+        float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
+
+/*
+        Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
+        Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
+*/
+        // transform to screen coordinates
+        Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition();
+
+        bool outOfView;
+        if (pos.z > 1.0)
+        {
+            // z > 1.0 means that the object is behind the camera
+            outOfView = true;
+            // we have to switch all coordinates (if you don't know why,
+            // try linear algebra lectures, because I can't explain..)
+            pos.x = -pos.x;
+            pos.y = -pos.y;
+        }
+        else
+            outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+
+        if (outOfView)
+        {
+            // object is not in view
+            aimMarker_->hide();
+
+            if (!wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavArrows");
+                wasOutOfView_ = true;
+            }
+
+            if (pos.x < pos.y)
+            {
+                if (pos.y > -pos.x)
+                {
+                    // up
+                    float position = pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 0.0);
+                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
+                    navText_->setLeft((position - textLength) * 0.5);
+                    navText_->setTop(navMarker_->getHeight());
+                }
+                else
+                {
+                    // left
+                    float position = pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(0.0, (position - navMarker_->getWidth()) * 0.5);
+                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
+                    navText_->setLeft(navMarker_->getWidth() + 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
+                }
+            }
+            else
+            {
+                if (pos.y < -pos.x)
+                {
+                    // down
+                    float position = -pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 1.0 - navMarker_->getHeight());
+                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
+                    navText_->setLeft((position - textLength) * 0.5);
+                    navText_->setTop(1.0 - navMarker_->getHeight() - navText_->getCharHeight());
+                }
+                else
+                {
+                    // right
+                    float position = -pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(1.0 - navMarker_->getWidth(), (position - navMarker_->getHeight()) * 0.5);
+                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
+                    navText_->setLeft(1.0 - navMarker_->getWidth() - textLength - 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
+                }
+            }
+        }
+        else
+        {
+            // object is in view
+/*
+            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
+                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());
+*/
+            if (wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavTDC");
+                wasOutOfView_ = false;
+            }
+
+            // object is in view
+            navMarker_->setUV(0.0, 0.0, 1.0, 1.0);
+            navMarker_->setLeft((pos.x + 1.0 - navMarker_->getWidth()) * 0.5);
+            navMarker_->setTop((-pos.y + 1.0 - navMarker_->getHeight()) * 0.5);
+
+            aimMarker_->show();
+/*
+            aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5);
+            aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5);
+*/
+            navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5);
+            navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5);
+        }
+    }
+
+    float HUDNavigation::getDist2Focus() const
+    {
+/*
+        if (Radar::getInstance().getFocus())
+            return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
+        else
+*/
+            return 0;
+    }
+
+    /**
+    @brief Overridden method of OrxonoxOverlay. Usually the entire overlay
+           scales with scale(). Here we obviously have to adjust this.
+    */
+    void HUDNavigation::sizeChanged()
+    {
+        // use size to compensate for apspect ratio if enabled.
+        float xScale = this->getActualSize().x;
+        float yScale = this->getActualSize().y;
+        if (this->navMarker_)
+            navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+        if (this->aimMarker_)
+            aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale);
+        if (this->navText_)
+            navText_->setCharHeight(navText_->getCharHeight() * yScale);
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDNavigation.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDNavigation.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDNavigation.h	(revision 2122)
@@ -0,0 +1,80 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDNavigation_H__
+#define _HUDNavigation_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "overlays/OrxonoxOverlay.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HUDNavigation : public OrxonoxOverlay, public Tickable
+    {
+    public:
+        HUDNavigation(BaseObject* creator);
+        ~HUDNavigation();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+        virtual void tick(float dt);
+
+    private:
+        void sizeChanged();
+        void angleChanged() { }
+        void positionChanged() { }
+
+        // XMLPort accessors
+        void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); }
+        float getNavMarkerSize() const    { return this->navMarkerSize_; }
+
+        void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); }
+        float getAimMarkerSize() const    { return this->aimMarkerSize_; }
+
+        void setTextSize(float size);
+        float getTextSize() const;
+
+        void setFont(const std::string& font);
+        const std::string& getFont() const;
+
+        void updateMarker();
+        void updateFocus();
+        float getDist2Focus() const;
+
+        Ogre::PanelOverlayElement* navMarker_;      //!< the panel used to show the arrow and the target marker
+        float navMarkerSize_;                       //!< One paramter size of the navigation marker
+        Ogre::PanelOverlayElement* aimMarker_;      //!< Panel used to show the aim Marker
+        float aimMarkerSize_;                       //!< One paramter size of the aim marker
+        Ogre::TextAreaOverlayElement* navText_;     //!< Text overlay to display the target distance
+        bool wasOutOfView_;                         //!< Performance booster variable: setMaterial is not cheap
+    };
+}
+
+#endif /* _HUDNavigation_H__ */
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDRadar.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDRadar.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDRadar.cc	(revision 2122)
@@ -0,0 +1,156 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Yuning Chai
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDRadar.h"
+
+#include <OgreOverlayManager.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "util/String.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/Radar.h"
+#include "tools/TextureGenerator.h"
+
+namespace orxonox
+{
+    CreateFactory(HUDRadar);
+
+    HUDRadar::HUDRadar(BaseObject* creator)
+        : OrxonoxOverlay(creator)
+    {
+        RegisterObject(HUDRadar);
+
+        marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+            .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString()));
+        marker_->setMaterialName("Orxonox/RadarMarker");
+        overlay_->add2D(marker_);
+        marker_->hide();
+
+        setRadarSensitivity(1.0f);
+        setHalfDotSizeDistance(3000.0f);
+        setMaximumDotSize(0.1f);
+
+        shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
+        shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
+        shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
+    }
+
+    HUDRadar::~HUDRadar()
+    {
+        if (this->isInitialized())
+        {
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_);
+            for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
+                it != this->radarDots_.end(); ++it)
+            {
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it);
+            }
+        }
+    }
+
+    void HUDRadar::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(HUDRadar, XMLPort, xmlElement, mode);
+
+        XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode);
+        XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlElement, mode);
+        XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode);
+    }
+
+    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
+    {
+/*
+        const WorldEntity* wePointer = object->getWorldEntity();
+
+        // Just to be sure that we actually have a WorldEntity.
+        // We could do a dynamic_cast, but that would be a lot slower.
+        if (!wePointer)
+        {
+            CCOUT(4) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
+            return;
+        }
+*/
+        // try to find a panel already created
+        Ogre::PanelOverlayElement* panel;
+        //std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object);
+        if (itRadarDots_ == this->radarDots_.end())
+        {
+            // we have to create a new entry
+            panel = static_cast<Ogre::PanelOverlayElement*>(
+                Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString()));
+            radarDots_.push_back(panel);
+            // get right material
+            panel->setMaterialName(TextureGenerator::getMaterialName(
+                shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour()));
+            this->overlay_->add2D(panel);
+            this->itRadarDots_ = this->radarDots_.end();
+        }
+        else
+        {
+            panel = *itRadarDots_;
+            ++itRadarDots_;
+            std::string materialName = TextureGenerator::getMaterialName(
+                shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour());
+            if (materialName != panel->getMaterialName())
+                panel->setMaterialName(materialName);
+        }
+        panel->show();
+/*
+        // set size to fit distance...
+        float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
+        // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
+        float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance);
+        panel->setDimensions(size, size);
+
+        // calc position on radar...
+        Vector2 coord = get2DViewcoordinates(SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), wePointer->getWorldPosition());
+        coord *= Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture
+        panel->setPosition((1.0 + coord.x - size) * 0.5, (1.0 - coord.y - size) * 0.5);
+
+        if (bIsMarked)
+        {
+            this->marker_->show();
+            this->marker_->setDimensions(size * 1.5, size * 1.5);
+            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
+        }
+*/
+    }
+
+    void HUDRadar::radarTick(float dt)
+    {
+        for (itRadarDots_ = radarDots_.begin(); itRadarDots_ != radarDots_.end(); ++itRadarDots_)
+            (*itRadarDots_)->hide();
+        this->itRadarDots_ = this->radarDots_.begin();
+        this->marker_->hide();
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDRadar.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDRadar.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDRadar.h	(revision 2122)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Yuning Chai
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDRadar_H__
+#define _HUDRadar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <vector>
+#include <map>
+#include <OgrePrerequisites.h>
+#include "overlays/OrxonoxOverlay.h"
+#include "objects/RadarListener.h"
+#include "objects/RadarViewable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener
+    {
+    public:
+        HUDRadar(BaseObject* creator);
+        ~HUDRadar();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    private:
+        // XML accessors
+        float getHalfDotSizeDistance() const { return this->halfDotSizeDistance_; }
+        void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; }
+
+        float getMaximumDotSize() const { return this->maximumDotSize_; }
+        void setMaximumDotSize(float size) { this->maximumDotSize_ = size; }
+
+        float getRadarSensitivity() const { return this->sensitivity_; }
+        // used also by RadarListener interface!
+        void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; }
+
+        // RadarListener interface
+        void displayObject(RadarViewable* viewable, bool bIsMarked);
+        void radarTick(float dt);
+
+        std::map<RadarViewable::Shape, std::string> shapeMaterials_;
+
+        std::vector<Ogre::PanelOverlayElement*> radarDots_;
+        std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_;
+        Ogre::PanelOverlayElement* marker_;
+
+        float halfDotSizeDistance_;
+        float maximumDotSize_;
+
+        float sensitivity_;
+    };
+}
+
+#endif /* _HUDRadar_H__ */
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDSpeedBar.cc
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 2122)
@@ -0,0 +1,62 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Felix Schulthess
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDSpeedBar.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(HUDSpeedBar);
+
+    HUDSpeedBar::HUDSpeedBar(BaseObject* creator)
+        : HUDBar(creator)
+    {
+        RegisterObject(HUDSpeedBar);
+
+    }
+
+    HUDSpeedBar::~HUDSpeedBar()
+    {
+    }
+
+    void HUDSpeedBar::tick(float dt)
+    {
+/*
+        SpaceShip* ship = SpaceShip::getLocalShip();
+        if (ship)
+        {
+            float v = ship->getVelocity().length();
+            float value = v / ship->getMaxSpeed();
+            if (value != this->getValue())
+                this->setValue(value);
+        }
+*/
+    }
+}
Index: /code/branches/physics/src/orxonox/overlays/hud/HUDSpeedBar.h
===================================================================
--- /code/branches/physics/src/orxonox/overlays/hud/HUDSpeedBar.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/overlays/hud/HUDSpeedBar.h	(revision 2122)
@@ -0,0 +1,49 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Felix Schulthess
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDSpeedBar_H__
+#define _HUDSpeedBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDBar.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HUDSpeedBar : public HUDBar, public Tickable
+    {
+    public:
+        HUDSpeedBar(BaseObject* creator);
+        ~HUDSpeedBar();
+
+        virtual void tick(float dt);
+    };
+}
+#endif /* _HUDSpeedBar_H__ */
Index: /code/branches/physics/src/orxonox/tolua/tolua.pkg
===================================================================
--- /code/branches/physics/src/orxonox/tolua/tolua.pkg	(revision 2122)
+++ /code/branches/physics/src/orxonox/tolua/tolua.pkg	(revision 2122)
@@ -0,0 +1,1 @@
+$cfile "../../src/orxonox/gui/GUIManager.h"
Index: /code/branches/physics/src/orxonox/tools/BillboardSet.cc
===================================================================
--- /code/branches/physics/src/orxonox/tools/BillboardSet.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/BillboardSet.cc	(revision 2122)
@@ -0,0 +1,163 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BillboardSet.h"
+
+#include <sstream>
+#include <cassert>
+
+#include <OgreSceneManager.h>
+#include <OgreBillboard.h>
+
+#include "util/Convert.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    unsigned int BillboardSet::billboardSetCounter_s = 0;
+
+    BillboardSet::BillboardSet()
+    {
+        this->billboardSet_ = 0;
+    }
+
+    BillboardSet::~BillboardSet()
+    {
+        this->destroyBillboardSet();
+    }
+
+    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count)
+    {
+        this->setBillboardSet(scenemanager, file, Vector3::ZERO, count);
+    }
+
+    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count)
+    {
+        this->setBillboardSet(scenemanager, file, colour, Vector3::ZERO, count);
+    }
+
+    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count)
+    {
+        assert(scenemanager);
+        this->destroyBillboardSet();
+
+        try
+        {
+            this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
+            this->billboardSet_->createBillboard(position);
+            this->billboardSet_->setMaterialName(file);
+        }
+        catch (...)
+        {
+            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
+        }
+
+        this->scenemanager_ = scenemanager;
+    }
+
+    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count)
+    {
+        assert(scenemanager);
+        this->destroyBillboardSet();
+
+        try
+        {
+            this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
+            this->billboardSet_->createBillboard(position, colour);
+            this->billboardSet_->setMaterialName(file);
+        }
+        catch (...)
+        {
+            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
+        }
+
+        this->scenemanager_ = scenemanager;
+    }
+
+    void BillboardSet::destroyBillboardSet()
+    {
+        if (this->billboardSet_ && this->scenemanager_)
+            this->scenemanager_->destroyBillboardSet(this->billboardSet_);
+    }
+
+    const std::string& BillboardSet::getName() const
+    {
+        if (this->billboardSet_)
+            return this->billboardSet_->getName();
+        else
+            return BLANKSTRING;
+    }
+
+    void BillboardSet::setVisible(bool visible)
+    {
+        if (this->billboardSet_)
+            this->billboardSet_->setVisible(visible);
+    }
+
+    bool BillboardSet::getVisible() const
+    {
+        if (this->billboardSet_)
+            return this->billboardSet_->getVisible();
+        else
+            return false;
+    }
+
+    void BillboardSet::setColour(const ColourValue& colour)
+    {
+        if (this->billboardSet_)
+        {
+            for (int i = 0; i < this->billboardSet_->getNumBillboards(); ++i)
+                this->billboardSet_->getBillboard(i)->setColour(colour);
+        }
+    }
+
+    const ColourValue& BillboardSet::getColour() const
+    {
+        if (this->billboardSet_ && this->billboardSet_->getNumBillboards() > 0)
+        {
+            return this->billboardSet_->getBillboard(0)->getColour();
+        }
+        else
+            return ColourValue::White;
+    }
+
+    void BillboardSet::setMaterial(const std::string& material)
+    {
+        if (this->billboardSet_)
+            this->billboardSet_->setMaterialName(material);
+    }
+
+    const std::string& BillboardSet::getMaterial() const
+    {
+        if (this->billboardSet_)
+            return this->billboardSet_->getMaterialName();
+        else
+            return BLANKSTRING;
+    }
+}
Index: /code/branches/physics/src/orxonox/tools/BillboardSet.h
===================================================================
--- /code/branches/physics/src/orxonox/tools/BillboardSet.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/BillboardSet.h	(revision 2122)
@@ -0,0 +1,75 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _BillboardSet_H__
+#define _BillboardSet_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgreBillboardSet.h>
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BillboardSet
+    {
+        public:
+            BillboardSet();
+            ~BillboardSet();
+
+            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count = 1);
+            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count = 1);
+            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count = 1);
+            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1);
+
+            inline Ogre::BillboardSet* getBillboardSet()
+                { return this->billboardSet_; }
+
+            const std::string& getName() const;
+
+            void setVisible(bool visible);
+            bool getVisible() const;
+
+            void setColour(const ColourValue& colour);
+            const ColourValue& getColour() const;
+
+            void setMaterial(const std::string& material);
+            const std::string& getMaterial() const;
+
+        private:
+            void destroyBillboardSet();
+
+            static unsigned int billboardSetCounter_s;
+            Ogre::BillboardSet* billboardSet_;
+            Ogre::SceneManager* scenemanager_;
+    };
+}
+
+#endif /* _BillboardSet_H__ */
Index: /code/branches/physics/src/orxonox/tools/Mesh.cc
===================================================================
--- /code/branches/physics/src/orxonox/tools/Mesh.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/Mesh.cc	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Mesh.h"
+
+#include <sstream>
+#include <OgreSceneManager.h>
+#include <cassert>
+
+#include "core/Core.h"
+#include "util/Convert.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    unsigned int Mesh::meshCounter_s = 0;
+
+    Mesh::Mesh()
+    {
+        this->entity_ = 0;
+        this->bCastShadows_ = true;
+    }
+
+    Mesh::~Mesh()
+    {
+        if (this->entity_ && this->scenemanager_)
+            this->scenemanager_->destroyEntity(this->entity_);
+    }
+
+    void Mesh::setMeshSource(Ogre::SceneManager* scenemanager, const std::string& meshsource)
+    {
+        assert(scenemanager);
+
+        this->scenemanager_ = scenemanager;
+
+        if (this->entity_)
+            this->scenemanager_->destroyEntity(this->entity_);
+
+        if (Core::showsGraphics())
+        {
+            try
+            {
+                this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
+                this->entity_->setCastShadows(this->bCastShadows_);
+            }
+            catch (...)
+            {
+                COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
+            }
+        }
+    }
+
+    void Mesh::setCastShadows(bool bCastShadows)
+    {
+        this->bCastShadows_ = bCastShadows;
+        if (this->entity_)
+            this->entity_->setCastShadows(this->bCastShadows_);
+    }
+
+    const std::string& Mesh::getName() const
+    {
+        if (this->entity_)
+            return this->entity_->getName();
+        else
+            return BLANKSTRING;
+    }
+
+    void Mesh::setVisible(bool bVisible)
+    {
+        if (this->entity_)
+            this->entity_->setVisible(bVisible);
+    }
+
+    bool Mesh::isVisible() const
+    {
+        if (this->entity_)
+            return this->entity_->getVisible();
+        else
+            return false;
+    }
+}
Index: /code/branches/physics/src/orxonox/tools/Mesh.h
===================================================================
--- /code/branches/physics/src/orxonox/tools/Mesh.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/Mesh.h	(revision 2122)
@@ -0,0 +1,67 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Mesh_H__
+#define _Mesh_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgreEntity.h>
+
+namespace orxonox
+{
+    class _OrxonoxExport Mesh
+    {
+        public:
+            Mesh();
+            ~Mesh();
+
+            void setMeshSource(Ogre::SceneManager* scenemanager, const std::string& file);
+
+            inline Ogre::Entity* getEntity()
+                { return this->entity_; }
+
+            const std::string& getName() const;
+
+            void setVisible(bool bVisible);
+            bool isVisible() const;
+
+            void setCastShadows(bool bCastShadows);
+            inline bool getCastShadows() const
+                { return this->bCastShadows_; }
+
+        private:
+            static unsigned int meshCounter_s;
+            Ogre::Entity* entity_;
+            bool bCastShadows_;
+            Ogre::SceneManager* scenemanager_;
+    };
+}
+
+#endif /* _Mesh_H__ */
Index: /code/branches/physics/src/orxonox/tools/ParticleInterface.cc
===================================================================
--- /code/branches/physics/src/orxonox/tools/ParticleInterface.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/ParticleInterface.cc	(revision 2122)
@@ -0,0 +1,209 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+* @file ParticleInterface.cc
+* @brief class to control praticle effects
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "ParticleInterface.h"
+
+#include <OgreParticleSystem.h>
+#include <OgreParticleEmitter.h>
+#include <OgreSceneManager.h>
+#include <cassert>
+
+#include "GraphicsEngine.h"
+#include "core/CoreIncludes.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    unsigned int ParticleInterface::counter_s = 0;
+    ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
+
+    ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
+    {
+        RegisterRootObject(ParticleInterface);
+
+        assert(scenemanager);
+
+        this->scenemanager_ = scenemanager;
+        this->sceneNode_ = 0;
+
+        this->bEnabled_ = true;
+        this->bVisible_ = true;
+        this->bAllowedByLOD_ = true;
+
+        this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
+        this->particleSystem_->setSpeedFactor(1.0f);
+        //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
+
+        this->setDetailLevel((unsigned int)detaillevel);
+    }
+
+    ParticleInterface::~ParticleInterface()
+    {
+        this->particleSystem_->removeAllEmitters();
+        this->detachFromSceneNode();
+        this->scenemanager_->destroyParticleSystem(particleSystem_);
+    }
+
+    void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)
+    {
+        if (this->sceneNode_)
+            this->detachFromSceneNode();
+
+        this->sceneNode_ = sceneNode;
+        this->sceneNode_->attachObject(this->particleSystem_);
+    }
+
+    void ParticleInterface::detachFromSceneNode()
+    {
+        if (this->sceneNode_)
+        {
+            this->sceneNode_->detachObject(this->particleSystem_);
+            this->sceneNode_ = 0;
+        }
+    }
+
+    Ogre::ParticleEmitter* ParticleInterface::createNewEmitter()
+    {
+        if (this->particleSystem_->getNumEmitters() > 0)
+        {
+            Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType());
+            this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter);
+            return newemitter;
+        }
+        else
+            return 0;
+    }
+    Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const
+    {
+        if (emitterNr < this->particleSystem_->getNumEmitters())
+            return this->particleSystem_->getEmitter(emitterNr);
+        else
+            return 0;
+    }
+    void ParticleInterface::removeEmitter(unsigned int emitterNr)
+    {
+        if (emitterNr < this->particleSystem_->getNumEmitters())
+            this->particleSystem_->removeEmitter(emitterNr);
+    }
+    void ParticleInterface::removeAllEmitters()
+    {
+        this->particleSystem_->removeAllEmitters();
+    }
+    unsigned int ParticleInterface::getNumEmitters() const
+    {
+        return this->particleSystem_->getNumEmitters();
+    }
+
+    Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name)
+    {
+        return this->particleSystem_->addAffector(name);
+    }
+    Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const
+    {
+        if (affectorNr < this->particleSystem_->getNumAffectors())
+            return this->particleSystem_->getAffector(affectorNr);
+        else
+            return 0;
+    }
+    void ParticleInterface::removeAffector(unsigned int affectorNr)
+    {
+        if (affectorNr < this->particleSystem_->getNumAffectors())
+            this->particleSystem_->removeAffector(affectorNr);
+    }
+    void ParticleInterface::removeAllAffectors()
+    {
+        this->particleSystem_->removeAllAffectors();
+    }
+    unsigned int ParticleInterface::getNumAffectors() const
+    {
+        return this->particleSystem_->getNumAffectors();
+    }
+
+    void ParticleInterface::setEnabled(bool enable)
+    {
+        this->bEnabled_ = enable;
+
+        for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
+            this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_);
+    }
+
+    void ParticleInterface::setVisible(bool visible)
+    {
+        this->bVisible_ = visible;
+
+        this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_);
+    }
+
+    void ParticleInterface::setDetailLevel(unsigned int level)
+    {
+        this->detaillevel_ = level;
+        this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle());
+    }
+
+    void ParticleInterface::detailLevelChanged(unsigned int newlevel)
+    {
+        if (newlevel >= (unsigned int)this->detaillevel_)
+            this->bAllowedByLOD_ = true;
+        else
+            this->bAllowedByLOD_ = false;
+
+        this->updateVisibility();
+    }
+
+    void ParticleInterface::updateVisibility()
+    {
+        this->setEnabled(this->isEnabled());
+        this->setVisible(this->isVisible());
+    }
+
+    void ParticleInterface::setSpeedFactor(float factor)
+    {
+        //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
+        this->particleSystem_->setSpeedFactor(1.0f * factor);
+    }
+    float ParticleInterface::getSpeedFactor() const
+    {
+        //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
+        return (this->particleSystem_->getSpeedFactor() / 1.0f);
+    }
+
+    bool ParticleInterface::getKeepParticlesInLocalSpace() const
+    {
+        return this->particleSystem_->getKeepParticlesInLocalSpace();
+    }
+    void ParticleInterface::setKeepParticlesInLocalSpace(bool keep)
+    {
+        this->particleSystem_->setKeepParticlesInLocalSpace(keep);
+    }
+}
Index: /code/branches/physics/src/orxonox/tools/ParticleInterface.h
===================================================================
--- /code/branches/physics/src/orxonox/tools/ParticleInterface.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/ParticleInterface.h	(revision 2122)
@@ -0,0 +1,108 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleInterface_H__
+#define _ParticleInterface_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgreParticleEmitter.h>
+
+#include "core/OrxonoxClass.h"
+#include "util/Math.h"
+
+#define getAllEmitters() \
+  storeThisAsCurrentParticleInterface(); \
+  for (unsigned int i = 0; i < ParticleInterface::getCurrentParticleInterface()->getNumEmitters(); ++i) \
+    ParticleInterface::getCurrentParticleInterface()->getEmitter(i)
+
+namespace orxonox
+{
+    class _OrxonoxExport ParticleInterface : public OrxonoxClass
+    {
+        public:
+            ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel);
+            virtual ~ParticleInterface();
+
+            inline Ogre::ParticleSystem* getParticleSystem() const
+                { return this->particleSystem_; }
+
+            void addToSceneNode(Ogre::SceneNode* sceneNode);
+            void detachFromSceneNode();
+
+            Ogre::ParticleEmitter* createNewEmitter();
+            Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const;
+            void removeEmitter(unsigned int emitterNr);
+            void removeAllEmitters();
+            unsigned int getNumEmitters() const;
+
+            Ogre::ParticleAffector* addAffector(const std::string& name);
+            Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const;
+            void removeAffector(unsigned int affectorNr);
+            void removeAllAffectors();
+            unsigned int getNumAffectors() const;
+
+            float getSpeedFactor() const;
+            void setSpeedFactor(float factor);
+            bool getKeepParticlesInLocalSpace() const;
+            void setKeepParticlesInLocalSpace(bool keep);
+
+            void setEnabled(bool enable);
+            inline bool isEnabled() const
+                { return this->bEnabled_; }
+
+            void setVisible(bool visible);
+            inline bool isVisible() const
+                { return this->bVisible_; }
+
+            void detailLevelChanged(unsigned int newlevel);
+            void setDetailLevel(unsigned int level);
+
+            inline void storeThisAsCurrentParticleInterface()
+                { ParticleInterface::currentParticleInterface_s = this; }
+            inline static ParticleInterface* getCurrentParticleInterface()
+                { return ParticleInterface::currentParticleInterface_s; }
+
+        private:
+            void updateVisibility();
+
+            static ParticleInterface* currentParticleInterface_s;
+            static unsigned int       counter_s;
+
+            Ogre::SceneNode*          sceneNode_;
+            Ogre::ParticleSystem*     particleSystem_;
+            bool                      bVisible_;
+            bool                      bEnabled_;
+            bool                      bAllowedByLOD_;
+            unsigned int              detaillevel_;     //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
+            Ogre::SceneManager*       scenemanager_;
+    };
+}
+
+#endif /* _ParticleInterface_H__ */
Index: /code/branches/physics/src/orxonox/tools/TextureGenerator.cc
===================================================================
--- /code/branches/physics/src/orxonox/tools/TextureGenerator.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/TextureGenerator.cc	(revision 2122)
@@ -0,0 +1,86 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the TextureGenerator.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "TextureGenerator.h"
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+#include "util/Convert.h"
+
+namespace std
+{
+    template <>
+    bool less<orxonox::ColourValue>::operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
+    {
+        if (__x.r == __y.r)
+        {
+            if (__x.g == __y.g)
+            {
+                if (__x.b == __y.b)
+                {
+                    return __x.a < __y.a;
+                }
+                return __x.b < __y.b;
+            }
+            return __x.g < __y.g;
+        }
+        return __x.r < __y.r;
+    }
+}
+
+namespace orxonox
+{
+    std::map<std::string, std::map<ColourValue, std::string> > TextureGenerator::materials_s;
+    unsigned int TextureGenerator::materialCount_s = 0;
+
+    /*static*/ const std::string& TextureGenerator::getMaterialName(std::string textureName, const ColourValue& colour)
+    {
+        std::map<ColourValue, std::string>& colourMap = materials_s[textureName];
+        std::map<ColourValue, std::string>::const_iterator it = colourMap.find(colour);
+
+        if (it == colourMap.end())
+        {
+            std::string materialName = textureName + "_Material_" + convertToString(materialCount_s++);
+            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialName, "General");
+            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+            Ogre::TextureUnitState* textureUnitState = material->getTechnique(0)->getPass(0)->createTextureUnitState();
+            textureUnitState->setTextureName(textureName);
+            textureUnitState->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour);
+            return (colourMap[colour] = materialName);
+        }
+        else
+        {
+            return (*it).second;
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/tools/TextureGenerator.h
===================================================================
--- /code/branches/physics/src/orxonox/tools/TextureGenerator.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/TextureGenerator.h	(revision 2122)
@@ -0,0 +1,59 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+/**
+    @file
+    @brief
+*/
+
+#ifndef _TextureGenerator_H__
+#define _TextureGenerator_H__
+
+#include "OrxonoxPrereqs.h"
+#include <string>
+#include <map>
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport TextureGenerator
+    {
+    public:
+        static const std::string& getMaterialName(std::string textureName, const ColourValue& colour);
+
+    private:
+        TextureGenerator();
+        TextureGenerator(const TextureGenerator&);
+        ~TextureGenerator();
+
+        static std::map<std::string, std::map<ColourValue, std::string> > materials_s;
+        static unsigned int materialCount_s;
+    };
+}
+
+#endif /* _TextureGenerator_H__ */
Index: /code/branches/physics/src/orxonox/tools/Timer.cc
===================================================================
--- /code/branches/physics/src/orxonox/tools/Timer.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/Timer.cc	(revision 2122)
@@ -0,0 +1,161 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <set>
+
+#include "OrxonoxStableHeaders.h"
+#include "Timer.h"
+
+#include "core/Executor.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandExecutor.h"
+#include "core/Clock.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutExtern(delay);
+    SetConsoleCommandShortcutExtern(killdelays);
+
+    static std::set<StaticTimer*> delaytimerset;
+
+    /**
+        @brief Calls a console command after 'delay' seconds.
+        @param delay The delay in seconds
+        @param command The console command
+    */
+    void delay(float delay, const std::string& command)
+    {
+        StaticTimer *delaytimer = new StaticTimer();
+        delaytimerset.insert(delaytimer);
+
+        ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
+        delayexecutor->setDefaultValues(delaytimer, command);
+        delaytimer->setTimer(delay, false, delayexecutor);
+    }
+
+    /**
+        @brief Executes the command.
+        @param timer The timer to destroy after the command-execution
+        @param command The command to execute
+    */
+    void executeDelayedCommand(StaticTimer* timer, const std::string& command)
+    {
+        CommandExecutor::execute(command);
+        delete timer;
+        delaytimerset.erase(timer);
+    }
+
+    /**
+        @brief Kills all delayed commands.
+    */
+    void killdelays()
+    {
+        for (std::set<StaticTimer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
+            delete (*it);
+
+        delaytimerset.clear();
+    }
+
+    /**
+        @brief Constructor: Sets the default-values.
+    */
+    TimerBase::TimerBase()
+    {
+        this->executor_ = 0;
+        this->interval_ = 0;
+        this->bLoop_ = false;
+        this->bActive_ = false;
+        this->bKillAfterCall_ = false;
+
+        this->time_ = 0;
+
+        RegisterRootObject(TimerBase);
+    }
+
+    /**
+        @brief Deletes the executor.
+    */
+    TimerBase::~TimerBase()
+    {
+        this->deleteExecutor();
+    }
+
+    /**
+        @brief Executes the executor.
+    */
+    void TimerBase::run() const
+    {
+        bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer
+
+        (*this->executor_)();
+
+        if (temp)
+            delete this;
+    }
+
+    /**
+        @brief Deletes the executor.
+    */
+    void TimerBase::deleteExecutor()
+    {
+      if (this->executor_)
+          delete this->executor_;
+    }
+
+    /**
+        @brief Updates the timer before the frames are rendered.
+    */
+    void TimerBase::tick(const Clock& time)
+    {
+        if (this->bActive_)
+        {
+            // If active: Decrease the timer by the duration of the last frame
+            this->time_ -= time.getDeltaTimeMicroseconds();
+
+            if (this->time_ <= 0)
+            {
+                // It's time to call the function
+                if (this->bLoop_ && !this->bKillAfterCall_)
+                {
+                    this->time_ += this->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
+                    while (this->time_ <= 0)
+                    {
+                        // The interval was shorter than one tick, so execute the function more than once
+                        this->run();
+                        this->time_ += this->interval_;
+                    }
+                }
+                else
+                    this->stopTimer(); // Stop the timer if we don't want to loop
+
+                this->run();
+            }
+        }
+    }
+}
Index: /code/branches/physics/src/orxonox/tools/Timer.h
===================================================================
--- /code/branches/physics/src/orxonox/tools/Timer.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/Timer.h	(revision 2122)
@@ -0,0 +1,209 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*!
+    @file Timer.h
+    @brief Definition and Implementation of the Timer class.
+
+    The Timer is a callback-object, calling a given function after a given time-interval.
+
+    Usage:
+    header.h:
+        class ClassName
+        {
+            public:
+                ClassName();
+                void functionName();
+                Timer<ClassName> myTimer;
+        };
+
+    source.cc:
+        include "core/Executor.h"
+
+        ClassName::ClassName()
+        {
+            myTimer.setTimer(interval_in_seconds, bLoop, this, createExecutor(createFunctor(&ClassName::functionName)));
+        }
+
+        void ClassName::functionName()
+        {
+            whateveryouwant();
+            something(else);
+        }
+*/
+
+#ifndef _Timer_H__
+#define _Timer_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class StaticTimer;
+    void delay(float delay, const std::string& command);
+    void killdelays();
+    void executeDelayedCommand(StaticTimer* timer, const std::string& command);
+
+    //! TimerBase is the parent of the Timer class.
+    class _OrxonoxExport TimerBase : public OrxonoxClass
+    {
+        public:
+            ~TimerBase();
+
+            void run() const;
+            void deleteExecutor();
+
+            /** @brief Starts the Timer: Function-call after 'interval' seconds. */
+            inline void startTimer()
+                { this->bActive_ = true; this->time_ = this->interval_; }
+            /** @brief Stops the Timer. */
+            inline void stopTimer()
+                { this->bActive_ = false; this->time_ = this->interval_; }
+            /** @brief Pauses the Timer - it will continue with the actual state if you unpause it. */
+            inline void pauseTimer()
+                { this->bActive_ = false; }
+            /** @brief Unpauses the Timer - continues with the given state. */
+            inline void unpauseTimer()
+                { this->bActive_ = true; }
+            /** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */
+            inline bool isActive() const
+                { return this->bActive_; }
+            /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */
+            inline float getRemainingTime() const
+                { return (float)this->time_ / 1000000.0f; }
+            /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */
+            inline void addTime(float time)
+                { if (time > 0.0f) this->time_ += (long long)(time * 1000000.0f); }
+            /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */
+            inline void removeTime(float time)
+                { if (time > 0.0f) this->time_ -= (long long)(time * 1000000.0f); }
+            /** @brief Sets the interval of the Timer. @param interval The interval */
+            inline void setInterval(float interval)
+                { this->interval_ = (long long)(interval * 1000000.0f); }
+            /** @brief Sets bLoop to a given value. @param bLoop True = loop */
+            inline void setLoop(bool bLoop)
+                { this->bLoop_ = bLoop; }
+
+            void tick(const Clock& time);
+
+        protected:
+            TimerBase();
+
+            Executor* executor_;  //!< The executor of the function that should be called when the time expires
+
+            long long interval_;  //!< The time-interval in micro seconds
+            bool bLoop_;          //!< If true, the function gets called every 'interval' seconds
+            bool bActive_;        //!< If true, the Timer ticks and calls the function if the time's up
+            bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function
+
+            long long time_;      //!< Internal variable, counting the time till the next function-call
+    };
+
+    //! The Timer is a callback-object, calling a given function after a given time-interval.
+    template <class T = BaseObject>
+    class Timer : public TimerBase
+    {
+        public:
+            Timer() {}
+
+            /**
+                @brief Constructor: Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param object The object owning the timer and the function
+                @param exeuctor A executor of the function to call
+            */
+            Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor, bool bKillAfterCall = false)
+            {
+                this->setTimer(interval, bLoop, object, exeuctor, bKillAfterCall);
+            }
+
+            /**
+                @brief Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param object The object owning the timer and the function
+                @param exeuctor A executor of the function to call
+            */
+            void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor, bool bKillAfterCall = false)
+            {
+                this->deleteExecutor();
+
+                this->setInterval(interval);
+                this->bLoop_ = bLoop;
+                executor->setObject(object);
+                this->executor_ = (Executor*)executor;
+                this->bActive_ = true;
+
+                this->time_ = this->interval_;
+                this->bKillAfterCall_ = bKillAfterCall;
+            }
+    };
+
+    //! The StaticTimer is a callback-object, calling a static function after a given time-interval.
+    class StaticTimer : public TimerBase
+    {
+        public:
+            StaticTimer() {}
+
+            /**
+                @brief Constructor: Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param exeuctor A executor of the function to call
+            */
+            StaticTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
+            {
+                this->setTimer(interval, bLoop, executor, bKillAfterCall);
+            }
+
+            /**
+                @brief Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param object The object owning the timer and the function
+                @param executor A executor of the function to call
+            */
+            void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
+            {
+                this->deleteExecutor();
+
+                this->setInterval(interval);
+                this->bLoop_ = bLoop;
+                this->executor_ = (Executor*)executor;
+                this->bActive_ = true;
+
+                this->time_ = this->interval_;
+                this->bKillAfterCall_ = bKillAfterCall;
+            }
+    };
+
+}
+
+#endif /* _Timer_H__ */
Index: /code/branches/physics/src/orxonox/tools/WindowEventListener.cc
===================================================================
--- /code/branches/physics/src/orxonox/tools/WindowEventListener.cc	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/WindowEventListener.cc	(revision 2122)
@@ -0,0 +1,42 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "WindowEventListener.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor for the WindowEventListener.
+    */
+    WindowEventListener::WindowEventListener()
+    {
+        RegisterRootObject(WindowEventListener);
+    }
+}
Index: /code/branches/physics/src/orxonox/tools/WindowEventListener.h
===================================================================
--- /code/branches/physics/src/orxonox/tools/WindowEventListener.h	(revision 2122)
+++ /code/branches/physics/src/orxonox/tools/WindowEventListener.h	(revision 2122)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _WindowEventListener_H__
+#define _WindowEventListener_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+
+namespace orxonox
+{
+    /**
+        @brief Interface for receiving window events.
+    */
+    class _OrxonoxExport WindowEventListener : virtual public OrxonoxClass
+    {
+    public:
+        WindowEventListener();
+        virtual ~WindowEventListener() { }
+
+            /** Window has moved position */
+            virtual void windowMoved() { }
+
+            /** Window has resized */
+            virtual void windowResized(int newWidth, int newHeight) { }
+
+            /** Window has lost/gained focus */
+            virtual void windowFocusChanged() { }
+    };
+}
+
+#endif /* _WindowEventListener_H__ */
Index: /code/branches/physics/src/tinyxml/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/tinyxml/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/tinyxml/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,9 @@
+SET( TINYXML_SRC_FILES
+  ticpp.cc
+  tinystr.cc
+  tinyxml.cc
+  tinyxmlerror.cc
+  tinyxmlparser.cc
+)
+
+ADD_LIBRARY(tinyxml_orxonox SHARED ${TINYXML_SRC_FILES})
Index: /code/branches/physics/src/tinyxml/ticpp.cc
===================================================================
--- /code/branches/physics/src/tinyxml/ticpp.cc	(revision 2122)
+++ /code/branches/physics/src/tinyxml/ticpp.cc	(revision 2122)
@@ -0,0 +1,1139 @@
+#define TIXML_USE_TICPP
+
+/*
+http://code.google.com/p/ticpp/
+Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/*
+Modifications by the orxonox team:
+In function: void Document::Parse( const std::string& xml, bool throwIfParseError, TiXmlEncoding encoding )
+     change: Added row and column number to the error description.
+     author: Reto Grieder
+*/
+
+#ifdef TIXML_USE_TICPP
+
+#include "ticpp.h"
+#include "ticpprc.h"
+#include "tinyxml.h"
+#include <sstream>
+
+using namespace ticpp;
+
+// In the following Visitor functions, casting away const should be safe, as the object can only be referred to by a const &
+bool Visitor::VisitEnter( const TiXmlDocument& doc )
+{
+	return VisitEnter( Document( const_cast< TiXmlDocument* >( &doc ) ) );
+}
+
+bool Visitor::VisitExit( const TiXmlDocument& doc )
+{
+	return VisitEnter( Document( const_cast< TiXmlDocument* >( &doc ) ) );
+}
+
+bool Visitor::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
+{
+	if ( 0 != firstAttribute )
+	{
+		Attribute attribute( const_cast< TiXmlAttribute* >( firstAttribute ) );
+		return VisitEnter( Element( const_cast< TiXmlElement* >( &element ) ), &attribute );
+	}
+	else
+	{
+		return VisitEnter( Element( const_cast< TiXmlElement* >( &element ) ), 0 );
+	}
+}
+
+bool Visitor::VisitExit( const TiXmlElement& element )
+{
+	return VisitExit( Element( const_cast< TiXmlElement* >( &element ) ) );
+}
+
+bool Visitor::Visit( const TiXmlDeclaration& declaration )
+{
+	return Visit( Declaration( const_cast< TiXmlDeclaration* >( &declaration ) ) );
+}
+
+bool Visitor::Visit( const TiXmlStylesheetReference& stylesheet )
+{
+	return Visit( StylesheetReference( const_cast< TiXmlStylesheetReference* >( &stylesheet ) ) );
+}
+
+bool Visitor::Visit( const TiXmlText& text )
+{
+	return Visit( Text( const_cast< TiXmlText* >( &text ) ) );
+}
+
+bool Visitor::Visit( const TiXmlComment& comment )
+{
+	return Visit( Comment( const_cast< TiXmlComment* >( &comment ) ) );
+}
+
+Attribute::Attribute()
+{
+	SetTiXmlPointer( new TiXmlAttribute() );
+	m_impRC->InitRef();
+}
+
+Attribute::Attribute( TiXmlAttribute* attribute )
+{
+	SetTiXmlPointer( attribute );
+	m_impRC->IncRef();
+}
+
+Attribute::Attribute( const std::string& name, const std::string& value )
+{
+	SetTiXmlPointer( new TiXmlAttribute( name, value ) );
+	m_impRC->InitRef();
+}
+
+void Attribute::operator=( const Attribute& copy )
+{
+	// Dropping the reference to the old object
+	this->m_impRC->DecRef();
+
+	// Pointing to the new Object
+	SetTiXmlPointer( copy.m_tiXmlPointer );
+
+	// The internal tixml pointer changed in the above line
+	this->m_impRC->IncRef();
+}
+
+Attribute::Attribute( const Attribute& copy ) : Base()
+{
+	// Dropping the reference to the old object
+	this->m_impRC->DecRef();
+
+	// Pointing to the new Object
+	SetTiXmlPointer( copy.m_tiXmlPointer );
+
+	// The internal tixml pointer changed in the above line
+	this->m_impRC->IncRef();
+}
+
+Attribute::~Attribute()
+{
+	m_impRC->DecRef();
+}
+
+std::string Attribute::Value() const
+{
+	ValidatePointer();
+	return m_tiXmlPointer->ValueStr();
+}
+
+std::string Attribute::Name() const
+{
+	ValidatePointer();
+	return m_tiXmlPointer->Name();
+}
+
+Attribute* Attribute::Next( bool throwIfNoAttribute ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->Next();
+	if ( 0 == attribute )
+	{
+		if ( throwIfNoAttribute )
+		{
+			TICPPTHROW( "No more attributes found" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Attribute* Attribute::Previous( bool throwIfNoAttribute ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->Previous();
+	if ( 0 == attribute )
+	{
+		if ( throwIfNoAttribute )
+		{
+			TICPPTHROW( "No more attributes found" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+void Attribute::IterateNext( const std::string&, Attribute** next ) const
+{
+	*next = Next( false );
+}
+
+void Attribute::IteratePrevious( const std::string&, Attribute** previous ) const
+{
+	*previous = Previous( false );
+}
+
+void Attribute::Print( FILE* file, int depth ) const
+{
+	ValidatePointer();
+	m_tiXmlPointer->Print( file, depth );
+}
+
+void Attribute::SetTiXmlPointer( TiXmlAttribute* newPointer )
+{
+	m_tiXmlPointer = newPointer;
+	SetImpRC( newPointer );
+}
+
+//*****************************************************************************
+
+Node* Node::NodeFactory( TiXmlNode* tiXmlNode, bool throwIfNull, bool rememberSpawnedWrapper ) const
+{
+	if ( 0 == tiXmlNode )
+	{
+		if ( throwIfNull )
+		{
+			TICPPTHROW( "tiXmlNode is NULL" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Node* temp;
+	switch ( tiXmlNode->Type() )
+	{
+		case TiXmlNode::DOCUMENT:
+			temp = new Document( tiXmlNode->ToDocument() );
+			break;
+
+		case TiXmlNode::ELEMENT:
+			temp = new Element( tiXmlNode->ToElement() );
+			break;
+
+		case TiXmlNode::COMMENT:
+			temp = new Comment( tiXmlNode->ToComment() );
+			break;
+
+		case TiXmlNode::TEXT:
+			temp = new Text( tiXmlNode->ToText() );
+			break;
+
+		case TiXmlNode::DECLARATION:
+			temp = new Declaration( tiXmlNode->ToDeclaration() );
+			break;
+
+		case TiXmlNode::STYLESHEETREFERENCE:
+			temp = new StylesheetReference( tiXmlNode->ToStylesheetReference() );
+			break;
+
+		default:
+			TICPPTHROW( "Type is unsupported" )
+	}
+
+	if ( rememberSpawnedWrapper )
+	{
+		m_spawnedWrappers.push_back( temp );
+	}
+	return temp;
+}
+
+
+std::string Node::Value() const
+{
+	return GetTiXmlPointer()->ValueStr();
+}
+
+void Node::Clear()
+{
+	GetTiXmlPointer()->Clear();
+}
+
+Node* Node::Parent( bool throwIfNoParent ) const
+{
+	TiXmlNode* parent = GetTiXmlPointer()->Parent();
+	if ( ( 0 == parent ) && throwIfNoParent )
+	{
+		TICPPTHROW( "No parent exists" );
+	}
+
+	return NodeFactory( parent, false );
+}
+
+Node* Node::FirstChild( bool throwIfNoChildren ) const
+{
+	return FirstChild( "", throwIfNoChildren );
+}
+
+Node* Node::FirstChild( const std::string& value, bool throwIfNoChildren ) const
+{
+	return FirstChild( value.c_str(), throwIfNoChildren );
+}
+
+Node* Node::FirstChild( const char* value, bool throwIfNoChildren ) const
+{
+	TiXmlNode* childNode;
+	if ( 0 == strlen( value ) )
+	{
+		childNode = GetTiXmlPointer()->FirstChild();
+	}
+	else
+	{
+		childNode = GetTiXmlPointer()->FirstChild( value );
+	}
+
+	if ( ( 0 == childNode ) && throwIfNoChildren )
+	{
+		TICPPTHROW( "Child with the value of \"" << value << "\" not found" );
+	}
+
+	return NodeFactory( childNode, false );
+}
+
+Node* Node::LastChild( bool throwIfNoChildren ) const
+{
+	return LastChild( "", throwIfNoChildren );
+}
+
+Node* Node::LastChild( const std::string& value, bool throwIfNoChildren ) const
+{
+	return LastChild( value.c_str(), throwIfNoChildren );
+}
+
+Node* Node::LastChild( const char* value, bool throwIfNoChildren ) const
+{
+	TiXmlNode* childNode;
+	if ( 0 == strlen( value ) )
+	{
+		childNode = GetTiXmlPointer()->LastChild();
+	}
+	else
+	{
+		childNode = GetTiXmlPointer()->LastChild( value );
+	}
+
+	if ( ( 0 == childNode ) && throwIfNoChildren )
+	{
+		TICPPTHROW( "Child with the value of \"" << value << "\" not found" );
+	}
+
+	return NodeFactory( childNode, false );
+}
+
+Node* Node::IterateChildren ( Node* previous ) const
+{
+	TiXmlNode* pointer;
+	if ( 0 == previous )
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( 0 );
+	}
+	else
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( previous->GetTiXmlPointer() );
+	}
+
+	return NodeFactory( pointer, false );
+}
+
+Node* Node::IterateChildren( const std::string& value, Node* previous ) const
+{
+	TiXmlNode* pointer;
+	if ( 0 == previous )
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( value, 0 );
+	}
+	else
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( value, previous->GetTiXmlPointer() );
+	}
+
+	return NodeFactory( pointer, false );
+}
+
+Node* Node::InsertEndChild( Node& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	addThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->InsertEndChild( *addThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+Node* Node::LinkEndChild( Node* childNode )
+{
+	if ( childNode->Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be linked" );
+	}
+
+	// Increment reference count when adding to the tree
+	childNode->m_impRC->IncRef();
+
+	if ( 0 == GetTiXmlPointer()->LinkEndChild( childNode->GetTiXmlPointer() ) )
+	{
+		TICPPTHROW( "Node can't be linked" );
+	}
+
+	return childNode;
+}
+
+Node* Node::InsertBeforeChild( Node* beforeThis, Node& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	addThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->InsertBeforeChild( beforeThis->GetTiXmlPointer(), *addThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+Node* Node::InsertAfterChild( Node* afterThis, Node& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	addThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->InsertAfterChild( afterThis->GetTiXmlPointer(), *addThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+Node* Node::ReplaceChild( Node* replaceThis, Node& withThis )
+{
+	if ( withThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	withThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->ReplaceChild( replaceThis->GetTiXmlPointer(), *withThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+void Node::RemoveChild( Node* removeThis )
+{
+	if  ( !GetTiXmlPointer()->RemoveChild( removeThis->GetTiXmlPointer() ) )
+	{
+		TICPPTHROW( "Node to remove (" << removeThis->Value() << ") is not a child of this Node (" << Value() << ")" )
+	}
+}
+
+Node* Node::PreviousSibling( bool throwIfNoSiblings ) const
+{
+	return PreviousSibling( "", throwIfNoSiblings );
+}
+
+Node* Node::PreviousSibling( const std::string& value, bool throwIfNoSiblings ) const
+{
+	return PreviousSibling( value.c_str(), throwIfNoSiblings );
+}
+
+Node* Node::PreviousSibling( const char* value, bool throwIfNoSiblings ) const
+{
+	TiXmlNode* sibling;
+	if ( 0 == strlen( value ) )
+	{
+		sibling = GetTiXmlPointer()->PreviousSibling();
+	}
+	else
+	{
+		sibling = GetTiXmlPointer()->PreviousSibling( value );
+	}
+
+	if ( ( 0 == sibling ) && throwIfNoSiblings )
+	{
+		TICPPTHROW( "No Siblings found with value, '" << value << "', Prior to this Node (" << Value() << ")" )
+	}
+
+	return NodeFactory( sibling, false );
+}
+
+Node* Node::NextSibling( bool throwIfNoSiblings ) const
+{
+	return NextSibling( "", throwIfNoSiblings );
+}
+
+Node* Node::NextSibling( const std::string& value, bool throwIfNoSiblings ) const
+{
+	return NextSibling( value.c_str(), throwIfNoSiblings );
+}
+
+Node* Node::NextSibling( const char* value, bool throwIfNoSiblings ) const
+{
+	TiXmlNode* sibling;
+	if ( 0 == strlen( value ) )
+	{
+		sibling = GetTiXmlPointer()->NextSibling();
+	}
+	else
+	{
+		sibling = GetTiXmlPointer()->NextSibling( value );
+	}
+
+	if ( ( 0 == sibling ) && throwIfNoSiblings )
+	{
+		TICPPTHROW( "No Siblings found with value, '" << value << "', After this Node (" << Value() << ")" )
+	}
+
+	return NodeFactory( sibling, false );
+}
+
+Element* Node::NextSiblingElement( bool throwIfNoSiblings ) const
+{
+	return NextSiblingElement( "", throwIfNoSiblings );
+}
+
+Element* Node::NextSiblingElement( const std::string& value, bool throwIfNoSiblings ) const
+{
+	return NextSiblingElement( value.c_str(), throwIfNoSiblings );
+}
+
+Element* Node::NextSiblingElement( const char* value, bool throwIfNoSiblings ) const
+{
+	TiXmlElement* sibling;
+	if ( 0 == strlen( value ) )
+	{
+		sibling = GetTiXmlPointer()->NextSiblingElement();
+	}
+	else
+	{
+		sibling = GetTiXmlPointer()->NextSiblingElement( value );
+	}
+
+	if ( 0 == sibling )
+	{
+		if ( throwIfNoSiblings )
+		{
+			TICPPTHROW( "No Element Siblings found with value, '" << value << "', After this Node (" << Value() << ")" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Element* temp = new Element( sibling );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Element* Node::FirstChildElement( bool throwIfNoChildren ) const
+{
+	return FirstChildElement( "", throwIfNoChildren );
+}
+
+Element* Node::FirstChildElement( const std::string& value, bool throwIfNoChildren ) const
+{
+	return FirstChildElement( value.c_str(), throwIfNoChildren );
+}
+
+Element* Node::FirstChildElement( const char* value, bool throwIfNoChildren ) const
+{
+	TiXmlElement* element;
+	if ( 0 == strlen( value ) )
+	{
+		element = GetTiXmlPointer()->FirstChildElement();
+	}
+	else
+	{
+		element = GetTiXmlPointer()->FirstChildElement( value );
+	}
+
+	if ( 0 == element )
+	{
+		if( throwIfNoChildren )
+		{
+			TICPPTHROW( "Element (" << Value() << ") does NOT contain a child with the value of '" << value << "'" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Element* temp = new Element( element );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+int Node::Type() const
+{
+	return GetTiXmlPointer()->Type();
+}
+
+Document* Node::GetDocument( bool throwIfNoDocument ) const
+{
+	TiXmlDocument* doc = GetTiXmlPointer()->GetDocument();
+	if ( 0 == doc )
+	{
+		if( throwIfNoDocument )
+		{
+			TICPPTHROW( "This node (" << Value() << ") is not linked under a document" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+	Document* temp = new Document( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+bool Node::NoChildren() const
+{
+	return GetTiXmlPointer()->NoChildren();
+}
+
+Document* Node::ToDocument() const
+{
+	TiXmlDocument* doc = GetTiXmlPointer()->ToDocument();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Document" )
+	}
+	Document* temp = new Document( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Element* Node::ToElement() const
+{
+	TiXmlElement* doc = GetTiXmlPointer()->ToElement();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Element" )
+	}
+	Element* temp = new Element( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Comment* Node::ToComment() const
+{
+	TiXmlComment* doc = GetTiXmlPointer()->ToComment();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Comment" )
+	}
+	Comment* temp = new Comment( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Text* Node::ToText() const
+{
+	TiXmlText* doc = GetTiXmlPointer()->ToText();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Text" )
+	}
+	Text* temp = new Text( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Declaration* Node::ToDeclaration() const
+{
+	TiXmlDeclaration* doc = GetTiXmlPointer()->ToDeclaration();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Declaration" )
+	}
+	Declaration* temp = new Declaration( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+StylesheetReference* Node::ToStylesheetReference() const
+{
+	TiXmlStylesheetReference* doc = GetTiXmlPointer()->ToStylesheetReference();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a StylesheetReference" )
+	}
+	StylesheetReference* temp = new StylesheetReference( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+std::auto_ptr< Node > Node::Clone() const
+{
+	TiXmlNode* node = GetTiXmlPointer()->Clone();
+	if ( 0 == node )
+	{
+		TICPPTHROW( "Node could not be cloned" );
+	}
+	std::auto_ptr< Node > temp( NodeFactory( node, false, false ) );
+
+	// Take ownership of the memory from TiXml
+	temp->m_impRC->InitRef();
+
+	return temp;
+}
+
+bool Node::Accept( TiXmlVisitor* visitor ) const
+{
+	return GetTiXmlPointer()->Accept( visitor );
+}
+
+//*****************************************************************************
+
+Comment::Comment()
+: NodeImp< TiXmlComment >( new TiXmlComment() )
+{
+	m_impRC->InitRef();
+}
+
+Comment::Comment( TiXmlComment* comment )
+: NodeImp< TiXmlComment >( comment )
+{
+}
+
+Comment::Comment( const std::string& comment )
+: NodeImp< TiXmlComment >( new TiXmlComment() )
+{
+	m_impRC->InitRef();
+	m_tiXmlPointer->SetValue( comment );
+}
+
+//*****************************************************************************
+
+Text::Text()
+: NodeImp< TiXmlText >( new TiXmlText("") )
+{
+	m_impRC->InitRef();
+}
+
+
+Text::Text( const std::string& value )
+: NodeImp< TiXmlText >( new TiXmlText( value ) )
+{
+	m_impRC->InitRef();
+}
+
+Text::Text( TiXmlText* text )
+: NodeImp< TiXmlText >( text )
+{
+}
+
+
+//*****************************************************************************
+
+Document::Document()
+: NodeImp< TiXmlDocument >( new TiXmlDocument() )
+{
+	m_impRC->InitRef();
+}
+
+Document::Document( TiXmlDocument* document )
+: NodeImp< TiXmlDocument >( document )
+{
+}
+
+Document::Document( const char* documentName )
+: NodeImp< TiXmlDocument >( new TiXmlDocument( documentName ) )
+{
+	m_impRC->InitRef();
+}
+
+Document::Document( const std::string& documentName )
+: NodeImp< TiXmlDocument >( new TiXmlDocument( documentName ) )
+{
+	m_impRC->InitRef();
+}
+
+void Document::LoadFile( TiXmlEncoding encoding )
+{
+	if ( !m_tiXmlPointer->LoadFile( encoding ) )
+	{
+		TICPPTHROW( "Couldn't load " << m_tiXmlPointer->Value() );
+	}
+}
+
+void Document::SaveFile( void ) const
+{
+	if ( !m_tiXmlPointer->SaveFile() )
+	{
+		TICPPTHROW( "Couldn't save " << m_tiXmlPointer->Value() );
+	}
+}
+
+void Document::LoadFile( const std::string& filename, TiXmlEncoding encoding )
+{
+	if ( !m_tiXmlPointer->LoadFile( filename.c_str(), encoding ) )
+	{
+		TICPPTHROW( "Couldn't load " << filename );
+	}
+}
+
+void Document::LoadFile( const char* filename, TiXmlEncoding encoding )
+{
+	if ( !m_tiXmlPointer->LoadFile( filename, encoding ) )
+	{
+		TICPPTHROW( "Couldn't load " << filename );
+	}
+}
+
+void Document::SaveFile( const std::string& filename ) const
+{
+	if ( !m_tiXmlPointer->SaveFile( filename.c_str() ) )
+	{
+		TICPPTHROW( "Couldn't save " << filename );
+	}
+}
+
+void Document::Parse( const std::string& xml, bool throwIfParseError, TiXmlEncoding encoding )
+{
+	m_tiXmlPointer->Parse( xml.c_str(), 0, encoding );
+	if( throwIfParseError && m_tiXmlPointer->Error() )
+	{
+		TICPPTHROW( "Error parsing xml: " << m_tiXmlPointer->ErrorDesc()
+            << " In row " << m_tiXmlPointer->ErrorRow() << ", column " << m_tiXmlPointer->ErrorCol() << ".");
+	}
+}
+
+//*****************************************************************************
+
+Element::Element()
+: NodeImp< TiXmlElement >( new TiXmlElement( "DefaultValueCausedByCreatingAnElementWithNoParameters" ) )
+{
+	m_impRC->InitRef();
+}
+
+Element::Element( const std::string& value )
+: NodeImp< TiXmlElement >( new TiXmlElement( value ) )
+{
+	m_impRC->InitRef();
+}
+
+Element::Element( const char* value )
+: NodeImp< TiXmlElement >( new TiXmlElement( value ) )
+{
+	m_impRC->InitRef();
+}
+
+Element::Element( TiXmlElement* element )
+: NodeImp< TiXmlElement >( element )
+{
+}
+
+Attribute* Element::FirstAttribute( bool throwIfNoAttributes ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->FirstAttribute();
+	if ( ( 0 == attribute ) && throwIfNoAttributes )
+	{
+		TICPPTHROW( "This Element (" << Value() << ") has no attributes" )
+	}
+
+	if ( 0 == attribute )
+	{
+		if( throwIfNoAttributes )
+		{
+			TICPPTHROW( "Element (" << Value() << ") has no attributes" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Attribute* Element::LastAttribute( bool throwIfNoAttributes ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->LastAttribute();
+	if ( ( 0 == attribute ) && throwIfNoAttributes )
+	{
+		TICPPTHROW( "This Element (" << Value() << ") has no attributes" )
+	}
+
+	if ( 0 == attribute )
+	{
+		if( throwIfNoAttributes )
+		{
+			TICPPTHROW( "Element (" << Value() << ") has no attributes" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+std::string Element::GetAttributeOrDefault( const std::string& name, const std::string& defaultValue ) const
+{
+	std::string value;
+	if ( !GetAttributeImp( name, &value ) )
+	{
+		return defaultValue;
+	}
+	return value;
+}
+
+std::string Element::GetAttribute( const std::string& name ) const
+{
+	return GetAttributeOrDefault( name, std::string() );
+}
+
+bool Element::GetAttributeImp( const std::string& name, std::string* value ) const
+{
+	ValidatePointer();
+
+	// Get value from TinyXML, if the attribute exists
+	const char* retVal = m_tiXmlPointer->Attribute( name.c_str() );
+
+	// TinyXML returns NULL if the attribute doesn't exist
+	if ( 0 == retVal )
+	{
+		return false;
+	}
+	else
+	{
+		*value = retVal;
+		return true;
+	}
+}
+
+bool Element::GetTextImp( std::string* value ) const
+{
+	ValidatePointer();
+
+	// Get value from TinyXML, if the attribute exists
+	const char* retVal = m_tiXmlPointer->GetText();
+
+	// TinyXML returns NULL if the attribute doesn't exist
+	if ( 0 == retVal )
+	{
+		return false;
+	}
+	else
+	{
+		*value = retVal;
+		return true;
+	}
+}
+
+//*****************************************************************************
+
+Declaration::Declaration()
+: NodeImp< TiXmlDeclaration >( new TiXmlDeclaration() )
+{
+	m_impRC->InitRef();
+}
+
+Declaration::Declaration( TiXmlDeclaration* declaration )
+: NodeImp< TiXmlDeclaration >( declaration )
+{
+}
+
+Declaration::Declaration( const std::string& version, const std::string& encoding, const std::string& standalone )
+: NodeImp< TiXmlDeclaration >( new TiXmlDeclaration( version, encoding, standalone ) )
+{
+	m_impRC->InitRef();
+}
+
+std::string Declaration::Version() const
+{
+	return m_tiXmlPointer->Version();
+}
+
+std::string Declaration::Encoding() const
+{
+	return m_tiXmlPointer->Encoding();
+}
+
+std::string Declaration::Standalone() const
+{
+	return m_tiXmlPointer->Standalone();
+}
+
+//*****************************************************************************
+
+StylesheetReference::StylesheetReference()
+: NodeImp< TiXmlStylesheetReference >( new TiXmlStylesheetReference() )
+{
+	m_impRC->InitRef();
+}
+
+StylesheetReference::StylesheetReference( TiXmlStylesheetReference* stylesheetReference )
+: NodeImp< TiXmlStylesheetReference >( stylesheetReference )
+{
+}
+
+StylesheetReference::StylesheetReference( const std::string& type, const std::string& href )
+: NodeImp< TiXmlStylesheetReference >( new TiXmlStylesheetReference( type, href ) )
+{
+	m_impRC->InitRef();
+}
+
+std::string StylesheetReference::Type() const
+{
+	return m_tiXmlPointer->Type();
+}
+
+std::string StylesheetReference::Href() const
+{
+	return m_tiXmlPointer->Href();
+}
+
+//*****************************************************************************
+
+Exception::Exception(const std::string &details)
+:
+m_details( details )
+{
+
+}
+
+Exception::~Exception() throw()
+{
+}
+
+const char* Exception::what() const throw()
+{
+	return m_details.c_str();
+}
+
+//*****************************************************************************
+
+TiCppRC::TiCppRC()
+{
+	// Spawn reference counter for this object
+	m_tiRC = new TiCppRCImp( this );
+}
+
+TiCppRC::~TiCppRC()
+{
+	// Set pointer held by reference counter to NULL
+	this->m_tiRC->Nullify();
+
+	// Decrement reference - so reference counter will delete itself if necessary
+	this->m_tiRC->DecRef();
+}
+
+//*****************************************************************************
+
+TiCppRCImp::TiCppRCImp( TiCppRC* tiCppRC )
+	: m_count( 1 ), m_tiCppRC ( tiCppRC )
+{
+}
+
+void TiCppRCImp::IncRef()
+{
+	m_count++;
+}
+
+void TiCppRCImp::DecRef()
+{
+	m_count--;
+	if ( 0 == m_count )
+	{
+		delete m_tiCppRC;
+		delete this;
+	}
+}
+
+void TiCppRCImp::InitRef()
+{
+	m_count = 1;
+}
+
+void TiCppRCImp::Nullify()
+{
+	m_tiCppRC = 0;
+}
+
+TiCppRC* TiCppRCImp::Get()
+{
+	return m_tiCppRC;
+}
+
+bool TiCppRCImp::IsNull()
+{
+	return 0 == m_tiCppRC;
+}
+
+#endif // TIXML_USE_TICPP
Index: /code/branches/physics/src/tinyxml/ticpp.h
===================================================================
--- /code/branches/physics/src/tinyxml/ticpp.h	(revision 2122)
+++ /code/branches/physics/src/tinyxml/ticpp.h	(revision 2122)
@@ -0,0 +1,1812 @@
+#define TIXML_USE_TICPP
+
+/*
+http://code.google.com/p/ticpp/
+Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+@copydoc ticpp
+@file
+@author		Ryan Pusztai
+@author		Ryan Mulder
+@date		04/11/2006
+
+@version  0.04b by nico@orxonox.net: gcc-4.3 compilation hotfixes
+@version	0.04a by edam@waxworlds.org: based Exception based on std::exception; added stream
+					<< and >> support; added Document::Parse(); bug fix; improved THROW() macro.
+@version	0.04 Added NodeImp class. Also made all the classes inherit from NodeImp.
+@version	0.03 Added Declaration class
+@version	0.02 Added Element class
+@version	0.01 Added Exception class, Document class
+
+@todo add UNKNOWN support. See ticpp::NodeFactory.
+@todo add TYPECOUNT support. See ticpp::NodeFactory.
+@todo Add a quick reference
+*/
+#ifdef TIXML_USE_TICPP
+
+#ifndef TICPP_INCLUDED
+#define TICPP_INCLUDED
+
+#include "tinyxml.h"
+#include <sstream>
+#include <vector>
+#include <memory>
+#include <exception>
+#include <typeinfo>
+
+/**
+@subpage ticpp is a TinyXML wrapper that uses a lot more C++ ideals.
+It throws exceptions, uses templates, is in its own name space, and
+<b>requires</b> STL (Standard Template Library). This is done to ease the use
+of getting values in and out of the xml.
+
+If you don't perfer to use some of the concepts just don't use it.
+It is just a wrapper that extends TinyXML. It doesn't actually change
+any of TinyXML.
+*/
+namespace ticpp
+{
+    /**
+	This is a ticpp exception class
+	*/
+	class Exception : public std::exception
+	{
+	public:
+		/**
+		Construct an exception with a message
+		*/
+		Exception( const std::string& details );
+		~Exception() throw();
+
+		/// Override std::exception::what() to return m_details
+		const char* what() const throw();
+
+		std::string m_details; /**< Exception Details */
+	};
+
+	/**
+	This allows you to stream your exceptions in.
+	It will take care of the conversion	and throwing the exception.
+	*/
+	#define TICPPTHROW( message ) 											\
+	{																		\
+		std::ostringstream full_message;									\
+		std::string file( __FILE__ );										\
+		file = file.substr( file.find_last_of( "\\/" ) + 1 );				\
+		full_message << message << " <" << file << "@" << __LINE__ << ">";	\
+		throw Exception( full_message.str() );								\
+	}
+
+	// Forward Declarations for Visitor, and others.
+	class Document;
+	class Element;
+	class Declaration;
+	class StylesheetReference;
+	class Text;
+	class Comment;
+	class Attribute;
+
+	/** Wrapper around TiXmlVisitor */
+	class Visitor : public TiXmlVisitor
+	{
+	public:
+		// Overload the TiXmlVisitor functions, wrap objects, call ticpp::Visitor functions
+		/// @internal
+		virtual bool VisitEnter( const TiXmlDocument& doc );
+		/// @internal
+		virtual bool VisitExit( const TiXmlDocument& doc );
+		/// @internal
+		virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
+		/// @internal
+		virtual bool VisitExit( const TiXmlElement& element );
+		/// @internal
+		virtual bool Visit( const TiXmlDeclaration& declaration );
+		/// @internal
+		virtual bool Visit( const TiXmlStylesheetReference& stylesheet );
+		/// @internal
+		virtual bool Visit( const TiXmlText& text );
+		/// @internal
+		virtual bool Visit( const TiXmlComment& comment );
+
+	public:
+		/// Visit a document.
+		virtual bool VisitEnter( const Document& /*doc*/ )			{ return true; }
+		/// Visit a document.
+		virtual bool VisitExit( const Document& /*doc*/ )			{ return true; }
+
+		/// Visit an element.
+		virtual bool VisitEnter( const Element& /*element*/, const Attribute* /*firstAttribute*/ )	{ return true; }
+		/// Visit an element.
+		virtual bool VisitExit( const Element& /*element*/ )		{ return true; }
+
+		/// Visit a declaration
+		virtual bool Visit( const Declaration& /*declaration*/ )	{ return true; }
+		/// Visit a stylesheet reference
+		virtual bool Visit( const StylesheetReference& /*stylesheet*/ )	{ return true; }
+		/// Visit a text node
+		virtual bool Visit( const Text& /*text*/ )					{ return true; }
+		/// Visit a comment node
+		virtual bool Visit( const Comment& /*comment*/ )			{ return true; }
+	};
+
+	/** Wrapper around TiXmlBase */
+	class Base
+	{
+	public:
+
+		/**
+		Converts any class with a proper overload of the << opertor to a std::string
+		@param value The value to be converted
+		@throws Exception When value cannot be converted to a std::string
+		*/
+		template < class T >
+			std::string ToString( const T& value ) const
+		{
+			std::stringstream convert;
+			convert << value;
+			if ( convert.fail() )
+			{
+				TICPPTHROW( "Could not convert value to text" );
+			}
+			return convert.str();
+		}
+
+		std::string ToString( const std::string& value ) const
+		{
+			return value;
+		}
+
+		/**
+		Converts a std::string to any class with a proper overload of the >> opertor
+		@param temp			The string to be converted
+		@param out	[OUT]	The container for the returned value
+		@throws Exception When temp cannot be converted to the target type
+		*/
+		template < class T >
+			void FromString( const std::string& temp, T* out ) const
+		{
+			std::istringstream val( temp );
+			val >> *out;
+
+			if ( val.fail() )
+			{
+				TICPPTHROW( "Could not convert \"" << temp << "\" to target type" );
+			}
+		}
+
+		/**
+		Specialization for std::string
+		*/
+		void FromString( const std::string& temp, std::string* out ) const
+		{
+			*out = temp;
+		}
+
+		/**
+		Return the position, in the original source file, of this node or attribute.
+		Wrapper around TiXmlBase::Row()
+		*/
+		int Row() const
+		{
+			return GetBasePointer()->Row();
+		}
+
+		/**
+		Return the position, in the original source file, of this node or attribute.
+		Wrapper around TiXmlBase::Row()
+		*/
+		int Column() const
+		{
+			return GetBasePointer()->Column();
+		}
+
+		/**
+		Destructor
+		*/
+		virtual ~Base()
+		{
+			DeleteSpawnedWrappers();
+		}
+
+	protected:
+		mutable TiCppRCImp* m_impRC;	/**< Holds status of internal TiXmlPointer - use this to determine if object has been deleted already */
+
+		mutable std::vector< Base* > m_spawnedWrappers; /**< Remember all wrappers that we've created with 'new' - ( e.g. NodeFactory, FirstChildElement, etc. )*/
+
+		/**
+		@internal
+		Updates the pointer to the reference counter to point at the counter in the new node.
+
+		@param node TiXmlBase containing the new reference counter
+		*/
+		void SetImpRC( TiXmlBase* node )
+		{
+			m_impRC = node->m_tiRC;
+		}
+
+		void ValidatePointer() const
+		{
+			if ( m_impRC->IsNull() )
+			{
+				TICPPTHROW( "Internal TiXml Pointer is NULL" );
+			}
+		}
+
+		/**
+		@internal
+		Delete all container objects we've spawned with 'new'.
+		*/
+		void DeleteSpawnedWrappers()
+		{
+			std::vector< Base* >::reverse_iterator wrapper;
+			for ( wrapper = m_spawnedWrappers.rbegin(); wrapper != m_spawnedWrappers.rend(); ++wrapper )
+			{
+				delete *wrapper;
+			}
+			m_spawnedWrappers.clear();
+		}
+
+		/**
+		@internal
+		Get internal TiXmlBase*
+		*/
+		virtual TiXmlBase* GetBasePointer() const = 0;
+	};
+
+	/**
+	Wrapper around TiXmlAttribute
+	*/
+	class Attribute : public Base
+	{
+	private:
+		TiXmlAttribute* m_tiXmlPointer;
+		TiXmlBase* GetBasePointer() const
+		{
+			ValidatePointer();
+			return m_tiXmlPointer;
+		}
+
+	public:
+		/**
+		Construct an empty attribute.
+		*/
+		Attribute();
+
+		/**
+		Construct an attribute with @a name and @a value
+
+		@param name The name of the attribute
+		@param value The value of the attribute
+		*/
+		Attribute( const std::string& name, const std::string& value );
+
+		/**
+		@internal
+		Construct an attribute with the internal pointer
+
+		@param attribute The internal pointer
+		*/
+		Attribute( TiXmlAttribute* attribute );
+
+		/**
+		Get the value of this attribute
+		Uses Base::FromString to convert TiXmlAttribute::ValueStr from a std::string,
+		and puts it in the passed pointer.
+
+		@param value [OUT] A pointer to fill with the value
+		*/
+		template < class T >
+			void GetValue( T* value ) const
+		{
+			ValidatePointer();
+			FromString( m_tiXmlPointer->ValueStr(), value );
+		}
+
+		/**
+		Get the value of this attribute.
+		Simple wrapper for TiXmlAttribute::ValueStr.
+
+		@see GetValue
+		*/
+		std::string Value() const;
+
+		/**
+		Set the value of this node.
+		Uses Base::ToString to convert value to a std::string, then calls TiXmlAttribute::SetValue.
+
+		@param value The value to set
+		*/
+		template < class T >
+			void SetValue( const T& value )
+		{
+			ValidatePointer();
+			m_tiXmlPointer->SetValue( ToString( value ) );
+		}
+
+		/**
+		Get the value of this attribute
+		Uses Base::FromString to convert TiXmlAttribute::Name from a std::string,
+		and puts it in the passed pointer.
+
+		@param name [OUT] A pointer to fill with the name
+		*/
+		template < class T >
+			void GetName( T* name ) const
+		{
+			ValidatePointer();
+			FromString( m_tiXmlPointer->Name(), name );
+		}
+
+		/**
+		Get the value of this attribute.
+		Simple wrapper for TiXmlAttribute::Name.
+
+		@see GetName
+		*/
+		std::string Name() const;
+
+		/**
+		Set the value of this attribute.
+		Uses Base::ToString to convert @a name to a std::string, then calls TiXmlAttribute::SetName.
+
+		@param name The name to set
+		*/
+		template < class T >
+			void SetName( const T& name )
+		{
+			ValidatePointer();
+			m_tiXmlPointer->SetName( ToString( name ) );
+		}
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		*/
+		void operator=( const Attribute& copy );
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		*/
+		Attribute( const Attribute& copy );
+
+		/*
+		Decrements reference count.
+		*/
+		~Attribute();
+
+		/**
+		Get the next sibling attribute in the DOM.
+		*/
+		Attribute* Next( bool throwIfNoAttribute = true ) const;
+
+		/**
+		Get the previous sibling attribute in the DOM.
+		*/
+		Attribute* Previous( bool throwIfNoAttribute = true ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param next [OUT] The pointer to the next valid attribute
+		@return true if there is a next attribute, false if not
+		*/
+		void IterateNext( const std::string&, Attribute** next ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param previous [OUT] The pointer to the previous valid attribute
+		@return true if there is a previous attribute, false if not
+		*/
+		void IteratePrevious( const std::string&, Attribute** previous ) const;
+
+		/**
+		All TinyXml classes can print themselves to a filestream.
+		*/
+		virtual void Print( FILE* file, int depth ) const;
+
+	private:
+
+		/**
+		@internal
+		Sets the internal pointer.
+		Saves a copy of the pointer to the RC object.
+
+		@param newPointer TiXmlAttribute* to set.
+		*/
+		void SetTiXmlPointer( TiXmlAttribute* newPointer );
+	};
+
+	/**
+	Wrapper around TiXmlNode
+	*/
+	class Node : public Base
+	{
+	public:
+
+		/**
+		Get the value of this node
+		Uses Base::FromString to convert TiXmlNode::ValueStr from a std::string,
+		and puts it in the passed pointer.
+
+		@param value [OUT] A pointer to fill with the value
+		*/
+		template < class T >
+			void GetValue( T* value) const
+		{
+			FromString( GetTiXmlPointer()->ValueStr(), value );
+		}
+
+		/**
+		Get the value of this node.
+		Simple wrapper for TiXmlNode::ValueStr.
+
+		@see GetValue
+		*/
+		std::string Value() const;
+
+		/**
+		Set the value of this node.
+		Uses Base::ToString to convert value to a std::string, then calls TiXmlNode::SetValue.
+
+		@param value The value to set
+		*/
+		template < class T >
+			void SetValue( const T& value )
+		{
+			GetTiXmlPointer()->SetValue( ToString( value ) );
+		}
+
+		/**
+		Clear all Nodes below this.
+		Simple wrapper for TiXmlNode::Clear.
+		*/
+		void Clear();
+
+		/**
+		The Parent of this Node.
+		Simple wrapper for TiXmlNode::Parent.
+
+		@param throwIfNoParent [DEF] If true, throws when Parent = NULL.
+		@return The parent of this node, NULL if there is no Parent.
+		@throws Exception When throwIfNoParent is true, and TiXmlNode::Parent returns Null.
+		*/
+		Node* Parent( bool throwIfNoParent = true ) const;
+
+		/**
+		The first child of this node.
+
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
+		@return Pointer to child, Null if no children and 'throwIfNoChildren' is false.
+		@throws Exception When throwIfNoChildren is true, and TiXmlNode::FirstChild returns Null.
+
+		@see TiXmlNode::FirstChild
+		*/
+		Node* FirstChild( bool throwIfNoChildren = true ) const;
+
+		/**
+		@internal
+		The first child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see FirstChild( bool throwIfNoChildren = true )
+		*/
+		Node* FirstChild( const char* value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The first child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see FirstChild( const char* value, bool throwIfNoChildren = true )
+		*/
+		Node* FirstChild( const std::string& value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The last child of this node.
+
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
+		@return Pointer to child, Null if no children and 'throwIfNoChildren' is false.
+		@throws Exception When throwIfNoChildren is true, and TiXmlNode::LastChild returns Null.
+
+		@see TiXmlNode::LastChild
+		*/
+		Node* LastChild( bool throwIfNoChildren = true ) const;
+
+		/**
+		@internal
+		The last child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see LastChild( bool throwIfNoChildren = true )
+		*/
+		Node* LastChild( const char* value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The last child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see LastChild( const char* value, bool throwIfNoChildren = true )
+		*/
+		Node* LastChild( const std::string& value, bool throwIfNoChildren = true ) const;
+
+		/**
+		An alternate way to walk the children of a node.
+		Simple wrapper for TiXmlNode::IterateChildren.
+
+		@param previous The previous Node* that was returned from IterateChildren.
+		@return NULL When there are no more children.
+		*/
+		Node* IterateChildren( Node* previous ) const;
+
+		/**
+		This flavor of IterateChildren searches for children with a particular @a value.
+		Simple wrapper for TiXmlNode::IterateChildren.
+
+		@param value	The value you want to search for.
+		@param previous The previous Node* that was returned from IterateChildren.
+		@return NULL When there are no more children.
+		*/
+		Node* IterateChildren( const std::string& value, Node* previous ) const;
+
+		/**
+		Adds a child past the LastChild.
+		Throws if you try to insert a document.
+
+		@note This takes a copy of @a addThis so it is not as efficiant as LinkEndChild.
+		@param addThis Node to insert.
+		@throws Exception When TiXmlNode::InsertEndChild returns Null
+
+		@see LinkEndChild
+		@see TiXmlNode::InsertEndChild
+		*/
+		Node* InsertEndChild( Node& addThis );
+
+		/**
+		Adds a child past the LastChild.
+		Throws if you try to link a document.
+
+		@param childNode Node to link.
+		@throws Exception When TiXmlNode::LinkEndChild returns Null.
+
+		@see InsertEndChild
+		@see TiXmlNode::LinkEndChild
+		*/
+		Node* LinkEndChild( Node* childNode );
+
+		/**
+		Adds a child before the specified child.
+		Throws if you try to insert a document.
+
+		@param beforeThis	Node that will have @a addThis linked before.
+		@param addThis		Node to insert before.
+		@throws Exception When TiXmlNode::InsertBeforeChild returns Null.
+
+		@see InsertAfterChild
+		@see TiXmlNode::InsertBeforeChild
+		*/
+		Node* InsertBeforeChild( Node* beforeThis, Node& addThis );
+
+		/**
+		Adds a child after the specified child.
+		Throws if you try to insert a document.
+
+		@param afterThis	Node that will have @a addThis linked after.
+		@param addThis		Node to insert after.
+		@throws Exception When TiXmlNode::InsertAfterChild returns Null.
+
+		@see InsertBeforeChild
+		@see TiXmlNode::InsertAfterChild
+		*/
+		Node* InsertAfterChild( Node* afterThis, Node& addThis );
+
+		/**
+		Replace a child of this node.
+		Throws if you try to replace with a document.
+
+		@param replaceThis	Node to replace.
+		@param withThis		Node that is replacing @a replaceThis.
+		@throws Exception When TiXmlNode::ReplaceChild returns Null.
+
+		@see TiXmlNode::ReplaceChild
+		*/
+		Node* ReplaceChild( Node* replaceThis, Node& withThis );
+
+		/**
+		Delete a child of this node.
+
+		@param removeThis Node to delete.
+		@throws Exception When removeThis is not a child of this Node.
+
+		@see TiXmlNode::RemoveChild
+		*/
+		void RemoveChild( Node* removeThis );
+
+		/**
+		Navigate to a sibling node.
+		Wrapper around TiXmlNode::PreviousSibling.
+
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+		@return Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
+		@throws Exception When TiXmlNode::PreviousSibling returns Null and 'throwIfNoSiblings' is true.
+		*/
+		Node* PreviousSibling( bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see PreviousSibling( bool throwIfNoSiblings )
+		*/
+		Node* PreviousSibling( const std::string& value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see PreviousSibling( const std::string& value, bool throwIfNoSiblings )
+		*/
+		Node* PreviousSibling( const char* value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling node.
+		Wrapper around TiXmlNode::NextSibling.
+
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+		@return Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
+		@throws Exception When TiXmlNode::NextSibling returns Null and 'throwIfNoSiblings' is true.
+		*/
+		Node* NextSibling( bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see NextSibling( bool throwIfNoSiblings )
+		*/
+		Node* NextSibling( const std::string& value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see NextSibling( const std::string& value, bool throwIfNoSiblings )
+		*/
+		Node* NextSibling( const char* value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param next [OUT] The pointer to the first valid node
+		*/
+		template < class T >
+			void IterateFirst( const std::string& value, T** first ) const
+		{
+			*first = 0;
+			for( Node* child = FirstChild( value, false ); child; child = child->NextSibling( value, false ) )
+			{
+				*first = dynamic_cast< T* >( child );
+				if ( 0 != *first )
+				{
+					return;
+				}
+			}
+		}
+
+		virtual	void IterateFirst( const std::string&, Attribute** ) const
+		{
+			TICPPTHROW( "Attributes can only be iterated with Elements." )
+		}
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param next [OUT] The pointer to the next valid node
+		*/
+		template < class T >
+			void IterateNext( const std::string& value, T** next ) const
+		{
+			Node* sibling = NextSibling( value, false );
+			*next = dynamic_cast< T* >( sibling );
+
+			while ( ( 0 != sibling ) && ( 0 == *next ) )
+			{
+				sibling = sibling->NextSibling( value, false );
+				*next = dynamic_cast< T* >( sibling );
+			}
+		}
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param previous [OUT] The pointer to the previous valid node
+		*/
+		template < class T >
+			void IteratePrevious( const std::string& value, T** previous  ) const
+		{
+			Node* sibling = PreviousSibling( value, false );
+			*previous = dynamic_cast< T* >( sibling );
+
+			while ( ( 0 != sibling ) && ( 0 == *previous ) )
+			{
+				sibling = sibling->PreviousSibling( value, false );
+				*previous = dynamic_cast< T* >( sibling );
+			}
+		}
+
+		/**
+		Navigate to a sibling element.
+		Wrapper around TiXmlNode::NextSibling.
+
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling element.
+		@return Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
+		@throws Exception When TiXmlNode::NextSibling returns Null and 'throwIfNoSiblings' is true.
+		*/
+		Element* NextSiblingElement( bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling element with the given @a value.
+
+		@overload
+		@param value The value of the element to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling elements.
+		@see NextSiblingElement( bool throwIfNoSiblings )
+		*/
+		Element* NextSiblingElement( const std::string& value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Navigate to a sibling element with the given @a value.
+
+		@overload
+		@param value The value of the element to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling elements.
+
+		@see NextSiblingElement( const std::string& value, bool throwIfNoSiblings )
+		*/
+		Element* NextSiblingElement( const char* value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		The first child element of this node.
+
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
+		@return Pointer to child, Null if no element children and 'throwIfNoChildren' is false.
+		@throws Exception When throwIfNoChildren is true, and TiXmlNode::FirstChildElement returns Null.
+
+		@see TiXmlNode::FirstChildElement
+		*/
+		Element* FirstChildElement( bool throwIfNoChildren = true ) const;
+
+		/**
+		@internal
+		The first child element of this node with the matching @a value.
+
+		@overload
+		@param value Value to match.
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
+
+		@see FirstChildElement( bool throwIfNoChildren = true )
+		*/
+		Element* FirstChildElement( const char* value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The first child element of this node with the matching @a value.
+
+		@overload
+		@param value Value to match.
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
+
+		@see FirstChildElement( const char* value, bool throwIfNoChildren = true )
+		*/
+		Element* FirstChildElement( const std::string& value, bool throwIfNoChildren = true ) const;
+
+		/**
+		Query the type (as TiXmlNode::NodeType ) of this node.
+		*/
+		int Type() const;
+
+		/**
+		Return a pointer to the Document this node lives in.
+
+		@param throwIfNoDocument [DEF] If true, will throw an exception if this node is not linked under a Document.
+		@return A pointer to the Document this node lives in, NULL if not linked under a Document, and 'throwIfNoDocument' is false.
+		@throws Exception When this node is not linked under a Document and 'throwIfNoDocument' is true.
+		*/
+		Document* GetDocument( bool throwIfNoDocument = true ) const;
+
+		/**
+		Check if this node has no children.
+
+		@return true if this node has no children.
+		*/
+		bool NoChildren() const;
+
+		/**
+		Pointer conversion ( NOT OBJECT CONVERSION ) - replaces TiXmlNode::ToElement, TiXmlNode::ToDocument, TiXmlNode::ToComment, etc.
+
+		@throws Exception When the target is not an object of class T
+		@warning Some ancient compilers do not support explicit specification of member template arguments, which this depends on ( e.g. VC6 ).
+		*/
+		template < class T >
+			T* To() const
+		{
+			T* pointer = dynamic_cast< T* >( this );
+			if ( 0 == pointer )
+			{
+				std::string thisType = typeid( this ).name();
+				std::string targetType = typeid( T ).name();
+				std::string thatType = typeid( *this ).name();
+				TICPPTHROW( "The " << thisType.substr( 6 ) << " could not be casted to a " << targetType.substr( 6 )
+					<< " *, because the target object is not a " << targetType.substr( 6 ) << ". (It is a " << thatType.substr( 6 ) << ")" );
+			}
+			return pointer;
+		}
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToDocument.
+
+		@throws Exception When this node is not a Document.
+		*/
+		Document* ToDocument() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToElement.
+
+		@throws Exception When this node is not a Element.
+		*/
+		Element* ToElement() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToComment.
+
+		@throws Exception When this node is not a Comment.
+		*/
+		Comment* ToComment() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToText.
+
+		@throws Exception When this node is not a Text.
+		*/
+		Text* ToText() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToDeclaration.
+
+		@throws Exception When this node is not a Declaration.
+		*/
+		Declaration* ToDeclaration() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToStylesheetReference.
+
+		@throws Exception When this node is not a StylesheetReference.
+		*/
+		StylesheetReference* ToStylesheetReference() const;
+
+		/**
+		Create an exact duplicate of this node and return it.
+
+		@note Using auto_ptr to manage the memory declared on the heap by TiXmlNode::Clone.
+		@code
+		// Now using clone
+		ticpp::Document doc( "C:\\Test.xml" );
+		ticpp::Node* sectionToClone;
+		sectionToClone = doc.FirstChild( "settings" );
+		std::auto_ptr< ticpp::Node > clonedNode = sectionToClone->Clone();
+		// Now you can use the clone.
+		ticpp::Node* node2 = clonedNode->FirstChildElement()->FirstChild();
+		...
+		// After the variable clonedNode goes out of scope it will automatically be cleaned up.
+		@endcode
+		@return Pointer the duplicate node.
+		*/
+		std::auto_ptr< Node > Clone() const;
+
+		/**
+		Accept a hierchical visit the nodes in the TinyXML DOM.
+		@return The boolean returned by the visitor.
+		*/
+		bool Accept( TiXmlVisitor* visitor ) const;
+
+		/**
+ 		Stream input operator.
+ 		*/
+ 		friend std::istream& operator >>( std::istream& in, Node& base )
+ 		{
+ 			in >> *base.GetTiXmlPointer();
+ 			return in;
+ 		}
+
+ 		/**
+ 		Stream output operator.
+ 		*/
+ 		friend std::ostream& operator <<( std::ostream& out, const Node& base )
+ 		{
+ 			out << *base.GetTiXmlPointer();
+ 			return out;
+ 		}
+
+	protected:
+		/**
+		@internal
+		Allows NodeImp to use Node*'s.
+		*/
+		virtual TiXmlNode* GetTiXmlPointer() const = 0;
+
+		TiXmlBase* GetBasePointer() const
+		{
+			return GetTiXmlPointer();
+		}
+
+		/**
+		@internal
+		Constructs the correct child of Node, based on the Type of the TiXmlNode*.
+		*/
+		Node* NodeFactory( TiXmlNode* tiXmlNode, bool throwIfNull = true, bool rememberSpawnedWrapper = true ) const;
+
+	};
+
+	/** Iterator for conveniently stepping through Nodes and Attributes.
+	TinyXML++ introduces iterators:
+	@code
+	ticpp::Iterator< ticpp::Node > child;
+	for ( child = child.begin( parent ); child != child.end(); child++ )
+	@endcode
+
+	Iterators have the added advantage of filtering by type:
+	@code
+	// Only iterates through Comment nodes
+	ticpp::Iterator< ticpp::Comment > child;
+	for ( child = child.begin( parent ); child != child.end(); child++ )
+	@endcode
+
+	@code
+	// Only iterates through Element nodes with value "ElementValue"
+	ticpp::Iterator< ticpp::Element > child( "ElementValue" );
+	for ( child = child.begin( parent ); child != child.end(); child++ )
+	@endcode
+
+	Finally, Iterators also work with Attributes
+	@code
+	ticpp::Iterator< ticpp::Attribute > attribute;
+	for ( attribute = attribute.begin( element ); attribute != attribute.end(); attribute++ )
+	@endcode
+	*/
+	template < class T = Node >
+		class Iterator
+	{
+	private:
+		T* m_p;					/**< Internal Pointer */
+		std::string m_value;	/**< Value for NextSibling  calls */
+
+	public:
+
+		/**
+		For for loop comparisons.
+		@param parent The parent of the nodes to iterate.
+		@return The first child of type T.
+		@code
+		ticpp::Iterator< ticpp::Node > child;
+		for ( child = child.begin( parent ); child != child.end(); child++ )
+		@endcode
+		*/
+		T* begin( const Node* parent ) const
+		{
+			T* pointer;
+			parent->IterateFirst( m_value, &pointer );
+			return pointer;
+		}
+
+		/**
+		For for loop comparisons.
+		@return NULL
+		@code
+		ticpp::Iterator< ticpp::Node > child;
+		for ( child = child.begin( parent ); child != child.end(); child++ )
+		@endcode
+		*/
+		T* end() const
+		{
+			return 0;
+		}
+
+		/** Constructor.
+		@param value If not empty, this iterator will only visit nodes with matching value.
+		@code
+		// Only iterates through Element nodes with value "ElementValue"
+		ticpp::Iterator< ticpp::Element > child( "ElementValue" );
+		for ( child = child.begin( parent ); child != child.end(); child++ )
+		@endcode
+		*/
+		Iterator( const std::string& value = "" )
+			: m_p( 0 ), m_value( value )
+		{
+		}
+
+		/// Constructor
+		Iterator( T* node, const std::string& value = "" )
+			: m_p( node ), m_value( value )
+		{
+		}
+
+		/// Constructor
+		Iterator( const Iterator& it, const std::string& value  = "" )
+			: m_p( it.m_p ), m_value( value )
+		{
+		}
+
+		/**
+		Gets internal pointer.
+		@return The internal pointer.
+		*/
+		T* Get() const
+		{
+			return m_p;
+		}
+
+		/** Sets internal pointer */
+		Iterator& operator=( const Iterator& it )
+		{
+			m_p = it.m_p;
+			return *this;
+		}
+
+		/** Sets internal pointer */
+		Iterator& operator=( T* p )
+		{
+			m_p = p;
+			return *this;
+		}
+
+		/** Sets internal pointer to the Next Sibling, or Iterator::END, if there are no more siblings */
+		Iterator& operator++()
+		{
+			m_p->IterateNext( m_value, &m_p );
+			return *this;
+		}
+
+		/** Sets internal pointer to the Next Sibling, or Iterator::END, if there are no more siblings */
+		Iterator& operator++(int)
+		{
+			return this->operator ++();
+		}
+
+		/** Sets internal pointer to the Previous Sibling, or Iterator::END, if there are no prior siblings */
+		Iterator& operator--()
+		{
+			m_p->IteratePrevious( m_value, &m_p );
+			return *this;
+		}
+
+		/** Sets internal pointer to the Previous Sibling, or Iterator::END, if there are no prior siblings */
+		Iterator& operator--(int)
+		{
+			return this->operator --();
+		}
+
+		/** Compares internal pointer */
+		bool operator!=( T* p ) const
+		{
+			return m_p != p;
+		}
+
+		/** Compares internal pointer */
+		bool operator!=( const Iterator& it ) const
+		{
+			return m_p != it.m_p;
+		}
+
+		/** Compares internal pointer* */
+		bool operator==( T* p ) const
+		{
+			return m_p == p;
+		}
+
+		/** Compares internal pointer */
+		bool operator==( const Iterator& it ) const
+		{
+			return m_p == it.m_p;
+		}
+
+		/** So Iterator behaves like a STL iterator */
+		T* operator->() const
+		{
+			return m_p;
+		}
+
+		/** So Iterator behaves like a STL iterator */
+		T& operator*() const
+		{
+			return *m_p;
+		}
+	};
+
+	/** Implementation of Node wrapper */
+	template < class T >
+		class NodeImp : public Node
+	{
+	protected:
+
+		T* m_tiXmlPointer;		/**< Internal pointer to the TiXml Class which is being wrapped */
+
+    public:
+		/**
+		@internal
+		Gets the internal TinyXML pointer.
+
+		@returns The internal TiXmlNode*.
+		*/
+		TiXmlNode* GetTiXmlPointer() const
+		{
+			ValidatePointer();
+			return m_tiXmlPointer;
+		}
+    protected:
+
+		/**
+		@internal
+		Sets the internal pointer.
+		Saves a copy of the pointer to the RC object.
+
+		@param newPointer TiXmlNode* to set.
+		*/
+		void SetTiXmlPointer( T* newPointer )
+		{
+			m_tiXmlPointer = newPointer;
+			SetImpRC( newPointer );
+		}
+
+		/**
+		@internal
+		Constructor used by child classes.
+		*/
+		NodeImp( T* tiXmlPointer )
+		{
+			// Check for NULL pointers
+			if ( 0 == tiXmlPointer )
+			{
+				TICPPTHROW( "Can not create a " << typeid( T ).name() );
+			}
+			SetTiXmlPointer( tiXmlPointer );
+			m_impRC->IncRef();
+		}
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		In addition, the spawnedWrappers must be cleared out before a new TiXml object is loaded in.
+		*/
+		virtual void operator=( const NodeImp<T>& copy )
+		{
+			DeleteSpawnedWrappers();
+
+			// Dropping the reference to the old object
+			this->m_impRC->DecRef();
+
+			// Pointing to the new Object
+			SetTiXmlPointer( copy.m_tiXmlPointer );
+
+			// The internal tixml pointer changed in the above line
+			this->m_impRC->IncRef();
+		}
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		In addition, the spawnedWrappers must be cleared out before a new TiXml object is loaded in
+		*/
+		NodeImp( const NodeImp<T>& copy ) : Node( copy )
+		{
+			// Pointing to the new Object
+			SetTiXmlPointer( copy.m_tiXmlPointer );
+
+			// The internal tixml pointer changed in the above line
+			this->m_impRC->IncRef();
+		}
+
+	public:
+
+		/*
+		Deletes the spawned wrapper objects.
+		Decrements reference count.
+		*/
+		virtual ~NodeImp()
+		{
+			// The spawnedWrappers need to be deleted before m_tiXmlPointer
+			DeleteSpawnedWrappers();
+			m_impRC->DecRef();
+		}
+	};
+
+	/** Wrapper around TiXmlComment */
+	class Comment : public NodeImp< TiXmlComment >
+	{
+	public:
+
+		/**
+		Constructor.
+		*/
+		Comment();
+
+		/**
+		Constructor.
+		*/
+		Comment( TiXmlComment* comment );
+
+		/**
+		Constructor.
+		*/
+		Comment( const std::string& comment );
+	};
+
+	/** Wrapper around TiXmlText */
+	class Text : public NodeImp< TiXmlText >
+	{
+	public:
+
+		/**
+		Constructor.
+		*/
+		Text();
+
+		/**
+		Constructor.
+		@overload
+		*/
+		Text( TiXmlText* text );
+
+		/**
+		Constructor.
+		@overload
+		*/
+		Text( const std::string& value );
+
+		/**
+		Streams value into a string and creates a Text with it.
+		Uses ToString to covert the parameter to a string.
+
+		@param value The value of the Text node.
+		@throws Exception
+
+		@see TiXmlText
+        */
+		template < class T >
+			Text( const T& value )
+				: NodeImp< TiXmlText >( new TiXmlText( ToString( value ) ) )
+		{
+			m_impRC->InitRef();
+		}
+	};
+
+	/** Wrapper around TiXmlDocument */
+	class Document : public NodeImp< TiXmlDocument >
+	{
+	public:
+		/**
+		Default	Constructor.
+		Create an empty document, that has no name.
+		*/
+		Document();
+
+		/**
+		Constructor.
+		*/
+		Document( TiXmlDocument* document );
+
+		/**
+		Constructor.
+		*/
+		Document( const char* documentName );
+
+		/**
+		Constructor.
+		Create a document with a name. The name of the document is also the filename of the xml.
+
+		@param documentName Name to set in the Document.
+		*/
+		Document( const std::string& documentName );
+
+		/**
+		Load a file using the current document value. Throws if load is unsuccessful.
+
+		@param encoding Sets the documents encoding.
+		@see TiXmlEncoding
+		@throws Exception
+		*/
+		void LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+		/**
+		Save a file using the current document value. Throws if it can't save the file.
+
+		@throws Exception
+		*/
+		void SaveFile() const;
+
+		/**
+		Load a file using the given filename. Throws if load is unsuccessful.
+
+		@param filename File to load.
+		@param encoding Sets the documents encoding.
+		@see TiXmlEncoding
+		@throws Exception
+		*/
+		void LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+		/**
+		@copydoc Document::LoadFile( const std::string&, TiXmlEncoding )
+		*/
+		void LoadFile( const char* filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+		/**
+		Save a file using the given filename. Throws if it can't save the file.
+
+		@param filename File to save.
+		@throws Exception
+		*/
+		void SaveFile( const std::string& filename ) const;
+
+		/**
+		Parse the given xml data.
+
+		@param xml Xml to parse.
+		@param throwIfParseError [DEF] If true, throws when there is a parse error.
+		@param encoding Sets the documents encoding.
+		@throws Exception
+		*/
+		void Parse( const std::string& xml, bool throwIfParseError = true, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	};
+
+	/** Wrapper around TiXmlElement */
+	class Element : public NodeImp< TiXmlElement >
+	{
+	public:
+		/**
+		Default Constructor.
+		*/
+		Element();
+
+		/**
+		Default	Constructor. Initializes all the variables.
+		@param value The value of the element.
+		*/
+		Element( const std::string& value );
+
+		/**
+		Default	Constructor. Initializes all the variables.
+		@param value The value of the element.
+		*/
+		Element( const char* value );
+
+		/**
+		Constructor.
+		*/
+		Element( TiXmlElement* element );
+
+		/**
+		Constructor that allows you to set the element text
+		@param value The value of the element.
+		@param text The text to set.
+		*/
+		template < class T >
+			Element( const std::string& value, const T& text )
+			: NodeImp< TiXmlElement >( new TiXmlElement( value ) )
+		{
+			m_impRC->InitRef();
+			SetText( text );
+		}
+
+		/**
+		Access the first attribute in this element.
+
+		@param throwIfNoAttributes [DEF] If true, throws when there are no attributes
+		@return The first attribute, NULL if there are none and @a throwIfNoAttributes is true
+		*/
+		Attribute* FirstAttribute( bool throwIfNoAttributes = true ) const;
+
+		/**
+		Access the last attribute in this element.
+
+		@param throwIfNoAttributes [DEF] If true, throws when there are no attributes
+		@return The last attribute, NULL if there are none and @a throwIfNoAttributes is true
+		*/
+		Attribute* LastAttribute( bool throwIfNoAttributes = true ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param next [OUT] The pointer to the first valid node
+		*/
+		void IterateFirst( const std::string&, Attribute** first ) const
+		{
+			*first = 0;
+			for( Attribute* child = FirstAttribute( false ); child; child = child->Next( false ) )
+			{
+				*first = dynamic_cast< Attribute* >( child );
+				if ( 0 != *first )
+				{
+					return;
+				}
+			}
+		}
+
+		/**
+		Sets an attribute of name to a given value.
+		The attribute will be created if it does not exist, or changed if it does.
+		Uses ToString to convert the @a value to a string, so there is no need to use any other SetAttribute methods.
+
+		@see GetAttribute
+		*/
+		template < class T >
+			void SetAttribute ( const std::string& name, const T& value )
+		{
+			ValidatePointer();
+			m_tiXmlPointer->SetAttribute( name, ToString( value ) );
+		}
+
+		/**
+		Gets the text of an Element.
+
+		@param throwIfNotFound	[DEF]	If true, will throw an exception if there is no text in this element
+		@note This only works if the Text is the FirstChild node
+		@throws Exception When there is no text and throwIfNotFound is true
+
+		@see GetText( T* value, bool throwIfNotFound = false )
+		@see GetTextOrDefault
+		@see GetTextOrDefault( T* value, const DefaultT& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		std::string GetText( bool throwIfNotFound = true ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				if ( throwIfNotFound )
+				{
+					TICPPTHROW( "Text does not exists in the current element" );
+				}
+			}
+
+			return temp;
+		}
+
+		/**
+		Gets the text of an Element, if it doesn't exist it will return the defaultValue.
+
+		@param defaultValue			What to put in 'value' if there is no text in this element
+		@note This only works if the Text is the FirstChild node
+
+		@see GetText
+		@see GetText( T* value, bool throwIfNotFound = false )
+		@see GetTextOrDefault( T* value, const DefaultT& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		std::string GetTextOrDefault( const std::string& defaultValue ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				return defaultValue;
+			}
+
+			return temp;
+		}
+
+		/**
+		Gets the text value of an Element, if it doesn't exist it will return the defaultValue.
+		Uses FromString to convert the string to the type of choice
+
+		@param value		[OUT]	The container for the returned value
+		@param defaultValue			What to put in 'value' if there is no text in this element
+		@note This is different than GetText() in that it will covert the text to what ever type you want.
+		@note This only works if the Text is the FirstChild node
+
+		@see GetText
+		@see GetText( T* value, bool throwIfNotFound = false )
+		@see GetTextOrDefault( const std::string& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		template < class T, class DefaultT >
+			void GetTextOrDefault( T* value, const DefaultT& defaultValue ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				// The text value does not exist - set value to the default
+				*value = defaultValue;
+				return;
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Gets the text of an Element.
+		Uses FromString to convert the string to the type of choice.
+
+		@param value			[OUT]	The container for the returned value
+		@param throwIfNotFound	[DEF]	If true, will throw an exception if there is no text in this element
+		@note This is different than GetText() in that it will covert the text to what ever type you want
+		@note This only works if the Text is the FirstChild node
+		@throws Exception When there is no text and throwIfNotFound is true
+
+		@see GetText
+		@see GetTextOrDefault
+		@see GetTextOrDefault( T* value, const DefaultT& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		template< class T >
+			void GetText( T* value, bool throwIfNotFound = true ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				if ( throwIfNotFound )
+				{
+					TICPPTHROW( "Text does not exists in the current element" );
+				}
+				else
+				{
+					return;
+				}
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Convenience function to set the text of an element.
+		Creates a Text node and inserts it as the first child.
+		Uses ToString to convert the parameter to a string.
+
+		@param value The text to set.
+		*/
+		template < class T >
+			void SetText( const T& value )
+		{
+			ValidatePointer();
+			std::string temp = ToString( value );
+
+			if ( m_tiXmlPointer->NoChildren() )
+			{
+				m_tiXmlPointer->LinkEndChild( new TiXmlText( temp ) );
+			}
+			else
+			{
+				if ( 0 == m_tiXmlPointer->GetText() )
+				{
+					m_tiXmlPointer->InsertBeforeChild( m_tiXmlPointer->FirstChild(), TiXmlText( temp ) );
+				}
+				else
+				{
+					// There already is text, so change it
+					m_tiXmlPointer->FirstChild()->SetValue( temp );
+				}
+			}
+		}
+
+		/**
+		Gets an attribute of @a name from an element, if it doesn't exist it will return the defaultValue.
+		Uses FromString to convert the string to the type of choice.
+
+		@param name			The name of the attribute you are querying.
+		@param value		[OUT] The container for the returned value.
+		@param defaultValue	What to put in @a value if there is no attribute in this element.
+		@throws Exception
+
+		@see GetAttribute
+		*/
+		template < class T, class DefaulT >
+			void GetAttributeOrDefault( const std::string& name, T* value, const DefaulT& defaultValue ) const
+		{
+			// Get the attribute's value as a std::string
+			std::string temp;
+			if ( !GetAttributeImp( name, &temp ) )
+			{
+				// The attribute does not exist - set value to the default
+				*value = defaultValue;
+				return;
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Gets an attribute of @a name from an element, if it doesn't exist it will return the defaultValue.
+
+		@param name			The name of the attribute you are querying.
+		@param defaultValue	What to put in @a value if there is no attribute in this element.
+
+		@see GetAttribute
+		*/
+		std::string GetAttributeOrDefault( const std::string& name, const std::string& defaultValue ) const;
+
+		/**
+		Gets an attribute of @a name from an element.
+		Uses FromString to convert the string to the type of choice.
+
+		@param name				The name of the attribute you are querying.
+		@param value			[OUT]	The container for the returned value
+		@param throwIfNotFound	[DEF]	If true, will throw an exception if the attribute doesn't exist
+		@throws Exception When the attribute doesn't exist and throwIfNotFound is true
+
+		@see GetAttributeOrDefault
+		*/
+		template< class T >
+			void GetAttribute( const std::string& name, T* value, bool throwIfNotFound = true ) const
+		{
+			// Get the attribute's value as a std::string
+			std::string temp;
+			if ( !GetAttributeImp( name, &temp ) )
+			{
+				if ( throwIfNotFound )
+				{
+					TICPPTHROW( "Attribute does not exist" );
+				}
+				else
+				{
+					return;
+				}
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Gets an attribute of @a name from an element.
+		Returns an empty string if the attribute does not exist.
+
+		@param name	The name of the attribute you are querying.
+		@return The value of the attribute, or an empty string if it does not exist.
+
+		@see GetAttributeOrDefault
+		*/
+		std::string GetAttribute( const std::string& name ) const;
+
+	private:
+
+		/**
+		@internal
+		Implimentation of the GetAttribute and GetAttributeOrDefault template methods.
+		*/
+		bool GetAttributeImp( const std::string& name, std::string* value ) const;
+
+		/**
+		@internal
+		Implimentation of the GetText, GetTextOrDefault, GetTextValue, and GetTextValueOrDefault template methods.
+		*/
+		bool GetTextImp( std::string* value ) const;
+	};
+
+	/** Wrapper around TiXmlDeclaration */
+	class Declaration : public NodeImp< TiXmlDeclaration >
+	{
+	public:
+		/**
+		Default	Constructor. Construct an empty declaration.
+		*/
+		Declaration();
+
+		/**
+		Constructor.
+		*/
+		Declaration( TiXmlDeclaration* declaration );
+
+		/**
+		Constructor.
+		*/
+		Declaration( const std::string& version, const std::string& encoding, const std::string& standalone );
+
+		/**
+		Version. Will return an empty string if none was found.
+		*/
+		std::string Version() const;
+
+		/**
+		Encoding. Will return an empty string if none was found.
+		*/
+		std::string Encoding() const;
+
+		/**
+		StandAlone. Is this a standalone document?
+		*/
+		std::string Standalone() const;
+	};
+
+	/** Wrapper around TiXmlStylesheetReference */
+	class StylesheetReference : public NodeImp< TiXmlStylesheetReference >
+	{
+	public:
+		/**
+		Default	Constructor. Construct an empty declaration.
+		*/
+		StylesheetReference();
+
+		/**
+		Constructor.
+		*/
+		StylesheetReference( TiXmlStylesheetReference* stylesheetReference );
+
+		/**
+		Constructor.
+		*/
+		StylesheetReference( const std::string& type, const std::string& href );
+
+		/**
+		Type. Will return an empty string if none was found.
+		*/
+		std::string Type() const;
+
+		/**
+		Href. Will return an empty string if none was found.
+		*/
+		std::string Href() const;
+	};
+}
+
+#endif	// TICPP_INCLUDED
+
+#endif // TIXML_USE_TICPP
Index: /code/branches/physics/src/tinyxml/ticpprc.h
===================================================================
--- /code/branches/physics/src/tinyxml/ticpprc.h	(revision 2122)
+++ /code/branches/physics/src/tinyxml/ticpprc.h	(revision 2122)
@@ -0,0 +1,116 @@
+#define TIXML_USE_TICPP
+
+/*
+http://code.google.com/p/ticpp/
+Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifdef TIXML_USE_TICPP
+
+#ifndef TICPPRC_INCLUDED
+#define TICPPRC_INCLUDED
+
+
+// Forward declare ticpp::Node, so it can be made a friend of TiCppRC
+namespace ticpp
+{
+	class Base;
+}
+
+// Forward declare TiCppRCImp so TiCppRC can hold a pointer to it
+class TiCppRCImp;
+
+/**
+Base class for reference counting functionality
+*/
+class TiCppRC
+{
+	// Allow ticpp::Node to directly modify reference count
+	friend class ticpp::Base;
+
+private:
+
+	TiCppRCImp* m_tiRC; /**< Pointer to reference counter */
+
+public:
+
+	/**
+	Constructor
+	Spawns new reference counter with a pointer to this
+	*/
+	TiCppRC();
+
+	/**
+	Destructor
+	Nullifies the pointer to this held by the reference counter
+	Decrements reference count
+	*/
+	virtual ~TiCppRC();
+};
+
+class TiCppRCImp
+{
+private:
+
+	int m_count;		/**< Holds reference count to me, and to the node I point to */
+
+	TiCppRC* m_tiCppRC;	/**< Holds pointer to an object inheriting TiCppRC */
+
+public:
+
+	/**
+	Initializes m_tiCppRC pointer, and set reference count to 1
+	*/
+	TiCppRCImp( TiCppRC* tiCppRC );
+
+	/**
+	Allows the TiCppRC object to set the pointer to itself ( m_tiCppRc ) to NULL when the TiCppRC object is deleted
+	*/
+	void Nullify();
+
+	/**
+	Increment Reference Count
+	*/
+	void IncRef();
+
+	/**
+	Decrement Reference Count
+	*/
+	void DecRef();
+
+	/**
+	Set Reference Count to 1 - dangerous! - Use only if you are sure of the consequences
+	*/
+	void InitRef();
+
+	/**
+	Get internal pointer to the TiCppRC object - not reference counted, use at your own risk
+	*/
+	TiCppRC* Get();
+
+	/**
+	Returns state of internal pointer - will be null if the object was deleted
+	*/
+	bool IsNull();
+};
+
+#endif // TICPP_INCLUDED
+
+#endif // TIXML_USE_TICPP
Index: /code/branches/physics/src/tinyxml/tinystr.cc
===================================================================
--- /code/branches/physics/src/tinyxml/tinystr.cc	(revision 2122)
+++ /code/branches/physics/src/tinyxml/tinystr.cc	(revision 2122)
@@ -0,0 +1,116 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original file by Yves Berquin.
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+/*
+ * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
+ */
+
+
+#ifndef TIXML_USE_STL
+
+#include "tinystr.h"
+
+// Error value for find primitive
+const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
+
+
+// Null rep.
+TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
+
+
+void TiXmlString::reserve (size_type cap)
+{
+	if (cap > capacity())
+	{
+		TiXmlString tmp;
+		tmp.init(length(), cap);
+		memcpy(tmp.start(), data(), length());
+		swap(tmp);
+	}
+}
+
+
+TiXmlString& TiXmlString::assign(const char* str, size_type len)
+{
+	size_type cap = capacity();
+	if (len > cap || cap > 3*(len + 8))
+	{
+		TiXmlString tmp;
+		tmp.init(len);
+		memcpy(tmp.start(), str, len);
+		swap(tmp);
+	}
+	else
+	{
+		memmove(start(), str, len);
+		set_size(len);
+	}
+	return *this;
+}
+
+
+TiXmlString& TiXmlString::append(const char* str, size_type len)
+{
+	size_type newsize = length() + len;
+	if (newsize > capacity())
+	{
+		reserve (newsize + capacity());
+	}
+	memmove(finish(), str, len);
+	set_size(newsize);
+	return *this;
+}
+
+
+TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
+{
+	TiXmlString tmp;
+	tmp.reserve(a.length() + b.length());
+	tmp += a;
+	tmp += b;
+	return tmp;
+}
+
+TiXmlString operator + (const TiXmlString & a, const char* b)
+{
+	TiXmlString tmp;
+	TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
+	tmp.reserve(a.length() + b_len);
+	tmp += a;
+	tmp.append(b, b_len);
+	return tmp;
+}
+
+TiXmlString operator + (const char* a, const TiXmlString & b)
+{
+	TiXmlString tmp;
+	TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
+	tmp.reserve(a_len + b.length());
+	tmp.append(a, a_len);
+	tmp += b;
+	return tmp;
+}
+
+
+#endif	// TIXML_USE_STL
Index: /code/branches/physics/src/tinyxml/tinystr.h
===================================================================
--- /code/branches/physics/src/tinyxml/tinystr.h	(revision 2122)
+++ /code/branches/physics/src/tinyxml/tinystr.h	(revision 2122)
@@ -0,0 +1,319 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original file by Yves Berquin.
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+/*
+ * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.
+ *
+ * - completely rewritten. compact, clean, and fast implementation.
+ * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)
+ * - fixed reserve() to work as per specification.
+ * - fixed buggy compares operator==(), operator<(), and operator>()
+ * - fixed operator+=() to take a const ref argument, following spec.
+ * - added "copy" constructor with length, and most compare operators.
+ * - added swap(), clear(), size(), capacity(), operator+().
+ */
+
+#ifndef TIXML_USE_STL
+
+#ifndef TIXML_STRING_INCLUDED
+#define TIXML_STRING_INCLUDED
+
+#include <assert.h>
+#include <string.h>
+
+/*	The support for explicit isn't that universal, and it isn't really
+	required - it is used to check that the TiXmlString class isn't incorrectly
+	used. Be nice to old compilers and macro it here:
+*/
+#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
+	// Microsoft visual studio, version 6 and higher.
+	#define TIXML_EXPLICIT explicit
+#elif defined(__GNUC__) && (__GNUC__ >= 3 )
+	// GCC version 3 and higher.s
+	#define TIXML_EXPLICIT explicit
+#else
+	#define TIXML_EXPLICIT
+#endif
+
+
+/*
+   TiXmlString is an emulation of a subset of the std::string template.
+   Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
+   Only the member functions relevant to the TinyXML project have been implemented.
+   The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
+   a string and there's no more room, we allocate a buffer twice as big as we need.
+*/
+class TiXmlString
+{
+  public :
+	// The size type used
+  	typedef size_t size_type;
+
+	// Error value for find primitive
+	static const size_type npos; // = -1;
+
+
+	// TiXmlString empty constructor
+	TiXmlString () : rep_(&nullrep_)
+	{
+	}
+
+	// TiXmlString copy constructor
+	TiXmlString ( const TiXmlString & copy) : rep_(0)
+	{
+		init(copy.length());
+		memcpy(start(), copy.data(), length());
+	}
+
+	// TiXmlString constructor, based on a string
+	TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
+	{
+		init( static_cast<size_type>( strlen(copy) ));
+		memcpy(start(), copy, length());
+	}
+
+	// TiXmlString constructor, based on a string
+	TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
+	{
+		init(len);
+		memcpy(start(), str, len);
+	}
+
+	// TiXmlString destructor
+	~TiXmlString ()
+	{
+		quit();
+	}
+
+	// = operator
+	TiXmlString& operator = (const char * copy)
+	{
+		return assign( copy, (size_type)strlen(copy));
+	}
+
+	// = operator
+	TiXmlString& operator = (const TiXmlString & copy)
+	{
+		return assign(copy.start(), copy.length());
+	}
+
+
+	// += operator. Maps to append
+	TiXmlString& operator += (const char * suffix)
+	{
+		return append(suffix, static_cast<size_type>( strlen(suffix) ));
+	}
+
+	// += operator. Maps to append
+	TiXmlString& operator += (char single)
+	{
+		return append(&single, 1);
+	}
+
+	// += operator. Maps to append
+	TiXmlString& operator += (const TiXmlString & suffix)
+	{
+		return append(suffix.data(), suffix.length());
+	}
+
+
+	// Convert a TiXmlString into a null-terminated char *
+	const char * c_str () const { return rep_->str; }
+
+	// Convert a TiXmlString into a char * (need not be null terminated).
+	const char * data () const { return rep_->str; }
+
+	// Return the length of a TiXmlString
+	size_type length () const { return rep_->size; }
+
+	// Alias for length()
+	size_type size () const { return rep_->size; }
+
+	// Checks if a TiXmlString is empty
+	bool empty () const { return rep_->size == 0; }
+
+	// Return capacity of string
+	size_type capacity () const { return rep_->capacity; }
+
+
+	// single char extraction
+	const char& at (size_type index) const
+	{
+		assert( index < length() );
+		return rep_->str[ index ];
+	}
+
+	// [] operator
+	char& operator [] (size_type index) const
+	{
+		assert( index < length() );
+		return rep_->str[ index ];
+	}
+
+	// find a char in a string. Return TiXmlString::npos if not found
+	size_type find (char lookup) const
+	{
+		return find(lookup, 0);
+	}
+
+	// find a char in a string from an offset. Return TiXmlString::npos if not found
+	size_type find (char tofind, size_type offset) const
+	{
+		if (offset >= length()) return npos;
+
+		for (const char* p = c_str() + offset; *p != '\0'; ++p)
+		{
+		   if (*p == tofind) return static_cast< size_type >( p - c_str() );
+		}
+		return npos;
+	}
+
+	void clear ()
+	{
+		//Lee:
+		//The original was just too strange, though correct:
+		//	TiXmlString().swap(*this);
+		//Instead use the quit & re-init:
+		quit();
+		init(0,0);
+	}
+
+	/*	Function to reserve a big amount of data when we know we'll need it. Be aware that this
+		function DOES NOT clear the content of the TiXmlString if any exists.
+	*/
+	void reserve (size_type cap);
+
+	TiXmlString& assign (const char* str, size_type len);
+
+	TiXmlString& append (const char* str, size_type len);
+
+	void swap (TiXmlString& other)
+	{
+		Rep* r = rep_;
+		rep_ = other.rep_;
+		other.rep_ = r;
+	}
+
+  private:
+
+	void init(size_type sz) { init(sz, sz); }
+	void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
+	char* start() const { return rep_->str; }
+	char* finish() const { return rep_->str + rep_->size; }
+
+	struct Rep
+	{
+		size_type size, capacity;
+		char str[1];
+	};
+
+	void init(size_type sz, size_type cap)
+	{
+		if (cap)
+		{
+			// Lee: the original form:
+			//	rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
+			// doesn't work in some cases of new being overloaded. Switching
+			// to the normal allocation, although use an 'int' for systems
+			// that are overly picky about structure alignment.
+			const size_type bytesNeeded = sizeof(Rep) + cap;
+			const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); 
+			rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
+
+			rep_->str[ rep_->size = sz ] = '\0';
+			rep_->capacity = cap;
+		}
+		else
+		{
+			rep_ = &nullrep_;
+		}
+	}
+
+	void quit()
+	{
+		if (rep_ != &nullrep_)
+		{
+			// The rep_ is really an array of ints. (see the allocator, above).
+			// Cast it back before delete, so the compiler won't incorrectly call destructors.
+			delete [] ( reinterpret_cast<int*>( rep_ ) );
+		}
+	}
+
+	Rep * rep_;
+	static Rep nullrep_;
+
+} ;
+
+
+inline bool operator == (const TiXmlString & a, const TiXmlString & b)
+{
+	return    ( a.length() == b.length() )				// optimization on some platforms
+	       && ( strcmp(a.c_str(), b.c_str()) == 0 );	// actual compare
+}
+inline bool operator < (const TiXmlString & a, const TiXmlString & b)
+{
+	return strcmp(a.c_str(), b.c_str()) < 0;
+}
+
+inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
+inline bool operator >  (const TiXmlString & a, const TiXmlString & b) { return b < a; }
+inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
+inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
+
+inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
+inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
+inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
+inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
+
+TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
+TiXmlString operator + (const TiXmlString & a, const char* b);
+TiXmlString operator + (const char* a, const TiXmlString & b);
+
+
+/*
+   TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
+   Only the operators that we need for TinyXML have been developped.
+*/
+class TiXmlOutStream : public TiXmlString
+{
+public :
+
+	// TiXmlOutStream << operator.
+	TiXmlOutStream & operator << (const TiXmlString & in)
+	{
+		*this += in;
+		return *this;
+	}
+
+	// TiXmlOutStream << operator.
+	TiXmlOutStream & operator << (const char * in)
+	{
+		*this += in;
+		return *this;
+	}
+
+} ;
+
+#endif	// TIXML_STRING_INCLUDED
+#endif	// TIXML_USE_STL
Index: /code/branches/physics/src/tinyxml/tinyxml.cc
===================================================================
--- /code/branches/physics/src/tinyxml/tinyxml.cc	(revision 2122)
+++ /code/branches/physics/src/tinyxml/tinyxml.cc	(revision 2122)
@@ -0,0 +1,1961 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+#include "tinyxml.h"
+
+#include <ctype.h>
+
+#ifdef TIXML_USE_STL
+#include <sstream>
+#include <iostream>
+#endif
+
+
+bool TiXmlBase::condenseWhiteSpace = true;
+
+// Microsoft compiler security
+FILE* TiXmlFOpen( const char* filename, const char* mode )
+{
+	#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
+		FILE* fp = 0;
+		errno_t err = fopen_s( &fp, filename, mode );
+		if ( !err && fp )
+			return fp;
+		return 0;
+	#else
+		return fopen( filename, mode );
+	#endif
+}
+
+void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
+{
+	int i=0;
+
+	while( i<(int)str.length() )
+	{
+		unsigned char c = (unsigned char) str[i];
+
+		if (    c == '&'
+		     && i < ( (int)str.length() - 2 )
+			 && str[i+1] == '#'
+			 && str[i+2] == 'x' )
+		{
+			// Hexadecimal character reference.
+			// Pass through unchanged.
+			// &#xA9;	-- copyright symbol, for example.
+			//
+			// The -1 is a bug fix from Rob Laveaux. It keeps
+			// an overflow from happening if there is no ';'.
+			// There are actually 2 ways to exit this loop -
+			// while fails (error case) and break (semicolon found).
+			// However, there is no mechanism (currently) for
+			// this function to return an error.
+			while ( i<(int)str.length()-1 )
+			{
+				outString->append( str.c_str() + i, 1 );
+				++i;
+				if ( str[i] == ';' )
+					break;
+			}
+		}
+		else if ( c == '&' )
+		{
+			outString->append( entity[0].str, entity[0].strLength );
+			++i;
+		}
+		else if ( c == '<' )
+		{
+			outString->append( entity[1].str, entity[1].strLength );
+			++i;
+		}
+		else if ( c == '>' )
+		{
+			outString->append( entity[2].str, entity[2].strLength );
+			++i;
+		}
+		else if ( c == '\"' )
+		{
+			outString->append( entity[3].str, entity[3].strLength );
+			++i;
+		}
+		else if ( c == '\'' )
+		{
+			outString->append( entity[4].str, entity[4].strLength );
+			++i;
+		}
+		else if ( c < 32 )
+		{
+			// Easy pass at non-alpha/numeric/symbol
+			// Below 32 is symbolic.
+			char buf[ 32 ];
+
+			#if defined(TIXML_SNPRINTF)
+				TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
+			#else
+				sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
+			#endif
+
+			//*ME:	warning C4267: convert 'size_t' to 'int'
+			//*ME:	Int-Cast to make compiler happy ...
+			outString->append( buf, (int)strlen( buf ) );
+			++i;
+		}
+		else
+		{
+			//char realc = (char) c;
+			//outString->append( &realc, 1 );
+			*outString += (char) c;	// somewhat more efficient function call.
+			++i;
+		}
+	}
+}
+
+
+TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
+{
+	parent = 0;
+	type = _type;
+	firstChild = 0;
+	lastChild = 0;
+	prev = 0;
+	next = 0;
+}
+
+
+TiXmlNode::~TiXmlNode()
+{
+	TiXmlNode* node = firstChild;
+	TiXmlNode* temp = 0;
+
+	while ( node )
+	{
+		temp = node;
+		node = node->next;
+		delete temp;
+	}
+}
+
+
+void TiXmlNode::CopyTo( TiXmlNode* target ) const
+{
+	target->SetValue (value.c_str() );
+	target->userData = userData;
+}
+
+
+void TiXmlNode::Clear()
+{
+	TiXmlNode* node = firstChild;
+	TiXmlNode* temp = 0;
+
+	while ( node )
+	{
+		temp = node;
+		node = node->next;
+		delete temp;
+	}
+
+	firstChild = 0;
+	lastChild = 0;
+}
+
+
+TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
+{
+	assert( node->parent == 0 || node->parent == this );
+	assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
+
+	if ( node->Type() == TiXmlNode::DOCUMENT )
+	{
+		delete node;
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	node->parent = this;
+
+	node->prev = lastChild;
+	node->next = 0;
+
+	if ( lastChild )
+		lastChild->next = node;
+	else
+		firstChild = node;			// it was an empty list.
+
+	lastChild = node;
+	return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+	TiXmlNode* node = addThis.Clone();
+	if ( !node )
+		return 0;
+
+	return LinkEndChild( node );
+}
+
+
+TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
+{
+	if ( !beforeThis || beforeThis->parent != this ) {
+		return 0;
+	}
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	TiXmlNode* node = addThis.Clone();
+	if ( !node )
+		return 0;
+	node->parent = this;
+
+	node->next = beforeThis;
+	node->prev = beforeThis->prev;
+	if ( beforeThis->prev )
+	{
+		beforeThis->prev->next = node;
+	}
+	else
+	{
+		assert( firstChild == beforeThis );
+		firstChild = node;
+	}
+	beforeThis->prev = node;
+	return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis )
+{
+	if ( !afterThis || afterThis->parent != this ) {
+		return 0;
+	}
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	TiXmlNode* node = addThis.Clone();
+	if ( !node )
+		return 0;
+	node->parent = this;
+
+	node->prev = afterThis;
+	node->next = afterThis->next;
+	if ( afterThis->next )
+	{
+		afterThis->next->prev = node;
+	}
+	else
+	{
+		assert( lastChild == afterThis );
+		lastChild = node;
+	}
+	afterThis->next = node;
+	return node;
+}
+
+
+TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
+{
+	if ( replaceThis->parent != this )
+		return 0;
+
+	TiXmlNode* node = withThis.Clone();
+	if ( !node )
+		return 0;
+
+	node->next = replaceThis->next;
+	node->prev = replaceThis->prev;
+
+	if ( replaceThis->next )
+		replaceThis->next->prev = node;
+	else
+		lastChild = node;
+
+	if ( replaceThis->prev )
+		replaceThis->prev->next = node;
+	else
+		firstChild = node;
+
+	delete replaceThis;
+	node->parent = this;
+	return node;
+}
+
+
+bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
+{
+	if ( removeThis->parent != this )
+	{
+		assert( 0 );
+		return false;
+	}
+
+	if ( removeThis->next )
+		removeThis->next->prev = removeThis->prev;
+	else
+		lastChild = removeThis->prev;
+
+	if ( removeThis->prev )
+		removeThis->prev->next = removeThis->next;
+	else
+		firstChild = removeThis->next;
+
+	delete removeThis;
+	return true;
+}
+
+const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = firstChild; node; node = node->next )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = lastChild; node; node = node->prev )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const
+{
+	if ( !previous )
+	{
+		return FirstChild();
+	}
+	else
+	{
+		assert( previous->parent == this );
+		return previous->NextSibling();
+	}
+}
+
+
+const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const
+{
+	if ( !previous )
+	{
+		return FirstChild( val );
+	}
+	else
+	{
+		assert( previous->parent == this );
+		return previous->NextSibling( val );
+	}
+}
+
+
+const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = next; node; node = node->next )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = prev; node; node = node->prev )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+void TiXmlElement::RemoveAttribute( const char * name )
+{
+    #ifdef TIXML_USE_STL
+	TIXML_STRING str( name );
+	TiXmlAttribute* node = attributeSet.Find( str );
+	#else
+	TiXmlAttribute* node = attributeSet.Find( name );
+	#endif
+	if ( node )
+	{
+		attributeSet.Remove( node );
+		delete node;
+	}
+}
+
+const TiXmlElement* TiXmlNode::FirstChildElement() const
+{
+	const TiXmlNode* node;
+
+	for (	node = FirstChild();
+			node;
+			node = node->NextSibling() )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const
+{
+	const TiXmlNode* node;
+
+	for (	node = FirstChild( _value );
+			node;
+			node = node->NextSibling( _value ) )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlElement* TiXmlNode::NextSiblingElement() const
+{
+	const TiXmlNode* node;
+
+	for (	node = NextSibling();
+			node;
+			node = node->NextSibling() )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const
+{
+	const TiXmlNode* node;
+
+	for (	node = NextSibling( _value );
+			node;
+			node = node->NextSibling( _value ) )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlDocument* TiXmlNode::GetDocument() const
+{
+	const TiXmlNode* node;
+
+	for( node = this; node; node = node->parent )
+	{
+		if ( node->ToDocument() )
+			return node->ToDocument();
+	}
+	return 0;
+}
+
+
+TiXmlElement::TiXmlElement (const char * _value)
+	: TiXmlNode( TiXmlNode::ELEMENT )
+{
+	firstChild = lastChild = 0;
+	value = _value;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlElement::TiXmlElement( const std::string& _value )
+	: TiXmlNode( TiXmlNode::ELEMENT )
+{
+	firstChild = lastChild = 0;
+	value = _value;
+}
+#endif
+
+
+TiXmlElement::TiXmlElement( const TiXmlElement& copy)
+	: TiXmlNode( TiXmlNode::ELEMENT )
+{
+	firstChild = lastChild = 0;
+	copy.CopyTo( this );
+}
+
+
+void TiXmlElement::operator=( const TiXmlElement& base )
+{
+	ClearThis();
+	base.CopyTo( this );
+}
+
+
+TiXmlElement::~TiXmlElement()
+{
+	ClearThis();
+}
+
+
+void TiXmlElement::ClearThis()
+{
+	Clear();
+	while( attributeSet.First() )
+	{
+		TiXmlAttribute* node = attributeSet.First();
+		attributeSet.Remove( node );
+		delete node;
+	}
+}
+
+
+const char* TiXmlElement::Attribute( const char* name ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( node )
+		return node->Value();
+	return 0;
+}
+
+
+#ifdef TIXML_USE_STL
+const std::string* TiXmlElement::Attribute( const std::string& name ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( node )
+		return &node->ValueStr();
+	return 0;
+}
+#endif
+
+
+const char* TiXmlElement::Attribute( const char* name, int* i ) const
+{
+	const char* s = Attribute( name );
+	if ( i )
+	{
+		if ( s ) {
+			*i = atoi( s );
+		}
+		else {
+			*i = 0;
+		}
+	}
+	return s;
+}
+
+
+#ifdef TIXML_USE_STL
+const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
+{
+	const std::string* s = Attribute( name );
+	if ( i )
+	{
+		if ( s ) {
+			*i = atoi( s->c_str() );
+		}
+		else {
+			*i = 0;
+		}
+	}
+	return s;
+}
+#endif
+
+
+const char* TiXmlElement::Attribute( const char* name, double* d ) const
+{
+	const char* s = Attribute( name );
+	if ( d )
+	{
+		if ( s ) {
+			*d = atof( s );
+		}
+		else {
+			*d = 0;
+		}
+	}
+	return s;
+}
+
+
+#ifdef TIXML_USE_STL
+const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const
+{
+	const std::string* s = Attribute( name );
+	if ( d )
+	{
+		if ( s ) {
+			*d = atof( s->c_str() );
+		}
+		else {
+			*d = 0;
+		}
+	}
+	return s;
+}
+#endif
+
+
+int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryIntValue( ival );
+}
+
+
+#ifdef TIXML_USE_STL
+int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryIntValue( ival );
+}
+#endif
+
+
+int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryDoubleValue( dval );
+}
+
+
+#ifdef TIXML_USE_STL
+int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryDoubleValue( dval );
+}
+#endif
+
+
+void TiXmlElement::SetAttribute( const char * name, int val )
+{
+	char buf[64];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
+	#else
+		sprintf( buf, "%d", val );
+	#endif
+	SetAttribute( name, buf );
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlElement::SetAttribute( const std::string& name, int val )
+{
+   std::ostringstream oss;
+   oss << val;
+   SetAttribute( name, oss.str() );
+}
+#endif
+
+
+void TiXmlElement::SetDoubleAttribute( const char * name, double val )
+{
+	char buf[256];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
+	#else
+		sprintf( buf, "%f", val );
+	#endif
+	SetAttribute( name, buf );
+}
+
+
+void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
+{
+    #ifdef TIXML_USE_STL
+	TIXML_STRING _name( cname );
+	TIXML_STRING _value( cvalue );
+	#else
+	const char* _name = cname;
+	const char* _value = cvalue;
+	#endif
+
+	TiXmlAttribute* node = attributeSet.Find( _name );
+	if ( node )
+	{
+		node->SetValue( _value );
+		return;
+	}
+
+	TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
+	if ( attrib )
+	{
+		attributeSet.Add( attrib );
+	}
+	else
+	{
+		TiXmlDocument* document = GetDocument();
+		if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+	}
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value )
+{
+	TiXmlAttribute* node = attributeSet.Find( name );
+	if ( node )
+	{
+		node->SetValue( _value );
+		return;
+	}
+
+	TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
+	if ( attrib )
+	{
+		attributeSet.Add( attrib );
+	}
+	else
+	{
+		TiXmlDocument* document = GetDocument();
+		if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+	}
+}
+#endif
+
+
+void TiXmlElement::Print( FILE* cfile, int depth ) const
+{
+	int i;
+	assert( cfile );
+	for ( i=0; i<depth; i++ ) {
+		fprintf( cfile, "    " );
+	}
+
+	fprintf( cfile, "<%s", value.c_str() );
+
+	const TiXmlAttribute* attrib;
+	for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
+	{
+		fprintf( cfile, " " );
+		attrib->Print( cfile, depth );
+	}
+
+	// There are 3 different formatting approaches:
+	// 1) An element without children is printed as a <foo /> node
+	// 2) An element with only a text child is printed as <foo> text </foo>
+	// 3) An element with children is printed on multiple lines.
+	TiXmlNode* node;
+	if ( !firstChild )
+	{
+		fprintf( cfile, " />" );
+	}
+	else if ( firstChild == lastChild && firstChild->ToText() )
+	{
+		fprintf( cfile, ">" );
+		firstChild->Print( cfile, depth + 1 );
+		fprintf( cfile, "</%s>", value.c_str() );
+	}
+	else
+	{
+		fprintf( cfile, ">" );
+
+		for ( node = firstChild; node; node=node->NextSibling() )
+		{
+			if ( !node->ToText() )
+			{
+				fprintf( cfile, "\n" );
+			}
+			node->Print( cfile, depth+1 );
+		}
+		fprintf( cfile, "\n" );
+		for( i=0; i<depth; ++i ) {
+			fprintf( cfile, "    " );
+		}
+		fprintf( cfile, "</%s>", value.c_str() );
+	}
+}
+
+
+void TiXmlElement::CopyTo( TiXmlElement* target ) const
+{
+	// superclass:
+	TiXmlNode::CopyTo( target );
+
+	// Element class:
+	// Clone the attributes, then clone the children.
+	const TiXmlAttribute* attribute = 0;
+	for(	attribute = attributeSet.First();
+	attribute;
+	attribute = attribute->Next() )
+	{
+		target->SetAttribute( attribute->Name(), attribute->Value() );
+	}
+
+	TiXmlNode* node = 0;
+	for ( node = firstChild; node; node = node->NextSibling() )
+	{
+		target->LinkEndChild( node->Clone() );
+	}
+}
+
+bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const
+{
+	if ( visitor->VisitEnter( *this, attributeSet.First() ) )
+	{
+		for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
+		{
+			if ( !node->Accept( visitor ) )
+				break;
+		}
+	}
+	return visitor->VisitExit( *this );
+}
+
+
+TiXmlNode* TiXmlElement::Clone() const
+{
+	TiXmlElement* clone = new TiXmlElement( Value() );
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+const char* TiXmlElement::GetText() const
+{
+	const TiXmlNode* child = this->FirstChild();
+	if ( child ) {
+		const TiXmlText* childText = child->ToText();
+		if ( childText ) {
+			return childText->Value();
+		}
+	}
+	return 0;
+}
+
+
+TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	tabsize = 4;
+	useMicrosoftBOM = false;
+	ClearError();
+}
+
+TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	tabsize = 4;
+	useMicrosoftBOM = false;
+	value = documentName;
+	ClearError();
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	tabsize = 4;
+	useMicrosoftBOM = false;
+    value = documentName;
+	ClearError();
+}
+#endif
+
+
+TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlDocument::operator=( const TiXmlDocument& copy )
+{
+	Clear();
+	copy.CopyTo( this );
+}
+
+
+bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
+{
+	// See STL_STRING_BUG below.
+	//StringToBuffer buf( value );
+
+	return LoadFile( Value(), encoding );
+}
+
+
+bool TiXmlDocument::SaveFile() const
+{
+	// See STL_STRING_BUG below.
+//	StringToBuffer buf( value );
+//
+//	if ( buf.buffer && SaveFile( buf.buffer ) )
+//		return true;
+//
+//	return false;
+	return SaveFile( Value() );
+}
+
+bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
+{
+	// There was a really terrifying little bug here. The code:
+	//		value = filename
+	// in the STL case, cause the assignment method of the std::string to
+	// be called. What is strange, is that the std::string had the same
+	// address as it's c_str() method, and so bad things happen. Looks
+	// like a bug in the Microsoft STL implementation.
+	// Add an extra string to avoid the crash.
+	TIXML_STRING filename( _filename );
+	value = filename;
+
+	// reading in binary mode so that tinyxml can normalize the EOL
+	FILE* file = TiXmlFOpen( value.c_str (), "rb" );
+
+	if ( file )
+	{
+		bool result = LoadFile( file, encoding );
+		fclose( file );
+		return result;
+	}
+	else
+	{
+		SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+}
+
+bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
+{
+	if ( !file )
+	{
+		SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+
+	// Delete the existing data:
+	Clear();
+	location.Clear();
+
+	// Get the file size, so we can pre-allocate the string. HUGE speed impact.
+	long length = 0;
+	fseek( file, 0, SEEK_END );
+	length = ftell( file );
+	fseek( file, 0, SEEK_SET );
+
+	// Strange case, but good to handle up front.
+	if ( length <= 0 )
+	{
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+
+	// If we have a file, assume it is all one big XML file, and read it in.
+	// The document parser may decide the document ends sooner than the entire file, however.
+	TIXML_STRING data;
+	data.reserve( length );
+
+	// Subtle bug here. TinyXml did use fgets. But from the XML spec:
+	// 2.11 End-of-Line Handling
+	// <snip>
+	// <quote>
+	// ...the XML processor MUST behave as if it normalized all line breaks in external
+	// parsed entities (including the document entity) on input, before parsing, by translating
+	// both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
+	// a single #xA character.
+	// </quote>
+	//
+	// It is not clear fgets does that, and certainly isn't clear it works cross platform.
+	// Generally, you expect fgets to translate from the convention of the OS to the c/unix
+	// convention, and not work generally.
+
+	/*
+	while( fgets( buf, sizeof(buf), file ) )
+	{
+		data += buf;
+	}
+	*/
+
+	char* buf = new char[ length+1 ];
+	buf[0] = 0;
+
+	if ( fread( buf, length, 1, file ) != 1 ) {
+		delete [] buf;
+		SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+
+	const char* lastPos = buf;
+	const char* p = buf;
+
+	buf[length] = 0;
+	while( *p ) {
+		assert( p < (buf+length) );
+		if ( *p == 0xa ) {
+			// Newline character. No special rules for this. Append all the characters
+			// since the last string, and include the newline.
+			data.append( lastPos, (p-lastPos+1) );	// append, include the newline
+			++p;									// move past the newline
+			lastPos = p;							// and point to the new buffer (may be 0)
+			assert( p <= (buf+length) );
+		}
+		else if ( *p == 0xd ) {
+			// Carriage return. Append what we have so far, then
+			// handle moving forward in the buffer.
+			if ( (p-lastPos) > 0 ) {
+				data.append( lastPos, p-lastPos );	// do not add the CR
+			}
+			data += (char)0xa;						// a proper newline
+
+			if ( *(p+1) == 0xa ) {
+				// Carriage return - new line sequence
+				p += 2;
+				lastPos = p;
+				assert( p <= (buf+length) );
+			}
+			else {
+				// it was followed by something else...that is presumably characters again.
+				++p;
+				lastPos = p;
+				assert( p <= (buf+length) );
+			}
+		}
+		else {
+			++p;
+		}
+	}
+	// Handle any left over characters.
+	if ( p-lastPos ) {
+		data.append( lastPos, p-lastPos );
+	}
+	delete [] buf;
+	buf = 0;
+
+	Parse( data.c_str(), 0, encoding );
+
+	if (  Error() )
+        return false;
+    else
+		return true;
+}
+
+
+bool TiXmlDocument::SaveFile( const char * filename ) const
+{
+	// The old c stuff lives on...
+	FILE* fp = TiXmlFOpen( filename, "w" );
+	if ( fp )
+	{
+		bool result = SaveFile( fp );
+		fclose( fp );
+		return result;
+	}
+	return false;
+}
+
+
+bool TiXmlDocument::SaveFile( FILE* fp ) const
+{
+	if ( useMicrosoftBOM )
+	{
+		const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
+		const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
+		const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
+
+		fputc( TIXML_UTF_LEAD_0, fp );
+		fputc( TIXML_UTF_LEAD_1, fp );
+		fputc( TIXML_UTF_LEAD_2, fp );
+	}
+	Print( fp, 0 );
+	return (ferror(fp) == 0);
+}
+
+
+void TiXmlDocument::CopyTo( TiXmlDocument* target ) const
+{
+	TiXmlNode::CopyTo( target );
+
+	target->error = error;
+	target->errorId = errorId;
+	target->errorDesc = errorDesc;
+	target->tabsize = tabsize;
+	target->errorLocation = errorLocation;
+	target->useMicrosoftBOM = useMicrosoftBOM;
+
+	TiXmlNode* node = 0;
+	for ( node = firstChild; node; node = node->NextSibling() )
+	{
+		target->LinkEndChild( node->Clone() );
+	}
+}
+
+
+TiXmlNode* TiXmlDocument::Clone() const
+{
+	TiXmlDocument* clone = new TiXmlDocument();
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+void TiXmlDocument::Print( FILE* cfile, int depth ) const
+{
+	assert( cfile );
+	for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
+	{
+		node->Print( cfile, depth );
+		fprintf( cfile, "\n" );
+	}
+}
+
+
+bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const
+{
+	if ( visitor->VisitEnter( *this ) )
+	{
+		for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
+		{
+			if ( !node->Accept( visitor ) )
+				break;
+		}
+	}
+	return visitor->VisitExit( *this );
+}
+
+
+const TiXmlAttribute* TiXmlAttribute::Next() const
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( next->value.empty() && next->name.empty() )
+		return 0;
+	return next;
+}
+
+/*
+TiXmlAttribute* TiXmlAttribute::Next()
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( next->value.empty() && next->name.empty() )
+		return 0;
+	return next;
+}
+*/
+
+const TiXmlAttribute* TiXmlAttribute::Previous() const
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( prev->value.empty() && prev->name.empty() )
+		return 0;
+	return prev;
+}
+
+/*
+TiXmlAttribute* TiXmlAttribute::Previous()
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( prev->value.empty() && prev->name.empty() )
+		return 0;
+	return prev;
+}
+*/
+
+void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
+{
+	TIXML_STRING n, v;
+
+	EncodeString( name, &n );
+	EncodeString( value, &v );
+
+	if (value.find ('\"') == TIXML_STRING::npos) {
+		if ( cfile ) {
+		fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
+		}
+		if ( str ) {
+			(*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
+		}
+	}
+	else {
+		if ( cfile ) {
+		fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
+		}
+		if ( str ) {
+			(*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
+		}
+	}
+}
+
+
+int TiXmlAttribute::QueryIntValue( int* ival ) const
+{
+	if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 )
+		return TIXML_SUCCESS;
+	return TIXML_WRONG_TYPE;
+}
+
+int TiXmlAttribute::QueryDoubleValue( double* dval ) const
+{
+	if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 )
+		return TIXML_SUCCESS;
+	return TIXML_WRONG_TYPE;
+}
+
+void TiXmlAttribute::SetIntValue( int _value )
+{
+	char buf [64];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
+	#else
+		sprintf (buf, "%d", _value);
+	#endif
+	SetValue (buf);
+}
+
+void TiXmlAttribute::SetDoubleValue( double _value )
+{
+	char buf [256];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value);
+	#else
+		sprintf (buf, "%lf", _value);
+	#endif
+	SetValue (buf);
+}
+
+int TiXmlAttribute::IntValue() const
+{
+	return atoi (value.c_str ());
+}
+
+double  TiXmlAttribute::DoubleValue() const
+{
+	return atof (value.c_str ());
+}
+
+
+TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlComment::operator=( const TiXmlComment& base )
+{
+	Clear();
+	base.CopyTo( this );
+}
+
+
+void TiXmlComment::Print( FILE* cfile, int depth ) const
+{
+	assert( cfile );
+	for ( int i=0; i<depth; i++ )
+	{
+		fprintf( cfile,  "    " );
+	}
+	fprintf( cfile, "<!--%s-->", value.c_str() );
+}
+
+
+void TiXmlComment::CopyTo( TiXmlComment* target ) const
+{
+	TiXmlNode::CopyTo( target );
+}
+
+
+bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlComment::Clone() const
+{
+	TiXmlComment* clone = new TiXmlComment();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+void TiXmlText::Print( FILE* cfile, int depth ) const
+{
+	assert( cfile );
+	if ( cdata )
+	{
+		int i;
+		fprintf( cfile, "\n" );
+		for ( i=0; i<depth; i++ ) {
+			fprintf( cfile, "    " );
+		}
+		fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() );	// unformatted output
+	}
+	else
+	{
+		TIXML_STRING buffer;
+		EncodeString( value, &buffer );
+		fprintf( cfile, "%s", buffer.c_str() );
+	}
+}
+
+
+void TiXmlText::CopyTo( TiXmlText* target ) const
+{
+	TiXmlNode::CopyTo( target );
+	target->cdata = cdata;
+}
+
+
+bool TiXmlText::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlText::Clone() const
+{
+	TiXmlText* clone = 0;
+	clone = new TiXmlText( "" );
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+TiXmlDeclaration::TiXmlDeclaration( const char * _version,
+									const char * _encoding,
+									const char * _standalone )
+	: TiXmlNode( TiXmlNode::DECLARATION )
+{
+	version = _version;
+	encoding = _encoding;
+	standalone = _standalone;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDeclaration::TiXmlDeclaration(	const std::string& _version,
+									const std::string& _encoding,
+									const std::string& _standalone )
+	: TiXmlNode( TiXmlNode::DECLARATION )
+{
+	version = _version;
+	encoding = _encoding;
+	standalone = _standalone;
+}
+#endif
+
+
+TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
+	: TiXmlNode( TiXmlNode::DECLARATION )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
+{
+	Clear();
+	copy.CopyTo( this );
+}
+
+
+void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
+{
+	if ( cfile ) fprintf( cfile, "<?xml " );
+	if ( str )	 (*str) += "<?xml ";
+
+	if ( !version.empty() ) {
+		if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ());
+		if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }
+	}
+	if ( !encoding.empty() ) {
+		if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
+		if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }
+	}
+	if ( !standalone.empty() ) {
+		if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
+		if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }
+	}
+	if ( cfile ) fprintf( cfile, "?>" );
+	if ( str )	 (*str) += "?>";
+}
+
+
+void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const
+{
+	TiXmlNode::CopyTo( target );
+
+	target->version = version;
+	target->encoding = encoding;
+	target->standalone = standalone;
+}
+
+
+bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlDeclaration::Clone() const
+{
+	TiXmlDeclaration* clone = new TiXmlDeclaration();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+TiXmlStylesheetReference::TiXmlStylesheetReference( const char * _type,
+													const char * _href )
+	: TiXmlNode( TiXmlNode::STYLESHEETREFERENCE )
+{
+	type = _type;
+	href = _href;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlStylesheetReference::TiXmlStylesheetReference(	const std::string& _type,
+													const std::string& _href )
+	: TiXmlNode( TiXmlNode::STYLESHEETREFERENCE )
+{
+	type = _type;
+	href = _href;
+}
+#endif
+
+
+TiXmlStylesheetReference::TiXmlStylesheetReference( const TiXmlStylesheetReference& copy )
+	: TiXmlNode( TiXmlNode::STYLESHEETREFERENCE )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlStylesheetReference::operator=( const TiXmlStylesheetReference& copy )
+{
+	Clear();
+	copy.CopyTo( this );
+}
+
+
+void TiXmlStylesheetReference::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
+{
+	if ( cfile ) fprintf( cfile, "<?xml-stylesheet " );
+	if ( str )	 (*str) += "<?xml-stylesheet ";
+
+	if ( !type.empty() ) {
+		if ( cfile ) fprintf (cfile, "type=\"%s\" ", type.c_str ());
+		if ( str ) { (*str) += "type=\""; (*str) += type; (*str) += "\" "; }
+	}
+	if ( !href.empty() ) {
+		if ( cfile ) fprintf (cfile, "href=\"%s\" ", href.c_str ());
+		if ( str ) { (*str) += "href=\""; (*str) += href; (*str) += "\" "; }
+	}
+	if ( cfile ) fprintf (cfile, "?>");
+	if ( str )	 (*str) += "?>";
+}
+
+void TiXmlStylesheetReference::CopyTo( TiXmlStylesheetReference* target ) const
+{
+	TiXmlNode::CopyTo( target );
+
+	target->type = type;
+	target->href = href;
+}
+
+bool TiXmlStylesheetReference::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+TiXmlNode* TiXmlStylesheetReference::Clone() const
+{
+	TiXmlStylesheetReference* clone = new TiXmlStylesheetReference();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+void TiXmlUnknown::Print( FILE* cfile, int depth ) const
+{
+	for ( int i=0; i<depth; i++ )
+		fprintf( cfile, "    " );
+	fprintf( cfile, "<%s>", value.c_str() );
+}
+
+
+void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const
+{
+	TiXmlNode::CopyTo( target );
+}
+
+
+bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlUnknown::Clone() const
+{
+	TiXmlUnknown* clone = new TiXmlUnknown();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+TiXmlAttributeSet::TiXmlAttributeSet()
+{
+	sentinel.next = &sentinel;
+	sentinel.prev = &sentinel;
+}
+
+
+TiXmlAttributeSet::~TiXmlAttributeSet()
+{
+	assert( sentinel.next == &sentinel );
+	assert( sentinel.prev == &sentinel );
+}
+
+
+void TiXmlAttributeSet::Add( TiXmlAttribute* addMe )
+{
+    #ifdef TIXML_USE_STL
+	assert( !Find( TIXML_STRING( addMe->Name() ) ) );	// Shouldn't be multiply adding to the set.
+	#else
+	assert( !Find( addMe->Name() ) );	// Shouldn't be multiply adding to the set.
+	#endif
+
+	addMe->next = &sentinel;
+	addMe->prev = sentinel.prev;
+
+	sentinel.prev->next = addMe;
+	sentinel.prev      = addMe;
+}
+
+void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
+{
+	TiXmlAttribute* node;
+
+	for( node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( node == removeMe )
+		{
+			node->prev->next = node->next;
+			node->next->prev = node->prev;
+			node->next = 0;
+			node->prev = 0;
+			return;
+		}
+	}
+	assert( 0 );		// we tried to remove a non-linked attribute.
+}
+
+
+#ifdef TIXML_USE_STL
+const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
+{
+	for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( node->name == name )
+			return node;
+	}
+	return 0;
+}
+
+/*
+TiXmlAttribute*	TiXmlAttributeSet::Find( const std::string& name )
+{
+	for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( node->name == name )
+			return node;
+	}
+	return 0;
+}
+*/
+#endif
+
+
+const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
+{
+	for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( strcmp( node->name.c_str(), name ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+/*
+TiXmlAttribute*	TiXmlAttributeSet::Find( const char* name )
+{
+	for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( strcmp( node->name.c_str(), name ) == 0 )
+			return node;
+	}
+	return 0;
+}
+*/
+
+#ifdef TIXML_USE_STL
+std::istream& operator>> (std::istream & in, TiXmlNode & base)
+{
+	TIXML_STRING tag;
+	tag.reserve( 8 * 1000 );
+	base.StreamIn( &in, &tag );
+
+	base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
+	return in;
+}
+#endif
+
+
+#ifdef TIXML_USE_STL
+std::ostream& operator<< (std::ostream & out, const TiXmlNode & base)
+{
+	TiXmlPrinter printer;
+	printer.SetStreamPrinting();
+	base.Accept( &printer );
+	out << printer.Str();
+
+	return out;
+}
+
+
+std::string& operator<< (std::string& out, const TiXmlNode& base )
+{
+	TiXmlPrinter printer;
+	printer.SetStreamPrinting();
+	base.Accept( &printer );
+	out.append( printer.Str() );
+
+	return out;
+}
+#endif
+
+
+TiXmlHandle TiXmlHandle::FirstChild() const
+{
+	if ( node )
+	{
+		TiXmlNode* child = node->FirstChild();
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const
+{
+	if ( node )
+	{
+		TiXmlNode* child = node->FirstChild( value );
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement() const
+{
+	if ( node )
+	{
+		TiXmlElement* child = node->FirstChildElement();
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const
+{
+	if ( node )
+	{
+		TiXmlElement* child = node->FirstChildElement( value );
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::Child( int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlNode* child = node->FirstChild();
+		for (	i=0;
+				child && i<count;
+				child = child->NextSibling(), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlNode* child = node->FirstChild( value );
+		for (	i=0;
+				child && i<count;
+				child = child->NextSibling( value ), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement( int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlElement* child = node->FirstChildElement();
+		for (	i=0;
+				child && i<count;
+				child = child->NextSiblingElement(), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlElement* child = node->FirstChildElement( value );
+		for (	i=0;
+				child && i<count;
+				child = child->NextSiblingElement( value ), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+bool TiXmlPrinter::VisitEnter( const TiXmlDocument& )
+{
+	return true;
+}
+
+bool TiXmlPrinter::VisitExit( const TiXmlDocument& )
+{
+	return true;
+}
+
+bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
+{
+	DoIndent();
+	buffer += "<";
+	buffer += element.Value();
+
+	for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )
+	{
+		buffer += " ";
+		attrib->Print( 0, 0, &buffer );
+	}
+
+	if ( !element.FirstChild() )
+	{
+		buffer += " />";
+		DoLineBreak();
+	}
+	else
+	{
+		buffer += ">";
+		if (    element.FirstChild()->ToText()
+			  && element.LastChild() == element.FirstChild()
+			  && element.FirstChild()->ToText()->CDATA() == false )
+		{
+			simpleTextPrint = true;
+			// no DoLineBreak()!
+		}
+		else
+		{
+			DoLineBreak();
+		}
+	}
+	++depth;
+	return true;
+}
+
+
+bool TiXmlPrinter::VisitExit( const TiXmlElement& element )
+{
+	--depth;
+	if ( !element.FirstChild() )
+	{
+		// nothing.
+	}
+	else
+	{
+		if ( simpleTextPrint )
+		{
+			simpleTextPrint = false;
+		}
+		else
+		{
+			DoIndent();
+		}
+		buffer += "</";
+		buffer += element.Value();
+		buffer += ">";
+		DoLineBreak();
+	}
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlText& text )
+{
+	if ( text.CDATA() )
+	{
+		DoIndent();
+		buffer += "<![CDATA[";
+		buffer += text.Value();
+		buffer += "]]>";
+		DoLineBreak();
+	}
+	else if ( simpleTextPrint )
+	{
+		TIXML_STRING str;
+		TiXmlBase::EncodeString( text.ValueTStr(), &str );
+		buffer += str;
+	}
+	else
+	{
+		DoIndent();
+		TIXML_STRING str;
+		TiXmlBase::EncodeString( text.ValueTStr(), &str );
+		buffer += str;
+		DoLineBreak();
+	}
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration )
+{
+	DoIndent();
+	declaration.Print( 0, 0, &buffer );
+	DoLineBreak();
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlComment& comment )
+{
+	DoIndent();
+	buffer += "<!--";
+	buffer += comment.Value();
+	buffer += "-->";
+	DoLineBreak();
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown )
+{
+	DoIndent();
+	buffer += "<";
+	buffer += unknown.Value();
+	buffer += ">";
+	DoLineBreak();
+	return true;
+}
+
Index: /code/branches/physics/src/tinyxml/tinyxml.h
===================================================================
--- /code/branches/physics/src/tinyxml/tinyxml.h	(revision 2122)
+++ /code/branches/physics/src/tinyxml/tinyxml.h	(revision 2122)
@@ -0,0 +1,1885 @@
+#define TIXML_USE_TICPP
+
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+
+#ifndef TINYXML_INCLUDED
+#define TINYXML_INCLUDED
+
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable : 4530 )
+#pragma warning( disable : 4786 )
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+// Help out windows:
+#if defined( _DEBUG ) && !defined( DEBUG )
+#define DEBUG
+#endif
+
+#ifdef TIXML_USE_TICPP
+	#ifndef TIXML_USE_STL
+		#define TIXML_USE_STL
+	#endif
+#endif
+
+#ifdef TIXML_USE_STL
+	#include <string>
+ 	#include <iostream>
+	#include <sstream>
+	#define TIXML_STRING		std::string
+#else
+	#include "tinystr.h"
+	#define TIXML_STRING		TiXmlString
+#endif
+
+// Deprecated library function hell. Compilers want to use the
+// new safe versions. This probably doesn't fully address the problem,
+// but it gets closer. There are too many compilers for me to fully
+// test. If you get compilation troubles, undefine TIXML_SAFE
+#define TIXML_SAFE
+
+#ifdef TIXML_SAFE
+	#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
+		// Microsoft visual studio, version 2005 and higher.
+		#define TIXML_SNPRINTF _snprintf_s
+		#define TIXML_SNSCANF  _snscanf_s
+		#define TIXML_SSCANF   sscanf_s
+	#elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
+		// Microsoft visual studio, version 6 and higher.
+		//#pragma message( "Using _sn* functions." )
+		#define TIXML_SNPRINTF _snprintf
+		#define TIXML_SNSCANF  _snscanf
+		#define TIXML_SSCANF   sscanf
+	#elif defined(__GNUC__) && (__GNUC__ >= 3 )
+		// GCC version 3 and higher.s
+		//#warning( "Using sn* functions." )
+		#define TIXML_SNPRINTF snprintf
+		#define TIXML_SNSCANF  snscanf
+		#define TIXML_SSCANF   sscanf
+	#else
+		#define TIXML_SSCANF   sscanf
+	#endif
+#endif
+
+class TiXmlDocument;
+class TiXmlElement;
+class TiXmlComment;
+class TiXmlUnknown;
+class TiXmlAttribute;
+class TiXmlText;
+class TiXmlDeclaration;
+class TiXmlStylesheetReference;
+class TiXmlParsingData;
+
+const int TIXML_MAJOR_VERSION = 2;
+const int TIXML_MINOR_VERSION = 5;
+const int TIXML_PATCH_VERSION = 3;
+
+/*	Internal structure for tracking location of items
+	in the XML file.
+*/
+struct TiXmlCursor
+{
+	TiXmlCursor()		{ Clear(); }
+	void Clear()		{ row = col = -1; }
+
+	int row;	// 0 based.
+	int col;	// 0 based.
+};
+
+
+/**
+	If you call the Accept() method, it requires being passed a TiXmlVisitor
+	class to handle callbacks. For nodes that contain other nodes (Document, Element)
+	you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
+	are simple called with Visit().
+
+	If you return 'true' from a Visit method, recursive parsing will continue. If you return
+	false, <b>no children of this node or its sibilings</b> will be Visited.
+
+	All flavors of Visit methods have a default implementation that returns 'true' (continue
+	visiting). You need to only override methods that are interesting to you.
+
+	Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting.
+
+	You should never change the document from a callback.
+
+	@sa TiXmlNode::Accept()
+*/
+class TiXmlVisitor
+{
+public:
+	virtual ~TiXmlVisitor() {}
+
+	/// Visit a document.
+	virtual bool VisitEnter( const TiXmlDocument& /*doc*/ )			{ return true; }
+	/// Visit a document.
+	virtual bool VisitExit( const TiXmlDocument& /*doc*/ )			{ return true; }
+
+	/// Visit an element.
+	virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ )	{ return true; }
+	/// Visit an element.
+	virtual bool VisitExit( const TiXmlElement& /*element*/ )		{ return true; }
+
+	/// Visit a declaration
+	virtual bool Visit( const TiXmlDeclaration& /*declaration*/ )	{ return true; }
+	/// Visit a stylesheet reference
+	virtual bool Visit( const TiXmlStylesheetReference& /*stylesheet*/ )	{ return true; }
+	/// Visit a text node
+	virtual bool Visit( const TiXmlText& /*text*/ )					{ return true; }
+	/// Visit a comment node
+	virtual bool Visit( const TiXmlComment& /*comment*/ )			{ return true; }
+	/// Visit an unknow node
+	virtual bool Visit( const TiXmlUnknown& /*unknown*/ )			{ return true; }
+};
+
+// Only used by Attribute::Query functions
+enum
+{
+	TIXML_SUCCESS,
+	TIXML_NO_ATTRIBUTE,
+	TIXML_WRONG_TYPE
+};
+
+
+// Used by the parsing routines.
+enum TiXmlEncoding
+{
+	TIXML_ENCODING_UNKNOWN,
+	TIXML_ENCODING_UTF8,
+	TIXML_ENCODING_LEGACY
+};
+
+const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
+
+/** TiXmlBase is a base class for every class in TinyXml.
+	It does little except to establish that TinyXml classes
+	can be printed and provide some utility functions.
+
+	In XML, the document and elements can contain
+	other elements and other types of nodes.
+
+	@verbatim
+	A Document can contain:	Element	(container or leaf)
+							Comment (leaf)
+							Unknown (leaf)
+							Declaration( leaf )
+
+	An Element can contain:	Element (container or leaf)
+							Text	(leaf)
+							Attributes (not on tree)
+							Comment (leaf)
+							Unknown (leaf)
+
+	A Decleration contains: Attributes (not on tree)
+	@endverbatim
+*/
+#ifdef TIXML_USE_TICPP
+#include "ticpprc.h"
+class TiXmlBase : public TiCppRC
+#else
+class TiXmlBase
+#endif
+{
+	friend class TiXmlNode;
+	friend class TiXmlElement;
+	friend class TiXmlDocument;
+
+public:
+	TiXmlBase()	:	userData(0)		{}
+	virtual ~TiXmlBase()			{}
+
+	/**	All TinyXml classes can print themselves to a filestream
+		or the string class (TiXmlString in non-STL mode, std::string
+		in STL mode.) Either or both cfile and str can be null.
+
+		This is a formatted print, and will insert
+		tabs and newlines.
+
+		(For an unformatted stream, use the << operator.)
+	*/
+	virtual void Print( FILE* cfile, int depth ) const = 0;
+
+	/**	The world does not agree on whether white space should be kept or
+		not. In order to make everyone happy, these global, static functions
+		are provided to set whether or not TinyXml will condense all white space
+		into a single space or not. The default is to condense. Note changing this
+		value is not thread safe.
+	*/
+	static void SetCondenseWhiteSpace( bool condense )		{ condenseWhiteSpace = condense; }
+
+	/// Return the current white space setting.
+	static bool IsWhiteSpaceCondensed()						{ return condenseWhiteSpace; }
+
+	/** Return the position, in the original source file, of this node or attribute.
+		The row and column are 1-based. (That is the first row and first column is
+		1,1). If the returns values are 0 or less, then the parser does not have
+		a row and column value.
+
+		Generally, the row and column value will be set when the TiXmlDocument::Load(),
+		TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set
+		when the DOM was created from operator>>.
+
+		The values reflect the initial load. Once the DOM is modified programmatically
+		(by adding or changing nodes and attributes) the new values will NOT update to
+		reflect changes in the document.
+
+		There is a minor performance cost to computing the row and column. Computation
+		can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.
+
+		@sa TiXmlDocument::SetTabSize()
+	*/
+	int Row() const			{ return location.row + 1; }
+	int Column() const		{ return location.col + 1; }	///< See Row()
+
+	void  SetUserData( void* user )			{ userData = user; }	///< Set a pointer to arbitrary user data.
+	void* GetUserData()						{ return userData; }	///< Get a pointer to arbitrary user data.
+	const void* GetUserData() const 		{ return userData; }	///< Get a pointer to arbitrary user data.
+
+	// Table that returs, for a given lead byte, the total number of bytes
+	// in the UTF-8 sequence.
+	static const int utf8ByteTable[256];
+
+	virtual const char* Parse(	const char* p,
+								TiXmlParsingData* data,
+								TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
+
+	/** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
+		or they will be transformed into entities!
+	*/
+	static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
+
+	enum
+	{
+		TIXML_NO_ERROR = 0,
+		TIXML_ERROR,
+		TIXML_ERROR_OPENING_FILE,
+		TIXML_ERROR_OUT_OF_MEMORY,
+		TIXML_ERROR_PARSING_ELEMENT,
+		TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
+		TIXML_ERROR_READING_ELEMENT_VALUE,
+		TIXML_ERROR_READING_ATTRIBUTES,
+		TIXML_ERROR_PARSING_EMPTY,
+		TIXML_ERROR_READING_END_TAG,
+		TIXML_ERROR_PARSING_UNKNOWN,
+		TIXML_ERROR_PARSING_COMMENT,
+		TIXML_ERROR_PARSING_DECLARATION,
+		TIXML_ERROR_DOCUMENT_EMPTY,
+		TIXML_ERROR_EMBEDDED_NULL,
+		TIXML_ERROR_PARSING_CDATA,
+		TIXML_ERROR_DOCUMENT_TOP_ONLY,
+
+		TIXML_ERROR_STRING_COUNT
+	};
+
+protected:
+
+	static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
+	inline static bool IsWhiteSpace( char c )
+	{
+		return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
+	}
+	inline static bool IsWhiteSpace( int c )
+	{
+		if ( c < 256 )
+			return IsWhiteSpace( (char) c );
+		return false;	// Again, only truly correct for English/Latin...but usually works.
+	}
+
+	#ifdef TIXML_USE_STL
+	static bool	StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
+	static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
+	#endif
+
+	/*	Reads an XML name into the string provided. Returns
+		a pointer just past the last character of the name,
+		or 0 if the function has an error.
+	*/
+	static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
+
+	/*	Reads text. Returns a pointer past the given end tag.
+		Wickedly complex options, but it keeps the (sensitive) code in one place.
+	*/
+	static const char* ReadText(	const char* in,				// where to start
+									TIXML_STRING* text,			// the string read
+									bool ignoreWhiteSpace,		// whether to keep the white space
+									const char* endTag,			// what ends this text
+									bool ignoreCase,			// whether to ignore case in the end tag
+									TiXmlEncoding encoding );	// the current encoding
+
+	// If an entity has been found, transform it into a character.
+	static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
+
+	// Get a character, while interpreting entities.
+	// The length can be from 0 to 4 bytes.
+	inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
+	{
+		assert( p );
+		if ( encoding == TIXML_ENCODING_UTF8 )
+		{
+			*length = utf8ByteTable[ *((const unsigned char*)p) ];
+			assert( *length >= 0 && *length < 5 );
+		}
+		else
+		{
+			*length = 1;
+		}
+
+		if ( *length == 1 )
+		{
+			if ( *p == '&' )
+				return GetEntity( p, _value, length, encoding );
+			*_value = *p;
+			return p+1;
+		}
+		else if ( *length )
+		{
+			//strncpy( _value, p, *length );	// lots of compilers don't like this function (unsafe),
+												// and the null terminator isn't needed
+			for( int i=0; p[i] && i<*length; ++i ) {
+				_value[i] = p[i];
+			}
+			return p + (*length);
+		}
+		else
+		{
+			// Not valid text.
+			return 0;
+		}
+	}
+
+	// Return true if the next characters in the stream are any of the endTag sequences.
+	// Ignore case only works for english, and should only be relied on when comparing
+	// to English words: StringEqual( p, "version", true ) is fine.
+	static bool StringEqual(	const char* p,
+								const char* endTag,
+								bool ignoreCase,
+								TiXmlEncoding encoding );
+
+	static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
+
+	TiXmlCursor location;
+
+    /// Field containing a generic user pointer
+	void*			userData;
+
+	// None of these methods are reliable for any language except English.
+	// Good for approximation, not great for accuracy.
+	static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
+	static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
+	inline static int ToLower( int v, TiXmlEncoding encoding )
+	{
+		if ( encoding == TIXML_ENCODING_UTF8 )
+		{
+			if ( v < 128 ) return tolower( v );
+			return v;
+		}
+		else
+		{
+			return tolower( v );
+		}
+	}
+	static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
+
+private:
+	TiXmlBase( const TiXmlBase& );				// not implemented.
+	void operator=( const TiXmlBase& base );	// not allowed.
+
+	struct Entity
+	{
+		const char*     str;
+		unsigned int	strLength;
+		char		    chr;
+	};
+	enum
+	{
+		NUM_ENTITY = 5,
+		MAX_ENTITY_LENGTH = 6
+
+	};
+	static Entity entity[ NUM_ENTITY ];
+	static bool condenseWhiteSpace;
+};
+
+
+/** The parent class for everything in the Document Object Model.
+	(Except for attributes).
+	Nodes have siblings, a parent, and children. A node can be
+	in a document, or stand on its own. The type of a TiXmlNode
+	can be queried, and it can be cast to its more defined type.
+*/
+class TiXmlNode : public TiXmlBase
+{
+	friend class TiXmlDocument;
+	friend class TiXmlElement;
+
+public:
+	#ifdef TIXML_USE_STL
+
+	    /** An input stream operator, for every class. Tolerant of newlines and
+		    formatting, but doesn't expect them.
+	    */
+	    friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
+
+	    /** An output stream operator, for every class. Note that this outputs
+		    without any newlines or formatting, as opposed to Print(), which
+		    includes tabs and new lines.
+
+		    The operator<< and operator>> are not completely symmetric. Writing
+		    a node to a stream is very well defined. You'll get a nice stream
+		    of output, without any extra whitespace or newlines.
+
+		    But reading is not as well defined. (As it always is.) If you create
+		    a TiXmlElement (for example) and read that from an input stream,
+		    the text needs to define an element or junk will result. This is
+		    true of all input streams, but it's worth keeping in mind.
+
+		    A TiXmlDocument will read nodes until it reads a root element, and
+			all the children of that root element.
+	    */
+	    friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
+
+		/// Appends the XML node or attribute to a std::string.
+		friend std::string& operator<< (std::string& out, const TiXmlNode& base );
+
+	#endif
+
+	/** The types of XML nodes supported by TinyXml. (All the
+			unsupported types are picked up by UNKNOWN.)
+	*/
+	enum NodeType
+	{
+		DOCUMENT,
+		ELEMENT,
+		COMMENT,
+		UNKNOWN,
+		TEXT,
+		DECLARATION,
+		STYLESHEETREFERENCE,
+		TYPECOUNT
+	};
+
+	virtual ~TiXmlNode();
+
+	/** The meaning of 'value' changes for the specific type of
+		TiXmlNode.
+		@verbatim
+		Document:	filename of the xml file
+		Element:	name of the element
+		Comment:	the comment text
+		Unknown:	the tag contents
+		Text:		the text string
+		@endverbatim
+
+		The subclasses will wrap this function.
+	*/
+	const char *Value() const { return value.c_str (); }
+
+    #ifdef TIXML_USE_STL
+	/** Return Value() as a std::string. If you only use STL,
+	    this is more efficient than calling Value().
+		Only available in STL mode.
+	*/
+	const std::string& ValueStr() const { return value; }
+	#endif
+
+	const TIXML_STRING& ValueTStr() const { return value; }
+
+	/** Changes the value of the node. Defined as:
+		@verbatim
+		Document:	filename of the xml file
+		Element:	name of the element
+		Comment:	the comment text
+		Unknown:	the tag contents
+		Text:		the text string
+		@endverbatim
+	*/
+	void SetValue(const char * _value) { value = _value;}
+
+    #ifdef TIXML_USE_STL
+	/// STL std::string form.
+	void SetValue( const std::string& _value )	{ value = _value; }
+	#endif
+
+	/// Delete all the children of this node. Does not affect 'this'.
+	void Clear();
+
+	/// One step up the DOM.
+	TiXmlNode* Parent()							{ return parent; }
+	const TiXmlNode* Parent() const				{ return parent; }
+
+	const TiXmlNode* FirstChild()	const		{ return firstChild; }	///< The first child of this node. Will be null if there are no children.
+	TiXmlNode* FirstChild()						{ return firstChild; }
+	const TiXmlNode* FirstChild( const char * value ) const;			///< The first child of this node with the matching 'value'. Will be null if none found.
+	/// The first child of this node with the matching 'value'. Will be null if none found.
+	TiXmlNode* FirstChild( const char * _value ) {
+		// Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
+		// call the method, cast the return back to non-const.
+		return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
+	}
+	const TiXmlNode* LastChild() const	{ return lastChild; }		/// The last child of this node. Will be null if there are no children.
+	TiXmlNode* LastChild()	{ return lastChild; }
+
+	const TiXmlNode* LastChild( const char * value ) const;			/// The last child of this node matching 'value'. Will be null if there are no children.
+	TiXmlNode* LastChild( const char * _value ) {
+		return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlNode* FirstChild( const std::string& _value ) const	{	return FirstChild (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* FirstChild( const std::string& _value )				{	return FirstChild (_value.c_str ());	}	///< STL std::string form.
+	const TiXmlNode* LastChild( const std::string& _value ) const	{	return LastChild (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* LastChild( const std::string& _value )				{	return LastChild (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/** An alternate way to walk the children of a node.
+		One way to iterate over nodes is:
+		@verbatim
+			for( child = parent->FirstChild(); child; child = child->NextSibling() )
+		@endverbatim
+
+		IterateChildren does the same thing with the syntax:
+		@verbatim
+			child = 0;
+			while( child = parent->IterateChildren( child ) )
+		@endverbatim
+
+		IterateChildren takes the previous child as input and finds
+		the next one. If the previous child is null, it returns the
+		first. IterateChildren will return null when done.
+	*/
+	const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
+	TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
+	}
+
+	/// This flavor of IterateChildren searches for children with a particular 'value'
+	const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
+	TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const	{	return IterateChildren (_value.c_str (), previous);	}	///< STL std::string form.
+	TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) {	return IterateChildren (_value.c_str (), previous);	}	///< STL std::string form.
+	#endif
+
+	/** Add a new node related to this. Adds a child past the LastChild.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
+
+
+	/** Add a new node related to this. Adds a child past the LastChild.
+
+		NOTE: the node to be added is passed by pointer, and will be
+		henceforth owned (and deleted) by tinyXml. This method is efficient
+		and avoids an extra copy, but should be used with care as it
+		uses a different memory model than the other insert functions.
+
+		@sa InsertEndChild
+	*/
+	TiXmlNode* LinkEndChild( TiXmlNode* addThis );
+
+	/** Add a new node related to this. Adds a child before the specified child.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
+
+	/** Add a new node related to this. Adds a child after the specified child.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* InsertAfterChild(  TiXmlNode* afterThis, const TiXmlNode& addThis );
+
+	/** Replace a child of this node.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
+
+	/// Delete a child of this node.
+	bool RemoveChild( TiXmlNode* removeThis );
+
+	/// Navigate to a sibling node.
+	const TiXmlNode* PreviousSibling() const			{ return prev; }
+	TiXmlNode* PreviousSibling()						{ return prev; }
+
+	/// Navigate to a sibling node.
+	const TiXmlNode* PreviousSibling( const char * ) const;
+	TiXmlNode* PreviousSibling( const char *_prev ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlNode* PreviousSibling( const std::string& _value ) const	{	return PreviousSibling (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* PreviousSibling( const std::string& _value ) 			{	return PreviousSibling (_value.c_str ());	}	///< STL std::string form.
+	const TiXmlNode* NextSibling( const std::string& _value) const		{	return NextSibling (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* NextSibling( const std::string& _value) 					{	return NextSibling (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/// Navigate to a sibling node.
+	const TiXmlNode* NextSibling() const				{ return next; }
+	TiXmlNode* NextSibling()							{ return next; }
+
+	/// Navigate to a sibling node with the given 'value'.
+	const TiXmlNode* NextSibling( const char * ) const;
+	TiXmlNode* NextSibling( const char* _next ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
+	}
+
+	/** Convenience function to get through elements.
+		Calls NextSibling and ToElement. Will skip all non-Element
+		nodes. Returns 0 if there is not another element.
+	*/
+	const TiXmlElement* NextSiblingElement() const;
+	TiXmlElement* NextSiblingElement() {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
+	}
+
+	/** Convenience function to get through elements.
+		Calls NextSibling and ToElement. Will skip all non-Element
+		nodes. Returns 0 if there is not another element.
+	*/
+	const TiXmlElement* NextSiblingElement( const char * ) const;
+	TiXmlElement* NextSiblingElement( const char *_next ) {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlElement* NextSiblingElement( const std::string& _value) const	{	return NextSiblingElement (_value.c_str ());	}	///< STL std::string form.
+	TiXmlElement* NextSiblingElement( const std::string& _value)				{	return NextSiblingElement (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/// Convenience function to get through elements.
+	const TiXmlElement* FirstChildElement()	const;
+	TiXmlElement* FirstChildElement() {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
+	}
+
+	/// Convenience function to get through elements.
+	const TiXmlElement* FirstChildElement( const char * _value ) const;
+	TiXmlElement* FirstChildElement( const char * _value ) {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlElement* FirstChildElement( const std::string& _value ) const	{	return FirstChildElement (_value.c_str ());	}	///< STL std::string form.
+	TiXmlElement* FirstChildElement( const std::string& _value )				{	return FirstChildElement (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/** Query the type (as an enumerated value, above) of this node.
+		The possible types are: DOCUMENT, ELEMENT, COMMENT,
+								UNKNOWN, TEXT, and DECLARATION.
+	*/
+	int Type() const	{ return type; }
+
+	/** Return a pointer to the Document this node lives in.
+		Returns null if not in a document.
+	*/
+	const TiXmlDocument* GetDocument() const;
+	TiXmlDocument* GetDocument() {
+		return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
+	}
+
+	/// Returns true if this node has no children.
+	bool NoChildren() const						{ return !firstChild; }
+
+	virtual const TiXmlDocument*    ToDocument()    const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlElement*     ToElement()     const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlComment*     ToComment()     const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlUnknown*     ToUnknown()     const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlText*        ToText()        const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+
+	virtual TiXmlDocument*          ToDocument()    { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlElement*           ToElement()	    { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlComment*           ToComment()     { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlUnknown*           ToUnknown()	    { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlText*	            ToText()        { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlDeclaration*       ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlStylesheetReference*       ToStylesheetReference() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+
+	/** Create an exact duplicate of this node and return it. The memory must be deleted
+		by the caller.
+	*/
+	virtual TiXmlNode* Clone() const = 0;
+
+	/** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the
+		XML tree will be conditionally visited and the host will be called back
+		via the TiXmlVisitor interface.
+
+		This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse
+		the XML for the callbacks, so the performance of TinyXML is unchanged by using this
+		interface versus any other.)
+
+		The interface has been based on ideas from:
+
+		- http://www.saxproject.org/
+		- http://c2.com/cgi/wiki?HierarchicalVisitorPattern
+
+		Which are both good references for "visiting".
+
+		An example of using Accept():
+		@verbatim
+		TiXmlPrinter printer;
+		tinyxmlDoc.Accept( &printer );
+		const char* xmlcstr = printer.CStr();
+		@endverbatim
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
+
+protected:
+	TiXmlNode( NodeType _type );
+
+	// Copy to the allocated object. Shared functionality between Clone, Copy constructor,
+	// and the assignment operator.
+	void CopyTo( TiXmlNode* target ) const;
+
+	#ifdef TIXML_USE_STL
+	    // The real work of the input operator.
+	virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
+	#endif
+
+	// Figure out what is at *p, and parse it. Returns null if it is not an xml node.
+	TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
+
+	TiXmlNode*		parent;
+	NodeType		type;
+
+	TiXmlNode*		firstChild;
+	TiXmlNode*		lastChild;
+
+	TIXML_STRING	value;
+
+	TiXmlNode*		prev;
+	TiXmlNode*		next;
+
+private:
+	TiXmlNode( const TiXmlNode& );				// not implemented.
+	void operator=( const TiXmlNode& base );	// not allowed.
+};
+
+
+/** An attribute is a name-value pair. Elements have an arbitrary
+	number of attributes, each with a unique name.
+
+	@note The attributes are not TiXmlNodes, since they are not
+		  part of the tinyXML document object model. There are other
+		  suggested ways to look at this problem.
+*/
+class TiXmlAttribute : public TiXmlBase
+{
+	friend class TiXmlAttributeSet;
+
+public:
+	/// Construct an empty attribute.
+	TiXmlAttribute() : TiXmlBase()
+	{
+		document = 0;
+		prev = next = 0;
+	}
+
+	#ifdef TIXML_USE_STL
+	/// std::string constructor.
+	TiXmlAttribute( const std::string& _name, const std::string& _value )
+	{
+		name = _name;
+		value = _value;
+		document = 0;
+		prev = next = 0;
+	}
+	#endif
+
+	/// Construct an attribute with a name and value.
+	TiXmlAttribute( const char * _name, const char * _value )
+	{
+		name = _name;
+		value = _value;
+		document = 0;
+		prev = next = 0;
+	}
+
+	const char*		Name()  const		{ return name.c_str(); }		///< Return the name of this attribute.
+	const char*		Value() const		{ return value.c_str(); }		///< Return the value of this attribute.
+	#ifdef TIXML_USE_STL
+	const std::string& ValueStr() const	{ return value; }				///< Return the value of this attribute.
+	#endif
+	int				IntValue() const;									///< Return the value of this attribute, converted to an integer.
+	double			DoubleValue() const;								///< Return the value of this attribute, converted to a double.
+
+	// Get the tinyxml string representation
+	const TIXML_STRING& NameTStr() const { return name; }
+
+	/** QueryIntValue examines the value string. It is an alternative to the
+		IntValue() method with richer error checking.
+		If the value is an integer, it is stored in 'value' and
+		the call returns TIXML_SUCCESS. If it is not
+		an integer, it returns TIXML_WRONG_TYPE.
+
+		A specialized but useful call. Note that for success it returns 0,
+		which is the opposite of almost all other TinyXml calls.
+	*/
+	int QueryIntValue( int* _value ) const;
+	/// QueryDoubleValue examines the value string. See QueryIntValue().
+	int QueryDoubleValue( double* _value ) const;
+
+	void SetName( const char* _name )	{ name = _name; }				///< Set the name of this attribute.
+	void SetValue( const char* _value )	{ value = _value; }				///< Set the value.
+
+	void SetIntValue( int _value );										///< Set the value from an integer.
+	void SetDoubleValue( double _value );								///< Set the value from a double.
+
+    #ifdef TIXML_USE_STL
+	/// STL std::string form.
+	void SetName( const std::string& _name )	{ name = _name; }
+	/// STL std::string form.
+	void SetValue( const std::string& _value )	{ value = _value; }
+	#endif
+
+	/// Get the next sibling attribute in the DOM. Returns null at end.
+	const TiXmlAttribute* Next() const;
+	TiXmlAttribute* Next() {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
+	}
+
+	/// Get the previous sibling attribute in the DOM. Returns null at beginning.
+	const TiXmlAttribute* Previous() const;
+	TiXmlAttribute* Previous() {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
+	}
+
+	bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
+	bool operator<( const TiXmlAttribute& rhs )	 const { return name < rhs.name; }
+	bool operator>( const TiXmlAttribute& rhs )  const { return name > rhs.name; }
+
+	/*	Attribute parsing starts: first letter of the name
+						 returns: the next char after the value end quote
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	// Prints this Attribute to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const {
+		Print( cfile, depth, 0 );
+	}
+	void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
+
+	// [internal use]
+	// Set the document pointer so the attribute can report errors.
+	void SetDocument( TiXmlDocument* doc )	{ document = doc; }
+
+private:
+	TiXmlAttribute( const TiXmlAttribute& );				// not implemented.
+	void operator=( const TiXmlAttribute& base );	// not allowed.
+
+	TiXmlDocument*	document;	// A pointer back to a document, for error reporting.
+	TIXML_STRING name;
+	TIXML_STRING value;
+	TiXmlAttribute*	prev;
+	TiXmlAttribute*	next;
+};
+
+
+/*	A class used to manage a group of attributes.
+	It is only used internally, both by the ELEMENT and the DECLARATION.
+
+	The set can be changed transparent to the Element and Declaration
+	classes that use it, but NOT transparent to the Attribute
+	which has to implement a next() and previous() method. Which makes
+	it a bit problematic and prevents the use of STL.
+
+	This version is implemented with circular lists because:
+		- I like circular lists
+		- it demonstrates some independence from the (typical) doubly linked list.
+*/
+class TiXmlAttributeSet
+{
+public:
+	TiXmlAttributeSet();
+	~TiXmlAttributeSet();
+
+	void Add( TiXmlAttribute* attribute );
+	void Remove( TiXmlAttribute* attribute );
+
+	const TiXmlAttribute* First()	const	{ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
+	TiXmlAttribute* First()					{ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
+	const TiXmlAttribute* Last() const		{ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
+	TiXmlAttribute* Last()					{ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
+
+	const TiXmlAttribute*	Find( const char* _name ) const;
+	TiXmlAttribute*	Find( const char* _name ) {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
+	}
+	#ifdef TIXML_USE_STL
+	const TiXmlAttribute*	Find( const std::string& _name ) const;
+	TiXmlAttribute*	Find( const std::string& _name ) {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
+	}
+
+	#endif
+
+private:
+	//*ME:	Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
+	//*ME:	this class must be also use a hidden/disabled copy-constructor !!!
+	TiXmlAttributeSet( const TiXmlAttributeSet& );	// not allowed
+	void operator=( const TiXmlAttributeSet& );	// not allowed (as TiXmlAttribute)
+
+	TiXmlAttribute sentinel;
+};
+
+
+/** The element is a container class. It has a value, the element name,
+	and can contain other elements, text, comments, and unknowns.
+	Elements also contain an arbitrary number of attributes.
+*/
+class TiXmlElement : public TiXmlNode
+{
+public:
+	/// Construct an element.
+	TiXmlElement (const char * in_value);
+
+	#ifdef TIXML_USE_STL
+	/// std::string constructor.
+	TiXmlElement( const std::string& _value );
+	#endif
+
+	TiXmlElement( const TiXmlElement& );
+
+	void operator=( const TiXmlElement& base );
+
+	virtual ~TiXmlElement();
+
+	/** Given an attribute name, Attribute() returns the value
+		for the attribute of that name, or null if none exists.
+	*/
+	const char* Attribute( const char* name ) const;
+
+	/** Given an attribute name, Attribute() returns the value
+		for the attribute of that name, or null if none exists.
+		If the attribute exists and can be converted to an integer,
+		the integer value will be put in the return 'i', if 'i'
+		is non-null.
+	*/
+	const char* Attribute( const char* name, int* i ) const;
+
+	/** Given an attribute name, Attribute() returns the value
+		for the attribute of that name, or null if none exists.
+		If the attribute exists and can be converted to an double,
+		the double value will be put in the return 'd', if 'd'
+		is non-null.
+	*/
+	const char* Attribute( const char* name, double* d ) const;
+
+	/** QueryIntAttribute examines the attribute - it is an alternative to the
+		Attribute() method with richer error checking.
+		If the attribute is an integer, it is stored in 'value' and
+		the call returns TIXML_SUCCESS. If it is not
+		an integer, it returns TIXML_WRONG_TYPE. If the attribute
+		does not exist, then TIXML_NO_ATTRIBUTE is returned.
+	*/
+	int QueryIntAttribute( const char* name, int* _value ) const;
+	/// QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
+	int QueryDoubleAttribute( const char* name, double* _value ) const;
+	/// QueryFloatAttribute examines the attribute - see QueryIntAttribute().
+	int QueryFloatAttribute( const char* name, float* _value ) const {
+		double d;
+		int result = QueryDoubleAttribute( name, &d );
+		if ( result == TIXML_SUCCESS ) {
+			*_value = (float)d;
+		}
+		return result;
+	}
+
+    #ifdef TIXML_USE_STL
+	/** Template form of the attribute query which will try to read the
+		attribute into the specified type. Very easy, very powerful, but
+		be careful to make sure to call this with the correct type.
+
+		NOTE: This method doesn't work correctly for 'string' types.
+
+		@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
+	*/
+	template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
+	{
+		const TiXmlAttribute* node = attributeSet.Find( name );
+		if ( !node )
+			return TIXML_NO_ATTRIBUTE;
+
+		std::stringstream sstream( node->ValueStr() );
+		sstream >> *outValue;
+		if ( !sstream.fail() )
+			return TIXML_SUCCESS;
+		return TIXML_WRONG_TYPE;
+	}
+	/*
+	 This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
+	 but template specialization is hard to get working cross-compiler. Leaving the bug for now.
+
+	// The above will fail for std::string because the space character is used as a seperator.
+	// Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
+	template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const
+	{
+		const TiXmlAttribute* node = attributeSet.Find( name );
+		if ( !node )
+			return TIXML_NO_ATTRIBUTE;
+		*outValue = node->ValueStr();
+		return TIXML_SUCCESS;
+	}
+	*/
+	#endif
+
+	/** Sets an attribute of name to a given value. The attribute
+		will be created if it does not exist, or changed if it does.
+	*/
+	void SetAttribute( const char* name, const char * _value );
+
+    #ifdef TIXML_USE_STL
+	const std::string* Attribute( const std::string& name ) const;
+	const std::string* Attribute( const std::string& name, int* i ) const;
+	const std::string* Attribute( const std::string& name, double* d ) const;
+	int QueryIntAttribute( const std::string& name, int* _value ) const;
+	int QueryDoubleAttribute( const std::string& name, double* _value ) const;
+
+	/// STL std::string form.
+	void SetAttribute( const std::string& name, const std::string& _value );
+	///< STL std::string form.
+	void SetAttribute( const std::string& name, int _value );
+	#endif
+
+	/** Sets an attribute of name to a given value. The attribute
+		will be created if it does not exist, or changed if it does.
+	*/
+	void SetAttribute( const char * name, int value );
+
+	/** Sets an attribute of name to a given value. The attribute
+		will be created if it does not exist, or changed if it does.
+	*/
+	void SetDoubleAttribute( const char * name, double value );
+
+	/** Deletes an attribute with the given name.
+	*/
+	void RemoveAttribute( const char * name );
+    #ifdef TIXML_USE_STL
+	void RemoveAttribute( const std::string& name )	{	RemoveAttribute (name.c_str ());	}	///< STL std::string form.
+	#endif
+
+	const TiXmlAttribute* FirstAttribute() const	{ return attributeSet.First(); }		///< Access the first attribute in this element.
+	TiXmlAttribute* FirstAttribute() 				{ return attributeSet.First(); }
+	const TiXmlAttribute* LastAttribute()	const 	{ return attributeSet.Last(); }		///< Access the last attribute in this element.
+	TiXmlAttribute* LastAttribute()					{ return attributeSet.Last(); }
+
+	/** Convenience function for easy access to the text inside an element. Although easy
+		and concise, GetText() is limited compared to getting the TiXmlText child
+		and accessing it directly.
+
+		If the first child of 'this' is a TiXmlText, the GetText()
+		returns the character string of the Text node, else null is returned.
+
+		This is a convenient method for getting the text of simple contained text:
+		@verbatim
+		<foo>This is text</foo>
+		const char* str = fooElement->GetText();
+		@endverbatim
+
+		'str' will be a pointer to "This is text".
+
+		Note that this function can be misleading. If the element foo was created from
+		this XML:
+		@verbatim
+		<foo><b>This is text</b></foo>
+		@endverbatim
+
+		then the value of str would be null. The first child node isn't a text node, it is
+		another element. From this XML:
+		@verbatim
+		<foo>This is <b>text</b></foo>
+		@endverbatim
+		GetText() will return "This is ".
+
+		WARNING: GetText() accesses a child node - don't become confused with the
+				 similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are
+				 safe type casts on the referenced node.
+	*/
+	const char* GetText() const;
+
+	/// Creates a new Element and returns it - the returned element is a copy.
+	virtual TiXmlNode* Clone() const;
+	// Print the Element to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	/*	Attribtue parsing starts: next char past '<'
+						 returns: next char past '>'
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlElement*     ToElement()     const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlElement*           ToElement()	          { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+
+	void CopyTo( TiXmlElement* target ) const;
+	void ClearThis();	// like clear, but initializes 'this' object as well
+
+	// Used to be public [internal use]
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+	/*	[internal use]
+		Reads the "value" of the element -- another element, or text.
+		This should terminate with the current end tag.
+	*/
+	const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
+
+private:
+
+	TiXmlAttributeSet attributeSet;
+};
+
+
+/**	An XML comment.
+*/
+class TiXmlComment : public TiXmlNode
+{
+public:
+	/// Constructs an empty comment.
+	TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
+	/// Construct a comment from text.
+	TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
+		SetValue( _value );
+	}
+	TiXmlComment( const TiXmlComment& );
+	void operator=( const TiXmlComment& base );
+
+	virtual ~TiXmlComment()	{}
+
+	/// Returns a copy of this Comment.
+	virtual TiXmlNode* Clone() const;
+	// Write this Comment to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	/*	Attribtue parsing starts: at the ! of the !--
+						 returns: next char past '>'
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlComment*  ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlComment*  ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+	void CopyTo( TiXmlComment* target ) const;
+
+	// used to be public
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+//	virtual void StreamOut( TIXML_OSTREAM * out ) const;
+
+private:
+
+};
+
+
+/** XML text. A text node can have 2 ways to output the next. "normal" output
+	and CDATA. It will default to the mode it was parsed from the XML file and
+	you generally want to leave it alone, but you can change the output mode with
+	SetCDATA() and query it with CDATA().
+*/
+class TiXmlText : public TiXmlNode
+{
+	friend class TiXmlElement;
+public:
+	/** Constructor for text element. By default, it is treated as
+		normal, encoded text. If you want it be output as a CDATA text
+		element, set the parameter _cdata to 'true'
+	*/
+	TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
+	{
+		SetValue( initValue );
+		cdata = false;
+	}
+	virtual ~TiXmlText() {}
+
+	#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
+	{
+		SetValue( initValue );
+		cdata = false;
+	}
+	#endif
+
+	TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT )	{ copy.CopyTo( this ); }
+	void operator=( const TiXmlText& base )							 	{ base.CopyTo( this ); }
+
+	// Write this text object to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	/// Queries whether this represents text using a CDATA section.
+	bool CDATA() const				{ return cdata; }
+	/// Turns on or off a CDATA representation of text.
+	void SetCDATA( bool _cdata )	{ cdata = _cdata; }
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlText*       ToText()       { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* content ) const;
+
+protected :
+	///  [internal use] Creates a new Element and returns it.
+	virtual TiXmlNode* Clone() const;
+	void CopyTo( TiXmlText* target ) const;
+
+	bool Blank() const;	// returns true if all white space and new lines
+	// [internal use]
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+	bool cdata;			// true if this should be input and output as a CDATA style text element
+};
+
+
+/** In correct XML the declaration is the first entry in the file.
+	@verbatim
+		<?xml version="1.0" standalone="yes"?>
+	@endverbatim
+
+	TinyXml will happily read or write files without a declaration,
+	however. There are 3 possible attributes to the declaration:
+	version, encoding, and standalone.
+
+	Note: In this version of the code, the attributes are
+	handled as special cases, not generic attributes, simply
+	because there can only be at most 3 and they are always the same.
+*/
+class TiXmlDeclaration : public TiXmlNode
+{
+public:
+	/// Construct an empty declaration.
+	TiXmlDeclaration()   : TiXmlNode( TiXmlNode::DECLARATION ) {}
+
+#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlDeclaration(	const std::string& _version,
+						const std::string& _encoding,
+						const std::string& _standalone );
+#endif
+
+	/// Construct.
+	TiXmlDeclaration(	const char* _version,
+						const char* _encoding,
+						const char* _standalone );
+
+	TiXmlDeclaration( const TiXmlDeclaration& copy );
+	void operator=( const TiXmlDeclaration& copy );
+
+	virtual ~TiXmlDeclaration()	{}
+
+	/// Version. Will return an empty string if none was found.
+	const char *Version() const			{ return version.c_str (); }
+	/// Encoding. Will return an empty string if none was found.
+	const char *Encoding() const		{ return encoding.c_str (); }
+	/// Is this a standalone document?
+	const char *Standalone() const		{ return standalone.c_str (); }
+
+	/// Creates a copy of this Declaration and returns it.
+	virtual TiXmlNode* Clone() const;
+	// Print this declaration to a FILE stream.
+	virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
+	virtual void Print( FILE* cfile, int depth ) const {
+		Print( cfile, depth, 0 );
+	}
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlDeclaration*       ToDeclaration()       { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+	void CopyTo( TiXmlDeclaration* target ) const;
+	// used to be public
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+
+	TIXML_STRING version;
+	TIXML_STRING encoding;
+	TIXML_STRING standalone;
+};
+
+/** A stylesheet reference looks like this:
+	@verbatim
+		<?xml-stylesheet type="text/xsl" href="style.xsl"?>
+	@endverbatim
+
+	Note: In this version of the code, the attributes are
+	handled as special cases, not generic attributes, simply
+	because there can only be at most 2 and they are always the same.
+*/
+class TiXmlStylesheetReference : public TiXmlNode
+{
+public:
+	/// Construct an empty declaration.
+	TiXmlStylesheetReference()   : TiXmlNode( TiXmlNode::STYLESHEETREFERENCE ) {}
+
+#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlStylesheetReference(	const std::string& _type,
+								const std::string& _href );
+#endif
+
+	/// Construct.
+	TiXmlStylesheetReference(	const char* _type,
+								const char* _href );
+
+	TiXmlStylesheetReference( const TiXmlStylesheetReference& copy );
+	void operator=( const TiXmlStylesheetReference& copy );
+
+	virtual ~TiXmlStylesheetReference()	{}
+
+	/// Type. Will return an empty string if none was found.
+	const char *Type() const { return type.c_str (); }
+	/// Href. Will return an empty string if none was found.
+	const char *Href() const		{ return href.c_str (); }
+
+	/// Creates a copy of this StylesheetReference and returns it.
+	virtual TiXmlNode* Clone() const;
+	// Print this declaration to a FILE stream.
+	virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
+	virtual void Print( FILE* cfile, int depth ) const {
+		Print( cfile, depth, 0 );
+	}
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlStylesheetReference*       ToStylesheetReference()       { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+	void CopyTo( TiXmlStylesheetReference* target ) const;
+	// used to be public
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+
+	TIXML_STRING type;
+	TIXML_STRING href;
+};
+
+/** Any tag that tinyXml doesn't recognize is saved as an
+	unknown. It is a tag of text, but should not be modified.
+	It will be written back to the XML, unchanged, when the file
+	is saved.
+
+	DTD tags get thrown into TiXmlUnknowns.
+*/
+class TiXmlUnknown : public TiXmlNode
+{
+public:
+	TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN )	{}
+	virtual ~TiXmlUnknown() {}
+
+	TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN )		{ copy.CopyTo( this ); }
+	void operator=( const TiXmlUnknown& copy )										{ copy.CopyTo( this ); }
+
+	/// Creates a copy of this Unknown and returns it.
+	virtual TiXmlNode* Clone() const;
+	// Print this Unknown to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlUnknown*     ToUnknown()     const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlUnknown*           ToUnknown()	    { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* content ) const;
+
+protected:
+	void CopyTo( TiXmlUnknown* target ) const;
+
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+
+};
+
+
+/** Always the top level node. A document binds together all the
+	XML pieces. It can be saved, loaded, and printed to the screen.
+	The 'value' of a document node is the xml file name.
+*/
+class TiXmlDocument : public TiXmlNode
+{
+public:
+	/// Create an empty document, that has no name.
+	TiXmlDocument();
+	/// Create a document with a name. The name of the document is also the filename of the xml.
+	TiXmlDocument( const char * documentName );
+
+	#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlDocument( const std::string& documentName );
+	#endif
+
+	TiXmlDocument( const TiXmlDocument& copy );
+	void operator=( const TiXmlDocument& copy );
+
+	virtual ~TiXmlDocument() {}
+
+	/** Load a file using the current document value.
+		Returns true if successful. Will delete any existing
+		document data before loading.
+	*/
+	bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	/// Save a file using the current document value. Returns true if successful.
+	bool SaveFile() const;
+	/// Load a file using the given filename. Returns true if successful.
+	bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	/// Save a file using the given filename. Returns true if successful.
+	bool SaveFile( const char * filename ) const;
+	/** Load a file using the given FILE*. Returns true if successful. Note that this method
+		doesn't stream - the entire object pointed at by the FILE*
+		will be interpreted as an XML file. TinyXML doesn't stream in XML from the current
+		file location. Streaming may be added in the future.
+	*/
+	bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	/// Save a file using the given FILE*. Returns true if successful.
+	bool SaveFile( FILE* ) const;
+
+	#ifdef TIXML_USE_STL
+	bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )			///< STL std::string version.
+	{
+//		StringToBuffer f( filename );
+//		return ( f.buffer && LoadFile( f.buffer, encoding ));
+		return LoadFile( filename.c_str(), encoding );
+	}
+	bool SaveFile( const std::string& filename ) const		///< STL std::string version.
+	{
+//		StringToBuffer f( filename );
+//		return ( f.buffer && SaveFile( f.buffer ));
+		return SaveFile( filename.c_str() );
+	}
+	#endif
+
+	/** Parse the given null terminated block of xml data. Passing in an encoding to this
+		method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml
+		to use that encoding, regardless of what TinyXml might otherwise try to detect.
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+	/** Get the root element -- the only top level element -- of the document.
+		In well formed XML, there should only be one. TinyXml is tolerant of
+		multiple elements at the document level.
+	*/
+	const TiXmlElement* RootElement() const		{ return FirstChildElement(); }
+	TiXmlElement* RootElement()					{ return FirstChildElement(); }
+
+	/** If an error occurs, Error will be set to true. Also,
+		- The ErrorId() will contain the integer identifier of the error (not generally useful)
+		- The ErrorDesc() method will return the name of the error. (very useful)
+		- The ErrorRow() and ErrorCol() will return the location of the error (if known)
+	*/
+	bool Error() const						{ return error; }
+
+	/// Contains a textual (english) description of the error if one occurs.
+	const char * ErrorDesc() const	{ return errorDesc.c_str (); }
+
+	/** Generally, you probably want the error string ( ErrorDesc() ). But if you
+		prefer the ErrorId, this function will fetch it.
+	*/
+	int ErrorId()	const				{ return errorId; }
+
+	/** Returns the location (if known) of the error. The first column is column 1,
+		and the first row is row 1. A value of 0 means the row and column wasn't applicable
+		(memory errors, for example, have no row/column) or the parser lost the error. (An
+		error in the error reporting, in that case.)
+
+		@sa SetTabSize, Row, Column
+	*/
+	int ErrorRow() const	{ return errorLocation.row+1; }
+	int ErrorCol() const	{ return errorLocation.col+1; }	///< The column where the error occured. See ErrorRow()
+
+	/** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol())
+		to report the correct values for row and column. It does not change the output
+		or input in any way.
+
+		By calling this method, with a tab size
+		greater than 0, the row and column of each node and attribute is stored
+		when the file is loaded. Very useful for tracking the DOM back in to
+		the source file.
+
+		The tab size is required for calculating the location of nodes. If not
+		set, the default of 4 is used. The tabsize is set per document. Setting
+		the tabsize to 0 disables row/column tracking.
+
+		Note that row and column tracking is not supported when using operator>>.
+
+		The tab size needs to be enabled before the parse or load. Correct usage:
+		@verbatim
+		TiXmlDocument doc;
+		doc.SetTabSize( 8 );
+		doc.Load( "myfile.xml" );
+		@endverbatim
+
+		@sa Row, Column
+	*/
+	void SetTabSize( int _tabsize )		{ tabsize = _tabsize; }
+
+	int TabSize() const	{ return tabsize; }
+
+	/** If you have handled the error, it can be reset with this call. The error
+		state is automatically cleared if you Parse a new XML block.
+	*/
+	void ClearError()						{	error = false;
+												errorId = 0;
+												errorDesc = "";
+												errorLocation.row = errorLocation.col = 0;
+												//errorLocation.last = 0;
+											}
+
+	/** Write the document to standard out using formatted printing ("pretty print"). */
+	void Print() const						{ Print( stdout, 0 ); }
+
+	/* Write the document to a string using formatted printing ("pretty print"). This
+		will allocate a character array (new char[]) and return it as a pointer. The
+		calling code pust call delete[] on the return char* to avoid a memory leak.
+	*/
+	//char* PrintToMemory() const;
+
+	/// Print this Document to a FILE stream.
+	virtual void Print( FILE* cfile, int depth = 0 ) const;
+	// [internal use]
+	void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
+
+	virtual const TiXmlDocument*    ToDocument()    const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlDocument*          ToDocument()          { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* content ) const;
+
+protected :
+	// [internal use]
+	virtual TiXmlNode* Clone() const;
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+	void CopyTo( TiXmlDocument* target ) const;
+
+	bool error;
+	int  errorId;
+	TIXML_STRING errorDesc;
+	int tabsize;
+	TiXmlCursor errorLocation;
+	bool useMicrosoftBOM;		// the UTF-8 BOM were found when read. Note this, and try to write.
+};
+
+
+/**
+	A TiXmlHandle is a class that wraps a node pointer with null checks; this is
+	an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml
+	DOM structure. It is a separate utility class.
+
+	Take an example:
+	@verbatim
+	<Document>
+		<Element attributeA = "valueA">
+			<Child attributeB = "value1" />
+			<Child attributeB = "value2" />
+		</Element>
+	<Document>
+	@endverbatim
+
+	Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
+	easy to write a *lot* of code that looks like:
+
+	@verbatim
+	TiXmlElement* root = document.FirstChildElement( "Document" );
+	if ( root )
+	{
+		TiXmlElement* element = root->FirstChildElement( "Element" );
+		if ( element )
+		{
+			TiXmlElement* child = element->FirstChildElement( "Child" );
+			if ( child )
+			{
+				TiXmlElement* child2 = child->NextSiblingElement( "Child" );
+				if ( child2 )
+				{
+					// Finally do something useful.
+	@endverbatim
+
+	And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity
+	of such code. A TiXmlHandle checks for null	pointers so it is perfectly safe
+	and correct to use:
+
+	@verbatim
+	TiXmlHandle docHandle( &document );
+	TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();
+	if ( child2 )
+	{
+		// do something useful
+	@endverbatim
+
+	Which is MUCH more concise and useful.
+
+	It is also safe to copy handles - internally they are nothing more than node pointers.
+	@verbatim
+	TiXmlHandle handleCopy = handle;
+	@endverbatim
+
+	What they should not be used for is iteration:
+
+	@verbatim
+	int i=0;
+	while ( true )
+	{
+		TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement();
+		if ( !child )
+			break;
+		// do something
+		++i;
+	}
+	@endverbatim
+
+	It seems reasonable, but it is in fact two embedded while loops. The Child method is
+	a linear walk to find the element, so this code would iterate much more than it needs
+	to. Instead, prefer:
+
+	@verbatim
+	TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement();
+
+	for( child; child; child=child->NextSiblingElement() )
+	{
+		// do something
+	}
+	@endverbatim
+*/
+class TiXmlHandle
+{
+public:
+	/// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
+	TiXmlHandle( TiXmlNode* _node )					{ this->node = _node; }
+	/// Copy constructor
+	TiXmlHandle( const TiXmlHandle& ref )			{ this->node = ref.node; }
+	TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
+
+	/// Return a handle to the first child node.
+	TiXmlHandle FirstChild() const;
+	/// Return a handle to the first child node with the given name.
+	TiXmlHandle FirstChild( const char * value ) const;
+	/// Return a handle to the first child element.
+	TiXmlHandle FirstChildElement() const;
+	/// Return a handle to the first child element with the given name.
+	TiXmlHandle FirstChildElement( const char * value ) const;
+
+	/** Return a handle to the "index" child with the given name.
+		The first child is 0, the second 1, etc.
+	*/
+	TiXmlHandle Child( const char* value, int index ) const;
+	/** Return a handle to the "index" child.
+		The first child is 0, the second 1, etc.
+	*/
+	TiXmlHandle Child( int index ) const;
+	/** Return a handle to the "index" child element with the given name.
+		The first child element is 0, the second 1, etc. Note that only TiXmlElements
+		are indexed: other types are not counted.
+	*/
+	TiXmlHandle ChildElement( const char* value, int index ) const;
+	/** Return a handle to the "index" child element.
+		The first child element is 0, the second 1, etc. Note that only TiXmlElements
+		are indexed: other types are not counted.
+	*/
+	TiXmlHandle ChildElement( int index ) const;
+
+	#ifdef TIXML_USE_STL
+	TiXmlHandle FirstChild( const std::string& _value ) const				{ return FirstChild( _value.c_str() ); }
+	TiXmlHandle FirstChildElement( const std::string& _value ) const		{ return FirstChildElement( _value.c_str() ); }
+
+	TiXmlHandle Child( const std::string& _value, int index ) const			{ return Child( _value.c_str(), index ); }
+	TiXmlHandle ChildElement( const std::string& _value, int index ) const	{ return ChildElement( _value.c_str(), index ); }
+	#endif
+
+	/** Return the handle as a TiXmlNode. This may return null.
+	*/
+	TiXmlNode* ToNode() const			{ return node; }
+	/** Return the handle as a TiXmlElement. This may return null.
+	*/
+	TiXmlElement* ToElement() const		{ return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
+	/**	Return the handle as a TiXmlText. This may return null.
+	*/
+	TiXmlText* ToText() const			{ return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
+	/** Return the handle as a TiXmlUnknown. This may return null.
+	*/
+	TiXmlUnknown* ToUnknown() const		{ return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
+
+	/** @deprecated use ToNode.
+		Return the handle as a TiXmlNode. This may return null.
+	*/
+	TiXmlNode* Node() const			{ return ToNode(); }
+	/** @deprecated use ToElement.
+		Return the handle as a TiXmlElement. This may return null.
+	*/
+	TiXmlElement* Element() const	{ return ToElement(); }
+	/**	@deprecated use ToText()
+		Return the handle as a TiXmlText. This may return null.
+	*/
+	TiXmlText* Text() const			{ return ToText(); }
+	/** @deprecated use ToUnknown()
+		Return the handle as a TiXmlUnknown. This may return null.
+	*/
+	TiXmlUnknown* Unknown() const	{ return ToUnknown(); }
+
+private:
+	TiXmlNode* node;
+};
+
+
+/** Print to memory functionality. The TiXmlPrinter is useful when you need to:
+
+	-# Print to memory (especially in non-STL mode)
+	-# Control formatting (line endings, etc.)
+
+	When constructed, the TiXmlPrinter is in its default "pretty printing" mode.
+	Before calling Accept() you can call methods to control the printing
+	of the XML document. After TiXmlNode::Accept() is called, the printed document can
+	be accessed via the CStr(), Str(), and Size() methods.
+
+	TiXmlPrinter uses the Visitor API.
+	@verbatim
+	TiXmlPrinter printer;
+	printer.SetIndent( "\t" );
+
+	doc.Accept( &printer );
+	fprintf( stdout, "%s", printer.CStr() );
+	@endverbatim
+*/
+class TiXmlPrinter : public TiXmlVisitor
+{
+public:
+	TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
+					 buffer(), indent( "    " ), lineBreak( "\n" ) {}
+
+	virtual bool VisitEnter( const TiXmlDocument& doc );
+	virtual bool VisitExit( const TiXmlDocument& doc );
+
+	virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
+	virtual bool VisitExit( const TiXmlElement& element );
+
+	virtual bool Visit( const TiXmlDeclaration& declaration );
+	virtual bool Visit( const TiXmlText& text );
+	virtual bool Visit( const TiXmlComment& comment );
+	virtual bool Visit( const TiXmlUnknown& unknown );
+
+	/** Set the indent characters for printing. By default 4 spaces
+		but tab (\t) is also useful, or null/empty string for no indentation.
+	*/
+	void SetIndent( const char* _indent )			{ indent = _indent ? _indent : "" ; }
+	/// Query the indention string.
+	const char* Indent()							{ return indent.c_str(); }
+	/** Set the line breaking string. By default set to newline (\n).
+		Some operating systems prefer other characters, or can be
+		set to the null/empty string for no indenation.
+	*/
+	void SetLineBreak( const char* _lineBreak )		{ lineBreak = _lineBreak ? _lineBreak : ""; }
+	/// Query the current line breaking string.
+	const char* LineBreak()							{ return lineBreak.c_str(); }
+
+	/** Switch over to "stream printing" which is the most dense formatting without
+		linebreaks. Common when the XML is needed for network transmission.
+	*/
+	void SetStreamPrinting()						{ indent = "";
+													  lineBreak = "";
+													}
+	/// Return the result.
+	const char* CStr()								{ return buffer.c_str(); }
+	/// Return the length of the result string.
+	size_t Size()									{ return buffer.size(); }
+
+	#ifdef TIXML_USE_STL
+	/// Return the result.
+	const std::string& Str()						{ return buffer; }
+	#endif
+
+private:
+	void DoIndent()	{
+		for( int i=0; i<depth; ++i )
+			buffer += indent;
+	}
+	void DoLineBreak() {
+		buffer += lineBreak;
+	}
+
+	int depth;
+	bool simpleTextPrint;
+	TIXML_STRING buffer;
+	TIXML_STRING indent;
+	TIXML_STRING lineBreak;
+};
+
+
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
+
+#endif
+
Index: /code/branches/physics/src/tinyxml/tinyxmlerror.cc
===================================================================
--- /code/branches/physics/src/tinyxml/tinyxmlerror.cc	(revision 2122)
+++ /code/branches/physics/src/tinyxml/tinyxmlerror.cc	(revision 2122)
@@ -0,0 +1,53 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied 
+warranty. In no event will the authors be held liable for any 
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any 
+purpose, including commercial applications, and to alter it and 
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include "tinyxml.h"
+
+// The goal of the seperate error file is to make the first
+// step towards localization. tinyxml (currently) only supports
+// english error messages, but the could now be translated.
+//
+// It also cleans up the code a bit.
+//
+
+const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
+{
+	"No error",
+	"Error",
+	"Failed to open file",
+	"Memory allocation failed.",
+	"Error parsing Element.",
+	"Failed to read Element name",
+	"Error reading Element value.",
+	"Error reading Attributes.",
+	"Error: empty tag.",
+	"Error reading end tag.",
+	"Error parsing Unknown.",
+	"Error parsing Comment.",
+	"Error parsing Declaration.",
+	"Error document empty.",
+	"Error null (0) or unexpected EOF found in input stream.",
+	"Error parsing CDATA.",
+	"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
+};
Index: /code/branches/physics/src/tinyxml/tinyxmlparser.cc
===================================================================
--- /code/branches/physics/src/tinyxml/tinyxmlparser.cc	(revision 2122)
+++ /code/branches/physics/src/tinyxml/tinyxmlparser.cc	(revision 2122)
@@ -0,0 +1,1722 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include <ctype.h>
+#include <stddef.h>
+
+#include "tinyxml.h"
+
+//#define DEBUG_PARSER
+#if defined( DEBUG_PARSER )
+#	if defined( DEBUG ) && defined( _MSC_VER )
+#		include <windows.h>
+#		define TIXML_LOG OutputDebugString
+#	else
+#		define TIXML_LOG printf
+#	endif
+#endif
+
+// Note tha "PutString" hardcodes the same list. This
+// is less flexible than it appears. Changing the entries
+// or order will break putstring.
+TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
+{
+	{ "&amp;",  5, '&' },
+	{ "&lt;",   4, '<' },
+	{ "&gt;",   4, '>' },
+	{ "&quot;", 6, '\"' },
+	{ "&apos;", 6, '\'' }
+};
+
+// Bunch of unicode info at:
+//		http://www.unicode.org/faq/utf_bom.html
+// Including the basic of this table, which determines the #bytes in the
+// sequence from the lead byte. 1 placed for invalid sequences --
+// although the result will be junk, pass it through as much as possible.
+// Beware of the non-characters in UTF-8:
+//				ef bb bf (Microsoft "lead bytes")
+//				ef bf be
+//				ef bf bf
+
+const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
+const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
+const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
+
+const int TiXmlBase::utf8ByteTable[256] =
+{
+	//	0	1	2	3	4	5	6	7	8	9	a	b	c	d	e	f
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x00
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x10
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x20
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x30
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x40
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x50
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x60
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x70	End of ASCII range
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x80 0x80 to 0xc1 invalid
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x90
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0xa0
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0xb0
+		1,	1,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	// 0xc0 0xc2 to 0xdf 2 byte
+		2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	// 0xd0
+		3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	// 0xe0 0xe0 to 0xef 3 byte
+		4,	4,	4,	4,	4,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1	// 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid
+};
+
+
+void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )
+{
+	const unsigned long BYTE_MASK = 0xBF;
+	const unsigned long BYTE_MARK = 0x80;
+	const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+	if (input < 0x80)
+		*length = 1;
+	else if ( input < 0x800 )
+		*length = 2;
+	else if ( input < 0x10000 )
+		*length = 3;
+	else if ( input < 0x200000 )
+		*length = 4;
+	else
+		{ *length = 0; return; }	// This code won't covert this correctly anyway.
+
+	output += *length;
+
+	// Scary scary fall throughs.
+	switch (*length)
+	{
+		case 4:
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
+			input >>= 6;
+		case 3:
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
+			input >>= 6;
+		case 2:
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
+			input >>= 6;
+		case 1:
+			--output;
+			*output = (char)(input | FIRST_BYTE_MARK[*length]);
+	}
+}
+
+
+/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
+{
+	// This will only work for low-ascii, everything else is assumed to be a valid
+	// letter. I'm not sure this is the best approach, but it is quite tricky trying
+	// to figure out alhabetical vs. not across encoding. So take a very
+	// conservative approach.
+
+//	if ( encoding == TIXML_ENCODING_UTF8 )
+//	{
+		if ( anyByte < 127 )
+			return isalpha( anyByte );
+		else
+			return 1;	// What else to do? The unicode set is huge...get the english ones right.
+//	}
+//	else
+//	{
+//		return isalpha( anyByte );
+//	}
+}
+
+
+/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
+{
+	// This will only work for low-ascii, everything else is assumed to be a valid
+	// letter. I'm not sure this is the best approach, but it is quite tricky trying
+	// to figure out alhabetical vs. not across encoding. So take a very
+	// conservative approach.
+
+//	if ( encoding == TIXML_ENCODING_UTF8 )
+//	{
+		if ( anyByte < 127 )
+			return isalnum( anyByte );
+		else
+			return 1;	// What else to do? The unicode set is huge...get the english ones right.
+//	}
+//	else
+//	{
+//		return isalnum( anyByte );
+//	}
+}
+
+
+class TiXmlParsingData
+{
+	friend class TiXmlDocument;
+  public:
+	void Stamp( const char* now, TiXmlEncoding encoding );
+
+	const TiXmlCursor& Cursor()	{ return cursor; }
+
+  private:
+	// Only used by the document!
+	TiXmlParsingData( const char* start, int _tabsize, int row, int col )
+	{
+		assert( start );
+		stamp = start;
+		tabsize = _tabsize;
+		cursor.row = row;
+		cursor.col = col;
+	}
+
+	TiXmlCursor		cursor;
+	const char*		stamp;
+	int				tabsize;
+};
+
+
+void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
+{
+	assert( now );
+
+	// Do nothing if the tabsize is 0.
+	if ( tabsize < 1 )
+	{
+		return;
+	}
+
+	// Get the current row, column.
+	int row = cursor.row;
+	int col = cursor.col;
+	const char* p = stamp;
+	assert( p );
+
+	while ( p < now )
+	{
+		// Treat p as unsigned, so we have a happy compiler.
+		const unsigned char* pU = (const unsigned char*)p;
+
+		// Code contributed by Fletcher Dunn: (modified by lee)
+		switch (*pU) {
+			case 0:
+				// We *should* never get here, but in case we do, don't
+				// advance past the terminating null character, ever
+				return;
+
+			case '\r':
+				// bump down to the next line
+				++row;
+				col = 0;
+				// Eat the character
+				++p;
+
+				// Check for \r\n sequence, and treat this as a single character
+				if (*p == '\n') {
+					++p;
+				}
+				break;
+
+			case '\n':
+				// bump down to the next line
+				++row;
+				col = 0;
+
+				// Eat the character
+				++p;
+
+				// Check for \n\r sequence, and treat this as a single
+				// character.  (Yes, this bizarre thing does occur still
+				// on some arcane platforms...)
+				if (*p == '\r') {
+					++p;
+				}
+				break;
+
+			case '\t':
+				// Eat the character
+				++p;
+
+				// Skip to next tab stop
+				col = (col / tabsize + 1) * tabsize;
+				break;
+
+			case TIXML_UTF_LEAD_0:
+				if ( encoding == TIXML_ENCODING_UTF8 )
+				{
+					if ( *(p+1) && *(p+2) )
+					{
+						// In these cases, don't advance the column. These are
+						// 0-width spaces.
+						if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
+							p += 3;
+						else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
+							p += 3;
+						else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
+							p += 3;
+						else
+							{ p +=3; ++col; }	// A normal character.
+					}
+				}
+				else
+				{
+					++p;
+					++col;
+				}
+				break;
+
+			default:
+				if ( encoding == TIXML_ENCODING_UTF8 )
+				{
+					// Eat the 1 to 4 byte utf8 character.
+					int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)];
+					if ( step == 0 )
+						step = 1;		// Error case from bad encoding, but handle gracefully.
+					p += step;
+
+					// Just advance one column, of course.
+					++col;
+				}
+				else
+				{
+					++p;
+					++col;
+				}
+				break;
+		}
+	}
+	cursor.row = row;
+	cursor.col = col;
+	assert( cursor.row >= -1 );
+	assert( cursor.col >= -1 );
+	stamp = p;
+	assert( stamp );
+}
+
+
+const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
+{
+	if ( !p || !*p )
+	{
+		return 0;
+	}
+	if ( encoding == TIXML_ENCODING_UTF8 )
+	{
+		while ( *p )
+		{
+			const unsigned char* pU = (const unsigned char*)p;
+
+			// Skip the stupid Microsoft UTF-8 Byte order marks
+			if (	*(pU+0)==TIXML_UTF_LEAD_0
+				 && *(pU+1)==TIXML_UTF_LEAD_1
+				 && *(pU+2)==TIXML_UTF_LEAD_2 )
+			{
+				p += 3;
+				continue;
+			}
+			else if(*(pU+0)==TIXML_UTF_LEAD_0
+				 && *(pU+1)==0xbfU
+				 && *(pU+2)==0xbeU )
+			{
+				p += 3;
+				continue;
+			}
+			else if(*(pU+0)==TIXML_UTF_LEAD_0
+				 && *(pU+1)==0xbfU
+				 && *(pU+2)==0xbfU )
+			{
+				p += 3;
+				continue;
+			}
+
+			if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )		// Still using old rules for white space.
+				++p;
+			else
+				break;
+		}
+	}
+	else
+	{
+		while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
+			++p;
+	}
+
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag )
+{
+	for( ;; )
+	{
+		if ( !in->good() ) return false;
+
+		int c = in->peek();
+		// At this scope, we can't get to a document. So fail silently.
+		if ( !IsWhiteSpace( c ) || c <= 0 )
+			return true;
+
+		*tag += (char) in->get();
+	}
+}
+
+/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag )
+{
+	//assert( character > 0 && character < 128 );	// else it won't work in utf-8
+	while ( in->good() )
+	{
+		int c = in->peek();
+		if ( c == character )
+			return true;
+		if ( c <= 0 )		// Silent failure: can't get document at this scope
+			return false;
+
+		in->get();
+		*tag += (char) c;
+	}
+	return false;
+}
+#endif
+
+// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The
+// "assign" optimization removes over 10% of the execution time.
+//
+const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding )
+{
+	// Oddly, not supported on some comilers,
+	//name->clear();
+	// So use this:
+	*name = "";
+	assert( p );
+
+	// Names start with letters or underscores.
+	// Of course, in unicode, tinyxml has no idea what a letter *is*. The
+	// algorithm is generous.
+	//
+	// After that, they can be letters, underscores, numbers,
+	// hyphens, or colons. (Colons are valid ony for namespaces,
+	// but tinyxml can't tell namespaces from names.)
+	if (    p && *p
+		 && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
+	{
+		const char* start = p;
+		while(		p && *p
+				&&	(		IsAlphaNum( (unsigned char ) *p, encoding )
+						 || *p == '_'
+						 || *p == '-'
+						 || *p == '.'
+						 || *p == ':' ) )
+		{
+			//(*name) += *p; // expensive
+			++p;
+		}
+		if ( p-start > 0 ) {
+			name->assign( start, p-start );
+		}
+		return p;
+	}
+	return 0;
+}
+
+const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding )
+{
+	// Presume an entity, and pull it out.
+    TIXML_STRING ent;
+	int i;
+	*length = 0;
+
+	if ( *(p+1) && *(p+1) == '#' && *(p+2) )
+	{
+		unsigned long ucs = 0;
+		ptrdiff_t delta = 0;
+		unsigned mult = 1;
+
+		if ( *(p+2) == 'x' )
+		{
+			// Hexadecimal.
+			if ( !*(p+3) ) return 0;
+
+			const char* q = p+3;
+			q = strchr( q, ';' );
+
+			if ( !q || !*q ) return 0;
+
+			delta = q-p;
+			--q;
+
+			while ( *q != 'x' )
+			{
+				if ( *q >= '0' && *q <= '9' )
+					ucs += mult * (*q - '0');
+				else if ( *q >= 'a' && *q <= 'f' )
+					ucs += mult * (*q - 'a' + 10);
+				else if ( *q >= 'A' && *q <= 'F' )
+					ucs += mult * (*q - 'A' + 10 );
+				else
+					return 0;
+				mult *= 16;
+				--q;
+			}
+		}
+		else
+		{
+			// Decimal.
+			if ( !*(p+2) ) return 0;
+
+			const char* q = p+2;
+			q = strchr( q, ';' );
+
+			if ( !q || !*q ) return 0;
+
+			delta = q-p;
+			--q;
+
+			while ( *q != '#' )
+			{
+				if ( *q >= '0' && *q <= '9' )
+					ucs += mult * (*q - '0');
+				else
+					return 0;
+				mult *= 10;
+				--q;
+			}
+		}
+		if ( encoding == TIXML_ENCODING_UTF8 )
+		{
+			// convert the UCS to UTF-8
+			ConvertUTF32ToUTF8( ucs, value, length );
+		}
+		else
+		{
+			*value = (char)ucs;
+			*length = 1;
+		}
+		return p + delta + 1;
+	}
+
+	// Now try to match it.
+	for( i=0; i<NUM_ENTITY; ++i )
+	{
+		if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
+		{
+			assert( strlen( entity[i].str ) == entity[i].strLength );
+			*value = entity[i].chr;
+			*length = 1;
+			return ( p + entity[i].strLength );
+		}
+	}
+
+	// So it wasn't an entity, its unrecognized, or something like that.
+	*value = *p;	// Don't put back the last one, since we return it!
+	//*length = 1;	// Leave unrecognized entities - this doesn't really work.
+					// Just writes strange XML.
+	return p+1;
+}
+
+
+bool TiXmlBase::StringEqual( const char* p,
+							 const char* tag,
+							 bool ignoreCase,
+							 TiXmlEncoding encoding )
+{
+	assert( p );
+	assert( tag );
+	if ( !p || !*p )
+	{
+		assert( 0 );
+		return false;
+	}
+
+	const char* q = p;
+
+	if ( ignoreCase )
+	{
+		while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) )
+		{
+			++q;
+			++tag;
+		}
+
+		if ( *tag == 0 )
+			return true;
+	}
+	else
+	{
+		while ( *q && *tag && *q == *tag )
+		{
+			++q;
+			++tag;
+		}
+
+		if ( *tag == 0 )		// Have we found the end of the tag, and everything equal?
+			return true;
+	}
+	return false;
+}
+
+const char* TiXmlBase::ReadText(	const char* p,
+									TIXML_STRING * text,
+									bool trimWhiteSpace,
+									const char* endTag,
+									bool caseInsensitive,
+									TiXmlEncoding encoding )
+{
+    *text = "";
+	if (    !trimWhiteSpace			// certain tags always keep whitespace
+		 || !condenseWhiteSpace )	// if true, whitespace is always kept
+	{
+		// Keep all the white space.
+		while (	   p && *p
+				&& !StringEqual( p, endTag, caseInsensitive, encoding )
+			  )
+		{
+			int len;
+			char cArr[4] = { 0, 0, 0, 0 };
+			p = GetChar( p, cArr, &len, encoding );
+			text->append( cArr, len );
+		}
+	}
+	else
+	{
+		bool whitespace = false;
+
+		// Remove leading white space:
+		p = SkipWhiteSpace( p, encoding );
+		while (	   p && *p
+				&& !StringEqual( p, endTag, caseInsensitive, encoding ) )
+		{
+			if ( *p == '\r' || *p == '\n' )
+			{
+				whitespace = true;
+				++p;
+			}
+			else if ( IsWhiteSpace( *p ) )
+			{
+				whitespace = true;
+				++p;
+			}
+			else
+			{
+				// If we've found whitespace, add it before the
+				// new character. Any whitespace just becomes a space.
+				if ( whitespace )
+				{
+					(*text) += ' ';
+					whitespace = false;
+				}
+				int len;
+				char cArr[4] = { 0, 0, 0, 0 };
+				p = GetChar( p, cArr, &len, encoding );
+				if ( len == 1 )
+					(*text) += cArr[0];	// more efficient
+				else
+					text->append( cArr, len );
+			}
+		}
+	}
+	if ( p )
+		p += strlen( endTag );
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+
+void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	// The basic issue with a document is that we don't know what we're
+	// streaming. Read something presumed to be a tag (and hope), then
+	// identify it, and call the appropriate stream method on the tag.
+	//
+	// This "pre-streaming" will never read the closing ">" so the
+	// sub-tag can orient itself.
+
+	if ( !StreamTo( in, '<', tag ) )
+	{
+		SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return;
+	}
+
+	while ( in->good() )
+	{
+		int tagIndex = (int) tag->length();
+		while ( in->good() && in->peek() != '>' )
+		{
+			int c = in->get();
+			if ( c <= 0 )
+			{
+				SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+				break;
+			}
+			(*tag) += (char) c;
+		}
+
+		if ( in->good() )
+		{
+			// We now have something we presume to be a node of
+			// some sort. Identify it, and call the node to
+			// continue streaming.
+			TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
+
+			if ( node )
+			{
+				node->StreamIn( in, tag );
+				bool isElement = node->ToElement() != 0;
+				delete node;
+				node = 0;
+
+				// If this is the root element, we're done. Parsing will be
+				// done by the >> operator.
+				if ( isElement )
+				{
+					return;
+				}
+			}
+			else
+			{
+				SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
+				return;
+			}
+		}
+	}
+	// We should have returned sooner.
+	SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
+}
+
+#endif
+
+const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding )
+{
+	ClearError();
+
+	// Parse away, at the document level. Since a document
+	// contains nothing but other tags, most of what happens
+	// here is skipping white space.
+	if ( !p || !*p )
+	{
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	// Note that, for a document, this needs to come
+	// before the while space skip, so that parsing
+	// starts from the pointer we are given.
+	location.Clear();
+	if ( prevData )
+	{
+		location.row = prevData->cursor.row;
+		location.col = prevData->cursor.col;
+	}
+	else
+	{
+		location.row = 0;
+		location.col = 0;
+	}
+	TiXmlParsingData data( p, TabSize(), location.row, location.col );
+	location = data.Cursor();
+
+	if ( encoding == TIXML_ENCODING_UNKNOWN )
+	{
+		// Check for the Microsoft UTF-8 lead bytes.
+		const unsigned char* pU = (const unsigned char*)p;
+		if (	*(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
+			 && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
+			 && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
+		{
+			encoding = TIXML_ENCODING_UTF8;
+			useMicrosoftBOM = true;
+		}
+	}
+
+    p = SkipWhiteSpace( p, encoding );
+	if ( !p )
+	{
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	while ( p && *p )
+	{
+		TiXmlNode* node = Identify( p, encoding );
+		if ( node )
+		{
+			p = node->Parse( p, &data, encoding );
+			LinkEndChild( node );
+		}
+		else
+		{
+			break;
+		}
+
+		// Did we get encoding info?
+		if (    encoding == TIXML_ENCODING_UNKNOWN
+			 && node->ToDeclaration() )
+		{
+			TiXmlDeclaration* dec = node->ToDeclaration();
+			const char* enc = dec->Encoding();
+			assert( enc );
+
+			if ( *enc == 0 )
+				encoding = TIXML_ENCODING_UTF8;
+			else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) )
+				encoding = TIXML_ENCODING_UTF8;
+			else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
+				encoding = TIXML_ENCODING_UTF8;	// incorrect, but be nice
+			else
+				encoding = TIXML_ENCODING_LEGACY;
+		}
+
+		p = SkipWhiteSpace( p, encoding );
+	}
+
+	// Was this empty?
+	if ( !firstChild ) {
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding );
+		return 0;
+	}
+
+	// All is well.
+	return p;
+}
+
+void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	// The first error in a chain is more accurate - don't set again!
+	if ( error )
+		return;
+
+	assert( err > 0 && err < TIXML_ERROR_STRING_COUNT );
+	error   = true;
+	errorId = err;
+	errorDesc = errorString[ errorId ];
+
+	errorLocation.Clear();
+	if ( pError && data )
+	{
+		data->Stamp( pError, encoding );
+		errorLocation = data->Cursor();
+	}
+}
+
+
+TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
+{
+	TiXmlNode* returnNode = 0;
+
+	p = SkipWhiteSpace( p, encoding );
+	if( !p || !*p || *p != '<' )
+	{
+		return 0;
+	}
+
+	TiXmlDocument* doc = GetDocument();
+	p = SkipWhiteSpace( p, encoding );
+
+	if ( !p || !*p )
+	{
+		return 0;
+	}
+
+	// What is this thing?
+	// - Elements start with a letter or underscore, but xml is reserved.
+	// - Comments: <!--
+	// - Decleration: <?xml
+	// - StylesheetReference <?xml-stylesheet
+	// - Everthing else is unknown to tinyxml.
+	//
+
+	const char* xmlHeader = { "<?xml" };
+	const char* xmlSSHeader = { "<?xml-stylesheet" };
+	const char* commentHeader = { "<!--" };
+	const char* dtdHeader = { "<!" };
+	const char* cdataHeader = { "<![CDATA[" };
+
+	if ( StringEqual( p, xmlSSHeader, true, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Stylesheet Reference\n" );
+		#endif
+		returnNode = new TiXmlStylesheetReference();
+	}
+	else if ( StringEqual( p, xmlHeader, true, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Declaration\n" );
+		#endif
+		returnNode = new TiXmlDeclaration();
+	}
+	else if ( StringEqual( p, commentHeader, false, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Comment\n" );
+		#endif
+		returnNode = new TiXmlComment();
+	}
+	else if ( StringEqual( p, cdataHeader, false, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing CDATA\n" );
+		#endif
+		TiXmlText* text = new TiXmlText( "" );
+		text->SetCDATA( true );
+		returnNode = text;
+	}
+	else if ( StringEqual( p, dtdHeader, false, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Unknown(1)\n" );
+		#endif
+		returnNode = new TiXmlUnknown();
+	}
+	else if (    IsAlpha( *(p+1), encoding )
+			  || *(p+1) == '_' )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Element\n" );
+		#endif
+		returnNode = new TiXmlElement( "" );
+	}
+	else
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Unknown(2)\n" );
+		#endif
+		returnNode = new TiXmlUnknown();
+	}
+
+	if ( returnNode )
+	{
+		// Set the parent, so it can report errors
+		returnNode->parent = this;
+	}
+	else
+	{
+		if ( doc )
+			doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+	}
+	return returnNode;
+}
+
+#ifdef TIXML_USE_STL
+
+void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
+{
+	// We're called with some amount of pre-parsing. That is, some of "this"
+	// element is in "tag". Go ahead and stream to the closing ">"
+	while( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c ;
+
+		if ( c == '>' )
+			break;
+	}
+
+	if ( tag->length() < 3 ) return;
+
+	// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
+	// If not, identify and stream.
+
+	if (    tag->at( tag->length() - 1 ) == '>'
+		 && tag->at( tag->length() - 2 ) == '/' )
+	{
+		// All good!
+		return;
+	}
+	else if ( tag->at( tag->length() - 1 ) == '>' )
+	{
+		// There is more. Could be:
+		//		text
+		//		cdata text (which looks like another node)
+		//		closing tag
+		//		another node.
+		for ( ;; )
+		{
+			StreamWhiteSpace( in, tag );
+
+			// Do we have text?
+			if ( in->good() && in->peek() != '<' )
+			{
+				// Yep, text.
+				TiXmlText text( "" );
+				text.StreamIn( in, tag );
+
+				// What follows text is a closing tag or another node.
+				// Go around again and figure it out.
+				continue;
+			}
+
+			// We now have either a closing tag...or another node.
+			// We should be at a "<", regardless.
+			if ( !in->good() ) return;
+			assert( in->peek() == '<' );
+			int tagIndex = (int) tag->length();
+
+			bool closingTag = false;
+			bool firstCharFound = false;
+
+			for( ;; )
+			{
+				if ( !in->good() )
+					return;
+
+				int c = in->peek();
+				if ( c <= 0 )
+				{
+					TiXmlDocument* document = GetDocument();
+					if ( document )
+						document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+					return;
+				}
+
+				if ( c == '>' )
+					break;
+
+				*tag += (char) c;
+				in->get();
+
+				// Early out if we find the CDATA id.
+				if ( c == '[' && tag->size() >= 9 )
+				{
+					size_t len = tag->size();
+					const char* start = tag->c_str() + len - 9;
+					if ( strcmp( start, "<![CDATA[" ) == 0 ) {
+						assert( !closingTag );
+						break;
+					}
+				}
+
+				if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
+				{
+					firstCharFound = true;
+					if ( c == '/' )
+						closingTag = true;
+				}
+			}
+			// If it was a closing tag, then read in the closing '>' to clean up the input stream.
+			// If it was not, the streaming will be done by the tag.
+			if ( closingTag )
+			{
+				if ( !in->good() )
+					return;
+
+				int c = in->get();
+				if ( c <= 0 )
+				{
+					TiXmlDocument* document = GetDocument();
+					if ( document )
+						document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+					return;
+				}
+				assert( c == '>' );
+				*tag += (char) c;
+
+				// We are done, once we've found our closing tag.
+				return;
+			}
+			else
+			{
+				// If not a closing tag, id it, and stream.
+				const char* tagloc = tag->c_str() + tagIndex;
+				TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING );
+				if ( !node )
+					return;
+				node->StreamIn( in, tag );
+				delete node;
+				node = 0;
+
+				// No return: go around from the beginning: text, closing tag, or node.
+			}
+		}
+	}
+}
+#endif
+
+const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	p = SkipWhiteSpace( p, encoding );
+	TiXmlDocument* document = GetDocument();
+
+	if ( !p || !*p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
+		return 0;
+	}
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+
+	if ( *p != '<' )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
+		return 0;
+	}
+
+	p = SkipWhiteSpace( p+1, encoding );
+
+	// Read the name.
+	const char* pErr = p;
+
+    p = ReadName( p, &value, encoding );
+	if ( !p || !*p )
+	{
+		if ( document )	document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
+		return 0;
+	}
+
+    TIXML_STRING endTag ("</");
+	endTag += value;
+	endTag += ">";
+
+	// Check for and read attributes. Also look for an empty
+	// tag or an end tag.
+	while ( p && *p )
+	{
+		pErr = p;
+		p = SkipWhiteSpace( p, encoding );
+		if ( !p || !*p )
+		{
+			if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
+			return 0;
+		}
+		if ( *p == '/' )
+		{
+			++p;
+			// Empty tag.
+			if ( *p  != '>' )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
+				return 0;
+			}
+			return (p+1);
+		}
+		else if ( *p == '>' )
+		{
+			// Done with attributes (if there were any.)
+			// Read the value -- which can include other
+			// elements -- read the end tag, and return.
+			++p;
+			p = ReadValue( p, data, encoding );		// Note this is an Element method, and will set the error if one happens.
+			if ( !p || !*p ) {
+				// We were looking for the end tag, but found nothing.
+				// Fix for [ 1663758 ] Failure to report error on bad XML
+				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
+				return 0;
+			}
+
+			// We should find the end tag now
+			if ( StringEqual( p, endTag.c_str(), false, encoding ) )
+			{
+				p += endTag.length();
+				return p;
+			}
+			else
+			{
+				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
+				return 0;
+			}
+		}
+		else
+		{
+			// Try to read an attribute:
+			TiXmlAttribute* attrib = new TiXmlAttribute();
+			if ( !attrib )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
+				return 0;
+			}
+
+			attrib->SetDocument( document );
+			pErr = p;
+			p = attrib->Parse( p, data, encoding );
+
+			if ( !p || !*p )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
+				delete attrib;
+				return 0;
+			}
+
+			// Handle the strange case of double attributes:
+			#ifdef TIXML_USE_STL
+			TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
+			#else
+			TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
+			#endif
+			if ( node )
+			{
+				node->SetValue( attrib->Value() );
+				delete attrib;
+				return 0;
+			}
+
+			attributeSet.Add( attrib );
+		}
+	}
+	return p;
+}
+
+
+const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	TiXmlDocument* document = GetDocument();
+
+	// Read in text and elements in any order.
+	const char* pWithWhiteSpace = p;
+	p = SkipWhiteSpace( p, encoding );
+
+	while ( p && *p )
+	{
+		if ( *p != '<' )
+		{
+			// Take what we have, make a text element.
+			TiXmlText* textNode = new TiXmlText( "" );
+
+			if ( !textNode )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
+				    return 0;
+			}
+
+			if ( TiXmlBase::IsWhiteSpaceCondensed() )
+			{
+				p = textNode->Parse( p, data, encoding );
+			}
+			else
+			{
+				// Special case: we want to keep the white space
+				// so that leading spaces aren't removed.
+				p = textNode->Parse( pWithWhiteSpace, data, encoding );
+			}
+
+			if ( !textNode->Blank() )
+				LinkEndChild( textNode );
+			else
+				delete textNode;
+		}
+		else
+		{
+			// We hit a '<'
+			// Have we hit a new element or an end tag? This could also be
+			// a TiXmlText in the "CDATA" style.
+			if ( StringEqual( p, "</", false, encoding ) )
+			{
+				return p;
+			}
+			else
+			{
+				TiXmlNode* node = Identify( p, encoding );
+				if ( node )
+				{
+					p = node->Parse( p, data, encoding );
+					LinkEndChild( node );
+				}
+				else
+				{
+					return 0;
+				}
+			}
+		}
+		pWithWhiteSpace = p;
+		p = SkipWhiteSpace( p, encoding );
+	}
+
+	if ( !p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
+	}
+	return p;
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c;
+
+		if ( c == '>' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+
+const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	TiXmlDocument* document = GetDocument();
+	p = SkipWhiteSpace( p, encoding );
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+	if ( !p || !*p || *p != '<' )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding );
+		return 0;
+	}
+	++p;
+    value = "";
+
+	while ( p && *p && *p != '>' )
+	{
+		value += *p;
+		++p;
+	}
+
+	if ( !p )
+	{
+		if ( document )	document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
+	}
+	if ( *p == '>' )
+		return p+1;
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+
+		(*tag) += (char) c;
+
+		if ( c == '>'
+			 && tag->at( tag->length() - 2 ) == '-'
+			 && tag->at( tag->length() - 3 ) == '-' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+
+const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	TiXmlDocument* document = GetDocument();
+	value = "";
+
+	p = SkipWhiteSpace( p, encoding );
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+	const char* startTag = "<!--";
+	const char* endTag   = "-->";
+
+	if ( !StringEqual( p, startTag, false, encoding ) )
+	{
+		document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding );
+		return 0;
+	}
+	p += strlen( startTag );
+
+	// [ 1475201 ] TinyXML parses entities in comments
+	// Oops - ReadText doesn't work, because we don't want to parse the entities.
+	// p = ReadText( p, &value, false, endTag, false, encoding );
+	//
+	// from the XML spec:
+	/*
+	 [Definition: Comments may appear anywhere in a document outside other markup; in addition,
+	              they may appear within the document type declaration at places allowed by the grammar.
+				  They are not part of the document's character data; an XML processor MAY, but need not,
+				  make it possible for an application to retrieve the text of comments. For compatibility,
+				  the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
+				  references MUST NOT be recognized within comments.
+
+				  An example of a comment:
+
+				  <!-- declarations for <head> & <body> -->
+	*/
+
+    value = "";
+	// Keep all the white space.
+	while (	p && *p && !StringEqual( p, endTag, false, encoding ) )
+	{
+		value.append( p, 1 );
+		++p;
+	}
+	if ( p )
+		p += strlen( endTag );
+
+	return p;
+}
+
+
+const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	p = SkipWhiteSpace( p, encoding );
+	if ( !p || !*p ) return 0;
+
+//	int tabsize = 4;
+//	if ( document )
+//		tabsize = document->TabSize();
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+	// Read the name, the '=' and the value.
+	const char* pErr = p;
+	p = ReadName( p, &name, encoding );
+	if ( !p || !*p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
+		return 0;
+	}
+	p = SkipWhiteSpace( p, encoding );
+	if ( !p || !*p || *p != '=' )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+		return 0;
+	}
+
+	++p;	// skip '='
+	p = SkipWhiteSpace( p, encoding );
+	if ( !p || !*p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+		return 0;
+	}
+
+	const char* end;
+	const char SINGLE_QUOTE = '\'';
+	const char DOUBLE_QUOTE = '\"';
+
+	if ( *p == SINGLE_QUOTE )
+	{
+		++p;
+		end = "\'";		// single quote in string
+		p = ReadText( p, &value, false, end, false, encoding );
+	}
+	else if ( *p == DOUBLE_QUOTE )
+	{
+		++p;
+		end = "\"";		// double quote in string
+		p = ReadText( p, &value, false, end, false, encoding );
+	}
+	else
+	{
+		// All attribute values should be in single or double quotes.
+		// But this is such a common error that the parser will try
+		// its best, even without them.
+		value = "";
+		while (    p && *p											// existence
+				&& !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r'	// whitespace
+				&& *p != '/' && *p != '>' )							// tag end
+		{
+			if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
+				// [ 1451649 ] Attribute values with trailing quotes not handled correctly
+				// We did not have an opening quote but seem to have a
+				// closing one. Give up and throw an error.
+				if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+				return 0;
+			}
+			value += *p;
+			++p;
+		}
+	}
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->peek();
+		if ( !cdata && (c == '<' ) )
+		{
+			return;
+		}
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+
+		(*tag) += (char) c;
+		in->get();	// "commits" the peek made above
+
+		if ( cdata && c == '>' && tag->size() >= 3 ) {
+			size_t len = tag->size();
+			if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) {
+				// terminator of cdata.
+				return;
+			}
+		}
+	}
+}
+#endif
+
+const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	value = "";
+	TiXmlDocument* document = GetDocument();
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+
+	const char* const startTag = "<![CDATA[";
+	const char* const endTag   = "]]>";
+
+	if ( cdata || StringEqual( p, startTag, false, encoding ) )
+	{
+		cdata = true;
+
+		if ( !StringEqual( p, startTag, false, encoding ) )
+		{
+			document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding );
+			return 0;
+		}
+		p += strlen( startTag );
+
+		// Keep all the white space, ignore the encoding, etc.
+		while (	   p && *p
+				&& !StringEqual( p, endTag, false, encoding )
+			  )
+		{
+			value += *p;
+			++p;
+		}
+
+		TIXML_STRING dummy;
+		p = ReadText( p, &dummy, false, endTag, false, encoding );
+		return p;
+	}
+	else
+	{
+		bool ignoreWhite = true;
+
+		const char* end = "<";
+		p = ReadText( p, &value, ignoreWhite, end, false, encoding );
+		if ( p )
+			return p-1;	// don't truncate the '<'
+		return 0;
+	}
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c;
+
+		if ( c == '>' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding )
+{
+	p = SkipWhiteSpace( p, _encoding );
+	// Find the beginning, find the end, and look for
+	// the stuff in-between.
+	TiXmlDocument* document = GetDocument();
+	if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
+		return 0;
+	}
+	if ( data )
+	{
+		data->Stamp( p, _encoding );
+		location = data->Cursor();
+	}
+	p += 5;
+
+	version = "";
+	encoding = "";
+	standalone = "";
+
+	while ( p && *p )
+	{
+		if ( *p == '>' )
+		{
+			++p;
+			return p;
+		}
+
+		p = SkipWhiteSpace( p, _encoding );
+		if ( StringEqual( p, "version", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			version = attrib.Value();
+		}
+		else if ( StringEqual( p, "encoding", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			encoding = attrib.Value();
+		}
+		else if ( StringEqual( p, "standalone", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			standalone = attrib.Value();
+		}
+		else
+		{
+			// Read over whatever it is.
+			while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
+				++p;
+		}
+	}
+	return 0;
+}
+
+bool TiXmlText::Blank() const
+{
+	for ( unsigned i=0; i<value.length(); i++ )
+		if ( !IsWhiteSpace( value[i] ) )
+			return false;
+	return true;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlStylesheetReference::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c;
+
+		if ( c == '>' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+const char* TiXmlStylesheetReference::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding )
+{
+	p = SkipWhiteSpace( p, _encoding );
+	// Find the beginning, find the end, and look for
+	// the stuff in-between.
+	TiXmlDocument* document = GetDocument();
+	if ( !p || !*p || !StringEqual( p, "<?xml-stylesheet", true, _encoding ) )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
+		return 0;
+	}
+	if ( data )
+	{
+		data->Stamp( p, _encoding );
+		location = data->Cursor();
+	}
+	p += 5;
+
+	type = "";
+	href = "";
+
+	while ( p && *p )
+	{
+		if ( *p == '>' )
+		{
+			++p;
+			return p;
+		}
+
+		p = SkipWhiteSpace( p, _encoding );
+		if ( StringEqual( p, "type", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			type = attrib.Value();
+		}
+		else if ( StringEqual( p, "href", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			href = attrib.Value();
+		}
+		else
+		{
+			// Read over whatever it is.
+			while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
+				++p;
+		}
+	}
+	return 0;
+}
Index: /code/branches/physics/src/tolua/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/tolua/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/tolua/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,73 @@
+SET (TOLUALIB_SRC_FILES
+  tolua_event.c
+  tolua_is.c
+  tolua_map.c
+  tolua_push.c
+  tolua_to.c
+)
+
+ADD_LIBRARY (tolualib_orxonox SHARED ${TOLUALIB_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (tolualib_orxonox
+  lua_orxonox
+)
+
+
+SET (TOLUAGEN_SRC_FILES
+  tolua.c
+  toluabind.c
+)
+
+ADD_EXECUTABLE (toluagen_orxonox ${TOLUAGEN_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (toluagen_orxonox
+  lua_orxonox
+  tolualib_orxonox
+  m
+)
+
+
+SET (TOLUA_PACKAGE "../../src/tolua/tolua-5.1.pkg")
+GET_TARGET_PROPERTY(TOLUAGEN_EXE toluagen_orxonox LOCATION)
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/toluabind_orxonox.c
+  COMMAND ${TOLUAGEN_EXE} -n tolua -o ../../src/tolua/toluabind_orxonox.c -H ../../src/tolua/toluabind_orxonox.h ${TOLUA_PACKAGE}
+  DEPENDS
+    toluagen_orxonox
+    tolua-5.1.pkg
+    lua/compat-5.1.lua
+    lua/compat.lua
+    lua/basic.lua
+    lua/feature.lua
+    lua/verbatim.lua
+    lua/code.lua
+    lua/typedef.lua
+    lua/container.lua
+    lua/package.lua
+    lua/module.lua
+    lua/namespace.lua
+    lua/define.lua
+    lua/enumerate.lua
+    lua/declaration.lua
+    lua/variable.lua
+    lua/array.lua
+    lua/function.lua
+    lua/operator.lua
+    lua/class.lua
+    lua/clean.lua
+    lua/doit.lua
+  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
+)
+
+SET (TOLUAEXE_SRC_FILES
+  tolua.c
+  toluabind_orxonox.c
+)
+
+ADD_EXECUTABLE (tolua_orxonox ${TOLUAEXE_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (tolua_orxonox
+  lua_orxonox
+  tolualib_orxonox
+  m
+)
Index: /code/branches/physics/src/tolua/lua/array.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/array.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/array.lua	(revision 2122)
@@ -0,0 +1,227 @@
+-- tolua: array class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1999
+-- $Id: array.lua,v 1.1 2000/11/06 22:03:57 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Array class
+-- Represents a extern array variable or a public member of a class.
+-- Stores all fields present in a declaration.
+classArray = {
+}
+classArray.__index = classArray
+setmetatable(classArray,classDeclaration)
+
+-- Print method
+function classArray:print (ident,close)
+ print(ident.."Array{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." def  = '"..self.def.."',")
+ print(ident.." dim  = '"..self.dim.."',")
+ print(ident.." ret  = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- check if it is a variable
+function classArray:isvariable ()
+ return true
+end
+
+
+-- get variable value
+function classArray:getvalue (class,static)
+ if class and static then
+  return class..'::'..self.name..'[tolua_index]'
+ elseif class then
+  return 'self->'..self.name..'[tolua_index]'
+ else
+  return self.name..'[tolua_index]'
+ end
+end
+
+-- Write binding functions
+function classArray:supcode ()
+ local class = self:inclass()
+
+ -- get function ------------------------------------------------
+ if class then
+  output("/* get function:",self.name," of class ",class," */")
+ else
+  output("/* get function:",self.name," */")
+ end
+ self.cgetname = self:cfuncname("tolua_get")
+ output("#ifndef TOLUA_DISABLE_"..self.cgetname)
+ output("\nstatic int",self.cgetname,"(lua_State* tolua_S)")
+ output("{")
+ output(" int tolua_index;")
+
+ -- declare self, if the case
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class and static==nil then
+  output(' ',self.parent.type,'*','self;')
+  output(' lua_pushstring(tolua_S,".self");')
+  output(' lua_rawget(tolua_S,1);')
+  output(' self = ')
+  output('(',self.parent.type,'*) ')
+  output('lua_touserdata(tolua_S,-1);')
+ elseif static then
+  _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+ -- check index
+	output('#ifndef TOLUA_RELEASE\n')
+	output(' {')
+	output('  tolua_Error tolua_err;')
+ output('  if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
+ output('   tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
+	output(' }')
+	output('#endif\n')
+	if flags['1'] then -- for compatibility with tolua5 ?
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
+	else
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);')
+	end
+	output('#ifndef TOLUA_RELEASE\n')
+	if self.dim and self.dim ~= '' then
+	  output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
+	else
+	  output(' if (tolua_index<0)')
+	end
+ output('  tolua_error(tolua_S,"array indexing out of range.",NULL);')
+	output('#endif\n')
+
+ -- return value
+ local t,ct = isbasic(self.type)
+ if t then
+  output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static)..');')
+ else
+		t = self.type
+  if self.ptr == '&' or self.ptr == '' then
+   output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')
+  else
+   output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')
+  end
+ end
+ output(' return 1;')
+ output('}')
+ output('#endif //#ifndef TOLUA_DISABLE\n')
+ output('\n')
+
+ -- set function ------------------------------------------------
+ if not strfind(self.type,'const') then
+  if class then
+   output("/* set function:",self.name," of class ",class," */")
+  else
+   output("/* set function:",self.name," */")
+  end
+  self.csetname = self:cfuncname("tolua_set")
+  output("#ifndef TOLUA_DISABLE_"..self.csetname)
+  output("\nstatic int",self.csetname,"(lua_State* tolua_S)")
+  output("{")
+
+  -- declare index
+  output(' int tolua_index;')
+
+  -- declare self, if the case
+  local _,_,static = strfind(self.mod,'^%s*(static)')
+  if class and static==nil then
+   output(' ',self.parent.type,'*','self;')
+   output(' lua_pushstring(tolua_S,".self");')
+   output(' lua_rawget(tolua_S,1);')
+   output(' self = ')
+   output('(',self.parent.type,'*) ')
+   output('lua_touserdata(tolua_S,-1);')
+  elseif static then
+   _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+  end
+
+  -- check index
+	 output('#ifndef TOLUA_RELEASE\n')
+	 output(' {')
+	 output('  tolua_Error tolua_err;')
+  output('  if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
+  output('   tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
+		output(' }')
+		output('#endif\n')
+
+	if flags['1'] then -- for compatibility with tolua5 ?
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
+	else
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);')
+	end
+
+	 output('#ifndef TOLUA_RELEASE\n')
+	if self.dim and self.dim ~= '' then
+	  output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
+	else
+	  output(' if (tolua_index<0)')
+	end
+  output('  tolua_error(tolua_S,"array indexing out of range.",NULL);')
+		output('#endif\n')
+
+  -- assign value
+  local ptr = ''
+  if self.ptr~='' then ptr = '*' end
+  output(' ')
+  if class and static then
+   output(class..'::'..self.name..'[tolua_index]')
+  elseif class then
+   output('self->'..self.name..'[tolua_index]')
+  else
+   output(self.name..'[tolua_index]')
+  end
+  local t = isbasic(self.type)
+  output(' = ')
+  if not t and ptr=='' then output('*') end
+  output('((',self.mod,self.type)
+  if not t then
+   output('*')
+  end
+  output(') ')
+  local def = 0
+  if self.def ~= '' then def = self.def end
+  if t then
+   output('tolua_to'..t,'(tolua_S,3,',def,'));')
+  else
+   output('tolua_tousertype(tolua_S,3,',def,'));')
+  end
+  output(' return 0;')
+  output('}')
+  output('#endif //#ifndef TOLUA_DISABLE\n')
+  output('\n')
+ end
+
+end
+
+function classArray:register (pre)
+ pre = pre or ''
+ if self.csetname then
+  output(pre..'tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
+ else
+  output(pre..'tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
+ end
+end
+
+-- Internal constructor
+function _Array (t)
+ setmetatable(t,classArray)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the variable declaration.
+function Array (s)
+ return _Array (Declaration(s,'var'))
+end
+
+
Index: /code/branches/physics/src/tolua/lua/basic.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/basic.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/basic.lua	(revision 2122)
@@ -0,0 +1,356 @@
+-- tolua: basic utility functions
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- Last update: Apr 2003
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Basic C types and their corresponding Lua types
+-- All occurrences of "char*" will be replaced by "_cstring",
+-- and all occurrences of "void*" will be replaced by "_userdata"
+_basic = {
+ ['void'] = '',
+ ['char'] = 'number',
+ ['int'] = 'number',
+ ['short'] = 'number',
+ ['long'] = 'number',
+ ['unsigned'] = 'number',
+ ['float'] = 'number',
+ ['double'] = 'number',
+ ['_cstring'] = 'string',
+ ['_userdata'] = 'userdata',
+ ['char*'] = 'string',
+ ['void*'] = 'userdata',
+ ['bool'] = 'boolean',
+ ['lua_Object'] = 'value',
+ ['LUA_VALUE'] = 'value',    -- for compatibility with tolua 4.0
+ ['lua_State*'] = 'state',
+ ['_lstate'] = 'state',
+ ['lua_Function'] = 'value',
+}
+
+_basic_ctype = {
+ number = "lua_Number",
+ string = "const char*",
+ userdata = "void*",
+ boolean = "bool",
+ value = "int",
+ state = "lua_State*",
+}
+
+-- functions the are used to do a 'raw push' of basic types
+_basic_raw_push = {}
+
+-- List of user defined types
+-- Each type corresponds to a variable name that stores its tag value.
+_usertype = {}
+
+-- List of types that have to be collected
+_collect = {}
+
+-- List of types
+_global_types = {n=0}
+_global_types_hash = {}
+
+-- list of classes
+_global_classes = {}
+
+-- List of enum constants
+_global_enums = {}
+
+-- List of auto renaming
+_renaming = {}
+function appendrenaming (s)
+ local b,e,old,new = strfind(s,"%s*(.-)%s*@%s*(.-)%s*$")
+	if not b then
+	 error("#Invalid renaming syntax; it should be of the form: pattern@pattern")
+	end
+	tinsert(_renaming,{old=old, new=new})
+end
+
+function applyrenaming (s)
+	for i=1,getn(_renaming) do
+	 local m,n = gsub(s,_renaming[i].old,_renaming[i].new)
+		if n ~= 0 then
+		 return m
+		end
+	end
+	return nil
+end
+
+-- Error handler
+function tolua_error (s,f)
+if _curr_code then
+	print("***curr code for error is "..tostring(_curr_code))
+	print(debug.traceback())
+end
+ local out = _OUTPUT
+ _OUTPUT = _STDERR
+ if strsub(s,1,1) == '#' then
+  write("\n** tolua: "..strsub(s,2)..".\n\n")
+  if _curr_code then
+   local _,_,s = strfind(_curr_code,"^%s*(.-\n)") -- extract first line
+   if s==nil then s = _curr_code end
+   s = gsub(s,"_userdata","void*") -- return with 'void*'
+   s = gsub(s,"_cstring","char*")  -- return with 'char*'
+   s = gsub(s,"_lstate","lua_State*")  -- return with 'lua_State*'
+   write("Code being processed:\n"..s.."\n")
+  end
+ else
+ if not f then f = "(f is nil)" end
+  print("\n** tolua internal error: "..f..s..".\n\n")
+  return
+ end
+ _OUTPUT = out
+end
+
+function warning (msg)
+ local out = _OUTPUT
+ _OUTPUT = _STDERR
+ write("\n** tolua warning: "..msg..".\n\n")
+ _OUTPUT = out
+end
+
+-- register an user defined type: returns full type
+function regtype (t)
+	--if isbasic(t) then
+	--	return t
+	--end
+	local ft = findtype(t)
+
+	if not _usertype[ft] then
+		return appendusertype(t)
+	end
+	return ft
+end
+
+-- return type name: returns full type
+function typevar(type)
+	if type == '' or type == 'void' then
+		return type
+	else
+		local ft = findtype(type)
+		if ft then
+			return ft
+		end
+		_usertype[type] = type
+		return type
+	end
+end
+
+-- check if basic type
+function isbasic (type)
+ local t = gsub(type,'const ','')
+ local m,t = applytypedef('', t)
+ local b = _basic[t]
+ if b then
+  return b,_basic_ctype[b]
+ end
+ return nil
+end
+
+-- split string using a token
+function split (s,t)
+ local l = {n=0}
+ local f = function (s)
+  l.n = l.n + 1
+  l[l.n] = s
+  return ""
+ end
+ local p = "%s*(.-)%s*"..t.."%s*"
+ s = gsub(s,"^%s+","")
+ s = gsub(s,"%s+$","")
+ s = gsub(s,p,f)
+ l.n = l.n + 1
+ l[l.n] = gsub(s,"(%s%s*)$","")
+ return l
+end
+
+-- splits a string using a pattern, considering the spacial cases of C code (templates, function parameters, etc)
+-- pattern can't contain the '^' (as used to identify the begining of the line)
+-- also strips whitespace
+function split_c_tokens(s, pat)
+
+	s = string.gsub(s, "^%s*", "")
+	s = string.gsub(s, "%s*$", "")
+
+	local token_begin = 1
+	local token_end = 1
+	local ofs = 1
+	local ret = {n=0}
+
+	function add_token(ofs)
+
+		local t = string.sub(s, token_begin, ofs)
+		t = string.gsub(t, "^%s*", "")
+		t = string.gsub(t, "%s*$", "")
+		ret.n = ret.n + 1
+		ret[ret.n] = t
+	end
+
+	while ofs <= string.len(s) do
+
+		local sub = string.sub(s, ofs, -1)
+		local b,e = string.find(sub, "^"..pat)
+		if b then
+			add_token(ofs-1)
+			ofs = ofs+e
+			token_begin = ofs
+		else
+			local char = string.sub(s, ofs, ofs)
+			if char == "(" or char == "<" then
+
+				local block
+				if char == "(" then block = "^%b()" end
+				if char == "<" then block = "^%b<>" end
+
+				b,e = string.find(sub, block)
+				if not b then
+					-- unterminated block?
+					ofs = ofs+1
+				else
+					ofs = ofs + e
+				end
+
+			else
+				ofs = ofs+1
+			end
+		end
+
+	end
+	add_token(ofs)
+	--if ret.n == 0 then
+
+	--	ret.n=1
+	--	ret[1] = ""
+	--end
+
+	return ret
+
+end
+
+-- concatenate strings of a table
+function concat (t,f,l,jstr)
+	jstr = jstr or " "
+ local s = ''
+ local i=f
+ while i<=l do
+  s = s..t[i]
+  i = i+1
+  if i <= l then s = s..jstr end
+ end
+ return s
+end
+
+-- concatenate all parameters, following output rules
+function concatparam (line, ...)
+ local i=1
+ while i<=arg.n do
+  if _cont and not strfind(_cont,'[%(,"]') and
+     strfind(arg[i],"^[%a_~]") then
+	    line = line .. ' '
+  end
+  line = line .. arg[i]
+  if arg[i] ~= '' then
+   _cont = strsub(arg[i],-1,-1)
+  end
+  i = i+1
+ end
+ if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
+  _cont=nil line = line .. '\n'
+ end
+	return line
+end
+
+-- output line
+function output (...)
+ local i=1
+ while i<=arg.n do
+  if _cont and not strfind(_cont,'[%(,"]') and
+     strfind(arg[i],"^[%a_~]") then
+	    write(' ')
+  end
+  write(arg[i])
+  if arg[i] ~= '' then
+   _cont = strsub(arg[i],-1,-1)
+  end
+  i = i+1
+ end
+ if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
+  _cont=nil write('\n')
+ end
+end
+
+function get_property_methods(ptype, name)
+
+	if get_property_methods_hook and get_property_methods_hook(ptype,name) then
+		return get_property_methods_hook(ptype, name)
+	end
+
+	if ptype == "default" then -- get_name, set_name
+		return "get_"..name, "set_"..name
+	end
+
+	if ptype == "qt" then -- name, setName
+		return name, "set"..string.upper(string.sub(name, 1, 1))..string.sub(name, 2, -1)
+	end
+
+	if ptype == "overload" then -- name, name
+		return name,name
+	end
+
+	return nil
+end
+
+-------------- the hooks
+
+-- called right after processing the $[ichl]file directives,
+-- right before processing anything else
+-- takes the package object as the parameter
+function preprocess_hook(p)
+	-- p.code has all the input code from the pkg
+end
+
+
+-- called for every $ifile directive
+-- takes a table with a string called 'code' inside, the filename, and any extra arguments
+-- passed to $ifile. no return value
+function include_file_hook(t, filename, ...)
+
+end
+
+-- called after processing anything that's not code (like '$renaming', comments, etc)
+-- and right before parsing the actual code.
+-- takes the Package object with all the code on the 'code' key. no return value
+function preparse_hook(package)
+
+end
+
+
+-- called after writing all the output.
+-- takes the Package object
+function post_output_hook(package)
+
+end
+
+
+-- called from 'get_property_methods' to get the methods to retrieve a property
+-- according to its type
+function get_property_methods_hook(property_type, name)
+
+end
+
+-- called from ClassContainer:doparse with the string being parsed
+-- return nil, or a substring
+function parser_hook(s)
+
+	return nil
+end
+
+
Index: /code/branches/physics/src/tolua/lua/class.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/class.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/class.lua	(revision 2122)
@@ -0,0 +1,220 @@
+-- tolua: class class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Class class
+-- Represents a class definition.
+-- Stores the following fields:
+--    name = class name
+--    base = class base, if any (only single inheritance is supported)
+--    {i}  = list of members
+classClass = {
+ classtype = 'class',
+ name = '',
+ base = '',
+ type = '',
+ btype = '',
+ ctype = '',
+}
+classClass.__index = classClass
+setmetatable(classClass,classContainer)
+
+
+-- register class
+function classClass:register (pre)
+	if not self:check_public_access() then
+		return
+	end
+
+ pre = pre or ''
+ push(self)
+	if _collect[self.type] then
+		output(pre,'#ifdef __cplusplus\n')
+  output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",'.._collect[self.type]..');')
+		output(pre,'#else\n')
+  output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
+		output(pre,'#endif\n')
+	else
+  output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
+	end
+	if self.extra_bases then
+		for k,base in ipairs(self.extra_bases) do
+			-- not now
+   --output(pre..' tolua_addbase(tolua_S, "'..self.type..'", "'..base..'");')
+		end
+	end
+ output(pre..'tolua_beginmodule(tolua_S,"'..self.lname..'");')
+ local i=1
+ while self[i] do
+  self[i]:register(pre..' ')
+  i = i+1
+ end
+ output(pre..'tolua_endmodule(tolua_S);')
+	pop()
+end
+
+-- return collection requirement
+function classClass:requirecollection (t)
+	if self.flags.protected_destructor then
+		return false
+	end
+ push(self)
+	local r = false
+ local i=1
+ while self[i] do
+  r = self[i]:requirecollection(t) or r
+  i = i+1
+ end
+	pop()
+	-- only class that exports destructor can be appropriately collected
+	-- classes that export constructors need to have a collector (overrided by -D flag on command line)
+	if self._delete or ((not flags['D']) and self._new) then
+		--t[self.type] = "tolua_collect_" .. gsub(self.type,"::","_")
+		t[self.type] = "tolua_collect_" .. clean_template(self.type)
+		r = true
+	end
+ return r
+end
+
+-- output tags
+function classClass:decltype ()
+ push(self)
+	self.type = regtype(self.original_name or self.name)
+	self.btype = typevar(self.base)
+	self.ctype = 'const '..self.type
+	if self.extra_bases then
+		for i=1,table.getn(self.extra_bases) do
+			self.extra_bases[i] = typevar(self.extra_bases[i])
+		end
+	end
+ local i=1
+ while self[i] do
+  self[i]:decltype()
+  i = i+1
+ end
+	pop()
+end
+
+
+-- Print method
+function classClass:print (ident,close)
+ print(ident.."Class{")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." base = '"..self.base.."';")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." btype = '"..self.btype.."',")
+ print(ident.." ctype = '"..self.ctype.."',")
+ local i=1
+ while self[i] do
+  self[i]:print(ident.." ",",")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+function classClass:set_protected_destructor(p)
+	self.flags.protected_destructor = self.flags.protected_destructor or p
+end
+
+-- Internal constructor
+function _Class (t)
+ setmetatable(t,classClass)
+ t:buildnames()
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects the name, the base (array) and the body of the class.
+function Class (n,p,b)
+
+	if table.getn(p) > 1 then
+		b = string.sub(b, 1, -2)
+		for i=2,table.getn(p),1 do
+			b = b.."\n tolua_inherits "..p[i].." __"..p[i].."__;\n"
+		end
+		b = b.."\n}"
+	end
+
+	-- check for template
+	b = string.gsub(b, "^{%s*TEMPLATE_BIND", "{\nTOLUA_TEMPLATE_BIND")
+	local t,_,T,I = string.find(b, "^{%s*TOLUA_TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+")
+	if t then
+
+		-- remove quotes
+		I = string.gsub(I, "\"", "")
+		T = string.gsub(T, "\"", "")
+		-- get type list
+		local types = split_c_tokens(I, ",")
+		-- remove TEMPLATE_BIND line
+		local bs = string.gsub(b, "^{%s*TOLUA_TEMPLATE_BIND[^\n]*\n", "{\n")
+
+		-- replace
+		for i =1 , types.n do
+
+			local Tl = split(T, " ")
+			local Il = split_c_tokens(types[i], " ")
+			local bI = bs
+			local pI = {}
+			for j = 1,Tl.n do
+				Tl[j] = findtype(Tl[j]) or Tl[j]
+				bI = string.gsub(bI, "([^_%w])"..Tl[j].."([^_%w])", "%1"..Il[j].."%2")
+				if p then
+					for i=1,table.getn(p) do
+						pI[i] = string.gsub(p[i], "([^_%w]?)"..Tl[j].."([^_%w]?)", "%1"..Il[j].."%2")
+					end
+				end
+			end
+			--local append = "<"..string.gsub(types[i], "%s+", ",")..">"
+			local append = "<"..concat(Il, 1, table.getn(Il), ",")..">"
+			append = string.gsub(append, "%s*,%s*", ",")
+			append = string.gsub(append, ">>", "> >")
+			for i=1,table.getn(pI) do
+				--pI[i] = string.gsub(pI[i], ">>", "> >")
+				pI[i] = resolve_template_types(pI[i])
+			end
+			bI = string.gsub(bI, ">>", "> >")
+			Class(n..append, pI, bI)
+		end
+		return
+	end
+
+	local mbase
+
+	if p then
+		mbase = table.remove(p, 1)
+		if not p[1] then p = nil end
+	end
+
+	mbase = mbase and resolve_template_types(mbase)
+
+	local c
+	local oname = string.gsub(n, "@.*$", "")
+	oname = getnamespace(classContainer.curr)..oname
+
+	if _global_classes[oname] then
+		c = _global_classes[oname]
+		if mbase and ((not c.base) or c.base == "") then
+			c.base = mbase
+		end
+	else
+		c = _Class(_Container{name=n, base=mbase, extra_bases=p})
+
+		local ft = getnamespace(c.parent)..c.original_name
+		append_global_type(ft, c)
+	end
+
+	push(c)
+	c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+	pop()
+end
+
Index: /code/branches/physics/src/tolua/lua/clean.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/clean.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/clean.lua	(revision 2122)
@@ -0,0 +1,79 @@
+-- mark up comments and strings
+STR1 = "\001"
+STR2 = "\002"
+STR3 = "\003"
+STR4 = "\004"
+REM  = "\005"
+ANY  = "([\001-\005])"
+ESC1 = "\006"
+ESC2 = "\007"
+
+MASK = { -- the substitution order is important
+ {ESC1, "\\'"},
+ {ESC2, '\\"'},
+ {STR1, "'"},
+ {STR2, '"'},
+ {STR3, "%[%["},
+ {STR4, "%]%]"},
+ {REM , "%-%-"},
+}
+
+function mask (s)
+ for i = 1,getn(MASK)  do
+  s = gsub(s,MASK[i][2],MASK[i][1])
+ end
+ return s
+end
+
+function unmask (s)
+ for i = 1,getn(MASK)  do
+  s = gsub(s,MASK[i][1],MASK[i][2])
+ end
+ return s
+end
+
+function clean (s)
+ -- check for compilation error
+ local code = "return function ()\n" .. s .. "\n end"
+ if not dostring(code) then
+  return nil
+ end
+
+ if flags['C'] then
+ 	return s
+ end
+
+ local S = "" -- saved string
+
+ s = mask(s)
+
+ -- remove blanks and comments
+ while 1 do
+  local b,e,d = strfind(s,ANY)
+  if b then
+   S = S..strsub(s,1,b-1)
+   s = strsub(s,b+1)
+   if d==STR1 or d==STR2 then
+    e = strfind(s,d)
+    S = S ..d..strsub(s,1,e)
+    s = strsub(s,e+1)
+   elseif d==STR3 then
+    e = strfind(s,STR4)
+    S = S..d..strsub(s,1,e)
+    s = strsub(s,e+1)
+   elseif d==REM then
+    s = gsub(s,"[^\n]*(\n?)","%1",1)
+   end
+  else
+   S = S..s
+   break
+  end
+ end
+ -- eliminate unecessary spaces
+ S = gsub(S,"[ \t]+"," ")
+ S = gsub(S,"[ \t]*\n[ \t]*","\n")
+	S = gsub(S,"\n+","\n")
+ S = unmask(S)
+ return S
+end
+
Index: /code/branches/physics/src/tolua/lua/code.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/code.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/code.lua	(revision 2122)
@@ -0,0 +1,96 @@
+-- tolua: code class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1999
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+-- global
+code_n = 1
+
+-- Code class
+-- Represents Lua code to be compiled and included
+-- in the initialization function.
+-- The following fields are stored:
+--   text = text code
+classCode = {
+ text = '',
+}
+classCode.__index = classCode
+setmetatable(classCode,classFeature)
+
+-- register code
+function classCode:register (pre)
+ pre = pre or ''
+ -- clean Lua code
+ local s = clean(self.text)
+ if not s then
+  --print(self.text)
+  error("parser error in embedded code")
+ end
+
+ -- get first line
+ local _, _, first_line=string.find(self.text, "^([^\n\r]*)")
+ if string.find(first_line, "^%s*%-%-") then
+	 if string.find(first_line, "^%-%-##") then
+		first_line = string.gsub(first_line, "^%-%-##", "")
+		if flags['C'] then
+			s = string.gsub(s, "^%-%-##[^\n\r]*\n", "")
+		end
+	 end
+ else
+ 	first_line = ""
+ end
+
+ -- convert to C
+ output('\n'..pre..'{ /* begin embedded lua code */\n')
+ output(pre..' int top = lua_gettop(tolua_S);')
+ output(pre..' static unsigned char B[] = {\n   ')
+ local t={n=0}
+ local b = gsub(s,'(.)',function (c)
+                         local e = ''
+                         t.n=t.n+1 if t.n==15 then t.n=0 e='\n'..pre..'  ' end
+                         return format('%3u,%s',strbyte(c),e)
+                        end
+               )
+ output(b..strbyte(" "))
+ output('\n'..pre..' };\n')
+ if first_line and first_line ~= "" then
+ 	output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: '..first_line..'");')
+ else
+ 	output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code '..code_n..'");')
+ end
+ output(pre..' lua_settop(tolua_S, top);')
+ output(pre..'} /* end of embedded lua code */\n\n')
+ code_n = code_n +1
+end
+
+
+-- Print method
+function classCode:print (ident,close)
+ print(ident.."Code{")
+ print(ident.." text = [["..self.text.."]],")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Code (t)
+ setmetatable(t,classCode)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the code text
+function Code (l)
+ return _Code {
+  text = l
+ }
+end
+
+
Index: /code/branches/physics/src/tolua/lua/compat-5.1.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/compat-5.1.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/compat-5.1.lua	(revision 2122)
@@ -0,0 +1,53 @@
+if string.find(_VERSION, "5%.0") then
+	return
+end
+
+-- "loadfile"
+local function pp_dofile(path)
+
+	local loaded = false
+	local getfile = function()
+
+		if loaded then
+			return
+		else
+			local file,err = io.open(path)
+			if not file then
+				error("error loading file "..path..": "..err)
+			end
+			local ret = file:read("*a")
+			file:close()
+
+			ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};")
+
+			loaded = true
+			return ret
+		end
+	end
+
+	local f = load(getfile, path)
+	return f()
+end
+
+old_dofile = dofile
+dofile = pp_dofile
+
+
+-- string.gsub
+--[[
+local ogsub = string.gsub
+local function compgsub(a,b,c,d)
+  if type(c) == "function" then
+    local oc = c
+    c = function (...) return oc(...) or '' end
+  end
+  return ogsub(a,b,c,d)
+end
+string.repl = ogsub
+--]]
+
+--string.gsub = compgsub
+
+
+
+
Index: /code/branches/physics/src/tolua/lua/compat.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/compat.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/compat.lua	(revision 2122)
@@ -0,0 +1,193 @@
+-------------------------------------------------------------------
+-- Real globals
+-- _ALERT
+-- _ERRORMESSAGE
+-- _VERSION
+-- _G
+-- assert
+-- error
+-- metatable
+-- next
+-- print
+-- require
+-- tonumber
+-- tostring
+-- type
+-- unpack
+
+-------------------------------------------------------------------
+-- collectgarbage
+-- gcinfo
+
+-- globals
+
+-- call   -> protect(f, err)
+-- loadfile
+-- loadstring
+
+-- rawget
+-- rawset
+
+-- getargs = Main.getargs ??
+
+rawtype = type
+
+function do_ (f, err)
+  if not f then print(err); return end
+  local a,b = pcall(f)
+  if not a then print(b); return nil
+  else return b or true
+  end
+end
+
+function dostring(s) return do_(loadstring(s)) end
+-- function dofile(s) return do_(loadfile(s)) end
+
+-------------------------------------------------------------------
+-- Table library
+local tab = table
+foreach = tab.foreach
+foreachi = tab.foreachi
+getn = tab.getn
+tinsert = tab.insert
+tremove = tab.remove
+sort = tab.sort
+
+-------------------------------------------------------------------
+-- Debug library
+local dbg = debug
+getinfo = dbg.getinfo
+getlocal = dbg.getlocal
+setcallhook = function () error"`setcallhook' is deprecated" end
+setlinehook = function () error"`setlinehook' is deprecated" end
+setlocal = dbg.setlocal
+
+-------------------------------------------------------------------
+-- math library
+local math = math
+abs = math.abs
+acos = function (x) return math.deg(math.acos(x)) end
+asin = function (x) return math.deg(math.asin(x)) end
+atan = function (x) return math.deg(math.atan(x)) end
+atan2 = function (x,y) return math.deg(math.atan2(x,y)) end
+ceil = math.ceil
+cos = function (x) return math.cos(math.rad(x)) end
+deg = math.deg
+exp = math.exp
+floor = math.floor
+frexp = math.frexp
+ldexp = math.ldexp
+log = math.log
+log10 = math.log10
+max = math.max
+min = math.min
+mod = math.mod
+PI = math.pi
+--??? pow = math.pow  
+rad = math.rad
+random = math.random
+randomseed = math.randomseed
+sin = function (x) return math.sin(math.rad(x)) end
+sqrt = math.sqrt
+tan = function (x) return math.tan(math.rad(x)) end
+
+-------------------------------------------------------------------
+-- string library
+local str = string
+strbyte = str.byte
+strchar = str.char
+strfind = str.find
+format = str.format
+gsub = str.gsub
+strlen = str.len
+strlower = str.lower
+strrep = str.rep
+strsub = str.sub
+strupper = str.upper
+
+-------------------------------------------------------------------
+-- os library
+clock = os.clock
+date = os.date
+difftime = os.difftime
+execute = os.execute --?
+exit = os.exit
+getenv = os.getenv
+remove = os.remove
+rename = os.rename
+setlocale = os.setlocale
+time = os.time
+tmpname = os.tmpname
+
+-------------------------------------------------------------------
+-- compatibility only
+getglobal = function (n) return _G[n] end
+setglobal = function (n,v) _G[n] = v end
+
+-------------------------------------------------------------------
+
+local io, tab = io, table
+
+-- IO library (files)
+_STDIN = io.stdin
+_STDERR = io.stderr
+_STDOUT = io.stdout
+_INPUT = io.stdin
+_OUTPUT = io.stdout
+seek = io.stdin.seek   -- sick ;-)
+tmpfile = io.tmpfile
+closefile = io.close
+openfile = io.open
+
+function flush (f)
+  if f then f:flush()
+  else _OUTPUT:flush()
+  end
+end
+
+function readfrom (name)
+  if name == nil then
+    local f, err, cod = io.close(_INPUT)
+    _INPUT = io.stdin
+    return f, err, cod
+  else
+    local f, err, cod = io.open(name, "r")
+    _INPUT = f or _INPUT
+    return f, err, cod
+  end
+end
+
+function writeto (name)
+  if name == nil then
+    local f, err, cod = io.close(_OUTPUT)
+    _OUTPUT = io.stdout
+    return f, err, cod
+  else
+    local f, err, cod = io.open(name, "w")
+    _OUTPUT = f or _OUTPUT
+    return f, err, cod
+  end
+end
+
+function appendto (name)
+  local f, err, cod = io.open(name, "a")
+  _OUTPUT = f or _OUTPUT
+  return f, err, cod
+end
+
+function read (...)
+  local f = _INPUT
+  if rawtype(arg[1]) == 'userdata' then
+    f = tab.remove(arg, 1)
+  end
+  return f:read(unpack(arg))
+end
+
+function write (...)
+  local f = _OUTPUT
+  if rawtype(arg[1]) == 'userdata' then
+    f = tab.remove(arg, 1)
+  end
+  return f:write(unpack(arg))
+end
+
Index: /code/branches/physics/src/tolua/lua/container.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/container.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/container.lua	(revision 2122)
@@ -0,0 +1,771 @@
+-- tolua: container abstract class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+-- table to store namespaced typedefs/enums in global scope
+global_typedefs = {}
+global_enums = {}
+
+-- Container class
+-- Represents a container of features to be bound
+-- to lua.
+classContainer =
+{
+ curr = nil,
+}
+classContainer.__index = classContainer
+setmetatable(classContainer,classFeature)
+
+-- output tags
+function classContainer:decltype ()
+ push(self)
+ local i=1
+ while self[i] do
+  self[i]:decltype()
+  i = i+1
+ end
+ pop()
+end
+
+
+-- write support code
+function classContainer:supcode ()
+
+	if not self:check_public_access() then
+		return
+	end
+
+ push(self)
+ local i=1
+ while self[i] do
+  if self[i]:check_public_access() then
+  	self[i]:supcode()
+  end
+  i = i+1
+ end
+ pop()
+end
+
+function classContainer:hasvar ()
+ local i=1
+ while self[i] do
+  if self[i]:isvariable() then
+		 return 1
+		end
+  i = i+1
+ end
+	return 0
+end
+
+-- Internal container constructor
+function _Container (self)
+ setmetatable(self,classContainer)
+ self.n = 0
+ self.typedefs = {tolua_n=0}
+ self.usertypes = {}
+ self.enums = {tolua_n=0}
+ self.lnames = {}
+ return self
+end
+
+-- push container
+function push (t)
+	t.prox = classContainer.curr
+ classContainer.curr = t
+end
+
+-- pop container
+function pop ()
+--print("name",classContainer.curr.name)
+--foreach(classContainer.curr.usertypes,print)
+--print("______________")
+ classContainer.curr = classContainer.curr.prox
+end
+
+-- get current namespace
+function getcurrnamespace ()
+	return getnamespace(classContainer.curr)
+end
+
+-- append to current container
+function append (t)
+ return classContainer.curr:append(t)
+end
+
+-- append typedef to current container
+function appendtypedef (t)
+ return classContainer.curr:appendtypedef(t)
+end
+
+-- append usertype to current container
+function appendusertype (t)
+ return classContainer.curr:appendusertype(t)
+end
+
+-- append enum to current container
+function appendenum (t)
+ return classContainer.curr:appendenum(t)
+end
+
+-- substitute typedef
+function applytypedef (mod,type)
+ return classContainer.curr:applytypedef(mod,type)
+end
+
+-- check if is type
+function findtype (type)
+ local t = classContainer.curr:findtype(type)
+	return t
+end
+
+-- check if is typedef
+function istypedef (type)
+ return classContainer.curr:istypedef(type)
+end
+
+-- get fulltype (with namespace)
+function fulltype (t)
+ local curr =  classContainer.curr
+	while curr do
+	 if curr then
+		 if curr.typedefs and curr.typedefs[t] then
+		  return curr.typedefs[t]
+		 elseif curr.usertypes and curr.usertypes[t] then
+		  return curr.usertypes[t]
+			end
+		end
+	 curr = curr.prox
+	end
+	return t
+end
+
+-- checks if it requires collection
+function classContainer:requirecollection (t)
+ push(self)
+ local i=1
+	local r = false
+ while self[i] do
+  r = self[i]:requirecollection(t) or r
+  i = i+1
+ end
+	pop()
+	return r
+end
+
+
+-- get namesapce
+function getnamespace (curr)
+	local namespace = ''
+	while curr do
+	 if curr and
+		   ( curr.classtype == 'class' or curr.classtype == 'namespace')
+		then
+		 namespace = (curr.original_name or curr.name) .. '::' .. namespace
+		 --namespace = curr.name .. '::' .. namespace
+		end
+	 curr = curr.prox
+	end
+	return namespace
+end
+
+-- get namespace (only namespace)
+function getonlynamespace ()
+ local curr = classContainer.curr
+	local namespace = ''
+	while curr do
+		if curr.classtype == 'class' then
+		 return namespace
+		elseif curr.classtype == 'namespace' then
+		 namespace = curr.name .. '::' .. namespace
+		end
+	 curr = curr.prox
+	end
+	return namespace
+end
+
+-- check if is enum
+function isenum (type)
+ return classContainer.curr:isenum(type)
+end
+
+-- append feature to container
+function classContainer:append (t)
+ self.n = self.n + 1
+ self[self.n] = t
+ t.parent = self
+end
+
+-- append typedef
+function classContainer:appendtypedef (t)
+ local namespace = getnamespace(classContainer.curr)
+ self.typedefs.tolua_n = self.typedefs.tolua_n + 1
+ self.typedefs[self.typedefs.tolua_n] = t
+	self.typedefs[t.utype] = namespace .. t.utype
+	global_typedefs[namespace..t.utype] = t
+	t.ftype = findtype(t.type) or t.type
+	--print("appending typedef "..t.utype.." as "..namespace..t.utype.." with ftype "..t.ftype)
+	append_global_type(namespace..t.utype)
+	if t.ftype and isenum(t.ftype) then
+
+		global_enums[namespace..t.utype] = true
+	end
+end
+
+-- append usertype: return full type
+function classContainer:appendusertype (t)
+	local container
+	if t == (self.original_name or self.name) then
+		container = self.prox
+	else
+		container = self
+	end
+	local ft = getnamespace(container) .. t
+	container.usertypes[t] = ft
+	_usertype[ft] = ft
+	return ft
+end
+
+-- append enum
+function classContainer:appendenum (t)
+ local namespace = getnamespace(classContainer.curr)
+ self.enums.tolua_n = self.enums.tolua_n + 1
+ self.enums[self.enums.tolua_n] = t
+	global_enums[namespace..t.name] = t
+end
+
+-- determine lua function name overload
+function classContainer:overload (lname)
+ if not self.lnames[lname] then
+  self.lnames[lname] = 0
+ else
+  self.lnames[lname] = self.lnames[lname] + 1
+ end
+ return format("%02d",self.lnames[lname])
+end
+
+-- applies typedef: returns the 'the facto' modifier and type
+function classContainer:applytypedef (mod,type)
+	if global_typedefs[type] then
+		--print("found typedef "..global_typedefs[type].type)
+		local mod1, type1 = global_typedefs[type].mod, global_typedefs[type].ftype
+		local mod2, type2 = applytypedef(mod.." "..mod1, type1)
+		--return mod2 .. ' ' .. mod1, type2
+		return mod2, type2
+	end
+	do return mod,type end
+end
+
+-- check if it is a typedef
+function classContainer:istypedef (type)
+ local env = self
+ while env do
+  if env.typedefs then
+   local i=1
+   while env.typedefs[i] do
+    if env.typedefs[i].utype == type then
+         return type
+        end
+        i = i+1
+   end
+  end
+  env = env.parent
+ end
+ return nil
+end
+
+function find_enum_var(var)
+
+	if tonumber(var) then return var end
+
+	local c = classContainer.curr
+	while c do
+		local ns = getnamespace(c)
+		for k,v in pairs(_global_enums) do
+			if match_type(var, v, ns) then
+				return v
+			end
+		end
+		if c.base and c.base ~= '' then
+			c = _global_classes[c:findtype(c.base)]
+		else
+			c = nil
+		end
+	end
+
+	return var
+end
+
+-- check if is a registered type: return full type or nil
+function classContainer:findtype (t)
+
+	t = string.gsub(t, "=.*", "")
+	if _basic[t] then
+	 return t
+	end
+
+	local _,_,em = string.find(t, "([&%*])%s*$")
+	t = string.gsub(t, "%s*([&%*])%s*$", "")
+	p = self
+	while p and type(p)=='table' do
+		local st = getnamespace(p)
+
+		for i=_global_types.n,1,-1 do -- in reverse order
+
+			if match_type(t, _global_types[i], st) then
+				return _global_types[i]..(em or "")
+			end
+		end
+		if p.base and p.base ~= '' and p.base ~= t then
+			--print("type is "..t..", p is "..p.base.." self.type is "..self.type.." self.name is "..self.name)
+			p = _global_classes[p:findtype(p.base)]
+		else
+			p = nil
+		end
+	end
+
+	return nil
+end
+
+function append_global_type(t, class)
+	_global_types.n = _global_types.n +1
+	_global_types[_global_types.n] = t
+	_global_types_hash[t] = 1
+	if class then append_class_type(t, class) end
+end
+
+function append_class_type(t,class)
+	if _global_classes[t] then
+		class.flags = _global_classes[t].flags
+		class.lnames = _global_classes[t].lnames
+		if _global_classes[t].base and (_global_classes[t].base ~= '') then
+			class.base = _global_classes[t].base or class.base
+		end
+	end
+	_global_classes[t] = class
+	class.flags = class.flags or {}
+end
+
+function match_type(childtype, regtype, st)
+--print("findtype "..childtype..", "..regtype..", "..st)
+	local b,e = string.find(regtype, childtype, -string.len(childtype), true)
+	if b then
+
+		if e == string.len(regtype) and
+				(b == 1 or (string.sub(regtype, b-1, b-1) == ':' and
+				string.sub(regtype, 1, b-1) == string.sub(st, 1, b-1))) then
+			return true
+		end
+	end
+
+	return false
+end
+
+function findtype_on_childs(self, t)
+
+	local tchild
+	if self.classtype == 'class' or self.classtype == 'namespace' then
+		for k,v in ipairs(self) do
+			if v.classtype == 'class' or v.classtype == 'namespace' then
+				if v.typedefs and v.typedefs[t] then
+				 return v.typedefs[t]
+				elseif v.usertypes and v.usertypes[t] then
+				 return v.usertypes[t]
+				end
+				tchild = findtype_on_childs(v, t)
+				if tchild then return tchild end
+			end
+		end
+	end
+	return nil
+
+end
+
+function classContainer:isenum (type)
+ if global_enums[type] then
+	return type
+ else
+ 	return false
+ end
+
+ local basetype = gsub(type,"^.*::","")
+ local env = self
+ while env do
+  if env.enums then
+   local i=1
+   while env.enums[i] do
+    if env.enums[i].name == basetype then
+         return true
+        end
+        i = i+1
+   end
+  end
+  env = env.parent
+ end
+ return false
+end
+
+methodisvirtual = false -- a global
+
+-- parse chunk
+function classContainer:doparse (s)
+--print ("parse "..s)
+
+ -- try the parser hook
+ do
+ 	local sub = parser_hook(s)
+ 	if sub then
+ 		return sub
+ 	end
+ end
+
+ -- try the null statement
+ do
+ 	local b,e,code = string.find(s, "^%s*;")
+ 	if b then
+ 		return strsub(s,e+1)
+ 	end
+ end
+
+ -- try empty verbatim line
+ do
+ 	local b,e,code = string.find(s, "^%s*$\n")
+ 	if b then
+ 		return strsub(s,e+1)
+ 	end
+ end
+
+ -- try Lua code
+ do
+  local b,e,code = strfind(s,"^%s*(%b\1\2)")
+  if b then
+   Code(strsub(code,2,-2))
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try C code
+ do
+  local b,e,code = strfind(s,"^%s*(%b\3\4)")
+  if b then
+	code = '{'..strsub(code,2,-2)..'\n}\n'
+	Verbatim(code,'r')        -- verbatim code for 'r'egister fragment
+	return strsub(s,e+1)
+  end
+ end
+
+ -- try C code for preamble section
+ do
+ 	local b,e,code = string.find(s, "^%s*(%b\5\6)")
+ 	if b then
+ 		code = string.sub(code, 2, -2).."\n"
+		Verbatim(code, '')
+		return string.sub(s, e+1)
+ 	end
+ end
+
+ -- try default_property directive
+ do
+ 	local b,e,ptype = strfind(s, "^%s*TOLUA_PROPERTY_TYPE%s*%(+%s*([^%)%s]*)%s*%)+%s*;?")
+ 	if b then
+ 		if not ptype or ptype == "" then
+ 			ptype = "default"
+ 		end
+ 		self:set_property_type(ptype)
+	 	return strsub(s, e+1)
+ 	end
+ end
+
+ -- try protected_destructor directive
+ do
+ 	local b,e = string.find(s, "^%s*TOLUA_PROTECTED_DESTRUCTOR%s*;?")
+	if b then
+		if self.set_protected_destructor then
+	 		self:set_protected_destructor(true)
+	 	end
+ 		return strsub(s, e+1)
+ 	end
+ end
+
+ -- try 'extern' keyword
+ do
+ 	local b,e = string.find(s, "^%s*extern%s+")
+ 	if b then
+		-- do nothing
+ 		return strsub(s, e+1)
+ 	end
+ end
+	
+ -- try 'virtual' keyworkd
+ do
+ 	local b,e = string.find(s, "^%s*virtual%s+")
+ 	if b then
+ 		methodisvirtual = true
+ 		return strsub(s, e+1)
+ 	end
+ end
+
+ -- try labels (public, private, etc)
+ do
+ 	local b,e = string.find(s, "^%s*%w*%s*:[^:]")
+ 	if b then
+ 		return strsub(s, e) -- preserve the [^:]
+ 	end
+ end
+
+ -- try module
+ do
+  local b,e,name,body = strfind(s,"^%s*module%s%s*([_%w][_%w]*)%s*(%b{})%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Module(name,body)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try namesapce
+ do
+  local b,e,name,body = strfind(s,"^%s*namespace%s%s*([_%w][_%w]*)%s*(%b{})%s*;?")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Namespace(name,body)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try define
+ do
+  local b,e,name = strfind(s,"^%s*#define%s%s*([^%s]*)[^\n]*\n%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Define(name)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try enumerates
+
+ do
+  local b,e,name,body,varname = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*([^%s;]*)%s*;?%s*")
+  if b then
+   --error("#Sorry, declaration of enums and variables on the same statement is not supported.\nDeclare your variable separately (example: '"..name.." "..varname..";')")
+   _curr_code = strsub(s,b,e)
+   Enumerate(name,body,varname)
+   return strsub(s,e+1)
+  end
+ end
+
+-- do
+--  local b,e,name,body = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*;?%s*")
+--  if b then
+--   _curr_code = strsub(s,b,e)
+--   Enumerate(name,body)
+--  return strsub(s,e+1)
+--  end
+-- end
+
+ do
+  local b,e,body,name = strfind(s,"^%s*typedef%s+enum[^{]*(%b{})%s*([%w_][^%s]*)%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Enumerate(name,body)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try operator
+ do
+  local b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
+  if not b then
+		 -- try inline
+   b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)[%s\n]*%b{}%s*;?%s*")
+  end
+  if not b then
+  	-- try cast operator
+  	b,e,decl,kind,arg,const = strfind(s, "^%s*(operator)%s+([%w_:%d<>%*%&%s]+)%s*(%b())%s*(c?o?n?s?t?)");
+  	if b then
+  		local _,ie = string.find(s, "^%s*%b{}", e+1)
+  		if ie then
+  			e = ie
+  		end
+  	end
+  end
+  if b then
+   _curr_code = strsub(s,b,e)
+   Operator(decl,kind,arg,const)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try function
+ do
+  --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w])%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
+  local b,e,decl,arg,const,virt = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)%s*(=?%s*0?)%s*;%s*")
+  if not b then
+  	-- try function with template
+  	b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w]%b<>)%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
+  end
+  if not b then
+   -- try a single letter function name
+   b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
+  end
+  if b then
+  	if virt and string.find(virt, "[=0]") then
+  		if self.flags then
+  			self.flags.pure_virtual = true
+  		end
+  	end
+   _curr_code = strsub(s,b,e)
+   Function(decl,arg,const)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try inline function
+ do
+  local b,e,decl,arg,const = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)[^;{]*%b{}%s*;?%s*")
+  --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w>])%s*(%b())%s*(c?o?n?s?t?)[^;]*%b{}%s*;?%s*")
+  if not b then
+   -- try a single letter function name
+   b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?).-%b{}%s*;?%s*")
+  end
+  if b then
+   _curr_code = strsub(s,b,e)
+   Function(decl,arg,const)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try class
+ do
+	 local b,e,name,base,body
+		base = '' body = ''
+		b,e,name = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*;")  -- dummy class
+		if not b then
+			b,e,name = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*;")    -- dummy struct
+			if not b then
+				b,e,name,base,body = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+				if not b then
+					b,e,name,base,body = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+					if not b then
+						b,e,name,base,body = strfind(s,"^%s*union%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+						if not b then
+							base = ''
+							b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;%s*")
+						end
+					end
+				end
+			end
+		end
+		if b then
+			if base ~= '' then
+				base = string.gsub(base, "^%s*:%s*", "")
+				base = string.gsub(base, "%s*public%s*", "")
+				base = split(base, ",")
+				--local b,e
+				--b,e,base = strfind(base,".-([_%w][_%w<>,:]*)$")
+			else
+				base = {}
+			end
+			_curr_code = strsub(s,b,e)
+			Class(name,base,body)
+			return strsub(s,e+1)
+		end
+	end
+
+ -- try typedef
+ do
+  local b,e,types = strfind(s,"^%s*typedef%s%s*(.-)%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Typedef(types)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try variable
+ do
+  local b,e,decl = strfind(s,"^%s*([_%w][_@%s%w%d%*&:<>,]*[_%w%d])%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+
+	local list = split_c_tokens(decl, ",")
+	Variable(list[1])
+	if list.n > 1 then
+		local _,_,type = strfind(list[1], "(.-)%s+([^%s]*)$");
+
+		local i =2;
+		while list[i] do
+			Variable(type.." "..list[i])
+			i=i+1
+		end
+	end
+   --Variable(decl)
+   return strsub(s,e+1)
+  end
+ end
+
+	-- try string
+ do
+  local b,e,decl = strfind(s,"^%s*([_%w]?[_%s%w%d]-char%s+[_@%w%d]*%s*%[%s*%S+%s*%])%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Variable(decl)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try array
+ do
+  local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:]*[]_%w%d])%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Array(decl)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- no matching
+ if gsub(s,"%s%s*","") ~= "" then
+  _curr_code = s
+  error("#parse error")
+ else
+  return ""
+ end
+
+end
+
+function classContainer:parse (s)
+
+	self.curr_member_access = nil
+
+ while s ~= '' do
+  s = self:doparse(s)
+  methodisvirtual = false
+ end
+end
+
+
+-- property types
+
+function get_property_type()
+
+	return classContainer.curr:get_property_type()
+end
+
+function classContainer:set_property_type(ptype)
+	ptype = string.gsub(ptype, "^%s*", "")
+	ptype = string.gsub(ptype, "%s*$", "")
+
+	self.property_type = ptype
+end
+
+function classContainer:get_property_type()
+	return self.property_type or (self.parent and self.parent:get_property_type()) or "default"
+end
Index: /code/branches/physics/src/tolua/lua/custom.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/custom.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/custom.lua	(revision 2122)
@@ -0,0 +1,45 @@
+
+function extract_code(fn,s)
+	local code = ""
+	if fn then
+		code = '\n$#include "'..fn..'"\n'
+	end
+	s= "\n" .. s .. "\n" -- add blank lines as sentinels
+	local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n")
+	while e do
+		t = strlower(t)
+		if t == "bind_begin" then
+			_,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e)
+			if not e then
+			 tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file")
+			end
+		end
+		if t == "bind_class" or t == "bind_block" then
+			local b
+			_,e,c,b = string.find(s, "([^{]-)(%b{})", e)
+			c = c..'{\n'..extract_code(nil, b)..'\n};\n'
+		end
+		code = code .. c .. "\n"
+	 _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e)
+	end
+	return code
+end
+
+function preprocess_hook(p)
+end
+
+function preparse_hook(p)
+end
+
+function include_file_hook(p, filename)
+	do return end
+--print("FILENAME is "..filename)
+	p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal")
+	p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "")
+	p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "")
+	p.code = string.gsub(p.code, "DECLSPEC", "")
+	p.code = string.gsub(p.code, "SDLCALL", "")
+	p.code = string.gsub(p.code, "DLLINTERFACE", "")
+	p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n")
+--print("code is "..p.code)
+end
Index: /code/branches/physics/src/tolua/lua/custom_hide.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/custom_hide.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/custom_hide.lua	(revision 2122)
@@ -0,0 +1,21 @@
+-- extract code with tolua_hide, and also
+function extract_code(fn,s)
+	local code = '\n$#include "'..fn..'"\n'
+	s= "\n" .. s .. "\n" -- add blank lines as sentinels
+	local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
+	while e do
+		t = strlower(t)
+		if t == "begin" then
+			_,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
+			if not e then
+			 tolua_error("Unbalanced 'tolua_begin' directive in header file")
+			end
+		end
+		c = c.."\n"
+		c = string.gsub(c, "\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[hH][iI][Dd][eE][^\n]*\n", "\n");
+		c = string.gsub(c, "#define[^%(\n]*%(.-\n", "\n")
+		code = code .. c
+	 _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
+	end
+	return code
+end
Index: /code/branches/physics/src/tolua/lua/declaration.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/declaration.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/declaration.lua	(revision 2122)
@@ -0,0 +1,567 @@
+-- tolua: declaration class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Declaration class
+-- Represents variable, function, or argument declaration.
+-- Stores the following fields:
+--  mod  = type modifiers
+--  type = type
+--  ptr  = "*" or "&", if representing a pointer or a reference
+--  name = name
+--  dim  = dimension, if a vector
+--  def  = default value, if any (only for arguments)
+--  ret  = "*" or "&", if value is to be returned (only for arguments)
+classDeclaration = {
+ mod = '',
+ type = '',
+ ptr = '',
+ name = '',
+ dim = '',
+ ret = '',
+ def = ''
+}
+classDeclaration.__index = classDeclaration
+setmetatable(classDeclaration,classFeature)
+
+-- Create an unique variable name
+function create_varname ()
+ if not _varnumber then _varnumber = 0 end
+ _varnumber = _varnumber + 1
+ return "tolua_var_".._varnumber
+end
+
+-- Check declaration name
+-- It also identifies default values
+function classDeclaration:checkname ()
+
+ if strsub(self.name,1,1) == '[' and not findtype(self.type) then
+  self.name = self.type..self.name
+  local m = split(self.mod,'%s%s*')
+  self.type = m[m.n]
+  self.mod = concat(m,1,m.n-1)
+ end
+
+ local t = split(self.name,'=')
+ if t.n==2 then
+  self.name = t[1]
+  self.def = find_enum_var(t[t.n])
+ end
+
+ local b,e,d = strfind(self.name,"%[(.-)%]")
+ if b then
+  self.name = strsub(self.name,1,b-1)
+  self.dim = find_enum_var(d)
+ end
+
+
+ if self.type ~= '' and self.type ~= 'void' and self.name == '' then
+  self.name = create_varname()
+ elseif self.kind=='var' then
+  if self.type=='' and self.name~='' then
+   self.type = self.type..self.name
+   self.name = create_varname()
+  elseif findtype(self.name) then
+   if self.type=='' then self.type = self.name
+   else self.type = self.type..' '..self.name end
+   self.name = create_varname()
+  end
+ end
+
+ -- adjust type of string
+ if self.type == 'char' and self.dim ~= '' then
+	 self.type = 'char*'
+ end
+
+	if self.kind and self.kind == 'var' then
+		self.name = string.gsub(self.name, ":.*$", "") -- ???
+	end
+end
+
+-- Check declaration type
+-- Substitutes typedef's.
+function classDeclaration:checktype ()
+
+ -- check if there is a pointer to basic type
+ local basic = isbasic(self.type)
+ if self.kind == 'func' and basic=='number' and string.find(self.ptr, "%*") then
+ 	self.type = '_userdata'
+ 	self.ptr = ""
+ end
+ if basic and self.ptr~='' then
+  self.ret = self.ptr
+  self.ptr = nil
+  if isbasic(self.type) == 'number' then
+  	self.return_userdata = true
+  end
+ end
+
+ -- check if there is array to be returned
+ if self.dim~='' and self.ret~='' then
+   error('#invalid parameter: cannot return an array of values')
+ end
+ -- restore 'void*' and 'string*'
+ if self.type == '_userdata' then self.type = 'void*'
+ elseif self.type == '_cstring' then self.type = 'char*'
+ elseif self.type == '_lstate' then self.type = 'lua_State*'
+ end
+
+ -- resolve types inside the templates
+ if self.type then
+	 self.type = resolve_template_types(self.type)
+ end
+
+--
+-- -- if returning value, automatically set default value
+-- if self.ret ~= '' and self.def == '' then
+--  self.def = '0'
+-- end
+--
+
+end
+
+function resolve_template_types(type)
+
+	if isbasic(type) then
+		return type
+	end
+	local b,_,m = string.find(type, "(%b<>)")
+	if b then
+
+		m = split_c_tokens(string.sub(m, 2, -2), ",")
+		for i=1, table.getn(m) do
+			m[i] = string.gsub(m[i],"%s*([%*&])", "%1")
+			m[i] = findtype(m[i]) or m[i]
+			m[i] = resolve_template_types(m[i])
+		end
+
+		local b,i
+		type,b,i = break_template(type)
+		local template_part = "<"..string.gsub(concat(m, 1, m.n), " ", ",")..">"
+		type = rebuild_template(type, b, template_part)
+		type = string.gsub(type, ">>", "> >")
+	end
+	return type
+end
+
+function break_template(s)
+	local b,e,timpl = string.find(s, "(%b<>)")
+	if timpl then
+		s = string.gsub(s, "%b<>", "")
+		return s, b, timpl
+	else
+		return s, 0, nil
+	end
+end
+
+function rebuild_template(s, b, timpl)
+
+	if b == 0 then
+		return s
+	end
+
+	return string.sub(s, 1, b-1)..timpl..string.sub(s, b, -1)
+end
+
+-- Print method
+function classDeclaration:print (ident,close)
+ print(ident.."Declaration{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." dim  = '"..self.dim.."',")
+ print(ident.." def  = '"..self.def.."',")
+ print(ident.." ret  = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- check if array of values are returned to Lua
+function classDeclaration:requirecollection (t)
+ if self.mod ~= 'const' and
+	    self.dim and self.dim ~= '' and
+				 not isbasic(self.type) and
+				 self.ptr == '' then
+		local type = gsub(self.type,"%s*const%s+","")
+		t[type] = "tolua_collect_" .. clean_template(type)
+		return true
+	end
+	return false
+end
+
+-- declare tag
+function classDeclaration:decltype ()
+
+	self.type = typevar(self.type)
+	if strfind(self.mod,'const') then
+		self.type = 'const '..self.type
+		self.mod = gsub(self.mod,'const%s*','')
+	end
+end
+
+
+-- output type checking
+function classDeclaration:outchecktype (narg)
+ local def
+ local t = isbasic(self.type)
+ if self.def~='' then
+  def = 1
+ else
+  def = 0
+ end
+ if self.dim ~= '' then
+	--if t=='string' then
+	--	return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)'
+	--else
+	return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
+ 	--end
+ elseif t then
+	return 'tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)'
+ else
+  return 'tolua_isusertype(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)'
+ end
+end
+
+function classDeclaration:builddeclaration (narg, cplusplus)
+ local array = self.dim ~= '' and tonumber(self.dim)==nil
+	local line = ""
+ local ptr = ''
+	local mod
+	local type = self.type
+ if self.dim ~= '' then
+	 type = gsub(self.type,'const%s+','')  -- eliminates const modifier for arrays
+ end
+ if self.ptr~='' and not isbasic(type) then ptr = '*' end
+ line = concatparam(line," ",self.mod,type,ptr)
+ if array then
+  line = concatparam(line,'*')
+ end
+ line = concatparam(line,self.name)
+ if self.dim ~= '' then
+  if tonumber(self.dim)~=nil then
+   line = concatparam(line,'[',self.dim,'];')
+  else
+	if cplusplus then
+		line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')
+	else
+		line = concatparam(line,' = (',type,ptr,'*)',
+		'malloc((',self.dim,')*sizeof(',type,ptr,'));')
+	end
+  end
+ else
+  local t = isbasic(type)
+  line = concatparam(line,' = ')
+  if t == 'state' then
+  	line = concatparam(line, 'tolua_S;')
+  else
+  	--print("t is "..tostring(t)..", ptr is "..tostring(self.ptr))
+  	if t == 'number' and string.find(self.ptr, "%*") then
+  		t = 'userdata'
+  	end
+	if not t and ptr=='' then line = concatparam(line,'*') end
+	line = concatparam(line,'((',self.mod,type)
+	if not t then
+		line = concatparam(line,'*')
+	end
+	line = concatparam(line,') ')
+			if isenum(type) then
+			line = concatparam(line,'(int) ')
+			end
+	local def = 0
+	if self.def ~= '' then
+		def = self.def
+		if (ptr == '' or self.ptr == '&') and not t then
+			def = "(void*)&(const "..type..")"..def
+		end
+	end
+	if t then
+	line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));')
+	else
+	line = concatparam(line,'tolua_tousertype(tolua_S,',narg,',',def,'));')
+	end
+  end
+ end
+	return line
+end
+
+-- Declare variable
+function classDeclaration:declare (narg)
+ if self.dim ~= '' and tonumber(self.dim)==nil then
+	 output('#ifdef __cplusplus\n')
+		output(self:builddeclaration(narg,true))
+		output('#else\n')
+		output(self:builddeclaration(narg,false))
+	 output('#endif\n')
+	else
+		output(self:builddeclaration(narg,false))
+	end
+end
+
+-- Get parameter value
+function classDeclaration:getarray (narg)
+ if self.dim ~= '' then
+	 local type = gsub(self.type,'const ','')
+  output('  {')
+	 output('#ifndef TOLUA_RELEASE\n')
+  local def; if self.def~='' then def=1 else def=0 end
+		local t = isbasic(type)
+		if (t) then
+   output('   if (!tolua_is'..t..'array(tolua_S,',narg,',',self.dim,',',def,',&tolua_err))')
+		else
+   output('   if (!tolua_isusertypearray(tolua_S,',narg,',"',type,'",',self.dim,',',def,',&tolua_err))')
+		end
+  output('    goto tolua_lerror;')
+  output('   else\n')
+	 output('#endif\n')
+  output('   {')
+  output('    int i;')
+  output('    for(i=0; i<'..self.dim..';i++)')
+  local t = isbasic(type)
+  local ptr = ''
+  if self.ptr~='' then ptr = '*' end
+  output('   ',self.name..'[i] = ')
+  if not t and ptr=='' then output('*') end
+  output('((',type)
+  if not t then
+   output('*')
+  end
+  output(') ')
+  local def = 0
+  if self.def ~= '' then def = self.def end
+  if t then
+   output('tolua_tofield'..t..'(tolua_S,',narg,',i+1,',def,'));')
+  else
+   output('tolua_tofieldusertype(tolua_S,',narg,',i+1,',def,'));')
+  end
+  output('   }')
+  output('  }')
+ end
+end
+
+-- Get parameter value
+function classDeclaration:setarray (narg)
+ if not strfind(self.type,'const%s+') and self.dim ~= '' then
+	 local type = gsub(self.type,'const ','')
+  output('  {')
+  output('   int i;')
+  output('   for(i=0; i<'..self.dim..';i++)')
+  local t,ct = isbasic(type)
+  if t then
+   output('    tolua_pushfield'..t..'(tolua_S,',narg,',i+1,(',ct,')',self.name,'[i]);')
+  else
+   if self.ptr == '' then
+     output('   {')
+     output('#ifdef __cplusplus\n')
+     output('    void* tolua_obj = new',type,'(',self.name,'[i]);')
+     output('    tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");')
+     output('#else\n')
+     output('    void* tolua_obj = tolua_copy(tolua_S,(void*)&',self.name,'[i],sizeof(',type,'));')
+     output('    tolua_pushfieldusertype(tolua_S,',narg,',i+1,tolua_obj,"',type,'");')
+     output('#endif\n')
+     output('   }')
+   else
+    output('   tolua_pushfieldusertype(tolua_S,',narg,',i+1,(void*)',self.name,'[i],"',type,'");')
+   end
+  end
+  output('  }')
+ end
+end
+
+-- Free dynamically allocated array
+function classDeclaration:freearray ()
+ if self.dim ~= '' and tonumber(self.dim)==nil then
+	 output('#ifdef __cplusplus\n')
+		output('  delete []',self.name,';')
+	 output('#else\n')
+  output('  free(',self.name,');')
+	 output('#endif\n')
+ end
+end
+
+-- Pass parameter
+function classDeclaration:passpar ()
+ if self.ptr=='&' and not isbasic(self.type) then
+  output('*'..self.name)
+ elseif self.ret=='*' then
+  output('&'..self.name)
+ else
+  output(self.name)
+ end
+end
+
+-- Return parameter value
+function classDeclaration:retvalue ()
+ if self.ret ~= '' then
+  local t,ct = isbasic(self.type)
+  if t and t~='' then
+   output('   tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');')
+  else
+   output('   tolua_pushusertype(tolua_S,(void*)'..self.name..',"',self.type,'");')
+  end
+  return 1
+ end
+ return 0
+end
+
+-- Internal constructor
+function _Declaration (t)
+
+ setmetatable(t,classDeclaration)
+ t:buildnames()
+ t:checkname()
+ t:checktype()
+ local ft = findtype(t.type) or t.type
+ if not isenum(ft) then
+	t.mod, t.type = applytypedef(t.mod, ft)
+ end
+
+ if t.kind=="var" and (string.find(t.mod, "tolua_property%s") or string.find(t.mod, "tolua_property$")) then
+ 	t.mod = string.gsub(t.mod, "tolua_property", "tolua_property__"..get_property_type())
+ end
+
+ return t
+end
+
+-- Constructor
+-- Expects the string declaration.
+-- The kind of declaration can be "var" or "func".
+function Declaration (s,kind,is_parameter)
+
+ -- eliminate spaces if default value is provided
+ s = gsub(s,"%s*=%s*","=")
+ s = gsub(s, "%s*<", "<")
+
+ local defb,tmpdef
+ defb,_,tmpdef = string.find(s, "(=.*)$")
+ if defb then
+ 	s = string.gsub(s, "=.*$", "")
+ else
+ 	tmpdef = ''
+ end
+ if kind == "var" then
+  -- check the form: void
+  if s == '' or s == 'void' then
+   return _Declaration{type = 'void', kind = kind, is_parameter = is_parameter}
+  end
+ end
+
+ -- check the form: mod type*& name
+ local t = split_c_tokens(s,'%*%s*&')
+ if t.n == 2 then
+  if kind == 'func' then
+   error("#invalid function return type: "..s)
+  end
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '*',
+   ret = '&',
+   --type = rebuild_template(m[m.n], tb, timpl),
+   type = m[m.n],
+   mod = concat(m,1,m.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ -- check the form: mod type** name
+ t = split_c_tokens(s,'%*%s*%*')
+ if t.n == 2 then
+  if kind == 'func' then
+   error("#invalid function return type: "..s)
+  end
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '*',
+   ret = '*',
+   --type = rebuild_template(m[m.n], tb, timpl),
+   type = m[m.n],
+   mod = concat(m,1,m.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ -- check the form: mod type& name
+ t = split_c_tokens(s,'&')
+ if t.n == 2 then
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '&',
+   --type = rebuild_template(m[m.n], tb, timpl),
+   type = m[m.n],
+   mod = concat(m,1,m.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ -- check the form: mod type* name
+ local s1 = gsub(s,"(%b\[\])",function (n) return gsub(n,'%*','\1') end)
+ t = split_c_tokens(s1,'%*')
+ if t.n == 2 then
+  t[2] = gsub(t[2],'\1','%*') -- restore * in dimension expression
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '*',
+   type = m[m.n],
+   --type = rebuild_template(m[m.n], tb, timpl),
+   mod = concat(m,1,m.n-1)   ,
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ if kind == 'var' then
+  -- check the form: mod type name
+  --t = split(s,'%s%s*')
+  t = split_c_tokens(s,'%s+')
+  local v
+  if findtype(t[t.n]) then v = create_varname() else v = t[t.n]; t.n = t.n-1 end
+  return _Declaration{
+   name = v..tmpdef,
+   --type = rebuild_template(t[t.n], tb, timpl),
+   type = t[t.n],
+   mod = concat(t,1,t.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+
+ else -- kind == "func"
+
+  -- check the form: mod type name
+  --t = split(s,'%s%s*')
+  t = split_c_tokens(s,'%s+')
+  local v = t[t.n]  -- last word is the function name
+  local tp,md
+  if t.n>1 then
+   tp = t[t.n-1]
+   md = concat(t,1,t.n-2)
+  end
+  --if tp then tp = rebuild_template(tp, tb, timpl) end
+  return _Declaration{
+   name = v,
+   type = tp,
+   mod = md,
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+end
+
Index: /code/branches/physics/src/tolua/lua/define.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/define.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/define.lua	(revision 2122)
@@ -0,0 +1,63 @@
+-- tolua: define class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: define.lua,v 1.2 1999/07/28 22:21:08 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Define class
+-- Represents a numeric const definition
+-- The following filds are stored:
+--   name = constant name
+classDefine = {
+ name = '',
+}
+classDefine.__index = classDefine
+setmetatable(classDefine,classFeature)
+
+-- register define
+function classDefine:register (pre)
+	if not self:check_public_access() then
+		return
+	end
+
+ pre = pre or ''
+ output(pre..'tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');')
+end
+
+-- Print method
+function classDefine:print (ident,close)
+ print(ident.."Define{")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Define (t)
+ setmetatable(t,classDefine)
+ t:buildnames()
+
+ if t.name == '' then
+  error("#invalid define")
+ end
+
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the constant name
+function Define (n)
+ return _Define{
+  name = n
+ }
+end
+
+
Index: /code/branches/physics/src/tolua/lua/doit.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/doit.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/doit.lua	(revision 2122)
@@ -0,0 +1,95 @@
+-- Generate binding code
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- Last update: Apr 2003
+-- $Id: $
+
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+function parse_extra()
+
+	for k,v in ipairs(_extra_parameters or {}) do
+		
+		local b,e,name,value = string.find(v, "^([^=])=(.*)$")
+		if b then
+			_extra_parameters[name] = value
+		else
+			_extra_parameters[v] = true
+		end
+	end
+end
+
+function doit ()
+	-- define package name, if not provided
+	if not flags.n then
+		if flags.f then
+			flags.n = gsub(flags.f,"%..*$","")
+			_,_,flags.n = string.find(flags.n, "([^/\\]*)$")
+		else
+			error("#no package name nor input file provided")
+		end
+	end
+
+	-- parse table with extra paramters
+	parse_extra()
+
+	-- do this after setting the package name
+	if flags['L'] then
+		dofile(flags['L'])
+	end
+
+	-- add cppstring
+	if not flags['S'] then
+		_basic['string'] = 'cppstring'
+		_basic['std::string'] = 'cppstring'
+		_basic_ctype.cppstring = 'const char*'
+	end
+
+	-- proccess package
+	local p  = Package(flags.n,flags.f)
+
+	if flags.p then
+		return        -- only parse
+	end
+
+	if flags.o then
+		local st,msg = writeto(flags.o)
+		if not st then
+			error('#'..msg)
+		end
+	end
+
+	p:decltype()
+	if flags.P then
+		p:print()
+	else
+		p:preamble()
+		p:supcode()
+		p:register()
+		push(p)
+		post_output_hook(p)
+		pop()
+	end
+
+	if flags.o then
+		writeto()
+	end
+
+	-- write header file
+	if not flags.P then
+		if flags.H then
+			local st,msg = writeto(flags.H)
+			if not st then
+				error('#'..msg)
+			end
+			p:header()
+			writeto()
+		end
+	end
+end
+
Index: /code/branches/physics/src/tolua/lua/enumerate.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/enumerate.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/enumerate.lua	(revision 2122)
@@ -0,0 +1,95 @@
+-- tolua: enumerate class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: enumerate.lua,v 1.3 2000/01/24 20:41:15 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Enumerate class
+-- Represents enumeration
+-- The following fields are stored:
+--    {i} = list of constant names
+classEnumerate = {
+}
+classEnumerate.__index = classEnumerate
+setmetatable(classEnumerate,classFeature)
+
+-- register enumeration
+function classEnumerate:register (pre)
+ pre = pre or ''
+ local nspace = getnamespace(classContainer.curr)
+ local i=1
+ while self[i] do
+  output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');')
+  i = i+1
+ end
+end
+
+-- Print method
+function classEnumerate:print (ident,close)
+ print(ident.."Enumerate{")
+ print(ident.." name = "..self.name)
+ local i=1
+ while self[i] do
+  print(ident.." '"..self[i].."'("..self.lnames[i].."),")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Enumerate (t,varname)
+ setmetatable(t,classEnumerate)
+ append(t)
+ appendenum(t)
+	 if varname and varname ~= "" then
+		if t.name ~= "" then
+			Variable(t.name.." "..varname)
+		else
+			local ns = getcurrnamespace()
+			warning("Variable "..ns..varname.." of type <anonymous enum> is declared as read-only")
+			Variable("tolua_readonly int "..varname)
+		end
+	end
+return t
+end
+
+-- Constructor
+-- Expects a string representing the enumerate body
+function Enumerate (n,b,varname)
+	b = string.gsub(b, ",[%s\n]*}", "\n}") -- eliminate last ','
+ local t = split(strsub(b,2,-2),',') -- eliminate braces
+ local i = 1
+ local e = {n=0}
+ while t[i] do
+  local tt = split(t[i],'=')  -- discard initial value
+  e.n = e.n + 1
+  e[e.n] = tt[1]
+  i = i+1
+ end
+ -- set lua names
+ i  = 1
+ e.lnames = {}
+ local ns = getcurrnamespace()
+ while e[i] do
+  local t = split(e[i],'@')
+  e[i] = t[1]
+		if not t[2] then
+		 t[2] = applyrenaming(t[1])
+		end
+  e.lnames[i] = t[2] or t[1]
+  _global_enums[ ns..e[i] ] = (ns..e[i])
+  i = i+1
+ end
+	e.name = n
+	if n ~= "" then
+		Typedef("int "..n)
+	end
+ return _Enumerate(e, varname)
+end
+
Index: /code/branches/physics/src/tolua/lua/feature.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/feature.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/feature.lua	(revision 2122)
@@ -0,0 +1,128 @@
+-- tolua: abstract feature class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Feature class
+-- Represents the base class of all mapped feature.
+classFeature = {
+}
+classFeature.__index = classFeature
+
+-- write support code
+function classFeature:supcode ()
+end
+
+-- output tag
+function classFeature:decltype ()
+end
+
+-- register feature
+function classFeature:register (pre)
+end
+
+-- translate verbatim
+function classFeature:preamble ()
+end
+
+-- check if it is a variable
+function classFeature:isvariable ()
+ return false
+end
+
+-- check if it requires collection
+function classFeature:requirecollection (t)
+ return false
+end
+
+-- build names
+function classFeature:buildnames ()
+ if self.name and self.name~='' then
+  local n = split(self.name,'@')
+  self.name = n[1]
+  if not n[2] then
+   n[2] = applyrenaming(n[1])
+  end
+  self.lname = n[2] or gsub(n[1],"%[.-%]","")
+  self.original_name = self.name
+  self.lname = clean_template(self.lname)
+ end
+ if not self.is_parameter then
+	 self.name = getonlynamespace() .. self.name
+ end
+
+ local parent = classContainer.curr
+ if parent then
+ 	self.access = parent.curr_member_access
+ else
+ end
+end
+
+function classFeature:check_public_access()
+
+	if self.access and self.access ~= 0 then
+		return false
+	end
+
+	local parent = classContainer.curr
+	while parent do
+		if parent.access and parent.access ~= 0 then
+			return false
+		end
+		parent = parent.prox
+	end
+	return true
+end
+
+function clean_template(t)
+
+	return string.gsub(t, "[<>:, %*]", "_")
+end
+
+-- check if feature is inside a container definition
+-- it returns the container class name or nil.
+function classFeature:incontainer (which)
+ if self.parent then
+  local parent = self.parent
+  while parent do
+   if parent.classtype == which then
+    return parent.name
+   end
+   parent = parent.parent
+  end
+ end
+ return nil
+end
+
+function classFeature:inclass ()
+ return self:incontainer('class')
+end
+
+function classFeature:inmodule ()
+ return self:incontainer('module')
+end
+
+function classFeature:innamespace ()
+ return self:incontainer('namespace')
+end
+
+-- return C binding function name based on name
+-- the client specifies a prefix
+function classFeature:cfuncname (n)
+
+ if self.parent then
+  n = self.parent:cfuncname(n)
+ end
+
+  n = string.gsub(n..'_'.. (self.lname or self.name), "[<>:, \.%*&]", "_")
+
+  return n
+end
+
Index: /code/branches/physics/src/tolua/lua/function.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/function.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/function.lua	(revision 2122)
@@ -0,0 +1,737 @@
+-- tolua: function class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: function.lua 1597 2008-03-11 22:25:01Z ice-drezday $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- CEGUILua mod
+-- exception handling
+-- patch from Tov
+-- modded by Lindquist
+exceptionDefs = exceptionDefs or {}
+exceptionDefs["std::exception"]             = {}
+exceptionDefs["std::exception"]["var"]      = "&e"
+exceptionDefs["std::exception"]["c_str"]    = "e.what()"
+
+exceptionDefs["any"]                        = {}
+exceptionDefs["any"]["var"]                 = ""
+exceptionDefs["any"]["c_str"]               = '"Unknown"'
+
+exceptionMessageBufferSize = 512
+
+function outputExceptionError(f,e,errBuf)
+    -- if the exception is not "..." then use the "c_str" info the get a real exception message
+    local messageC_str = true
+    if e.name == "any" then
+        messageC_str = false
+    end
+
+    -- make a default e.ret if empty
+    if not e.ret or e.ret == "" then
+        e.ret = "nil,message"
+    end
+
+    -- create a default exceptionDef if we dont have one
+    if not exceptionDefs[e.name] then
+        exceptionDefs[e.name] = {}
+        exceptionDefs[e.name].var = "&e"
+        exceptionDefs[e.name].c_str = '"Unknown"'
+    end
+
+    -- print catch header
+    local nameToEcho = e.name
+    if nameToEcho == "any" then
+        nameToEcho = "..."
+    end
+    if e.ret == "nil" then
+        output("catch(",nameToEcho," CEGUIDeadException(",exceptionDefs[e.name].var,"))\n{\n")
+	else
+    	output("catch(",nameToEcho,exceptionDefs[e.name].var,")\n{\n")
+	end
+
+    -- if just a nil
+    if e.ret == "nil" then
+        output("return 0;\n")
+    -- if error should be raised
+    elseif string.find(e.ret,"error") then
+        if messageC_str then
+            output("snprintf(errorBuffer,"..exceptionMessageBufferSize..",\"Exception of type '"..e.name.."' was thrown by function '"..f.."'\\nMessage: %s\","..exceptionDefs[e.name].c_str..");\n")
+        else
+            output("snprintf(errorBuffer,"..exceptionMessageBufferSize..",\"Unknown exception thrown by function '"..f.."'\");\n")
+        end
+        output("errorDoIt = true;\n")
+    -- else go through the returns
+    else
+        -- buffer for message
+        if string.find(e.ret,"message") and messageC_str and errBuf == false then
+            output("char errorBuffer["..exceptionMessageBufferSize.."];\n")
+        end
+        local numrets = 0
+        local retpat = "(%w+),?"
+        local i,j,retval = string.find(e.ret,retpat)
+        while i do
+            local code = ""
+
+            -- NIL
+            if retval == "nil" then
+                code = "tolua_pushnil(tolua_S);\n"
+
+            -- MESSAGE
+            elseif retval == "message" then
+                if messageC_str then
+                    code = "snprintf(errorBuffer,"..exceptionMessageBufferSize..",\"Exception of type '"..e.name.."' was thrown by function '"..f.."'\\nMessage: %s\","..exceptionDefs[e.name].c_str..");\ntolua_pushstring(tolua_S,errorBuffer);\n"
+                else
+                    code = "tolua_pushstring(tolua_S,\"Unknown exception thrown by function '"..f.."'\");\n"
+                end
+
+            -- TRUE
+            elseif retval == "true" then
+                code = "tolua_pushboolean(tolua_S, 1);\n"
+
+            -- FALSE
+            elseif retval == "false" then
+                code = "tolua_pushboolean(tolua_S, 0);\n"
+            end
+
+            -- print code for this return value
+            if code ~= "" then
+                output(code)
+                numrets = numrets + 1
+            end
+
+            -- next return value
+            i,j,retval = string.find(e.ret,retpat,j+1)
+        end
+        output("return ",numrets,";\n")
+    end
+
+    -- print catch footer
+    output("}\n")
+end
+
+function outputExceptionCatchBlocks(func,throws,err)
+    for i=1,table.getn(throws) do
+        outputExceptionError(func, throws[i], err)
+    end
+
+    -- if an error should be raised, we do it here
+    if err then
+        output("if (errorDoIt) {\n")
+        output("luaL_error(tolua_S,errorBuffer);\n")
+        output("}\n")
+    end
+end
+
+
+-- Function class
+-- Represents a function or a class method.
+-- The following fields are stored:
+--  mod  = type modifiers
+--  type = type
+--  ptr  = "*" or "&", if representing a pointer or a reference
+--  name = name
+--  lname = lua name
+--  args  = list of argument declarations
+--  const = if it is a method receiving a const "this".
+classFunction = {
+ mod = '',
+ type = '',
+ ptr = '',
+ name = '',
+ args = {n=0},
+ const = '',
+}
+classFunction.__index = classFunction
+setmetatable(classFunction,classFeature)
+
+-- declare tags
+function classFunction:decltype ()
+ self.type = typevar(self.type)
+ if strfind(self.mod,'const') then
+	 self.type = 'const '..self.type
+		self.mod = gsub(self.mod,'const','')
+	end
+ local i=1
+ while self.args[i] do
+  self.args[i]:decltype()
+  i = i+1
+ end
+end
+
+
+-- Write binding function
+-- Outputs C/C++ binding function.
+function classFunction:supcode (local_constructor)
+
+ local overload = strsub(self.cname,-2,-1) - 1  -- indicate overloaded func
+ local nret = 0      -- number of returned values
+ local class = self:inclass()
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class then
+
+ 	if self.name == 'new' and self.parent.flags.pure_virtual then
+ 		-- no constructor for classes with pure virtual methods
+ 		return
+ 	end
+
+ 	if local_constructor then
+		output("/* method: new_local of class ",class," */")
+	else
+		output("/* method:",self.name," of class ",class," */")
+	end
+ else
+  output("/* function:",self.name," */")
+ end
+
+ if local_constructor then
+  output("#ifndef TOLUA_DISABLE_"..self.cname.."_local")
+  output("\nstatic int",self.cname.."_local","(lua_State* tolua_S)")
+ else
+  output("#ifndef TOLUA_DISABLE_"..self.cname)
+  output("\nstatic int",self.cname,"(lua_State* tolua_S)")
+ end
+ output("{")
+
+ -- check types
+	if overload < 0 then
+	 output('#ifndef TOLUA_RELEASE\n')
+	end
+	output(' tolua_Error tolua_err;')
+ output(' if (\n')
+ -- check self
+ local narg
+ if class then narg=2 else narg=1 end
+ if class then
+		local func = 'tolua_isusertype'
+		local type = self.parent.type
+		if self.name=='new' or static~=nil then
+			func = 'tolua_isusertable'
+			type = self.parent.type
+		end
+		if self.const ~= '' then
+			type = "const "..type
+		end
+		output('     !'..func..'(tolua_S,1,"'..type..'",0,&tolua_err) ||\n')
+ end
+ -- check args
+ if self.args[1].type ~= 'void' then
+  local i=1
+  while self.args[i] do
+   local btype = isbasic(self.args[i].type)
+   if btype ~= 'value' and btype ~= 'state' then
+    output('     !'..self.args[i]:outchecktype(narg)..' ||\n')
+   end
+   if btype ~= 'state' then
+	   narg = narg+1
+   end
+   i = i+1
+  end
+ end
+ -- check end of list
+ output('     !tolua_isnoobj(tolua_S,'..narg..',&tolua_err)\n )')
+	output('  goto tolua_lerror;')
+
+ output(' else\n')
+	if overload < 0 then
+	 output('#endif\n')
+	end
+	output(' {')
+
+ -- declare self, if the case
+ local narg
+ if class then narg=2 else narg=1 end
+ if class and self.name~='new' and static==nil then
+  output(' ',self.const,self.parent.type,'*','self = ')
+  output('(',self.const,self.parent.type,'*) ')
+  output('tolua_tousertype(tolua_S,1,0);')
+ elseif static then
+  _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+ -- declare parameters
+ if self.args[1].type ~= 'void' then
+  local i=1
+  while self.args[i] do
+   self.args[i]:declare(narg)
+   if isbasic(self.args[i].type) ~= "state" then
+	   narg = narg+1
+   end
+   i = i+1
+  end
+ end
+
+ -- check self
+ if class and self.name~='new' and static==nil then
+	 output('#ifndef TOLUA_RELEASE\n')
+  output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
+	 output('#endif\n')
+ end
+
+ -- get array element values
+ if class then narg=2 else narg=1 end
+ if self.args[1].type ~= 'void' then
+  local i=1
+  while self.args[i] do
+   self.args[i]:getarray(narg)
+   narg = narg+1
+   i = i+1
+  end
+ end
+
+ --------------------------------------------------
+ -- CEGUILua mod
+ -- init exception handling
+ local throws = false
+ do
+  local pattern = "tolua_throws|.*|"
+  local i,j = string.find(self.mod, pattern)
+  if i then
+   throws = {}
+   -- ensure table is empty.  Used to be: table.setn(throws,0)
+   for x in pairs(throws) do
+     throws[x] = nil
+   end
+   local excepts = string.sub(self.mod, i+12,j)
+   local epattern = "|.-|"
+   local i,j = string.find(excepts, epattern)
+   while i do
+    local e = string.sub(excepts,i+1,j-1)
+    local _,_,name,rest = string.find(e, "([%w:_]+),?(.*)")
+    table.insert(throws,{name=name, ret=rest})
+    i,j = string.find(excepts, epattern, j)
+   end
+   self.mod = string.gsub(self.mod, pattern, "")
+  end
+ end
+ local exRaiseError = false
+ --------------------------------------------------
+
+ local out = string.find(self.mod, "tolua_outside")
+
+ ---------------
+ -- CEGUILua mod
+ -- remove "tolua_outside" from self.mod
+ if out then
+    self.mod = string.gsub(self.mod, "tolua_outside", "")
+ end
+
+ -- call function
+ if class and self.name=='delete' then
+  output('  delete self;')
+ elseif class and self.name == 'operator&[]' then
+  if flags['1'] then -- for compatibility with tolua5 ?
+	output('  self->operator[](',self.args[1].name,'-1) = ',self.args[2].name,';')
+  else
+    output('  self->operator[](',self.args[1].name,') = ',self.args[2].name,';')
+  end
+ else
+  -- CEGUILua mod begin- throws
+  if throws then
+    for i=1,table.getn(throws) do
+        if string.find(throws[i].ret, "error") then
+            output("char errorBuffer["..exceptionMessageBufferSize.."];\n")
+            output("bool errorDoIt = false;\n")
+            exRaiseError = true
+            break
+        end
+    end
+    output("try\n")
+  end
+  -- CEGUILua mod end - throws
+  output('  {')
+  if self.type ~= '' and self.type ~= 'void' then
+   output('  ',self.mod,self.type,self.ptr,'tolua_ret = ')
+   output('(',self.mod,self.type,self.ptr,') ')
+  else
+   output('  ')
+  end
+  if class and self.name=='new' then
+   output('new',self.type,'(')
+  elseif class and static then
+	if out then
+		output(self.name,'(')
+	else
+		output(class..'::'..self.name,'(')
+	end
+  elseif class then
+	if out then
+		output(self.name,'(')
+	else
+	  if self.cast_operator then
+	  	output('static_cast<',self.mod,self.type,self.ptr,'>(*self')
+	  else
+		output('self->'..self.name,'(')
+	  end
+	end
+  else
+   output(self.name,'(')
+  end
+
+  if out and not static then
+  	output('self')
+	if self.args[1] and self.args[1].name ~= '' then
+		output(',')
+	end
+  end
+  -- write parameters
+  local i=1
+  while self.args[i] do
+   self.args[i]:passpar()
+   i = i+1
+   if self.args[i] then
+    output(',')
+   end
+  end
+
+  if class and self.name == 'operator[]' and flags['1'] then
+	output('-1);')
+  else
+	output(');')
+  end
+
+  -- return values
+  if self.type ~= '' and self.type ~= 'void' then
+   nret = nret + 1
+   local t,ct = isbasic(self.type)
+   if t then
+   	if self.cast_operator and _basic_raw_push[t] then
+		output('   ',_basic_raw_push[t],'(tolua_S,(',ct,')tolua_ret);')
+   	else
+	    output('   tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);')
+	end
+   else
+			 t = self.type
+			 new_t = string.gsub(t, "const%s+", "")
+    if self.ptr == '' then
+     output('   {')
+     output('#ifdef __cplusplus\n')
+     output('    void* tolua_obj = new',new_t,'(tolua_ret);')
+     output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+     output('#else\n')
+     output('    void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
+     output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+     output('#endif\n')
+     output('   }')
+    elseif self.ptr == '&' then
+     output('   tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
+    else
+    	if local_constructor then
+	  output('   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");')
+    	else
+		     output('   tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
+	    end
+    end
+   end
+  end
+  local i=1
+  while self.args[i] do
+   nret = nret + self.args[i]:retvalue()
+   i = i+1
+  end
+  output('  }')
+
+  ------------------------------------------
+  -- CEGUILua mod
+  -- finish exception handling
+  -- catch
+  if throws then
+   outputExceptionCatchBlocks(self.name, throws, exRaiseError)
+  end
+  ------------------------------------------
+
+  -- set array element values
+  if class then narg=2 else narg=1 end
+  if self.args[1].type ~= 'void' then
+   local i=1
+   while self.args[i] do
+    self.args[i]:setarray(narg)
+    narg = narg+1
+    i = i+1
+   end
+  end
+
+  -- free dynamically allocated array
+  if self.args[1].type ~= 'void' then
+   local i=1
+   while self.args[i] do
+    self.args[i]:freearray()
+    i = i+1
+   end
+  end
+ end
+
+ output(' }')
+ output(' return '..nret..';')
+
+ -- call overloaded function or generate error
+	if overload < 0 then
+
+		output('#ifndef TOLUA_RELEASE\n')
+		output('tolua_lerror:\n')
+		output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
+		output(' return 0;')
+		output('#endif\n')
+	else
+		local _local = ""
+		if local_constructor then
+			_local = "_local"
+		end
+		output('tolua_lerror:\n')
+		output(' return '..strsub(self.cname,1,-3)..format("%02d",overload).._local..'(tolua_S);')
+	end
+ output('}')
+ output('#endif //#ifndef TOLUA_DISABLE\n')
+ output('\n')
+
+	-- recursive call to write local constructor
+	if class and self.name=='new' and not local_constructor then
+
+		self:supcode(1)
+	end
+
+end
+
+
+-- register function
+function classFunction:register (pre)
+
+	if not self:check_public_access() then
+		return
+	end
+
+ 	if self.name == 'new' and self.parent.flags.pure_virtual then
+ 		-- no constructor for classes with pure virtual methods
+ 		return
+ 	end
+
+ output(pre..'tolua_function(tolua_S,"'..self.lname..'",'..self.cname..');')
+  if self.name == 'new' then
+	  output(pre..'tolua_function(tolua_S,"new_local",'..self.cname..'_local);')
+	  output(pre..'tolua_function(tolua_S,".call",'..self.cname..'_local);')
+	  --output(' tolua_set_call_event(tolua_S,'..self.cname..'_local, "'..self.parent.type..'");')
+  end
+end
+
+-- Print method
+function classFunction:print (ident,close)
+ print(ident.."Function{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." const = '"..self.const.."',")
+ print(ident.." cname = '"..self.cname.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." args = {")
+ local i=1
+ while self.args[i] do
+  self.args[i]:print(ident.."  ",",")
+  i = i+1
+ end
+ print(ident.." }")
+ print(ident.."}"..close)
+end
+
+-- check if it returns an object by value
+function classFunction:requirecollection (t)
+	local r = false
+	if self.type ~= '' and not isbasic(self.type) and self.ptr=='' then
+		local type = gsub(self.type,"%s*const%s+","")
+	 t[type] = "tolua_collect_" .. clean_template(type)
+	 r = true
+	end
+	local i=1
+	while self.args[i] do
+		r = self.args[i]:requirecollection(t) or r
+		i = i+1
+	end
+	return r
+end
+
+-- determine lua function name overload
+function classFunction:overload ()
+ return self.parent:overload(self.lname)
+end
+
+
+function param_object(par) -- returns true if the parameter has an object as its default value
+
+	if not string.find(par, '=') then return false end -- it has no default value
+
+	local _,_,def = string.find(par, "=(.*)$")
+
+	if string.find(par, "|") then -- a list of flags
+
+		return true
+	end
+
+	if string.find(par, "%*") then -- it's a pointer with a default value
+
+		if string.find(par, '=%s*new') then -- it's a pointer with an instance as default parameter.. is that valid?
+			return true
+		end
+		return false -- default value is 'NULL' or something
+	end
+
+
+	if string.find(par, "[%(&]") then
+		return true
+	end -- default value is a constructor call (most likely for a const reference)
+
+	--if string.find(par, "&") then
+
+	--	if string.find(def, ":") or string.find(def, "^%s*new%s+") then
+
+	--		-- it's a reference with default to something like Class::member, or 'new Class'
+	--		return true
+	--	end
+	--end
+
+	return false -- ?
+end
+
+function strip_last_arg(all_args, last_arg) -- strips the default value from the last argument
+
+	local _,_,s_arg = string.find(last_arg, "^([^=]+)")
+	last_arg = string.gsub(last_arg, "([%%%(%)])", "%%%1");
+	all_args = string.gsub(all_args, "%s*,%s*"..last_arg.."%s*%)%s*$", ")")
+	return all_args, s_arg
+end
+
+
+
+-- Internal constructor
+function _Function (t)
+ setmetatable(t,classFunction)
+
+ if t.const ~= 'const' and t.const ~= '' then
+  error("#invalid 'const' specification")
+ end
+
+ append(t)
+ if t:inclass() then
+ --print ('t.name is '..t.name..', parent.name is '..t.parent.name)
+  if string.gsub(t.name, "%b<>", "") == string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then
+   t.name = 'new'
+   t.lname = 'new'
+   t.parent._new = true
+   t.type = t.parent.name
+   t.ptr = '*'
+  elseif string.gsub(t.name, "%b<>", "") == '~'..string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then
+   t.name = 'delete'
+   t.lname = 'delete'
+   t.parent._delete = true
+  end
+ end
+ t.cname = t:cfuncname("tolua")..t:overload(t)
+ return t
+end
+
+-- Constructor
+-- Expects three strings: one representing the function declaration,
+-- another representing the argument list, and the third representing
+-- the "const" or empty string.
+function Function (d,a,c)
+ --local t = split(strsub(a,2,-2),',') -- eliminate braces
+ --local t = split_params(strsub(a,2,-2))
+
+	if not flags['W'] and string.find(a, "%.%.%.%s*%)") then
+
+		warning("Functions with variable arguments (`...') are not supported. Ignoring "..d..a..c)
+		return nil
+	end
+
+
+ local i=1
+ local l = {n=0}
+
+ 	a = string.gsub(a, "%s*([%(%)])%s*", "%1")
+	local t,strip,last = strip_pars(strsub(a,2,-2));
+	if strip then
+		--local ns = string.sub(strsub(a,1,-2), 1, -(string.len(last)+1))
+		local ns = join(t, ",", 1, last-1)
+
+		ns = "("..string.gsub(ns, "%s*,%s*$", "")..')'
+		--ns = strip_defaults(ns)
+
+		Function(d, ns, c)
+		for i=1,last do
+			t[i] = string.gsub(t[i], "=.*$", "")
+		end
+	end
+
+ while t[i] do
+  l.n = l.n+1
+  l[l.n] = Declaration(t[i],'var',true)
+  i = i+1
+ end
+ local f = Declaration(d,'func')
+ f.args = l
+ f.const = c
+ return _Function(f)
+end
+
+function join(t, sep, first, last)
+
+	first = first or 1
+	last = last or table.getn(t)
+	local lsep = ""
+	local ret = ""
+	local loop = false
+	for i = first,last do
+
+		ret = ret..lsep..t[i]
+		lsep = sep
+		loop = true
+	end
+	if not loop then
+		return ""
+	end
+
+	return ret
+end
+
+function strip_pars(s)
+
+	local t = split_c_tokens(s, ',')
+	local strip = false
+	local last
+
+	for i=t.n,1,-1 do
+
+		if not strip and param_object(t[i]) then
+			last = i
+			strip = true
+		end
+		--if strip then
+		--	t[i] = string.gsub(t[i], "=.*$", "")
+		--end
+	end
+
+	return t,strip,last
+
+end
+
+function strip_defaults(s)
+
+	s = string.gsub(s, "^%(", "")
+	s = string.gsub(s, "%)$", "")
+
+	local t = split_c_tokens(s, ",")
+	local sep, ret = "",""
+	for i=1,t.n do
+		t[i] = string.gsub(t[i], "=.*$", "")
+		ret = ret..sep..t[i]
+		sep = ","
+	end
+
+	return "("..ret..")"
+end
+
+
Index: /code/branches/physics/src/tolua/lua/module.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/module.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/module.lua	(revision 2122)
@@ -0,0 +1,68 @@
+-- tolua: module class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Module class
+-- Represents module.
+-- The following fields are stored:
+--    {i} = list of objects in the module.
+classModule = {
+ classtype = 'module'
+}
+classModule.__index = classModule
+setmetatable(classModule,classContainer)
+
+-- register module
+function classModule:register (pre)
+ pre = pre or ''
+ push(self)
+ output(pre..'tolua_module(tolua_S,"'..self.name..'",',self:hasvar(),');')
+ output(pre..'tolua_beginmodule(tolua_S,"'..self.name..'");')
+ local i=1
+ while self[i] do
+  self[i]:register(pre..' ')
+  i = i+1
+ end
+ output(pre..'tolua_endmodule(tolua_S);')
+	pop()
+end
+
+-- Print method
+function classModule:print (ident,close)
+ print(ident.."Module{")
+ print(ident.." name = '"..self.name.."';")
+ local i=1
+ while self[i] do
+  self[i]:print(ident.." ",",")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Module (t)
+ setmetatable(t,classModule)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects two string representing the module name and body.
+function Module (n,b)
+ local t = _Module(_Container{name=n})
+ push(t)
+ t:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+ pop()
+ return t
+end
+
+
Index: /code/branches/physics/src/tolua/lua/namespace.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/namespace.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/namespace.lua	(revision 2122)
@@ -0,0 +1,52 @@
+-- tolua: namespace class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 2003
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Namespace class
+-- Represents a namesapce definition.
+-- Stores the following fields:
+--    name = class name
+--    {i}  = list of members
+classNamespace = {
+ classtype = 'namespace',
+ name = '',
+}
+classNamespace.__index = classNamespace
+setmetatable(classNamespace,classModule)
+
+-- Print method
+function classNamespace:print (ident,close)
+ print(ident.."Namespace{")
+ print(ident.." name = '"..self.name.."',")
+ local i=1
+ while self[i] do
+  self[i]:print(ident.." ",",")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Namespace (t)
+ setmetatable(t,classNamespace)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects the name and the body of the namespace.
+function Namespace (n,b)
+ local c = _Namespace(_Container{name=n})
+ push(c)
+ c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+ pop()
+end
+
Index: /code/branches/physics/src/tolua/lua/operator.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/operator.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/operator.lua	(revision 2122)
@@ -0,0 +1,214 @@
+-- tolua: operator class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Operator class
+-- Represents an operator function or a class operator method.
+-- It stores the same fields as functions do plus:
+--  kind = set of character representing the operator (as it appers in C++ code)
+classOperator = {
+ kind = '',
+}
+classOperator.__index = classOperator
+setmetatable(classOperator,classFunction)
+
+-- table to transform operator kind into the appropriate tag method name
+_TM = {['+'] = 'add',
+       ['-'] = 'sub',
+       ['*'] = 'mul',
+       ['/'] = 'div',
+       ['<'] = 'lt',
+       ['<='] = 'le',
+       ['=='] = 'eq',
+       ['[]'] = 'geti',
+       ['&[]'] = 'seti',
+       --['->'] = 'flechita',
+      }
+
+
+-- Print method
+function classOperator:print (ident,close)
+ print(ident.."Operator{")
+ print(ident.." kind  = '"..self.kind.."',")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." const = '"..self.const.."',")
+ print(ident.." cname = '"..self.cname.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." args = {")
+ local i=1
+ while self.args[i] do
+  self.args[i]:print(ident.."  ",",")
+  i = i+1
+ end
+ print(ident.." }")
+ print(ident.."}"..close)
+end
+
+function classOperator:supcode_tmp()
+
+	if not _TM[self.kind] then
+		return classFunction.supcode(self)
+	end
+
+	-- no overload, no parameters, always inclass
+	output("/* method:",self.name," of class ",self:inclass()," */")
+
+	output("#ifndef TOLUA_DISABLE_"..self.cname)
+	output("\nstatic int",self.cname,"(lua_State* tolua_S)")
+
+	if overload < 0 then
+	 output('#ifndef TOLUA_RELEASE\n')
+	end
+	output(' tolua_Error tolua_err;')
+	output(' if (\n')
+	-- check self
+	output('     !'..'tolua_isusertype(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n')
+	output('     !tolua_isnoobj(tolua_S,2,&tolua_err)\n )')
+	output('  goto tolua_lerror;')
+
+	output(' else\n')
+	output('#endif\n') -- tolua_release
+	output(' {')
+
+	-- declare self
+	output(' ',self.const,self.parent.type,'*','self = ')
+	output('(',self.const,self.parent.type,'*) ')
+	output('tolua_tousertype(tolua_S,1,0);')
+
+	-- check self
+	output('#ifndef TOLUA_RELEASE\n')
+	output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
+	output('#endif\n')
+
+	-- cast self
+	output('  ',self.mod,self.type,self.ptr,'tolua_ret = ')
+	output('(',self.mod,self.type,self.ptr,')(*self);')
+
+	-- return value
+	local t,ct = isbasic(self.type)
+	if t then
+		output('   tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);')
+	else
+		t = self.type
+		new_t = string.gsub(t, "const%s+", "")
+		if self.ptr == '' then
+			output('   {')
+			output('#ifdef __cplusplus\n')
+			output('    void* tolua_obj = new',new_t,'(tolua_ret);')
+			output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+			output('#else\n')
+			output('    void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
+			output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+			output('#endif\n')
+			output('   }')
+		elseif self.ptr == '&' then
+			output('   tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
+		else
+			if local_constructor then
+				output('   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");')
+			else
+				output('   tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
+			end
+		end
+	end
+
+	output('  }')
+	output(' return 1;')
+
+	output('#ifndef TOLUA_RELEASE\n')
+	output('tolua_lerror:\n')
+	output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
+	output(' return 0;')
+	output('#endif\n')
+
+
+	output('}')
+	output('#endif //#ifndef TOLUA_DISABLE\n')
+	output('\n')
+end
+
+-- Internal constructor
+function _Operator (t)
+ setmetatable(t,classOperator)
+
+ if t.const ~= 'const' and t.const ~= '' then
+  error("#invalid 'const' specification")
+ end
+
+ append(t)
+ if not t:inclass() then
+  error("#operator can only be defined as class member")
+ end
+
+ --t.name = t.name .. "_" .. (_TM[t.kind] or t.kind)
+ t.cname = t:cfuncname("tolua")..t:overload(t)
+ t.name = "operator" .. t.kind  -- set appropriate calling name
+ return t
+end
+
+-- Constructor
+function Operator (d,k,a,c)
+
+	local op_k = string.gsub(k, "^%s*", "")
+	op_k = string.gsub(k, "%s*$", "")
+	--if string.find(k, "^[%w_:%d<>%*%&]+$") then
+	if d == "operator" and k ~= '' then
+
+		d = k.." operator"
+	elseif not _TM[op_k] then
+
+		if flags['W'] then
+			error("tolua: no support for operator" .. f.kind)
+		else
+			warning("No support for operator "..op_k..", ignoring")
+			return nil
+		end
+	end
+
+	local ref = ''
+ local t = split_c_tokens(strsub(a,2,strlen(a)-1),',') -- eliminate braces
+ local i=1
+ local l = {n=0}
+ while t[i] do
+  l.n = l.n+1
+  l[l.n] = Declaration(t[i],'var')
+  i = i+1
+ end
+ if k == '[]' then
+	 local _
+	 _, _, ref = strfind(d,'(&)')
+  d = gsub(d,'&','')
+ elseif k=='&[]' then
+  l.n = l.n+1
+  l[l.n] = Declaration(d,'var')
+  l[l.n].name = 'tolua_value'
+ end
+ local f = Declaration(d,'func')
+ if k == '[]' and (l[1]==nil or isbasic(l[1].type)~='number') then
+  error('operator[] can only be defined for numeric index.')
+ end
+ f.args = l
+ f.const = c
+ f.kind = op_k
+ f.lname = "."..(_TM[f.kind] or f.kind)
+ if not _TM[f.kind] then
+ 	f.cast_operator = true
+ end
+ if f.kind == '[]' and ref=='&' and f.const~='const' then
+  Operator(d,'&'..k,a,c) 	-- create correspoding set operator
+ end
+ return _Operator(f)
+end
+
+
Index: /code/branches/physics/src/tolua/lua/package.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/package.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/package.lua	(revision 2122)
@@ -0,0 +1,316 @@
+-- tolua: package class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Package class
+-- Represents the whole package being bound.
+-- The following fields are stored:
+--    {i} = list of objects in the package.
+classPackage = {
+ classtype = 'package'
+}
+classPackage.__index = classPackage
+setmetatable(classPackage,classContainer)
+
+-- Print method
+function classPackage:print ()
+ print("Package: "..self.name)
+ local i=1
+ while self[i] do
+  self[i]:print("","")
+  i = i+1
+ end
+end
+
+function classPackage:preprocess ()
+
+ -- avoid preprocessing embedded Lua code
+ local L = {}
+ self.code = gsub(self.code,"\n%s*%$%[","\1") -- deal with embedded lua code
+ self.code = gsub(self.code,"\n%s*%$%]","\2")
+ self.code = gsub(self.code,"(%b\1\2)",       function (c)
+                                               tinsert(L,c)
+                                               return "\n#["..getn(L).."]#"
+                                              end)
+ -- avoid preprocessing embedded C code
+ local C = {}
+ self.code = gsub(self.code,"\n%s*%$%<","\3") -- deal with embedded C code
+ self.code = gsub(self.code,"\n%s*%$%>","\4")
+ self.code = gsub(self.code,"(%b\3\4)",       function (c)
+                                               tinsert(C,c)
+                                               return "\n#<"..getn(C)..">#"
+                                              end)
+ -- avoid preprocessing embedded C code
+ self.code = gsub(self.code,"\n%s*%$%{","\5") -- deal with embedded C code
+ self.code = gsub(self.code,"\n%s*%$%}","\6")
+ self.code = gsub(self.code,"(%b\5\6)",       function (c)
+                                               tinsert(C,c)
+                                               return "\n#<"..getn(C)..">#"
+                                              end)
+
+ --self.code = gsub(self.code,"\n%s*#[^d][^\n]*\n", "\n\n") -- eliminate preprocessor directives that don't start with 'd'
+ self.code = gsub(self.code,"\n[ \t]*#[ \t]*[^d%<%[]", "\n//") -- eliminate preprocessor directives that don't start with 'd'
+
+ -- avoid preprocessing verbatim lines
+ local V = {}
+ self.code = gsub(self.code,"\n(%s*%$[^%[%]][^\n]*)",function (v)
+                                               tinsert(V,v)
+                                               return "\n#"..getn(V).."#"
+                                              end)
+
+ -- perform global substitution
+
+ self.code = gsub(self.code,"(//[^\n]*)","")     -- eliminate C++ comments
+ self.code = gsub(self.code,"/%*","\1")
+ self.code = gsub(self.code,"%*/","\2")
+ self.code = gsub(self.code,"%b\1\2","")
+ self.code = gsub(self.code,"\1","/%*")
+ self.code = gsub(self.code,"\2","%*/")
+ self.code = gsub(self.code,"%s*@%s*","@") -- eliminate spaces beside @
+ self.code = gsub(self.code,"%s?inline(%s)","%1") -- eliminate 'inline' keyword
+ --self.code = gsub(self.code,"%s?extern(%s)","%1") -- eliminate 'extern' keyword
+ --self.code = gsub(self.code,"%s?virtual(%s)","%1") -- eliminate 'virtual' keyword
+ --self.code = gsub(self.code,"public:","") -- eliminate 'public:' keyword
+ self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ self.code = gsub(self.code,"([^%w_])char%s*%*","%1_cstring ")  -- substitute 'char*'
+ self.code = gsub(self.code,"([^%w_])lua_State%s*%*","%1_lstate ")  -- substitute 'lua_State*'
+
+ -- restore embedded Lua code
+ self.code = gsub(self.code,"%#%[(%d+)%]%#",function (n)
+                                              return L[tonumber(n)]
+                                            end)
+ -- restore embedded C code
+ self.code = gsub(self.code,"%#%<(%d+)%>%#",function (n)
+                                             return C[tonumber(n)]
+                                            end)
+ -- restore verbatim lines
+ self.code = gsub(self.code,"%#(%d+)%#",function (n)
+                                         return V[tonumber(n)]
+                                        end)
+
+ self.code = string.gsub(self.code, "\n%s*%$([^\n]+)", function (l)
+											Verbatim(l.."\n")
+											return "\n"
+										  end)
+end
+
+-- translate verbatim
+function classPackage:preamble ()
+ output('/*\n')
+ output('** Lua binding: '..self.name..'\n')
+ output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
+ output('*/\n\n')
+
+	output('#ifndef __cplusplus\n')
+	output('#include "stdlib.h"\n')
+	output('#endif\n')
+	output('#include "string.h"\n\n')
+ output('#include "tolua/tolua++.h"\n\n')
+
+ if not flags.h then
+--  local temp = string.reverse(flags.H)
+--  local start1, end1 = string.find(temp, '/')
+--  local start2, end2 = string.find(temp, '\\')
+--  local res
+--  if not start1 == nil then
+--   if not start2 == nil then
+--    if start1 > start2 then
+--     res = string.sub(temp, 1, start2)
+--    else
+--     res = string.sub(temp, 1, start1)
+--    end
+--   else
+--    res = string.sub(temp, 1, start1)
+--   end
+--  elseif not start2 == nil then
+--   res = string.sub(temp, 1, start2)
+--  end
+--  res = string.reverse(res)
+  output('#include "tolua_bind.h"')
+  output('\n')
+ end
+
+ local i=1
+ while self[i] do
+  self[i]:preamble()
+  i = i+1
+ end
+
+	if self:requirecollection(_collect) then
+		output('\n')
+		output('/* function to release collected object via destructor */')
+		output('#ifdef __cplusplus\n')
+		for i,v in pairs(_collect) do
+		 output('\nstatic int '..v..' (lua_State* tolua_S)')
+			output('{')
+			output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
+			output('	delete self;')
+			output('	return 0;')
+			output('}')
+		end
+		output('#endif\n\n')
+	end
+
+ output('\n')
+ output('/* function to register type */')
+ output('static void tolua_reg_types (lua_State* tolua_S)')
+ output('{')
+ foreach(_usertype,function(n,v) output(' tolua_usertype(tolua_S,"',v,'");') end)
+	if flags.t then
+		output("#ifndef Mtolua_typeid\n#define Mtolua_typeid(L,TI,T)\n#endif\n")
+		foreach(_usertype,function(n,v) output(' Mtolua_typeid(tolua_S,typeid(',v,'), "',v,'");') end)
+	end
+ output('}')
+ output('\n')
+end
+
+-- register package
+-- write package open function
+function classPackage:register (pre)
+ pre = pre or ''
+ push(self)
+ output(pre.."/* Open function */")
+ output(pre.."int tolua_"..self.name.."_open (lua_State* tolua_S)")
+ output(pre.."{")
+ output(pre.." tolua_open(tolua_S);")
+ output(pre.." tolua_reg_types(tolua_S);")
+ output(pre.." tolua_module(tolua_S,NULL,",self:hasvar(),");")
+ output(pre.." tolua_beginmodule(tolua_S,NULL);")
+ local i=1
+ while self[i] do
+  self[i]:register(pre.."  ")
+  i = i+1
+ end
+ output(pre.." tolua_endmodule(tolua_S);")
+ output(pre.." return 1;")
+ output(pre.."}")
+
+ output("\n\n")
+ output("#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501\n");
+ output(pre.."int luaopen_"..self.name.." (lua_State* tolua_S) {")
+ output(pre.." return tolua_"..self.name.."_open(tolua_S);")
+ output(pre.."};")
+ output("#endif\n\n")
+
+	pop()
+end
+
+-- write header file
+function classPackage:header ()
+ output('/*\n') output('** Lua binding: '..self.name..'\n')
+ output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
+ output('*/\n\n')
+
+ if not flags.h then
+  output('#include "../'..self.name..'Prereqs.h"\n')
+  output('/* Exported function */')
+  output('_'..self.name..'Export int  tolua_'..self.name..'_open (lua_State* tolua_S);')
+  output('\n')
+ end
+end
+
+-- Internal constructor
+function _Package (self)
+ setmetatable(self,classPackage)
+ return self
+end
+
+-- Parse C header file with tolua directives
+-- *** Thanks to Ariel Manzur for fixing bugs in nested directives ***
+function extract_code(fn,s)
+	local code = '\n$#include "'..fn..'"\n'
+	s= "\n" .. s .. "\n" -- add blank lines as sentinels
+	local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
+	while e do
+		t = strlower(t)
+		if t == "begin" then
+			_,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
+			if not e then
+			 tolua_error("Unbalanced 'tolua_begin' directive in header file")
+			end
+		end
+		code = code .. c .. "\n"
+	 _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
+	end
+	return code
+end
+
+-- Constructor
+-- Expects the package name, the file extension, and the file text.
+function Package (name,fn)
+ local ext = "pkg"
+
+ -- open input file, if any
+ if fn then
+  local st, msg = readfrom(flags.f)
+  if not st then
+   error('#'..msg)
+  end
+		local _; _, _, ext = strfind(fn,".*%.(.*)$")
+ end
+ local code = "\n" .. read('*a')
+	if ext == 'h' or ext == 'hpp' then
+	 code = extract_code(fn,code)
+	end
+
+ -- close file
+ if fn then
+  readfrom()
+ end
+
+ -- deal with include directive
+ local nsubst
+ repeat
+  code,nsubst = gsub(code,'\n%s*%$(.)file%s*"(.-)"([^\n]*)\n',
+		function (kind,fn,extra)
+			local _, _, ext = strfind(fn,".*%.(.*)$")
+			local fp,msg = openfile(fn,'r')
+			if not fp then
+				error('#'..msg..': '..fn)
+			end
+			local s = read(fp,'*a')
+			closefile(fp)
+			if kind == 'c' or kind == 'h' then
+				return extract_code(fn,s)
+			elseif kind == 'p' then
+				return "\n\n" .. s
+			elseif kind == 'l' then
+				return "\n$[--##"..fn.."\n" .. s .. "\n$]\n"
+			elseif kind == 'i' then
+				local t = {code=s}
+				extra = string.gsub(extra, "^%s*,%s*", "")
+				local pars = split_c_tokens(extra, ",")
+				include_file_hook(t, fn, unpack(pars))
+				return "\n\n" .. t.code
+			else
+				error('#Invalid include directive (use $cfile, $pfile, $lfile or $ifile)')
+			end
+		end)
+ until nsubst==0
+
+ -- deal with renaming directive
+ repeat -- I don't know why this is necesary
+	code,nsubst = gsub(code,'\n%s*%$renaming%s*(.-)%s*\n', function (r) appendrenaming(r) return "\n" end)
+ until nsubst == 0
+
+ local t = _Package(_Container{name=name, code=code})
+ push(t)
+ preprocess_hook(t)
+ t:preprocess()
+ preparse_hook(t)
+ t:parse(t.code)
+ pop()
+ return t
+end
+
+
Index: /code/branches/physics/src/tolua/lua/typedef.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/typedef.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/typedef.lua	(revision 2122)
@@ -0,0 +1,71 @@
+-- tolua: typedef class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Typedef class
+-- Represents a type synonym.
+-- The 'de facto' type replaces the typedef before the
+-- remaining code is parsed.
+-- The following fields are stored:
+--   utype = typedef name
+--   type = 'the facto' type
+--   mod = modifiers to the 'de facto' type
+classTypedef = {
+ utype = '',
+ mod = '',
+ type = ''
+}
+classTypedef.__index = classTypedef
+
+-- Print method
+function classTypedef:print (ident,close)
+ print(ident.."Typedef{")
+ print(ident.." utype = '"..self.utype.."',")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.."}"..close)
+end
+
+-- Return it's not a variable
+function classTypedef:isvariable ()
+ return false
+end
+
+-- Internal constructor
+function _Typedef (t)
+ setmetatable(t,classTypedef)
+ t.type = resolve_template_types(t.type)
+ appendtypedef(t)
+ return t
+end
+
+-- Constructor
+-- Expects one string representing the type definition.
+function Typedef (s)
+ if strfind(string.gsub(s, '%b<>', ''),'[%*&]') then
+  tolua_error("#invalid typedef: pointers (and references) are not supported")
+ end
+ local o = {mod = ''}
+ if string.find(s, "[<>]") then
+ 	_,_,o.type,o.utype = string.find(s, "^%s*([^<>]+%b<>[^%s]*)%s+(.-)$")
+ else
+ 	local t = split(gsub(s,"%s%s*"," ")," ")
+ 	o = {
+	  utype = t[t.n],
+	  type = t[t.n-1],
+	  mod = concat(t,1,t.n-2),
+	 }
+ end
+ return _Typedef(o)
+end
+
+
Index: /code/branches/physics/src/tolua/lua/variable.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/variable.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/variable.lua	(revision 2122)
@@ -0,0 +1,295 @@
+-- tolua: variable class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Variable class
+-- Represents a extern variable or a public member of a class.
+-- Stores all fields present in a declaration.
+classVariable = {
+ _get = {},   -- mapped get functions
+ _set = {},   -- mapped set functions
+}
+classVariable.__index = classVariable
+setmetatable(classVariable,classDeclaration)
+
+-- Print method
+function classVariable:print (ident,close)
+ print(ident.."Variable{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ if self.dim then print(ident.." dim = '"..self.dim.."',") end
+ print(ident.." def  = '"..self.def.."',")
+ print(ident.." ret  = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- Generates C function name
+function classVariable:cfuncname (prefix)
+ local parent = ""
+ local unsigned = ""
+ local ptr = ""
+
+ local p = self:inmodule() or self:innamespace() or self:inclass()
+
+ if p then
+ 	if self.parent.classtype == 'class' then
+		parent = "_" .. self.parent.type
+	else
+	  parent = "_" .. p
+	end
+ end
+
+ if strfind(self.mod,"(unsigned)") then
+  unsigned = "_unsigned"
+ end
+
+ if self.ptr == "*" then ptr = "_ptr"
+ elseif self.ptr == "&" then ptr = "_ref"
+ end
+
+ local name =  prefix .. parent .. unsigned .. "_" .. gsub(self.lname or self.name,".*::","") .. ptr
+
+	name = clean_template(name)
+ return name
+
+end
+
+-- check if it is a variable
+function classVariable:isvariable ()
+ return true
+end
+
+-- get variable value
+function classVariable:getvalue (class,static, prop_get)
+
+	local name
+	if prop_get then
+
+		name = prop_get.."()"
+	else
+		name = self.name
+	end
+
+	if class and static then
+	 return self.parent.type..'::'..name
+	elseif class then
+	 return 'self->'..name
+	else
+	 return name
+	end
+end
+
+-- get variable pointer value
+function classVariable:getpointervalue (class,static)
+ if class and static then
+  return class..'::p'
+ elseif class then
+  return 'self->p'
+ else
+  return 'p'
+ end
+end
+
+-- Write binding functions
+function classVariable:supcode ()
+
+ local class = self:inclass()
+
+	local prop_get,prop_set
+	if string.find(self.mod, 'tolua_property') then
+
+		_,_,type = string.find(self.mod, "tolua_property__([^%s]*)")
+		type = type or "default"
+		prop_get,prop_set = get_property_methods(type, self.name)
+		self.mod = string.gsub(self.mod, "tolua_property[^%s]*", "")
+	end
+
+ -- get function ------------------------------------------------
+ if class then
+  output("/* get function:",self.name," of class ",class," */")
+ else
+  output("/* get function:",self.name," */")
+ end
+ self.cgetname = self:cfuncname("tolua_get")
+ output("#ifndef TOLUA_DISABLE_"..self.cgetname)
+ output("\nstatic int",self.cgetname,"(lua_State* tolua_S)")
+ output("{")
+
+ -- declare self, if the case
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class and static==nil then
+  output(' ',self.parent.type,'*','self = ')
+  output('(',self.parent.type,'*) ')
+  output('tolua_tousertype(tolua_S,1,0);')
+ elseif static then
+  _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+
+ -- check self value
+ if class and static==nil then
+	 output('#ifndef TOLUA_RELEASE\n')
+  output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+		output('#endif\n')
+ end
+
+ -- return value
+ if string.find(self.mod, 'tolua_inherits') then
+ 	output('#ifdef __cplusplus\n')
+	output('  tolua_pushusertype(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");')
+	output('#else\n')
+	output('  tolua_pushusertype(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");')
+	output('#endif\n')
+ else
+	local t,ct = isbasic(self.type)
+	if t then
+		output('  tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static,prop_get)..');')
+	else
+		t = self.type
+		if self.ptr == '&' or self.ptr == '' then
+			output('  tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");')
+		else
+			output('  tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");')
+		end
+	end
+ end
+ output(' return 1;')
+ output('}')
+ output('#endif //#ifndef TOLUA_DISABLE\n')
+ output('\n')
+
+ -- set function ------------------------------------------------
+ if not (strfind(self.type,'const%s+') or string.find(self.mod, 'tolua_readonly') or string.find(self.mod, 'tolua_inherits'))  then
+  if class then
+   output("/* set function:",self.name," of class ",class," */")
+  else
+   output("/* set function:",self.name," */")
+  end
+  self.csetname = self:cfuncname("tolua_set")
+  output("#ifndef TOLUA_DISABLE_"..self.csetname)
+  output("\nstatic int",self.csetname,"(lua_State* tolua_S)")
+  output("{")
+
+  -- declare self, if the case
+  if class and static==nil then
+   output(' ',self.parent.type,'*','self = ')
+   output('(',self.parent.type,'*) ')
+   output('tolua_tousertype(tolua_S,1,0);')
+   -- check self value
+		end
+  -- check types
+		output('#ifndef TOLUA_RELEASE\n')
+		output('  tolua_Error tolua_err;')
+  if class and static==nil then
+   output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+  elseif static then
+   _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+  end
+
+  -- check variable type
+  output('  if (!'..self:outchecktype(2)..')')
+  output('   tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);')
+		output('#endif\n')
+
+  -- assign value
+		local def = 0
+		if self.def ~= '' then def = self.def end
+		if self.type == 'char*' and self.dim ~= '' then -- is string
+		 output(' strncpy(')
+			if class and static then
+				output(self.parent.type..'::'..self.name)
+			elseif class then
+				output('self->'..self.name)
+			else
+				output(self.name)
+			end
+			output(',tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);')
+		else
+			local ptr = ''
+			if self.ptr~='' then ptr = '*' end
+			output(' ')
+			local name = prop_set or self.name
+			if class and static then
+				output(self.parent.type..'::'..name)
+			elseif class then
+				output('self->'..name)
+			else
+				output(name)
+			end
+			local t = isbasic(self.type)
+			if prop_set then
+				output('(')
+			else
+				output(' = ')
+			end
+			if not t and ptr=='' then output('*') end
+			output('((',self.mod,self.type)
+			if not t then
+				output('*')
+			end
+			output(') ')
+			if t then
+				if isenum(self.type) then
+					output('(int) ')
+				end
+				output('tolua_to'..t,'(tolua_S,2,',def,'))')
+			else
+				output('tolua_tousertype(tolua_S,2,',def,'))')
+			end
+			if prop_set then
+				output(")")
+			end
+			output(";")
+		end
+  output(' return 0;')
+  output('}')
+  output('#endif //#ifndef TOLUA_DISABLE\n')
+  output('\n')
+ end
+
+end
+
+function classVariable:register (pre)
+
+	if not self:check_public_access() then
+		return
+	end
+ pre = pre or ''
+ local parent = self:inmodule() or self:innamespace() or self:inclass()
+ if not parent then
+  if classVariable._warning==nil then
+   warning("Mapping variable to global may degrade performance")
+   classVariable._warning = 1
+  end
+ end
+ if self.csetname then
+  output(pre..'tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
+ else
+  output(pre..'tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
+ end
+end
+
+-- Internal constructor
+function _Variable (t)
+ setmetatable(t,classVariable)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the variable declaration.
+function Variable (s)
+ return _Variable (Declaration(s,'var'))
+end
+
+
Index: /code/branches/physics/src/tolua/lua/verbatim.lua
===================================================================
--- /code/branches/physics/src/tolua/lua/verbatim.lua	(revision 2122)
+++ /code/branches/physics/src/tolua/lua/verbatim.lua	(revision 2122)
@@ -0,0 +1,78 @@
+-- tolua: verbatim class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: verbatim.lua,v 1.3 2000/01/24 20:41:16 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Verbatim class
+-- Represents a line translated directed to the binding file.
+-- The following filds are stored:
+--   line = line text
+classVerbatim = {
+ line = '',
+	cond = nil,    -- condition: where to generate the code (s=suport, r=register)
+}
+classVerbatim.__index = classVerbatim
+setmetatable(classVerbatim,classFeature)
+
+-- preamble verbatim
+function classVerbatim:preamble ()
+ if self.cond == '' then
+  write(self.line)
+ end
+end
+
+-- support code
+function classVerbatim:supcode ()
+ if strfind(self.cond,'s') then
+  write(self.line)
+  write('\n')
+ end
+end
+
+-- register code
+function classVerbatim:register (pre)
+ if strfind(self.cond,'r') then
+  write(self.line)
+ end
+end
+
+
+-- Print method
+function classVerbatim:print (ident,close)
+ print(ident.."Verbatim{")
+ print(ident.." line = '"..self.line.."',")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Verbatim (t)
+ setmetatable(t,classVerbatim)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the text line
+function Verbatim (l,cond)
+ if strsub(l,1,1) == "'" then
+  l = strsub(l,2)
+ elseif strsub(l,1,1) == '$' then
+  cond = 'sr'       -- generates in both suport and register fragments
+  l = strsub(l,2)
+ end
+ return _Verbatim {
+  line = l,
+  cond = cond or '',
+ }
+end
+
+
Index: /code/branches/physics/src/tolua/tolua++.h
===================================================================
--- /code/branches/physics/src/tolua/tolua++.h	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua++.h	(revision 2122)
@@ -0,0 +1,182 @@
+/* tolua
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+
+#ifndef TOLUA_H
+#define TOLUA_H
+
+/* original code */
+/*
+#ifndef TOLUA_API
+#define TOLUA_API extern
+#endif
+*/
+
+/********************************
+******* ORXONOX CHANGES *********
+********************************/
+
+#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined( TOLUA_STATIC_BUILD )
+#  ifdef TOLUA_SHARED_BUILD
+#    define TOLUA_API __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define TOLUA_API
+#    else
+#      define TOLUA_API __declspec(dllimport)
+#    endif
+#  endif
+#else
+#  define TOLUA_API extern
+#endif
+
+/********************************
+****** END ORXONOX CHANGES ******
+********************************/
+
+#define TOLUA_VERSION "tolua++-1.0.92"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define tolua_pushcppstring(x,y)	tolua_pushstring(x,y.c_str())
+#define tolua_iscppstring	tolua_isstring
+
+#define tolua_iscppstringarray tolua_isstringarray
+#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str())
+
+#define TEMPLATE_BIND(p)
+#define TOLUA_TEMPLATE_BIND(p)
+#define TOLUA_PROTECTED_DESTRUCTOR
+#define TOLUA_PROPERTY_TYPE(p)
+
+typedef int lua_Object;
+
+#include "lua/lua.h"
+#include "lua/lauxlib.h"
+
+struct tolua_Error
+{
+	int index;
+	int array;
+	const char* type;
+};
+typedef struct tolua_Error tolua_Error;
+
+#define TOLUA_NOPEER	LUA_REGISTRYINDEX /* for lua 5.1 */
+
+TOLUA_API const char* tolua_typename (lua_State* L, int lo);
+TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err);
+TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err);
+TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isvaluearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isbooleanarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumberarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isstringarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_istablearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdataarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertypearray
+ (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err);
+
+TOLUA_API void tolua_open (lua_State* L);
+
+TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size);
+TOLUA_API int tolua_register_gc (lua_State* L, int lo);
+TOLUA_API int tolua_default_collect (lua_State* tolua_S);
+
+TOLUA_API void tolua_usertype (lua_State* L, char* type);
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name);
+TOLUA_API void tolua_endmodule (lua_State* L);
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar);
+TOLUA_API void tolua_class (lua_State* L, char* name, char* base);
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col);
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func);
+TOLUA_API void tolua_constant (lua_State* L, char* name, double value);
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set);
+TOLUA_API void tolua_array (lua_State* L,char* name, lua_CFunction get, lua_CFunction set);
+
+/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */
+/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
+
+TOLUA_API void tolua_pushvalue (lua_State* L, int lo);
+TOLUA_API void tolua_pushboolean (lua_State* L, int value);
+TOLUA_API void tolua_pushnumber (lua_State* L, double value);
+TOLUA_API void tolua_pushstring (lua_State* L, const char* value);
+TOLUA_API void tolua_pushuserdata (lua_State* L, void* value);
+TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v);
+TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v);
+TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
+TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
+TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
+
+TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def);
+TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
+TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def);
+TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def);
+TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def);
+TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def);
+TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def);
+TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def);
+TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def);
+TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def);
+TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def);
+TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def);
+
+TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name);
+
+TOLUA_API int class_gc_event (lua_State* L);
+
+#ifdef __cplusplus
+static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) {
+
+	const char* s = tolua_tostring(L, narg, def);
+	return s?s:"";
+};
+
+static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) {
+
+	const char* s = tolua_tofieldstring(L, lo, index, def);
+	return s?s:"";
+};
+
+#else
+#define tolua_tocppstring tolua_tostring
+#define tolua_tofieldcppstring tolua_tofieldstring
+#endif
+
+TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /code/branches/physics/src/tolua/tolua-5.1.pkg
===================================================================
--- /code/branches/physics/src/tolua/tolua-5.1.pkg	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua-5.1.pkg	(revision 2122)
@@ -0,0 +1,30 @@
+$lfile "../../src/tolua/lua/compat-5.1.lua"
+$lfile "../../src/tolua/lua/compat.lua"
+$lfile "../../src/tolua/lua/basic.lua"
+$lfile "../../src/tolua/lua/feature.lua"
+$lfile "../../src/tolua/lua/verbatim.lua"
+$lfile "../../src/tolua/lua/code.lua"
+$lfile "../../src/tolua/lua/typedef.lua"
+$lfile "../../src/tolua/lua/container.lua"
+$lfile "../../src/tolua/lua/package.lua"
+$lfile "../../src/tolua/lua/module.lua"
+$lfile "../../src/tolua/lua/namespace.lua"
+$lfile "../../src/tolua/lua/define.lua"
+$lfile "../../src/tolua/lua/enumerate.lua"
+$lfile "../../src/tolua/lua/declaration.lua"
+$lfile "../../src/tolua/lua/variable.lua"
+$lfile "../../src/tolua/lua/array.lua"
+$lfile "../../src/tolua/lua/function.lua"
+$lfile "../../src/tolua/lua/operator.lua"
+$lfile "../../src/tolua/lua/class.lua"
+$lfile "../../src/tolua/lua/clean.lua"
+$lfile "../../src/tolua/lua/doit.lua"
+
+$[
+local err,msg = pcall(doit)
+if not err then
+ local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)")
+ tolua_error(msg,label)
+ print(debug.traceback())
+end
+$]
Index: /code/branches/physics/src/tolua/tolua.c
===================================================================
--- /code/branches/physics/src/tolua/tolua.c	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua.c	(revision 2122)
@@ -0,0 +1,167 @@
+/* tolua
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Aug 2003
+** $Id:$
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#include "tolua++.h"
+
+#include "lua/lua.h"
+#include "lua/lualib.h"
+#include "lua/lauxlib.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static void help (void)
+{
+ fprintf(stderr,"\n"
+         "usage: tolua++ [options] input_file\n"
+         "\n"
+         "Command line options are:\n"
+         "  -v       : print version information.\n"
+         "  -o  file : set output file; default is stdout.\n"
+         "  -H  file : create include file.\n"
+         "  -n  name : set package name; default is input file root name.\n"
+         "  -p       : parse only.\n"
+         "  -P       : parse and print structure information (for debug).\n"
+         "  -S       : disable support for c++ strings.\n"
+         "  -1       : substract 1 to operator[] index (for compatibility with tolua5).\n"
+         "  -L  file : run lua file (with dofile()) before doing anything.\n"
+         "  -D       : disable automatic exporting of destructors for classes that have\n"
+         "             constructors (for compatibility with tolua5)\n"
+         "  -W       : disable warnings for unsupported features (for compatibility\n"
+         "             with tolua5)\n"
+         "  -C       : disable cleanup of included lua code (for easier debugging)\n"
+         "  -E  value[=value] : add extra values to the luastate\n"
+         "  -t       : export a list of types asociates with the C++ typeid name\n"
+         "  -h       : print this message.\n"
+         "Should the input file be omitted, stdin is assumed;\n"
+         "in that case, the package name must be explicitly set.\n\n"
+        );
+}
+
+static void version (void)
+{
+ fprintf(stderr, "%s (written by W. Celes, A. Manzur)\n",TOLUA_VERSION);
+}
+
+static void setfield (lua_State* L, int table, char* f, char* v)
+{
+ lua_pushstring(L,f);
+ lua_pushstring(L,v);
+ lua_settable(L,table);
+}
+
+static void add_extra (lua_State* L, char* value) {
+	int len;
+	lua_getglobal(L, "_extra_parameters");
+	len = luaL_getn(L, -1);
+	lua_pushstring(L, value);
+	lua_rawseti(L, -2, len+1);
+	lua_pop(L, 1);
+};
+
+static void error (char* o)
+{
+ fprintf(stderr,"tolua: unknown option '%s'\n",o);
+ help();
+ exit(1);
+}
+
+int main (int argc, char* argv[])
+{
+ #ifdef LUA_VERSION_NUM /* lua 5.1 */
+ lua_State* L = luaL_newstate();
+ luaL_openlibs(L);
+ #else
+ lua_State* L = lua_open();
+ luaopen_base(L);
+ luaopen_io(L);
+ luaopen_string(L);
+ luaopen_table(L);
+ luaopen_math(L);
+ luaopen_debug(L);
+ #endif
+
+ lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION");
+ lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION");
+
+ if (argc==1)
+ {
+  help();
+  return 0;
+ }
+ else
+ {
+  int i, t;
+  lua_newtable(L);
+  lua_setglobal(L, "_extra_parameters");
+  lua_newtable(L);
+  lua_pushvalue(L,-1);
+  lua_setglobal(L,"flags");
+  t = lua_gettop(L);
+  for (i=1; i<argc; ++i)
+  {
+   if (*argv[i] == '-')
+   {
+    switch (argv[i][1])
+    {
+     case 'v': version(); return 0;
+     case 'h': help(); return 0;
+     case 'p': setfield(L,t,"p",""); break;
+     case 'P': setfield(L,t,"P",""); break;
+     case 'o': setfield(L,t,"o",argv[++i]); break;
+     case 'n': setfield(L,t,"n",argv[++i]); break;
+     case 'H': setfield(L,t,"H",argv[++i]); break;
+     case 'S': setfield(L,t,"S",""); break;
+     case '1': setfield(L,t,"1",""); break;
+     case 'L': setfield(L,t,"L",argv[++i]); break;
+     case 'D': setfield(L,t,"D",""); break;
+     case 'W': setfield(L,t,"W",""); break;
+     case 'C': setfield(L,t,"C",""); break;
+     case 'E': add_extra(L,argv[++i]); break;
+     case 't': setfield(L,t,"t",""); break;
+     default: error(argv[i]); break;
+    }
+   }
+   else
+   {
+    setfield(L,t,"f",argv[i]);
+    break;
+   }
+  }
+  lua_pop(L,1);
+ }
+/* #define TOLUA_SCRIPT_RUN */
+#ifndef TOLUA_SCRIPT_RUN
+ {
+  int tolua_tolua_open (lua_State* L);
+  tolua_tolua_open(L);
+ }
+#else
+ {
+  char* p;
+  char  path[BUFSIZ];
+  strcpy(path,argv[0]);
+  p = strrchr(path,'/');
+  if (p==NULL) p = strrchr(path,'\\');
+  p = (p==NULL) ? path : p+1;
+  sprintf(p,"%s","../src/bin/lua/");
+  lua_pushstring(L,path); lua_setglobal(L,"path");
+		strcat(path,"all.lua");
+  lua_dofile(L,path);
+ }
+#endif
+ return 0;
+}
Index: /code/branches/physics/src/tolua/tolua_event.c
===================================================================
--- /code/branches/physics/src/tolua/tolua_event.c	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua_event.c	(revision 2122)
@@ -0,0 +1,513 @@
+/* tolua: event functions
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#include <stdio.h>
+
+#include "tolua++.h"
+
+/* Store at ubox
+	* It stores, creating the corresponding table if needed,
+	* the pair key/value in the corresponding ubox table
+*/
+static void storeatubox (lua_State* L, int lo)
+{
+	#ifdef LUA_VERSION_NUM
+		lua_getfenv(L, lo);
+		if (lua_rawequal(L, -1, TOLUA_NOPEER)) {
+			lua_pop(L, 1);
+			lua_newtable(L);
+			lua_pushvalue(L, -1);
+			lua_setfenv(L, lo);	/* stack: k,v,table  */
+		};
+		lua_insert(L, -3);
+		lua_settable(L, -3); /* on lua 5.1, we trade the "tolua_peers" lookup for a settable call */
+		lua_pop(L, 1);
+	#else
+	 /* stack: key value (to be stored) */
+		lua_pushstring(L,"tolua_peers");
+		lua_rawget(L,LUA_REGISTRYINDEX);        /* stack: k v ubox */
+		lua_pushvalue(L,lo);
+		lua_rawget(L,-2);                       /* stack: k v ubox ubox[u] */
+		if (!lua_istable(L,-1))
+		{
+			lua_pop(L,1);                          /* stack: k v ubox */
+			lua_newtable(L);                       /* stack: k v ubox table */
+			lua_pushvalue(L,1);
+			lua_pushvalue(L,-2);                   /* stack: k v ubox table u table */
+			lua_rawset(L,-4);                      /* stack: k v ubox ubox[u]=table */
+		}
+		lua_insert(L,-4);                       /* put table before k */
+		lua_pop(L,1);                           /* pop ubox */
+		lua_rawset(L,-3);                       /* store at table */
+		lua_pop(L,1);                           /* pop ubox[u] */
+	#endif
+}
+
+/* Module index function
+*/
+static int module_index_event (lua_State* L)
+{
+	lua_pushstring(L,".get");
+	lua_rawget(L,-3);
+	if (lua_istable(L,-1))
+	{
+		lua_pushvalue(L,2);  /* key */
+		lua_rawget(L,-2);
+		if (lua_iscfunction(L,-1))
+		{
+			lua_call(L,0,1);
+			return 1;
+		}
+		else if (lua_istable(L,-1))
+			return 1;
+	}
+	/* call old index meta event */
+	if (lua_getmetatable(L,1))
+	{
+		lua_pushstring(L,"__index");
+		lua_rawget(L,-2);
+		lua_pushvalue(L,1);
+		lua_pushvalue(L,2);
+		if (lua_isfunction(L,-1))
+		{
+			lua_call(L,2,1);
+			return 1;
+		}
+		else if (lua_istable(L,-1))
+		{
+			lua_gettable(L,-3);
+			return 1;
+		}
+	}
+	lua_pushnil(L);
+	return 1;
+}
+
+/* Module newindex function
+*/
+static int module_newindex_event (lua_State* L)
+{
+	lua_pushstring(L,".set");
+	lua_rawget(L,-4);
+	if (lua_istable(L,-1))
+	{
+		lua_pushvalue(L,2);  /* key */
+		lua_rawget(L,-2);
+		if (lua_iscfunction(L,-1))
+		{
+			lua_pushvalue(L,1); /* only to be compatible with non-static vars */
+			lua_pushvalue(L,3); /* value */
+			lua_call(L,2,0);
+			return 0;
+		}
+	}
+	/* call old newindex meta event */
+	if (lua_getmetatable(L,1) && lua_getmetatable(L,-1))
+	{
+		lua_pushstring(L,"__newindex");
+		lua_rawget(L,-2);
+		if (lua_isfunction(L,-1))
+		{
+		 lua_pushvalue(L,1);
+		 lua_pushvalue(L,2);
+		 lua_pushvalue(L,3);
+			lua_call(L,3,0);
+		}
+	}
+	lua_settop(L,3);
+	lua_rawset(L,-3);
+	return 0;
+}
+
+/* Class index function
+	* If the object is a userdata (ie, an object), it searches the field in
+	* the alternative table stored in the corresponding "ubox" table.
+*/
+static int class_index_event (lua_State* L)
+{
+ int t = lua_type(L,1);
+	if (t == LUA_TUSERDATA)
+	{
+		/* Access alternative table */
+		#ifdef LUA_VERSION_NUM /* new macro on version 5.1 */
+		lua_getfenv(L,1);
+		if (!lua_rawequal(L, -1, TOLUA_NOPEER)) {
+			lua_pushvalue(L, 2); /* key */
+			lua_gettable(L, -2); /* on lua 5.1, we trade the "tolua_peers" lookup for a gettable call */
+			if (!lua_isnil(L, -1))
+				return 1;
+		};
+		#else
+		lua_pushstring(L,"tolua_peers");
+		lua_rawget(L,LUA_REGISTRYINDEX);        /* stack: obj key ubox */
+		lua_pushvalue(L,1);
+		lua_rawget(L,-2);                       /* stack: obj key ubox ubox[u] */
+		if (lua_istable(L,-1))
+		{
+			lua_pushvalue(L,2);  /* key */
+			lua_rawget(L,-2);                      /* stack: obj key ubox ubox[u] value */
+			if (!lua_isnil(L,-1))
+				return 1;
+		}
+		#endif
+		lua_settop(L,2);                        /* stack: obj key */
+		/* Try metatables */
+		lua_pushvalue(L,1);                     /* stack: obj key obj */
+		while (lua_getmetatable(L,-1))
+		{                                       /* stack: obj key obj mt */
+			lua_remove(L,-2);                      /* stack: obj key mt */
+			if (lua_isnumber(L,2))                 /* check if key is a numeric value */
+			{
+				/* try operator[] */
+				lua_pushstring(L,".geti");
+				lua_rawget(L,-2);                      /* stack: obj key mt func */
+				if (lua_isfunction(L,-1))
+				{
+					lua_pushvalue(L,1);
+					lua_pushvalue(L,2);
+					lua_call(L,2,1);
+					return 1;
+				}
+			}
+			else
+			{
+			 lua_pushvalue(L,2);                    /* stack: obj key mt key */
+				lua_rawget(L,-2);                      /* stack: obj key mt value */
+				if (!lua_isnil(L,-1))
+					return 1;
+				else
+					lua_pop(L,1);
+				/* try C/C++ variable */
+				lua_pushstring(L,".get");
+				lua_rawget(L,-2);                      /* stack: obj key mt tget */
+				if (lua_istable(L,-1))
+				{
+					lua_pushvalue(L,2);
+					lua_rawget(L,-2);                      /* stack: obj key mt value */
+					if (lua_iscfunction(L,-1))
+					{
+						lua_pushvalue(L,1);
+						lua_pushvalue(L,2);
+						lua_call(L,2,1);
+						return 1;
+					}
+					else if (lua_istable(L,-1))
+					{
+						/* deal with array: create table to be returned and cache it in ubox */
+						void* u = *((void**)lua_touserdata(L,1));
+						lua_newtable(L);                /* stack: obj key mt value table */
+						lua_pushstring(L,".self");
+						lua_pushlightuserdata(L,u);
+						lua_rawset(L,-3);               /* store usertype in ".self" */
+						lua_insert(L,-2);               /* stack: obj key mt table value */
+						lua_setmetatable(L,-2);         /* set stored value as metatable */
+						lua_pushvalue(L,-1);            /* stack: obj key met table table */
+						lua_pushvalue(L,2);             /* stack: obj key mt table table key */
+						lua_insert(L,-2);               /*  stack: obj key mt table key table */
+						storeatubox(L,1);               /* stack: obj key mt table */
+						return 1;
+					}
+				}
+			}
+			lua_settop(L,3);
+		}
+		lua_pushnil(L);
+		return 1;
+	}
+	else if (t== LUA_TTABLE)
+	{
+		module_index_event(L);
+		return 1;
+	}
+	lua_pushnil(L);
+	return 1;
+}
+
+/* Newindex function
+	* It first searches for a C/C++ varaible to be set.
+	* Then, it either stores it in the alternative ubox table (in the case it is
+	* an object) or in the own table (that represents the class or module).
+*/
+static int class_newindex_event (lua_State* L)
+{
+ int t = lua_type(L,1);
+	if (t == LUA_TUSERDATA)
+	{
+	 /* Try accessing a C/C++ variable to be set */
+		lua_getmetatable(L,1);
+		while (lua_istable(L,-1))                /* stack: t k v mt */
+		{
+			if (lua_isnumber(L,2))                 /* check if key is a numeric value */
+			{
+				/* try operator[] */
+				lua_pushstring(L,".seti");
+				lua_rawget(L,-2);                      /* stack: obj key mt func */
+				if (lua_isfunction(L,-1))
+				{
+					lua_pushvalue(L,1);
+					lua_pushvalue(L,2);
+					lua_pushvalue(L,3);
+					lua_call(L,3,0);
+					return 0;
+				}
+			}
+			else
+			{
+				lua_pushstring(L,".set");
+				lua_rawget(L,-2);                      /* stack: t k v mt tset */
+				if (lua_istable(L,-1))
+				{
+					lua_pushvalue(L,2);
+					lua_rawget(L,-2);                     /* stack: t k v mt tset func */
+					if (lua_iscfunction(L,-1))
+					{
+						lua_pushvalue(L,1);
+						lua_pushvalue(L,3);
+						lua_call(L,2,0);
+						return 0;
+					}
+					lua_pop(L,1);                          /* stack: t k v mt tset */
+				}
+				lua_pop(L,1);                           /* stack: t k v mt */
+				if (!lua_getmetatable(L,-1))            /* stack: t k v mt mt */
+					lua_pushnil(L);
+				lua_remove(L,-2);                       /* stack: t k v mt */
+			}
+		}
+	 lua_settop(L,3);                          /* stack: t k v */
+
+		/* then, store as a new field */
+		storeatubox(L,1);
+	}
+	else if (t== LUA_TTABLE)
+	{
+		module_newindex_event(L);
+	}
+	return 0;
+}
+
+static int class_call_event(lua_State* L) {
+
+	if (lua_istable(L, 1)) {
+		lua_pushstring(L, ".call");
+		lua_rawget(L, 1);
+		if (lua_isfunction(L, -1)) {
+
+			lua_insert(L, 1);
+			lua_call(L, lua_gettop(L)-1, 1);
+
+			return 1;
+		};
+	};
+	tolua_error(L,"Attempt to call a non-callable object.",NULL);
+	return 0;
+};
+
+static int do_operator (lua_State* L, const char* op)
+{
+	if (lua_isuserdata(L,1))
+	{
+		/* Try metatables */
+		lua_pushvalue(L,1);                     /* stack: op1 op2 */
+		while (lua_getmetatable(L,-1))
+		{                                       /* stack: op1 op2 op1 mt */
+			lua_remove(L,-2);                      /* stack: op1 op2 mt */
+			lua_pushstring(L,op);                  /* stack: op1 op2 mt key */
+			lua_rawget(L,-2);                      /* stack: obj key mt func */
+			if (lua_isfunction(L,-1))
+			{
+				lua_pushvalue(L,1);
+				lua_pushvalue(L,2);
+				lua_call(L,2,1);
+				return 1;
+			}
+			lua_settop(L,3);
+		}
+	}
+	tolua_error(L,"Attempt to perform operation on an invalid operand",NULL);
+	return 0;
+}
+
+static int class_add_event (lua_State* L)
+{
+	return do_operator(L,".add");
+}
+
+static int class_sub_event (lua_State* L)
+{
+	return do_operator(L,".sub");
+}
+
+static int class_mul_event (lua_State* L)
+{
+	return do_operator(L,".mul");
+}
+
+static int class_div_event (lua_State* L)
+{
+	return do_operator(L,".div");
+}
+
+static int class_lt_event (lua_State* L)
+{
+	return do_operator(L,".lt");
+}
+
+static int class_le_event (lua_State* L)
+{
+	return do_operator(L,".le");
+}
+
+static int class_eq_event (lua_State* L)
+{
+	return do_operator(L,".eq");
+}
+
+/*
+static int class_gc_event (lua_State* L)
+{
+	void* u = *((void**)lua_touserdata(L,1));
+	fprintf(stderr, "collecting: looking at %p\n", u);
+	lua_pushstring(L,"tolua_gc");
+	lua_rawget(L,LUA_REGISTRYINDEX);
+	lua_pushlightuserdata(L,u);
+	lua_rawget(L,-2);
+	if (lua_isfunction(L,-1))
+	{
+		lua_pushvalue(L,1);
+		lua_call(L,1,0);
+ 		lua_pushlightuserdata(L,u);
+		lua_pushnil(L);
+		lua_rawset(L,-3);
+	}
+	lua_pop(L,2);
+	return 0;
+}
+*/
+TOLUA_API int class_gc_event (lua_State* L)
+{
+	void* u = *((void**)lua_touserdata(L,1));
+	int top;
+	/*fprintf(stderr, "collecting: looking at %p\n", u);*/
+	/*
+	lua_pushstring(L,"tolua_gc");
+	lua_rawget(L,LUA_REGISTRYINDEX);
+	*/
+	lua_pushvalue(L, lua_upvalueindex(1));
+	lua_pushlightuserdata(L,u);
+	lua_rawget(L,-2);            /* stack: gc umt    */
+	lua_getmetatable(L,1);       /* stack: gc umt mt */
+	/*fprintf(stderr, "checking type\n");*/
+	top = lua_gettop(L);
+	if (tolua_fast_isa(L,top,top-1, lua_upvalueindex(2))) /* make sure we collect correct type */
+	{
+		/*fprintf(stderr, "Found type!\n");*/
+		/* get gc function */
+		lua_pushliteral(L,".collector");
+		lua_rawget(L,-2);           /* stack: gc umt mt collector */
+		if (lua_isfunction(L,-1)) {
+			/*fprintf(stderr, "Found .collector!\n");*/
+		}
+		else {
+			lua_pop(L,1);
+			/*fprintf(stderr, "Using default cleanup\n");*/
+			lua_pushcfunction(L,tolua_default_collect);
+		}
+
+		lua_pushvalue(L,1);         /* stack: gc umt mt collector u */
+		lua_call(L,1,0);
+
+		lua_pushlightuserdata(L,u); /* stack: gc umt mt u */
+		lua_pushnil(L);             /* stack: gc umt mt u nil */
+		lua_rawset(L,-5);           /* stack: gc umt mt */
+	}
+	lua_pop(L,3);
+	return 0;
+}
+
+
+/* Register module events
+	* It expects the metatable on the top of the stack
+*/
+TOLUA_API void tolua_moduleevents (lua_State* L)
+{
+	lua_pushstring(L,"__index");
+	lua_pushcfunction(L,module_index_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__newindex");
+	lua_pushcfunction(L,module_newindex_event);
+	lua_rawset(L,-3);
+}
+
+/* Check if the object on the top has a module metatable
+*/
+TOLUA_API int tolua_ismodulemetatable (lua_State* L)
+{
+	int r = 0;
+	if (lua_getmetatable(L,-1))
+	{
+		lua_pushstring(L,"__index");
+		lua_rawget(L,-2);
+		r = (lua_tocfunction(L,-1) == module_index_event);
+		lua_pop(L,2);
+	}
+	return r;
+}
+
+/* Register class events
+	* It expects the metatable on the top of the stack
+*/
+TOLUA_API void tolua_classevents (lua_State* L)
+{
+	lua_pushstring(L,"__index");
+	lua_pushcfunction(L,class_index_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__newindex");
+	lua_pushcfunction(L,class_newindex_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__add");
+	lua_pushcfunction(L,class_add_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__sub");
+	lua_pushcfunction(L,class_sub_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__mul");
+	lua_pushcfunction(L,class_mul_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__div");
+	lua_pushcfunction(L,class_div_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__lt");
+	lua_pushcfunction(L,class_lt_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__le");
+	lua_pushcfunction(L,class_le_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__eq");
+	lua_pushcfunction(L,class_eq_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__call");
+	lua_pushcfunction(L,class_call_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__gc");
+	lua_pushstring(L, "tolua_gc_event");
+	lua_rawget(L, LUA_REGISTRYINDEX);
+	/*lua_pushcfunction(L,class_gc_event);*/
+	lua_rawset(L,-3);
+}
+
Index: /code/branches/physics/src/tolua/tolua_event.h
===================================================================
--- /code/branches/physics/src/tolua/tolua_event.h	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua_event.h	(revision 2122)
@@ -0,0 +1,24 @@
+/* tolua: event functions
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#ifndef TOLUA_EVENT_H
+#define TOLUA_EVENT_H
+
+#include "tolua++.h"
+
+TOLUA_API void tolua_moduleevents (lua_State* L);
+TOLUA_API int tolua_ismodulemetatable (lua_State* L);
+TOLUA_API void tolua_classevents (lua_State* L);
+
+#endif
Index: /code/branches/physics/src/tolua/tolua_is.c
===================================================================
--- /code/branches/physics/src/tolua/tolua_is.c	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua_is.c	(revision 2122)
@@ -0,0 +1,607 @@
+/* tolua: functions to check types.
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#include "tolua++.h"
+#include "lua/lauxlib.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* a fast check if a is b, without parameter validation
+ i.e. if b is equal to a or a superclass of a. */
+TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index)
+{
+ int result;
+	if (lua_rawequal(L,mt_indexa,mt_indexb))
+		result = 1;
+	else
+	{
+		if (super_index) {
+			lua_pushvalue(L, super_index);
+		} else {
+			lua_pushliteral(L,"tolua_super");
+			lua_rawget(L,LUA_REGISTRYINDEX);  /* stack: super */
+		};
+		lua_pushvalue(L,mt_indexa);       /* stack: super mta */
+		lua_rawget(L,-2);                 /* stack: super super[mta] */
+		lua_pushvalue(L,mt_indexb);       /* stack: super super[mta] mtb */
+		lua_rawget(L,LUA_REGISTRYINDEX);  /* stack: super super[mta] typenameB */
+		lua_rawget(L,-2);                 /* stack: super super[mta] bool */
+		result = lua_toboolean(L,-1);
+		lua_pop(L,3);
+	}
+	return result;
+}
+
+/* Push and returns the corresponding object typename */
+TOLUA_API const char* tolua_typename (lua_State* L, int lo)
+{
+	int tag = lua_type(L,lo);
+ if (tag == LUA_TNONE)
+  lua_pushstring(L,"[no object]");
+ else if (tag != LUA_TUSERDATA && tag != LUA_TTABLE)
+  lua_pushstring(L,lua_typename(L,tag));
+ else if (tag == LUA_TUSERDATA)
+ {
+  if (!lua_getmetatable(L,lo))
+   lua_pushstring(L,lua_typename(L,tag));
+		else
+		{
+		 lua_rawget(L,LUA_REGISTRYINDEX);
+		 if (!lua_isstring(L,-1))
+			{
+		  lua_pop(L,1);
+				lua_pushstring(L,"[undefined]");
+			}
+		}
+	}
+	else  /* is table */
+	{
+		lua_pushvalue(L,lo);
+		lua_rawget(L,LUA_REGISTRYINDEX);
+		if (!lua_isstring(L,-1))
+		{
+			lua_pop(L,1);
+			lua_pushstring(L,"table");
+		}
+		else
+		{
+   lua_pushstring(L,"class ");
+			lua_insert(L,-2);
+			lua_concat(L,2);
+		}
+	}
+	return lua_tostring(L,-1);
+}
+
+TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err)
+{
+	if (msg[0] == '#')
+	{
+  const char* expected = err->type;
+		const char* provided = tolua_typename(L,err->index);
+  if (msg[1]=='f')
+  {
+   int narg = err->index;
+			if (err->array)
+    luaL_error(L,"%s\n     argument #%d is array of '%s'; array of '%s' expected.\n",
+               msg+2,narg,provided,expected);
+			else
+    luaL_error(L,"%s\n     argument #%d is '%s'; '%s' expected.\n",
+               msg+2,narg,provided,expected);
+  }
+  else if (msg[1]=='v')
+		{
+			if (err->array)
+    luaL_error(L,"%s\n     value is array of '%s'; array of '%s' expected.\n",
+               msg+2,provided,expected);
+			else
+    luaL_error(L,"%s\n     value is '%s'; '%s' expected.\n",
+               msg+2,provided,expected);
+		}
+ }
+ else
+  luaL_error(L,msg);
+}
+
+/* the equivalent of lua_is* for usertable */
+static  int lua_isusertable (lua_State* L, int lo, const char* type)
+{
+	int r = 0;
+	if (lo < 0) lo = lua_gettop(L)+lo+1;
+	lua_pushvalue(L,lo);
+	lua_rawget(L,LUA_REGISTRYINDEX);  /* get registry[t] */
+	if (lua_isstring(L,-1))
+	{
+		r = strcmp(lua_tostring(L,-1),type)==0;
+		if (!r)
+		{
+			/* try const */
+			lua_pushstring(L,"const ");
+			lua_insert(L,-2);
+			lua_concat(L,2);
+			r = lua_isstring(L,-1) && strcmp(lua_tostring(L,-1),type)==0;
+		}
+	}
+	lua_pop(L, 1);
+	return r;
+}
+
+int push_table_instance(lua_State* L, int lo) {
+
+	if (lua_istable(L, lo)) {
+
+		lua_pushstring(L, ".c_instance");
+		lua_gettable(L, lo);
+		if (lua_isuserdata(L, -1)) {
+
+			lua_replace(L, lo);
+			return 1;
+		} else {
+
+			lua_pop(L, 1);
+			return 0;
+		};
+	} else {
+		return 0;
+	};
+
+	return 0;
+};
+
+/* the equivalent of lua_is* for usertype */
+static int lua_isusertype (lua_State* L, int lo, const char* type)
+{
+	if (!lua_isuserdata(L,lo)) {
+		if (!push_table_instance(L, lo)) {
+			return 0;
+		};
+	};
+	{
+		/* check if it is of the same type */
+		int r;
+		const char *tn;
+		if (lua_getmetatable(L,lo))        /* if metatable? */
+		{
+		 lua_rawget(L,LUA_REGISTRYINDEX);  /* get registry[mt] */
+		 tn = lua_tostring(L,-1);
+		 r = tn && (strcmp(tn,type) == 0);
+		 lua_pop(L, 1);
+			if (r)
+			 return 1;
+			else
+			{
+				/* check if it is a specialized class */
+				lua_pushstring(L,"tolua_super");
+				lua_rawget(L,LUA_REGISTRYINDEX); /* get super */
+				lua_getmetatable(L,lo);
+				lua_rawget(L,-2);                /* get super[mt] */
+				if (lua_istable(L,-1))
+				{
+					int b;
+					lua_pushstring(L,type);
+					lua_rawget(L,-2);                /* get super[mt][type] */
+					b = lua_toboolean(L,-1);
+					lua_pop(L,3);
+					if (b)
+					 return 1;
+				}
+			}
+		}
+ }
+	return 0;
+}
+
+TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err)
+{
+ if (lua_gettop(L)<abs(lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "[no object]";
+ return 0;
+}
+TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def || abs(lo)<=lua_gettop(L))  /* any valid index */
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "value";
+	return 0;
+}
+
+TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnil(L,lo) || lua_isboolean(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "boolean";
+	return 0;
+}
+
+TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnumber(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "number";
+	return 0;
+}
+
+TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+ if (lua_isnil(L,lo) || lua_isstring(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "string";
+	return 0;
+}
+
+TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_istable(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "table";
+	return 0;
+}
+
+TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isusertable(L,lo,type))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = type;
+	return 0;
+}
+
+
+TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnil(L,lo) || lua_isuserdata(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "userdata";
+	return 0;
+}
+
+TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnil(L,lo) || lua_isusertype(L,lo,type))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = type;
+	return 0;
+}
+
+TOLUA_API int tolua_isvaluearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+		return 1;
+}
+
+TOLUA_API int tolua_isbooleanarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) &&
+					  !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "boolean";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isnumberarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+			if (!lua_isnumber(L,-1) &&
+					  !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "number";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isstringarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+   if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "string";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_istablearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (! lua_istable(L,-1) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "table";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isuserdataarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "userdata";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isusertypearray
+ (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->type = type;
+				err->array = 1;
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+#if 0
+int tolua_isbooleanfield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) &&
+			  !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "boolean";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isnumberfield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!lua_isnumber(L,-1) &&
+			  !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "number";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isstringfield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+ if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "string";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_istablefield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i+1);
+	lua_gettable(L,lo);
+	if (! lua_istable(L,-1) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "table";
+		return 0;
+	}
+	lua_pop(L,1);
+}
+
+int tolua_isusertablefield
+ (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (! lua_isusertable(L,-1,type) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = type;
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isuserdatafield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "userdata";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isusertypefield
+ (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!(lua_isnil(L,-1) || lua_isusertype(L,-1,type)) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->type = type;
+		err->array = 1;
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+#endif
Index: /code/branches/physics/src/tolua/tolua_map.c
===================================================================
--- /code/branches/physics/src/tolua/tolua_map.c	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua_map.c	(revision 2122)
@@ -0,0 +1,704 @@
+/* tolua: functions to map features
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#include "tolua++.h"
+#include "tolua_event.h"
+#include "lua/lauxlib.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+/* Create metatable
+	* Create and register new metatable
+*/
+static int tolua_newmetatable (lua_State* L, char* name)
+{
+	int r = luaL_newmetatable(L,name);
+
+	#ifdef LUA_VERSION_NUM /* only lua 5.1 */
+	if (r) {
+		lua_pushvalue(L, -1);
+		lua_pushstring(L, name);
+		lua_settable(L, LUA_REGISTRYINDEX); /* reg[mt] = type_name */
+	};
+	#endif
+
+	if (r)
+		tolua_classevents(L); /* set meta events */
+	lua_pop(L,1);
+	return r;
+}
+
+/* Map super classes
+	* It sets 'name' as being also a 'base', mapping all super classes of 'base' in 'name'
+*/
+static void mapsuper (lua_State* L, const char* name, const char* base)
+{
+	/* push registry.super */
+ lua_pushstring(L,"tolua_super");
+ lua_rawget(L,LUA_REGISTRYINDEX);    /* stack: super */
+	luaL_getmetatable(L,name);          /* stack: super mt */
+ lua_rawget(L,-2);                   /* stack: super table */
+	if (lua_isnil(L,-1))
+	{
+	 /* create table */
+		lua_pop(L,1);
+	 lua_newtable(L);                    /* stack: super table */
+	 luaL_getmetatable(L,name);          /* stack: super table mt */
+		lua_pushvalue(L,-2);                /* stack: super table mt table */
+		lua_rawset(L,-4);                   /* stack: super table */
+	}
+
+	/* set base as super class */
+	lua_pushstring(L,base);
+	lua_pushboolean(L,1);
+	lua_rawset(L,-3);                    /* stack: super table */
+
+	/* set all super class of base as super class of name */
+	luaL_getmetatable(L,base);          /* stack: super table base_mt */
+	lua_rawget(L,-3);                   /* stack: super table base_table */
+	if (lua_istable(L,-1))
+	{
+		/* traverse base table */
+		lua_pushnil(L);  /* first key */
+		while (lua_next(L,-2) != 0)
+		{
+			/* stack: ... base_table key value */
+			lua_pushvalue(L,-2);    /* stack: ... base_table key value key */
+			lua_insert(L,-2);       /* stack: ... base_table key key value */
+			lua_rawset(L,-5);       /* stack: ... base_table key */
+		}
+	}
+	lua_pop(L,3);                       /* stack: <empty> */
+}
+
+/* creates a 'tolua_ubox' table for base clases, and
+// expects the metatable and base metatable on the stack */
+static void set_ubox(lua_State* L) {
+
+	/* mt basemt */
+	if (!lua_isnil(L, -1)) {
+		lua_pushstring(L, "tolua_ubox");
+		lua_rawget(L,-2);
+	} else {
+		lua_pushnil(L);
+	};
+	/* mt basemt base_ubox */
+	if (!lua_isnil(L,-1)) {
+		lua_pushstring(L, "tolua_ubox");
+		lua_insert(L, -2);
+		/* mt basemt key ubox */
+		lua_rawset(L,-4);
+		/* (mt with ubox) basemt */
+	} else {
+		/* mt basemt nil */
+		lua_pop(L, 1);
+		lua_pushstring(L,"tolua_ubox"); lua_newtable(L);
+		/* make weak value metatable for ubox table to allow userdata to be
+		garbage-collected */
+		lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3);               /* stack: string ubox mt */
+		lua_setmetatable(L, -2);  /* stack:mt basemt string ubox */
+		lua_rawset(L,-4);
+	};
+
+};
+
+/* Map inheritance
+	* It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name'
+*/
+static void mapinheritance (lua_State* L, const char* name, const char* base)
+{
+	/* set metatable inheritance */
+	luaL_getmetatable(L,name);
+
+	if (base && *base)
+		luaL_getmetatable(L,base);
+	else {
+
+		if (lua_getmetatable(L, -1)) { /* already has a mt, we don't overwrite it */
+			lua_pop(L, 2);
+			return;
+		};
+		luaL_getmetatable(L,"tolua_commonclass");
+	};
+
+	set_ubox(L);
+
+	lua_setmetatable(L,-2);
+	lua_pop(L,1);
+}
+
+/* Object type
+*/
+static int tolua_bnd_type (lua_State* L)
+{
+	tolua_typename(L,lua_gettop(L));
+	return 1;
+}
+
+/* Take ownership
+*/
+static int tolua_bnd_takeownership (lua_State* L)
+{
+	int success = 0;
+	if (lua_isuserdata(L,1))
+	{
+		if (lua_getmetatable(L,1))        /* if metatable? */
+		{
+			lua_pop(L,1);             /* clear metatable off stack */
+			/* force garbage collection to avoid C to reuse a to-be-collected address */
+			#ifdef LUA_VERSION_NUM
+			lua_gc(L, LUA_GCCOLLECT, 0);
+			#else
+			lua_setgcthreshold(L,0);
+			#endif
+
+			success = tolua_register_gc(L,1);
+		}
+	}
+	lua_pushboolean(L,success!=0);
+	return 1;
+}
+
+/* Release ownership
+*/
+static int tolua_bnd_releaseownership (lua_State* L)
+{
+	int done = 0;
+	if (lua_isuserdata(L,1))
+	{
+		void* u = *((void**)lua_touserdata(L,1));
+		/* force garbage collection to avoid releasing a to-be-collected address */
+		#ifdef LUA_VERSION_NUM
+		lua_gc(L, LUA_GCCOLLECT, 0);
+		#else
+		lua_setgcthreshold(L,0);
+		#endif
+		lua_pushstring(L,"tolua_gc");
+		lua_rawget(L,LUA_REGISTRYINDEX);
+		lua_pushlightuserdata(L,u);
+		lua_rawget(L,-2);
+		lua_getmetatable(L,1);
+		if (lua_rawequal(L,-1,-2))  /* check that we are releasing the correct type */
+		{
+			lua_pushlightuserdata(L,u);
+			lua_pushnil(L);
+			lua_rawset(L,-5);
+			done = 1;
+		}
+	}
+	lua_pushboolean(L,done!=0);
+	return 1;
+}
+
+/* Type casting
+*/
+static int tolua_bnd_cast (lua_State* L)
+{
+
+/* // old code
+        void* v = tolua_tousertype(L,1,NULL);
+        const char* s = tolua_tostring(L,2,NULL);
+        if (v && s)
+         tolua_pushusertype(L,v,s);
+        else
+         lua_pushnil(L);
+        return 1;
+*/
+
+	void* v;
+	const char* s;
+	if (lua_islightuserdata(L, 1)) {
+		v = tolua_touserdata(L, 1, NULL);
+	} else {
+		v = tolua_tousertype(L, 1, 0);
+	};
+
+	s = tolua_tostring(L,2,NULL);
+	if (v && s)
+	 tolua_pushusertype(L,v,s);
+	else
+	 lua_pushnil(L);
+	return 1;
+}
+
+/* Inheritance
+*/
+static int tolua_bnd_inherit (lua_State* L) {
+
+	/* stack: lua object, c object */
+	lua_pushstring(L, ".c_instance");
+	lua_pushvalue(L, -2);
+	lua_rawset(L, -4);
+	/* l_obj[".c_instance"] = c_obj */
+
+	return 0;
+};
+
+#ifdef LUA_VERSION_NUM /* lua 5.1 */
+static int tolua_bnd_setpeer(lua_State* L) {
+
+	/* stack: userdata, table */
+	if (!lua_isuserdata(L, -2)) {
+		lua_pushstring(L, "Invalid argument #1 to setpeer: userdata expected.");
+		lua_error(L);
+	};
+	
+	if (lua_isnil(L, -1)) {
+
+		lua_pop(L, 1);
+		lua_pushvalue(L, TOLUA_NOPEER);
+	};
+	lua_setfenv(L, -2);
+
+	return 0;
+};
+
+static int tolua_bnd_getpeer(lua_State* L) {
+
+	/* stack: userdata */
+	lua_getfenv(L, -1);
+	if (lua_rawequal(L, -1, TOLUA_NOPEER)) {
+		lua_pop(L, 1);
+		lua_pushnil(L);
+	};
+	return 1;
+};
+#endif
+
+/* static int class_gc_event (lua_State* L); */
+
+TOLUA_API void tolua_open (lua_State* L)
+{
+ int top = lua_gettop(L);
+ lua_pushstring(L,"tolua_opened");
+ lua_rawget(L,LUA_REGISTRYINDEX);
+ if (!lua_isboolean(L,-1))
+ {
+  lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX);
+
+  #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */
+  /* create peer object table */
+  lua_pushstring(L, "tolua_peers"); lua_newtable(L);
+  /* make weak key metatable for peers indexed by userdata object */
+  lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3);                /* stack: string peers mt */
+  lua_setmetatable(L, -2);   /* stack: string peers */
+  lua_rawset(L,LUA_REGISTRYINDEX);
+  #endif
+
+  /* create object ptr -> udata mapping table */
+  lua_pushstring(L,"tolua_ubox"); lua_newtable(L);
+  /* make weak value metatable for ubox table to allow userdata to be
+     garbage-collected */
+  lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3);               /* stack: string ubox mt */
+  lua_setmetatable(L, -2);  /* stack: string ubox */
+  lua_rawset(L,LUA_REGISTRYINDEX);
+
+  lua_pushstring(L,"tolua_super"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX);
+  lua_pushstring(L,"tolua_gc"); lua_newtable(L);lua_rawset(L,LUA_REGISTRYINDEX);
+
+  /* create gc_event closure */
+  lua_pushstring(L, "tolua_gc_event");
+  lua_pushstring(L, "tolua_gc");
+  lua_rawget(L, LUA_REGISTRYINDEX);
+  lua_pushstring(L, "tolua_super");
+  lua_rawget(L, LUA_REGISTRYINDEX);
+  lua_pushcclosure(L, class_gc_event, 2);
+  lua_rawset(L, LUA_REGISTRYINDEX);
+
+  tolua_newmetatable(L,"tolua_commonclass");
+
+  tolua_module(L,NULL,0);
+  tolua_beginmodule(L,NULL);
+  tolua_module(L,"tolua",0);
+  tolua_beginmodule(L,"tolua");
+  tolua_function(L,"type",tolua_bnd_type);
+  tolua_function(L,"takeownership",tolua_bnd_takeownership);
+  tolua_function(L,"releaseownership",tolua_bnd_releaseownership);
+  tolua_function(L,"cast",tolua_bnd_cast);
+  tolua_function(L,"inherit", tolua_bnd_inherit);
+  #ifdef LUA_VERSION_NUM /* lua 5.1 */
+  tolua_function(L, "setpeer", tolua_bnd_setpeer);
+  tolua_function(L, "getpeer", tolua_bnd_getpeer);
+  #endif
+
+  tolua_endmodule(L);
+  tolua_endmodule(L);
+ }
+ lua_settop(L,top);
+}
+
+/* Copy a C object
+*/
+TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size)
+{
+	void* clone = (void*)malloc(size);
+	if (clone)
+	 memcpy(clone,value,size);
+	else
+		tolua_error(L,"insuficient memory",NULL);
+	return clone;
+}
+
+/* Default collect function
+*/
+TOLUA_API int tolua_default_collect (lua_State* tolua_S)
+{
+ void* self = tolua_tousertype(tolua_S,1,0);
+ free(self);
+ return 0;
+}
+
+/* Do clone
+*/
+TOLUA_API int tolua_register_gc (lua_State* L, int lo)
+{
+ int success = 1;
+ void *value = *(void **)lua_touserdata(L,lo);
+ lua_pushstring(L,"tolua_gc");
+ lua_rawget(L,LUA_REGISTRYINDEX);
+	lua_pushlightuserdata(L,value);
+	lua_rawget(L,-2);
+	if (!lua_isnil(L,-1)) /* make sure that object is not already owned */
+		success = 0;
+	else
+	{
+		lua_pushlightuserdata(L,value);
+		lua_getmetatable(L,lo);
+		lua_rawset(L,-4);
+	}
+	lua_pop(L,2);
+	return success;
+}
+
+/* Register a usertype
+	* It creates the correspoding metatable in the registry, for both 'type' and 'const type'.
+	* It maps 'const type' as being also a 'type'
+*/
+TOLUA_API void tolua_usertype (lua_State* L, char* type)
+{
+ char ctype[128] = "const ";
+ strncat(ctype,type,120);
+
+	/* create both metatables */
+ if (tolua_newmetatable(L,ctype) && tolua_newmetatable(L,type))
+	 mapsuper(L,type,ctype);             /* 'type' is also a 'const type' */
+}
+
+
+/* Begin module
+	* It pushes the module (or class) table on the stack
+*/
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name)
+{
+	if (name)
+	{
+	 lua_pushstring(L,name);
+		lua_rawget(L,-2);
+	}
+	else
+	 lua_pushvalue(L,LUA_GLOBALSINDEX);
+}
+
+/* End module
+	* It pops the module (or class) from the stack
+*/
+TOLUA_API void tolua_endmodule (lua_State* L)
+{
+	lua_pop(L,1);
+}
+
+/* Map module
+	* It creates a new module
+*/
+#if 1
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
+{
+	if (name)
+	{
+		/* tolua module */
+		lua_pushstring(L,name);
+		lua_rawget(L,-2);
+		if (!lua_istable(L,-1))  /* check if module already exists */
+		{
+			lua_pop(L,1);
+		 lua_newtable(L);
+		 lua_pushstring(L,name);
+			lua_pushvalue(L,-2);
+		 lua_rawset(L,-4);       /* assing module into module */
+		}
+	}
+	else
+	{
+		/* global table */
+		lua_pushvalue(L,LUA_GLOBALSINDEX);
+	}
+	if (hasvar)
+	{
+		if (!tolua_ismodulemetatable(L))  /* check if it already has a module metatable */
+		{
+			/* create metatable to get/set C/C++ variable */
+			lua_newtable(L);
+			tolua_moduleevents(L);
+			if (lua_getmetatable(L,-2))
+				lua_setmetatable(L,-2);  /* set old metatable as metatable of metatable */
+			lua_setmetatable(L,-2);
+		}
+	}
+	lua_pop(L,1);               /* pop module */
+}
+#else
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
+{
+	if (name)
+	{
+		/* tolua module */
+		lua_pushstring(L,name);
+		lua_newtable(L);
+	}
+	else
+	{
+		/* global table */
+		lua_pushvalue(L,LUA_GLOBALSINDEX);
+	}
+	if (hasvar)
+	{
+		/* create metatable to get/set C/C++ variable */
+		lua_newtable(L);
+		tolua_moduleevents(L);
+		if (lua_getmetatable(L,-2))
+			lua_setmetatable(L,-2);  /* set old metatable as metatable of metatable */
+		lua_setmetatable(L,-2);
+	}
+	if (name)
+		lua_rawset(L,-3);       /* assing module into module */
+	else
+		lua_pop(L,1);           /* pop global table */
+}
+#endif
+
+static void push_collector(lua_State* L, const char* type, lua_CFunction col) {
+
+	/* push collector function, but only if it's not NULL, or if there's no
+	   collector already */
+	if (!col) return;
+	luaL_getmetatable(L,type);
+	lua_pushstring(L,".collector");
+	/*
+	if (!col) {
+		lua_pushvalue(L, -1);
+		lua_rawget(L, -3);
+		if (!lua_isnil(L, -1)) {
+			lua_pop(L, 3);
+			return;
+		};
+		lua_pop(L, 1);
+	};
+	//	*/
+	lua_pushcfunction(L,col);
+
+	lua_rawset(L,-3);
+	lua_pop(L, 1);
+};
+
+/* Map C class
+	* It maps a C class, setting the appropriate inheritance and super classes.
+*/
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col)
+{
+	char cname[128] = "const ";
+	char cbase[128] = "const ";
+	strncat(cname,name,120);
+	strncat(cbase,base,120);
+
+	mapinheritance(L,name,base);
+	mapinheritance(L,cname,name);
+
+	mapsuper(L,cname,cbase);
+	mapsuper(L,name,base);
+
+	lua_pushstring(L,lname);
+	
+	push_collector(L, name, col);
+	/*
+	luaL_getmetatable(L,name);
+	lua_pushstring(L,".collector");
+	lua_pushcfunction(L,col);
+
+	lua_rawset(L,-3);
+	*/
+	
+	luaL_getmetatable(L,name);
+	lua_rawset(L,-3);              /* assign class metatable to module */
+
+	/* now we also need to store the collector table for the const
+	   instances of the class */
+	push_collector(L, cname, col);
+	/*
+	luaL_getmetatable(L,cname);
+	lua_pushstring(L,".collector");
+	lua_pushcfunction(L,col);
+	lua_rawset(L,-3);
+	lua_pop(L,1);
+	*/
+	
+
+}
+
+/* Add base
+	* It adds additional base classes to a class (for multiple inheritance)
+	* (not for now)
+TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base) {
+
+	char cname[128] = "const ";
+	char cbase[128] = "const ";
+	strncat(cname,name,120);
+	strncat(cbase,base,120);
+
+	mapsuper(L,cname,cbase);
+	mapsuper(L,name,base);
+};
+*/
+
+/* Map function
+	* It assigns a function into the current module (or class)
+*/
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func)
+{
+ lua_pushstring(L,name);
+ lua_pushcfunction(L,func);
+	lua_rawset(L,-3);
+}
+
+/* sets the __call event for the class (expects the class' main table on top) */
+/*	never really worked :(
+TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type) {
+
+	lua_getmetatable(L, -1);
+	//luaL_getmetatable(L, type);
+	lua_pushstring(L,"__call");
+	lua_pushcfunction(L,func);
+	lua_rawset(L,-3);
+	lua_pop(L, 1);
+};
+*/
+
+/* Map constant number
+	* It assigns a constant number into the current module (or class)
+*/
+TOLUA_API void tolua_constant (lua_State* L, char* name, double value)
+{
+	lua_pushstring(L,name);
+	tolua_pushnumber(L,value);
+	lua_rawset(L,-3);
+}
+
+
+/* Map variable
+	* It assigns a variable into the current module (or class)
+*/
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
+{
+	/* get func */
+	lua_pushstring(L,".get");
+	lua_rawget(L,-2);
+	if (!lua_istable(L,-1))
+	{
+		/* create .get table, leaving it at the top */
+		lua_pop(L,1);
+		lua_newtable(L);
+	 lua_pushstring(L,".get");
+		lua_pushvalue(L,-2);
+		lua_rawset(L,-4);
+	}
+	lua_pushstring(L,name);
+	lua_pushcfunction(L,get);
+ lua_rawset(L,-3);                  /* store variable */
+	lua_pop(L,1);                      /* pop .get table */
+
+	/* set func */
+	if (set)
+	{
+		lua_pushstring(L,".set");
+		lua_rawget(L,-2);
+		if (!lua_istable(L,-1))
+		{
+			/* create .set table, leaving it at the top */
+			lua_pop(L,1);
+			lua_newtable(L);
+			lua_pushstring(L,".set");
+			lua_pushvalue(L,-2);
+			lua_rawset(L,-4);
+		}
+		lua_pushstring(L,name);
+		lua_pushcfunction(L,set);
+		lua_rawset(L,-3);                  /* store variable */
+		lua_pop(L,1);                      /* pop .set table */
+	}
+}
+
+/* Access const array
+	* It reports an error when trying to write into a const array
+*/
+static int const_array (lua_State* L)
+{
+ luaL_error(L,"value of const array cannot be changed");
+ return 0;
+}
+
+/* Map an array
+	* It assigns an array into the current module (or class)
+*/
+TOLUA_API void tolua_array (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
+{
+	lua_pushstring(L,".get");
+	lua_rawget(L,-2);
+	if (!lua_istable(L,-1))
+	{
+		/* create .get table, leaving it at the top */
+		lua_pop(L,1);
+		lua_newtable(L);
+	 lua_pushstring(L,".get");
+		lua_pushvalue(L,-2);
+		lua_rawset(L,-4);
+	}
+	lua_pushstring(L,name);
+
+ lua_newtable(L);           /* create array metatable */
+ lua_pushvalue(L,-1);
+	lua_setmetatable(L,-2);    /* set the own table as metatable (for modules) */
+ lua_pushstring(L,"__index");
+ lua_pushcfunction(L,get);
+	lua_rawset(L,-3);
+ lua_pushstring(L,"__newindex");
+ lua_pushcfunction(L,set?set:const_array);
+	lua_rawset(L,-3);
+
+ lua_rawset(L,-3);                  /* store variable */
+	lua_pop(L,1);                      /* pop .get table */
+}
+
+
+TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name) {
+
+ #ifdef LUA_VERSION_NUM /* lua 5.1 */
+ luaL_loadbuffer(L, B, size, name) || lua_pcall(L, 0, 0, 0);
+ #else
+ lua_dobuffer(L, B, size, name);
+ #endif
+};
+
Index: /code/branches/physics/src/tolua/tolua_push.c
===================================================================
--- /code/branches/physics/src/tolua/tolua_push.c	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua_push.c	(revision 2122)
@@ -0,0 +1,171 @@
+/* tolua: functions to push C values.
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#include "tolua++.h"
+#include "lua/lauxlib.h"
+
+#include <stdlib.h>
+
+TOLUA_API void tolua_pushvalue (lua_State* L, int lo)
+{
+ lua_pushvalue(L,lo);
+}
+
+TOLUA_API void tolua_pushboolean (lua_State* L, int value)
+{
+ lua_pushboolean(L,value);
+}
+
+TOLUA_API void tolua_pushnumber (lua_State* L, double value)
+{
+ lua_pushnumber(L,value);
+}
+
+TOLUA_API void tolua_pushstring (lua_State* L, const char* value)
+{
+ if (value == NULL)
+  lua_pushnil(L);
+ else
+  lua_pushstring(L,value);
+}
+
+TOLUA_API void tolua_pushuserdata (lua_State* L, void* value)
+{
+ if (value == NULL)
+  lua_pushnil(L);
+ else
+  lua_pushlightuserdata(L,value);
+}
+
+TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type)
+{
+ if (value == NULL)
+  lua_pushnil(L);
+ else
+ {
+  luaL_getmetatable(L, type);
+  lua_pushstring(L,"tolua_ubox");
+  lua_rawget(L,-2);        /* stack: mt ubox */
+  if (lua_isnil(L, -1)) {
+	  lua_pop(L, 1);
+	  lua_pushstring(L, "tolua_ubox");
+	  lua_rawget(L, LUA_REGISTRYINDEX);
+  };
+  lua_pushlightuserdata(L,value);
+  lua_rawget(L,-2);                       /* stack: mt ubox ubox[u] */
+  if (lua_isnil(L,-1))
+  {
+   lua_pop(L,1);                          /* stack: mt ubox */
+   lua_pushlightuserdata(L,value);
+   *(void**)lua_newuserdata(L,sizeof(void *)) = value;   /* stack: mt ubox u newud */
+   lua_pushvalue(L,-1);                   /* stack: mt ubox u newud newud */
+   lua_insert(L,-4);                      /* stack: mt newud ubox u newud */
+   lua_rawset(L,-3);                      /* stack: mt newud ubox */
+   lua_pop(L,1);                          /* stack: mt newud */
+   /*luaL_getmetatable(L,type);*/
+   lua_pushvalue(L, -2);			/* stack: mt newud mt */
+   lua_setmetatable(L,-2);			/* stack: mt newud */
+
+   #ifdef LUA_VERSION_NUM
+   lua_pushvalue(L, TOLUA_NOPEER);
+   lua_setfenv(L, -2);
+   #endif
+  }
+  else
+  {
+   /* check the need of updating the metatable to a more specialized class */
+   lua_insert(L,-2);                       /* stack: mt ubox[u] ubox */
+   lua_pop(L,1);                           /* stack: mt ubox[u] */
+   lua_pushstring(L,"tolua_super");
+   lua_rawget(L,LUA_REGISTRYINDEX);        /* stack: mt ubox[u] super */
+   lua_getmetatable(L,-2);                 /* stack: mt ubox[u] super mt */
+   lua_rawget(L,-2);                       /* stack: mt ubox[u] super super[mt] */
+			if (lua_istable(L,-1))
+			{
+				lua_pushstring(L,type);                 /* stack: mt ubox[u] super super[mt] type */
+				lua_rawget(L,-2);                       /* stack: mt ubox[u] super super[mt] flag */
+				if (lua_toboolean(L,-1) == 1)   /* if true */
+				{
+					lua_pop(L,3);	/* mt ubox[u]*/
+					lua_remove(L, -2);
+					return;
+				}
+			}
+			/* type represents a more specilized type */
+			/*luaL_getmetatable(L,type);             // stack: mt ubox[u] super super[mt] flag mt */
+			lua_pushvalue(L, -5);					/* stack: mt ubox[u] super super[mt] flag mt */
+			lua_setmetatable(L,-5);                /* stack: mt ubox[u] super super[mt] flag */
+			lua_pop(L,3);                          /* stack: mt ubox[u] */
+  }
+  lua_remove(L, -2);	/* stack: ubox[u]*/
+ }
+}
+
+TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type)
+{
+	tolua_pushusertype(L,value,type);
+	tolua_register_gc(L,lua_gettop(L));
+}
+
+TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v)
+{
+ lua_pushnumber(L,index);
+ lua_pushvalue(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v)
+{
+ lua_pushnumber(L,index);
+ lua_pushboolean(L,v);
+ lua_settable(L,lo);
+}
+
+
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v)
+{
+ lua_pushnumber(L,index);
+ tolua_pushnumber(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v)
+{
+ lua_pushnumber(L,index);
+ tolua_pushstring(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v)
+{
+ lua_pushnumber(L,index);
+ tolua_pushuserdata(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type)
+{
+ lua_pushnumber(L,index);
+ tolua_pushusertype(L,v,type);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type)
+{
+ lua_pushnumber(L,index);
+ tolua_pushusertype(L,v,type);
+	tolua_register_gc(L,lua_gettop(L));
+ lua_settable(L,lo);
+}
+
Index: /code/branches/physics/src/tolua/tolua_to.c
===================================================================
--- /code/branches/physics/src/tolua/tolua_to.c	(revision 2122)
+++ /code/branches/physics/src/tolua/tolua_to.c	(revision 2122)
@@ -0,0 +1,133 @@
+/* tolua: funcitons to convert to C types
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+#include "tolua++.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def)
+{
+ return lua_gettop(L)<abs(narg) ? def : lua_tonumber(L,narg);
+}
+
+TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def)
+{
+ return lua_gettop(L)<abs(narg) ? def : lua_tostring(L,narg);
+}
+
+TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def)
+{
+	
+	/* return lua_gettop(L)<abs(narg) ? def : lua_touserdata(L,narg); */
+
+	if (lua_gettop(L)<abs(narg)) {
+ 		return def;
+	};
+	 
+	if (lua_islightuserdata(L, narg)) {
+	
+		return lua_touserdata(L,narg);
+	};
+	
+	return tolua_tousertype(L, narg, def);
+}
+
+extern int push_table_instance(lua_State* L, int lo);
+
+TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def)
+{
+ if (lua_gettop(L)<abs(narg))
+  return def;
+ else
+ {
+  void* u;
+  if (!lua_isuserdata(L, narg)) {
+	  if (!push_table_instance(L, narg)) return NULL;
+  };
+  u = lua_touserdata(L,narg);
+  return (u==NULL) ? NULL : *((void**)u); /* nil represents NULL */
+ }
+}
+
+TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def)
+{
+ return lua_gettop(L)<abs(narg) ? def : narg;
+}
+
+TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def)
+{
+ return lua_gettop(L)<abs(narg) ?  def : lua_toboolean(L,narg);
+}
+
+TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def)
+{
+ double v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lua_tonumber(L,-1);
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API const char* tolua_tofieldstring
+(lua_State* L, int lo, int index, const char* def)
+{
+ const char* v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lua_tostring(L,-1);
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def)
+{
+ void* v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lua_touserdata(L,-1);
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def)
+{
+ void* v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : (*(void **)(lua_touserdata(L, -1))); /* lua_unboxpointer(L,-1); */
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def)
+{
+ int v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lo;
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def)
+{
+ int v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? 0 : lua_toboolean(L,-1);
+ lua_pop(L,1);
+ return v;
+}
Index: /code/branches/physics/src/tolua/toluabind.c
===================================================================
--- /code/branches/physics/src/tolua/toluabind.c	(revision 2122)
+++ /code/branches/physics/src/tolua/toluabind.c	(revision 2122)
@@ -0,0 +1,7628 @@
+/*
+** Lua binding: tolua
+** Generated automatically by tolua++-1.0.91 on Wed Apr 26 22:30:14 2006.
+*/
+
+#ifndef __cplusplus
+#include "stdlib.h"
+#endif
+#include "string.h"
+
+#include "tolua++.h"
+
+/* Exported function */
+int  tolua_tolua_open (lua_State* tolua_S);
+
+
+/* function to register type */
+static void tolua_reg_types (lua_State* tolua_S)
+{
+}
+
+/* Open function */
+int tolua_tolua_open (lua_State* tolua_S)
+{
+ tolua_open(tolua_S);
+ tolua_reg_types(tolua_S);
+ tolua_module(tolua_S,NULL,0);
+ tolua_beginmodule(tolua_S,NULL);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+   105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+     95, 86, 69, 82, 83, 73, 79, 78, 44, 32, 34, 53, 37, 46, 48,
+     34, 41, 32,116,104,101,110, 13, 10,  9,114,101,116,117,114,
+    110, 13, 10,101,110,100, 13, 10, 13, 10, 45, 45, 32, 34,108,
+    111, 97,100,102,105,108,101, 34, 13, 10,108,111, 99, 97,108,
+     32,102,117,110, 99,116,105,111,110, 32,112,112, 95,100,111,
+    102,105,108,101, 40,112, 97,116,104, 41, 13, 10, 13, 10,  9,
+    108,111, 99, 97,108, 32,108,111, 97,100,101,100, 32, 61, 32,
+    102, 97,108,115,101, 13, 10,  9,108,111, 99, 97,108, 32,103,
+    101,116,102,105,108,101, 32, 61, 32,102,117,110, 99,116,105,
+    111,110, 40, 41, 13, 10, 13, 10,  9,  9,105,102, 32,108,111,
+     97,100,101,100, 32,116,104,101,110, 13, 10,  9,  9,  9,114,
+    101,116,117,114,110, 13, 10,  9,  9,101,108,115,101, 13, 10,
+      9,  9,  9,108,111, 99, 97,108, 32,102,105,108,101, 44,101,
+    114,114, 32, 61, 32,105,111, 46,111,112,101,110, 40,112, 97,
+    116,104, 41, 13, 10,  9,  9,  9,105,102, 32,110,111,116, 32,
+    102,105,108,101, 32,116,104,101,110, 13, 10,  9,  9,  9,  9,
+    101,114,114,111,114, 40, 34,101,114,114,111,114, 32,108,111,
+     97,100,105,110,103, 32,102,105,108,101, 32, 34, 46, 46,112,
+     97,116,104, 46, 46, 34, 58, 32, 34, 46, 46,101,114,114, 41,
+     13, 10,  9,  9,  9,101,110,100, 13, 10,  9,  9,  9,108,111,
+     99, 97,108, 32,114,101,116, 32, 61, 32,102,105,108,101, 58,
+    114,101, 97,100, 40, 34, 42, 97, 34, 41, 13, 10,  9,  9,  9,
+    102,105,108,101, 58, 99,108,111,115,101, 40, 41, 13, 10, 13,
+     10,  9,  9,  9,114,101,116, 32, 61, 32,115,116,114,105,110,
+    103, 46,103,115,117, 98, 40,114,101,116, 44, 32, 34, 37, 46,
+     37, 46, 37, 46, 37,115, 42, 37, 41, 34, 44, 32, 34, 46, 46,
+     46, 41, 32,108,111, 99, 97,108, 32, 97,114,103, 32, 61, 32,
+    123,110, 61,115,101,108,101, 99,116, 40, 39, 35, 39, 44, 32,
+     46, 46, 46, 41, 44, 32, 46, 46, 46,125, 59, 34, 41, 13, 10,
+     13, 10,  9,  9,  9,108,111, 97,100,101,100, 32, 61, 32,116,
+    114,117,101, 13, 10,  9,  9,  9,114,101,116,117,114,110, 32,
+    114,101,116, 13, 10,  9,  9,101,110,100, 13, 10,  9,101,110,
+    100, 13, 10, 13, 10,  9,108,111, 99, 97,108, 32,102, 32, 61,
+     32,108,111, 97,100, 40,103,101,116,102,105,108,101, 44, 32,
+    112, 97,116,104, 41, 13, 10,  9,114,101,116,117,114,110, 32,
+    102, 40, 41, 13, 10,101,110,100, 13, 10, 13, 10,111,108,100,
+     95,100,111,102,105,108,101, 32, 61, 32,100,111,102,105,108,
+    101, 13, 10,100,111,102,105,108,101, 32, 61, 32,112,112, 95,
+    100,111,102,105,108,101, 13, 10, 13, 10, 13, 10, 45, 45, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 13, 10, 45, 45,
+     91, 91, 13, 10,108,111, 99, 97,108, 32,111,103,115,117, 98,
+     32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 13,
+     10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110,
+     32, 99,111,109,112,103,115,117, 98, 40, 97, 44, 98, 44, 99,
+     44,100, 41, 13, 10, 32, 32,105,102, 32,116,121,112,101, 40,
+     99, 41, 32, 61, 61, 32, 34,102,117,110, 99,116,105,111,110,
+     34, 32,116,104,101,110, 13, 10, 32, 32, 32, 32,108,111, 99,
+     97,108, 32,111, 99, 32, 61, 32, 99, 13, 10, 32, 32, 32, 32,
+     99, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40, 46,
+     46, 46, 41, 32,114,101,116,117,114,110, 32,111, 99, 40, 46,
+     46, 46, 41, 32,111,114, 32, 39, 39, 32,101,110,100, 13, 10,
+     32, 32,101,110,100, 13, 10, 32, 32,114,101,116,117,114,110,
+     32,111,103,115,117, 98, 40, 97, 44, 98, 44, 99, 44,100, 41,
+     13, 10,101,110,100, 13, 10,115,116,114,105,110,103, 46,114,
+    101,112,108, 32, 61, 32,111,103,115,117, 98, 13, 10, 45, 45,
+     93, 93, 13, 10, 13, 10, 45, 45,115,116,114,105,110,103, 46,
+    103,115,117, 98, 32, 61, 32, 99,111,109,112,103,115,117, 98,
+     13,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/compat-5.1.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 82,101, 97,108,
+     32,103,108,111, 98, 97,108,115, 10, 45, 45, 32, 95, 65, 76,
+     69, 82, 84, 10, 45, 45, 32, 95, 69, 82, 82, 79, 82, 77, 69,
+     83, 83, 65, 71, 69, 10, 45, 45, 32, 95, 86, 69, 82, 83, 73,
+     79, 78, 10, 45, 45, 32, 95, 71, 10, 45, 45, 32, 97,115,115,
+    101,114,116, 10, 45, 45, 32,101,114,114,111,114, 10, 45, 45,
+     32,109,101,116, 97,116, 97, 98,108,101, 10, 45, 45, 32,110,
+    101,120,116, 10, 45, 45, 32,112,114,105,110,116, 10, 45, 45,
+     32,114,101,113,117,105,114,101, 10, 45, 45, 32,116,111,110,
+    117,109, 98,101,114, 10, 45, 45, 32,116,111,115,116,114,105,
+    110,103, 10, 45, 45, 32,116,121,112,101, 10, 45, 45, 32,117,
+    110,112, 97, 99,107, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
+     45, 45, 32, 99,111,108,108,101, 99,116,103, 97,114, 98, 97,
+    103,101, 10, 45, 45, 32,103, 99,105,110,102,111, 10, 10, 45,
+     45, 32,103,108,111, 98, 97,108,115, 10, 10, 45, 45, 32, 99,
+     97,108,108, 32, 32, 32, 45, 62, 32,112,114,111,116,101, 99,
+    116, 40,102, 44, 32,101,114,114, 41, 10, 45, 45, 32,108,111,
+     97,100,102,105,108,101, 10, 45, 45, 32,108,111, 97,100,115,
+    116,114,105,110,103, 10, 10, 45, 45, 32,114, 97,119,103,101,
+    116, 10, 45, 45, 32,114, 97,119,115,101,116, 10, 10, 45, 45,
+     32,103,101,116, 97,114,103,115, 32, 61, 32, 77, 97,105,110,
+     46,103,101,116, 97,114,103,115, 32, 63, 63, 10, 10,114, 97,
+    119,116,121,112,101, 32, 61, 32,116,121,112,101, 10, 10,102,
+    117,110, 99,116,105,111,110, 32,100,111, 95, 32, 40,102, 44,
+     32,101,114,114, 41, 10, 32, 32,105,102, 32,110,111,116, 32,
+    102, 32,116,104,101,110, 32,112,114,105,110,116, 40,101,114,
+    114, 41, 59, 32,114,101,116,117,114,110, 32,101,110,100, 10,
+     32, 32,108,111, 99, 97,108, 32, 97, 44, 98, 32, 61, 32,112,
+     99, 97,108,108, 40,102, 41, 10, 32, 32,105,102, 32,110,111,
+    116, 32, 97, 32,116,104,101,110, 32,112,114,105,110,116, 40,
+     98, 41, 59, 32,114,101,116,117,114,110, 32,110,105,108, 10,
+     32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32, 98,
+     32,111,114, 32,116,114,117,101, 10, 32, 32,101,110,100, 10,
+    101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,100,
+    111,115,116,114,105,110,103, 40,115, 41, 32,114,101,116,117,
+    114,110, 32,100,111, 95, 40,108,111, 97,100,115,116,114,105,
+    110,103, 40,115, 41, 41, 32,101,110,100, 10, 45, 45, 32,102,
+    117,110, 99,116,105,111,110, 32,100,111,102,105,108,101, 40,
+    115, 41, 32,114,101,116,117,114,110, 32,100,111, 95, 40,108,
+    111, 97,100,102,105,108,101, 40,115, 41, 41, 32,101,110,100,
+     10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 84, 97,
+     98,108,101, 32,108,105, 98,114, 97,114,121, 10,108,111, 99,
+     97,108, 32,116, 97, 98, 32, 61, 32,116, 97, 98,108,101, 10,
+    102,111,114,101, 97, 99,104, 32, 61, 32,116, 97, 98, 46,102,
+    111,114,101, 97, 99,104, 10,102,111,114,101, 97, 99,104,105,
+     32, 61, 32,116, 97, 98, 46,102,111,114,101, 97, 99,104,105,
+     10,103,101,116,110, 32, 61, 32,116, 97, 98, 46,103,101,116,
+    110, 10,116,105,110,115,101,114,116, 32, 61, 32,116, 97, 98,
+     46,105,110,115,101,114,116, 10,116,114,101,109,111,118,101,
+     32, 61, 32,116, 97, 98, 46,114,101,109,111,118,101, 10,115,
+    111,114,116, 32, 61, 32,116, 97, 98, 46,115,111,114,116, 10,
+     10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 98,
+    117,103, 32,108,105, 98,114, 97,114,121, 10,108,111, 99, 97,
+    108, 32,100, 98,103, 32, 61, 32,100,101, 98,117,103, 10,103,
+    101,116,105,110,102,111, 32, 61, 32,100, 98,103, 46,103,101,
+    116,105,110,102,111, 10,103,101,116,108,111, 99, 97,108, 32,
+     61, 32,100, 98,103, 46,103,101,116,108,111, 99, 97,108, 10,
+    115,101,116, 99, 97,108,108,104,111,111,107, 32, 61, 32,102,
+    117,110, 99,116,105,111,110, 32, 40, 41, 32,101,114,114,111,
+    114, 34, 96,115,101,116, 99, 97,108,108,104,111,111,107, 39,
+     32,105,115, 32,100,101,112,114,101, 99, 97,116,101,100, 34,
+     32,101,110,100, 10,115,101,116,108,105,110,101,104,111,111,
+    107, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40, 41,
+     32,101,114,114,111,114, 34, 96,115,101,116,108,105,110,101,
+    104,111,111,107, 39, 32,105,115, 32,100,101,112,114,101, 99,
+     97,116,101,100, 34, 32,101,110,100, 10,115,101,116,108,111,
+     99, 97,108, 32, 61, 32,100, 98,103, 46,115,101,116,108,111,
+     99, 97,108, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45,
+     32,109, 97,116,104, 32,108,105, 98,114, 97,114,121, 10,108,
+    111, 99, 97,108, 32,109, 97,116,104, 32, 61, 32,109, 97,116,
+    104, 10, 97, 98,115, 32, 61, 32,109, 97,116,104, 46, 97, 98,
+    115, 10, 97, 99,111,115, 32, 61, 32,102,117,110, 99,116,105,
+    111,110, 32, 40,120, 41, 32,114,101,116,117,114,110, 32,109,
+     97,116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97, 99,
+    111,115, 40,120, 41, 41, 32,101,110,100, 10, 97,115,105,110,
+     32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,120, 41,
+     32,114,101,116,117,114,110, 32,109, 97,116,104, 46,100,101,
+    103, 40,109, 97,116,104, 46, 97,115,105,110, 40,120, 41, 41,
+     32,101,110,100, 10, 97,116, 97,110, 32, 61, 32,102,117,110,
+     99,116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114,
+    110, 32,109, 97,116,104, 46,100,101,103, 40,109, 97,116,104,
+     46, 97,116, 97,110, 40,120, 41, 41, 32,101,110,100, 10, 97,
+    116, 97,110, 50, 32, 61, 32,102,117,110, 99,116,105,111,110,
+     32, 40,120, 44,121, 41, 32,114,101,116,117,114,110, 32,109,
+     97,116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97,116,
+     97,110, 50, 40,120, 44,121, 41, 41, 32,101,110,100, 10, 99,
+    101,105,108, 32, 61, 32,109, 97,116,104, 46, 99,101,105,108,
+     10, 99,111,115, 32, 61, 32,102,117,110, 99,116,105,111,110,
+     32, 40,120, 41, 32,114,101,116,117,114,110, 32,109, 97,116,
+    104, 46, 99,111,115, 40,109, 97,116,104, 46,114, 97,100, 40,
+    120, 41, 41, 32,101,110,100, 10,100,101,103, 32, 61, 32,109,
+     97,116,104, 46,100,101,103, 10,101,120,112, 32, 61, 32,109,
+     97,116,104, 46,101,120,112, 10,102,108,111,111,114, 32, 61,
+     32,109, 97,116,104, 46,102,108,111,111,114, 10,102,114,101,
+    120,112, 32, 61, 32,109, 97,116,104, 46,102,114,101,120,112,
+     10,108,100,101,120,112, 32, 61, 32,109, 97,116,104, 46,108,
+    100,101,120,112, 10,108,111,103, 32, 61, 32,109, 97,116,104,
+     46,108,111,103, 10,108,111,103, 49, 48, 32, 61, 32,109, 97,
+    116,104, 46,108,111,103, 49, 48, 10,109, 97,120, 32, 61, 32,
+    109, 97,116,104, 46,109, 97,120, 10,109,105,110, 32, 61, 32,
+    109, 97,116,104, 46,109,105,110, 10,109,111,100, 32, 61, 32,
+    109, 97,116,104, 46,109,111,100, 10, 80, 73, 32, 61, 32,109,
+     97,116,104, 46,112,105, 10, 45, 45, 63, 63, 63, 32,112,111,
+    119, 32, 61, 32,109, 97,116,104, 46,112,111,119, 32, 32, 10,
+    114, 97,100, 32, 61, 32,109, 97,116,104, 46,114, 97,100, 10,
+    114, 97,110,100,111,109, 32, 61, 32,109, 97,116,104, 46,114,
+     97,110,100,111,109, 10,114, 97,110,100,111,109,115,101,101,
+    100, 32, 61, 32,109, 97,116,104, 46,114, 97,110,100,111,109,
+    115,101,101,100, 10,115,105,110, 32, 61, 32,102,117,110, 99,
+    116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114,110,
+     32,109, 97,116,104, 46,115,105,110, 40,109, 97,116,104, 46,
+    114, 97,100, 40,120, 41, 41, 32,101,110,100, 10,115,113,114,
+    116, 32, 61, 32,109, 97,116,104, 46,115,113,114,116, 10,116,
+     97,110, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,
+    120, 41, 32,114,101,116,117,114,110, 32,109, 97,116,104, 46,
+    116, 97,110, 40,109, 97,116,104, 46,114, 97,100, 40,120, 41,
+     41, 32,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
+     45, 45, 32,115,116,114,105,110,103, 32,108,105, 98,114, 97,
+    114,121, 10,108,111, 99, 97,108, 32,115,116,114, 32, 61, 32,
+    115,116,114,105,110,103, 10,115,116,114, 98,121,116,101, 32,
+     61, 32,115,116,114, 46, 98,121,116,101, 10,115,116,114, 99,
+    104, 97,114, 32, 61, 32,115,116,114, 46, 99,104, 97,114, 10,
+    115,116,114,102,105,110,100, 32, 61, 32,115,116,114, 46,102,
+    105,110,100, 10,102,111,114,109, 97,116, 32, 61, 32,115,116,
+    114, 46,102,111,114,109, 97,116, 10,103,115,117, 98, 32, 61,
+     32,115,116,114, 46,103,115,117, 98, 10,115,116,114,108,101,
+    110, 32, 61, 32,115,116,114, 46,108,101,110, 10,115,116,114,
+    108,111,119,101,114, 32, 61, 32,115,116,114, 46,108,111,119,
+    101,114, 10,115,116,114,114,101,112, 32, 61, 32,115,116,114,
+     46,114,101,112, 10,115,116,114,115,117, 98, 32, 61, 32,115,
+    116,114, 46,115,117, 98, 10,115,116,114,117,112,112,101,114,
+     32, 61, 32,115,116,114, 46,117,112,112,101,114, 10, 10, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 10, 45, 45, 32,111,115, 32,108,105,
+     98,114, 97,114,121, 10, 99,108,111, 99,107, 32, 61, 32,111,
+    115, 46, 99,108,111, 99,107, 10,100, 97,116,101, 32, 61, 32,
+    111,115, 46,100, 97,116,101, 10,100,105,102,102,116,105,109,
+    101, 32, 61, 32,111,115, 46,100,105,102,102,116,105,109,101,
+     10,101,120,101, 99,117,116,101, 32, 61, 32,111,115, 46,101,
+    120,101, 99,117,116,101, 32, 45, 45, 63, 10,101,120,105,116,
+     32, 61, 32,111,115, 46,101,120,105,116, 10,103,101,116,101,
+    110,118, 32, 61, 32,111,115, 46,103,101,116,101,110,118, 10,
+    114,101,109,111,118,101, 32, 61, 32,111,115, 46,114,101,109,
+    111,118,101, 10,114,101,110, 97,109,101, 32, 61, 32,111,115,
+     46,114,101,110, 97,109,101, 10,115,101,116,108,111, 99, 97,
+    108,101, 32, 61, 32,111,115, 46,115,101,116,108,111, 99, 97,
+    108,101, 10,116,105,109,101, 32, 61, 32,111,115, 46,116,105,
+    109,101, 10,116,109,112,110, 97,109,101, 32, 61, 32,111,115,
+     46,116,109,112,110, 97,109,101, 10, 10, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 10, 45, 45, 32, 99,111,109,112, 97,116,105, 98,105,
+    108,105,116,121, 32,111,110,108,121, 10,103,101,116,103,108,
+    111, 98, 97,108, 32, 61, 32,102,117,110, 99,116,105,111,110,
+     32, 40,110, 41, 32,114,101,116,117,114,110, 32, 95, 71, 91,
+    110, 93, 32,101,110,100, 10,115,101,116,103,108,111, 98, 97,
+    108, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,110,
+     44,118, 41, 32, 95, 71, 91,110, 93, 32, 61, 32,118, 32,101,
+    110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10,108,111,
+     99, 97,108, 32,105,111, 44, 32,116, 97, 98, 32, 61, 32,105,
+    111, 44, 32,116, 97, 98,108,101, 10, 10, 45, 45, 32, 73, 79,
+     32,108,105, 98,114, 97,114,121, 32, 40,102,105,108,101,115,
+     41, 10, 95, 83, 84, 68, 73, 78, 32, 61, 32,105,111, 46,115,
+    116,100,105,110, 10, 95, 83, 84, 68, 69, 82, 82, 32, 61, 32,
+    105,111, 46,115,116,100,101,114,114, 10, 95, 83, 84, 68, 79,
+     85, 84, 32, 61, 32,105,111, 46,115,116,100,111,117,116, 10,
+     95, 73, 78, 80, 85, 84, 32, 61, 32,105,111, 46,115,116,100,
+    105,110, 10, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,105,111,
+     46,115,116,100,111,117,116, 10,115,101,101,107, 32, 61, 32,
+    105,111, 46,115,116,100,105,110, 46,115,101,101,107, 32, 32,
+     32, 45, 45, 32,115,105, 99,107, 32, 59, 45, 41, 10,116,109,
+    112,102,105,108,101, 32, 61, 32,105,111, 46,116,109,112,102,
+    105,108,101, 10, 99,108,111,115,101,102,105,108,101, 32, 61,
+     32,105,111, 46, 99,108,111,115,101, 10,111,112,101,110,102,
+    105,108,101, 32, 61, 32,105,111, 46,111,112,101,110, 10, 10,
+    102,117,110, 99,116,105,111,110, 32,102,108,117,115,104, 32,
+     40,102, 41, 10, 32, 32,105,102, 32,102, 32,116,104,101,110,
+     32,102, 58,102,108,117,115,104, 40, 41, 10, 32, 32,101,108,
+    115,101, 32, 95, 79, 85, 84, 80, 85, 84, 58,102,108,117,115,
+    104, 40, 41, 10, 32, 32,101,110,100, 10,101,110,100, 10, 10,
+    102,117,110, 99,116,105,111,110, 32,114,101, 97,100,102,114,
+    111,109, 32, 40,110, 97,109,101, 41, 10, 32, 32,105,102, 32,
+    110, 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,101,
+    110, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 44, 32,
+    101,114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46, 99,
+    108,111,115,101, 40, 95, 73, 78, 80, 85, 84, 41, 10, 32, 32,
+     32, 32, 95, 73, 78, 80, 85, 84, 32, 61, 32,105,111, 46,115,
+    116,100,105,110, 10, 32, 32, 32, 32,114,101,116,117,114,110,
+     32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10, 32, 32,
+    101,108,115,101, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,
+    102, 44, 32,101,114,114, 44, 32, 99,111,100, 32, 61, 32,105,
+    111, 46,111,112,101,110, 40,110, 97,109,101, 44, 32, 34,114,
+     34, 41, 10, 32, 32, 32, 32, 95, 73, 78, 80, 85, 84, 32, 61,
+     32,102, 32,111,114, 32, 95, 73, 78, 80, 85, 84, 10, 32, 32,
+     32, 32,114,101,116,117,114,110, 32,102, 44, 32,101,114,114,
+     44, 32, 99,111,100, 10, 32, 32,101,110,100, 10,101,110,100,
+     10, 10,102,117,110, 99,116,105,111,110, 32,119,114,105,116,
+    101,116,111, 32, 40,110, 97,109,101, 41, 10, 32, 32,105,102,
+     32,110, 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,
+    101,110, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 44,
+     32,101,114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46,
+     99,108,111,115,101, 40, 95, 79, 85, 84, 80, 85, 84, 41, 10,
+     32, 32, 32, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,105,
+    111, 46,115,116,100,111,117,116, 10, 32, 32, 32, 32,114,101,
+    116,117,114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,
+    100, 10, 32, 32,101,108,115,101, 10, 32, 32, 32, 32,108,111,
+     99, 97,108, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100,
+     32, 61, 32,105,111, 46,111,112,101,110, 40,110, 97,109,101,
+     44, 32, 34,119, 34, 41, 10, 32, 32, 32, 32, 95, 79, 85, 84,
+     80, 85, 84, 32, 61, 32,102, 32,111,114, 32, 95, 79, 85, 84,
+     80, 85, 84, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
+    102, 44, 32,101,114,114, 44, 32, 99,111,100, 10, 32, 32,101,
+    110,100, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,
+    110, 32, 97,112,112,101,110,100,116,111, 32, 40,110, 97,109,
+    101, 41, 10, 32, 32,108,111, 99, 97,108, 32,102, 44, 32,101,
+    114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46,111,112,
+    101,110, 40,110, 97,109,101, 44, 32, 34, 97, 34, 41, 10, 32,
+     32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,102, 32,111,114,
+     32, 95, 79, 85, 84, 80, 85, 84, 10, 32, 32,114,101,116,117,
+    114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10,
+    101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,114,
+    101, 97,100, 32, 40, 46, 46, 46, 41, 10, 32, 32,108,111, 99,
+     97,108, 32,102, 32, 61, 32, 95, 73, 78, 80, 85, 84, 10, 32,
+     32,105,102, 32,114, 97,119,116,121,112,101, 40, 97,114,103,
+     91, 49, 93, 41, 32, 61, 61, 32, 39,117,115,101,114,100, 97,
+    116, 97, 39, 32,116,104,101,110, 10, 32, 32, 32, 32,102, 32,
+     61, 32,116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,
+    103, 44, 32, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,114,
+    101,116,117,114,110, 32,102, 58,114,101, 97,100, 40,117,110,
+    112, 97, 99,107, 40, 97,114,103, 41, 41, 10,101,110,100, 10,
+     10,102,117,110, 99,116,105,111,110, 32,119,114,105,116,101,
+     32, 40, 46, 46, 46, 41, 10, 32, 32,108,111, 99, 97,108, 32,
+    102, 32, 61, 32, 95, 79, 85, 84, 80, 85, 84, 10, 32, 32,105,
+    102, 32,114, 97,119,116,121,112,101, 40, 97,114,103, 91, 49,
+     93, 41, 32, 61, 61, 32, 39,117,115,101,114,100, 97,116, 97,
+     39, 32,116,104,101,110, 10, 32, 32, 32, 32,102, 32, 61, 32,
+    116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,103, 44,
+     32, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,114,101,116,
+    117,114,110, 32,102, 58,119,114,105,116,101, 40,117,110,112,
+     97, 99,107, 40, 97,114,103, 41, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/compat.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 98, 97,115,105, 99,
+     32,117,116,105,108,105,116,121, 32,102,117,110, 99,116,105,
+    111,110,115, 10, 45, 45, 32, 87,114,105,116,116,101,110, 32,
+     98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,108,
+    101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47, 80,
+     85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32, 49,
+     57, 57, 56, 10, 45, 45, 32, 76, 97,115,116, 32,117,112,100,
+     97,116,101, 58, 32, 65,112,114, 32, 50, 48, 48, 51, 10, 45,
+     45, 32, 36, 73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,
+    105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101,
+     32,115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32,
+     99, 97,110, 32,114,101,100,105,115,116,114,105, 98,117,116,
+    101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100,
+    105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,
+    115,111,102,116,119, 97,114,101, 32,112,114,111,118,105,100,
+    101,100, 32,104,101,114,101,117,110,100,101,114, 32,105,115,
+     32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32,
+     98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,
+    104,101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110,
+    111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111,
+     32,112,114,111,118,105,100,101, 32,109, 97,105,110,116,101,
+    110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44,
+     32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,
+    104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32,
+    109,111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10,
+     10, 10, 45, 45, 32, 66, 97,115,105, 99, 32, 67, 32,116,121,
+    112,101,115, 32, 97,110,100, 32,116,104,101,105,114, 32, 99,
+    111,114,114,101,115,112,111,110,100,105,110,103, 32, 76,117,
+     97, 32,116,121,112,101,115, 10, 45, 45, 32, 65,108,108, 32,
+    111, 99, 99,117,114,114,101,110, 99,101,115, 32,111,102, 32,
+     34, 99,104, 97,114, 42, 34, 32,119,105,108,108, 32, 98,101,
+     32,114,101,112,108, 97, 99,101,100, 32, 98,121, 32, 34, 95,
+     99,115,116,114,105,110,103, 34, 44, 10, 45, 45, 32, 97,110,
+    100, 32, 97,108,108, 32,111, 99, 99,117,114,114,101,110, 99,
+    101,115, 32,111,102, 32, 34,118,111,105,100, 42, 34, 32,119,
+    105,108,108, 32, 98,101, 32,114,101,112,108, 97, 99,101,100,
+     32, 98,121, 32, 34, 95,117,115,101,114,100, 97,116, 97, 34,
+     10, 95, 98, 97,115,105, 99, 32, 61, 32,123, 10, 32, 91, 39,
+    118,111,105,100, 39, 93, 32, 61, 32, 39, 39, 44, 10, 32, 91,
+     39, 99,104, 97,114, 39, 93, 32, 61, 32, 39,110,117,109, 98,
+    101,114, 39, 44, 10, 32, 91, 39,105,110,116, 39, 93, 32, 61,
+     32, 39,110,117,109, 98,101,114, 39, 44, 10, 32, 91, 39,115,
+    104,111,114,116, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,
+    114, 39, 44, 10, 32, 91, 39,108,111,110,103, 39, 93, 32, 61,
+     32, 39,110,117,109, 98,101,114, 39, 44, 10, 32, 91, 39,117,
+    110,115,105,103,110,101,100, 39, 93, 32, 61, 32, 39,110,117,
+    109, 98,101,114, 39, 44, 10, 32, 91, 39,102,108,111, 97,116,
+     39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44, 10,
+     32, 91, 39,100,111,117, 98,108,101, 39, 93, 32, 61, 32, 39,
+    110,117,109, 98,101,114, 39, 44, 10, 32, 91, 39, 95, 99,115,
+    116,114,105,110,103, 39, 93, 32, 61, 32, 39,115,116,114,105,
+    110,103, 39, 44, 10, 32, 91, 39, 95,117,115,101,114,100, 97,
+    116, 97, 39, 93, 32, 61, 32, 39,117,115,101,114,100, 97,116,
+     97, 39, 44, 10, 32, 91, 39, 99,104, 97,114, 42, 39, 93, 32,
+     61, 32, 39,115,116,114,105,110,103, 39, 44, 10, 32, 91, 39,
+    118,111,105,100, 42, 39, 93, 32, 61, 32, 39,117,115,101,114,
+    100, 97,116, 97, 39, 44, 10, 32, 91, 39, 98,111,111,108, 39,
+     93, 32, 61, 32, 39, 98,111,111,108,101, 97,110, 39, 44, 10,
+     32, 91, 39,108,117, 97, 95, 79, 98,106,101, 99,116, 39, 93,
+     32, 61, 32, 39,118, 97,108,117,101, 39, 44, 10, 32, 91, 39,
+     76, 85, 65, 95, 86, 65, 76, 85, 69, 39, 93, 32, 61, 32, 39,
+    118, 97,108,117,101, 39, 44, 32, 32, 32, 32, 45, 45, 32,102,
+    111,114, 32, 99,111,109,112, 97,116,105, 98,105,108,105,116,
+    121, 32,119,105,116,104, 32,116,111,108,117, 97, 32, 52, 46,
+     48, 10, 32, 91, 39,108,117, 97, 95, 83,116, 97,116,101, 42,
+     39, 93, 32, 61, 32, 39,115,116, 97,116,101, 39, 44, 10, 32,
+     91, 39, 95,108,115,116, 97,116,101, 39, 93, 32, 61, 32, 39,
+    115,116, 97,116,101, 39, 44, 10, 32, 91, 39,108,117, 97, 95,
+     70,117,110, 99,116,105,111,110, 39, 93, 32, 61, 32, 39,118,
+     97,108,117,101, 39, 44, 10,125, 10, 10, 95, 98, 97,115,105,
+     99, 95, 99,116,121,112,101, 32, 61, 32,123, 10, 32,110,117,
+    109, 98,101,114, 32, 61, 32, 34,108,117, 97, 95, 78,117,109,
+     98,101,114, 34, 44, 10, 32,115,116,114,105,110,103, 32, 61,
+     32, 34, 99,111,110,115,116, 32, 99,104, 97,114, 42, 34, 44,
+     10, 32,117,115,101,114,100, 97,116, 97, 32, 61, 32, 34,118,
+    111,105,100, 42, 34, 44, 10, 32, 98,111,111,108,101, 97,110,
+     32, 61, 32, 34, 98,111,111,108, 34, 44, 10, 32,118, 97,108,
+    117,101, 32, 61, 32, 34,105,110,116, 34, 44, 10, 32,115,116,
+     97,116,101, 32, 61, 32, 34,108,117, 97, 95, 83,116, 97,116,
+    101, 42, 34, 44, 10,125, 10, 10, 45, 45, 32,102,117,110, 99,
+    116,105,111,110,115, 32,116,104,101, 32, 97,114,101, 32,117,
+    115,101,100, 32,116,111, 32,100,111, 32, 97, 32, 39,114, 97,
+    119, 32,112,117,115,104, 39, 32,111,102, 32, 98, 97,115,105,
+     99, 32,116,121,112,101,115, 10, 95, 98, 97,115,105, 99, 95,
+    114, 97,119, 95,112,117,115,104, 32, 61, 32,123,125, 10, 10,
+     45, 45, 32, 76,105,115,116, 32,111,102, 32,117,115,101,114,
+     32,100,101,102,105,110,101,100, 32,116,121,112,101,115, 10,
+     45, 45, 32, 69, 97, 99,104, 32,116,121,112,101, 32, 99,111,
+    114,114,101,115,112,111,110,100,115, 32,116,111, 32, 97, 32,
+    118, 97,114,105, 97, 98,108,101, 32,110, 97,109,101, 32,116,
+    104, 97,116, 32,115,116,111,114,101,115, 32,105,116,115, 32,
+    116, 97,103, 32,118, 97,108,117,101, 46, 10, 95,117,115,101,
+    114,116,121,112,101, 32, 61, 32,123,125, 10, 10, 45, 45, 32,
+     76,105,115,116, 32,111,102, 32,116,121,112,101,115, 32,116,
+    104, 97,116, 32,104, 97,118,101, 32,116,111, 32, 98,101, 32,
+     99,111,108,108,101, 99,116,101,100, 10, 95, 99,111,108,108,
+    101, 99,116, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,105,
+    115,116, 32,111,102, 32,116,121,112,101,115, 10, 95,103,108,
+    111, 98, 97,108, 95,116,121,112,101,115, 32, 61, 32,123,110,
+     61, 48,125, 10, 95,103,108,111, 98, 97,108, 95,116,121,112,
+    101,115, 95,104, 97,115,104, 32, 61, 32,123,125, 10, 10, 45,
+     45, 32,108,105,115,116, 32,111,102, 32, 99,108, 97,115,115,
+    101,115, 10, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115,
+    115,101,115, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,105,
+    115,116, 32,111,102, 32,101,110,117,109, 32, 99,111,110,115,
+    116, 97,110,116,115, 10, 95,103,108,111, 98, 97,108, 95,101,
+    110,117,109,115, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,
+    105,115,116, 32,111,102, 32, 97,117,116,111, 32,114,101,110,
+     97,109,105,110,103, 10, 95,114,101,110, 97,109,105,110,103,
+     32, 61, 32,123,125, 10,102,117,110, 99,116,105,111,110, 32,
+     97,112,112,101,110,100,114,101,110, 97,109,105,110,103, 32,
+     40,115, 41, 10, 32,108,111, 99, 97,108, 32, 98, 44,101, 44,
+    111,108,100, 44,110,101,119, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 37,115, 42, 40, 46, 45, 41, 37,115,
+     42, 64, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 36, 34, 41,
+     10,  9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110,
+     10,  9, 32,101,114,114,111,114, 40, 34, 35, 73,110,118, 97,
+    108,105,100, 32,114,101,110, 97,109,105,110,103, 32,115,121,
+    110,116, 97,120, 59, 32,105,116, 32,115,104,111,117,108,100,
+     32, 98,101, 32,111,102, 32,116,104,101, 32,102,111,114,109,
+     58, 32,112, 97,116,116,101,114,110, 64,112, 97,116,116,101,
+    114,110, 34, 41, 10,  9,101,110,100, 10,  9,116,105,110,115,
+    101,114,116, 40, 95,114,101,110, 97,109,105,110,103, 44,123,
+    111,108,100, 61,111,108,100, 44, 32,110,101,119, 61,110,101,
+    119,125, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,
+    111,110, 32, 97,112,112,108,121,114,101,110, 97,109,105,110,
+    103, 32, 40,115, 41, 10,  9,102,111,114, 32,105, 61, 49, 44,
+    103,101,116,110, 40, 95,114,101,110, 97,109,105,110,103, 41,
+     32,100,111, 10,  9, 32,108,111, 99, 97,108, 32,109, 44,110,
+     32, 61, 32,103,115,117, 98, 40,115, 44, 95,114,101,110, 97,
+    109,105,110,103, 91,105, 93, 46,111,108,100, 44, 95,114,101,
+    110, 97,109,105,110,103, 91,105, 93, 46,110,101,119, 41, 10,
+      9,  9,105,102, 32,110, 32,126, 61, 32, 48, 32,116,104,101,
+    110, 10,  9,  9, 32,114,101,116,117,114,110, 32,109, 10,  9,
+      9,101,110,100, 10,  9,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32,110,105,108, 10,101,110,100, 10, 10, 45, 45, 32,
+     69,114,114,111,114, 32,104, 97,110,100,108,101,114, 10,102,
+    117,110, 99,116,105,111,110, 32,116,111,108,117, 97, 95,101,
+    114,114,111,114, 32, 40,115, 44,102, 41, 10,105,102, 32, 95,
+     99,117,114,114, 95, 99,111,100,101, 32,116,104,101,110, 10,
+      9,112,114,105,110,116, 40, 34, 42, 42, 42, 99,117,114,114,
+     32, 99,111,100,101, 32,102,111,114, 32,101,114,114,111,114,
+     32,105,115, 32, 34, 46, 46,116,111,115,116,114,105,110,103,
+     40, 95, 99,117,114,114, 95, 99,111,100,101, 41, 41, 10,  9,
+    112,114,105,110,116, 40,100,101, 98,117,103, 46,116,114, 97,
+     99,101, 98, 97, 99,107, 40, 41, 41, 10,101,110,100, 10, 32,
+    108,111, 99, 97,108, 32,111,117,116, 32, 61, 32, 95, 79, 85,
+     84, 80, 85, 84, 10, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61,
+     32, 95, 83, 84, 68, 69, 82, 82, 10, 32,105,102, 32,115,116,
+    114,115,117, 98, 40,115, 44, 49, 44, 49, 41, 32, 61, 61, 32,
+     39, 35, 39, 32,116,104,101,110, 10, 32, 32,119,114,105,116,
+    101, 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97, 58, 32,
+     34, 46, 46,115,116,114,115,117, 98, 40,115, 44, 50, 41, 46,
+     46, 34, 46, 92,110, 92,110, 34, 41, 10, 32, 32,105,102, 32,
+     95, 99,117,114,114, 95, 99,111,100,101, 32,116,104,101,110,
+     10, 32, 32, 32,108,111, 99, 97,108, 32, 95, 44, 95, 44,115,
+     32, 61, 32,115,116,114,102,105,110,100, 40, 95, 99,117,114,
+    114, 95, 99,111,100,101, 44, 34, 94, 37,115, 42, 40, 46, 45,
+     92,110, 41, 34, 41, 32, 45, 45, 32,101,120,116,114, 97, 99,
+    116, 32,102,105,114,115,116, 32,108,105,110,101, 10, 32, 32,
+     32,105,102, 32,115, 61, 61,110,105,108, 32,116,104,101,110,
+     32,115, 32, 61, 32, 95, 99,117,114,114, 95, 99,111,100,101,
+     32,101,110,100, 10, 32, 32, 32,115, 32, 61, 32,103,115,117,
+     98, 40,115, 44, 34, 95,117,115,101,114,100, 97,116, 97, 34,
+     44, 34,118,111,105,100, 42, 34, 41, 32, 45, 45, 32,114,101,
+    116,117,114,110, 32,119,105,116,104, 32, 39,118,111,105,100,
+     42, 39, 10, 32, 32, 32,115, 32, 61, 32,103,115,117, 98, 40,
+    115, 44, 34, 95, 99,115,116,114,105,110,103, 34, 44, 34, 99,
+    104, 97,114, 42, 34, 41, 32, 32, 45, 45, 32,114,101,116,117,
+    114,110, 32,119,105,116,104, 32, 39, 99,104, 97,114, 42, 39,
+     10, 32, 32, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44,
+     34, 95,108,115,116, 97,116,101, 34, 44, 34,108,117, 97, 95,
+     83,116, 97,116,101, 42, 34, 41, 32, 32, 45, 45, 32,114,101,
+    116,117,114,110, 32,119,105,116,104, 32, 39,108,117, 97, 95,
+     83,116, 97,116,101, 42, 39, 10, 32, 32, 32,119,114,105,116,
+    101, 40, 34, 67,111,100,101, 32, 98,101,105,110,103, 32,112,
+    114,111, 99,101,115,115,101,100, 58, 92,110, 34, 46, 46,115,
+     46, 46, 34, 92,110, 34, 41, 10, 32, 32,101,110,100, 10, 32,
+    101,108,115,101, 10, 32,105,102, 32,110,111,116, 32,102, 32,
+    116,104,101,110, 32,102, 32, 61, 32, 34, 40,102, 32,105,115,
+     32,110,105,108, 41, 34, 32,101,110,100, 10, 32, 32,112,114,
+    105,110,116, 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97,
+     32,105,110,116,101,114,110, 97,108, 32,101,114,114,111,114,
+     58, 32, 34, 46, 46,102, 46, 46,115, 46, 46, 34, 46, 92,110,
+     92,110, 34, 41, 10, 32, 32,114,101,116,117,114,110, 10, 32,
+    101,110,100, 10, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,
+    111,117,116, 10,101,110,100, 10, 10,102,117,110, 99,116,105,
+    111,110, 32,119, 97,114,110,105,110,103, 32, 40,109,115,103,
+     41, 10, 32,108,111, 99, 97,108, 32,111,117,116, 32, 61, 32,
+     95, 79, 85, 84, 80, 85, 84, 10, 32, 95, 79, 85, 84, 80, 85,
+     84, 32, 61, 32, 95, 83, 84, 68, 69, 82, 82, 10, 32,119,114,
+    105,116,101, 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97,
+     32,119, 97,114,110,105,110,103, 58, 32, 34, 46, 46,109,115,
+    103, 46, 46, 34, 46, 92,110, 92,110, 34, 41, 10, 32, 95, 79,
+     85, 84, 80, 85, 84, 32, 61, 32,111,117,116, 10,101,110,100,
+     10, 10, 45, 45, 32,114,101,103,105,115,116,101,114, 32, 97,
+    110, 32,117,115,101,114, 32,100,101,102,105,110,101,100, 32,
+    116,121,112,101, 58, 32,114,101,116,117,114,110,115, 32,102,
+    117,108,108, 32,116,121,112,101, 10,102,117,110, 99,116,105,
+    111,110, 32,114,101,103,116,121,112,101, 32, 40,116, 41, 10,
+      9, 45, 45,105,102, 32,105,115, 98, 97,115,105, 99, 40,116,
+     41, 32,116,104,101,110, 10,  9, 45, 45,  9,114,101,116,117,
+    114,110, 32,116, 10,  9, 45, 45,101,110,100, 10,  9,108,111,
+     99, 97,108, 32,102,116, 32, 61, 32,102,105,110,100,116,121,
+    112,101, 40,116, 41, 10, 10,  9,105,102, 32,110,111,116, 32,
+     95,117,115,101,114,116,121,112,101, 91,102,116, 93, 32,116,
+    104,101,110, 10,  9,  9,114,101,116,117,114,110, 32, 97,112,
+    112,101,110,100,117,115,101,114,116,121,112,101, 40,116, 41,
+     10,  9,101,110,100, 10,  9,114,101,116,117,114,110, 32,102,
+    116, 10,101,110,100, 10, 10, 45, 45, 32,114,101,116,117,114,
+    110, 32,116,121,112,101, 32,110, 97,109,101, 58, 32,114,101,
+    116,117,114,110,115, 32,102,117,108,108, 32,116,121,112,101,
+     10,102,117,110, 99,116,105,111,110, 32,116,121,112,101,118,
+     97,114, 40,116,121,112,101, 41, 10,  9,105,102, 32,116,121,
+    112,101, 32, 61, 61, 32, 39, 39, 32,111,114, 32,116,121,112,
+    101, 32, 61, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,
+    110, 10,  9,  9,114,101,116,117,114,110, 32,116,121,112,101,
+     10,  9,101,108,115,101, 10,  9,  9,108,111, 99, 97,108, 32,
+    102,116, 32, 61, 32,102,105,110,100,116,121,112,101, 40,116,
+    121,112,101, 41, 10,  9,  9,105,102, 32,102,116, 32,116,104,
+    101,110, 10,  9,  9,  9,114,101,116,117,114,110, 32,102,116,
+     10,  9,  9,101,110,100, 10,  9,  9, 95,117,115,101,114,116,
+    121,112,101, 91,116,121,112,101, 93, 32, 61, 32,116,121,112,
+    101, 10,  9,  9,114,101,116,117,114,110, 32,116,121,112,101,
+     10,  9,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,
+    104,101, 99,107, 32,105,102, 32, 98, 97,115,105, 99, 32,116,
+    121,112,101, 10,102,117,110, 99,116,105,111,110, 32,105,115,
+     98, 97,115,105, 99, 32, 40,116,121,112,101, 41, 10, 32,108,
+    111, 99, 97,108, 32,116, 32, 61, 32,103,115,117, 98, 40,116,
+    121,112,101, 44, 39, 99,111,110,115,116, 32, 39, 44, 39, 39,
+     41, 10, 32,108,111, 99, 97,108, 32,109, 44,116, 32, 61, 32,
+     97,112,112,108,121,116,121,112,101,100,101,102, 40, 39, 39,
+     44, 32,116, 41, 10, 32,108,111, 99, 97,108, 32, 98, 32, 61,
+     32, 95, 98, 97,115,105, 99, 91,116, 93, 10, 32,105,102, 32,
+     98, 32,116,104,101,110, 10, 32, 32,114,101,116,117,114,110,
+     32, 98, 44, 95, 98, 97,115,105, 99, 95, 99,116,121,112,101,
+     91, 98, 93, 10, 32,101,110,100, 10, 32,114,101,116,117,114,
+    110, 32,110,105,108, 10,101,110,100, 10, 10, 45, 45, 32,115,
+    112,108,105,116, 32,115,116,114,105,110,103, 32,117,115,105,
+    110,103, 32, 97, 32,116,111,107,101,110, 10,102,117,110, 99,
+    116,105,111,110, 32,115,112,108,105,116, 32, 40,115, 44,116,
+     41, 10, 32,108,111, 99, 97,108, 32,108, 32, 61, 32,123,110,
+     61, 48,125, 10, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,
+    102,117,110, 99,116,105,111,110, 32, 40,115, 41, 10, 32, 32,
+    108, 46,110, 32, 61, 32,108, 46,110, 32, 43, 32, 49, 10, 32,
+     32,108, 91,108, 46,110, 93, 32, 61, 32,115, 10, 32, 32,114,
+    101,116,117,114,110, 32, 34, 34, 10, 32,101,110,100, 10, 32,
+    108,111, 99, 97,108, 32,112, 32, 61, 32, 34, 37,115, 42, 40,
+     46, 45, 41, 37,115, 42, 34, 46, 46,116, 46, 46, 34, 37,115,
+     42, 34, 10, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44,
+     34, 94, 37,115, 43, 34, 44, 34, 34, 41, 10, 32,115, 32, 61,
+     32,103,115,117, 98, 40,115, 44, 34, 37,115, 43, 36, 34, 44,
+     34, 34, 41, 10, 32,115, 32, 61, 32,103,115,117, 98, 40,115,
+     44,112, 44,102, 41, 10, 32,108, 46,110, 32, 61, 32,108, 46,
+    110, 32, 43, 32, 49, 10, 32,108, 91,108, 46,110, 93, 32, 61,
+     32,103,115,117, 98, 40,115, 44, 34, 40, 37,115, 37,115, 42,
+     41, 36, 34, 44, 34, 34, 41, 10, 32,114,101,116,117,114,110,
+     32,108, 10,101,110,100, 10, 10, 45, 45, 32,115,112,108,105,
+    116,115, 32, 97, 32,115,116,114,105,110,103, 32,117,115,105,
+    110,103, 32, 97, 32,112, 97,116,116,101,114,110, 44, 32, 99,
+    111,110,115,105,100,101,114,105,110,103, 32,116,104,101, 32,
+    115,112, 97, 99,105, 97,108, 32, 99, 97,115,101,115, 32,111,
+    102, 32, 67, 32, 99,111,100,101, 32, 40,116,101,109,112,108,
+     97,116,101,115, 44, 32,102,117,110, 99,116,105,111,110, 32,
+    112, 97,114, 97,109,101,116,101,114,115, 44, 32,101,116, 99,
+     41, 10, 45, 45, 32,112, 97,116,116,101,114,110, 32, 99, 97,
+    110, 39,116, 32, 99,111,110,116, 97,105,110, 32,116,104,101,
+     32, 39, 94, 39, 32, 40, 97,115, 32,117,115,101,100, 32,116,
+    111, 32,105,100,101,110,116,105,102,121, 32,116,104,101, 32,
+     98,101,103,105,110,105,110,103, 32,111,102, 32,116,104,101,
+     32,108,105,110,101, 41, 10, 45, 45, 32, 97,108,115,111, 32,
+    115,116,114,105,112,115, 32,119,104,105,116,101,115,112, 97,
+     99,101, 10,102,117,110, 99,116,105,111,110, 32,115,112,108,
+    105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44, 32,
+    112, 97,116, 41, 10, 10,  9,115, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,115, 44, 32, 34, 94, 37,115,
+     42, 34, 44, 32, 34, 34, 41, 10,  9,115, 32, 61, 32,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40,115, 44, 32, 34, 37,
+    115, 42, 36, 34, 44, 32, 34, 34, 41, 10, 10,  9,108,111, 99,
+     97,108, 32,116,111,107,101,110, 95, 98,101,103,105,110, 32,
+     61, 32, 49, 10,  9,108,111, 99, 97,108, 32,116,111,107,101,
+    110, 95,101,110,100, 32, 61, 32, 49, 10,  9,108,111, 99, 97,
+    108, 32,111,102,115, 32, 61, 32, 49, 10,  9,108,111, 99, 97,
+    108, 32,114,101,116, 32, 61, 32,123,110, 61, 48,125, 10, 10,
+      9,102,117,110, 99,116,105,111,110, 32, 97,100,100, 95,116,
+    111,107,101,110, 40,111,102,115, 41, 10, 10,  9,  9,108,111,
+     99, 97,108, 32,116, 32, 61, 32,115,116,114,105,110,103, 46,
+    115,117, 98, 40,115, 44, 32,116,111,107,101,110, 95, 98,101,
+    103,105,110, 44, 32,111,102,115, 41, 10,  9,  9,116, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,116, 44,
+     32, 34, 94, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,  9,  9,
+    116, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98,
+     40,116, 44, 32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, 41,
+     10,  9,  9,114,101,116, 46,110, 32, 61, 32,114,101,116, 46,
+    110, 32, 43, 32, 49, 10,  9,  9,114,101,116, 91,114,101,116,
+     46,110, 93, 32, 61, 32,116, 10,  9,101,110,100, 10, 10,  9,
+    119,104,105,108,101, 32,111,102,115, 32, 60, 61, 32,115,116,
+    114,105,110,103, 46,108,101,110, 40,115, 41, 32,100,111, 10,
+     10,  9,  9,108,111, 99, 97,108, 32,115,117, 98, 32, 61, 32,
+    115,116,114,105,110,103, 46,115,117, 98, 40,115, 44, 32,111,
+    102,115, 44, 32, 45, 49, 41, 10,  9,  9,108,111, 99, 97,108,
+     32, 98, 44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,115,117, 98, 44, 32, 34, 94, 34, 46, 46,112,
+     97,116, 41, 10,  9,  9,105,102, 32, 98, 32,116,104,101,110,
+     10,  9,  9,  9, 97,100,100, 95,116,111,107,101,110, 40,111,
+    102,115, 45, 49, 41, 10,  9,  9,  9,111,102,115, 32, 61, 32,
+    111,102,115, 43,101, 10,  9,  9,  9,116,111,107,101,110, 95,
+     98,101,103,105,110, 32, 61, 32,111,102,115, 10,  9,  9,101,
+    108,115,101, 10,  9,  9,  9,108,111, 99, 97,108, 32, 99,104,
+     97,114, 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98,
+     40,115, 44, 32,111,102,115, 44, 32,111,102,115, 41, 10,  9,
+      9,  9,105,102, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 40,
+     34, 32,111,114, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 60,
+     34, 32,116,104,101,110, 10, 10,  9,  9,  9,  9,108,111, 99,
+     97,108, 32, 98,108,111, 99,107, 10,  9,  9,  9,  9,105,102,
+     32, 99,104, 97,114, 32, 61, 61, 32, 34, 40, 34, 32,116,104,
+    101,110, 32, 98,108,111, 99,107, 32, 61, 32, 34, 94, 37, 98,
+     40, 41, 34, 32,101,110,100, 10,  9,  9,  9,  9,105,102, 32,
+     99,104, 97,114, 32, 61, 61, 32, 34, 60, 34, 32,116,104,101,
+    110, 32, 98,108,111, 99,107, 32, 61, 32, 34, 94, 37, 98, 60,
+     62, 34, 32,101,110,100, 10, 10,  9,  9,  9,  9, 98, 44,101,
+     32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    115,117, 98, 44, 32, 98,108,111, 99,107, 41, 10,  9,  9,  9,
+      9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10,
+      9,  9,  9,  9,  9, 45, 45, 32,117,110,116,101,114,109,105,
+    110, 97,116,101,100, 32, 98,108,111, 99,107, 63, 10,  9,  9,
+      9,  9,  9,111,102,115, 32, 61, 32,111,102,115, 43, 49, 10,
+      9,  9,  9,  9,101,108,115,101, 10,  9,  9,  9,  9,  9,111,
+    102,115, 32, 61, 32,111,102,115, 32, 43, 32,101, 10,  9,  9,
+      9,  9,101,110,100, 10, 10,  9,  9,  9,101,108,115,101, 10,
+      9,  9,  9,  9,111,102,115, 32, 61, 32,111,102,115, 43, 49,
+     10,  9,  9,  9,101,110,100, 10,  9,  9,101,110,100, 10, 10,
+      9,101,110,100, 10,  9, 97,100,100, 95,116,111,107,101,110,
+     40,111,102,115, 41, 10,  9, 45, 45,105,102, 32,114,101,116,
+     46,110, 32, 61, 61, 32, 48, 32,116,104,101,110, 10, 10,  9,
+     45, 45,  9,114,101,116, 46,110, 61, 49, 10,  9, 45, 45,  9,
+    114,101,116, 91, 49, 93, 32, 61, 32, 34, 34, 10,  9, 45, 45,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,114,101,
+    116, 10, 10,101,110,100, 10, 10, 45, 45, 32, 99,111,110, 99,
+     97,116,101,110, 97,116,101, 32,115,116,114,105,110,103,115,
+     32,111,102, 32, 97, 32,116, 97, 98,108,101, 10,102,117,110,
+     99,116,105,111,110, 32, 99,111,110, 99, 97,116, 32, 40,116,
+     44,102, 44,108, 44,106,115,116,114, 41, 10,  9,106,115,116,
+    114, 32, 61, 32,106,115,116,114, 32,111,114, 32, 34, 32, 34,
+     10, 32,108,111, 99, 97,108, 32,115, 32, 61, 32, 39, 39, 10,
+     32,108,111, 99, 97,108, 32,105, 61,102, 10, 32,119,104,105,
+    108,101, 32,105, 60, 61,108, 32,100,111, 10, 32, 32,115, 32,
+     61, 32,115, 46, 46,116, 91,105, 93, 10, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32, 32,105,102, 32,105, 32, 60, 61, 32,
+    108, 32,116,104,101,110, 32,115, 32, 61, 32,115, 46, 46,106,
+    115,116,114, 32,101,110,100, 10, 32,101,110,100, 10, 32,114,
+    101,116,117,114,110, 32,115, 10,101,110,100, 10, 10, 45, 45,
+     32, 99,111,110, 99, 97,116,101,110, 97,116,101, 32, 97,108,
+    108, 32,112, 97,114, 97,109,101,116,101,114,115, 44, 32,102,
+    111,108,108,111,119,105,110,103, 32,111,117,116,112,117,116,
+     32,114,117,108,101,115, 10,102,117,110, 99,116,105,111,110,
+     32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 32, 40,108,
+    105,110,101, 44, 32, 46, 46, 46, 41, 10, 32,108,111, 99, 97,
+    108, 32,105, 61, 49, 10, 32,119,104,105,108,101, 32,105, 60,
+     61, 97,114,103, 46,110, 32,100,111, 10, 32, 32,105,102, 32,
+     95, 99,111,110,116, 32, 97,110,100, 32,110,111,116, 32,115,
+    116,114,102,105,110,100, 40, 95, 99,111,110,116, 44, 39, 91,
+     37, 40, 44, 34, 93, 39, 41, 32, 97,110,100, 10, 32, 32, 32,
+     32, 32,115,116,114,102,105,110,100, 40, 97,114,103, 91,105,
+     93, 44, 34, 94, 91, 37, 97, 95,126, 93, 34, 41, 32,116,104,
+    101,110, 10,  9, 32, 32, 32, 32,108,105,110,101, 32, 61, 32,
+    108,105,110,101, 32, 46, 46, 32, 39, 32, 39, 10, 32, 32,101,
+    110,100, 10, 32, 32,108,105,110,101, 32, 61, 32,108,105,110,
+    101, 32, 46, 46, 32, 97,114,103, 91,105, 93, 10, 32, 32,105,
+    102, 32, 97,114,103, 91,105, 93, 32,126, 61, 32, 39, 39, 32,
+    116,104,101,110, 10, 32, 32, 32, 95, 99,111,110,116, 32, 61,
+     32,115,116,114,115,117, 98, 40, 97,114,103, 91,105, 93, 44,
+     45, 49, 44, 45, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,
+    105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,105,
+    102, 32,115,116,114,102,105,110,100, 40, 97,114,103, 91, 97,
+    114,103, 46,110, 93, 44, 34, 91, 37, 47, 37, 41, 37, 59, 37,
+    123, 37,125, 93, 36, 34, 41, 32,116,104,101,110, 10, 32, 32,
+     95, 99,111,110,116, 61,110,105,108, 32,108,105,110,101, 32,
+     61, 32,108,105,110,101, 32, 46, 46, 32, 39, 92,110, 39, 10,
+     32,101,110,100, 10,  9,114,101,116,117,114,110, 32,108,105,
+    110,101, 10,101,110,100, 10, 10, 45, 45, 32,111,117,116,112,
+    117,116, 32,108,105,110,101, 10,102,117,110, 99,116,105,111,
+    110, 32,111,117,116,112,117,116, 32, 40, 46, 46, 46, 41, 10,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,
+    108,101, 32,105, 60, 61, 97,114,103, 46,110, 32,100,111, 10,
+     32, 32,105,102, 32, 95, 99,111,110,116, 32, 97,110,100, 32,
+    110,111,116, 32,115,116,114,102,105,110,100, 40, 95, 99,111,
+    110,116, 44, 39, 91, 37, 40, 44, 34, 93, 39, 41, 32, 97,110,
+    100, 10, 32, 32, 32, 32, 32,115,116,114,102,105,110,100, 40,
+     97,114,103, 91,105, 93, 44, 34, 94, 91, 37, 97, 95,126, 93,
+     34, 41, 32,116,104,101,110, 10,  9, 32, 32, 32, 32,119,114,
+    105,116,101, 40, 39, 32, 39, 41, 10, 32, 32,101,110,100, 10,
+     32, 32,119,114,105,116,101, 40, 97,114,103, 91,105, 93, 41,
+     10, 32, 32,105,102, 32, 97,114,103, 91,105, 93, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,111,
+    110,116, 32, 61, 32,115,116,114,115,117, 98, 40, 97,114,103,
+     91,105, 93, 44, 45, 49, 44, 45, 49, 41, 10, 32, 32,101,110,
+    100, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,
+    100, 10, 32,105,102, 32,115,116,114,102,105,110,100, 40, 97,
+    114,103, 91, 97,114,103, 46,110, 93, 44, 34, 91, 37, 47, 37,
+     41, 37, 59, 37,123, 37,125, 93, 36, 34, 41, 32,116,104,101,
+    110, 10, 32, 32, 95, 99,111,110,116, 61,110,105,108, 32,119,
+    114,105,116,101, 40, 39, 92,110, 39, 41, 10, 32,101,110,100,
+     10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
+    103,101,116, 95,112,114,111,112,101,114,116,121, 95,109,101,
+    116,104,111,100,115, 40,112,116,121,112,101, 44, 32,110, 97,
+    109,101, 41, 10, 10,  9,105,102, 32,103,101,116, 95,112,114,
+    111,112,101,114,116,121, 95,109,101,116,104,111,100,115, 95,
+    104,111,111,107, 32, 97,110,100, 32,103,101,116, 95,112,114,
+    111,112,101,114,116,121, 95,109,101,116,104,111,100,115, 95,
+    104,111,111,107, 40,112,116,121,112,101, 44,110, 97,109,101,
+     41, 32,116,104,101,110, 10,  9,  9,114,101,116,117,114,110,
+     32,103,101,116, 95,112,114,111,112,101,114,116,121, 95,109,
+    101,116,104,111,100,115, 95,104,111,111,107, 40,112,116,121,
+    112,101, 44, 32,110, 97,109,101, 41, 10,  9,101,110,100, 10,
+     10,  9,105,102, 32,112,116,121,112,101, 32, 61, 61, 32, 34,
+    100,101,102, 97,117,108,116, 34, 32,116,104,101,110, 32, 45,
+     45, 32,103,101,116, 95,110, 97,109,101, 44, 32,115,101,116,
+     95,110, 97,109,101, 10,  9,  9,114,101,116,117,114,110, 32,
+     34,103,101,116, 95, 34, 46, 46,110, 97,109,101, 44, 32, 34,
+    115,101,116, 95, 34, 46, 46,110, 97,109,101, 10,  9,101,110,
+    100, 10, 10,  9,105,102, 32,112,116,121,112,101, 32, 61, 61,
+     32, 34,113,116, 34, 32,116,104,101,110, 32, 45, 45, 32,110,
+     97,109,101, 44, 32,115,101,116, 78, 97,109,101, 10,  9,  9,
+    114,101,116,117,114,110, 32,110, 97,109,101, 44, 32, 34,115,
+    101,116, 34, 46, 46,115,116,114,105,110,103, 46,117,112,112,
+    101,114, 40,115,116,114,105,110,103, 46,115,117, 98, 40,110,
+     97,109,101, 44, 32, 49, 44, 32, 49, 41, 41, 46, 46,115,116,
+    114,105,110,103, 46,115,117, 98, 40,110, 97,109,101, 44, 32,
+     50, 44, 32, 45, 49, 41, 10,  9,101,110,100, 10, 10,  9,105,
+    102, 32,112,116,121,112,101, 32, 61, 61, 32, 34,111,118,101,
+    114,108,111, 97,100, 34, 32,116,104,101,110, 32, 45, 45, 32,
+    110, 97,109,101, 44, 32,110, 97,109,101, 10,  9,  9,114,101,
+    116,117,114,110, 32,110, 97,109,101, 44,110, 97,109,101, 10,
+      9,101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,110,
+    105,108, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 32,116,104,101, 32,104,111,111,
+    107,115, 10, 10, 45, 45, 32, 99, 97,108,108,101,100, 32,114,
+    105,103,104,116, 32, 97,102,116,101,114, 32,112,114,111, 99,
+    101,115,115,105,110,103, 32,116,104,101, 32, 36, 91,105, 99,
+    104,108, 93,102,105,108,101, 32,100,105,114,101, 99,116,105,
+    118,101,115, 44, 10, 45, 45, 32,114,105,103,104,116, 32, 98,
+    101,102,111,114,101, 32,112,114,111, 99,101,115,115,105,110,
+    103, 32, 97,110,121,116,104,105,110,103, 32,101,108,115,101,
+     10, 45, 45, 32,116, 97,107,101,115, 32,116,104,101, 32,112,
+     97, 99,107, 97,103,101, 32,111, 98,106,101, 99,116, 32, 97,
+    115, 32,116,104,101, 32,112, 97,114, 97,109,101,116,101,114,
+     10,102,117,110, 99,116,105,111,110, 32,112,114,101,112,114,
+    111, 99,101,115,115, 95,104,111,111,107, 40,112, 41, 10,  9,
+     45, 45, 32,112, 46, 99,111,100,101, 32,104, 97,115, 32, 97,
+    108,108, 32,116,104,101, 32,105,110,112,117,116, 32, 99,111,
+    100,101, 32,102,114,111,109, 32,116,104,101, 32,112,107,103,
+     10,101,110,100, 10, 10, 10, 45, 45, 32, 99, 97,108,108,101,
+    100, 32,102,111,114, 32,101,118,101,114,121, 32, 36,105,102,
+    105,108,101, 32,100,105,114,101, 99,116,105,118,101, 10, 45,
+     45, 32,116, 97,107,101,115, 32, 97, 32,116, 97, 98,108,101,
+     32,119,105,116,104, 32, 97, 32,115,116,114,105,110,103, 32,
+     99, 97,108,108,101,100, 32, 39, 99,111,100,101, 39, 32,105,
+    110,115,105,100,101, 44, 32,116,104,101, 32,102,105,108,101,
+    110, 97,109,101, 44, 32, 97,110,100, 32, 97,110,121, 32,101,
+    120,116,114, 97, 32, 97,114,103,117,109,101,110,116,115, 10,
+     45, 45, 32,112, 97,115,115,101,100, 32,116,111, 32, 36,105,
+    102,105,108,101, 46, 32,110,111, 32,114,101,116,117,114,110,
+     32,118, 97,108,117,101, 10,102,117,110, 99,116,105,111,110,
+     32,105,110, 99,108,117,100,101, 95,102,105,108,101, 95,104,
+    111,111,107, 40,116, 44, 32,102,105,108,101,110, 97,109,101,
+     44, 32, 46, 46, 46, 41, 10, 10,101,110,100, 10, 10, 45, 45,
+     32, 99, 97,108,108,101,100, 32, 97,102,116,101,114, 32,112,
+    114,111, 99,101,115,115,105,110,103, 32, 97,110,121,116,104,
+    105,110,103, 32,116,104, 97,116, 39,115, 32,110,111,116, 32,
+     99,111,100,101, 32, 40,108,105,107,101, 32, 39, 36,114,101,
+    110, 97,109,105,110,103, 39, 44, 32, 99,111,109,109,101,110,
+    116,115, 44, 32,101,116, 99, 41, 10, 45, 45, 32, 97,110,100,
+     32,114,105,103,104,116, 32, 98,101,102,111,114,101, 32,112,
+     97,114,115,105,110,103, 32,116,104,101, 32, 97, 99,116,117,
+     97,108, 32, 99,111,100,101, 46, 10, 45, 45, 32,116, 97,107,
+    101,115, 32,116,104,101, 32, 80, 97, 99,107, 97,103,101, 32,
+    111, 98,106,101, 99,116, 32,119,105,116,104, 32, 97,108,108,
+     32,116,104,101, 32, 99,111,100,101, 32,111,110, 32,116,104,
+    101, 32, 39, 99,111,100,101, 39, 32,107,101,121, 46, 32,110,
+    111, 32,114,101,116,117,114,110, 32,118, 97,108,117,101, 10,
+    102,117,110, 99,116,105,111,110, 32,112,114,101,112, 97,114,
+    115,101, 95,104,111,111,107, 40,112, 97, 99,107, 97,103,101,
+     41, 10, 10,101,110,100, 10, 10, 10, 45, 45, 32, 99, 97,108,
+    108,101,100, 32, 97,102,116,101,114, 32,119,114,105,116,105,
+    110,103, 32, 97,108,108, 32,116,104,101, 32,111,117,116,112,
+    117,116, 46, 10, 45, 45, 32,116, 97,107,101,115, 32,116,104,
+    101, 32, 80, 97, 99,107, 97,103,101, 32,111, 98,106,101, 99,
+    116, 10,102,117,110, 99,116,105,111,110, 32,112,111,115,116,
+     95,111,117,116,112,117,116, 95,104,111,111,107, 40,112, 97,
+     99,107, 97,103,101, 41, 10, 10,101,110,100, 10, 10, 10, 45,
+     45, 32, 99, 97,108,108,101,100, 32,102,114,111,109, 32, 39,
+    103,101,116, 95,112,114,111,112,101,114,116,121, 95,109,101,
+    116,104,111,100,115, 39, 32,116,111, 32,103,101,116, 32,116,
+    104,101, 32,109,101,116,104,111,100,115, 32,116,111, 32,114,
+    101,116,114,105,101,118,101, 32, 97, 32,112,114,111,112,101,
+    114,116,121, 10, 45, 45, 32, 97, 99, 99,111,114,100,105,110,
+    103, 32,116,111, 32,105,116,115, 32,116,121,112,101, 10,102,
+    117,110, 99,116,105,111,110, 32,103,101,116, 95,112,114,111,
+    112,101,114,116,121, 95,109,101,116,104,111,100,115, 95,104,
+    111,111,107, 40,112,114,111,112,101,114,116,121, 95,116,121,
+    112,101, 44, 32,110, 97,109,101, 41, 10, 10,101,110,100, 10,
+     10, 45, 45, 32, 99, 97,108,108,101,100, 32,102,114,111,109,
+     32, 67,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     58,100,111,112, 97,114,115,101, 32,119,105,116,104, 32,116,
+    104,101, 32,115,116,114,105,110,103, 32, 98,101,105,110,103,
+     32,112, 97,114,115,101,100, 10, 45, 45, 32,114,101,116,117,
+    114,110, 32,110,105,108, 44, 32,111,114, 32, 97, 32,115,117,
+     98,115,116,114,105,110,103, 10,102,117,110, 99,116,105,111,
+    110, 32,112, 97,114,115,101,114, 95,104,111,111,107, 40,115,
+     41, 10, 10,  9,114,101,116,117,114,110, 32,110,105,108, 10,
+    101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/basic.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 97, 98,115,116,114,
+     97, 99,116, 32,102,101, 97,116,117,114,101, 32, 99,108, 97,
+    115,115, 10, 45, 45, 32, 87,114,105,116,116,101,110, 32, 98,
+    121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,108,101,
+    115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47, 80, 85,
+     67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32, 49, 57,
+     57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10, 10, 45,
+     45, 32, 84,104,105,115, 32, 99,111,100,101, 32,105,115, 32,
+    102,114,101,101, 32,115,111,102,116,119, 97,114,101, 59, 32,
+    121,111,117, 32, 99, 97,110, 32,114,101,100,105,115,116,114,
+    105, 98,117,116,101, 32,105,116, 32, 97,110,100, 47,111,114,
+     32,109,111,100,105,102,121, 32,105,116, 46, 10, 45, 45, 32,
+     84,104,101, 32,115,111,102,116,119, 97,114,101, 32,112,114,
+    111,118,105,100,101,100, 32,104,101,114,101,117,110,100,101,
+    114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, 97,115, 32,
+    105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,110,100, 10,
+     45, 45, 32,116,104,101, 32, 97,117,116,104,111,114, 32,104,
+     97,115, 32,110,111, 32,111, 98,108,105,103, 97,116,105,111,
+    110, 32,116,111, 32,112,114,111,118,105,100,101, 32,109, 97,
+    105,110,116,101,110, 97,110, 99,101, 44, 32,115,117,112,112,
+    111,114,116, 44, 32,117,112,100, 97,116,101,115, 44, 10, 45,
+     45, 32,101,110,104, 97,110, 99,101,109,101,110,116,115, 44,
+     32,111,114, 32,109,111,100,105,102,105, 99, 97,116,105,111,
+    110,115, 46, 10, 10, 10, 45, 45, 32, 70,101, 97,116,117,114,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,
+    101,115,101,110,116,115, 32,116,104,101, 32, 98, 97,115,101,
+     32, 99,108, 97,115,115, 32,111,102, 32, 97,108,108, 32,109,
+     97,112,112,101,100, 32,102,101, 97,116,117,114,101, 46, 10,
+     99,108, 97,115,115, 70,101, 97,116,117,114,101, 32, 61, 32,
+    123, 10,125, 10, 99,108, 97,115,115, 70,101, 97,116,117,114,
+    101, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,
+    115,115, 70,101, 97,116,117,114,101, 10, 10, 45, 45, 32,119,
+    114,105,116,101, 32,115,117,112,112,111,114,116, 32, 99,111,
+    100,101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 70,101, 97,116,117,114,101, 58,115,117,112, 99,111,
+    100,101, 32, 40, 41, 10,101,110,100, 10, 10, 45, 45, 32,111,
+    117,116,112,117,116, 32,116, 97,103, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,
+    101, 58,100,101, 99,108,116,121,112,101, 32, 40, 41, 10,101,
+    110,100, 10, 10, 45, 45, 32,114,101,103,105,115,116,101,114,
+     32,102,101, 97,116,117,114,101, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101,
+     58,114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41,
+     10,101,110,100, 10, 10, 45, 45, 32,116,114, 97,110,115,108,
+     97,116,101, 32,118,101,114, 98, 97,116,105,109, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,
+    116,117,114,101, 58,112,114,101, 97,109, 98,108,101, 32, 40,
+     41, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107,
+     32,105,102, 32,105,116, 32,105,115, 32, 97, 32,118, 97,114,
+    105, 97, 98,108,101, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,105,115,
+    118, 97,114,105, 97, 98,108,101, 32, 40, 41, 10, 32,114,101,
+    116,117,114,110, 32,102, 97,108,115,101, 10,101,110,100, 10,
+     10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,105,116,
+     32,114,101,113,117,105,114,101,115, 32, 99,111,108,108,101,
+     99,116,105,111,110, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,114,101,
+    113,117,105,114,101, 99,111,108,108,101, 99,116,105,111,110,
+     32, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,102, 97,
+    108,115,101, 10,101,110,100, 10, 10, 45, 45, 32, 98,117,105,
+    108,100, 32,110, 97,109,101,115, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101,
+     58, 98,117,105,108,100,110, 97,109,101,115, 32, 40, 41, 10,
+     32,105,102, 32,115,101,108,102, 46,110, 97,109,101, 32, 97,
+    110,100, 32,115,101,108,102, 46,110, 97,109,101,126, 61, 39,
+     39, 32,116,104,101,110, 10, 32, 32,108,111, 99, 97,108, 32,
+    110, 32, 61, 32,115,112,108,105,116, 40,115,101,108,102, 46,
+    110, 97,109,101, 44, 39, 64, 39, 41, 10, 32, 32,115,101,108,
+    102, 46,110, 97,109,101, 32, 61, 32,110, 91, 49, 93, 10, 32,
+     32,105,102, 32,110,111,116, 32,110, 91, 50, 93, 32,116,104,
+    101,110, 10, 32, 32, 32,110, 91, 50, 93, 32, 61, 32, 97,112,
+    112,108,121,114,101,110, 97,109,105,110,103, 40,110, 91, 49,
+     93, 41, 10, 32, 32,101,110,100, 10, 32, 32,115,101,108,102,
+     46,108,110, 97,109,101, 32, 61, 32,110, 91, 50, 93, 32,111,
+    114, 32,103,115,117, 98, 40,110, 91, 49, 93, 44, 34, 37, 91,
+     46, 45, 37, 93, 34, 44, 34, 34, 41, 10, 32, 32,115,101,108,
+    102, 46,111,114,105,103,105,110, 97,108, 95,110, 97,109,101,
+     32, 61, 32,115,101,108,102, 46,110, 97,109,101, 10, 32, 32,
+    115,101,108,102, 46,108,110, 97,109,101, 32, 61, 32, 99,108,
+    101, 97,110, 95,116,101,109,112,108, 97,116,101, 40,115,101,
+    108,102, 46,108,110, 97,109,101, 41, 10, 32,101,110,100, 10,
+     32,105,102, 32,110,111,116, 32,115,101,108,102, 46,105,115,
+     95,112, 97,114, 97,109,101,116,101,114, 32,116,104,101,110,
+     10,  9, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 32,
+    103,101,116,111,110,108,121,110, 97,109,101,115,112, 97, 99,
+    101, 40, 41, 32, 46, 46, 32,115,101,108,102, 46,110, 97,109,
+    101, 10, 32,101,110,100, 10, 10, 32,108,111, 99, 97,108, 32,
+    112, 97,114,101,110,116, 32, 61, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 10, 32,
+    105,102, 32,112, 97,114,101,110,116, 32,116,104,101,110, 10,
+     32,  9,115,101,108,102, 46, 97, 99, 99,101,115,115, 32, 61,
+     32,112, 97,114,101,110,116, 46, 99,117,114,114, 95,109,101,
+    109, 98,101,114, 95, 97, 99, 99,101,115,115, 10, 32,101,108,
+    115,101, 10, 32,101,110,100, 10,101,110,100, 10, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,
+    116,117,114,101, 58, 99,104,101, 99,107, 95,112,117, 98,108,
+    105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 10, 10,  9,105,
+    102, 32,115,101,108,102, 46, 97, 99, 99,101,115,115, 32, 97,
+    110,100, 32,115,101,108,102, 46, 97, 99, 99,101,115,115, 32,
+    126, 61, 32, 48, 32,116,104,101,110, 10,  9,  9,114,101,116,
+    117,114,110, 32,102, 97,108,115,101, 10,  9,101,110,100, 10,
+     10,  9,108,111, 99, 97,108, 32,112, 97,114,101,110,116, 32,
+     61, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 46, 99,117,114,114, 10,  9,119,104,105,108,101, 32,112,
+     97,114,101,110,116, 32,100,111, 10,  9,  9,105,102, 32,112,
+     97,114,101,110,116, 46, 97, 99, 99,101,115,115, 32, 97,110,
+    100, 32,112, 97,114,101,110,116, 46, 97, 99, 99,101,115,115,
+     32,126, 61, 32, 48, 32,116,104,101,110, 10,  9,  9,  9,114,
+    101,116,117,114,110, 32,102, 97,108,115,101, 10,  9,  9,101,
+    110,100, 10,  9,  9,112, 97,114,101,110,116, 32, 61, 32,112,
+     97,114,101,110,116, 46,112,114,111,120, 10,  9,101,110,100,
+     10,  9,114,101,116,117,114,110, 32,116,114,117,101, 10,101,
+    110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+    101, 97,110, 95,116,101,109,112,108, 97,116,101, 40,116, 41,
+     10, 10,  9,114,101,116,117,114,110, 32,115,116,114,105,110,
+    103, 46,103,115,117, 98, 40,116, 44, 32, 34, 91, 60, 62, 58,
+     44, 32, 37, 42, 93, 34, 44, 32, 34, 95, 34, 41, 10,101,110,
+    100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    102,101, 97,116,117,114,101, 32,105,115, 32,105,110,115,105,
+    100,101, 32, 97, 32, 99,111,110,116, 97,105,110,101,114, 32,
+    100,101,102,105,110,105,116,105,111,110, 10, 45, 45, 32,105,
+    116, 32,114,101,116,117,114,110,115, 32,116,104,101, 32, 99,
+    111,110,116, 97,105,110,101,114, 32, 99,108, 97,115,115, 32,
+    110, 97,109,101, 32,111,114, 32,110,105,108, 46, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,
+    116,117,114,101, 58,105,110, 99,111,110,116, 97,105,110,101,
+    114, 32, 40,119,104,105, 99,104, 41, 10, 32,105,102, 32,115,
+    101,108,102, 46,112, 97,114,101,110,116, 32,116,104,101,110,
+     10, 32, 32,108,111, 99, 97,108, 32,112, 97,114,101,110,116,
+     32, 61, 32,115,101,108,102, 46,112, 97,114,101,110,116, 10,
+     32, 32,119,104,105,108,101, 32,112, 97,114,101,110,116, 32,
+    100,111, 10, 32, 32, 32,105,102, 32,112, 97,114,101,110,116,
+     46, 99,108, 97,115,115,116,121,112,101, 32, 61, 61, 32,119,
+    104,105, 99,104, 32,116,104,101,110, 10, 32, 32, 32, 32,114,
+    101,116,117,114,110, 32,112, 97,114,101,110,116, 46,110, 97,
+    109,101, 10, 32, 32, 32,101,110,100, 10, 32, 32, 32,112, 97,
+    114,101,110,116, 32, 61, 32,112, 97,114,101,110,116, 46,112,
+     97,114,101,110,116, 10, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 32,114,101,116,117,114,110, 32,110,105,108, 10,101,
+    110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 70,101, 97,116,117,114,101, 58,105,110, 99,108,
+     97,115,115, 32, 40, 41, 10, 32,114,101,116,117,114,110, 32,
+    115,101,108,102, 58,105,110, 99,111,110,116, 97,105,110,101,
+    114, 40, 39, 99,108, 97,115,115, 39, 41, 10,101,110,100, 10,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     70,101, 97,116,117,114,101, 58,105,110,109,111,100,117,108,
+    101, 32, 40, 41, 10, 32,114,101,116,117,114,110, 32,115,101,
+    108,102, 58,105,110, 99,111,110,116, 97,105,110,101,114, 40,
+     39,109,111,100,117,108,101, 39, 41, 10,101,110,100, 10, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,
+    101, 97,116,117,114,101, 58,105,110,110, 97,109,101,115,112,
+     97, 99,101, 32, 40, 41, 10, 32,114,101,116,117,114,110, 32,
+    115,101,108,102, 58,105,110, 99,111,110,116, 97,105,110,101,
+    114, 40, 39,110, 97,109,101,115,112, 97, 99,101, 39, 41, 10,
+    101,110,100, 10, 10, 45, 45, 32,114,101,116,117,114,110, 32,
+     67, 32, 98,105,110,100,105,110,103, 32,102,117,110, 99,116,
+    105,111,110, 32,110, 97,109,101, 32, 98, 97,115,101,100, 32,
+    111,110, 32,110, 97,109,101, 10, 45, 45, 32,116,104,101, 32,
+     99,108,105,101,110,116, 32,115,112,101, 99,105,102,105,101,
+    115, 32, 97, 32,112,114,101,102,105,120, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,
+    114,101, 58, 99,102,117,110, 99,110, 97,109,101, 32, 40,110,
+     41, 10, 10, 32,105,102, 32,115,101,108,102, 46,112, 97,114,
+    101,110,116, 32,116,104,101,110, 10, 32, 32,110, 32, 61, 32,
+    115,101,108,102, 46,112, 97,114,101,110,116, 58, 99,102,117,
+    110, 99,110, 97,109,101, 40,110, 41, 10, 32,101,110,100, 10,
+     10, 32, 32,110, 32, 61, 32,115,116,114,105,110,103, 46,103,
+    115,117, 98, 40,110, 46, 46, 39, 95, 39, 46, 46, 32, 40,115,
+    101,108,102, 46,108,110, 97,109,101, 32,111,114, 32,115,101,
+    108,102, 46,110, 97,109,101, 41, 44, 32, 34, 91, 60, 62, 58,
+     44, 32, 92, 46, 37, 42, 38, 93, 34, 44, 32, 34, 95, 34, 41,
+     10, 10, 32, 32,114,101,116,117,114,110, 32,110, 10,101,110,
+    100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/feature.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,118,101,114, 98, 97,
+    116,105,109, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32,118,101,114, 98, 97,116,105,109, 46,108,117, 97,
+     44,118, 32, 49, 46, 51, 32, 50, 48, 48, 48, 47, 48, 49, 47,
+     50, 52, 32, 50, 48, 58, 52, 49, 58, 49, 54, 32, 99,101,108,
+    101,115, 32, 69,120,112, 32, 36, 10, 10, 45, 45, 32, 84,104,
+    105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101,
+     32,115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32,
+     99, 97,110, 32,114,101,100,105,115,116,114,105, 98,117,116,
+    101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100,
+    105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,
+    115,111,102,116,119, 97,114,101, 32,112,114,111,118,105,100,
+    101,100, 32,104,101,114,101,117,110,100,101,114, 32,105,115,
+     32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32,
+     98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,
+    104,101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110,
+    111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111,
+     32,112,114,111,118,105,100,101, 32,109, 97,105,110,116,101,
+    110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44,
+     32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,
+    104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32,
+    109,111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10,
+     10, 10, 10, 45, 45, 32, 86,101,114, 98, 97,116,105,109, 32,
+     99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,115,
+    101,110,116,115, 32, 97, 32,108,105,110,101, 32,116,114, 97,
+    110,115,108, 97,116,101,100, 32,100,105,114,101, 99,116,101,
+    100, 32,116,111, 32,116,104,101, 32, 98,105,110,100,105,110,
+    103, 32,102,105,108,101, 46, 10, 45, 45, 32, 84,104,101, 32,
+    102,111,108,108,111,119,105,110,103, 32,102,105,108,100,115,
+     32, 97,114,101, 32,115,116,111,114,101,100, 58, 10, 45, 45,
+     32, 32, 32,108,105,110,101, 32, 61, 32,108,105,110,101, 32,
+    116,101,120,116, 10, 99,108, 97,115,115, 86,101,114, 98, 97,
+    116,105,109, 32, 61, 32,123, 10, 32,108,105,110,101, 32, 61,
+     32, 39, 39, 44, 10,  9, 99,111,110,100, 32, 61, 32,110,105,
+    108, 44, 32, 32, 32, 32, 45, 45, 32, 99,111,110,100,105,116,
+    105,111,110, 58, 32,119,104,101,114,101, 32,116,111, 32,103,
+    101,110,101,114, 97,116,101, 32,116,104,101, 32, 99,111,100,
+    101, 32, 40,115, 61,115,117,112,111,114,116, 44, 32,114, 61,
+    114,101,103,105,115,116,101,114, 41, 10,125, 10, 99,108, 97,
+    115,115, 86,101,114, 98, 97,116,105,109, 46, 95, 95,105,110,
+    100,101,120, 32, 61, 32, 99,108, 97,115,115, 86,101,114, 98,
+     97,116,105,109, 10,115,101,116,109,101,116, 97,116, 97, 98,
+    108,101, 40, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,
+    109, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 41,
+     10, 10, 45, 45, 32,112,114,101, 97,109, 98,108,101, 32,118,
+    101,114, 98, 97,116,105,109, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,109,
+     58,112,114,101, 97,109, 98,108,101, 32, 40, 41, 10, 32,105,
+    102, 32,115,101,108,102, 46, 99,111,110,100, 32, 61, 61, 32,
+     39, 39, 32,116,104,101,110, 10, 32, 32,119,114,105,116,101,
+     40,115,101,108,102, 46,108,105,110,101, 41, 10, 32,101,110,
+    100, 10,101,110,100, 10, 10, 45, 45, 32,115,117,112,112,111,
+    114,116, 32, 99,111,100,101, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,109,
+     58,115,117,112, 99,111,100,101, 32, 40, 41, 10, 32,105,102,
+     32,115,116,114,102,105,110,100, 40,115,101,108,102, 46, 99,
+    111,110,100, 44, 39,115, 39, 41, 32,116,104,101,110, 10, 32,
+     32,119,114,105,116,101, 40,115,101,108,102, 46,108,105,110,
+    101, 41, 10, 32, 32,119,114,105,116,101, 40, 39, 92,110, 39,
+     41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+    114,101,103,105,115,116,101,114, 32, 99,111,100,101, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 86,101,
+    114, 98, 97,116,105,109, 58,114,101,103,105,115,116,101,114,
+     32, 40,112,114,101, 41, 10, 32,105,102, 32,115,116,114,102,
+    105,110,100, 40,115,101,108,102, 46, 99,111,110,100, 44, 39,
+    114, 39, 41, 32,116,104,101,110, 10, 32, 32,119,114,105,116,
+    101, 40,115,101,108,102, 46,108,105,110,101, 41, 10, 32,101,
+    110,100, 10,101,110,100, 10, 10, 10, 45, 45, 32, 80,114,105,
+    110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,
+    105,109, 58,112,114,105,110,116, 32, 40,105,100,101,110,116,
+     44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 86,101,114, 98, 97,116,105,
+    109,123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,108,105,110,101, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,108,105,110,101, 46, 46, 34, 39,
+     44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,
+    101,110,100, 10, 10, 10, 45, 45, 32, 73,110,116,101,114,110,
+     97,108, 32, 99,111,110,115,116,114,117, 99,116,111,114, 10,
+    102,117,110, 99,116,105,111,110, 32, 95, 86,101,114, 98, 97,
+    116,105,109, 32, 40,116, 41, 10, 32,115,101,116,109,101,116,
+     97,116, 97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 86,
+    101,114, 98, 97,116,105,109, 41, 10, 32, 97,112,112,101,110,
+    100, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,116, 10,
+    101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116,114,117,
+     99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99,116,115,
+     32, 97, 32,115,116,114,105,110,103, 32,114,101,112,114,101,
+    115,101,110,116,105,110,103, 32,116,104,101, 32,116,101,120,
+    116, 32,108,105,110,101, 10,102,117,110, 99,116,105,111,110,
+     32, 86,101,114, 98, 97,116,105,109, 32, 40,108, 44, 99,111,
+    110,100, 41, 10, 32,105,102, 32,115,116,114,115,117, 98, 40,
+    108, 44, 49, 44, 49, 41, 32, 61, 61, 32, 34, 39, 34, 32,116,
+    104,101,110, 10, 32, 32,108, 32, 61, 32,115,116,114,115,117,
+     98, 40,108, 44, 50, 41, 10, 32,101,108,115,101,105,102, 32,
+    115,116,114,115,117, 98, 40,108, 44, 49, 44, 49, 41, 32, 61,
+     61, 32, 39, 36, 39, 32,116,104,101,110, 10, 32, 32, 99,111,
+    110,100, 32, 61, 32, 39,115,114, 39, 32, 32, 32, 32, 32, 32,
+     32, 45, 45, 32,103,101,110,101,114, 97,116,101,115, 32,105,
+    110, 32, 98,111,116,104, 32,115,117,112,111,114,116, 32, 97,
+    110,100, 32,114,101,103,105,115,116,101,114, 32,102,114, 97,
+    103,109,101,110,116,115, 10, 32, 32,108, 32, 61, 32,115,116,
+    114,115,117, 98, 40,108, 44, 50, 41, 10, 32,101,110,100, 10,
+     32,114,101,116,117,114,110, 32, 95, 86,101,114, 98, 97,116,
+    105,109, 32,123, 10, 32, 32,108,105,110,101, 32, 61, 32,108,
+     44, 10, 32, 32, 99,111,110,100, 32, 61, 32, 99,111,110,100,
+     32,111,114, 32, 39, 39, 44, 10, 32,125, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/verbatim.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 99,111,100,101, 32,
+     99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,101,
+    110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,
+    101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102,
+     47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108,
+     32, 49, 57, 57, 57, 10, 45, 45, 32, 36, 73,100, 58, 32, 36,
+     10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,
+    105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114,
+    101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105,
+    115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100,
+     47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10,
+     45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101,
+     32,112,114,111,118,105,100,101,100, 32,104,101,114,101,117,
+    110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34,
+     97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,
+    110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111,
+    114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97,
+    116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,101,
+     32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115,
+    117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115,
+     44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110,
+    116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97,
+    116,105,111,110,115, 46, 10, 10, 45, 45, 32,103,108,111, 98,
+     97,108, 10, 99,111,100,101, 95,110, 32, 61, 32, 49, 10, 10,
+     45, 45, 32, 67,111,100,101, 32, 99,108, 97,115,115, 10, 45,
+     45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 76,117,
+     97, 32, 99,111,100,101, 32,116,111, 32, 98,101, 32, 99,111,
+    109,112,105,108,101,100, 32, 97,110,100, 32,105,110, 99,108,
+    117,100,101,100, 10, 45, 45, 32,105,110, 32,116,104,101, 32,
+    105,110,105,116,105, 97,108,105,122, 97,116,105,111,110, 32,
+    102,117,110, 99,116,105,111,110, 46, 10, 45, 45, 32, 84,104,
+    101, 32,102,111,108,108,111,119,105,110,103, 32,102,105,101,
+    108,100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58,
+     10, 45, 45, 32, 32, 32,116,101,120,116, 32, 61, 32,116,101,
+    120,116, 32, 99,111,100,101, 10, 99,108, 97,115,115, 67,111,
+    100,101, 32, 61, 32,123, 10, 32,116,101,120,116, 32, 61, 32,
+     39, 39, 44, 10,125, 10, 99,108, 97,115,115, 67,111,100,101,
+     46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115,
+    115, 67,111,100,101, 10,115,101,116,109,101,116, 97,116, 97,
+     98,108,101, 40, 99,108, 97,115,115, 67,111,100,101, 44, 99,
+    108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10, 10, 45,
+     45, 32,114,101,103,105,115,116,101,114, 32, 99,111,100,101,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     67,111,100,101, 58,114,101,103,105,115,116,101,114, 32, 40,
+    112,114,101, 41, 10, 32,112,114,101, 32, 61, 32,112,114,101,
+     32,111,114, 32, 39, 39, 10, 32, 45, 45, 32, 99,108,101, 97,
+    110, 32, 76,117, 97, 32, 99,111,100,101, 10, 32,108,111, 99,
+     97,108, 32,115, 32, 61, 32, 99,108,101, 97,110, 40,115,101,
+    108,102, 46,116,101,120,116, 41, 10, 32,105,102, 32,110,111,
+    116, 32,115, 32,116,104,101,110, 10, 32, 32, 45, 45,112,114,
+    105,110,116, 40,115,101,108,102, 46,116,101,120,116, 41, 10,
+     32, 32,101,114,114,111,114, 40, 34,112, 97,114,115,101,114,
+     32,101,114,114,111,114, 32,105,110, 32,101,109, 98,101,100,
+    100,101,100, 32, 99,111,100,101, 34, 41, 10, 32,101,110,100,
+     10, 10, 32, 45, 45, 32,103,101,116, 32,102,105,114,115,116,
+     32,108,105,110,101, 10, 32,108,111, 99, 97,108, 32, 95, 44,
+     32, 95, 44, 32,102,105,114,115,116, 95,108,105,110,101, 61,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,115,101,108,
+    102, 46,116,101,120,116, 44, 32, 34, 94, 40, 91, 94, 92,110,
+     92,114, 93, 42, 41, 34, 41, 10, 32,105,102, 32,115,116,114,
+    105,110,103, 46,102,105,110,100, 40,102,105,114,115,116, 95,
+    108,105,110,101, 44, 32, 34, 94, 37,115, 42, 37, 45, 37, 45,
+     34, 41, 32,116,104,101,110, 10,  9, 32,105,102, 32,115,116,
+    114,105,110,103, 46,102,105,110,100, 40,102,105,114,115,116,
+     95,108,105,110,101, 44, 32, 34, 94, 37, 45, 37, 45, 35, 35,
+     34, 41, 32,116,104,101,110, 10,  9,  9,102,105,114,115,116,
+     95,108,105,110,101, 32, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40,102,105,114,115,116, 95,108,105,110,101,
+     44, 32, 34, 94, 37, 45, 37, 45, 35, 35, 34, 44, 32, 34, 34,
+     41, 10,  9,  9,105,102, 32,102,108, 97,103,115, 91, 39, 67,
+     39, 93, 32,116,104,101,110, 10,  9,  9,  9,115, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44, 32,
+     34, 94, 37, 45, 37, 45, 35, 35, 91, 94, 92,110, 92,114, 93,
+     42, 92,110, 34, 44, 32, 34, 34, 41, 10,  9,  9,101,110,100,
+     10,  9, 32,101,110,100, 10, 32,101,108,115,101, 10, 32,  9,
+    102,105,114,115,116, 95,108,105,110,101, 32, 61, 32, 34, 34,
+     10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,111,110,118,
+    101,114,116, 32,116,111, 32, 67, 10, 32,111,117,116,112,117,
+    116, 40, 39, 92,110, 39, 46, 46,112,114,101, 46, 46, 39,123,
+     32, 47, 42, 32, 98,101,103,105,110, 32,101,109, 98,101,100,
+    100,101,100, 32,108,117, 97, 32, 99,111,100,101, 32, 42, 47,
+     92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40,112,114,
+    101, 46, 46, 39, 32,105,110,116, 32,116,111,112, 32, 61, 32,
+    108,117, 97, 95,103,101,116,116,111,112, 40,116,111,108,117,
+     97, 95, 83, 41, 59, 39, 41, 10, 32,111,117,116,112,117,116,
+     40,112,114,101, 46, 46, 39, 32,115,116, 97,116,105, 99, 32,
+    117,110,115,105,103,110,101,100, 32, 99,104, 97,114, 32, 66,
+     91, 93, 32, 61, 32,123, 92,110, 32, 32, 32, 39, 41, 10, 32,
+    108,111, 99, 97,108, 32,116, 61,123,110, 61, 48,125, 10, 32,
+    108,111, 99, 97,108, 32, 98, 32, 61, 32,103,115,117, 98, 40,
+    115, 44, 39, 40, 46, 41, 39, 44,102,117,110, 99,116,105,111,
+    110, 32, 40, 99, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,108,111, 99, 97,108, 32,101, 32, 61, 32, 39, 39, 10, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32,116, 46,110, 61,116, 46,
+    110, 43, 49, 32,105,102, 32,116, 46,110, 61, 61, 49, 53, 32,
+    116,104,101,110, 32,116, 46,110, 61, 48, 32,101, 61, 39, 92,
+    110, 39, 46, 46,112,114,101, 46, 46, 39, 32, 32, 39, 32,101,
+    110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,
+    116,117,114,110, 32,102,111,114,109, 97,116, 40, 39, 37, 51,
+    117, 44, 37,115, 39, 44,115,116,114, 98,121,116,101, 40, 99,
+     41, 44,101, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
+    110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 41, 10, 32,111,117,116,112,117,116, 40, 98, 46,
+     46,115,116,114, 98,121,116,101, 40, 34, 32, 34, 41, 41, 10,
+     32,111,117,116,112,117,116, 40, 39, 92,110, 39, 46, 46,112,
+    114,101, 46, 46, 39, 32,125, 59, 92,110, 39, 41, 10, 32,105,
+    102, 32,102,105,114,115,116, 95,108,105,110,101, 32, 97,110,
+    100, 32,102,105,114,115,116, 95,108,105,110,101, 32,126, 61,
+     32, 34, 34, 32,116,104,101,110, 10, 32,  9,111,117,116,112,
+    117,116, 40,112,114,101, 46, 46, 39, 32,116,111,108,117, 97,
+     95,100,111, 98,117,102,102,101,114, 40,116,111,108,117, 97,
+     95, 83, 44, 40, 99,104, 97,114, 42, 41, 66, 44,115,105,122,
+    101,111,102, 40, 66, 41, 44, 34,116,111,108,117, 97, 32,101,
+    109, 98,101,100,100,101,100, 58, 32, 39, 46, 46,102,105,114,
+    115,116, 95,108,105,110,101, 46, 46, 39, 34, 41, 59, 39, 41,
+     10, 32,101,108,115,101, 10, 32,  9,111,117,116,112,117,116,
+     40,112,114,101, 46, 46, 39, 32,116,111,108,117, 97, 95,100,
+    111, 98,117,102,102,101,114, 40,116,111,108,117, 97, 95, 83,
+     44, 40, 99,104, 97,114, 42, 41, 66, 44,115,105,122,101,111,
+    102, 40, 66, 41, 44, 34,116,111,108,117, 97, 58, 32,101,109,
+     98,101,100,100,101,100, 32, 76,117, 97, 32, 99,111,100,101,
+     32, 39, 46, 46, 99,111,100,101, 95,110, 46, 46, 39, 34, 41,
+     59, 39, 41, 10, 32,101,110,100, 10, 32,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39, 32,108,117, 97, 95,115,101,
+    116,116,111,112, 40,116,111,108,117, 97, 95, 83, 44, 32,116,
+    111,112, 41, 59, 39, 41, 10, 32,111,117,116,112,117,116, 40,
+    112,114,101, 46, 46, 39,125, 32, 47, 42, 32,101,110,100, 32,
+    111,102, 32,101,109, 98,101,100,100,101,100, 32,108,117, 97,
+     32, 99,111,100,101, 32, 42, 47, 92,110, 92,110, 39, 41, 10,
+     32, 99,111,100,101, 95,110, 32, 61, 32, 99,111,100,101, 95,
+    110, 32, 43, 49, 10,101,110,100, 10, 10, 10, 45, 45, 32, 80,
+    114,105,110,116, 32,109,101,116,104,111,100, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,100,101,
+     58,112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,
+    108,111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 67,111,100,101,123, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    116,101,120,116, 32, 61, 32, 91, 91, 34, 46, 46,115,101,108,
+    102, 46,116,101,120,116, 46, 46, 34, 93, 93, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+    125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10,
+     10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,
+    111,110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,
+    116,105,111,110, 32, 95, 67,111,100,101, 32, 40,116, 41, 10,
+     32,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116,
+     44, 99,108, 97,115,115, 67,111,100,101, 41, 10, 32, 97,112,
+    112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,114,110,
+     32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,
+    116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101,
+     99,116,115, 32, 97, 32,115,116,114,105,110,103, 32,114,101,
+    112,114,101,115,101,110,116,105,110,103, 32,116,104,101, 32,
+     99,111,100,101, 32,116,101,120,116, 10,102,117,110, 99,116,
+    105,111,110, 32, 67,111,100,101, 32, 40,108, 41, 10, 32,114,
+    101,116,117,114,110, 32, 95, 67,111,100,101, 32,123, 10, 32,
+     32,116,101,120,116, 32, 61, 32,108, 10, 32,125, 10,101,110,
+    100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/code.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,116,121,112,101,100,
+    101,102, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,
+    116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,
+    114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,
+    114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32,
+     74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100,
+     58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,
+    100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,
+    119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,
+    101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32,
+     97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,
+    116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119,
+     97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,
+    114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,
+    110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115,
+     44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,
+    116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,
+    105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,
+    105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101,
+     44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,
+    116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,
+    109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,
+    105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45,
+     32, 84,121,112,101,100,101,102, 32, 99,108, 97,115,115, 10,
+     45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 97,
+     32,116,121,112,101, 32,115,121,110,111,110,121,109, 46, 10,
+     45, 45, 32, 84,104,101, 32, 39,100,101, 32,102, 97, 99,116,
+    111, 39, 32,116,121,112,101, 32,114,101,112,108, 97, 99,101,
+    115, 32,116,104,101, 32,116,121,112,101,100,101,102, 32, 98,
+    101,102,111,114,101, 32,116,104,101, 10, 45, 45, 32,114,101,
+    109, 97,105,110,105,110,103, 32, 99,111,100,101, 32,105,115,
+     32,112, 97,114,115,101,100, 46, 10, 45, 45, 32, 84,104,101,
+     32,102,111,108,108,111,119,105,110,103, 32,102,105,101,108,
+    100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58, 10,
+     45, 45, 32, 32, 32,117,116,121,112,101, 32, 61, 32,116,121,
+    112,101,100,101,102, 32,110, 97,109,101, 10, 45, 45, 32, 32,
+     32,116,121,112,101, 32, 61, 32, 39,116,104,101, 32,102, 97,
+     99,116,111, 39, 32,116,121,112,101, 10, 45, 45, 32, 32, 32,
+    109,111,100, 32, 61, 32,109,111,100,105,102,105,101,114,115,
+     32,116,111, 32,116,104,101, 32, 39,100,101, 32,102, 97, 99,
+    116,111, 39, 32,116,121,112,101, 10, 99,108, 97,115,115, 84,
+    121,112,101,100,101,102, 32, 61, 32,123, 10, 32,117,116,121,
+    112,101, 32, 61, 32, 39, 39, 44, 10, 32,109,111,100, 32, 61,
+     32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39, 39,
+     10,125, 10, 99,108, 97,115,115, 84,121,112,101,100,101,102,
+     46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115,
+    115, 84,121,112,101,100,101,102, 10, 10, 45, 45, 32, 80,114,
+    105,110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 84,121,112,101,100,
+    101,102, 58,112,114,105,110,116, 32, 40,105,100,101,110,116,
+     44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 84,121,112,101,100,101,102,
+    123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,117,116,121,112,101, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,117,116,121,112,101, 46, 46, 34,
+     39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,109,111,100, 32, 61, 32, 39, 34, 46,
+     46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34,
+     41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41,
+     10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100,
+     10, 10, 45, 45, 32, 82,101,116,117,114,110, 32,105,116, 39,
+    115, 32,110,111,116, 32, 97, 32,118, 97,114,105, 97, 98,108,
+    101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 84,121,112,101,100,101,102, 58,105,115,118, 97,114,105,
+     97, 98,108,101, 32, 40, 41, 10, 32,114,101,116,117,114,110,
+     32,102, 97,108,115,101, 10,101,110,100, 10, 10, 45, 45, 32,
+     73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114,
+    117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32,
+     95, 84,121,112,101,100,101,102, 32, 40,116, 41, 10, 32,115,
+    101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,
+    108, 97,115,115, 84,121,112,101,100,101,102, 41, 10, 32,116,
+     46,116,121,112,101, 32, 61, 32,114,101,115,111,108,118,101,
+     95,116,101,109,112,108, 97,116,101, 95,116,121,112,101,115,
+     40,116, 46,116,121,112,101, 41, 10, 32, 97,112,112,101,110,
+    100,116,121,112,101,100,101,102, 40,116, 41, 10, 32,114,101,
+    116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32,
+     67,111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32,
+     69,120,112,101, 99,116,115, 32,111,110,101, 32,115,116,114,
+    105,110,103, 32,114,101,112,114,101,115,101,110,116,105,110,
+    103, 32,116,104,101, 32,116,121,112,101, 32,100,101,102,105,
+    110,105,116,105,111,110, 46, 10,102,117,110, 99,116,105,111,
+    110, 32, 84,121,112,101,100,101,102, 32, 40,115, 41, 10, 32,
+    105,102, 32,115,116,114,102,105,110,100, 40,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,115, 44, 32, 39, 37, 98, 60,
+     62, 39, 44, 32, 39, 39, 41, 44, 39, 91, 37, 42, 38, 93, 39,
+     41, 32,116,104,101,110, 10, 32, 32,116,111,108,117, 97, 95,
+    101,114,114,111,114, 40, 34, 35,105,110,118, 97,108,105,100,
+     32,116,121,112,101,100,101,102, 58, 32,112,111,105,110,116,
+    101,114,115, 32, 40, 97,110,100, 32,114,101,102,101,114,101,
+    110, 99,101,115, 41, 32, 97,114,101, 32,110,111,116, 32,115,
+    117,112,112,111,114,116,101,100, 34, 41, 10, 32,101,110,100,
+     10, 32,108,111, 99, 97,108, 32,111, 32, 61, 32,123,109,111,
+    100, 32, 61, 32, 39, 39,125, 10, 32,105,102, 32,115,116,114,
+    105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 91, 60,
+     62, 93, 34, 41, 32,116,104,101,110, 10, 32,  9, 95, 44, 95,
+     44,111, 46,116,121,112,101, 44,111, 46,117,116,121,112,101,
+     32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    115, 44, 32, 34, 94, 37,115, 42, 40, 91, 94, 60, 62, 93, 43,
+     37, 98, 60, 62, 91, 94, 37,115, 93, 42, 41, 37,115, 43, 40,
+     46, 45, 41, 36, 34, 41, 10, 32,101,108,115,101, 10, 32,  9,
+    108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,108,105,116,
+     40,103,115,117, 98, 40,115, 44, 34, 37,115, 37,115, 42, 34,
+     44, 34, 32, 34, 41, 44, 34, 32, 34, 41, 10, 32,  9,111, 32,
+     61, 32,123, 10,  9, 32, 32,117,116,121,112,101, 32, 61, 32,
+    116, 91,116, 46,110, 93, 44, 10,  9, 32, 32,116,121,112,101,
+     32, 61, 32,116, 91,116, 46,110, 45, 49, 93, 44, 10,  9, 32,
+     32,109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,116,
+     44, 49, 44,116, 46,110, 45, 50, 41, 44, 10,  9, 32,125, 10,
+     32,101,110,100, 10, 32,114,101,116,117,114,110, 32, 95, 84,
+    121,112,101,100,101,102, 40,111, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/typedef.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 99,111,110,116, 97,
+    105,110,101,114, 32, 97, 98,115,116,114, 97, 99,116, 32, 99,
+    108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,101,110,
+     32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,
+    108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47,
+     80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32,
+     49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10,
+     10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,105,
+    115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114,101,
+     59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105,115,
+    116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100, 47,
+    111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10, 45,
+     45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101, 32,
+    112,114,111,118,105,100,101,100, 32,104,101,114,101,117,110,
+    100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, 97,
+    115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,110,
+    100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111,114,
+     32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97,116,
+    105,111,110, 32,116,111, 32,112,114,111,118,105,100,101, 32,
+    109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115,117,
+    112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115, 44,
+     10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110,116,
+    115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97,116,
+    105,111,110,115, 46, 10, 10, 45, 45, 32,116, 97, 98,108,101,
+     32,116,111, 32,115,116,111,114,101, 32,110, 97,109,101,115,
+    112, 97, 99,101,100, 32,116,121,112,101,100,101,102,115, 47,
+    101,110,117,109,115, 32,105,110, 32,103,108,111, 98, 97,108,
+     32,115, 99,111,112,101, 10,103,108,111, 98, 97,108, 95,116,
+    121,112,101,100,101,102,115, 32, 61, 32,123,125, 10,103,108,
+    111, 98, 97,108, 95,101,110,117,109,115, 32, 61, 32,123,125,
+     10, 10, 45, 45, 32, 67,111,110,116, 97,105,110,101,114, 32,
+     99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,115,
+    101,110,116,115, 32, 97, 32, 99,111,110,116, 97,105,110,101,
+    114, 32,111,102, 32,102,101, 97,116,117,114,101,115, 32,116,
+    111, 32, 98,101, 32, 98,111,117,110,100, 10, 45, 45, 32,116,
+    111, 32,108,117, 97, 46, 10, 99,108, 97,115,115, 67,111,110,
+    116, 97,105,110,101,114, 32, 61, 10,123, 10, 32, 99,117,114,
+    114, 32, 61, 32,110,105,108, 44, 10,125, 10, 99,108, 97,115,
+    115, 67,111,110,116, 97,105,110,101,114, 46, 95, 95,105,110,
+    100,101,120, 32, 61, 32, 99,108, 97,115,115, 67,111,110,116,
+     97,105,110,101,114, 10,115,101,116,109,101,116, 97,116, 97,
+     98,108,101, 40, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,
+    101, 41, 10, 10, 45, 45, 32,111,117,116,112,117,116, 32,116,
+     97,103,115, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 67,111,110,116, 97,105,110,101,114, 58,100,101,
+     99,108,116,121,112,101, 32, 40, 41, 10, 32,112,117,115,104,
+     40,115,101,108,102, 41, 10, 32,108,111, 99, 97,108, 32,105,
+     61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, 91,
+    105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,105, 93,
+     58,100,101, 99,108,116,121,112,101, 40, 41, 10, 32, 32,105,
+     32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,111,
+    112, 40, 41, 10,101,110,100, 10, 10, 10, 45, 45, 32,119,114,
+    105,116,101, 32,115,117,112,112,111,114,116, 32, 99,111,100,
+    101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 67,111,110,116, 97,105,110,101,114, 58,115,117,112, 99,
+    111,100,101, 32, 40, 41, 10, 10,  9,105,102, 32,110,111,116,
+     32,115,101,108,102, 58, 99,104,101, 99,107, 95,112,117, 98,
+    108,105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,
+    101,110, 10,  9,  9,114,101,116,117,114,110, 10,  9,101,110,
+    100, 10, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,
+    108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32,
+     32,105,102, 32,115,101,108,102, 91,105, 93, 58, 99,104,101,
+     99,107, 95,112,117, 98,108,105, 99, 95, 97, 99, 99,101,115,
+    115, 40, 41, 32,116,104,101,110, 10, 32, 32,  9,115,101,108,
+    102, 91,105, 93, 58,115,117,112, 99,111,100,101, 40, 41, 10,
+     32, 32,101,110,100, 10, 32, 32,105, 32, 61, 32,105, 43, 49,
+     10, 32,101,110,100, 10, 32,112,111,112, 40, 41, 10,101,110,
+    100, 10, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 58,104, 97,115,
+    118, 97,114, 32, 40, 41, 10, 32,108,111, 99, 97,108, 32,105,
+     61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, 91,
+    105, 93, 32,100,111, 10, 32, 32,105,102, 32,115,101,108,102,
+     91,105, 93, 58,105,115,118, 97,114,105, 97, 98,108,101, 40,
+     41, 32,116,104,101,110, 10,  9,  9, 32,114,101,116,117,114,
+    110, 32, 49, 10,  9,  9,101,110,100, 10, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32, 48, 10,101,110,100, 10, 10, 45, 45, 32, 73,110,
+    116,101,114,110, 97,108, 32, 99,111,110,116, 97,105,110,101,
+    114, 32, 99,111,110,115,116,114,117, 99,116,111,114, 10,102,
+    117,110, 99,116,105,111,110, 32, 95, 67,111,110,116, 97,105,
+    110,101,114, 32, 40,115,101,108,102, 41, 10, 32,115,101,116,
+    109,101,116, 97,116, 97, 98,108,101, 40,115,101,108,102, 44,
+     99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 41,
+     10, 32,115,101,108,102, 46,110, 32, 61, 32, 48, 10, 32,115,
+    101,108,102, 46,116,121,112,101,100,101,102,115, 32, 61, 32,
+    123,116,111,108,117, 97, 95,110, 61, 48,125, 10, 32,115,101,
+    108,102, 46,117,115,101,114,116,121,112,101,115, 32, 61, 32,
+    123,125, 10, 32,115,101,108,102, 46,101,110,117,109,115, 32,
+     61, 32,123,116,111,108,117, 97, 95,110, 61, 48,125, 10, 32,
+    115,101,108,102, 46,108,110, 97,109,101,115, 32, 61, 32,123,
+    125, 10, 32,114,101,116,117,114,110, 32,115,101,108,102, 10,
+    101,110,100, 10, 10, 45, 45, 32,112,117,115,104, 32, 99,111,
+    110,116, 97,105,110,101,114, 10,102,117,110, 99,116,105,111,
+    110, 32,112,117,115,104, 32, 40,116, 41, 10,  9,116, 46,112,
+    114,111,120, 32, 61, 32, 99,108, 97,115,115, 67,111,110,116,
+     97,105,110,101,114, 46, 99,117,114,114, 10, 32, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,
+    114, 32, 61, 32,116, 10,101,110,100, 10, 10, 45, 45, 32,112,
+    111,112, 32, 99,111,110,116, 97,105,110,101,114, 10,102,117,
+    110, 99,116,105,111,110, 32,112,111,112, 32, 40, 41, 10, 45,
+     45,112,114,105,110,116, 40, 34,110, 97,109,101, 34, 44, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,
+    117,114,114, 46,110, 97,109,101, 41, 10, 45, 45,102,111,114,
+    101, 97, 99,104, 40, 99,108, 97,115,115, 67,111,110,116, 97,
+    105,110,101,114, 46, 99,117,114,114, 46,117,115,101,114,116,
+    121,112,101,115, 44,112,114,105,110,116, 41, 10, 45, 45,112,
+    114,105,110,116, 40, 34, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+     95, 95, 95, 95, 95, 34, 41, 10, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 32, 61,
+     32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     46, 99,117,114,114, 46,112,114,111,120, 10,101,110,100, 10,
+     10, 45, 45, 32,103,101,116, 32, 99,117,114,114,101,110,116,
+     32,110, 97,109,101,115,112, 97, 99,101, 10,102,117,110, 99,
+    116,105,111,110, 32,103,101,116, 99,117,114,114,110, 97,109,
+    101,115,112, 97, 99,101, 32, 40, 41, 10,  9,114,101,116,117,
+    114,110, 32,103,101,116,110, 97,109,101,115,112, 97, 99,101,
+     40, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     46, 99,117,114,114, 41, 10,101,110,100, 10, 10, 45, 45, 32,
+     97,112,112,101,110,100, 32,116,111, 32, 99,117,114,114,101,
+    110,116, 32, 99,111,110,116, 97,105,110,101,114, 10,102,117,
+    110, 99,116,105,111,110, 32, 97,112,112,101,110,100, 32, 40,
+    116, 41, 10, 32,114,101,116,117,114,110, 32, 99,108, 97,115,
+    115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114,
+     58, 97,112,112,101,110,100, 40,116, 41, 10,101,110,100, 10,
+     10, 45, 45, 32, 97,112,112,101,110,100, 32,116,121,112,101,
+    100,101,102, 32,116,111, 32, 99,117,114,114,101,110,116, 32,
+     99,111,110,116, 97,105,110,101,114, 10,102,117,110, 99,116,
+    105,111,110, 32, 97,112,112,101,110,100,116,121,112,101,100,
+    101,102, 32, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,
+     99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46,
+     99,117,114,114, 58, 97,112,112,101,110,100,116,121,112,101,
+    100,101,102, 40,116, 41, 10,101,110,100, 10, 10, 45, 45, 32,
+     97,112,112,101,110,100, 32,117,115,101,114,116,121,112,101,
+     32,116,111, 32, 99,117,114,114,101,110,116, 32, 99,111,110,
+    116, 97,105,110,101,114, 10,102,117,110, 99,116,105,111,110,
+     32, 97,112,112,101,110,100,117,115,101,114,116,121,112,101,
+     32, 40,116, 41, 10, 32,114,101,116,117,114,110, 32, 99,108,
+     97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,
+    114,114, 58, 97,112,112,101,110,100,117,115,101,114,116,121,
+    112,101, 40,116, 41, 10,101,110,100, 10, 10, 45, 45, 32, 97,
+    112,112,101,110,100, 32,101,110,117,109, 32,116,111, 32, 99,
+    117,114,114,101,110,116, 32, 99,111,110,116, 97,105,110,101,
+    114, 10,102,117,110, 99,116,105,111,110, 32, 97,112,112,101,
+    110,100,101,110,117,109, 32, 40,116, 41, 10, 32,114,101,116,
+    117,114,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 46, 99,117,114,114, 58, 97,112,112,101,110,100,
+    101,110,117,109, 40,116, 41, 10,101,110,100, 10, 10, 45, 45,
+     32,115,117, 98,115,116,105,116,117,116,101, 32,116,121,112,
+    101,100,101,102, 10,102,117,110, 99,116,105,111,110, 32, 97,
+    112,112,108,121,116,121,112,101,100,101,102, 32, 40,109,111,
+    100, 44,116,121,112,101, 41, 10, 32,114,101,116,117,114,110,
+     32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     46, 99,117,114,114, 58, 97,112,112,108,121,116,121,112,101,
+    100,101,102, 40,109,111,100, 44,116,121,112,101, 41, 10,101,
+    110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102,
+     32,105,115, 32,116,121,112,101, 10,102,117,110, 99,116,105,
+    111,110, 32,102,105,110,100,116,121,112,101, 32, 40,116,121,
+    112,101, 41, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,
+     99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46,
+     99,117,114,114, 58,102,105,110,100,116,121,112,101, 40,116,
+    121,112,101, 41, 10,  9,114,101,116,117,114,110, 32,116, 10,
+    101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,
+    102, 32,105,115, 32,116,121,112,101,100,101,102, 10,102,117,
+    110, 99,116,105,111,110, 32,105,115,116,121,112,101,100,101,
+    102, 32, 40,116,121,112,101, 41, 10, 32,114,101,116,117,114,
+    110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 46, 99,117,114,114, 58,105,115,116,121,112,101,100,101,
+    102, 40,116,121,112,101, 41, 10,101,110,100, 10, 10, 45, 45,
+     32,103,101,116, 32,102,117,108,108,116,121,112,101, 32, 40,
+    119,105,116,104, 32,110, 97,109,101,115,112, 97, 99,101, 41,
+     10,102,117,110, 99,116,105,111,110, 32,102,117,108,108,116,
+    121,112,101, 32, 40,116, 41, 10, 32,108,111, 99, 97,108, 32,
+     99,117,114,114, 32, 61, 32, 32, 99,108, 97,115,115, 67,111,
+    110,116, 97,105,110,101,114, 46, 99,117,114,114, 10,  9,119,
+    104,105,108,101, 32, 99,117,114,114, 32,100,111, 10,  9, 32,
+    105,102, 32, 99,117,114,114, 32,116,104,101,110, 10,  9,  9,
+     32,105,102, 32, 99,117,114,114, 46,116,121,112,101,100,101,
+    102,115, 32, 97,110,100, 32, 99,117,114,114, 46,116,121,112,
+    101,100,101,102,115, 91,116, 93, 32,116,104,101,110, 10,  9,
+      9, 32, 32,114,101,116,117,114,110, 32, 99,117,114,114, 46,
+    116,121,112,101,100,101,102,115, 91,116, 93, 10,  9,  9, 32,
+    101,108,115,101,105,102, 32, 99,117,114,114, 46,117,115,101,
+    114,116,121,112,101,115, 32, 97,110,100, 32, 99,117,114,114,
+     46,117,115,101,114,116,121,112,101,115, 91,116, 93, 32,116,
+    104,101,110, 10,  9,  9, 32, 32,114,101,116,117,114,110, 32,
+     99,117,114,114, 46,117,115,101,114,116,121,112,101,115, 91,
+    116, 93, 10,  9,  9,  9,101,110,100, 10,  9,  9,101,110,100,
+     10,  9, 32, 99,117,114,114, 32, 61, 32, 99,117,114,114, 46,
+    112,114,111,120, 10,  9,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,
+    101, 99,107,115, 32,105,102, 32,105,116, 32,114,101,113,117,
+    105,114,101,115, 32, 99,111,108,108,101, 99,116,105,111,110,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     67,111,110,116, 97,105,110,101,114, 58,114,101,113,117,105,
+    114,101, 99,111,108,108,101, 99,116,105,111,110, 32, 40,116,
+     41, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10, 32,
+    108,111, 99, 97,108, 32,105, 61, 49, 10,  9,108,111, 99, 97,
+    108, 32,114, 32, 61, 32,102, 97,108,115,101, 10, 32,119,104,
+    105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,
+     32, 32,114, 32, 61, 32,115,101,108,102, 91,105, 93, 58,114,
+    101,113,117,105,114,101, 99,111,108,108,101, 99,116,105,111,
+    110, 40,116, 41, 32,111,114, 32,114, 10, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10,  9,112,111,112, 40,
+     41, 10,  9,114,101,116,117,114,110, 32,114, 10,101,110,100,
+     10, 10, 10, 45, 45, 32,103,101,116, 32,110, 97,109,101,115,
+     97,112, 99,101, 10,102,117,110, 99,116,105,111,110, 32,103,
+    101,116,110, 97,109,101,115,112, 97, 99,101, 32, 40, 99,117,
+    114,114, 41, 10,  9,108,111, 99, 97,108, 32,110, 97,109,101,
+    115,112, 97, 99,101, 32, 61, 32, 39, 39, 10,  9,119,104,105,
+    108,101, 32, 99,117,114,114, 32,100,111, 10,  9, 32,105,102,
+     32, 99,117,114,114, 32, 97,110,100, 10,  9,  9, 32, 32, 32,
+     40, 32, 99,117,114,114, 46, 99,108, 97,115,115,116,121,112,
+    101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, 32,111,114,
+     32, 99,117,114,114, 46, 99,108, 97,115,115,116,121,112,101,
+     32, 61, 61, 32, 39,110, 97,109,101,115,112, 97, 99,101, 39,
+     41, 10,  9,  9,116,104,101,110, 10,  9,  9, 32,110, 97,109,
+    101,115,112, 97, 99,101, 32, 61, 32, 40, 99,117,114,114, 46,
+    111,114,105,103,105,110, 97,108, 95,110, 97,109,101, 32,111,
+    114, 32, 99,117,114,114, 46,110, 97,109,101, 41, 32, 46, 46,
+     32, 39, 58, 58, 39, 32, 46, 46, 32,110, 97,109,101,115,112,
+     97, 99,101, 10,  9,  9, 32, 45, 45,110, 97,109,101,115,112,
+     97, 99,101, 32, 61, 32, 99,117,114,114, 46,110, 97,109,101,
+     32, 46, 46, 32, 39, 58, 58, 39, 32, 46, 46, 32,110, 97,109,
+    101,115,112, 97, 99,101, 10,  9,  9,101,110,100, 10,  9, 32,
+     99,117,114,114, 32, 61, 32, 99,117,114,114, 46,112,114,111,
+    120, 10,  9,101,110,100, 10,  9,114,101,116,117,114,110, 32,
+    110, 97,109,101,115,112, 97, 99,101, 10,101,110,100, 10, 10,
+     45, 45, 32,103,101,116, 32,110, 97,109,101,115,112, 97, 99,
+    101, 32, 40,111,110,108,121, 32,110, 97,109,101,115,112, 97,
+     99,101, 41, 10,102,117,110, 99,116,105,111,110, 32,103,101,
+    116,111,110,108,121,110, 97,109,101,115,112, 97, 99,101, 32,
+     40, 41, 10, 32,108,111, 99, 97,108, 32, 99,117,114,114, 32,
+     61, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 46, 99,117,114,114, 10,  9,108,111, 99, 97,108, 32,110,
+     97,109,101,115,112, 97, 99,101, 32, 61, 32, 39, 39, 10,  9,
+    119,104,105,108,101, 32, 99,117,114,114, 32,100,111, 10,  9,
+      9,105,102, 32, 99,117,114,114, 46, 99,108, 97,115,115,116,
+    121,112,101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, 32,
+    116,104,101,110, 10,  9,  9, 32,114,101,116,117,114,110, 32,
+    110, 97,109,101,115,112, 97, 99,101, 10,  9,  9,101,108,115,
+    101,105,102, 32, 99,117,114,114, 46, 99,108, 97,115,115,116,
+    121,112,101, 32, 61, 61, 32, 39,110, 97,109,101,115,112, 97,
+     99,101, 39, 32,116,104,101,110, 10,  9,  9, 32,110, 97,109,
+    101,115,112, 97, 99,101, 32, 61, 32, 99,117,114,114, 46,110,
+     97,109,101, 32, 46, 46, 32, 39, 58, 58, 39, 32, 46, 46, 32,
+    110, 97,109,101,115,112, 97, 99,101, 10,  9,  9,101,110,100,
+     10,  9, 32, 99,117,114,114, 32, 61, 32, 99,117,114,114, 46,
+    112,114,111,120, 10,  9,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32,110, 97,109,101,115,112, 97, 99,101, 10,101,110,
+    100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    105,115, 32,101,110,117,109, 10,102,117,110, 99,116,105,111,
+    110, 32,105,115,101,110,117,109, 32, 40,116,121,112,101, 41,
+     10, 32,114,101,116,117,114,110, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 58,105,
+    115,101,110,117,109, 40,116,121,112,101, 41, 10,101,110,100,
+     10, 10, 45, 45, 32, 97,112,112,101,110,100, 32,102,101, 97,
+    116,117,114,101, 32,116,111, 32, 99,111,110,116, 97,105,110,
+    101,114, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 58, 97,112,112,
+    101,110,100, 32, 40,116, 41, 10, 32,115,101,108,102, 46,110,
+     32, 61, 32,115,101,108,102, 46,110, 32, 43, 32, 49, 10, 32,
+    115,101,108,102, 91,115,101,108,102, 46,110, 93, 32, 61, 32,
+    116, 10, 32,116, 46,112, 97,114,101,110,116, 32, 61, 32,115,
+    101,108,102, 10,101,110,100, 10, 10, 45, 45, 32, 97,112,112,
+    101,110,100, 32,116,121,112,101,100,101,102, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,110,116,
+     97,105,110,101,114, 58, 97,112,112,101,110,100,116,121,112,
+    101,100,101,102, 32, 40,116, 41, 10, 32,108,111, 99, 97,108,
+     32,110, 97,109,101,115,112, 97, 99,101, 32, 61, 32,103,101,
+    116,110, 97,109,101,115,112, 97, 99,101, 40, 99,108, 97,115,
+    115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114,
+     41, 10, 32,115,101,108,102, 46,116,121,112,101,100,101,102,
+    115, 46,116,111,108,117, 97, 95,110, 32, 61, 32,115,101,108,
+    102, 46,116,121,112,101,100,101,102,115, 46,116,111,108,117,
+     97, 95,110, 32, 43, 32, 49, 10, 32,115,101,108,102, 46,116,
+    121,112,101,100,101,102,115, 91,115,101,108,102, 46,116,121,
+    112,101,100,101,102,115, 46,116,111,108,117, 97, 95,110, 93,
+     32, 61, 32,116, 10,  9,115,101,108,102, 46,116,121,112,101,
+    100,101,102,115, 91,116, 46,117,116,121,112,101, 93, 32, 61,
+     32,110, 97,109,101,115,112, 97, 99,101, 32, 46, 46, 32,116,
+     46,117,116,121,112,101, 10,  9,103,108,111, 98, 97,108, 95,
+    116,121,112,101,100,101,102,115, 91,110, 97,109,101,115,112,
+     97, 99,101, 46, 46,116, 46,117,116,121,112,101, 93, 32, 61,
+     32,116, 10,  9,116, 46,102,116,121,112,101, 32, 61, 32,102,
+    105,110,100,116,121,112,101, 40,116, 46,116,121,112,101, 41,
+     32,111,114, 32,116, 46,116,121,112,101, 10,  9, 45, 45,112,
+    114,105,110,116, 40, 34, 97,112,112,101,110,100,105,110,103,
+     32,116,121,112,101,100,101,102, 32, 34, 46, 46,116, 46,117,
+    116,121,112,101, 46, 46, 34, 32, 97,115, 32, 34, 46, 46,110,
+     97,109,101,115,112, 97, 99,101, 46, 46,116, 46,117,116,121,
+    112,101, 46, 46, 34, 32,119,105,116,104, 32,102,116,121,112,
+    101, 32, 34, 46, 46,116, 46,102,116,121,112,101, 41, 10,  9,
+     97,112,112,101,110,100, 95,103,108,111, 98, 97,108, 95,116,
+    121,112,101, 40,110, 97,109,101,115,112, 97, 99,101, 46, 46,
+    116, 46,117,116,121,112,101, 41, 10,  9,105,102, 32,116, 46,
+    102,116,121,112,101, 32, 97,110,100, 32,105,115,101,110,117,
+    109, 40,116, 46,102,116,121,112,101, 41, 32,116,104,101,110,
+     10, 10,  9,  9,103,108,111, 98, 97,108, 95,101,110,117,109,
+    115, 91,110, 97,109,101,115,112, 97, 99,101, 46, 46,116, 46,
+    117,116,121,112,101, 93, 32, 61, 32,116,114,117,101, 10,  9,
+    101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 97,112,112,
+    101,110,100, 32,117,115,101,114,116,121,112,101, 58, 32,114,
+    101,116,117,114,110, 32,102,117,108,108, 32,116,121,112,101,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     67,111,110,116, 97,105,110,101,114, 58, 97,112,112,101,110,
+    100,117,115,101,114,116,121,112,101, 32, 40,116, 41, 10,  9,
+    108,111, 99, 97,108, 32, 99,111,110,116, 97,105,110,101,114,
+     10,  9,105,102, 32,116, 32, 61, 61, 32, 40,115,101,108,102,
+     46,111,114,105,103,105,110, 97,108, 95,110, 97,109,101, 32,
+    111,114, 32,115,101,108,102, 46,110, 97,109,101, 41, 32,116,
+    104,101,110, 10,  9,  9, 99,111,110,116, 97,105,110,101,114,
+     32, 61, 32,115,101,108,102, 46,112,114,111,120, 10,  9,101,
+    108,115,101, 10,  9,  9, 99,111,110,116, 97,105,110,101,114,
+     32, 61, 32,115,101,108,102, 10,  9,101,110,100, 10,  9,108,
+    111, 99, 97,108, 32,102,116, 32, 61, 32,103,101,116,110, 97,
+    109,101,115,112, 97, 99,101, 40, 99,111,110,116, 97,105,110,
+    101,114, 41, 32, 46, 46, 32,116, 10,  9, 99,111,110,116, 97,
+    105,110,101,114, 46,117,115,101,114,116,121,112,101,115, 91,
+    116, 93, 32, 61, 32,102,116, 10,  9, 95,117,115,101,114,116,
+    121,112,101, 91,102,116, 93, 32, 61, 32,102,116, 10,  9,114,
+    101,116,117,114,110, 32,102,116, 10,101,110,100, 10, 10, 45,
+     45, 32, 97,112,112,101,110,100, 32,101,110,117,109, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,
+    110,116, 97,105,110,101,114, 58, 97,112,112,101,110,100,101,
+    110,117,109, 32, 40,116, 41, 10, 32,108,111, 99, 97,108, 32,
+    110, 97,109,101,115,112, 97, 99,101, 32, 61, 32,103,101,116,
+    110, 97,109,101,115,112, 97, 99,101, 40, 99,108, 97,115,115,
+     67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 41,
+     10, 32,115,101,108,102, 46,101,110,117,109,115, 46,116,111,
+    108,117, 97, 95,110, 32, 61, 32,115,101,108,102, 46,101,110,
+    117,109,115, 46,116,111,108,117, 97, 95,110, 32, 43, 32, 49,
+     10, 32,115,101,108,102, 46,101,110,117,109,115, 91,115,101,
+    108,102, 46,101,110,117,109,115, 46,116,111,108,117, 97, 95,
+    110, 93, 32, 61, 32,116, 10,  9,103,108,111, 98, 97,108, 95,
+    101,110,117,109,115, 91,110, 97,109,101,115,112, 97, 99,101,
+     46, 46,116, 46,110, 97,109,101, 93, 32, 61, 32,116, 10,101,
+    110,100, 10, 10, 45, 45, 32,100,101,116,101,114,109,105,110,
+    101, 32,108,117, 97, 32,102,117,110, 99,116,105,111,110, 32,
+    110, 97,109,101, 32,111,118,101,114,108,111, 97,100, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,
+    110,116, 97,105,110,101,114, 58,111,118,101,114,108,111, 97,
+    100, 32, 40,108,110, 97,109,101, 41, 10, 32,105,102, 32,110,
+    111,116, 32,115,101,108,102, 46,108,110, 97,109,101,115, 91,
+    108,110, 97,109,101, 93, 32,116,104,101,110, 10, 32, 32,115,
+    101,108,102, 46,108,110, 97,109,101,115, 91,108,110, 97,109,
+    101, 93, 32, 61, 32, 48, 10, 32,101,108,115,101, 10, 32, 32,
+    115,101,108,102, 46,108,110, 97,109,101,115, 91,108,110, 97,
+    109,101, 93, 32, 61, 32,115,101,108,102, 46,108,110, 97,109,
+    101,115, 91,108,110, 97,109,101, 93, 32, 43, 32, 49, 10, 32,
+    101,110,100, 10, 32,114,101,116,117,114,110, 32,102,111,114,
+    109, 97,116, 40, 34, 37, 48, 50,100, 34, 44,115,101,108,102,
+     46,108,110, 97,109,101,115, 91,108,110, 97,109,101, 93, 41,
+     10,101,110,100, 10, 10, 45, 45, 32, 97,112,112,108,105,101,
+    115, 32,116,121,112,101,100,101,102, 58, 32,114,101,116,117,
+    114,110,115, 32,116,104,101, 32, 39,116,104,101, 32,102, 97,
+     99,116,111, 39, 32,109,111,100,105,102,105,101,114, 32, 97,
+    110,100, 32,116,121,112,101, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 58, 97,112,112,108,121,116,121,112,101,100,101,102, 32,
+     40,109,111,100, 44,116,121,112,101, 41, 10,  9,105,102, 32,
+    103,108,111, 98, 97,108, 95,116,121,112,101,100,101,102,115,
+     91,116,121,112,101, 93, 32,116,104,101,110, 10,  9,  9, 45,
+     45,112,114,105,110,116, 40, 34,102,111,117,110,100, 32,116,
+    121,112,101,100,101,102, 32, 34, 46, 46,103,108,111, 98, 97,
+    108, 95,116,121,112,101,100,101,102,115, 91,116,121,112,101,
+     93, 46,116,121,112,101, 41, 10,  9,  9,108,111, 99, 97,108,
+     32,109,111,100, 49, 44, 32,116,121,112,101, 49, 32, 61, 32,
+    103,108,111, 98, 97,108, 95,116,121,112,101,100,101,102,115,
+     91,116,121,112,101, 93, 46,109,111,100, 44, 32,103,108,111,
+     98, 97,108, 95,116,121,112,101,100,101,102,115, 91,116,121,
+    112,101, 93, 46,102,116,121,112,101, 10,  9,  9,108,111, 99,
+     97,108, 32,109,111,100, 50, 44, 32,116,121,112,101, 50, 32,
+     61, 32, 97,112,112,108,121,116,121,112,101,100,101,102, 40,
+    109,111,100, 46, 46, 34, 32, 34, 46, 46,109,111,100, 49, 44,
+     32,116,121,112,101, 49, 41, 10,  9,  9, 45, 45,114,101,116,
+    117,114,110, 32,109,111,100, 50, 32, 46, 46, 32, 39, 32, 39,
+     32, 46, 46, 32,109,111,100, 49, 44, 32,116,121,112,101, 50,
+     10,  9,  9,114,101,116,117,114,110, 32,109,111,100, 50, 44,
+     32,116,121,112,101, 50, 10,  9,101,110,100, 10,  9,100,111,
+     32,114,101,116,117,114,110, 32,109,111,100, 44,116,121,112,
+    101, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,
+    104,101, 99,107, 32,105,102, 32,105,116, 32,105,115, 32, 97,
+     32,116,121,112,101,100,101,102, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,
+    101,114, 58,105,115,116,121,112,101,100,101,102, 32, 40,116,
+    121,112,101, 41, 10, 32,108,111, 99, 97,108, 32,101,110,118,
+     32, 61, 32,115,101,108,102, 10, 32,119,104,105,108,101, 32,
+    101,110,118, 32,100,111, 10, 32, 32,105,102, 32,101,110,118,
+     46,116,121,112,101,100,101,102,115, 32,116,104,101,110, 10,
+     32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,
+     32,119,104,105,108,101, 32,101,110,118, 46,116,121,112,101,
+    100,101,102,115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32,
+    105,102, 32,101,110,118, 46,116,121,112,101,100,101,102,115,
+     91,105, 93, 46,117,116,121,112,101, 32, 61, 61, 32,116,121,
+    112,101, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,114,101,116,117,114,110, 32,116,121,112,101, 10, 32,
+     32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
+     32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,
+    101,110,100, 10, 32, 32,101,110,100, 10, 32, 32,101,110,118,
+     32, 61, 32,101,110,118, 46,112, 97,114,101,110,116, 10, 32,
+    101,110,100, 10, 32,114,101,116,117,114,110, 32,110,105,108,
+     10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
+    102,105,110,100, 95,101,110,117,109, 95,118, 97,114, 40,118,
+     97,114, 41, 10, 10,  9,105,102, 32,116,111,110,117,109, 98,
+    101,114, 40,118, 97,114, 41, 32,116,104,101,110, 32,114,101,
+    116,117,114,110, 32,118, 97,114, 32,101,110,100, 10, 10,  9,
+    108,111, 99, 97,108, 32, 99, 32, 61, 32, 99,108, 97,115,115,
+     67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 10,
+      9,119,104,105,108,101, 32, 99, 32,100,111, 10,  9,  9,108,
+    111, 99, 97,108, 32,110,115, 32, 61, 32,103,101,116,110, 97,
+    109,101,115,112, 97, 99,101, 40, 99, 41, 10,  9,  9,102,111,
+    114, 32,107, 44,118, 32,105,110, 32,112, 97,105,114,115, 40,
+     95,103,108,111, 98, 97,108, 95,101,110,117,109,115, 41, 32,
+    100,111, 10,  9,  9,  9,105,102, 32,109, 97,116, 99,104, 95,
+    116,121,112,101, 40,118, 97,114, 44, 32,118, 44, 32,110,115,
+     41, 32,116,104,101,110, 10,  9,  9,  9,  9,114,101,116,117,
+    114,110, 32,118, 10,  9,  9,  9,101,110,100, 10,  9,  9,101,
+    110,100, 10,  9,  9,105,102, 32, 99, 46, 98, 97,115,101, 32,
+     97,110,100, 32, 99, 46, 98, 97,115,101, 32,126, 61, 32, 39,
+     39, 32,116,104,101,110, 10,  9,  9,  9, 99, 32, 61, 32, 95,
+    103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,
+     99, 58,102,105,110,100,116,121,112,101, 40, 99, 46, 98, 97,
+    115,101, 41, 93, 10,  9,  9,101,108,115,101, 10,  9,  9,  9,
+     99, 32, 61, 32,110,105,108, 10,  9,  9,101,110,100, 10,  9,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,118, 97,
+    114, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107,
+     32,105,102, 32,105,115, 32, 97, 32,114,101,103,105,115,116,
+    101,114,101,100, 32,116,121,112,101, 58, 32,114,101,116,117,
+    114,110, 32,102,117,108,108, 32,116,121,112,101, 32,111,114,
+     32,110,105,108, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,102,
+    105,110,100,116,121,112,101, 32, 40,116, 41, 10, 10,  9,116,
+     32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,
+    116, 44, 32, 34, 61, 46, 42, 34, 44, 32, 34, 34, 41, 10,  9,
+    105,102, 32, 95, 98, 97,115,105, 99, 91,116, 93, 32,116,104,
+    101,110, 10,  9, 32,114,101,116,117,114,110, 32,116, 10,  9,
+    101,110,100, 10, 10,  9,108,111, 99, 97,108, 32, 95, 44, 95,
+     44,101,109, 32, 61, 32,115,116,114,105,110,103, 46,102,105,
+    110,100, 40,116, 44, 32, 34, 40, 91, 38, 37, 42, 93, 41, 37,
+    115, 42, 36, 34, 41, 10,  9,116, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,116, 44, 32, 34, 37,115, 42,
+     40, 91, 38, 37, 42, 93, 41, 37,115, 42, 36, 34, 44, 32, 34,
+     34, 41, 10,  9,112, 32, 61, 32,115,101,108,102, 10,  9,119,
+    104,105,108,101, 32,112, 32, 97,110,100, 32,116,121,112,101,
+     40,112, 41, 61, 61, 39,116, 97, 98,108,101, 39, 32,100,111,
+     10,  9,  9,108,111, 99, 97,108, 32,115,116, 32, 61, 32,103,
+    101,116,110, 97,109,101,115,112, 97, 99,101, 40,112, 41, 10,
+     10,  9,  9,102,111,114, 32,105, 61, 95,103,108,111, 98, 97,
+    108, 95,116,121,112,101,115, 46,110, 44, 49, 44, 45, 49, 32,
+    100,111, 32, 45, 45, 32,105,110, 32,114,101,118,101,114,115,
+    101, 32,111,114,100,101,114, 10, 10,  9,  9,  9,105,102, 32,
+    109, 97,116, 99,104, 95,116,121,112,101, 40,116, 44, 32, 95,
+    103,108,111, 98, 97,108, 95,116,121,112,101,115, 91,105, 93,
+     44, 32,115,116, 41, 32,116,104,101,110, 10,  9,  9,  9,  9,
+    114,101,116,117,114,110, 32, 95,103,108,111, 98, 97,108, 95,
+    116,121,112,101,115, 91,105, 93, 46, 46, 40,101,109, 32,111,
+    114, 32, 34, 34, 41, 10,  9,  9,  9,101,110,100, 10,  9,  9,
+    101,110,100, 10,  9,  9,105,102, 32,112, 46, 98, 97,115,101,
+     32, 97,110,100, 32,112, 46, 98, 97,115,101, 32,126, 61, 32,
+     39, 39, 32, 97,110,100, 32,112, 46, 98, 97,115,101, 32,126,
+     61, 32,116, 32,116,104,101,110, 10,  9,  9,  9, 45, 45,112,
+    114,105,110,116, 40, 34,116,121,112,101, 32,105,115, 32, 34,
+     46, 46,116, 46, 46, 34, 44, 32,112, 32,105,115, 32, 34, 46,
+     46,112, 46, 98, 97,115,101, 46, 46, 34, 32,115,101,108,102,
+     46,116,121,112,101, 32,105,115, 32, 34, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 34, 32,115,101,108,102, 46,
+    110, 97,109,101, 32,105,115, 32, 34, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 41, 10,  9,  9,  9,112, 32, 61, 32, 95,
+    103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,
+    112, 58,102,105,110,100,116,121,112,101, 40,112, 46, 98, 97,
+    115,101, 41, 93, 10,  9,  9,101,108,115,101, 10,  9,  9,  9,
+    112, 32, 61, 32,110,105,108, 10,  9,  9,101,110,100, 10,  9,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,110,105,
+    108, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
+     32, 97,112,112,101,110,100, 95,103,108,111, 98, 97,108, 95,
+    116,121,112,101, 40,116, 44, 32, 99,108, 97,115,115, 41, 10,
+      9, 95,103,108,111, 98, 97,108, 95,116,121,112,101,115, 46,
+    110, 32, 61, 32, 95,103,108,111, 98, 97,108, 95,116,121,112,
+    101,115, 46,110, 32, 43, 49, 10,  9, 95,103,108,111, 98, 97,
+    108, 95,116,121,112,101,115, 91, 95,103,108,111, 98, 97,108,
+     95,116,121,112,101,115, 46,110, 93, 32, 61, 32,116, 10,  9,
+     95,103,108,111, 98, 97,108, 95,116,121,112,101,115, 95,104,
+     97,115,104, 91,116, 93, 32, 61, 32, 49, 10,  9,105,102, 32,
+     99,108, 97,115,115, 32,116,104,101,110, 32, 97,112,112,101,
+    110,100, 95, 99,108, 97,115,115, 95,116,121,112,101, 40,116,
+     44, 32, 99,108, 97,115,115, 41, 32,101,110,100, 10,101,110,
+    100, 10, 10,102,117,110, 99,116,105,111,110, 32, 97,112,112,
+    101,110,100, 95, 99,108, 97,115,115, 95,116,121,112,101, 40,
+    116, 44, 99,108, 97,115,115, 41, 10,  9,105,102, 32, 95,103,
+    108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,116,
+     93, 32,116,104,101,110, 10,  9,  9, 99,108, 97,115,115, 46,
+    102,108, 97,103,115, 32, 61, 32, 95,103,108,111, 98, 97,108,
+     95, 99,108, 97,115,115,101,115, 91,116, 93, 46,102,108, 97,
+    103,115, 10,  9,  9, 99,108, 97,115,115, 46,108,110, 97,109,
+    101,115, 32, 61, 32, 95,103,108,111, 98, 97,108, 95, 99,108,
+     97,115,115,101,115, 91,116, 93, 46,108,110, 97,109,101,115,
+     10,  9,  9,105,102, 32, 95,103,108,111, 98, 97,108, 95, 99,
+    108, 97,115,115,101,115, 91,116, 93, 46, 98, 97,115,101, 32,
+     97,110,100, 32, 40, 95,103,108,111, 98, 97,108, 95, 99,108,
+     97,115,115,101,115, 91,116, 93, 46, 98, 97,115,101, 32,126,
+     61, 32, 39, 39, 41, 32,116,104,101,110, 10,  9,  9,  9, 99,
+    108, 97,115,115, 46, 98, 97,115,101, 32, 61, 32, 95,103,108,
+    111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,116, 93,
+     46, 98, 97,115,101, 32,111,114, 32, 99,108, 97,115,115, 46,
+     98, 97,115,101, 10,  9,  9,101,110,100, 10,  9,101,110,100,
+     10,  9, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115,115,
+    101,115, 91,116, 93, 32, 61, 32, 99,108, 97,115,115, 10,  9,
+     99,108, 97,115,115, 46,102,108, 97,103,115, 32, 61, 32, 99,
+    108, 97,115,115, 46,102,108, 97,103,115, 32,111,114, 32,123,
+    125, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
+     32,109, 97,116, 99,104, 95,116,121,112,101, 40, 99,104,105,
+    108,100,116,121,112,101, 44, 32,114,101,103,116,121,112,101,
+     44, 32,115,116, 41, 10, 45, 45,112,114,105,110,116, 40, 34,
+    102,105,110,100,116,121,112,101, 32, 34, 46, 46, 99,104,105,
+    108,100,116,121,112,101, 46, 46, 34, 44, 32, 34, 46, 46,114,
+    101,103,116,121,112,101, 46, 46, 34, 44, 32, 34, 46, 46,115,
+    116, 41, 10,  9,108,111, 99, 97,108, 32, 98, 44,101, 32, 61,
+     32,115,116,114,105,110,103, 46,102,105,110,100, 40,114,101,
+    103,116,121,112,101, 44, 32, 99,104,105,108,100,116,121,112,
+    101, 44, 32, 45,115,116,114,105,110,103, 46,108,101,110, 40,
+     99,104,105,108,100,116,121,112,101, 41, 44, 32,116,114,117,
+    101, 41, 10,  9,105,102, 32, 98, 32,116,104,101,110, 10, 10,
+      9,  9,105,102, 32,101, 32, 61, 61, 32,115,116,114,105,110,
+    103, 46,108,101,110, 40,114,101,103,116,121,112,101, 41, 32,
+     97,110,100, 10,  9,  9,  9,  9, 40, 98, 32, 61, 61, 32, 49,
+     32,111,114, 32, 40,115,116,114,105,110,103, 46,115,117, 98,
+     40,114,101,103,116,121,112,101, 44, 32, 98, 45, 49, 44, 32,
+     98, 45, 49, 41, 32, 61, 61, 32, 39, 58, 39, 32, 97,110,100,
+     10,  9,  9,  9,  9,115,116,114,105,110,103, 46,115,117, 98,
+     40,114,101,103,116,121,112,101, 44, 32, 49, 44, 32, 98, 45,
+     49, 41, 32, 61, 61, 32,115,116,114,105,110,103, 46,115,117,
+     98, 40,115,116, 44, 32, 49, 44, 32, 98, 45, 49, 41, 41, 41,
+     32,116,104,101,110, 10,  9,  9,  9,114,101,116,117,114,110,
+     32,116,114,117,101, 10,  9,  9,101,110,100, 10,  9,101,110,
+    100, 10, 10,  9,114,101,116,117,114,110, 32,102, 97,108,115,
+    101, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
+     32,102,105,110,100,116,121,112,101, 95,111,110, 95, 99,104,
+    105,108,100,115, 40,115,101,108,102, 44, 32,116, 41, 10, 10,
+      9,108,111, 99, 97,108, 32,116, 99,104,105,108,100, 10,  9,
+    105,102, 32,115,101,108,102, 46, 99,108, 97,115,115,116,121,
+    112,101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, 32,111,
+    114, 32,115,101,108,102, 46, 99,108, 97,115,115,116,121,112,
+    101, 32, 61, 61, 32, 39,110, 97,109,101,115,112, 97, 99,101,
+     39, 32,116,104,101,110, 10,  9,  9,102,111,114, 32,107, 44,
+    118, 32,105,110, 32,105,112, 97,105,114,115, 40,115,101,108,
+    102, 41, 32,100,111, 10,  9,  9,  9,105,102, 32,118, 46, 99,
+    108, 97,115,115,116,121,112,101, 32, 61, 61, 32, 39, 99,108,
+     97,115,115, 39, 32,111,114, 32,118, 46, 99,108, 97,115,115,
+    116,121,112,101, 32, 61, 61, 32, 39,110, 97,109,101,115,112,
+     97, 99,101, 39, 32,116,104,101,110, 10,  9,  9,  9,  9,105,
+    102, 32,118, 46,116,121,112,101,100,101,102,115, 32, 97,110,
+    100, 32,118, 46,116,121,112,101,100,101,102,115, 91,116, 93,
+     32,116,104,101,110, 10,  9,  9,  9,  9, 32,114,101,116,117,
+    114,110, 32,118, 46,116,121,112,101,100,101,102,115, 91,116,
+     93, 10,  9,  9,  9,  9,101,108,115,101,105,102, 32,118, 46,
+    117,115,101,114,116,121,112,101,115, 32, 97,110,100, 32,118,
+     46,117,115,101,114,116,121,112,101,115, 91,116, 93, 32,116,
+    104,101,110, 10,  9,  9,  9,  9, 32,114,101,116,117,114,110,
+     32,118, 46,117,115,101,114,116,121,112,101,115, 91,116, 93,
+     10,  9,  9,  9,  9,101,110,100, 10,  9,  9,  9,  9,116, 99,
+    104,105,108,100, 32, 61, 32,102,105,110,100,116,121,112,101,
+     95,111,110, 95, 99,104,105,108,100,115, 40,118, 44, 32,116,
+     41, 10,  9,  9,  9,  9,105,102, 32,116, 99,104,105,108,100,
+     32,116,104,101,110, 32,114,101,116,117,114,110, 32,116, 99,
+    104,105,108,100, 32,101,110,100, 10,  9,  9,  9,101,110,100,
+     10,  9,  9,101,110,100, 10,  9,101,110,100, 10,  9,114,101,
+    116,117,114,110, 32,110,105,108, 10, 10,101,110,100, 10, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 58,105,115,101,110,117,109,
+     32, 40,116,121,112,101, 41, 10, 32,105,102, 32,103,108,111,
+     98, 97,108, 95,101,110,117,109,115, 91,116,121,112,101, 93,
+     32,116,104,101,110, 10,  9,114,101,116,117,114,110, 32,116,
+    121,112,101, 10, 32,101,108,115,101, 10, 32,  9,114,101,116,
+    117,114,110, 32,102, 97,108,115,101, 10, 32,101,110,100, 10,
+     10, 32,108,111, 99, 97,108, 32, 98, 97,115,101,116,121,112,
+    101, 32, 61, 32,103,115,117, 98, 40,116,121,112,101, 44, 34,
+     94, 46, 42, 58, 58, 34, 44, 34, 34, 41, 10, 32,108,111, 99,
+     97,108, 32,101,110,118, 32, 61, 32,115,101,108,102, 10, 32,
+    119,104,105,108,101, 32,101,110,118, 32,100,111, 10, 32, 32,
+    105,102, 32,101,110,118, 46,101,110,117,109,115, 32,116,104,
+    101,110, 10, 32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49,
+     10, 32, 32, 32,119,104,105,108,101, 32,101,110,118, 46,101,
+    110,117,109,115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32,
+    105,102, 32,101,110,118, 46,101,110,117,109,115, 91,105, 93,
+     46,110, 97,109,101, 32, 61, 61, 32, 98, 97,115,101,116,121,
+    112,101, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,114,101,116,117,114,110, 32,116,114,117,101, 10, 32,
+     32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
+     32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,
+    101,110,100, 10, 32, 32,101,110,100, 10, 32, 32,101,110,118,
+     32, 61, 32,101,110,118, 46,112, 97,114,101,110,116, 10, 32,
+    101,110,100, 10, 32,114,101,116,117,114,110, 32,102, 97,108,
+    115,101, 10,101,110,100, 10, 10,109,101,116,104,111,100,105,
+    115,118,105,114,116,117, 97,108, 32, 61, 32,102, 97,108,115,
+    101, 32, 45, 45, 32, 97, 32,103,108,111, 98, 97,108, 10, 10,
+     45, 45, 32,112, 97,114,115,101, 32, 99,104,117,110,107, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 58,100,111,112, 97,114,115,
+    101, 32, 40,115, 41, 10, 45, 45,112,114,105,110,116, 32, 40,
+     34,112, 97,114,115,101, 32, 34, 46, 46,115, 41, 10, 10, 32,
+     45, 45, 32,116,114,121, 32,116,104,101, 32,112, 97,114,115,
+    101,114, 32,104,111,111,107, 10, 32,100,111, 10, 32,  9,108,
+    111, 99, 97,108, 32,115,117, 98, 32, 61, 32,112, 97,114,115,
+    101,114, 95,104,111,111,107, 40,115, 41, 10, 32,  9,105,102,
+     32,115,117, 98, 32,116,104,101,110, 10, 32,  9,  9,114,101,
+    116,117,114,110, 32,115,117, 98, 10, 32,  9,101,110,100, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,116,
+    104,101, 32,110,117,108,108, 32,115,116, 97,116,101,109,101,
+    110,116, 10, 32,100,111, 10, 32,  9,108,111, 99, 97,108, 32,
+     98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,116,114,105,
+    110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115,
+     42, 59, 34, 41, 10, 32,  9,105,102, 32, 98, 32,116,104,101,
+    110, 10, 32,  9,  9,114,101,116,117,114,110, 32,115,116,114,
+    115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32,  9,101,110,
+    100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121,
+     32,101,109,112,116,121, 32,118,101,114, 98, 97,116,105,109,
+     32,108,105,110,101, 10, 32,100,111, 10, 32,  9,108,111, 99,
+     97,108, 32, 98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34,
+     94, 37,115, 42, 36, 92,110, 34, 41, 10, 32,  9,105,102, 32,
+     98, 32,116,104,101,110, 10, 32,  9,  9,114,101,116,117,114,
+    110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41,
+     10, 32,  9,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45,
+     45, 32,116,114,121, 32, 76,117, 97, 32, 99,111,100,101, 10,
+     32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101,
+     44, 99,111,100,101, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115, 44, 34, 94, 37,115, 42, 40, 37, 98, 92, 49, 92, 50,
+     41, 34, 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110,
+     10, 32, 32, 32, 67,111,100,101, 40,115,116,114,115,117, 98,
+     40, 99,111,100,101, 44, 50, 44, 45, 50, 41, 41, 10, 32, 32,
+     32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32, 67, 32, 99,
+    111,100,101, 10, 32,100,111, 10, 32, 32,108,111, 99, 97,108,
+     32, 98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,116,114,
+    102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 37, 98,
+     92, 51, 92, 52, 41, 34, 41, 10, 32, 32,105,102, 32, 98, 32,
+    116,104,101,110, 10,  9, 99,111,100,101, 32, 61, 32, 39,123,
+     39, 46, 46,115,116,114,115,117, 98, 40, 99,111,100,101, 44,
+     50, 44, 45, 50, 41, 46, 46, 39, 92,110,125, 92,110, 39, 10,
+      9, 86,101,114, 98, 97,116,105,109, 40, 99,111,100,101, 44,
+     39,114, 39, 41, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32,
+    118,101,114, 98, 97,116,105,109, 32, 99,111,100,101, 32,102,
+    111,114, 32, 39,114, 39,101,103,105,115,116,101,114, 32,102,
+    114, 97,103,109,101,110,116, 10,  9,114,101,116,117,114,110,
+     32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45,
+     32,116,114,121, 32, 67, 32, 99,111,100,101, 32,102,111,114,
+     32,112,114,101, 97,109, 98,108,101, 32,115,101, 99,116,105,
+    111,110, 10, 32,100,111, 10, 32,  9,108,111, 99, 97,108, 32,
+     98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,116,114,105,
+    110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115,
+     42, 40, 37, 98, 92, 53, 92, 54, 41, 34, 41, 10, 32,  9,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32,  9,  9, 99,111,100,
+    101, 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,
+     99,111,100,101, 44, 32, 50, 44, 32, 45, 50, 41, 46, 46, 34,
+     92,110, 34, 10,  9,  9, 86,101,114, 98, 97,116,105,109, 40,
+     99,111,100,101, 44, 32, 39, 39, 41, 10,  9,  9,114,101,116,
+    117,114,110, 32,115,116,114,105,110,103, 46,115,117, 98, 40,
+    115, 44, 32,101, 43, 49, 41, 10, 32,  9,101,110,100, 10, 32,
+    101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,100,101,
+    102, 97,117,108,116, 95,112,114,111,112,101,114,116,121, 32,
+    100,105,114,101, 99,116,105,118,101, 10, 32,100,111, 10, 32,
+      9,108,111, 99, 97,108, 32, 98, 44,101, 44,112,116,121,112,
+    101, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 32,
+     34, 94, 37,115, 42, 84, 79, 76, 85, 65, 95, 80, 82, 79, 80,
+     69, 82, 84, 89, 95, 84, 89, 80, 69, 37,115, 42, 37, 40, 43,
+     37,115, 42, 40, 91, 94, 37, 41, 37,115, 93, 42, 41, 37,115,
+     42, 37, 41, 43, 37,115, 42, 59, 63, 34, 41, 10, 32,  9,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32,  9,  9,105,102, 32,
+    110,111,116, 32,112,116,121,112,101, 32,111,114, 32,112,116,
+    121,112,101, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10,
+     32,  9,  9,  9,112,116,121,112,101, 32, 61, 32, 34,100,101,
+    102, 97,117,108,116, 34, 10, 32,  9,  9,101,110,100, 10, 32,
+      9,  9,115,101,108,102, 58,115,101,116, 95,112,114,111,112,
+    101,114,116,121, 95,116,121,112,101, 40,112,116,121,112,101,
+     41, 10,  9, 32,  9,114,101,116,117,114,110, 32,115,116,114,
+    115,117, 98, 40,115, 44, 32,101, 43, 49, 41, 10, 32,  9,101,
+    110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,
+    121, 32,112,114,111,116,101, 99,116,101,100, 95,100,101,115,
+    116,114,117, 99,116,111,114, 32,100,105,114,101, 99,116,105,
+    118,101, 10, 32,100,111, 10, 32,  9,108,111, 99, 97,108, 32,
+     98, 44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,105,
+    110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 84, 79, 76, 85,
+     65, 95, 80, 82, 79, 84, 69, 67, 84, 69, 68, 95, 68, 69, 83,
+     84, 82, 85, 67, 84, 79, 82, 37,115, 42, 59, 63, 34, 41, 10,
+      9,105,102, 32, 98, 32,116,104,101,110, 10,  9,  9,105,102,
+     32,115,101,108,102, 46,115,101,116, 95,112,114,111,116,101,
+     99,116,101,100, 95,100,101,115,116,114,117, 99,116,111,114,
+     32,116,104,101,110, 10,  9, 32,  9,  9,115,101,108,102, 58,
+    115,101,116, 95,112,114,111,116,101, 99,116,101,100, 95,100,
+    101,115,116,114,117, 99,116,111,114, 40,116,114,117,101, 41,
+     10,  9, 32,  9,101,110,100, 10, 32,  9,  9,114,101,116,117,
+    114,110, 32,115,116,114,115,117, 98, 40,115, 44, 32,101, 43,
+     49, 41, 10, 32,  9,101,110,100, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32,116,114,121, 32, 39,101,120,116,101,114,110,
+     39, 32,107,101,121,119,111,114,100, 10, 32,100,111, 10, 32,
+      9,108,111, 99, 97,108, 32, 98, 44,101, 32, 61, 32,115,116,
+    114,105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94,
+     37,115, 42,101,120,116,101,114,110, 37,115, 43, 34, 41, 10,
+     32,  9,105,102, 32, 98, 32,116,104,101,110, 10,  9,  9, 45,
+     45, 32,100,111, 32,110,111,116,104,105,110,103, 10, 32,  9,
+      9,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44, 32,101, 43, 49, 41, 10, 32,  9,101,110,100, 10, 32,
+    101,110,100, 10,  9, 10, 32, 45, 45, 32,116,114,121, 32, 39,
+    118,105,114,116,117, 97,108, 39, 32,107,101,121,119,111,114,
+    107,100, 10, 32,100,111, 10, 32,  9,108,111, 99, 97,108, 32,
+     98, 44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,105,
+    110,100, 40,115, 44, 32, 34, 94, 37,115, 42,118,105,114,116,
+    117, 97,108, 37,115, 43, 34, 41, 10, 32,  9,105,102, 32, 98,
+     32,116,104,101,110, 10, 32,  9,  9,109,101,116,104,111,100,
+    105,115,118,105,114,116,117, 97,108, 32, 61, 32,116,114,117,
+    101, 10, 32,  9,  9,114,101,116,117,114,110, 32,115,116,114,
+    115,117, 98, 40,115, 44, 32,101, 43, 49, 41, 10, 32,  9,101,
+    110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,
+    121, 32,108, 97, 98,101,108,115, 32, 40,112,117, 98,108,105,
+     99, 44, 32,112,114,105,118, 97,116,101, 44, 32,101,116, 99,
+     41, 10, 32,100,111, 10, 32,  9,108,111, 99, 97,108, 32, 98,
+     44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,115, 44, 32, 34, 94, 37,115, 42, 37,119, 42, 37,115,
+     42, 58, 91, 94, 58, 93, 34, 41, 10, 32,  9,105,102, 32, 98,
+     32,116,104,101,110, 10, 32,  9,  9,114,101,116,117,114,110,
+     32,115,116,114,115,117, 98, 40,115, 44, 32,101, 41, 32, 45,
+     45, 32,112,114,101,115,101,114,118,101, 32,116,104,101, 32,
+     91, 94, 58, 93, 10, 32,  9,101,110,100, 10, 32,101,110,100,
+     10, 10, 32, 45, 45, 32,116,114,121, 32,109,111,100,117,108,
+    101, 10, 32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98,
+     44,101, 44,110, 97,109,101, 44, 98,111,100,121, 32, 61, 32,
+    115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42,
+    109,111,100,117,108,101, 37,115, 37,115, 42, 40, 91, 95, 37,
+    119, 93, 91, 95, 37,119, 93, 42, 41, 37,115, 42, 40, 37, 98,
+    123,125, 41, 37,115, 42, 34, 41, 10, 32, 32,105,102, 32, 98,
+     32,116,104,101,110, 10, 32, 32, 32, 95, 99,117,114,114, 95,
+     99,111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115,
+     44, 98, 44,101, 41, 10, 32, 32, 32, 77,111,100,117,108,101,
+     40,110, 97,109,101, 44, 98,111,100,121, 41, 10, 32, 32, 32,
+    114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,115,
+     44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 10, 32, 45, 45, 32,116,114,121, 32,110, 97,109,101,
+    115, 97,112, 99,101, 10, 32,100,111, 10, 32, 32,108,111, 99,
+     97,108, 32, 98, 44,101, 44,110, 97,109,101, 44, 98,111,100,
+    121, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34,
+     94, 37,115, 42,110, 97,109,101,115,112, 97, 99,101, 37,115,
+     37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 93, 42,
+     41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42, 59, 63,
+     34, 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10,
+     32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61,
+     32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10,
+     32, 32, 32, 78, 97,109,101,115,112, 97, 99,101, 40,110, 97,
+    109,101, 44, 98,111,100,121, 41, 10, 32, 32, 32,114,101,116,
+    117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43,
+     49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32,116,114,121, 32,100,101,102,105,110,101, 10,
+     32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101,
+     44,110, 97,109,101, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115, 44, 34, 94, 37,115, 42, 35,100,101,102,105,110,101,
+     37,115, 37,115, 42, 40, 91, 94, 37,115, 93, 42, 41, 91, 94,
+     92,110, 93, 42, 92,110, 37,115, 42, 34, 41, 10, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,117,
+    114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117,
+     98, 40,115, 44, 98, 44,101, 41, 10, 32, 32, 32, 68,101,102,
+    105,110,101, 40,110, 97,109,101, 41, 10, 32, 32, 32,114,101,
+    116,117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101,
+     43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10,
+     10, 32, 45, 45, 32,116,114,121, 32,101,110,117,109,101,114,
+     97,116,101,115, 10, 10, 32,100,111, 10, 32, 32,108,111, 99,
+     97,108, 32, 98, 44,101, 44,110, 97,109,101, 44, 98,111,100,
+    121, 44,118, 97,114,110, 97,109,101, 32, 61, 32,115,116,114,
+    102,105,110,100, 40,115, 44, 34, 94, 37,115, 42,101,110,117,
+    109, 37,115, 43, 40, 37, 83, 42, 41, 37,115, 42, 40, 37, 98,
+    123,125, 41, 37,115, 42, 40, 91, 94, 37,115, 59, 93, 42, 41,
+     37,115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32, 32,105,102,
+     32, 98, 32,116,104,101,110, 10, 32, 32, 32, 45, 45,101,114,
+    114,111,114, 40, 34, 35, 83,111,114,114,121, 44, 32,100,101,
+     99,108, 97,114, 97,116,105,111,110, 32,111,102, 32,101,110,
+    117,109,115, 32, 97,110,100, 32,118, 97,114,105, 97, 98,108,
+    101,115, 32,111,110, 32,116,104,101, 32,115, 97,109,101, 32,
+    115,116, 97,116,101,109,101,110,116, 32,105,115, 32,110,111,
+    116, 32,115,117,112,112,111,114,116,101,100, 46, 92,110, 68,
+    101, 99,108, 97,114,101, 32,121,111,117,114, 32,118, 97,114,
+    105, 97, 98,108,101, 32,115,101,112, 97,114, 97,116,101,108,
+    121, 32, 40,101,120, 97,109,112,108,101, 58, 32, 39, 34, 46,
+     46,110, 97,109,101, 46, 46, 34, 32, 34, 46, 46,118, 97,114,
+    110, 97,109,101, 46, 46, 34, 59, 39, 41, 34, 41, 10, 32, 32,
+     32, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, 32,115,
+    116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 32, 32,
+     32, 69,110,117,109,101,114, 97,116,101, 40,110, 97,109,101,
+     44, 98,111,100,121, 44,118, 97,114,110, 97,109,101, 41, 10,
+     32, 32, 32,114,101,116,117,114,110, 32,115,116,114,115,117,
+     98, 40,115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10,
+     32,101,110,100, 10, 10, 45, 45, 32,100,111, 10, 45, 45, 32,
+     32,108,111, 99, 97,108, 32, 98, 44,101, 44,110, 97,109,101,
+     44, 98,111,100,121, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115, 44, 34, 94, 37,115, 42,101,110,117,109, 37,115, 43,
+     40, 37, 83, 42, 41, 37,115, 42, 40, 37, 98,123,125, 41, 37,
+    115, 42, 59, 63, 37,115, 42, 34, 41, 10, 45, 45, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 45, 45, 32, 32, 32, 95,
+     99,117,114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,
+    115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 45, 45, 32, 32,
+     32, 69,110,117,109,101,114, 97,116,101, 40,110, 97,109,101,
+     44, 98,111,100,121, 41, 10, 45, 45, 32, 32,114,101,116,117,
+    114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49,
+     41, 10, 45, 45, 32, 32,101,110,100, 10, 45, 45, 32,101,110,
+    100, 10, 10, 32,100,111, 10, 32, 32,108,111, 99, 97,108, 32,
+     98, 44,101, 44, 98,111,100,121, 44,110, 97,109,101, 32, 61,
+     32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115,
+     42,116,121,112,101,100,101,102, 37,115, 43,101,110,117,109,
+     91, 94,123, 93, 42, 40, 37, 98,123,125, 41, 37,115, 42, 40,
+     91, 37,119, 95, 93, 91, 94, 37,115, 93, 42, 41, 37,115, 42,
+     59, 37,115, 42, 34, 41, 10, 32, 32,105,102, 32, 98, 32,116,
+    104,101,110, 10, 32, 32, 32, 95, 99,117,114,114, 95, 99,111,
+    100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44, 98,
+     44,101, 41, 10, 32, 32, 32, 69,110,117,109,101,114, 97,116,
+    101, 40,110, 97,109,101, 44, 98,111,100,121, 41, 10, 32, 32,
+     32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,111,112,101,
+    114, 97,116,111,114, 10, 32,100,111, 10, 32, 32,108,111, 99,
+     97,108, 32, 98, 44,101, 44,100,101, 99,108, 44,107,105,110,
+    100, 44, 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40,
+     91, 95, 37,119, 93, 91, 95, 37,119, 37,115, 37, 42, 38, 58,
+     60, 62, 44, 93, 45, 37,115, 43,111,112,101,114, 97,116,111,
+    114, 41, 37,115, 42, 40, 91, 94, 37,115, 93, 91, 94, 37,115,
+     93, 42, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42,
+     40, 99, 63,111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42,
+     59, 37,115, 42, 34, 41, 10, 32, 32,105,102, 32,110,111,116,
+     32, 98, 32,116,104,101,110, 10,  9,  9, 32, 45, 45, 32,116,
+    114,121, 32,105,110,108,105,110,101, 10, 32, 32, 32, 98, 44,
+    101, 44,100,101, 99,108, 44,107,105,110,100, 44, 97,114,103,
+     44, 99,111,110,115,116, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93,
+     91, 95, 37,119, 37,115, 37, 42, 38, 58, 60, 62, 44, 93, 45,
+     37,115, 43,111,112,101,114, 97,116,111,114, 41, 37,115, 42,
+     40, 91, 94, 37,115, 93, 91, 94, 37,115, 93, 42, 41, 37,115,
+     42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,
+    110, 63,115, 63,116, 63, 41, 91, 37,115, 92,110, 93, 42, 37,
+     98,123,125, 37,115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32,
+     32,101,110,100, 10, 32, 32,105,102, 32,110,111,116, 32, 98,
+     32,116,104,101,110, 10, 32, 32,  9, 45, 45, 32,116,114,121,
+     32, 99, 97,115,116, 32,111,112,101,114, 97,116,111,114, 10,
+     32, 32,  9, 98, 44,101, 44,100,101, 99,108, 44,107,105,110,
+    100, 44, 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115, 42,
+     40,111,112,101,114, 97,116,111,114, 41, 37,115, 43, 40, 91,
+     37,119, 95, 58, 37,100, 60, 62, 37, 42, 37, 38, 37,115, 93,
+     43, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40,
+     99, 63,111, 63,110, 63,115, 63,116, 63, 41, 34, 41, 59, 10,
+     32, 32,  9,105,102, 32, 98, 32,116,104,101,110, 10, 32, 32,
+      9,  9,108,111, 99, 97,108, 32, 95, 44,105,101, 32, 61, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,115, 44, 32,
+     34, 94, 37,115, 42, 37, 98,123,125, 34, 44, 32,101, 43, 49,
+     41, 10, 32, 32,  9,  9,105,102, 32,105,101, 32,116,104,101,
+    110, 10, 32, 32,  9,  9,  9,101, 32, 61, 32,105,101, 10, 32,
+     32,  9,  9,101,110,100, 10, 32, 32,  9,101,110,100, 10, 32,
+     32,101,110,100, 10, 32, 32,105,102, 32, 98, 32,116,104,101,
+    110, 10, 32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101,
+     32, 61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101,
+     41, 10, 32, 32, 32, 79,112,101,114, 97,116,111,114, 40,100,
+    101, 99,108, 44,107,105,110,100, 44, 97,114,103, 44, 99,111,
+    110,115,116, 41, 10, 32, 32, 32,114,101,116,117,114,110, 32,
+    115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32,
+     32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,
+    116,114,121, 32,102,117,110, 99,116,105,111,110, 10, 32,100,
+    111, 10, 32, 32, 45, 45,108,111, 99, 97,108, 32, 98, 44,101,
+     44,100,101, 99,108, 44, 97,114,103, 44, 99,111,110,115,116,
+     32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94,
+     37,115, 42, 40, 91,126, 95, 37,119, 93, 91, 95, 64, 37,119,
+     37,115, 37, 42, 38, 58, 60, 62, 93, 42, 91, 95, 37,119, 93,
+     41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99,
+     63,111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 61, 63,
+     37,115, 42, 48, 63, 37,115, 42, 59, 37,115, 42, 34, 41, 10,
+     32, 32,108,111, 99, 97,108, 32, 98, 44,101, 44,100,101, 99,
+    108, 44, 97,114,103, 44, 99,111,110,115,116, 44,118,105,114,
+    116, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34,
+     94, 37,115, 42, 40, 91, 94, 37, 40, 92,110, 93, 43, 41, 37,
+    115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111,
+     63,110, 63,115, 63,116, 63, 41, 37,115, 42, 40, 61, 63, 37,
+    115, 42, 48, 63, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10,
+     32, 32,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110,
+     10, 32, 32,  9, 45, 45, 32,116,114,121, 32,102,117,110, 99,
+    116,105,111,110, 32,119,105,116,104, 32,116,101,109,112,108,
+     97,116,101, 10, 32, 32,  9, 98, 44,101, 44,100,101, 99,108,
+     44, 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,116,
+    114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91,
+    126, 95, 37,119, 93, 91, 95, 64, 37,119, 37,115, 37, 42, 38,
+     58, 60, 62, 93, 42, 91, 95, 37,119, 93, 37, 98, 60, 62, 41,
+     37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,
+    111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 61, 63, 37,
+    115, 42, 48, 63, 37,115, 42, 59, 37,115, 42, 34, 41, 10, 32,
+     32,101,110,100, 10, 32, 32,105,102, 32,110,111,116, 32, 98,
+     32,116,104,101,110, 10, 32, 32, 32, 45, 45, 32,116,114,121,
+     32, 97, 32,115,105,110,103,108,101, 32,108,101,116,116,101,
+    114, 32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101,
+     10, 32, 32, 32, 98, 44,101, 44,100,101, 99,108, 44, 97,114,
+    103, 44, 99,111,110,115,116, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119,
+     93, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40,
+     99, 63,111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 59,
+     37,115, 42, 34, 41, 10, 32, 32,101,110,100, 10, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32, 32,  9,105,102, 32,
+    118,105,114,116, 32, 97,110,100, 32,115,116,114,105,110,103,
+     46,102,105,110,100, 40,118,105,114,116, 44, 32, 34, 91, 61,
+     48, 93, 34, 41, 32,116,104,101,110, 10, 32, 32,  9,  9,105,
+    102, 32,115,101,108,102, 46,102,108, 97,103,115, 32,116,104,
+    101,110, 10, 32, 32,  9,  9,  9,115,101,108,102, 46,102,108,
+     97,103,115, 46,112,117,114,101, 95,118,105,114,116,117, 97,
+    108, 32, 61, 32,116,114,117,101, 10, 32, 32,  9,  9,101,110,
+    100, 10, 32, 32,  9,101,110,100, 10, 32, 32, 32, 95, 99,117,
+    114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117,
+     98, 40,115, 44, 98, 44,101, 41, 10, 32, 32, 32, 70,117,110,
+     99,116,105,111,110, 40,100,101, 99,108, 44, 97,114,103, 44,
+     99,111,110,115,116, 41, 10, 32, 32, 32,114,101,116,117,114,
+    110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41,
+     10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45,
+     45, 32,116,114,121, 32,105,110,108,105,110,101, 32,102,117,
+    110, 99,116,105,111,110, 10, 32,100,111, 10, 32, 32,108,111,
+     99, 97,108, 32, 98, 44,101, 44,100,101, 99,108, 44, 97,114,
+    103, 44, 99,111,110,115,116, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 94, 37, 40,
+     92,110, 93, 43, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,
+    115, 42, 40, 99, 63,111, 63,110, 63,115, 63,116, 63, 41, 91,
+     94, 59,123, 93, 42, 37, 98,123,125, 37,115, 42, 59, 63, 37,
+    115, 42, 34, 41, 10, 32, 32, 45, 45,108,111, 99, 97,108, 32,
+     98, 44,101, 44,100,101, 99,108, 44, 97,114,103, 44, 99,111,
+    110,115,116, 32, 61, 32,115,116,114,102,105,110,100, 40,115,
+     44, 34, 94, 37,115, 42, 40, 91,126, 95, 37,119, 93, 91, 95,
+     64, 37,119, 37,115, 37, 42, 38, 58, 60, 62, 93, 42, 91, 95,
+     37,119, 62, 93, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,
+    115, 42, 40, 99, 63,111, 63,110, 63,115, 63,116, 63, 41, 91,
+     94, 59, 93, 42, 37, 98,123,125, 37,115, 42, 59, 63, 37,115,
+     42, 34, 41, 10, 32, 32,105,102, 32,110,111,116, 32, 98, 32,
+    116,104,101,110, 10, 32, 32, 32, 45, 45, 32,116,114,121, 32,
+     97, 32,115,105,110,103,108,101, 32,108,101,116,116,101,114,
+     32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101, 10,
+     32, 32, 32, 98, 44,101, 44,100,101, 99,108, 44, 97,114,103,
+     44, 99,111,110,115,116, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93,
+     41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99,
+     63,111, 63,110, 63,115, 63,116, 63, 41, 46, 45, 37, 98,123,
+    125, 37,115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32, 32,101,
+    110,100, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10,
+     32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61,
+     32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10,
+     32, 32, 32, 70,117,110, 99,116,105,111,110, 40,100,101, 99,
+    108, 44, 97,114,103, 44, 99,111,110,115,116, 41, 10, 32, 32,
+     32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32, 99,108, 97,
+    115,115, 10, 32,100,111, 10,  9, 32,108,111, 99, 97,108, 32,
+     98, 44,101, 44,110, 97,109,101, 44, 98, 97,115,101, 44, 98,
+    111,100,121, 10,  9,  9, 98, 97,115,101, 32, 61, 32, 39, 39,
+     32, 98,111,100,121, 32, 61, 32, 39, 39, 10,  9,  9, 98, 44,
+    101, 44,110, 97,109,101, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42, 99,108, 97,115,115, 37,
+    115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93, 42,
+     41, 37,115, 42, 59, 34, 41, 32, 32, 45, 45, 32,100,117,109,
+    109,121, 32, 99,108, 97,115,115, 10,  9,  9,105,102, 32,110,
+    111,116, 32, 98, 32,116,104,101,110, 10,  9,  9,  9, 98, 44,
+    101, 44,110, 97,109,101, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42,115,116,114,117, 99,116,
+     37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93,
+     42, 41, 37,115, 42, 59, 34, 41, 32, 32, 32, 32, 45, 45, 32,
+    100,117,109,109,121, 32,115,116,114,117, 99,116, 10,  9,  9,
+      9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10,
+      9,  9,  9,  9, 98, 44,101, 44,110, 97,109,101, 44, 98, 97,
+    115,101, 44, 98,111,100,121, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 94, 37,115, 42, 99,108, 97,115,115,
+     37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93,
+     42, 41, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 40, 37, 98,
+    123,125, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10,  9,  9,
+      9,  9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110,
+     10,  9,  9,  9,  9,  9, 98, 44,101, 44,110, 97,109,101, 44,
+     98, 97,115,101, 44, 98,111,100,121, 32, 61, 32,115,116,114,
+    102,105,110,100, 40,115, 44, 34, 94, 37,115, 42,115,116,114,
+    117, 99,116, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,
+    119, 64, 93, 42, 41, 37,115, 42, 40, 46, 45, 41, 37,115, 42,
+     40, 37, 98,123,125, 41, 37,115, 42, 59, 37,115, 42, 34, 41,
+     10,  9,  9,  9,  9,  9,105,102, 32,110,111,116, 32, 98, 32,
+    116,104,101,110, 10,  9,  9,  9,  9,  9,  9, 98, 44,101, 44,
+    110, 97,109,101, 44, 98, 97,115,101, 44, 98,111,100,121, 32,
+     61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,
+    115, 42,117,110,105,111,110, 37,115, 42, 40, 91, 95, 37,119,
+     93, 91, 95, 37,119, 64, 93, 42, 41, 37,115, 42, 40, 46, 45,
+     41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42, 59, 37,
+    115, 42, 34, 41, 10,  9,  9,  9,  9,  9,  9,105,102, 32,110,
+    111,116, 32, 98, 32,116,104,101,110, 10,  9,  9,  9,  9,  9,
+      9,  9, 98, 97,115,101, 32, 61, 32, 39, 39, 10,  9,  9,  9,
+      9,  9,  9,  9, 98, 44,101, 44, 98,111,100,121, 44,110, 97,
+    109,101, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44,
+     34, 94, 37,115, 42,116,121,112,101,100,101,102, 37,115, 37,
+    115, 42,115,116,114,117, 99,116, 37,115, 37,115, 42, 91, 95,
+     37,119, 93, 42, 37,115, 42, 40, 37, 98,123,125, 41, 37,115,
+     42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93, 42, 41,
+     37,115, 42, 59, 37,115, 42, 34, 41, 10,  9,  9,  9,  9,  9,
+      9,101,110,100, 10,  9,  9,  9,  9,  9,101,110,100, 10,  9,
+      9,  9,  9,101,110,100, 10,  9,  9,  9,101,110,100, 10,  9,
+      9,101,110,100, 10,  9,  9,105,102, 32, 98, 32,116,104,101,
+    110, 10,  9,  9,  9,105,102, 32, 98, 97,115,101, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 10,  9,  9,  9,  9, 98, 97,
+    115,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40, 98, 97,115,101, 44, 32, 34, 94, 37,115, 42, 58, 37,
+    115, 42, 34, 44, 32, 34, 34, 41, 10,  9,  9,  9,  9, 98, 97,
+    115,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40, 98, 97,115,101, 44, 32, 34, 37,115, 42,112,117, 98,
+    108,105, 99, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,  9,  9,
+      9,  9, 98, 97,115,101, 32, 61, 32,115,112,108,105,116, 40,
+     98, 97,115,101, 44, 32, 34, 44, 34, 41, 10,  9,  9,  9,  9,
+     45, 45,108,111, 99, 97,108, 32, 98, 44,101, 10,  9,  9,  9,
+      9, 45, 45, 98, 44,101, 44, 98, 97,115,101, 32, 61, 32,115,
+    116,114,102,105,110,100, 40, 98, 97,115,101, 44, 34, 46, 45,
+     40, 91, 95, 37,119, 93, 91, 95, 37,119, 60, 62, 44, 58, 93,
+     42, 41, 36, 34, 41, 10,  9,  9,  9,101,108,115,101, 10,  9,
+      9,  9,  9, 98, 97,115,101, 32, 61, 32,123,125, 10,  9,  9,
+      9,101,110,100, 10,  9,  9,  9, 95, 99,117,114,114, 95, 99,
+    111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44,
+     98, 44,101, 41, 10,  9,  9,  9, 67,108, 97,115,115, 40,110,
+     97,109,101, 44, 98, 97,115,101, 44, 98,111,100,121, 41, 10,
+      9,  9,  9,114,101,116,117,114,110, 32,115,116,114,115,117,
+     98, 40,115, 44,101, 43, 49, 41, 10,  9,  9,101,110,100, 10,
+      9,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,116,
+    121,112,101,100,101,102, 10, 32,100,111, 10, 32, 32,108,111,
+     99, 97,108, 32, 98, 44,101, 44,116,121,112,101,115, 32, 61,
+     32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115,
+     42,116,121,112,101,100,101,102, 37,115, 37,115, 42, 40, 46,
+     45, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,117,
+    114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117,
+     98, 40,115, 44, 98, 44,101, 41, 10, 32, 32, 32, 84,121,112,
+    101,100,101,102, 40,116,121,112,101,115, 41, 10, 32, 32, 32,
+    114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,115,
+     44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 10, 32, 45, 45, 32,116,114,121, 32,118, 97,114,105,
+     97, 98,108,101, 10, 32,100,111, 10, 32, 32,108,111, 99, 97,
+    108, 32, 98, 44,101, 44,100,101, 99,108, 32, 61, 32,115,116,
+    114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91,
+     95, 37,119, 93, 91, 95, 64, 37,115, 37,119, 37,100, 37, 42,
+     38, 58, 60, 62, 44, 93, 42, 91, 95, 37,119, 37,100, 93, 41,
+     37,115, 42, 59, 37,115, 42, 34, 41, 10, 32, 32,105,102, 32,
+     98, 32,116,104,101,110, 10, 32, 32, 32, 95, 99,117,114,114,
+     95, 99,111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40,
+    115, 44, 98, 44,101, 41, 10, 10,  9,108,111, 99, 97,108, 32,
+    108,105,115,116, 32, 61, 32,115,112,108,105,116, 95, 99, 95,
+    116,111,107,101,110,115, 40,100,101, 99,108, 44, 32, 34, 44,
+     34, 41, 10,  9, 86, 97,114,105, 97, 98,108,101, 40,108,105,
+    115,116, 91, 49, 93, 41, 10,  9,105,102, 32,108,105,115,116,
+     46,110, 32, 62, 32, 49, 32,116,104,101,110, 10,  9,  9,108,
+    111, 99, 97,108, 32, 95, 44, 95, 44,116,121,112,101, 32, 61,
+     32,115,116,114,102,105,110,100, 40,108,105,115,116, 91, 49,
+     93, 44, 32, 34, 40, 46, 45, 41, 37,115, 43, 40, 91, 94, 37,
+    115, 93, 42, 41, 36, 34, 41, 59, 10, 10,  9,  9,108,111, 99,
+     97,108, 32,105, 32, 61, 50, 59, 10,  9,  9,119,104,105,108,
+    101, 32,108,105,115,116, 91,105, 93, 32,100,111, 10,  9,  9,
+      9, 86, 97,114,105, 97, 98,108,101, 40,116,121,112,101, 46,
+     46, 34, 32, 34, 46, 46,108,105,115,116, 91,105, 93, 41, 10,
+      9,  9,  9,105, 61,105, 43, 49, 10,  9,  9,101,110,100, 10,
+      9,101,110,100, 10, 32, 32, 32, 45, 45, 86, 97,114,105, 97,
+     98,108,101, 40,100,101, 99,108, 41, 10, 32, 32, 32,114,101,
+    116,117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101,
+     43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10,
+     10,  9, 45, 45, 32,116,114,121, 32,115,116,114,105,110,103,
+     10, 32,100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,
+    101, 44,100,101, 99,108, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93,
+     63, 91, 95, 37,115, 37,119, 37,100, 93, 45, 99,104, 97,114,
+     37,115, 43, 91, 95, 64, 37,119, 37,100, 93, 42, 37,115, 42,
+     37, 91, 37,115, 42, 37, 83, 43, 37,115, 42, 37, 93, 41, 37,
+    115, 42, 59, 37,115, 42, 34, 41, 10, 32, 32,105,102, 32, 98,
+     32,116,104,101,110, 10, 32, 32, 32, 95, 99,117,114,114, 95,
+     99,111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115,
+     44, 98, 44,101, 41, 10, 32, 32, 32, 86, 97,114,105, 97, 98,
+    108,101, 40,100,101, 99,108, 41, 10, 32, 32, 32,114,101,116,
+    117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43,
+     49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32,116,114,121, 32, 97,114,114, 97,121, 10, 32,
+    100,111, 10, 32, 32,108,111, 99, 97,108, 32, 98, 44,101, 44,
+    100,101, 99,108, 32, 61, 32,115,116,114,102,105,110,100, 40,
+    115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 93,
+     91, 95, 64, 37,115, 37,119, 37,100, 37, 42, 38, 58, 93, 42,
+     91, 93, 95, 37,119, 37,100, 93, 41, 37,115, 42, 59, 37,115,
+     42, 34, 41, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110,
+     10, 32, 32, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32,
+     61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41,
+     10, 32, 32, 32, 65,114,114, 97,121, 40,100,101, 99,108, 41,
+     10, 32, 32, 32,114,101,116,117,114,110, 32,115,116,114,115,
+    117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100,
+     10, 32,101,110,100, 10, 10, 32, 45, 45, 32,110,111, 32,109,
+     97,116, 99,104,105,110,103, 10, 32,105,102, 32,103,115,117,
+     98, 40,115, 44, 34, 37,115, 37,115, 42, 34, 44, 34, 34, 41,
+     32,126, 61, 32, 34, 34, 32,116,104,101,110, 10, 32, 32, 95,
+     99,117,114,114, 95, 99,111,100,101, 32, 61, 32,115, 10, 32,
+     32,101,114,114,111,114, 40, 34, 35,112, 97,114,115,101, 32,
+    101,114,114,111,114, 34, 41, 10, 32,101,108,115,101, 10, 32,
+     32,114,101,116,117,114,110, 32, 34, 34, 10, 32,101,110,100,
+     10, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     58,112, 97,114,115,101, 32, 40,115, 41, 10, 10,  9,115,101,
+    108,102, 46, 99,117,114,114, 95,109,101,109, 98,101,114, 95,
+     97, 99, 99,101,115,115, 32, 61, 32,110,105,108, 10, 10, 32,
+    119,104,105,108,101, 32,115, 32,126, 61, 32, 39, 39, 32,100,
+    111, 10, 32, 32,115, 32, 61, 32,115,101,108,102, 58,100,111,
+    112, 97,114,115,101, 40,115, 41, 10, 32, 32,109,101,116,104,
+    111,100,105,115,118,105,114,116,117, 97,108, 32, 61, 32,102,
+     97,108,115,101, 10, 32,101,110,100, 10,101,110,100, 10, 10,
+     10, 45, 45, 32,112,114,111,112,101,114,116,121, 32,116,121,
+    112,101,115, 10, 10,102,117,110, 99,116,105,111,110, 32,103,
+    101,116, 95,112,114,111,112,101,114,116,121, 95,116,121,112,
+    101, 40, 41, 10, 10,  9,114,101,116,117,114,110, 32, 99,108,
+     97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,
+    114,114, 58,103,101,116, 95,112,114,111,112,101,114,116,121,
+     95,116,121,112,101, 40, 41, 10,101,110,100, 10, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,110,
+    116, 97,105,110,101,114, 58,115,101,116, 95,112,114,111,112,
+    101,114,116,121, 95,116,121,112,101, 40,112,116,121,112,101,
+     41, 10,  9,112,116,121,112,101, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,112,116,121,112,101, 44, 32,
+     34, 94, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,  9,112,116,
+    121,112,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40,112,116,121,112,101, 44, 32, 34, 37,115, 42, 36,
+     34, 44, 32, 34, 34, 41, 10, 10,  9,115,101,108,102, 46,112,
+    114,111,112,101,114,116,121, 95,116,121,112,101, 32, 61, 32,
+    112,116,121,112,101, 10,101,110,100, 10, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,
+    105,110,101,114, 58,103,101,116, 95,112,114,111,112,101,114,
+    116,121, 95,116,121,112,101, 40, 41, 10,  9,114,101,116,117,
+    114,110, 32,115,101,108,102, 46,112,114,111,112,101,114,116,
+    121, 95,116,121,112,101, 32,111,114, 32, 40,115,101,108,102,
+     46,112, 97,114,101,110,116, 32, 97,110,100, 32,115,101,108,
+    102, 46,112, 97,114,101,110,116, 58,103,101,116, 95,112,114,
+    111,112,101,114,116,121, 95,116,121,112,101, 40, 41, 41, 32,
+    111,114, 32, 34,100,101,102, 97,117,108,116, 34, 10,101,110,
+    100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/container.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,112, 97, 99,107, 97,
+    103,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,
+    116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,
+    114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,
+    114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32,
+     74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100,
+     58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,
+    100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,
+    119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,
+    101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32,
+     97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,
+    116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119,
+     97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,
+    114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,
+    110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115,
+     44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,
+    116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,
+    105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,
+    105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101,
+     44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,
+    116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,
+    109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,
+    105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45,
+     32, 80, 97, 99,107, 97,103,101, 32, 99,108, 97,115,115, 10,
+     45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32,116,
+    104,101, 32,119,104,111,108,101, 32,112, 97, 99,107, 97,103,
+    101, 32, 98,101,105,110,103, 32, 98,111,117,110,100, 46, 10,
+     45, 45, 32, 84,104,101, 32,102,111,108,108,111,119,105,110,
+    103, 32,102,105,101,108,100,115, 32, 97,114,101, 32,115,116,
+    111,114,101,100, 58, 10, 45, 45, 32, 32, 32, 32,123,105,125,
+     32, 61, 32,108,105,115,116, 32,111,102, 32,111, 98,106,101,
+     99,116,115, 32,105,110, 32,116,104,101, 32,112, 97, 99,107,
+     97,103,101, 46, 10, 99,108, 97,115,115, 80, 97, 99,107, 97,
+    103,101, 32, 61, 32,123, 10, 32, 99,108, 97,115,115,116,121,
+    112,101, 32, 61, 32, 39,112, 97, 99,107, 97,103,101, 39, 10,
+    125, 10, 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 46,
+     95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115,
+     80, 97, 99,107, 97,103,101, 10,115,101,116,109,101,116, 97,
+    116, 97, 98,108,101, 40, 99,108, 97,115,115, 80, 97, 99,107,
+     97,103,101, 44, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 41, 10, 10, 45, 45, 32, 80,114,105,110,116, 32,
+    109,101,116,104,111,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,112,
+    114,105,110,116, 32, 40, 41, 10, 32,112,114,105,110,116, 40,
+     34, 80, 97, 99,107, 97,103,101, 58, 32, 34, 46, 46,115,101,
+    108,102, 46,110, 97,109,101, 41, 10, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,
+    105, 93, 58,112,114,105,110,116, 40, 34, 34, 44, 34, 34, 41,
+     10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100,
+     10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,112,114,
+    101,112,114,111, 99,101,115,115, 32, 40, 41, 10, 10, 32, 45,
+     45, 32, 97,118,111,105,100, 32,112,114,101,112,114,111, 99,
+    101,115,115,105,110,103, 32,101,109, 98,101,100,100,101,100,
+     32, 76,117, 97, 32, 99,111,100,101, 10, 32,108,111, 99, 97,
+    108, 32, 76, 32, 61, 32,123,125, 10, 32,115,101,108,102, 46,
+     99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,
+    102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 37, 36,
+     37, 91, 34, 44, 34, 92, 49, 34, 41, 32, 45, 45, 32,100,101,
+     97,108, 32,119,105,116,104, 32,101,109, 98,101,100,100,101,
+    100, 32,108,117, 97, 32, 99,111,100,101, 10, 32,115,101,108,
+    102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,
+    101,108,102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42,
+     37, 36, 37, 93, 34, 44, 34, 92, 50, 34, 41, 10, 32,115,101,
+    108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,
+    115,101,108,102, 46, 99,111,100,101, 44, 34, 40, 37, 98, 92,
+     49, 92, 50, 41, 34, 44, 32, 32, 32, 32, 32, 32, 32,102,117,
+    110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116,105,
+    110,115,101,114,116, 40, 76, 44, 99, 41, 10, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,
+    116,117,114,110, 32, 34, 92,110, 35, 91, 34, 46, 46,103,101,
+    116,110, 40, 76, 41, 46, 46, 34, 93, 35, 34, 10, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,
+    100, 41, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,114,
+    101,112,114,111, 99,101,115,115,105,110,103, 32,101,109, 98,
+    101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,108,
+    111, 99, 97,108, 32, 67, 32, 61, 32,123,125, 10, 32,115,101,
+    108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,
+    115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110, 37,115,
+     42, 37, 36, 37, 60, 34, 44, 34, 92, 51, 34, 41, 32, 45, 45,
+     32,100,101, 97,108, 32,119,105,116,104, 32,101,109, 98,101,
+    100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,115,101,
+    108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,
+    115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110, 37,115,
+     42, 37, 36, 37, 62, 34, 44, 34, 92, 52, 34, 41, 10, 32,115,
+    101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98,
+     40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40, 37, 98,
+     92, 51, 92, 52, 41, 34, 44, 32, 32, 32, 32, 32, 32, 32,102,
+    117,110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116,
+    105,110,115,101,114,116, 40, 67, 44, 99, 41, 10, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,
+    101,116,117,114,110, 32, 34, 92,110, 35, 60, 34, 46, 46,103,
+    101,116,110, 40, 67, 41, 46, 46, 34, 62, 35, 34, 10, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
+    110,100, 41, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,
+    114,101,112,114,111, 99,101,115,115,105,110,103, 32,101,109,
+     98,101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,
+    115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117,
+     98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110,
+     37,115, 42, 37, 36, 37,123, 34, 44, 34, 92, 53, 34, 41, 32,
+     45, 45, 32,100,101, 97,108, 32,119,105,116,104, 32,101,109,
+     98,101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,
+    115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117,
+     98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 92,110,
+     37,115, 42, 37, 36, 37,125, 34, 44, 34, 92, 54, 34, 41, 10,
+     32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,
+    117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40,
+     37, 98, 92, 53, 92, 54, 41, 34, 44, 32, 32, 32, 32, 32, 32,
+     32,102,117,110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,116,105,110,115,101,114,116, 40, 67, 44, 99, 41, 10, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,114,101,116,117,114,110, 32, 34, 92,110, 35, 60, 34, 46,
+     46,103,101,116,110, 40, 67, 41, 46, 46, 34, 62, 35, 34, 10,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,101,110,100, 41, 10, 10, 32, 45, 45,115,101,108,102, 46,
+     99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,
+    102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 35, 91,
+     94,100, 93, 91, 94, 92,110, 93, 42, 92,110, 34, 44, 32, 34,
+     92,110, 92,110, 34, 41, 32, 45, 45, 32,101,108,105,109,105,
+    110, 97,116,101, 32,112,114,101,112,114,111, 99,101,115,115,
+    111,114, 32,100,105,114,101, 99,116,105,118,101,115, 32,116,
+    104, 97,116, 32,100,111,110, 39,116, 32,115,116, 97,114,116,
+     32,119,105,116,104, 32, 39,100, 39, 10, 32,115,101,108,102,
+     46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46, 99,111,100,101, 44, 34, 92,110, 91, 32, 92,116,
+     93, 42, 35, 91, 32, 92,116, 93, 42, 91, 94,100, 37, 60, 37,
+     91, 93, 34, 44, 32, 34, 92,110, 47, 47, 34, 41, 32, 45, 45,
+     32,101,108,105,109,105,110, 97,116,101, 32,112,114,101,112,
+    114,111, 99,101,115,115,111,114, 32,100,105,114,101, 99,116,
+    105,118,101,115, 32,116,104, 97,116, 32,100,111,110, 39,116,
+     32,115,116, 97,114,116, 32,119,105,116,104, 32, 39,100, 39,
+     10, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,114,101,
+    112,114,111, 99,101,115,115,105,110,103, 32,118,101,114, 98,
+     97,116,105,109, 32,108,105,110,101,115, 10, 32,108,111, 99,
+     97,108, 32, 86, 32, 61, 32,123,125, 10, 32,115,101,108,102,
+     46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46, 99,111,100,101, 44, 34, 92,110, 40, 37,115, 42,
+     37, 36, 91, 94, 37, 91, 37, 93, 93, 91, 94, 92,110, 93, 42,
+     41, 34, 44,102,117,110, 99,116,105,111,110, 32, 40,118, 41,
+     10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32,116,105,110,115,101,114,116, 40, 86, 44,118, 41,
+     10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32,114,101,116,117,114,110, 32, 34, 92,110, 35, 34,
+     46, 46,103,101,116,110, 40, 86, 41, 46, 46, 34, 35, 34, 10,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,101,110,100, 41, 10, 10, 32, 45, 45, 32,112,101,114,102,
+    111,114,109, 32,103,108,111, 98, 97,108, 32,115,117, 98,115,
+    116,105,116,117,116,105,111,110, 10, 10, 32,115,101,108,102,
+     46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46, 99,111,100,101, 44, 34, 40, 47, 47, 91, 94, 92,
+    110, 93, 42, 41, 34, 44, 34, 34, 41, 32, 32, 32, 32, 32, 45,
+     45, 32,101,108,105,109,105,110, 97,116,101, 32, 67, 43, 43,
+     32, 99,111,109,109,101,110,116,115, 10, 32,115,101,108,102,
+     46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46, 99,111,100,101, 44, 34, 47, 37, 42, 34, 44, 34,
+     92, 49, 34, 41, 10, 32,115,101,108,102, 46, 99,111,100,101,
+     32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,
+    100,101, 44, 34, 37, 42, 47, 34, 44, 34, 92, 50, 34, 41, 10,
+     32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,
+    117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 37,
+     98, 92, 49, 92, 50, 34, 44, 34, 34, 41, 10, 32,115,101,108,
+    102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,
+    101,108,102, 46, 99,111,100,101, 44, 34, 92, 49, 34, 44, 34,
+     47, 37, 42, 34, 41, 10, 32,115,101,108,102, 46, 99,111,100,
+    101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,
+    111,100,101, 44, 34, 92, 50, 34, 44, 34, 37, 42, 47, 34, 41,
+     10, 32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,
+    115,117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34,
+     37,115, 42, 64, 37,115, 42, 34, 44, 34, 64, 34, 41, 32, 45,
+     45, 32,101,108,105,109,105,110, 97,116,101, 32,115,112, 97,
+     99,101,115, 32, 98,101,115,105,100,101, 32, 64, 10, 32,115,
+    101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98,
+     40,115,101,108,102, 46, 99,111,100,101, 44, 34, 37,115, 63,
+    105,110,108,105,110,101, 40, 37,115, 41, 34, 44, 34, 37, 49,
+     34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 39,105,110,108,105,110,101, 39, 32,107,101,121,119,111,
+    114,100, 10, 32, 45, 45,115,101,108,102, 46, 99,111,100,101,
+     32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,
+    100,101, 44, 34, 37,115, 63,101,120,116,101,114,110, 40, 37,
+    115, 41, 34, 44, 34, 37, 49, 34, 41, 32, 45, 45, 32,101,108,
+    105,109,105,110, 97,116,101, 32, 39,101,120,116,101,114,110,
+     39, 32,107,101,121,119,111,114,100, 10, 32, 45, 45,115,101,
+    108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,
+    115,101,108,102, 46, 99,111,100,101, 44, 34, 37,115, 63,118,
+    105,114,116,117, 97,108, 40, 37,115, 41, 34, 44, 34, 37, 49,
+     34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 39,118,105,114,116,117, 97,108, 39, 32,107,101,121,119,
+    111,114,100, 10, 32, 45, 45,115,101,108,102, 46, 99,111,100,
+    101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,
+    111,100,101, 44, 34,112,117, 98,108,105, 99, 58, 34, 44, 34,
+     34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 39,112,117, 98,108,105, 99, 58, 39, 32,107,101,121,119,
+    111,114,100, 10, 32,115,101,108,102, 46, 99,111,100,101, 32,
+     61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,100,
+    101, 44, 34, 40, 91, 94, 37,119, 95, 93, 41,118,111,105,100,
+     37,115, 42, 37, 42, 34, 44, 34, 37, 49, 95,117,115,101,114,
+    100, 97,116, 97, 32, 34, 41, 32, 45, 45, 32,115,117, 98,115,
+    116,105,116,117,116,101, 32, 39,118,111,105,100, 42, 39, 10,
+     32,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,
+    117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40,
+     91, 94, 37,119, 95, 93, 41,118,111,105,100, 37,115, 42, 37,
+     42, 34, 44, 34, 37, 49, 95,117,115,101,114,100, 97,116, 97,
+     32, 34, 41, 32, 45, 45, 32,115,117, 98,115,116,105,116,117,
+    116,101, 32, 39,118,111,105,100, 42, 39, 10, 32,115,101,108,
+    102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,
+    101,108,102, 46, 99,111,100,101, 44, 34, 40, 91, 94, 37,119,
+     95, 93, 41, 99,104, 97,114, 37,115, 42, 37, 42, 34, 44, 34,
+     37, 49, 95, 99,115,116,114,105,110,103, 32, 34, 41, 32, 32,
+     45, 45, 32,115,117, 98,115,116,105,116,117,116,101, 32, 39,
+     99,104, 97,114, 42, 39, 10, 32,115,101,108,102, 46, 99,111,
+    100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46,
+     99,111,100,101, 44, 34, 40, 91, 94, 37,119, 95, 93, 41,108,
+    117, 97, 95, 83,116, 97,116,101, 37,115, 42, 37, 42, 34, 44,
+     34, 37, 49, 95,108,115,116, 97,116,101, 32, 34, 41, 32, 32,
+     45, 45, 32,115,117, 98,115,116,105,116,117,116,101, 32, 39,
+    108,117, 97, 95, 83,116, 97,116,101, 42, 39, 10, 10, 32, 45,
+     45, 32,114,101,115,116,111,114,101, 32,101,109, 98,101,100,
+    100,101,100, 32, 76,117, 97, 32, 99,111,100,101, 10, 32,115,
+    101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98,
+     40,115,101,108,102, 46, 99,111,100,101, 44, 34, 37, 35, 37,
+     91, 40, 37,100, 43, 41, 37, 93, 37, 35, 34, 44,102,117,110,
+     99,116,105,111,110, 32, 40,110, 41, 10, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,
+    114,110, 32, 76, 91,116,111,110,117,109, 98,101,114, 40,110,
+     41, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,101,110,100, 41, 10, 32, 45, 45, 32,114,101,115,116,
+    111,114,101, 32,101,109, 98,101,100,100,101,100, 32, 67, 32,
+     99,111,100,101, 10, 32,115,101,108,102, 46, 99,111,100,101,
+     32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,
+    100,101, 44, 34, 37, 35, 37, 60, 40, 37,100, 43, 41, 37, 62,
+     37, 35, 34, 44,102,117,110, 99,116,105,111,110, 32, 40,110,
+     41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,114,101,116,117,114,110, 32, 67, 91,116,111,110,117,
+    109, 98,101,114, 40,110, 41, 93, 10, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 41, 10, 32, 45,
+     45, 32,114,101,115,116,111,114,101, 32,118,101,114, 98, 97,
+    116,105,109, 32,108,105,110,101,115, 10, 32,115,101,108,102,
+     46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46, 99,111,100,101, 44, 34, 37, 35, 40, 37,100, 43,
+     41, 37, 35, 34, 44,102,117,110, 99,116,105,111,110, 32, 40,
+    110, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,
+    101,116,117,114,110, 32, 86, 91,116,111,110,117,109, 98,101,
+    114, 40,110, 41, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,101,110,100, 41, 10, 10, 32,115,101,108,102, 46, 99,111,
+    100,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40,115,101,108,102, 46, 99,111,100,101, 44, 32, 34, 92,
+    110, 37,115, 42, 37, 36, 40, 91, 94, 92,110, 93, 43, 41, 34,
+     44, 32,102,117,110, 99,116,105,111,110, 32, 40,108, 41, 10,
+      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 86,101,114, 98,
+     97,116,105,109, 40,108, 46, 46, 34, 92,110, 34, 41, 10,  9,
+      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,114,101,116,117,114,
+    110, 32, 34, 92,110, 34, 10,  9,  9,  9,  9,  9,  9,  9,  9,
+      9,  9, 32, 32,101,110,100, 41, 10,101,110,100, 10, 10, 45,
+     45, 32,116,114, 97,110,115,108, 97,116,101, 32,118,101,114,
+     98, 97,116,105,109, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,112,114,
+    101, 97,109, 98,108,101, 32, 40, 41, 10, 32,111,117,116,112,
+    117,116, 40, 39, 47, 42, 92,110, 39, 41, 10, 32,111,117,116,
+    112,117,116, 40, 39, 42, 42, 32, 76,117, 97, 32, 98,105,110,
+    100,105,110,103, 58, 32, 39, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 39, 92,110, 39, 41, 10, 32,111,117,116,
+    112,117,116, 40, 39, 42, 42, 32, 71,101,110,101,114, 97,116,
+    101,100, 32, 97,117,116,111,109, 97,116,105, 99, 97,108,108,
+    121, 32, 98,121, 32, 39, 46, 46, 84, 79, 76, 85, 65, 95, 86,
+     69, 82, 83, 73, 79, 78, 46, 46, 39, 32,111,110, 32, 39, 46,
+     46,100, 97,116,101, 40, 41, 46, 46, 39, 46, 92,110, 39, 41,
+     10, 32,111,117,116,112,117,116, 40, 39, 42, 47, 92,110, 92,
+    110, 39, 41, 10, 10,  9,111,117,116,112,117,116, 40, 39, 35,
+    105,102,110,100,101,102, 32, 95, 95, 99,112,108,117,115,112,
+    108,117,115, 92,110, 39, 41, 10,  9,111,117,116,112,117,116,
+     40, 39, 35,105,110, 99,108,117,100,101, 32, 34,115,116,100,
+    108,105, 98, 46,104, 34, 92,110, 39, 41, 10,  9,111,117,116,
+    112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41,
+     10,  9,111,117,116,112,117,116, 40, 39, 35,105,110, 99,108,
+    117,100,101, 32, 34,115,116,114,105,110,103, 46,104, 34, 92,
+    110, 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40, 39,
+     35,105,110, 99,108,117,100,101, 32, 34,116,111,108,117, 97,
+     43, 43, 46,104, 34, 92,110, 92,110, 39, 41, 10, 10, 32,105,
+    102, 32,110,111,116, 32,102,108, 97,103,115, 46,104, 32,116,
+    104,101,110, 10, 32, 32,111,117,116,112,117,116, 40, 39, 47,
+     42, 32, 69,120,112,111,114,116,101,100, 32,102,117,110, 99,
+    116,105,111,110, 32, 42, 47, 39, 41, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 84, 79, 76, 85, 65, 95, 65, 80, 73, 32,
+    105,110,116, 32, 32,116,111,108,117, 97, 95, 39, 46, 46,115,
+    101,108,102, 46,110, 97,109,101, 46, 46, 39, 95,111,112,101,
+    110, 32, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,
+    111,108,117, 97, 95, 83, 41, 59, 39, 41, 10, 32, 32,111,117,
+    116,112,117,116, 40, 39, 92,110, 39, 41, 10, 32,101,110,100,
+     10, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,
+    104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111,
+     10, 32, 32,115,101,108,102, 91,105, 93, 58,112,114,101, 97,
+    109, 98,108,101, 40, 41, 10, 32, 32,105, 32, 61, 32,105, 43,
+     49, 10, 32,101,110,100, 10, 10,  9,105,102, 32,115,101,108,
+    102, 58,114,101,113,117,105,114,101, 99,111,108,108,101, 99,
+    116,105,111,110, 40, 95, 99,111,108,108,101, 99,116, 41, 32,
+    116,104,101,110, 10,  9,  9,111,117,116,112,117,116, 40, 39,
+     92,110, 39, 41, 10,  9,  9,111,117,116,112,117,116, 40, 39,
+     47, 42, 32,102,117,110, 99,116,105,111,110, 32,116,111, 32,
+    114,101,108,101, 97,115,101, 32, 99,111,108,108,101, 99,116,
+    101,100, 32,111, 98,106,101, 99,116, 32,118,105, 97, 32,100,
+    101,115,116,114,117, 99,116,111,114, 32, 42, 47, 39, 41, 10,
+      9,  9,111,117,116,112,117,116, 40, 39, 35,105,102,100,101,
+    102, 32, 95, 95, 99,112,108,117,115,112,108,117,115, 92,110,
+     39, 41, 10,  9,  9,102,111,114, 32,105, 44,118, 32,105,110,
+     32,112, 97,105,114,115, 40, 95, 99,111,108,108,101, 99,116,
+     41, 32,100,111, 10,  9,  9, 32,111,117,116,112,117,116, 40,
+     39, 92,110,115,116, 97,116,105, 99, 32,105,110,116, 32, 39,
+     46, 46,118, 46, 46, 39, 32, 40,108,117, 97, 95, 83,116, 97,
+    116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 39, 41, 10,
+      9,  9,  9,111,117,116,112,117,116, 40, 39,123, 39, 41, 10,
+      9,  9,  9,111,117,116,112,117,116, 40, 39, 32, 39, 46, 46,
+    105, 46, 46, 39, 42, 32,115,101,108,102, 32, 61, 32, 40, 39,
+     46, 46,105, 46, 46, 39, 42, 41, 32,116,111,108,117, 97, 95,
+    116,111,117,115,101,114,116,121,112,101, 40,116,111,108,117,
+     97, 95, 83, 44, 49, 44, 48, 41, 59, 39, 41, 10,  9,  9,  9,
+    111,117,116,112,117,116, 40, 39,  9,100,101,108,101,116,101,
+     32,115,101,108,102, 59, 39, 41, 10,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39,  9,114,101,116,117,114,110, 32, 48, 59,
+     39, 41, 10,  9,  9,  9,111,117,116,112,117,116, 40, 39,125,
+     39, 41, 10,  9,  9,101,110,100, 10,  9,  9,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 92,110, 39,
+     41, 10,  9,101,110,100, 10, 10, 32,111,117,116,112,117,116,
+     40, 39, 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40,
+     39, 47, 42, 32,102,117,110, 99,116,105,111,110, 32,116,111,
+     32,114,101,103,105,115,116,101,114, 32,116,121,112,101, 32,
+     42, 47, 39, 41, 10, 32,111,117,116,112,117,116, 40, 39,115,
+    116, 97,116,105, 99, 32,118,111,105,100, 32,116,111,108,117,
+     97, 95,114,101,103, 95,116,121,112,101,115, 32, 40,108,117,
+     97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117, 97, 95,
+     83, 41, 39, 41, 10, 32,111,117,116,112,117,116, 40, 39,123,
+     39, 41, 10, 32,102,111,114,101, 97, 99,104, 40, 95,117,115,
+    101,114,116,121,112,101, 44,102,117,110, 99,116,105,111,110,
+     40,110, 44,118, 41, 32,111,117,116,112,117,116, 40, 39, 32,
+    116,111,108,117, 97, 95,117,115,101,114,116,121,112,101, 40,
+    116,111,108,117, 97, 95, 83, 44, 34, 39, 44,118, 44, 39, 34,
+     41, 59, 39, 41, 32,101,110,100, 41, 10,  9,105,102, 32,102,
+    108, 97,103,115, 46,116, 32,116,104,101,110, 10,  9,  9,111,
+    117,116,112,117,116, 40, 34, 35,105,102,110,100,101,102, 32,
+     77,116,111,108,117, 97, 95,116,121,112,101,105,100, 92,110,
+     35,100,101,102,105,110,101, 32, 77,116,111,108,117, 97, 95,
+    116,121,112,101,105,100, 40, 76, 44, 84, 73, 44, 84, 41, 92,
+    110, 35,101,110,100,105,102, 92,110, 34, 41, 10,  9,  9,102,
+    111,114,101, 97, 99,104, 40, 95,117,115,101,114,116,121,112,
+    101, 44,102,117,110, 99,116,105,111,110, 40,110, 44,118, 41,
+     32,111,117,116,112,117,116, 40, 39, 32, 77,116,111,108,117,
+     97, 95,116,121,112,101,105,100, 40,116,111,108,117, 97, 95,
+     83, 44,116,121,112,101,105,100, 40, 39, 44,118, 44, 39, 41,
+     44, 32, 34, 39, 44,118, 44, 39, 34, 41, 59, 39, 41, 32,101,
+    110,100, 41, 10,  9,101,110,100, 10, 32,111,117,116,112,117,
+    116, 40, 39,125, 39, 41, 10, 32,111,117,116,112,117,116, 40,
+     39, 92,110, 39, 41, 10,101,110,100, 10, 10, 45, 45, 32,114,
+    101,103,105,115,116,101,114, 32,112, 97, 99,107, 97,103,101,
+     10, 45, 45, 32,119,114,105,116,101, 32,112, 97, 99,107, 97,
+    103,101, 32,111,112,101,110, 32,102,117,110, 99,116,105,111,
+    110, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 80, 97, 99,107, 97,103,101, 58,114,101,103,105,115,116,
+    101,114, 32, 40,112,114,101, 41, 10, 32,112,114,101, 32, 61,
+     32,112,114,101, 32,111,114, 32, 39, 39, 10, 32,112,117,115,
+    104, 40,115,101,108,102, 41, 10, 32,111,117,116,112,117,116,
+     40,112,114,101, 46, 46, 34, 47, 42, 32, 79,112,101,110, 32,
+    102,117,110, 99,116,105,111,110, 32, 42, 47, 34, 41, 10, 32,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 84, 79,
+     76, 85, 65, 95, 65, 80, 73, 32,105,110,116, 32,116,111,108,
+    117, 97, 95, 34, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 34, 95,111,112,101,110, 32, 40,108,117, 97, 95, 83,
+    116, 97,116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 34,
+     41, 10, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46,
+     34,123, 34, 41, 10, 32,111,117,116,112,117,116, 40,112,114,
+    101, 46, 46, 34, 32,116,111,108,117, 97, 95,111,112,101,110,
+     40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41, 10, 32,111,
+    117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,116,111,
+    108,117, 97, 95,114,101,103, 95,116,121,112,101,115, 40,116,
+    111,108,117, 97, 95, 83, 41, 59, 34, 41, 10, 32,111,117,116,
+    112,117,116, 40,112,114,101, 46, 46, 34, 32,116,111,108,117,
+     97, 95,109,111,100,117,108,101, 40,116,111,108,117, 97, 95,
+     83, 44, 78, 85, 76, 76, 44, 34, 44,115,101,108,102, 58,104,
+     97,115,118, 97,114, 40, 41, 44, 34, 41, 59, 34, 41, 10, 32,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,116,
+    111,108,117, 97, 95, 98,101,103,105,110,109,111,100,117,108,
+    101, 40,116,111,108,117, 97, 95, 83, 44, 78, 85, 76, 76, 41,
+     59, 34, 41, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10,
+     32,119,104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,
+    100,111, 10, 32, 32,115,101,108,102, 91,105, 93, 58,114,101,
+    103,105,115,116,101,114, 40,112,114,101, 46, 46, 34, 32, 32,
+     34, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,
+    110,100, 10, 32,111,117,116,112,117,116, 40,112,114,101, 46,
+     46, 34, 32,116,111,108,117, 97, 95,101,110,100,109,111,100,
+    117,108,101, 40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41,
+     10, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46, 34,
+     32,114,101,116,117,114,110, 32, 49, 59, 34, 41, 10, 32,111,
+    117,116,112,117,116, 40,112,114,101, 46, 46, 34,125, 34, 41,
+     10, 10, 32,111,117,116,112,117,116, 40, 34, 92,110, 92,110,
+     34, 41, 10, 32,111,117,116,112,117,116, 40, 34, 35,105,102,
+     32,100,101,102,105,110,101,100, 40, 76, 85, 65, 95, 86, 69,
+     82, 83, 73, 79, 78, 95, 78, 85, 77, 41, 32, 38, 38, 32, 76,
+     85, 65, 95, 86, 69, 82, 83, 73, 79, 78, 95, 78, 85, 77, 32,
+     62, 61, 32, 53, 48, 49, 92,110, 34, 41, 59, 10, 32,111,117,
+    116,112,117,116, 40,112,114,101, 46, 46, 34, 84, 79, 76, 85,
+     65, 95, 65, 80, 73, 32,105,110,116, 32,108,117, 97,111,112,
+    101,110, 95, 34, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 34, 32, 40,108,117, 97, 95, 83,116, 97,116,101, 42,
+     32,116,111,108,117, 97, 95, 83, 41, 32,123, 34, 41, 10, 32,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,114,
+    101,116,117,114,110, 32,116,111,108,117, 97, 95, 34, 46, 46,
+    115,101,108,102, 46,110, 97,109,101, 46, 46, 34, 95,111,112,
+    101,110, 40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41, 10,
+     32,111,117,116,112,117,116, 40,112,114,101, 46, 46, 34,125,
+     59, 34, 41, 10, 32,111,117,116,112,117,116, 40, 34, 35,101,
+    110,100,105,102, 92,110, 92,110, 34, 41, 10, 10,  9,112,111,
+    112, 40, 41, 10,101,110,100, 10, 10, 45, 45, 32,119,114,105,
+    116,101, 32,104,101, 97,100,101,114, 32,102,105,108,101, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 80,
+     97, 99,107, 97,103,101, 58,104,101, 97,100,101,114, 32, 40,
+     41, 10, 32,111,117,116,112,117,116, 40, 39, 47, 42, 92,110,
+     39, 41, 32,111,117,116,112,117,116, 40, 39, 42, 42, 32, 76,
+    117, 97, 32, 98,105,110,100,105,110,103, 58, 32, 39, 46, 46,
+    115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 92,110, 39,
+     41, 10, 32,111,117,116,112,117,116, 40, 39, 42, 42, 32, 71,
+    101,110,101,114, 97,116,101,100, 32, 97,117,116,111,109, 97,
+    116,105, 99, 97,108,108,121, 32, 98,121, 32, 39, 46, 46, 84,
+     79, 76, 85, 65, 95, 86, 69, 82, 83, 73, 79, 78, 46, 46, 39,
+     32,111,110, 32, 39, 46, 46,100, 97,116,101, 40, 41, 46, 46,
+     39, 46, 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40,
+     39, 42, 47, 92,110, 92,110, 39, 41, 10, 10, 32,105,102, 32,
+    110,111,116, 32,102,108, 97,103,115, 46,104, 32,116,104,101,
+    110, 10, 32, 32,111,117,116,112,117,116, 40, 39, 47, 42, 32,
+     69,120,112,111,114,116,101,100, 32,102,117,110, 99,116,105,
+    111,110, 32, 42, 47, 39, 41, 10, 32, 32,111,117,116,112,117,
+    116, 40, 39, 84, 79, 76, 85, 65, 95, 65, 80, 73, 32,105,110,
+    116, 32, 32,116,111,108,117, 97, 95, 39, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 46, 46, 39, 95,111,112,101,110, 32,
+     40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,108,
+    117, 97, 95, 83, 41, 59, 39, 41, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39, 92,110, 39, 41, 10, 32,101,110,100, 10,101,
+    110,100, 10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108,
+     32, 99,111,110,115,116,114,117, 99,116,111,114, 10,102,117,
+    110, 99,116,105,111,110, 32, 95, 80, 97, 99,107, 97,103,101,
+     32, 40,115,101,108,102, 41, 10, 32,115,101,116,109,101,116,
+     97,116, 97, 98,108,101, 40,115,101,108,102, 44, 99,108, 97,
+    115,115, 80, 97, 99,107, 97,103,101, 41, 10, 32,114,101,116,
+    117,114,110, 32,115,101,108,102, 10,101,110,100, 10, 10, 45,
+     45, 32, 80, 97,114,115,101, 32, 67, 32,104,101, 97,100,101,
+    114, 32,102,105,108,101, 32,119,105,116,104, 32,116,111,108,
+    117, 97, 32,100,105,114,101, 99,116,105,118,101,115, 10, 45,
+     45, 32, 42, 42, 42, 32, 84,104, 97,110,107,115, 32,116,111,
+     32, 65,114,105,101,108, 32, 77, 97,110,122,117,114, 32,102,
+    111,114, 32,102,105,120,105,110,103, 32, 98,117,103,115, 32,
+    105,110, 32,110,101,115,116,101,100, 32,100,105,114,101, 99,
+    116,105,118,101,115, 32, 42, 42, 42, 10,102,117,110, 99,116,
+    105,111,110, 32,101,120,116,114, 97, 99,116, 95, 99,111,100,
+    101, 40,102,110, 44,115, 41, 10,  9,108,111, 99, 97,108, 32,
+     99,111,100,101, 32, 61, 32, 39, 92,110, 36, 35,105,110, 99,
+    108,117,100,101, 32, 34, 39, 46, 46,102,110, 46, 46, 39, 34,
+     92,110, 39, 10,  9,115, 61, 32, 34, 92,110, 34, 32, 46, 46,
+     32,115, 32, 46, 46, 32, 34, 92,110, 34, 32, 45, 45, 32, 97,
+    100,100, 32, 98,108, 97,110,107, 32,108,105,110,101,115, 32,
+     97,115, 32,115,101,110,116,105,110,101,108,115, 10,  9,108,
+    111, 99, 97,108, 32, 95, 44,101, 44, 99, 44,116, 32, 61, 32,
+    115,116,114,102,105,110,100, 40,115, 44, 32, 34, 92,110, 40,
+     91, 94, 92,110, 93, 45, 41, 91, 84,116, 93, 91, 79,111, 93,
+     91, 76,108, 93, 91, 85,117, 93, 91, 65, 97, 93, 95, 40, 91,
+     94, 37,115, 93, 42, 41, 91, 94, 92,110, 93, 42, 92,110, 34,
+     41, 10,  9,119,104,105,108,101, 32,101, 32,100,111, 10,  9,
+      9,116, 32, 61, 32,115,116,114,108,111,119,101,114, 40,116,
+     41, 10,  9,  9,105,102, 32,116, 32, 61, 61, 32, 34, 98,101,
+    103,105,110, 34, 32,116,104,101,110, 10,  9,  9,  9, 95, 44,
+    101, 44, 99, 32, 61, 32,115,116,114,102,105,110,100, 40,115,
+     44, 34, 40, 46, 45, 41, 92,110, 91, 94, 92,110, 93, 42, 91,
+     84,116, 93, 91, 79,111, 93, 91, 76,108, 93, 91, 85,117, 93,
+     91, 65, 97, 93, 95, 91, 69,101, 93, 91, 78,110, 93, 91, 68,
+    100, 93, 91, 94, 92,110, 93, 42, 92,110, 34, 44,101, 41, 10,
+      9,  9,  9,105,102, 32,110,111,116, 32,101, 32,116,104,101,
+    110, 10,  9,  9,  9, 32,116,111,108,117, 97, 95,101,114,114,
+    111,114, 40, 34, 85,110, 98, 97,108, 97,110, 99,101,100, 32,
+     39,116,111,108,117, 97, 95, 98,101,103,105,110, 39, 32,100,
+    105,114,101, 99,116,105,118,101, 32,105,110, 32,104,101, 97,
+    100,101,114, 32,102,105,108,101, 34, 41, 10,  9,  9,  9,101,
+    110,100, 10,  9,  9,101,110,100, 10,  9,  9, 99,111,100,101,
+     32, 61, 32, 99,111,100,101, 32, 46, 46, 32, 99, 32, 46, 46,
+     32, 34, 92,110, 34, 10,  9, 32, 95, 44,101, 44, 99, 44,116,
+     32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 32, 34,
+     92,110, 40, 91, 94, 92,110, 93, 45, 41, 91, 84,116, 93, 91,
+     79,111, 93, 91, 76,108, 93, 91, 85,117, 93, 91, 65, 97, 93,
+     95, 40, 91, 94, 37,115, 93, 42, 41, 91, 94, 92,110, 93, 42,
+     92,110, 34, 44,101, 41, 10,  9,101,110,100, 10,  9,114,101,
+    116,117,114,110, 32, 99,111,100,101, 10,101,110,100, 10, 10,
+     45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114, 10,
+     45, 45, 32, 69,120,112,101, 99,116,115, 32,116,104,101, 32,
+    112, 97, 99,107, 97,103,101, 32,110, 97,109,101, 44, 32,116,
+    104,101, 32,102,105,108,101, 32,101,120,116,101,110,115,105,
+    111,110, 44, 32, 97,110,100, 32,116,104,101, 32,102,105,108,
+    101, 32,116,101,120,116, 46, 10,102,117,110, 99,116,105,111,
+    110, 32, 80, 97, 99,107, 97,103,101, 32, 40,110, 97,109,101,
+     44,102,110, 41, 10, 32,108,111, 99, 97,108, 32,101,120,116,
+     32, 61, 32, 34,112,107,103, 34, 10, 10, 32, 45, 45, 32,111,
+    112,101,110, 32,105,110,112,117,116, 32,102,105,108,101, 44,
+     32,105,102, 32, 97,110,121, 10, 32,105,102, 32,102,110, 32,
+    116,104,101,110, 10, 32, 32,108,111, 99, 97,108, 32,115,116,
+     44, 32,109,115,103, 32, 61, 32,114,101, 97,100,102,114,111,
+    109, 40,102,108, 97,103,115, 46,102, 41, 10, 32, 32,105,102,
+     32,110,111,116, 32,115,116, 32,116,104,101,110, 10, 32, 32,
+     32,101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,115,103,
+     41, 10, 32, 32,101,110,100, 10,  9,  9,108,111, 99, 97,108,
+     32, 95, 59, 32, 95, 44, 32, 95, 44, 32,101,120,116, 32, 61,
+     32,115,116,114,102,105,110,100, 40,102,110, 44, 34, 46, 42,
+     37, 46, 40, 46, 42, 41, 36, 34, 41, 10, 32,101,110,100, 10,
+     32,108,111, 99, 97,108, 32, 99,111,100,101, 32, 61, 32, 34,
+     92,110, 34, 32, 46, 46, 32,114,101, 97,100, 40, 39, 42, 97,
+     39, 41, 10,  9,105,102, 32,101,120,116, 32, 61, 61, 32, 39,
+    104, 39, 32,111,114, 32,101,120,116, 32, 61, 61, 32, 39,104,
+    112,112, 39, 32,116,104,101,110, 10,  9, 32, 99,111,100,101,
+     32, 61, 32,101,120,116,114, 97, 99,116, 95, 99,111,100,101,
+     40,102,110, 44, 99,111,100,101, 41, 10,  9,101,110,100, 10,
+     10, 32, 45, 45, 32, 99,108,111,115,101, 32,102,105,108,101,
+     10, 32,105,102, 32,102,110, 32,116,104,101,110, 10, 32, 32,
+    114,101, 97,100,102,114,111,109, 40, 41, 10, 32,101,110,100,
+     10, 10, 32, 45, 45, 32,100,101, 97,108, 32,119,105,116,104,
+     32,105,110, 99,108,117,100,101, 32,100,105,114,101, 99,116,
+    105,118,101, 10, 32,108,111, 99, 97,108, 32,110,115,117, 98,
+    115,116, 10, 32,114,101,112,101, 97,116, 10, 32, 32, 99,111,
+    100,101, 44,110,115,117, 98,115,116, 32, 61, 32,103,115,117,
+     98, 40, 99,111,100,101, 44, 39, 92,110, 37,115, 42, 37, 36,
+     40, 46, 41,102,105,108,101, 37,115, 42, 34, 40, 46, 45, 41,
+     34, 40, 91, 94, 92,110, 93, 42, 41, 92,110, 39, 44, 10,  9,
+      9,102,117,110, 99,116,105,111,110, 32, 40,107,105,110,100,
+     44,102,110, 44,101,120,116,114, 97, 41, 10,  9,  9,  9,108,
+    111, 99, 97,108, 32, 95, 44, 32, 95, 44, 32,101,120,116, 32,
+     61, 32,115,116,114,102,105,110,100, 40,102,110, 44, 34, 46,
+     42, 37, 46, 40, 46, 42, 41, 36, 34, 41, 10,  9,  9,  9,108,
+    111, 99, 97,108, 32,102,112, 44,109,115,103, 32, 61, 32,111,
+    112,101,110,102,105,108,101, 40,102,110, 44, 39,114, 39, 41,
+     10,  9,  9,  9,105,102, 32,110,111,116, 32,102,112, 32,116,
+    104,101,110, 10,  9,  9,  9,  9,101,114,114,111,114, 40, 39,
+     35, 39, 46, 46,109,115,103, 46, 46, 39, 58, 32, 39, 46, 46,
+    102,110, 41, 10,  9,  9,  9,101,110,100, 10,  9,  9,  9,108,
+    111, 99, 97,108, 32,115, 32, 61, 32,114,101, 97,100, 40,102,
+    112, 44, 39, 42, 97, 39, 41, 10,  9,  9,  9, 99,108,111,115,
+    101,102,105,108,101, 40,102,112, 41, 10,  9,  9,  9,105,102,
+     32,107,105,110,100, 32, 61, 61, 32, 39, 99, 39, 32,111,114,
+     32,107,105,110,100, 32, 61, 61, 32, 39,104, 39, 32,116,104,
+    101,110, 10,  9,  9,  9,  9,114,101,116,117,114,110, 32,101,
+    120,116,114, 97, 99,116, 95, 99,111,100,101, 40,102,110, 44,
+    115, 41, 10,  9,  9,  9,101,108,115,101,105,102, 32,107,105,
+    110,100, 32, 61, 61, 32, 39,112, 39, 32,116,104,101,110, 10,
+      9,  9,  9,  9,114,101,116,117,114,110, 32, 34, 92,110, 92,
+    110, 34, 32, 46, 46, 32,115, 10,  9,  9,  9,101,108,115,101,
+    105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,108, 39, 32,
+    116,104,101,110, 10,  9,  9,  9,  9,114,101,116,117,114,110,
+     32, 34, 92,110, 36, 91, 45, 45, 35, 35, 34, 46, 46,102,110,
+     46, 46, 34, 92,110, 34, 32, 46, 46, 32,115, 32, 46, 46, 32,
+     34, 92,110, 36, 93, 92,110, 34, 10,  9,  9,  9,101,108,115,
+    101,105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,105, 39,
+     32,116,104,101,110, 10,  9,  9,  9,  9,108,111, 99, 97,108,
+     32,116, 32, 61, 32,123, 99,111,100,101, 61,115,125, 10,  9,
+      9,  9,  9,101,120,116,114, 97, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,101,120,116,114, 97, 44, 32,
+     34, 94, 37,115, 42, 44, 37,115, 42, 34, 44, 32, 34, 34, 41,
+     10,  9,  9,  9,  9,108,111, 99, 97,108, 32,112, 97,114,115,
+     32, 61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,
+    110,115, 40,101,120,116,114, 97, 44, 32, 34, 44, 34, 41, 10,
+      9,  9,  9,  9,105,110, 99,108,117,100,101, 95,102,105,108,
+    101, 95,104,111,111,107, 40,116, 44, 32,102,110, 44, 32,117,
+    110,112, 97, 99,107, 40,112, 97,114,115, 41, 41, 10,  9,  9,
+      9,  9,114,101,116,117,114,110, 32, 34, 92,110, 92,110, 34,
+     32, 46, 46, 32,116, 46, 99,111,100,101, 10,  9,  9,  9,101,
+    108,115,101, 10,  9,  9,  9,  9,101,114,114,111,114, 40, 39,
+     35, 73,110,118, 97,108,105,100, 32,105,110, 99,108,117,100,
+    101, 32,100,105,114,101, 99,116,105,118,101, 32, 40,117,115,
+    101, 32, 36, 99,102,105,108,101, 44, 32, 36,112,102,105,108,
+    101, 44, 32, 36,108,102,105,108,101, 32,111,114, 32, 36,105,
+    102,105,108,101, 41, 39, 41, 10,  9,  9,  9,101,110,100, 10,
+      9,  9,101,110,100, 41, 10, 32,117,110,116,105,108, 32,110,
+    115,117, 98,115,116, 61, 61, 48, 10, 10, 32, 45, 45, 32,100,
+    101, 97,108, 32,119,105,116,104, 32,114,101,110, 97,109,105,
+    110,103, 32,100,105,114,101, 99,116,105,118,101, 10, 32,114,
+    101,112,101, 97,116, 32, 45, 45, 32, 73, 32,100,111,110, 39,
+    116, 32,107,110,111,119, 32,119,104,121, 32,116,104,105,115,
+     32,105,115, 32,110,101, 99,101,115, 97,114,121, 10,  9, 99,
+    111,100,101, 44,110,115,117, 98,115,116, 32, 61, 32,103,115,
+    117, 98, 40, 99,111,100,101, 44, 39, 92,110, 37,115, 42, 37,
+     36,114,101,110, 97,109,105,110,103, 37,115, 42, 40, 46, 45,
+     41, 37,115, 42, 92,110, 39, 44, 32,102,117,110, 99,116,105,
+    111,110, 32, 40,114, 41, 32, 97,112,112,101,110,100,114,101,
+    110, 97,109,105,110,103, 40,114, 41, 32,114,101,116,117,114,
+    110, 32, 34, 92,110, 34, 32,101,110,100, 41, 10, 32,117,110,
+    116,105,108, 32,110,115,117, 98,115,116, 32, 61, 61, 32, 48,
+     10, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32, 95, 80,
+     97, 99,107, 97,103,101, 40, 95, 67,111,110,116, 97,105,110,
+    101,114,123,110, 97,109,101, 61,110, 97,109,101, 44, 32, 99,
+    111,100,101, 61, 99,111,100,101,125, 41, 10, 32,112,117,115,
+    104, 40,116, 41, 10, 32,112,114,101,112,114,111, 99,101,115,
+    115, 95,104,111,111,107, 40,116, 41, 10, 32,116, 58,112,114,
+    101,112,114,111, 99,101,115,115, 40, 41, 10, 32,112,114,101,
+    112, 97,114,115,101, 95,104,111,111,107, 40,116, 41, 10, 32,
+    116, 58,112, 97,114,115,101, 40,116, 46, 99,111,100,101, 41,
+     10, 32,112,111,112, 40, 41, 10, 32,114,101,116,117,114,110,
+     32,116, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/package.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,109,111,100,117,108,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,
+    116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114,
+     32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114,
+     97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,
+    117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58,
+     32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,
+    101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,119,
+     97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,
+    100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,
+    110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116,
+     46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,
+    114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,114,
+    101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110,
+     32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44,
+     32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,
+    104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,
+    103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,105,
+    100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44,
+     32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116,
+    101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,
+    101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105,
+     99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45, 32,
+     77,111,100,117,108,101, 32, 99,108, 97,115,115, 10, 45, 45,
+     32, 82,101,112,114,101,115,101,110,116,115, 32,109,111,100,
+    117,108,101, 46, 10, 45, 45, 32, 84,104,101, 32,102,111,108,
+    108,111,119,105,110,103, 32,102,105,101,108,100,115, 32, 97,
+    114,101, 32,115,116,111,114,101,100, 58, 10, 45, 45, 32, 32,
+     32, 32,123,105,125, 32, 61, 32,108,105,115,116, 32,111,102,
+     32,111, 98,106,101, 99,116,115, 32,105,110, 32,116,104,101,
+     32,109,111,100,117,108,101, 46, 10, 99,108, 97,115,115, 77,
+    111,100,117,108,101, 32, 61, 32,123, 10, 32, 99,108, 97,115,
+    115,116,121,112,101, 32, 61, 32, 39,109,111,100,117,108,101,
+     39, 10,125, 10, 99,108, 97,115,115, 77,111,100,117,108,101,
+     46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115,
+    115, 77,111,100,117,108,101, 10,115,101,116,109,101,116, 97,
+    116, 97, 98,108,101, 40, 99,108, 97,115,115, 77,111,100,117,
+    108,101, 44, 99,108, 97,115,115, 67,111,110,116, 97,105,110,
+    101,114, 41, 10, 10, 45, 45, 32,114,101,103,105,115,116,101,
+    114, 32,109,111,100,117,108,101, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 77,111,100,117,108,101, 58,
+    114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41, 10,
+     32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39,
+     39, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10, 32,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116,111,
+    108,117, 97, 95,109,111,100,117,108,101, 40,116,111,108,117,
+     97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,110, 97,
+    109,101, 46, 46, 39, 34, 44, 39, 44,115,101,108,102, 58,104,
+     97,115,118, 97,114, 40, 41, 44, 39, 41, 59, 39, 41, 10, 32,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116,111,
+    108,117, 97, 95, 98,101,103,105,110,109,111,100,117,108,101,
+     40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,
+    108,102, 46,110, 97,109,101, 46, 46, 39, 34, 41, 59, 39, 41,
+     10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,
+    105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,
+     32, 32,115,101,108,102, 91,105, 93, 58,114,101,103,105,115,
+    116,101,114, 40,112,114,101, 46, 46, 39, 32, 39, 41, 10, 32,
+     32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,116,111,
+    108,117, 97, 95,101,110,100,109,111,100,117,108,101, 40,116,
+    111,108,117, 97, 95, 83, 41, 59, 39, 41, 10,  9,112,111,112,
+     40, 41, 10,101,110,100, 10, 10, 45, 45, 32, 80,114,105,110,
+    116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 77,111,100,117,108,101, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 77,111,100,117,108,101,123, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 46, 46, 34, 39, 59, 34, 41, 10, 32,
+    108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,
+    101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32, 32,
+    115,101,108,102, 91,105, 93, 58,112,114,105,110,116, 40,105,
+    100,101,110,116, 46, 46, 34, 32, 34, 44, 34, 44, 34, 41, 10,
+     32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+    125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10,
+     10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,
+    110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116,
+    105,111,110, 32, 95, 77,111,100,117,108,101, 32, 40,116, 41,
+     10, 32,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,
+    116, 44, 99,108, 97,115,115, 77,111,100,117,108,101, 41, 10,
+     32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,
+    117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,
+    111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,
+    120,112,101, 99,116,115, 32,116,119,111, 32,115,116,114,105,
+    110,103, 32,114,101,112,114,101,115,101,110,116,105,110,103,
+     32,116,104,101, 32,109,111,100,117,108,101, 32,110, 97,109,
+    101, 32, 97,110,100, 32, 98,111,100,121, 46, 10,102,117,110,
+     99,116,105,111,110, 32, 77,111,100,117,108,101, 32, 40,110,
+     44, 98, 41, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,
+     95, 77,111,100,117,108,101, 40, 95, 67,111,110,116, 97,105,
+    110,101,114,123,110, 97,109,101, 61,110,125, 41, 10, 32,112,
+    117,115,104, 40,116, 41, 10, 32,116, 58,112, 97,114,115,101,
+     40,115,116,114,115,117, 98, 40, 98, 44, 50, 44,115,116,114,
+    108,101,110, 40, 98, 41, 45, 49, 41, 41, 32, 45, 45, 32,101,
+    108,105,109,105,110, 97,116,101, 32, 98,114, 97, 99,101,115,
+     10, 32,112,111,112, 40, 41, 10, 32,114,101,116,117,114,110,
+     32,116, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/module.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,110, 97,109,101,115,
+    112, 97, 99,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,
+    114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,
+    109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101,
+     67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45,
+     45, 32, 74,117,108, 32, 50, 48, 48, 51, 10, 45, 45, 32, 36,
+     73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32,
+     99,111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,
+    102,116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110,
+     32,114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,
+    116, 32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121,
+     32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,
+    116,119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,
+    104,101,114,101,117,110,100,101,114, 32,105,115, 32,111,110,
+     32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,
+    105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32,
+     97,117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111,
+     98,108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,
+    111,118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110,
+     99,101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,
+    100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110,
+     99,101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,
+    105,102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45,
+     45, 32, 78, 97,109,101,115,112, 97, 99,101, 32, 99,108, 97,
+    115,115, 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,
+    115, 32, 97, 32,110, 97,109,101,115, 97,112, 99,101, 32,100,
+    101,102,105,110,105,116,105,111,110, 46, 10, 45, 45, 32, 83,
+    116,111,114,101,115, 32,116,104,101, 32,102,111,108,108,111,
+    119,105,110,103, 32,102,105,101,108,100,115, 58, 10, 45, 45,
+     32, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,108, 97,115,
+    115, 32,110, 97,109,101, 10, 45, 45, 32, 32, 32, 32,123,105,
+    125, 32, 32, 61, 32,108,105,115,116, 32,111,102, 32,109,101,
+    109, 98,101,114,115, 10, 99,108, 97,115,115, 78, 97,109,101,
+    115,112, 97, 99,101, 32, 61, 32,123, 10, 32, 99,108, 97,115,
+    115,116,121,112,101, 32, 61, 32, 39,110, 97,109,101,115,112,
+     97, 99,101, 39, 44, 10, 32,110, 97,109,101, 32, 61, 32, 39,
+     39, 44, 10,125, 10, 99,108, 97,115,115, 78, 97,109,101,115,
+    112, 97, 99,101, 46, 95, 95,105,110,100,101,120, 32, 61, 32,
+     99,108, 97,115,115, 78, 97,109,101,115,112, 97, 99,101, 10,
+    115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,108,
+     97,115,115, 78, 97,109,101,115,112, 97, 99,101, 44, 99,108,
+     97,115,115, 77,111,100,117,108,101, 41, 10, 10, 45, 45, 32,
+     80,114,105,110,116, 32,109,101,116,104,111,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 78, 97,109,
+    101,115,112, 97, 99,101, 58,112,114,105,110,116, 32, 40,105,
+    100,101,110,116, 44, 99,108,111,115,101, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 78, 97,109,
+    101,115,112, 97, 99,101,123, 34, 41, 10, 32,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101,
+     32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, 97,109,
+    101, 46, 46, 34, 39, 44, 34, 41, 10, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,
+    105, 93, 58,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46, 46, 99,
+    108,111,115,101, 41, 10,101,110,100, 10, 10, 45, 45, 32, 73,
+    110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114,117,
+     99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32, 95,
+     78, 97,109,101,115,112, 97, 99,101, 32, 40,116, 41, 10, 32,
+    115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44,
+     99,108, 97,115,115, 78, 97,109,101,115,112, 97, 99,101, 41,
+     10, 32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,
+    116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32,
+     67,111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32,
+     69,120,112,101, 99,116,115, 32,116,104,101, 32,110, 97,109,
+    101, 32, 97,110,100, 32,116,104,101, 32, 98,111,100,121, 32,
+    111,102, 32,116,104,101, 32,110, 97,109,101,115,112, 97, 99,
+    101, 46, 10,102,117,110, 99,116,105,111,110, 32, 78, 97,109,
+    101,115,112, 97, 99,101, 32, 40,110, 44, 98, 41, 10, 32,108,
+    111, 99, 97,108, 32, 99, 32, 61, 32, 95, 78, 97,109,101,115,
+    112, 97, 99,101, 40, 95, 67,111,110,116, 97,105,110,101,114,
+    123,110, 97,109,101, 61,110,125, 41, 10, 32,112,117,115,104,
+     40, 99, 41, 10, 32, 99, 58,112, 97,114,115,101, 40,115,116,
+    114,115,117, 98, 40, 98, 44, 50, 44,115,116,114,108,101,110,
+     40, 98, 41, 45, 49, 41, 41, 32, 45, 45, 32,101,108,105,109,
+    105,110, 97,116,101, 32, 98,114, 97, 99,101,115, 10, 32,112,
+    111,112, 40, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/namespace.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,100,101,102,105,110,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,
+    116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114,
+     32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114,
+     97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,
+    117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58,
+     32,100,101,102,105,110,101, 46,108,117, 97, 44,118, 32, 49,
+     46, 50, 32, 49, 57, 57, 57, 47, 48, 55, 47, 50, 56, 32, 50,
+     50, 58, 50, 49, 58, 48, 56, 32, 99,101,108,101,115, 32, 69,
+    120,112, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45,
+     32, 68,101,102,105,110,101, 32, 99,108, 97,115,115, 10, 45,
+     45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 97, 32,
+    110,117,109,101,114,105, 99, 32, 99,111,110,115,116, 32,100,
+    101,102,105,110,105,116,105,111,110, 10, 45, 45, 32, 84,104,
+    101, 32,102,111,108,108,111,119,105,110,103, 32,102,105,108,
+    100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58, 10,
+     45, 45, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,111,110,
+    115,116, 97,110,116, 32,110, 97,109,101, 10, 99,108, 97,115,
+    115, 68,101,102,105,110,101, 32, 61, 32,123, 10, 32,110, 97,
+    109,101, 32, 61, 32, 39, 39, 44, 10,125, 10, 99,108, 97,115,
+    115, 68,101,102,105,110,101, 46, 95, 95,105,110,100,101,120,
+     32, 61, 32, 99,108, 97,115,115, 68,101,102,105,110,101, 10,
+    115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,108,
+     97,115,115, 68,101,102,105,110,101, 44, 99,108, 97,115,115,
+     70,101, 97,116,117,114,101, 41, 10, 10, 45, 45, 32,114,101,
+    103,105,115,116,101,114, 32,100,101,102,105,110,101, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101,
+    102,105,110,101, 58,114,101,103,105,115,116,101,114, 32, 40,
+    112,114,101, 41, 10,  9,105,102, 32,110,111,116, 32,115,101,
+    108,102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99,
+     95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10,
+      9,  9,114,101,116,117,114,110, 10,  9,101,110,100, 10, 10,
+     32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39,
+     39, 10, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46,
+     39,116,111,108,117, 97, 95, 99,111,110,115,116, 97,110,116,
+     40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,
+    108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, 39, 46,
+     46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 41, 59,
+     39, 41, 10,101,110,100, 10, 10, 45, 45, 32, 80,114,105,110,
+    116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 68,101,102,105,110,101, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 68,101,102,105,110,101,123, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+    125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10,
+     10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,
+    111,110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,
+    116,105,111,110, 32, 95, 68,101,102,105,110,101, 32, 40,116,
+     41, 10, 32,115,101,116,109,101,116, 97,116, 97, 98,108,101,
+     40,116, 44, 99,108, 97,115,115, 68,101,102,105,110,101, 41,
+     10, 32,116, 58, 98,117,105,108,100,110, 97,109,101,115, 40,
+     41, 10, 10, 32,105,102, 32,116, 46,110, 97,109,101, 32, 61,
+     61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,101,114,114,
+    111,114, 40, 34, 35,105,110,118, 97,108,105,100, 32,100,101,
+    102,105,110,101, 34, 41, 10, 32,101,110,100, 10, 10, 32, 97,
+    112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,114,
+    110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,
+    115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,
+    101, 99,116,115, 32, 97, 32,115,116,114,105,110,103, 32,114,
+    101,112,114,101,115,101,110,116,105,110,103, 32,116,104,101,
+     32, 99,111,110,115,116, 97,110,116, 32,110, 97,109,101, 10,
+    102,117,110, 99,116,105,111,110, 32, 68,101,102,105,110,101,
+     32, 40,110, 41, 10, 32,114,101,116,117,114,110, 32, 95, 68,
+    101,102,105,110,101,123, 10, 32, 32,110, 97,109,101, 32, 61,
+     32,110, 10, 32,125, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/define.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,101,110,117,109,101,
+    114, 97,116,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,
+    114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,
+    109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101,
+     67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45,
+     45, 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36,
+     73,100, 58, 32,101,110,117,109,101,114, 97,116,101, 46,108,
+    117, 97, 44,118, 32, 49, 46, 51, 32, 50, 48, 48, 48, 47, 48,
+     49, 47, 50, 52, 32, 50, 48, 58, 52, 49, 58, 49, 53, 32, 99,
+    101,108,101,115, 32, 69,120,112, 32, 36, 10, 10, 45, 45, 32,
+     84,104,105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,
+    101,101, 32,115,111,102,116,119, 97,114,101, 59, 32,121,111,
+    117, 32, 99, 97,110, 32,114,101,100,105,115,116,114,105, 98,
+    117,116,101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,
+    111,100,105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,
+    101, 32,115,111,102,116,119, 97,114,101, 32,112,114,111,118,
+    105,100,101,100, 32,104,101,114,101,117,110,100,101,114, 32,
+    105,115, 32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115,
+     34, 32, 98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45,
+     32,116,104,101, 32, 97,117,116,104,111,114, 32,104, 97,115,
+     32,110,111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,
+    116,111, 32,112,114,111,118,105,100,101, 32,109, 97,105,110,
+    116,101,110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,
+    116, 44, 32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,
+    101,110,104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,
+    114, 32,109,111,100,105,102,105, 99, 97,116,105,111,110,115,
+     46, 10, 10, 10, 45, 45, 32, 69,110,117,109,101,114, 97,116,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,
+    101,115,101,110,116,115, 32,101,110,117,109,101,114, 97,116,
+    105,111,110, 10, 45, 45, 32, 84,104,101, 32,102,111,108,108,
+    111,119,105,110,103, 32,102,105,101,108,100,115, 32, 97,114,
+    101, 32,115,116,111,114,101,100, 58, 10, 45, 45, 32, 32, 32,
+     32,123,105,125, 32, 61, 32,108,105,115,116, 32,111,102, 32,
+     99,111,110,115,116, 97,110,116, 32,110, 97,109,101,115, 10,
+     99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101, 32,
+     61, 32,123, 10,125, 10, 99,108, 97,115,115, 69,110,117,109,
+    101,114, 97,116,101, 46, 95, 95,105,110,100,101,120, 32, 61,
+     32, 99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101,
+     10,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,
+    108, 97,115,115, 69,110,117,109,101,114, 97,116,101, 44, 99,
+    108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10, 10, 45,
+     45, 32,114,101,103,105,115,116,101,114, 32,101,110,117,109,
+    101,114, 97,116,105,111,110, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 69,110,117,109,101,114, 97,116,
+    101, 58,114,101,103,105,115,116,101,114, 32, 40,112,114,101,
+     41, 10, 32,112,114,101, 32, 61, 32,112,114,101, 32,111,114,
+     32, 39, 39, 10, 32,108,111, 99, 97,108, 32,110,115,112, 97,
+     99,101, 32, 61, 32,103,101,116,110, 97,109,101,115,112, 97,
+     99,101, 40, 99,108, 97,115,115, 67,111,110,116, 97,105,110,
+    101,114, 46, 99,117,114,114, 41, 10, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95, 99,
+    111,110,115,116, 97,110,116, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+    115, 91,105, 93, 46, 46, 39, 34, 44, 39, 46, 46,110,115,112,
+     97, 99,101, 46, 46,115,101,108,102, 91,105, 93, 46, 46, 39,
+     41, 59, 39, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10,
+     32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 80,114,
+    105,110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 69,110,117,109,101,
+    114, 97,116,101, 58,112,114,105,110,116, 32, 40,105,100,101,
+    110,116, 44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 69,110,117,109,101,
+    114, 97,116,101,123, 34, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101, 32, 61,
+     32, 34, 46, 46,115,101,108,102, 46,110, 97,109,101, 41, 10,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,
+    108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32, 39, 34, 46, 46,115,101,108,102, 91,105, 93, 46, 46, 34,
+     39, 40, 34, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+    115, 91,105, 93, 46, 46, 34, 41, 44, 34, 41, 10, 32, 32,105,
+     32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46,
+     46, 99,108,111,115,101, 41, 10,101,110,100, 10, 10, 45, 45,
+     32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,
+    114,117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110,
+     32, 95, 69,110,117,109,101,114, 97,116,101, 32, 40,116, 44,
+    118, 97,114,110, 97,109,101, 41, 10, 32,115,101,116,109,101,
+    116, 97,116, 97, 98,108,101, 40,116, 44, 99,108, 97,115,115,
+     69,110,117,109,101,114, 97,116,101, 41, 10, 32, 97,112,112,
+    101,110,100, 40,116, 41, 10, 32, 97,112,112,101,110,100,101,
+    110,117,109, 40,116, 41, 10,  9, 32,105,102, 32,118, 97,114,
+    110, 97,109,101, 32, 97,110,100, 32,118, 97,114,110, 97,109,
+    101, 32,126, 61, 32, 34, 34, 32,116,104,101,110, 10,  9,  9,
+    105,102, 32,116, 46,110, 97,109,101, 32,126, 61, 32, 34, 34,
+     32,116,104,101,110, 10,  9,  9,  9, 86, 97,114,105, 97, 98,
+    108,101, 40,116, 46,110, 97,109,101, 46, 46, 34, 32, 34, 46,
+     46,118, 97,114,110, 97,109,101, 41, 10,  9,  9,101,108,115,
+    101, 10,  9,  9,  9,108,111, 99, 97,108, 32,110,115, 32, 61,
+     32,103,101,116, 99,117,114,114,110, 97,109,101,115,112, 97,
+     99,101, 40, 41, 10,  9,  9,  9,119, 97,114,110,105,110,103,
+     40, 34, 86, 97,114,105, 97, 98,108,101, 32, 34, 46, 46,110,
+    115, 46, 46,118, 97,114,110, 97,109,101, 46, 46, 34, 32,111,
+    102, 32,116,121,112,101, 32, 60, 97,110,111,110,121,109,111,
+    117,115, 32,101,110,117,109, 62, 32,105,115, 32,100,101, 99,
+    108, 97,114,101,100, 32, 97,115, 32,114,101, 97,100, 45,111,
+    110,108,121, 34, 41, 10,  9,  9,  9, 86, 97,114,105, 97, 98,
+    108,101, 40, 34,116,111,108,117, 97, 95,114,101, 97,100,111,
+    110,108,121, 32,105,110,116, 32, 34, 46, 46,118, 97,114,110,
+     97,109,101, 41, 10,  9,  9,101,110,100, 10,  9,101,110,100,
+     10,114,101,116,117,114,110, 32,116, 10,101,110,100, 10, 10,
+     45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114, 10,
+     45, 45, 32, 69,120,112,101, 99,116,115, 32, 97, 32,115,116,
+    114,105,110,103, 32,114,101,112,114,101,115,101,110,116,105,
+    110,103, 32,116,104,101, 32,101,110,117,109,101,114, 97,116,
+    101, 32, 98,111,100,121, 10,102,117,110, 99,116,105,111,110,
+     32, 69,110,117,109,101,114, 97,116,101, 32, 40,110, 44, 98,
+     44,118, 97,114,110, 97,109,101, 41, 10,  9, 98, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40, 98, 44, 32,
+     34, 44, 91, 37,115, 92,110, 93, 42,125, 34, 44, 32, 34, 92,
+    110,125, 34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,
+    116,101, 32,108, 97,115,116, 32, 39, 44, 39, 10, 32,108,111,
+     99, 97,108, 32,116, 32, 61, 32,115,112,108,105,116, 40,115,
+    116,114,115,117, 98, 40, 98, 44, 50, 44, 45, 50, 41, 44, 39,
+     44, 39, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,
+    101, 32, 98,114, 97, 99,101,115, 10, 32,108,111, 99, 97,108,
+     32,105, 32, 61, 32, 49, 10, 32,108,111, 99, 97,108, 32,101,
+     32, 61, 32,123,110, 61, 48,125, 10, 32,119,104,105,108,101,
+     32,116, 91,105, 93, 32,100,111, 10, 32, 32,108,111, 99, 97,
+    108, 32,116,116, 32, 61, 32,115,112,108,105,116, 40,116, 91,
+    105, 93, 44, 39, 61, 39, 41, 32, 32, 45, 45, 32,100,105,115,
+     99, 97,114,100, 32,105,110,105,116,105, 97,108, 32,118, 97,
+    108,117,101, 10, 32, 32,101, 46,110, 32, 61, 32,101, 46,110,
+     32, 43, 32, 49, 10, 32, 32,101, 91,101, 46,110, 93, 32, 61,
+     32,116,116, 91, 49, 93, 10, 32, 32,105, 32, 61, 32,105, 43,
+     49, 10, 32,101,110,100, 10, 32, 45, 45, 32,115,101,116, 32,
+    108,117, 97, 32,110, 97,109,101,115, 10, 32,105, 32, 32, 61,
+     32, 49, 10, 32,101, 46,108,110, 97,109,101,115, 32, 61, 32,
+    123,125, 10, 32,108,111, 99, 97,108, 32,110,115, 32, 61, 32,
+    103,101,116, 99,117,114,114,110, 97,109,101,115,112, 97, 99,
+    101, 40, 41, 10, 32,119,104,105,108,101, 32,101, 91,105, 93,
+     32,100,111, 10, 32, 32,108,111, 99, 97,108, 32,116, 32, 61,
+     32,115,112,108,105,116, 40,101, 91,105, 93, 44, 39, 64, 39,
+     41, 10, 32, 32,101, 91,105, 93, 32, 61, 32,116, 91, 49, 93,
+     10,  9,  9,105,102, 32,110,111,116, 32,116, 91, 50, 93, 32,
+    116,104,101,110, 10,  9,  9, 32,116, 91, 50, 93, 32, 61, 32,
+     97,112,112,108,121,114,101,110, 97,109,105,110,103, 40,116,
+     91, 49, 93, 41, 10,  9,  9,101,110,100, 10, 32, 32,101, 46,
+    108,110, 97,109,101,115, 91,105, 93, 32, 61, 32,116, 91, 50,
+     93, 32,111,114, 32,116, 91, 49, 93, 10, 32, 32, 95,103,108,
+    111, 98, 97,108, 95,101,110,117,109,115, 91, 32,110,115, 46,
+     46,101, 91,105, 93, 32, 93, 32, 61, 32, 40,110,115, 46, 46,
+    101, 91,105, 93, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49,
+     10, 32,101,110,100, 10,  9,101, 46,110, 97,109,101, 32, 61,
+     32,110, 10,  9,105,102, 32,110, 32,126, 61, 32, 34, 34, 32,
+    116,104,101,110, 10,  9,  9, 84,121,112,101,100,101,102, 40,
+     34,105,110,116, 32, 34, 46, 46,110, 41, 10,  9,101,110,100,
+     10, 32,114,101,116,117,114,110, 32, 95, 69,110,117,109,101,
+    114, 97,116,101, 40,101, 44, 32,118, 97,114,110, 97,109,101,
+     41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/enumerate.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,100,101, 99,108, 97,
+    114, 97,116,105,111,110, 32, 99,108, 97,115,115, 10, 45, 45,
+     32, 87,114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,
+    100,101,109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32,
+     84,101, 67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111,
+     10, 45, 45, 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45,
+     32, 36, 73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,
+    115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101, 32,
+    115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32, 99,
+     97,110, 32,114,101,100,105,115,116,114,105, 98,117,116,101,
+     32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100,105,
+    102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,
+    111,102,116,119, 97,114,101, 32,112,114,111,118,105,100,101,
+    100, 32,104,101,114,101,117,110,100,101,114, 32,105,115, 32,
+    111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98,
+     97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,
+    101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110,111,
+     32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111, 32,
+    112,114,111,118,105,100,101, 32,109, 97,105,110,116,101,110,
+     97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44, 32,
+    117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,104,
+     97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32,109,
+    111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10, 10,
+     10, 45, 45, 32, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,
+    115,101,110,116,115, 32,118, 97,114,105, 97, 98,108,101, 44,
+     32,102,117,110, 99,116,105,111,110, 44, 32,111,114, 32, 97,
+    114,103,117,109,101,110,116, 32,100,101, 99,108, 97,114, 97,
+    116,105,111,110, 46, 10, 45, 45, 32, 83,116,111,114,101,115,
+     32,116,104,101, 32,102,111,108,108,111,119,105,110,103, 32,
+    102,105,101,108,100,115, 58, 10, 45, 45, 32, 32,109,111,100,
+     32, 32, 61, 32,116,121,112,101, 32,109,111,100,105,102,105,
+    101,114,115, 10, 45, 45, 32, 32,116,121,112,101, 32, 61, 32,
+    116,121,112,101, 10, 45, 45, 32, 32,112,116,114, 32, 32, 61,
+     32, 34, 42, 34, 32,111,114, 32, 34, 38, 34, 44, 32,105,102,
+     32,114,101,112,114,101,115,101,110,116,105,110,103, 32, 97,
+     32,112,111,105,110,116,101,114, 32,111,114, 32, 97, 32,114,
+    101,102,101,114,101,110, 99,101, 10, 45, 45, 32, 32,110, 97,
+    109,101, 32, 61, 32,110, 97,109,101, 10, 45, 45, 32, 32,100,
+    105,109, 32, 32, 61, 32,100,105,109,101,110,115,105,111,110,
+     44, 32,105,102, 32, 97, 32,118,101, 99,116,111,114, 10, 45,
+     45, 32, 32,100,101,102, 32, 32, 61, 32,100,101,102, 97,117,
+    108,116, 32,118, 97,108,117,101, 44, 32,105,102, 32, 97,110,
+    121, 32, 40,111,110,108,121, 32,102,111,114, 32, 97,114,103,
+    117,109,101,110,116,115, 41, 10, 45, 45, 32, 32,114,101,116,
+     32, 32, 61, 32, 34, 42, 34, 32,111,114, 32, 34, 38, 34, 44,
+     32,105,102, 32,118, 97,108,117,101, 32,105,115, 32,116,111,
+     32, 98,101, 32,114,101,116,117,114,110,101,100, 32, 40,111,
+    110,108,121, 32,102,111,114, 32, 97,114,103,117,109,101,110,
+    116,115, 41, 10, 99,108, 97,115,115, 68,101, 99,108, 97,114,
+     97,116,105,111,110, 32, 61, 32,123, 10, 32,109,111,100, 32,
+     61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39,
+     39, 44, 10, 32,112,116,114, 32, 61, 32, 39, 39, 44, 10, 32,
+    110, 97,109,101, 32, 61, 32, 39, 39, 44, 10, 32,100,105,109,
+     32, 61, 32, 39, 39, 44, 10, 32,114,101,116, 32, 61, 32, 39,
+     39, 44, 10, 32,100,101,102, 32, 61, 32, 39, 39, 10,125, 10,
+     99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,
+    110, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,
+    115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 10,115,
+    101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,108, 97,
+    115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 44, 99,
+    108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10, 10, 45,
+     45, 32, 67,114,101, 97,116,101, 32, 97,110, 32,117,110,105,
+    113,117,101, 32,118, 97,114,105, 97, 98,108,101, 32,110, 97,
+    109,101, 10,102,117,110, 99,116,105,111,110, 32, 99,114,101,
+     97,116,101, 95,118, 97,114,110, 97,109,101, 32, 40, 41, 10,
+     32,105,102, 32,110,111,116, 32, 95,118, 97,114,110,117,109,
+     98,101,114, 32,116,104,101,110, 32, 95,118, 97,114,110,117,
+    109, 98,101,114, 32, 61, 32, 48, 32,101,110,100, 10, 32, 95,
+    118, 97,114,110,117,109, 98,101,114, 32, 61, 32, 95,118, 97,
+    114,110,117,109, 98,101,114, 32, 43, 32, 49, 10, 32,114,101,
+    116,117,114,110, 32, 34,116,111,108,117, 97, 95,118, 97,114,
+     95, 34, 46, 46, 95,118, 97,114,110,117,109, 98,101,114, 10,
+    101,110,100, 10, 10, 45, 45, 32, 67,104,101, 99,107, 32,100,
+    101, 99,108, 97,114, 97,116,105,111,110, 32,110, 97,109,101,
+     10, 45, 45, 32, 73,116, 32, 97,108,115,111, 32,105,100,101,
+    110,116,105,102,105,101,115, 32,100,101,102, 97,117,108,116,
+     32,118, 97,108,117,101,115, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,
+    105,111,110, 58, 99,104,101, 99,107,110, 97,109,101, 32, 40,
+     41, 10, 10, 32,105,102, 32,115,116,114,115,117, 98, 40,115,
+    101,108,102, 46,110, 97,109,101, 44, 49, 44, 49, 41, 32, 61,
+     61, 32, 39, 91, 39, 32, 97,110,100, 32,110,111,116, 32,102,
+    105,110,100,116,121,112,101, 40,115,101,108,102, 46,116,121,
+    112,101, 41, 32,116,104,101,110, 10, 32, 32,115,101,108,102,
+     46,110, 97,109,101, 32, 61, 32,115,101,108,102, 46,116,121,
+    112,101, 46, 46,115,101,108,102, 46,110, 97,109,101, 10, 32,
+     32,108,111, 99, 97,108, 32,109, 32, 61, 32,115,112,108,105,
+    116, 40,115,101,108,102, 46,109,111,100, 44, 39, 37,115, 37,
+    115, 42, 39, 41, 10, 32, 32,115,101,108,102, 46,116,121,112,
+    101, 32, 61, 32,109, 91,109, 46,110, 93, 10, 32, 32,115,101,
+    108,102, 46,109,111,100, 32, 61, 32, 99,111,110, 99, 97,116,
+     40,109, 44, 49, 44,109, 46,110, 45, 49, 41, 10, 32,101,110,
+    100, 10, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,115,
+    112,108,105,116, 40,115,101,108,102, 46,110, 97,109,101, 44,
+     39, 61, 39, 41, 10, 32,105,102, 32,116, 46,110, 61, 61, 50,
+     32,116,104,101,110, 10, 32, 32,115,101,108,102, 46,110, 97,
+    109,101, 32, 61, 32,116, 91, 49, 93, 10, 32, 32,115,101,108,
+    102, 46,100,101,102, 32, 61, 32,102,105,110,100, 95,101,110,
+    117,109, 95,118, 97,114, 40,116, 91,116, 46,110, 93, 41, 10,
+     32,101,110,100, 10, 10, 32,108,111, 99, 97,108, 32, 98, 44,
+    101, 44,100, 32, 61, 32,115,116,114,102,105,110,100, 40,115,
+    101,108,102, 46,110, 97,109,101, 44, 34, 37, 91, 40, 46, 45,
+     41, 37, 93, 34, 41, 10, 32,105,102, 32, 98, 32,116,104,101,
+    110, 10, 32, 32,115,101,108,102, 46,110, 97,109,101, 32, 61,
+     32,115,116,114,115,117, 98, 40,115,101,108,102, 46,110, 97,
+    109,101, 44, 49, 44, 98, 45, 49, 41, 10, 32, 32,115,101,108,
+    102, 46,100,105,109, 32, 61, 32,102,105,110,100, 95,101,110,
+    117,109, 95,118, 97,114, 40,100, 41, 10, 32,101,110,100, 10,
+     10, 10, 32,105,102, 32,115,101,108,102, 46,116,121,112,101,
+     32,126, 61, 32, 39, 39, 32, 97,110,100, 32,115,101,108,102,
+     46,116,121,112,101, 32,126, 61, 32, 39,118,111,105,100, 39,
+     32, 97,110,100, 32,115,101,108,102, 46,110, 97,109,101, 32,
+     61, 61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,115,101,
+    108,102, 46,110, 97,109,101, 32, 61, 32, 99,114,101, 97,116,
+    101, 95,118, 97,114,110, 97,109,101, 40, 41, 10, 32,101,108,
+    115,101,105,102, 32,115,101,108,102, 46,107,105,110,100, 61,
+     61, 39,118, 97,114, 39, 32,116,104,101,110, 10, 32, 32,105,
+    102, 32,115,101,108,102, 46,116,121,112,101, 61, 61, 39, 39,
+     32, 97,110,100, 32,115,101,108,102, 46,110, 97,109,101,126,
+     61, 39, 39, 32,116,104,101,110, 10, 32, 32, 32,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 32,115,101,108,102, 46,116,
+    121,112,101, 46, 46,115,101,108,102, 46,110, 97,109,101, 10,
+     32, 32, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 32,
+     99,114,101, 97,116,101, 95,118, 97,114,110, 97,109,101, 40,
+     41, 10, 32, 32,101,108,115,101,105,102, 32,102,105,110,100,
+    116,121,112,101, 40,115,101,108,102, 46,110, 97,109,101, 41,
+     32,116,104,101,110, 10, 32, 32, 32,105,102, 32,115,101,108,
+    102, 46,116,121,112,101, 61, 61, 39, 39, 32,116,104,101,110,
+     32,115,101,108,102, 46,116,121,112,101, 32, 61, 32,115,101,
+    108,102, 46,110, 97,109,101, 10, 32, 32, 32,101,108,115,101,
+     32,115,101,108,102, 46,116,121,112,101, 32, 61, 32,115,101,
+    108,102, 46,116,121,112,101, 46, 46, 39, 32, 39, 46, 46,115,
+    101,108,102, 46,110, 97,109,101, 32,101,110,100, 10, 32, 32,
+     32,115,101,108,102, 46,110, 97,109,101, 32, 61, 32, 99,114,
+    101, 97,116,101, 95,118, 97,114,110, 97,109,101, 40, 41, 10,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45,
+     32, 97,100,106,117,115,116, 32,116,121,112,101, 32,111,102,
+     32,115,116,114,105,110,103, 10, 32,105,102, 32,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 61, 32, 39, 99,104, 97,114,
+     39, 32, 97,110,100, 32,115,101,108,102, 46,100,105,109, 32,
+    126, 61, 32, 39, 39, 32,116,104,101,110, 10,  9, 32,115,101,
+    108,102, 46,116,121,112,101, 32, 61, 32, 39, 99,104, 97,114,
+     42, 39, 10, 32,101,110,100, 10, 10,  9,105,102, 32,115,101,
+    108,102, 46,107,105,110,100, 32, 97,110,100, 32,115,101,108,
+    102, 46,107,105,110,100, 32, 61, 61, 32, 39,118, 97,114, 39,
+     32,116,104,101,110, 10,  9,  9,115,101,108,102, 46,110, 97,
+    109,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40,115,101,108,102, 46,110, 97,109,101, 44, 32, 34, 58,
+     46, 42, 36, 34, 44, 32, 34, 34, 41, 32, 45, 45, 32, 63, 63,
+     63, 10,  9,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     67,104,101, 99,107, 32,100,101, 99,108, 97,114, 97,116,105,
+    111,110, 32,116,121,112,101, 10, 45, 45, 32, 83,117, 98,115,
+    116,105,116,117,116,101,115, 32,116,121,112,101,100,101,102,
+     39,115, 46, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 58,
+     99,104,101, 99,107,116,121,112,101, 32, 40, 41, 10, 10, 32,
+     45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,116,104,101,
+    114,101, 32,105,115, 32, 97, 32,112,111,105,110,116,101,114,
+     32,116,111, 32, 98, 97,115,105, 99, 32,116,121,112,101, 10,
+     32,108,111, 99, 97,108, 32, 98, 97,115,105, 99, 32, 61, 32,
+    105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46,116,121,
+    112,101, 41, 10, 32,105,102, 32,115,101,108,102, 46,107,105,
+    110,100, 32, 61, 61, 32, 39,102,117,110, 99, 39, 32, 97,110,
+    100, 32, 98, 97,115,105, 99, 61, 61, 39,110,117,109, 98,101,
+    114, 39, 32, 97,110,100, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,115,101,108,102, 46,112,116,114, 44, 32, 34,
+     37, 42, 34, 41, 32,116,104,101,110, 10, 32,  9,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 32, 39, 95,117,115,101,114,
+    100, 97,116, 97, 39, 10, 32,  9,115,101,108,102, 46,112,116,
+    114, 32, 61, 32, 34, 34, 10, 32,101,110,100, 10, 32,105,102,
+     32, 98, 97,115,105, 99, 32, 97,110,100, 32,115,101,108,102,
+     46,112,116,114,126, 61, 39, 39, 32,116,104,101,110, 10, 32,
+     32,115,101,108,102, 46,114,101,116, 32, 61, 32,115,101,108,
+    102, 46,112,116,114, 10, 32, 32,115,101,108,102, 46,112,116,
+    114, 32, 61, 32,110,105,108, 10, 32, 32,105,102, 32,105,115,
+     98, 97,115,105, 99, 40,115,101,108,102, 46,116,121,112,101,
+     41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,
+    104,101,110, 10, 32, 32,  9,115,101,108,102, 46,114,101,116,
+    117,114,110, 95,117,115,101,114,100, 97,116, 97, 32, 61, 32,
+    116,114,117,101, 10, 32, 32,101,110,100, 10, 32,101,110,100,
+     10, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    116,104,101,114,101, 32,105,115, 32, 97,114,114, 97,121, 32,
+    116,111, 32, 98,101, 32,114,101,116,117,114,110,101,100, 10,
+     32,105,102, 32,115,101,108,102, 46,100,105,109,126, 61, 39,
+     39, 32, 97,110,100, 32,115,101,108,102, 46,114,101,116,126,
+     61, 39, 39, 32,116,104,101,110, 10, 32, 32, 32,101,114,114,
+    111,114, 40, 39, 35,105,110,118, 97,108,105,100, 32,112, 97,
+    114, 97,109,101,116,101,114, 58, 32, 99, 97,110,110,111,116,
+     32,114,101,116,117,114,110, 32, 97,110, 32, 97,114,114, 97,
+    121, 32,111,102, 32,118, 97,108,117,101,115, 39, 41, 10, 32,
+    101,110,100, 10, 32, 45, 45, 32,114,101,115,116,111,114,101,
+     32, 39,118,111,105,100, 42, 39, 32, 97,110,100, 32, 39,115,
+    116,114,105,110,103, 42, 39, 10, 32,105,102, 32,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 61, 32, 39, 95,117,115,101,
+    114,100, 97,116, 97, 39, 32,116,104,101,110, 32,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 32, 39,118,111,105,100, 42,
+     39, 10, 32,101,108,115,101,105,102, 32,115,101,108,102, 46,
+    116,121,112,101, 32, 61, 61, 32, 39, 95, 99,115,116,114,105,
+    110,103, 39, 32,116,104,101,110, 32,115,101,108,102, 46,116,
+    121,112,101, 32, 61, 32, 39, 99,104, 97,114, 42, 39, 10, 32,
+    101,108,115,101,105,102, 32,115,101,108,102, 46,116,121,112,
+    101, 32, 61, 61, 32, 39, 95,108,115,116, 97,116,101, 39, 32,
+    116,104,101,110, 32,115,101,108,102, 46,116,121,112,101, 32,
+     61, 32, 39,108,117, 97, 95, 83,116, 97,116,101, 42, 39, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32,114,101,115,111,108,
+    118,101, 32,116,121,112,101,115, 32,105,110,115,105,100,101,
+     32,116,104,101, 32,116,101,109,112,108, 97,116,101,115, 10,
+     32,105,102, 32,115,101,108,102, 46,116,121,112,101, 32,116,
+    104,101,110, 10,  9, 32,115,101,108,102, 46,116,121,112,101,
+     32, 61, 32,114,101,115,111,108,118,101, 95,116,101,109,112,
+    108, 97,116,101, 95,116,121,112,101,115, 40,115,101,108,102,
+     46,116,121,112,101, 41, 10, 32,101,110,100, 10, 10, 45, 45,
+     10, 45, 45, 32, 45, 45, 32,105,102, 32,114,101,116,117,114,
+    110,105,110,103, 32,118, 97,108,117,101, 44, 32, 97,117,116,
+    111,109, 97,116,105, 99, 97,108,108,121, 32,115,101,116, 32,
+    100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 10, 45,
+     45, 32,105,102, 32,115,101,108,102, 46,114,101,116, 32,126,
+     61, 32, 39, 39, 32, 97,110,100, 32,115,101,108,102, 46,100,
+    101,102, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 45,
+     45, 32, 32,115,101,108,102, 46,100,101,102, 32, 61, 32, 39,
+     48, 39, 10, 45, 45, 32,101,110,100, 10, 45, 45, 10, 10,101,
+    110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,114,101,
+    115,111,108,118,101, 95,116,101,109,112,108, 97,116,101, 95,
+    116,121,112,101,115, 40,116,121,112,101, 41, 10, 10,  9,105,
+    102, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41,
+     32,116,104,101,110, 10,  9,  9,114,101,116,117,114,110, 32,
+    116,121,112,101, 10,  9,101,110,100, 10,  9,108,111, 99, 97,
+    108, 32, 98, 44, 95, 44,109, 32, 61, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40,116,121,112,101, 44, 32, 34, 40,
+     37, 98, 60, 62, 41, 34, 41, 10,  9,105,102, 32, 98, 32,116,
+    104,101,110, 10, 10,  9,  9,109, 32, 61, 32,115,112,108,105,
+    116, 95, 99, 95,116,111,107,101,110,115, 40,115,116,114,105,
+    110,103, 46,115,117, 98, 40,109, 44, 32, 50, 44, 32, 45, 50,
+     41, 44, 32, 34, 44, 34, 41, 10,  9,  9,102,111,114, 32,105,
+     61, 49, 44, 32,116, 97, 98,108,101, 46,103,101,116,110, 40,
+    109, 41, 32,100,111, 10,  9,  9,  9,109, 91,105, 93, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,109, 91,
+    105, 93, 44, 34, 37,115, 42, 40, 91, 37, 42, 38, 93, 41, 34,
+     44, 32, 34, 37, 49, 34, 41, 10,  9,  9,  9,109, 91,105, 93,
+     32, 61, 32,102,105,110,100,116,121,112,101, 40,109, 91,105,
+     93, 41, 32,111,114, 32,109, 91,105, 93, 10,  9,  9,  9,109,
+     91,105, 93, 32, 61, 32,114,101,115,111,108,118,101, 95,116,
+    101,109,112,108, 97,116,101, 95,116,121,112,101,115, 40,109,
+     91,105, 93, 41, 10,  9,  9,101,110,100, 10, 10,  9,  9,108,
+    111, 99, 97,108, 32, 98, 44,105, 10,  9,  9,116,121,112,101,
+     44, 98, 44,105, 32, 61, 32, 98,114,101, 97,107, 95,116,101,
+    109,112,108, 97,116,101, 40,116,121,112,101, 41, 10,  9,  9,
+    108,111, 99, 97,108, 32,116,101,109,112,108, 97,116,101, 95,
+    112, 97,114,116, 32, 61, 32, 34, 60, 34, 46, 46,115,116,114,
+    105,110,103, 46,103,115,117, 98, 40, 99,111,110, 99, 97,116,
+     40,109, 44, 32, 49, 44, 32,109, 46,110, 41, 44, 32, 34, 32,
+     34, 44, 32, 34, 44, 34, 41, 46, 46, 34, 62, 34, 10,  9,  9,
+    116,121,112,101, 32, 61, 32,114,101, 98,117,105,108,100, 95,
+    116,101,109,112,108, 97,116,101, 40,116,121,112,101, 44, 32,
+     98, 44, 32,116,101,109,112,108, 97,116,101, 95,112, 97,114,
+    116, 41, 10,  9,  9,116,121,112,101, 32, 61, 32,115,116,114,
+    105,110,103, 46,103,115,117, 98, 40,116,121,112,101, 44, 32,
+     34, 62, 62, 34, 44, 32, 34, 62, 32, 62, 34, 41, 10,  9,101,
+    110,100, 10,  9,114,101,116,117,114,110, 32,116,121,112,101,
+     10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
+     98,114,101, 97,107, 95,116,101,109,112,108, 97,116,101, 40,
+    115, 41, 10,  9,108,111, 99, 97,108, 32, 98, 44,101, 44,116,
+    105,109,112,108, 32, 61, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,115, 44, 32, 34, 40, 37, 98, 60, 62, 41, 34,
+     41, 10,  9,105,102, 32,116,105,109,112,108, 32,116,104,101,
+    110, 10,  9,  9,115, 32, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40,115, 44, 32, 34, 37, 98, 60, 62, 34, 44,
+     32, 34, 34, 41, 10,  9,  9,114,101,116,117,114,110, 32,115,
+     44, 32, 98, 44, 32,116,105,109,112,108, 10,  9,101,108,115,
+    101, 10,  9,  9,114,101,116,117,114,110, 32,115, 44, 32, 48,
+     44, 32,110,105,108, 10,  9,101,110,100, 10,101,110,100, 10,
+     10,102,117,110, 99,116,105,111,110, 32,114,101, 98,117,105,
+    108,100, 95,116,101,109,112,108, 97,116,101, 40,115, 44, 32,
+     98, 44, 32,116,105,109,112,108, 41, 10, 10,  9,105,102, 32,
+     98, 32, 61, 61, 32, 48, 32,116,104,101,110, 10,  9,  9,114,
+    101,116,117,114,110, 32,115, 10,  9,101,110,100, 10, 10,  9,
+    114,101,116,117,114,110, 32,115,116,114,105,110,103, 46,115,
+    117, 98, 40,115, 44, 32, 49, 44, 32, 98, 45, 49, 41, 46, 46,
+    116,105,109,112,108, 46, 46,115,116,114,105,110,103, 46,115,
+    117, 98, 40,115, 44, 32, 98, 44, 32, 45, 49, 41, 10,101,110,
+    100, 10, 10, 45, 45, 32, 80,114,105,110,116, 32,109,101,116,
+    104,111,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 68,101, 99,108, 97,114, 97,116,105,111,
+    110,123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44,
+     34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116,
+     46, 46, 34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34,
+     41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    100,105,109, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,100,105,109, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,100,101,
+    102, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,100,
+    101,102, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32,114,101,116, 32,
+     32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,114,101,116,
+     46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34,125, 34, 46, 46, 99,108,111,
+    115,101, 41, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101,
+     99,107, 32,105,102, 32, 97,114,114, 97,121, 32,111,102, 32,
+    118, 97,108,117,101,115, 32, 97,114,101, 32,114,101,116,117,
+    114,110,101,100, 32,116,111, 32, 76,117, 97, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,108,
+     97,114, 97,116,105,111,110, 58,114,101,113,117,105,114,101,
+     99,111,108,108,101, 99,116,105,111,110, 32, 40,116, 41, 10,
+     32,105,102, 32,115,101,108,102, 46,109,111,100, 32,126, 61,
+     32, 39, 99,111,110,115,116, 39, 32, 97,110,100, 10,  9, 32,
+     32, 32, 32,115,101,108,102, 46,100,105,109, 32, 97,110,100,
+     32,115,101,108,102, 46,100,105,109, 32,126, 61, 32, 39, 39,
+     32, 97,110,100, 10,  9,  9,  9,  9, 32,110,111,116, 32,105,
+    115, 98, 97,115,105, 99, 40,115,101,108,102, 46,116,121,112,
+    101, 41, 32, 97,110,100, 10,  9,  9,  9,  9, 32,115,101,108,
+    102, 46,112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,
+    110, 10,  9,  9,108,111, 99, 97,108, 32,116,121,112,101, 32,
+     61, 32,103,115,117, 98, 40,115,101,108,102, 46,116,121,112,
+    101, 44, 34, 37,115, 42, 99,111,110,115,116, 37,115, 43, 34,
+     44, 34, 34, 41, 10,  9,  9,116, 91,116,121,112,101, 93, 32,
+     61, 32, 34,116,111,108,117, 97, 95, 99,111,108,108,101, 99,
+    116, 95, 34, 32, 46, 46, 32, 99,108,101, 97,110, 95,116,101,
+    109,112,108, 97,116,101, 40,116,121,112,101, 41, 10,  9,  9,
+    114,101,116,117,114,110, 32,116,114,117,101, 10,  9,101,110,
+    100, 10,  9,114,101,116,117,114,110, 32,102, 97,108,115,101,
+     10,101,110,100, 10, 10, 45, 45, 32,100,101, 99,108, 97,114,
+    101, 32,116, 97,103, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,
+    110, 58,100,101, 99,108,116,121,112,101, 32, 40, 41, 10, 10,
+      9,115,101,108,102, 46,116,121,112,101, 32, 61, 32,116,121,
+    112,101,118, 97,114, 40,115,101,108,102, 46,116,121,112,101,
+     41, 10,  9,105,102, 32,115,116,114,102,105,110,100, 40,115,
+    101,108,102, 46,109,111,100, 44, 39, 99,111,110,115,116, 39,
+     41, 32,116,104,101,110, 10,  9,  9,115,101,108,102, 46,116,
+    121,112,101, 32, 61, 32, 39, 99,111,110,115,116, 32, 39, 46,
+     46,115,101,108,102, 46,116,121,112,101, 10,  9,  9,115,101,
+    108,102, 46,109,111,100, 32, 61, 32,103,115,117, 98, 40,115,
+    101,108,102, 46,109,111,100, 44, 39, 99,111,110,115,116, 37,
+    115, 42, 39, 44, 39, 39, 41, 10,  9,101,110,100, 10,101,110,
+    100, 10, 10, 10, 45, 45, 32,111,117,116,112,117,116, 32,116,
+    121,112,101, 32, 99,104,101, 99,107,105,110,103, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,
+    108, 97,114, 97,116,105,111,110, 58,111,117,116, 99,104,101,
+     99,107,116,121,112,101, 32, 40,110, 97,114,103, 41, 10, 32,
+    108,111, 99, 97,108, 32,100,101,102, 10, 32,108,111, 99, 97,
+    108, 32,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,
+    101,108,102, 46,116,121,112,101, 41, 10, 32,105,102, 32,115,
+    101,108,102, 46,100,101,102,126, 61, 39, 39, 32,116,104,101,
+    110, 10, 32, 32,100,101,102, 32, 61, 32, 49, 10, 32,101,108,
+    115,101, 10, 32, 32,100,101,102, 32, 61, 32, 48, 10, 32,101,
+    110,100, 10, 32,105,102, 32,115,101,108,102, 46,100,105,109,
+     32,126, 61, 32, 39, 39, 32,116,104,101,110, 10,  9, 45, 45,
+    105,102, 32,116, 61, 61, 39,115,116,114,105,110,103, 39, 32,
+    116,104,101,110, 10,  9, 45, 45,  9,114,101,116,117,114,110,
+     32, 39,116,111,108,117, 97, 95,105,115,115,116,114,105,110,
+    103, 97,114,114, 97,121, 40,116,111,108,117, 97, 95, 83, 44,
+     39, 46, 46,110, 97,114,103, 46, 46, 39, 44, 39, 46, 46,100,
+    101,102, 46, 46, 39, 44, 38,116,111,108,117, 97, 95,101,114,
+    114, 41, 39, 10,  9, 45, 45,101,108,115,101, 10,  9,114,101,
+    116,117,114,110, 32, 39,116,111,108,117, 97, 95,105,115,116,
+     97, 98,108,101, 40,116,111,108,117, 97, 95, 83, 44, 39, 46,
+     46,110, 97,114,103, 46, 46, 39, 44, 48, 44, 38,116,111,108,
+    117, 97, 95,101,114,114, 41, 39, 10, 32,  9, 45, 45,101,110,
+    100, 10, 32,101,108,115,101,105,102, 32,116, 32,116,104,101,
+    110, 10,  9,114,101,116,117,114,110, 32, 39,116,111,108,117,
+     97, 95,105,115, 39, 46, 46,116, 46, 46, 39, 40,116,111,108,
+    117, 97, 95, 83, 44, 39, 46, 46,110, 97,114,103, 46, 46, 39,
+     44, 39, 46, 46,100,101,102, 46, 46, 39, 44, 38,116,111,108,
+    117, 97, 95,101,114,114, 41, 39, 10, 32,101,108,115,101, 10,
+     32, 32,114,101,116,117,114,110, 32, 39,116,111,108,117, 97,
+     95,105,115,117,115,101,114,116,121,112,101, 40,116,111,108,
+    117, 97, 95, 83, 44, 39, 46, 46,110, 97,114,103, 46, 46, 39,
+     44, 34, 39, 46, 46,115,101,108,102, 46,116,121,112,101, 46,
+     46, 39, 34, 44, 39, 46, 46,100,101,102, 46, 46, 39, 44, 38,
+    116,111,108,117, 97, 95,101,114,114, 41, 39, 10, 32,101,110,
+    100, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,
+    111,110, 58, 98,117,105,108,100,100,101, 99,108, 97,114, 97,
+    116,105,111,110, 32, 40,110, 97,114,103, 44, 32, 99,112,108,
+    117,115,112,108,117,115, 41, 10, 32,108,111, 99, 97,108, 32,
+     97,114,114, 97,121, 32, 61, 32,115,101,108,102, 46,100,105,
+    109, 32,126, 61, 32, 39, 39, 32, 97,110,100, 32,116,111,110,
+    117,109, 98,101,114, 40,115,101,108,102, 46,100,105,109, 41,
+     61, 61,110,105,108, 10,  9,108,111, 99, 97,108, 32,108,105,
+    110,101, 32, 61, 32, 34, 34, 10, 32,108,111, 99, 97,108, 32,
+    112,116,114, 32, 61, 32, 39, 39, 10,  9,108,111, 99, 97,108,
+     32,109,111,100, 10,  9,108,111, 99, 97,108, 32,116,121,112,
+    101, 32, 61, 32,115,101,108,102, 46,116,121,112,101, 10, 32,
+    105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,  9, 32,116,121,112,101, 32,
+     61, 32,103,115,117, 98, 40,115,101,108,102, 46,116,121,112,
+    101, 44, 39, 99,111,110,115,116, 37,115, 43, 39, 44, 39, 39,
+     41, 32, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+    115, 32, 99,111,110,115,116, 32,109,111,100,105,102,105,101,
+    114, 32,102,111,114, 32, 97,114,114, 97,121,115, 10, 32,101,
+    110,100, 10, 32,105,102, 32,115,101,108,102, 46,112,116,114,
+    126, 61, 39, 39, 32, 97,110,100, 32,110,111,116, 32,105,115,
+     98, 97,115,105, 99, 40,116,121,112,101, 41, 32,116,104,101,
+    110, 32,112,116,114, 32, 61, 32, 39, 42, 39, 32,101,110,100,
+     10, 32,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,
+    112, 97,114, 97,109, 40,108,105,110,101, 44, 34, 32, 34, 44,
+    115,101,108,102, 46,109,111,100, 44,116,121,112,101, 44,112,
+    116,114, 41, 10, 32,105,102, 32, 97,114,114, 97,121, 32,116,
+    104,101,110, 10, 32, 32,108,105,110,101, 32, 61, 32, 99,111,
+    110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, 44,
+     39, 42, 39, 41, 10, 32,101,110,100, 10, 32,108,105,110,101,
+     32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,
+    108,105,110,101, 44,115,101,108,102, 46,110, 97,109,101, 41,
+     10, 32,105,102, 32,115,101,108,102, 46,100,105,109, 32,126,
+     61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,105,102, 32,
+    116,111,110,117,109, 98,101,114, 40,115,101,108,102, 46,100,
+    105,109, 41,126, 61,110,105,108, 32,116,104,101,110, 10, 32,
+     32, 32,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,
+    112, 97,114, 97,109, 40,108,105,110,101, 44, 39, 91, 39, 44,
+    115,101,108,102, 46,100,105,109, 44, 39, 93, 59, 39, 41, 10,
+     32, 32,101,108,115,101, 10,  9,105,102, 32, 99,112,108,117,
+    115,112,108,117,115, 32,116,104,101,110, 10,  9,  9,108,105,
+    110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,
+    109, 40,108,105,110,101, 44, 39, 32, 61, 32,110,101,119, 39,
+     44,116,121,112,101, 44,112,116,114, 44, 39, 91, 39, 46, 46,
+    115,101,108,102, 46,100,105,109, 46, 46, 39, 93, 59, 39, 41,
+     10,  9,101,108,115,101, 10,  9,  9,108,105,110,101, 32, 61,
+     32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105,
+    110,101, 44, 39, 32, 61, 32, 40, 39, 44,116,121,112,101, 44,
+    112,116,114, 44, 39, 42, 41, 39, 44, 10,  9,  9, 39,109, 97,
+    108,108,111, 99, 40, 40, 39, 44,115,101,108,102, 46,100,105,
+    109, 44, 39, 41, 42,115,105,122,101,111,102, 40, 39, 44,116,
+    121,112,101, 44,112,116,114, 44, 39, 41, 41, 59, 39, 41, 10,
+      9,101,110,100, 10, 32, 32,101,110,100, 10, 32,101,108,115,
+    101, 10, 32, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,105,
+    115, 98, 97,115,105, 99, 40,116,121,112,101, 41, 10, 32, 32,
+    108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,
+    114, 97,109, 40,108,105,110,101, 44, 39, 32, 61, 32, 39, 41,
+     10, 32, 32,105,102, 32,116, 32, 61, 61, 32, 39,115,116, 97,
+    116,101, 39, 32,116,104,101,110, 10, 32, 32,  9,108,105,110,
+    101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109,
+     40,108,105,110,101, 44, 32, 39,116,111,108,117, 97, 95, 83,
+     59, 39, 41, 10, 32, 32,101,108,115,101, 10, 32, 32,  9, 45,
+     45,112,114,105,110,116, 40, 34,116, 32,105,115, 32, 34, 46,
+     46,116,111,115,116,114,105,110,103, 40,116, 41, 46, 46, 34,
+     44, 32,112,116,114, 32,105,115, 32, 34, 46, 46,116,111,115,
+    116,114,105,110,103, 40,115,101,108,102, 46,112,116,114, 41,
+     41, 10, 32, 32,  9,105,102, 32,116, 32, 61, 61, 32, 39,110,
+    117,109, 98,101,114, 39, 32, 97,110,100, 32,115,116,114,105,
+    110,103, 46,102,105,110,100, 40,115,101,108,102, 46,112,116,
+    114, 44, 32, 34, 37, 42, 34, 41, 32,116,104,101,110, 10, 32,
+     32,  9,  9,116, 32, 61, 32, 39,117,115,101,114,100, 97,116,
+     97, 39, 10, 32, 32,  9,101,110,100, 10,  9,105,102, 32,110,
+    111,116, 32,116, 32, 97,110,100, 32,112,116,114, 61, 61, 39,
+     39, 32,116,104,101,110, 32,108,105,110,101, 32, 61, 32, 99,
+    111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110,101,
+     44, 39, 42, 39, 41, 32,101,110,100, 10,  9,108,105,110,101,
+     32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,
+    108,105,110,101, 44, 39, 40, 40, 39, 44,115,101,108,102, 46,
+    109,111,100, 44,116,121,112,101, 41, 10,  9,105,102, 32,110,
+    111,116, 32,116, 32,116,104,101,110, 10,  9,  9,108,105,110,
+    101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109,
+     40,108,105,110,101, 44, 39, 42, 39, 41, 10,  9,101,110,100,
+     10,  9,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,
+    112, 97,114, 97,109, 40,108,105,110,101, 44, 39, 41, 32, 39,
+     41, 10,  9,  9,  9,105,102, 32,105,115,101,110,117,109, 40,
+    116,121,112,101, 41, 32,116,104,101,110, 10,  9,  9,  9,108,
+    105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114,
+     97,109, 40,108,105,110,101, 44, 39, 40,105,110,116, 41, 32,
+     39, 41, 10,  9,  9,  9,101,110,100, 10,  9,108,111, 99, 97,
+    108, 32,100,101,102, 32, 61, 32, 48, 10,  9,105,102, 32,115,
+    101,108,102, 46,100,101,102, 32,126, 61, 32, 39, 39, 32,116,
+    104,101,110, 10,  9,  9,100,101,102, 32, 61, 32,115,101,108,
+    102, 46,100,101,102, 10,  9,  9,105,102, 32, 40,112,116,114,
+     32, 61, 61, 32, 39, 39, 32,111,114, 32,115,101,108,102, 46,
+    112,116,114, 32, 61, 61, 32, 39, 38, 39, 41, 32, 97,110,100,
+     32,110,111,116, 32,116, 32,116,104,101,110, 10,  9,  9,  9,
+    100,101,102, 32, 61, 32, 34, 40,118,111,105,100, 42, 41, 38,
+     40, 99,111,110,115,116, 32, 34, 46, 46,116,121,112,101, 46,
+     46, 34, 41, 34, 46, 46,100,101,102, 10,  9,  9,101,110,100,
+     10,  9,101,110,100, 10,  9,105,102, 32,116, 32,116,104,101,
+    110, 10,  9,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,
+    116,112, 97,114, 97,109, 40,108,105,110,101, 44, 39,116,111,
+    108,117, 97, 95,116,111, 39, 46, 46,116, 44, 39, 40,116,111,
+    108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44,
+     39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, 10,  9,101,
+    108,115,101, 10,  9,108,105,110,101, 32, 61, 32, 99,111,110,
+     99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, 44, 39,
+    116,111,108,117, 97, 95,116,111,117,115,101,114,116,121,112,
+    101, 40,116,111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,
+    103, 44, 39, 44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39,
+     41, 10,  9,101,110,100, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10,  9,114,101,116,117,114,110, 32,108,105,110,101,
+     10,101,110,100, 10, 10, 45, 45, 32, 68,101, 99,108, 97,114,
+    101, 32,118, 97,114,105, 97, 98,108,101, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,
+    114, 97,116,105,111,110, 58,100,101, 99,108, 97,114,101, 32,
+     40,110, 97,114,103, 41, 10, 32,105,102, 32,115,101,108,102,
+     46,100,105,109, 32,126, 61, 32, 39, 39, 32, 97,110,100, 32,
+    116,111,110,117,109, 98,101,114, 40,115,101,108,102, 46,100,
+    105,109, 41, 61, 61,110,105,108, 32,116,104,101,110, 10,  9,
+     32,111,117,116,112,117,116, 40, 39, 35,105,102,100,101,102,
+     32, 95, 95, 99,112,108,117,115,112,108,117,115, 92,110, 39,
+     41, 10,  9,  9,111,117,116,112,117,116, 40,115,101,108,102,
+     58, 98,117,105,108,100,100,101, 99,108, 97,114, 97,116,105,
+    111,110, 40,110, 97,114,103, 44,116,114,117,101, 41, 41, 10,
+      9,  9,111,117,116,112,117,116, 40, 39, 35,101,108,115,101,
+     92,110, 39, 41, 10,  9,  9,111,117,116,112,117,116, 40,115,
+    101,108,102, 58, 98,117,105,108,100,100,101, 99,108, 97,114,
+     97,116,105,111,110, 40,110, 97,114,103, 44,102, 97,108,115,
+    101, 41, 41, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10,  9,101,108,115,101,
+     10,  9,  9,111,117,116,112,117,116, 40,115,101,108,102, 58,
+     98,117,105,108,100,100,101, 99,108, 97,114, 97,116,105,111,
+    110, 40,110, 97,114,103, 44,102, 97,108,115,101, 41, 41, 10,
+      9,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 71,101,
+    116, 32,112, 97,114, 97,109,101,116,101,114, 32,118, 97,108,
+    117,101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 58,103,
+    101,116, 97,114,114, 97,121, 32, 40,110, 97,114,103, 41, 10,
+     32,105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 10,  9, 32,108,111, 99, 97,
+    108, 32,116,121,112,101, 32, 61, 32,103,115,117, 98, 40,115,
+    101,108,102, 46,116,121,112,101, 44, 39, 99,111,110,115,116,
+     32, 39, 44, 39, 39, 41, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 32,123, 39, 41, 10,  9, 32,111,117,116,112,117,
+    116, 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85,
+     65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10, 32,
+     32,108,111, 99, 97,108, 32,100,101,102, 59, 32,105,102, 32,
+    115,101,108,102, 46,100,101,102,126, 61, 39, 39, 32,116,104,
+    101,110, 32,100,101,102, 61, 49, 32,101,108,115,101, 32,100,
+    101,102, 61, 48, 32,101,110,100, 10,  9,  9,108,111, 99, 97,
+    108, 32,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,116,
+    121,112,101, 41, 10,  9,  9,105,102, 32, 40,116, 41, 32,116,
+    104,101,110, 10, 32, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 32, 32,105,102, 32, 40, 33,116,111,108,117, 97, 95,105,
+    115, 39, 46, 46,116, 46, 46, 39, 97,114,114, 97,121, 40,116,
+    111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39,
+     44, 39, 44,115,101,108,102, 46,100,105,109, 44, 39, 44, 39,
+     44,100,101,102, 44, 39, 44, 38,116,111,108,117, 97, 95,101,
+    114,114, 41, 41, 39, 41, 10,  9,  9,101,108,115,101, 10, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,105,102,
+     32, 40, 33,116,111,108,117, 97, 95,105,115,117,115,101,114,
+    116,121,112,101, 97,114,114, 97,121, 40,116,111,108,117, 97,
+     95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44, 34, 39, 44,
+    116,121,112,101, 44, 39, 34, 44, 39, 44,115,101,108,102, 46,
+    100,105,109, 44, 39, 44, 39, 44,100,101,102, 44, 39, 44, 38,
+    116,111,108,117, 97, 95,101,114,114, 41, 41, 39, 41, 10,  9,
+      9,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 32, 32, 32,103,111,116,111, 32,116,111,108,117, 97, 95,
+    108,101,114,114,111,114, 59, 39, 41, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32,101,108,115,101, 92,110, 39,
+     41, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32, 32, 32,123, 39, 41, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32, 32,105,110,116, 32,105, 59,
+     39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,
+     32, 32,102,111,114, 40,105, 61, 48, 59, 32,105, 60, 39, 46,
+     46,115,101,108,102, 46,100,105,109, 46, 46, 39, 59,105, 43,
+     43, 41, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,116, 32,
+     61, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41,
+     10, 32, 32,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32,
+     39, 39, 10, 32, 32,105,102, 32,115,101,108,102, 46,112,116,
+    114,126, 61, 39, 39, 32,116,104,101,110, 32,112,116,114, 32,
+     61, 32, 39, 42, 39, 32,101,110,100, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32, 39, 44,115,101,108,102, 46,
+    110, 97,109,101, 46, 46, 39, 91,105, 93, 32, 61, 32, 39, 41,
+     10, 32, 32,105,102, 32,110,111,116, 32,116, 32, 97,110,100,
+     32,112,116,114, 61, 61, 39, 39, 32,116,104,101,110, 32,111,
+    117,116,112,117,116, 40, 39, 42, 39, 41, 32,101,110,100, 10,
+     32, 32,111,117,116,112,117,116, 40, 39, 40, 40, 39, 44,116,
+    121,112,101, 41, 10, 32, 32,105,102, 32,110,111,116, 32,116,
+     32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 42, 39, 41, 10, 32, 32,101,110,100, 10, 32, 32,111,
+    117,116,112,117,116, 40, 39, 41, 32, 39, 41, 10, 32, 32,108,
+    111, 99, 97,108, 32,100,101,102, 32, 61, 32, 48, 10, 32, 32,
+    105,102, 32,115,101,108,102, 46,100,101,102, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 32,100,101,102, 32, 61, 32,115,
+    101,108,102, 46,100,101,102, 32,101,110,100, 10, 32, 32,105,
+    102, 32,116, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,
+    112,117,116, 40, 39,116,111,108,117, 97, 95,116,111,102,105,
+    101,108,100, 39, 46, 46,116, 46, 46, 39, 40,116,111,108,117,
+     97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44,105, 43,
+     49, 44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, 10,
+     32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,112,117,
+    116, 40, 39,116,111,108,117, 97, 95,116,111,102,105,101,108,
+    100,117,115,101,114,116,121,112,101, 40,116,111,108,117, 97,
+     95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44,105, 43, 49,
+     44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, 10, 32,
+     32,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 32, 32,125, 39, 41, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 32,125, 39, 41, 10, 32,101,110,100, 10,101,110,
+    100, 10, 10, 45, 45, 32, 71,101,116, 32,112, 97,114, 97,109,
+    101,116,101,114, 32,118, 97,108,117,101, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,
+    114, 97,116,105,111,110, 58,115,101,116, 97,114,114, 97,121,
+     32, 40,110, 97,114,103, 41, 10, 32,105,102, 32,110,111,116,
+     32,115,116,114,102,105,110,100, 40,115,101,108,102, 46,116,
+    121,112,101, 44, 39, 99,111,110,115,116, 37,115, 43, 39, 41,
+     32, 97,110,100, 32,115,101,108,102, 46,100,105,109, 32,126,
+     61, 32, 39, 39, 32,116,104,101,110, 10,  9, 32,108,111, 99,
+     97,108, 32,116,121,112,101, 32, 61, 32,103,115,117, 98, 40,
+    115,101,108,102, 46,116,121,112,101, 44, 39, 99,111,110,115,
+    116, 32, 39, 44, 39, 39, 41, 10, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32, 32,123, 39, 41, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32, 32,105,110,116, 32,105, 59, 39, 41,
+     10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,102,
+    111,114, 40,105, 61, 48, 59, 32,105, 60, 39, 46, 46,115,101,
+    108,102, 46,100,105,109, 46, 46, 39, 59,105, 43, 43, 41, 39,
+     41, 10, 32, 32,108,111, 99, 97,108, 32,116, 44, 99,116, 32,
+     61, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41,
+     10, 32, 32,105,102, 32,116, 32,116,104,101,110, 10, 32, 32,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,116,111,
+    108,117, 97, 95,112,117,115,104,102,105,101,108,100, 39, 46,
+     46,116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 39,
+     44,110, 97,114,103, 44, 39, 44,105, 43, 49, 44, 40, 39, 44,
+     99,116, 44, 39, 41, 39, 44,115,101,108,102, 46,110, 97,109,
+    101, 44, 39, 91,105, 93, 41, 59, 39, 41, 10, 32, 32,101,108,
+    115,101, 10, 32, 32, 32,105,102, 32,115,101,108,102, 46,112,
+    116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 32,
+     32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,
+    123, 39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,
+    115,112,108,117,115, 92,110, 39, 41, 10, 32, 32, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,118,111,105,
+    100, 42, 32,116,111,108,117, 97, 95,111, 98,106, 32, 61, 32,
+    110,101,119, 39, 44,116,121,112,101, 44, 39, 40, 39, 44,115,
+    101,108,102, 46,110, 97,109,101, 44, 39, 91,105, 93, 41, 59,
+     39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40,
+     39, 32, 32, 32, 32,116,111,108,117, 97, 95,112,117,115,104,
+    102,105,101,108,100,117,115,101,114,116,121,112,101, 95, 97,
+    110,100, 95,116, 97,107,101,111,119,110,101,114,115,104,105,
+    112, 40,116,111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,
+    103, 44, 39, 44,105, 43, 49, 44,116,111,108,117, 97, 95,111,
+     98,106, 44, 34, 39, 44,116,121,112,101, 44, 39, 34, 41, 59,
+     39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40,
+     39, 35,101,108,115,101, 92,110, 39, 41, 10, 32, 32, 32, 32,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,118,111,
+    105,100, 42, 32,116,111,108,117, 97, 95,111, 98,106, 32, 61,
+     32,116,111,108,117, 97, 95, 99,111,112,121, 40,116,111,108,
+    117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, 38, 39, 44,
+    115,101,108,102, 46,110, 97,109,101, 44, 39, 91,105, 93, 44,
+    115,105,122,101,111,102, 40, 39, 44,116,121,112,101, 44, 39,
+     41, 41, 59, 39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32, 32, 32,116,111,108,117, 97, 95,112,
+    117,115,104,102,105,101,108,100,117,115,101,114,116,121,112,
+    101, 40,116,111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,
+    103, 44, 39, 44,105, 43, 49, 44,116,111,108,117, 97, 95,111,
+     98,106, 44, 34, 39, 44,116,121,112,101, 44, 39, 34, 41, 59,
+     39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,125, 39,
+     41, 10, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32,111,
+    117,116,112,117,116, 40, 39, 32, 32, 32,116,111,108,117, 97,
+     95,112,117,115,104,102,105,101,108,100,117,115,101,114,116,
+    121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 39, 44,110,
+     97,114,103, 44, 39, 44,105, 43, 49, 44, 40,118,111,105,100,
+     42, 41, 39, 44,115,101,108,102, 46,110, 97,109,101, 44, 39,
+     91,105, 93, 44, 34, 39, 44,116,121,112,101, 44, 39, 34, 41,
+     59, 39, 41, 10, 32, 32, 32,101,110,100, 10, 32, 32,101,110,
+    100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,125,
+     39, 41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
+     32, 70,114,101,101, 32,100,121,110, 97,109,105, 99, 97,108,
+    108,121, 32, 97,108,108,111, 99, 97,116,101,100, 32, 97,114,
+    114, 97,121, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 58,
+    102,114,101,101, 97,114,114, 97,121, 32, 40, 41, 10, 32,105,
+    102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32, 39,
+     39, 32, 97,110,100, 32,116,111,110,117,109, 98,101,114, 40,
+    115,101,108,102, 46,100,105,109, 41, 61, 61,110,105,108, 32,
+    116,104,101,110, 10,  9, 32,111,117,116,112,117,116, 40, 39,
+     35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,115,112,
+    108,117,115, 92,110, 39, 41, 10,  9,  9,111,117,116,112,117,
+    116, 40, 39, 32, 32,100,101,108,101,116,101, 32, 91, 93, 39,
+     44,115,101,108,102, 46,110, 97,109,101, 44, 39, 59, 39, 41,
+     10,  9, 32,111,117,116,112,117,116, 40, 39, 35,101,108,115,
+    101, 92,110, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40,
+     39, 32, 32,102,114,101,101, 40, 39, 44,115,101,108,102, 46,
+    110, 97,109,101, 44, 39, 41, 59, 39, 41, 10,  9, 32,111,117,
+    116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39,
+     41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     80, 97,115,115, 32,112, 97,114, 97,109,101,116,101,114, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,
+    101, 99,108, 97,114, 97,116,105,111,110, 58,112, 97,115,115,
+    112, 97,114, 32, 40, 41, 10, 32,105,102, 32,115,101,108,102,
+     46,112,116,114, 61, 61, 39, 38, 39, 32, 97,110,100, 32,110,
+    111,116, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,102,
+     46,116,121,112,101, 41, 32,116,104,101,110, 10, 32, 32,111,
+    117,116,112,117,116, 40, 39, 42, 39, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 41, 10, 32,101,108,115,101,105,102, 32,
+    115,101,108,102, 46,114,101,116, 61, 61, 39, 42, 39, 32,116,
+    104,101,110, 10, 32, 32,111,117,116,112,117,116, 40, 39, 38,
+     39, 46, 46,115,101,108,102, 46,110, 97,109,101, 41, 10, 32,
+    101,108,115,101, 10, 32, 32,111,117,116,112,117,116, 40,115,
+    101,108,102, 46,110, 97,109,101, 41, 10, 32,101,110,100, 10,
+    101,110,100, 10, 10, 45, 45, 32, 82,101,116,117,114,110, 32,
+    112, 97,114, 97,109,101,116,101,114, 32,118, 97,108,117,101,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     68,101, 99,108, 97,114, 97,116,105,111,110, 58,114,101,116,
+    118, 97,108,117,101, 32, 40, 41, 10, 32,105,102, 32,115,101,
+    108,102, 46,114,101,116, 32,126, 61, 32, 39, 39, 32,116,104,
+    101,110, 10, 32, 32,108,111, 99, 97,108, 32,116, 44, 99,116,
+     32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,102,
+     46,116,121,112,101, 41, 10, 32, 32,105,102, 32,116, 32, 97,
+    110,100, 32,116,126, 61, 39, 39, 32,116,104,101,110, 10, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111,
+    108,117, 97, 95,112,117,115,104, 39, 46, 46,116, 46, 46, 39,
+     40,116,111,108,117, 97, 95, 83, 44, 40, 39, 44, 99,116, 44,
+     39, 41, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 46,
+     46, 39, 41, 59, 39, 41, 10, 32, 32,101,108,115,101, 10, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111,
+    108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,
+    101, 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100,
+     42, 41, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 46,
+     46, 39, 44, 34, 39, 44,115,101,108,102, 46,116,121,112,101,
+     44, 39, 34, 41, 59, 39, 41, 10, 32, 32,101,110,100, 10, 32,
+     32,114,101,116,117,114,110, 32, 49, 10, 32,101,110,100, 10,
+     32,114,101,116,117,114,110, 32, 48, 10,101,110,100, 10, 10,
+     45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,
+    115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116,105,
+    111,110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     32, 40,116, 41, 10, 10, 32,115,101,116,109,101,116, 97,116,
+     97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 68,101, 99,
+    108, 97,114, 97,116,105,111,110, 41, 10, 32,116, 58, 98,117,
+    105,108,100,110, 97,109,101,115, 40, 41, 10, 32,116, 58, 99,
+    104,101, 99,107,110, 97,109,101, 40, 41, 10, 32,116, 58, 99,
+    104,101, 99,107,116,121,112,101, 40, 41, 10, 32,108,111, 99,
+     97,108, 32,102,116, 32, 61, 32,102,105,110,100,116,121,112,
+    101, 40,116, 46,116,121,112,101, 41, 32,111,114, 32,116, 46,
+    116,121,112,101, 10, 32,105,102, 32,110,111,116, 32,105,115,
+    101,110,117,109, 40,102,116, 41, 32,116,104,101,110, 10,  9,
+    116, 46,109,111,100, 44, 32,116, 46,116,121,112,101, 32, 61,
+     32, 97,112,112,108,121,116,121,112,101,100,101,102, 40,116,
+     46,109,111,100, 44, 32,102,116, 41, 10, 32,101,110,100, 10,
+     10, 32,105,102, 32,116, 46,107,105,110,100, 61, 61, 34,118,
+     97,114, 34, 32, 97,110,100, 32, 40,115,116,114,105,110,103,
+     46,102,105,110,100, 40,116, 46,109,111,100, 44, 32, 34,116,
+    111,108,117, 97, 95,112,114,111,112,101,114,116,121, 37,115,
+     34, 41, 32,111,114, 32,115,116,114,105,110,103, 46,102,105,
+    110,100, 40,116, 46,109,111,100, 44, 32, 34,116,111,108,117,
+     97, 95,112,114,111,112,101,114,116,121, 36, 34, 41, 41, 32,
+    116,104,101,110, 10, 32,  9,116, 46,109,111,100, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,116, 46,109,
+    111,100, 44, 32, 34,116,111,108,117, 97, 95,112,114,111,112,
+    101,114,116,121, 34, 44, 32, 34,116,111,108,117, 97, 95,112,
+    114,111,112,101,114,116,121, 95, 95, 34, 46, 46,103,101,116,
+     95,112,114,111,112,101,114,116,121, 95,116,121,112,101, 40,
+     41, 41, 10, 32,101,110,100, 10, 10, 32,114,101,116,117,114,
+    110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,
+    115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,
+    101, 99,116,115, 32,116,104,101, 32,115,116,114,105,110,103,
+     32,100,101, 99,108, 97,114, 97,116,105,111,110, 46, 10, 45,
+     45, 32, 84,104,101, 32,107,105,110,100, 32,111,102, 32,100,
+    101, 99,108, 97,114, 97,116,105,111,110, 32, 99, 97,110, 32,
+     98,101, 32, 34,118, 97,114, 34, 32,111,114, 32, 34,102,117,
+    110, 99, 34, 46, 10,102,117,110, 99,116,105,111,110, 32, 68,
+    101, 99,108, 97,114, 97,116,105,111,110, 32, 40,115, 44,107,
+    105,110,100, 44,105,115, 95,112, 97,114, 97,109,101,116,101,
+    114, 41, 10, 10, 32, 45, 45, 32,101,108,105,109,105,110, 97,
+    116,101, 32,115,112, 97, 99,101,115, 32,105,102, 32,100,101,
+    102, 97,117,108,116, 32,118, 97,108,117,101, 32,105,115, 32,
+    112,114,111,118,105,100,101,100, 10, 32,115, 32, 61, 32,103,
+    115,117, 98, 40,115, 44, 34, 37,115, 42, 61, 37,115, 42, 34,
+     44, 34, 61, 34, 41, 10, 32,115, 32, 61, 32,103,115,117, 98,
+     40,115, 44, 32, 34, 37,115, 42, 60, 34, 44, 32, 34, 60, 34,
+     41, 10, 10, 32,108,111, 99, 97,108, 32,100,101,102, 98, 44,
+    116,109,112,100,101,102, 10, 32,100,101,102, 98, 44, 95, 44,
+    116,109,112,100,101,102, 32, 61, 32,115,116,114,105,110,103,
+     46,102,105,110,100, 40,115, 44, 32, 34, 40, 61, 46, 42, 41,
+     36, 34, 41, 10, 32,105,102, 32,100,101,102, 98, 32,116,104,
+    101,110, 10, 32,  9,115, 32, 61, 32,115,116,114,105,110,103,
+     46,103,115,117, 98, 40,115, 44, 32, 34, 61, 46, 42, 36, 34,
+     44, 32, 34, 34, 41, 10, 32,101,108,115,101, 10, 32,  9,116,
+    109,112,100,101,102, 32, 61, 32, 39, 39, 10, 32,101,110,100,
+     10, 32,105,102, 32,107,105,110,100, 32, 61, 61, 32, 34,118,
+     97,114, 34, 32,116,104,101,110, 10, 32, 32, 45, 45, 32, 99,
+    104,101, 99,107, 32,116,104,101, 32,102,111,114,109, 58, 32,
+    118,111,105,100, 10, 32, 32,105,102, 32,115, 32, 61, 61, 32,
+     39, 39, 32,111,114, 32,115, 32, 61, 61, 32, 39,118,111,105,
+    100, 39, 32,116,104,101,110, 10, 32, 32, 32,114,101,116,117,
+    114,110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,
+    123,116,121,112,101, 32, 61, 32, 39,118,111,105,100, 39, 44,
+     32,107,105,110,100, 32, 61, 32,107,105,110,100, 44, 32,105,
+    115, 95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105,
+    115, 95,112, 97,114, 97,109,101,116,101,114,125, 10, 32, 32,
+    101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,
+    104,101, 99,107, 32,116,104,101, 32,102,111,114,109, 58, 32,
+    109,111,100, 32,116,121,112,101, 42, 38, 32,110, 97,109,101,
+     10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,108,
+    105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44, 39,
+     37, 42, 37,115, 42, 38, 39, 41, 10, 32,105,102, 32,116, 46,
+    110, 32, 61, 61, 32, 50, 32,116,104,101,110, 10, 32, 32,105,
+    102, 32,107,105,110,100, 32, 61, 61, 32, 39,102,117,110, 99,
+     39, 32,116,104,101,110, 10, 32, 32, 32,101,114,114,111,114,
+     40, 34, 35,105,110,118, 97,108,105,100, 32,102,117,110, 99,
+    116,105,111,110, 32,114,101,116,117,114,110, 32,116,121,112,
+    101, 58, 32, 34, 46, 46,115, 41, 10, 32, 32,101,110,100, 10,
+     32, 32, 45, 45,108,111, 99, 97,108, 32,109, 32, 61, 32,115,
+    112,108,105,116, 40,116, 91, 49, 93, 44, 39, 37,115, 37,115,
+     42, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,109, 32, 61,
+     32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110,115,
+     40,116, 91, 49, 93, 44, 39, 37,115, 43, 39, 41, 10, 32, 32,
+    114,101,116,117,114,110, 32, 95, 68,101, 99,108, 97,114, 97,
+    116,105,111,110,123, 10, 32, 32, 32,110, 97,109,101, 32, 61,
+     32,116, 91, 50, 93, 46, 46,116,109,112,100,101,102, 44, 10,
+     32, 32, 32,112,116,114, 32, 61, 32, 39, 42, 39, 44, 10, 32,
+     32, 32,114,101,116, 32, 61, 32, 39, 38, 39, 44, 10, 32, 32,
+     32, 45, 45,116,121,112,101, 32, 61, 32,114,101, 98,117,105,
+    108,100, 95,116,101,109,112,108, 97,116,101, 40,109, 91,109,
+     46,110, 93, 44, 32,116, 98, 44, 32,116,105,109,112,108, 41,
+     44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,109, 91,109,
+     46,110, 93, 44, 10, 32, 32, 32,109,111,100, 32, 61, 32, 99,
+    111,110, 99, 97,116, 40,109, 44, 49, 44,109, 46,110, 45, 49,
+     41, 44, 10, 32, 32, 32,105,115, 95,112, 97,114, 97,109,101,
+    116,101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,101,
+    116,101,114, 44, 10, 32, 32, 32,107,105,110,100, 32, 61, 32,
+    107,105,110,100, 10, 32, 32,125, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,102,
+    111,114,109, 58, 32,109,111,100, 32,116,121,112,101, 42, 42,
+     32,110, 97,109,101, 10, 32,116, 32, 61, 32,115,112,108,105,
+    116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44, 39, 37,
+     42, 37,115, 42, 37, 42, 39, 41, 10, 32,105,102, 32,116, 46,
+    110, 32, 61, 61, 32, 50, 32,116,104,101,110, 10, 32, 32,105,
+    102, 32,107,105,110,100, 32, 61, 61, 32, 39,102,117,110, 99,
+     39, 32,116,104,101,110, 10, 32, 32, 32,101,114,114,111,114,
+     40, 34, 35,105,110,118, 97,108,105,100, 32,102,117,110, 99,
+    116,105,111,110, 32,114,101,116,117,114,110, 32,116,121,112,
+    101, 58, 32, 34, 46, 46,115, 41, 10, 32, 32,101,110,100, 10,
+     32, 32, 45, 45,108,111, 99, 97,108, 32,109, 32, 61, 32,115,
+    112,108,105,116, 40,116, 91, 49, 93, 44, 39, 37,115, 37,115,
+     42, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,109, 32, 61,
+     32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110,115,
+     40,116, 91, 49, 93, 44, 39, 37,115, 43, 39, 41, 10, 32, 32,
+    114,101,116,117,114,110, 32, 95, 68,101, 99,108, 97,114, 97,
+    116,105,111,110,123, 10, 32, 32, 32,110, 97,109,101, 32, 61,
+     32,116, 91, 50, 93, 46, 46,116,109,112,100,101,102, 44, 10,
+     32, 32, 32,112,116,114, 32, 61, 32, 39, 42, 39, 44, 10, 32,
+     32, 32,114,101,116, 32, 61, 32, 39, 42, 39, 44, 10, 32, 32,
+     32, 45, 45,116,121,112,101, 32, 61, 32,114,101, 98,117,105,
+    108,100, 95,116,101,109,112,108, 97,116,101, 40,109, 91,109,
+     46,110, 93, 44, 32,116, 98, 44, 32,116,105,109,112,108, 41,
+     44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,109, 91,109,
+     46,110, 93, 44, 10, 32, 32, 32,109,111,100, 32, 61, 32, 99,
+    111,110, 99, 97,116, 40,109, 44, 49, 44,109, 46,110, 45, 49,
+     41, 44, 10, 32, 32, 32,105,115, 95,112, 97,114, 97,109,101,
+    116,101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,101,
+    116,101,114, 44, 10, 32, 32, 32,107,105,110,100, 32, 61, 32,
+    107,105,110,100, 10, 32, 32,125, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,102,
+    111,114,109, 58, 32,109,111,100, 32,116,121,112,101, 38, 32,
+    110, 97,109,101, 10, 32,116, 32, 61, 32,115,112,108,105,116,
+     95, 99, 95,116,111,107,101,110,115, 40,115, 44, 39, 38, 39,
+     41, 10, 32,105,102, 32,116, 46,110, 32, 61, 61, 32, 50, 32,
+    116,104,101,110, 10, 32, 32, 45, 45,108,111, 99, 97,108, 32,
+    109, 32, 61, 32,115,112,108,105,116, 40,116, 91, 49, 93, 44,
+     39, 37,115, 37,115, 42, 39, 41, 10, 32, 32,108,111, 99, 97,
+    108, 32,109, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,
+    111,107,101,110,115, 40,116, 91, 49, 93, 44, 39, 37,115, 43,
+     39, 41, 10, 32, 32,114,101,116,117,114,110, 32, 95, 68,101,
+     99,108, 97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110,
+     97,109,101, 32, 61, 32,116, 91, 50, 93, 46, 46,116,109,112,
+    100,101,102, 44, 10, 32, 32, 32,112,116,114, 32, 61, 32, 39,
+     38, 39, 44, 10, 32, 32, 32, 45, 45,116,121,112,101, 32, 61,
+     32,114,101, 98,117,105,108,100, 95,116,101,109,112,108, 97,
+    116,101, 40,109, 91,109, 46,110, 93, 44, 32,116, 98, 44, 32,
+    116,105,109,112,108, 41, 44, 10, 32, 32, 32,116,121,112,101,
+     32, 61, 32,109, 91,109, 46,110, 93, 44, 10, 32, 32, 32,109,
+    111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,109, 44, 49,
+     44,109, 46,110, 45, 49, 41, 44, 10, 32, 32, 32,105,115, 95,
+    112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105,115, 95,
+    112, 97,114, 97,109,101,116,101,114, 44, 10, 32, 32, 32,107,
+    105,110,100, 32, 61, 32,107,105,110,100, 10, 32, 32,125, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32, 99,104,101, 99,107,
+     32,116,104,101, 32,102,111,114,109, 58, 32,109,111,100, 32,
+    116,121,112,101, 42, 32,110, 97,109,101, 10, 32,108,111, 99,
+     97,108, 32,115, 49, 32, 61, 32,103,115,117, 98, 40,115, 44,
+     34, 40, 37, 98, 92, 91, 92, 93, 41, 34, 44,102,117,110, 99,
+    116,105,111,110, 32, 40,110, 41, 32,114,101,116,117,114,110,
+     32,103,115,117, 98, 40,110, 44, 39, 37, 42, 39, 44, 39, 92,
+     49, 39, 41, 32,101,110,100, 41, 10, 32,116, 32, 61, 32,115,
+    112,108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115,
+     49, 44, 39, 37, 42, 39, 41, 10, 32,105,102, 32,116, 46,110,
+     32, 61, 61, 32, 50, 32,116,104,101,110, 10, 32, 32,116, 91,
+     50, 93, 32, 61, 32,103,115,117, 98, 40,116, 91, 50, 93, 44,
+     39, 92, 49, 39, 44, 39, 37, 42, 39, 41, 32, 45, 45, 32,114,
+    101,115,116,111,114,101, 32, 42, 32,105,110, 32,100,105,109,
+    101,110,115,105,111,110, 32,101,120,112,114,101,115,115,105,
+    111,110, 10, 32, 32, 45, 45,108,111, 99, 97,108, 32,109, 32,
+     61, 32,115,112,108,105,116, 40,116, 91, 49, 93, 44, 39, 37,
+    115, 37,115, 42, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,
+    109, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,
+    101,110,115, 40,116, 91, 49, 93, 44, 39, 37,115, 43, 39, 41,
+     10, 32, 32,114,101,116,117,114,110, 32, 95, 68,101, 99,108,
+     97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110, 97,109,
+    101, 32, 61, 32,116, 91, 50, 93, 46, 46,116,109,112,100,101,
+    102, 44, 10, 32, 32, 32,112,116,114, 32, 61, 32, 39, 42, 39,
+     44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,109, 91,109,
+     46,110, 93, 44, 10, 32, 32, 32, 45, 45,116,121,112,101, 32,
+     61, 32,114,101, 98,117,105,108,100, 95,116,101,109,112,108,
+     97,116,101, 40,109, 91,109, 46,110, 93, 44, 32,116, 98, 44,
+     32,116,105,109,112,108, 41, 44, 10, 32, 32, 32,109,111,100,
+     32, 61, 32, 99,111,110, 99, 97,116, 40,109, 44, 49, 44,109,
+     46,110, 45, 49, 41, 32, 32, 32, 44, 10, 32, 32, 32,105,115,
+     95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105,115,
+     95,112, 97,114, 97,109,101,116,101,114, 44, 10, 32, 32, 32,
+    107,105,110,100, 32, 61, 32,107,105,110,100, 10, 32, 32,125,
+     10, 32,101,110,100, 10, 10, 32,105,102, 32,107,105,110,100,
+     32, 61, 61, 32, 39,118, 97,114, 39, 32,116,104,101,110, 10,
+     32, 32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,
+    102,111,114,109, 58, 32,109,111,100, 32,116,121,112,101, 32,
+    110, 97,109,101, 10, 32, 32, 45, 45,116, 32, 61, 32,115,112,
+    108,105,116, 40,115, 44, 39, 37,115, 37,115, 42, 39, 41, 10,
+     32, 32,116, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,
+    111,107,101,110,115, 40,115, 44, 39, 37,115, 43, 39, 41, 10,
+     32, 32,108,111, 99, 97,108, 32,118, 10, 32, 32,105,102, 32,
+    102,105,110,100,116,121,112,101, 40,116, 91,116, 46,110, 93,
+     41, 32,116,104,101,110, 32,118, 32, 61, 32, 99,114,101, 97,
+    116,101, 95,118, 97,114,110, 97,109,101, 40, 41, 32,101,108,
+    115,101, 32,118, 32, 61, 32,116, 91,116, 46,110, 93, 59, 32,
+    116, 46,110, 32, 61, 32,116, 46,110, 45, 49, 32,101,110,100,
+     10, 32, 32,114,101,116,117,114,110, 32, 95, 68,101, 99,108,
+     97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110, 97,109,
+    101, 32, 61, 32,118, 46, 46,116,109,112,100,101,102, 44, 10,
+     32, 32, 32, 45, 45,116,121,112,101, 32, 61, 32,114,101, 98,
+    117,105,108,100, 95,116,101,109,112,108, 97,116,101, 40,116,
+     91,116, 46,110, 93, 44, 32,116, 98, 44, 32,116,105,109,112,
+    108, 41, 44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,116,
+     91,116, 46,110, 93, 44, 10, 32, 32, 32,109,111,100, 32, 61,
+     32, 99,111,110, 99, 97,116, 40,116, 44, 49, 44,116, 46,110,
+     45, 49, 41, 44, 10, 32, 32, 32,105,115, 95,112, 97,114, 97,
+    109,101,116,101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,
+    109,101,116,101,114, 44, 10, 32, 32, 32,107,105,110,100, 32,
+     61, 32,107,105,110,100, 10, 32, 32,125, 10, 10, 32,101,108,
+    115,101, 32, 45, 45, 32,107,105,110,100, 32, 61, 61, 32, 34,
+    102,117,110, 99, 34, 10, 10, 32, 32, 45, 45, 32, 99,104,101,
+     99,107, 32,116,104,101, 32,102,111,114,109, 58, 32,109,111,
+    100, 32,116,121,112,101, 32,110, 97,109,101, 10, 32, 32, 45,
+     45,116, 32, 61, 32,115,112,108,105,116, 40,115, 44, 39, 37,
+    115, 37,115, 42, 39, 41, 10, 32, 32,116, 32, 61, 32,115,112,
+    108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44,
+     39, 37,115, 43, 39, 41, 10, 32, 32,108,111, 99, 97,108, 32,
+    118, 32, 61, 32,116, 91,116, 46,110, 93, 32, 32, 45, 45, 32,
+    108, 97,115,116, 32,119,111,114,100, 32,105,115, 32,116,104,
+    101, 32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101,
+     10, 32, 32,108,111, 99, 97,108, 32,116,112, 44,109,100, 10,
+     32, 32,105,102, 32,116, 46,110, 62, 49, 32,116,104,101,110,
+     10, 32, 32, 32,116,112, 32, 61, 32,116, 91,116, 46,110, 45,
+     49, 93, 10, 32, 32, 32,109,100, 32, 61, 32, 99,111,110, 99,
+     97,116, 40,116, 44, 49, 44,116, 46,110, 45, 50, 41, 10, 32,
+     32,101,110,100, 10, 32, 32, 45, 45,105,102, 32,116,112, 32,
+    116,104,101,110, 32,116,112, 32, 61, 32,114,101, 98,117,105,
+    108,100, 95,116,101,109,112,108, 97,116,101, 40,116,112, 44,
+     32,116, 98, 44, 32,116,105,109,112,108, 41, 32,101,110,100,
+     10, 32, 32,114,101,116,117,114,110, 32, 95, 68,101, 99,108,
+     97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110, 97,109,
+    101, 32, 61, 32,118, 44, 10, 32, 32, 32,116,121,112,101, 32,
+     61, 32,116,112, 44, 10, 32, 32, 32,109,111,100, 32, 61, 32,
+    109,100, 44, 10, 32, 32, 32,105,115, 95,112, 97,114, 97,109,
+    101,116,101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,
+    101,116,101,114, 44, 10, 32, 32, 32,107,105,110,100, 32, 61,
+     32,107,105,110,100, 10, 32, 32,125, 10, 32,101,110,100, 10,
+     10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/declaration.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,118, 97,114,105, 97,
+     98,108,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45,
+     32, 86, 97,114,105, 97, 98,108,101, 32, 99,108, 97,115,115,
+     10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32,
+     97, 32,101,120,116,101,114,110, 32,118, 97,114,105, 97, 98,
+    108,101, 32,111,114, 32, 97, 32,112,117, 98,108,105, 99, 32,
+    109,101,109, 98,101,114, 32,111,102, 32, 97, 32, 99,108, 97,
+    115,115, 46, 10, 45, 45, 32, 83,116,111,114,101,115, 32, 97,
+    108,108, 32,102,105,101,108,100,115, 32,112,114,101,115,101,
+    110,116, 32,105,110, 32, 97, 32,100,101, 99,108, 97,114, 97,
+    116,105,111,110, 46, 10, 99,108, 97,115,115, 86, 97,114,105,
+     97, 98,108,101, 32, 61, 32,123, 10, 32, 95,103,101,116, 32,
+     61, 32,123,125, 44, 32, 32, 32, 45, 45, 32,109, 97,112,112,
+    101,100, 32,103,101,116, 32,102,117,110, 99,116,105,111,110,
+    115, 10, 32, 95,115,101,116, 32, 61, 32,123,125, 44, 32, 32,
+     32, 45, 45, 32,109, 97,112,112,101,100, 32,115,101,116, 32,
+    102,117,110, 99,116,105,111,110,115, 10,125, 10, 99,108, 97,
+    115,115, 86, 97,114,105, 97, 98,108,101, 46, 95, 95,105,110,
+    100,101,120, 32, 61, 32, 99,108, 97,115,115, 86, 97,114,105,
+     97, 98,108,101, 10,115,101,116,109,101,116, 97,116, 97, 98,
+    108,101, 40, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,
+    101, 44, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,
+    105,111,110, 41, 10, 10, 45, 45, 32, 80,114,105,110,116, 32,
+    109,101,116,104,111,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 86, 97,114,105, 97, 98,108,101,123, 34,
+     41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,
+    109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,105,102, 32,
+    115,101,108,102, 46,100,105,109, 32,116,104,101,110, 32,112,
+    114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,100,
+    105,109, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,100,
+    105,109, 46, 46, 34, 39, 44, 34, 41, 32,101,110,100, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    100,101,102, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,100,101,102, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,114,101,
+    116, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,114,
+    101,116, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46, 46, 99,
+    108,111,115,101, 41, 10,101,110,100, 10, 10, 45, 45, 32, 71,
+    101,110,101,114, 97,116,101,115, 32, 67, 32,102,117,110, 99,
+    116,105,111,110, 32,110, 97,109,101, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,
+    108,101, 58, 99,102,117,110, 99,110, 97,109,101, 32, 40,112,
+    114,101,102,105,120, 41, 10, 32,108,111, 99, 97,108, 32,112,
+     97,114,101,110,116, 32, 61, 32, 34, 34, 10, 32,108,111, 99,
+     97,108, 32,117,110,115,105,103,110,101,100, 32, 61, 32, 34,
+     34, 10, 32,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32,
+     34, 34, 10, 10, 32,108,111, 99, 97,108, 32,112, 32, 61, 32,
+    115,101,108,102, 58,105,110,109,111,100,117,108,101, 40, 41,
+     32,111,114, 32,115,101,108,102, 58,105,110,110, 97,109,101,
+    115,112, 97, 99,101, 40, 41, 32,111,114, 32,115,101,108,102,
+     58,105,110, 99,108, 97,115,115, 40, 41, 10, 10, 32,105,102,
+     32,112, 32,116,104,101,110, 10, 32,  9,105,102, 32,115,101,
+    108,102, 46,112, 97,114,101,110,116, 46, 99,108, 97,115,115,
+    116,121,112,101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39,
+     32,116,104,101,110, 10,  9,  9,112, 97,114,101,110,116, 32,
+     61, 32, 34, 95, 34, 32, 46, 46, 32,115,101,108,102, 46,112,
+     97,114,101,110,116, 46,116,121,112,101, 10,  9,101,108,115,
+    101, 10,  9, 32, 32,112, 97,114,101,110,116, 32, 61, 32, 34,
+     95, 34, 32, 46, 46, 32,112, 10,  9,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32,105,102, 32,115,116,114,102,105,110,100,
+     40,115,101,108,102, 46,109,111,100, 44, 34, 40,117,110,115,
+    105,103,110,101,100, 41, 34, 41, 32,116,104,101,110, 10, 32,
+     32,117,110,115,105,103,110,101,100, 32, 61, 32, 34, 95,117,
+    110,115,105,103,110,101,100, 34, 10, 32,101,110,100, 10, 10,
+     32,105,102, 32,115,101,108,102, 46,112,116,114, 32, 61, 61,
+     32, 34, 42, 34, 32,116,104,101,110, 32,112,116,114, 32, 61,
+     32, 34, 95,112,116,114, 34, 10, 32,101,108,115,101,105,102,
+     32,115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 34, 38,
+     34, 32,116,104,101,110, 32,112,116,114, 32, 61, 32, 34, 95,
+    114,101,102, 34, 10, 32,101,110,100, 10, 10, 32,108,111, 99,
+     97,108, 32,110, 97,109,101, 32, 61, 32, 32,112,114,101,102,
+    105,120, 32, 46, 46, 32,112, 97,114,101,110,116, 32, 46, 46,
+     32,117,110,115,105,103,110,101,100, 32, 46, 46, 32, 34, 95,
+     34, 32, 46, 46, 32,103,115,117, 98, 40,115,101,108,102, 46,
+    108,110, 97,109,101, 32,111,114, 32,115,101,108,102, 46,110,
+     97,109,101, 44, 34, 46, 42, 58, 58, 34, 44, 34, 34, 41, 32,
+     46, 46, 32,112,116,114, 10, 10,  9,110, 97,109,101, 32, 61,
+     32, 99,108,101, 97,110, 95,116,101,109,112,108, 97,116,101,
+     40,110, 97,109,101, 41, 10, 32,114,101,116,117,114,110, 32,
+    110, 97,109,101, 10, 10,101,110,100, 10, 10, 45, 45, 32, 99,
+    104,101, 99,107, 32,105,102, 32,105,116, 32,105,115, 32, 97,
+     32,118, 97,114,105, 97, 98,108,101, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,
+    108,101, 58,105,115,118, 97,114,105, 97, 98,108,101, 32, 40,
+     41, 10, 32,114,101,116,117,114,110, 32,116,114,117,101, 10,
+    101,110,100, 10, 10, 45, 45, 32,103,101,116, 32,118, 97,114,
+    105, 97, 98,108,101, 32,118, 97,108,117,101, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105,
+     97, 98,108,101, 58,103,101,116,118, 97,108,117,101, 32, 40,
+     99,108, 97,115,115, 44,115,116, 97,116,105, 99, 44, 32,112,
+    114,111,112, 95,103,101,116, 41, 10, 10,  9,108,111, 99, 97,
+    108, 32,110, 97,109,101, 10,  9,105,102, 32,112,114,111,112,
+     95,103,101,116, 32,116,104,101,110, 10, 10,  9,  9,110, 97,
+    109,101, 32, 61, 32,112,114,111,112, 95,103,101,116, 46, 46,
+     34, 40, 41, 34, 10,  9,101,108,115,101, 10,  9,  9,110, 97,
+    109,101, 32, 61, 32,115,101,108,102, 46,110, 97,109,101, 10,
+      9,101,110,100, 10, 10,  9,105,102, 32, 99,108, 97,115,115,
+     32, 97,110,100, 32,115,116, 97,116,105, 99, 32,116,104,101,
+    110, 10,  9, 32,114,101,116,117,114,110, 32,115,101,108,102,
+     46,112, 97,114,101,110,116, 46,116,121,112,101, 46, 46, 39,
+     58, 58, 39, 46, 46,110, 97,109,101, 10,  9,101,108,115,101,
+    105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,  9,
+     32,114,101,116,117,114,110, 32, 39,115,101,108,102, 45, 62,
+     39, 46, 46,110, 97,109,101, 10,  9,101,108,115,101, 10,  9,
+     32,114,101,116,117,114,110, 32,110, 97,109,101, 10,  9,101,
+    110,100, 10,101,110,100, 10, 10, 45, 45, 32,103,101,116, 32,
+    118, 97,114,105, 97, 98,108,101, 32,112,111,105,110,116,101,
+    114, 32,118, 97,108,117,101, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101,
+     58,103,101,116,112,111,105,110,116,101,114,118, 97,108,117,
+    101, 32, 40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99,
+     41, 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100,
+     32,115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, 32,
+    114,101,116,117,114,110, 32, 99,108, 97,115,115, 46, 46, 39,
+     58, 58,112, 39, 10, 32,101,108,115,101,105,102, 32, 99,108,
+     97,115,115, 32,116,104,101,110, 10, 32, 32,114,101,116,117,
+    114,110, 32, 39,115,101,108,102, 45, 62,112, 39, 10, 32,101,
+    108,115,101, 10, 32, 32,114,101,116,117,114,110, 32, 39,112,
+     39, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     87,114,105,116,101, 32, 98,105,110,100,105,110,103, 32,102,
+    117,110, 99,116,105,111,110,115, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,
+    101, 58,115,117,112, 99,111,100,101, 32, 40, 41, 10, 10, 32,
+    108,111, 99, 97,108, 32, 99,108, 97,115,115, 32, 61, 32,115,
+    101,108,102, 58,105,110, 99,108, 97,115,115, 40, 41, 10, 10,
+      9,108,111, 99, 97,108, 32,112,114,111,112, 95,103,101,116,
+     44,112,114,111,112, 95,115,101,116, 10,  9,105,102, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,115,101,108,102,
+     46,109,111,100, 44, 32, 39,116,111,108,117, 97, 95,112,114,
+    111,112,101,114,116,121, 39, 41, 32,116,104,101,110, 10, 10,
+      9,  9, 95, 44, 95, 44,116,121,112,101, 32, 61, 32,115,116,
+    114,105,110,103, 46,102,105,110,100, 40,115,101,108,102, 46,
+    109,111,100, 44, 32, 34,116,111,108,117, 97, 95,112,114,111,
+    112,101,114,116,121, 95, 95, 40, 91, 94, 37,115, 93, 42, 41,
+     34, 41, 10,  9,  9,116,121,112,101, 32, 61, 32,116,121,112,
+    101, 32,111,114, 32, 34,100,101,102, 97,117,108,116, 34, 10,
+      9,  9,112,114,111,112, 95,103,101,116, 44,112,114,111,112,
+     95,115,101,116, 32, 61, 32,103,101,116, 95,112,114,111,112,
+    101,114,116,121, 95,109,101,116,104,111,100,115, 40,116,121,
+    112,101, 44, 32,115,101,108,102, 46,110, 97,109,101, 41, 10,
+      9,  9,115,101,108,102, 46,109,111,100, 32, 61, 32,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40,115,101,108,102, 46,
+    109,111,100, 44, 32, 34,116,111,108,117, 97, 95,112,114,111,
+    112,101,114,116,121, 91, 94, 37,115, 93, 42, 34, 44, 32, 34,
+     34, 41, 10,  9,101,110,100, 10, 10, 32, 45, 45, 32,103,101,
+    116, 32,102,117,110, 99,116,105,111,110, 32, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
+     32,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,
+     32, 32,111,117,116,112,117,116, 40, 34, 47, 42, 32,103,101,
+    116, 32,102,117,110, 99,116,105,111,110, 58, 34, 44,115,101,
+    108,102, 46,110, 97,109,101, 44, 34, 32,111,102, 32, 99,108,
+     97,115,115, 32, 34, 44, 99,108, 97,115,115, 44, 34, 32, 42,
+     47, 34, 41, 10, 32,101,108,115,101, 10, 32, 32,111,117,116,
+    112,117,116, 40, 34, 47, 42, 32,103,101,116, 32,102,117,110,
+     99,116,105,111,110, 58, 34, 44,115,101,108,102, 46,110, 97,
+    109,101, 44, 34, 32, 42, 47, 34, 41, 10, 32,101,110,100, 10,
+     32,115,101,108,102, 46, 99,103,101,116,110, 97,109,101, 32,
+     61, 32,115,101,108,102, 58, 99,102,117,110, 99,110, 97,109,
+    101, 40, 34,116,111,108,117, 97, 95,103,101,116, 34, 41, 10,
+     32,111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101,
+    102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69,
+     95, 34, 46, 46,115,101,108,102, 46, 99,103,101,116,110, 97,
+    109,101, 41, 10, 32,111,117,116,112,117,116, 40, 34, 92,110,
+    115,116, 97,116,105, 99, 32,105,110,116, 34, 44,115,101,108,
+    102, 46, 99,103,101,116,110, 97,109,101, 44, 34, 40,108,117,
+     97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117, 97, 95,
+     83, 41, 34, 41, 10, 32,111,117,116,112,117,116, 40, 34,123,
+     34, 41, 10, 10, 32, 45, 45, 32,100,101, 99,108, 97,114,101,
+     32,115,101,108,102, 44, 32,105,102, 32,116,104,101, 32, 99,
+     97,115,101, 10, 32,108,111, 99, 97,108, 32, 95, 44, 95, 44,
+    115,116, 97,116,105, 99, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115,101,108,102, 46,109,111,100, 44, 39, 94, 37,115,
+     42, 40,115,116, 97,116,105, 99, 41, 39, 41, 10, 32,105,102,
+     32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,116,
+    105, 99, 61, 61,110,105,108, 32,116,104,101,110, 10, 32, 32,
+    111,117,116,112,117,116, 40, 39, 32, 39, 44,115,101,108,102,
+     46,112, 97,114,101,110,116, 46,116,121,112,101, 44, 39, 42,
+     39, 44, 39,115,101,108,102, 32, 61, 32, 39, 41, 10, 32, 32,
+    111,117,116,112,117,116, 40, 39, 40, 39, 44,115,101,108,102,
+     46,112, 97,114,101,110,116, 46,116,121,112,101, 44, 39, 42,
+     41, 32, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39,
+    116,111,108,117, 97, 95,116,111,117,115,101,114,116,121,112,
+    101, 40,116,111,108,117, 97, 95, 83, 44, 49, 44, 48, 41, 59,
+     39, 41, 10, 32,101,108,115,101,105,102, 32,115,116, 97,116,
+    105, 99, 32,116,104,101,110, 10, 32, 32, 95, 44, 95, 44,115,
+    101,108,102, 46,109,111,100, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115,101,108,102, 46,109,111,100, 44, 39, 94, 37,
+    115, 42,115,116, 97,116,105, 99, 37,115, 37,115, 42, 40, 46,
+     42, 41, 39, 41, 10, 32,101,110,100, 10, 10, 10, 32, 45, 45,
+     32, 99,104,101, 99,107, 32,115,101,108,102, 32,118, 97,108,
+    117,101, 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,
+    100, 32,115,116, 97,116,105, 99, 61, 61,110,105,108, 32,116,
+    104,101,110, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,
+    105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69,
+     76, 69, 65, 83, 69, 92,110, 39, 41, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32,105,102, 32, 40, 33,115,101,108,
+    102, 41, 32,116,111,108,117, 97, 95,101,114,114,111,114, 40,
+    116,111,108,117, 97, 95, 83, 44, 34,105,110,118, 97,108,105,
+    100, 32, 92, 39,115,101,108,102, 92, 39, 32,105,110, 32, 97,
+     99, 99,101,115,115,105,110,103, 32,118, 97,114,105, 97, 98,
+    108,101, 32, 92, 39, 39, 46, 46,115,101,108,102, 46,110, 97,
+    109,101, 46, 46, 39, 92, 39, 34, 44, 78, 85, 76, 76, 41, 59,
+     39, 41, 59, 10,  9,  9,111,117,116,112,117,116, 40, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10, 32,101,110,100, 10,
+     10, 32, 45, 45, 32,114,101,116,117,114,110, 32,118, 97,108,
+    117,101, 10, 32,105,102, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,115,101,108,102, 46,109,111,100, 44, 32, 39,
+    116,111,108,117, 97, 95,105,110,104,101,114,105,116,115, 39,
+     41, 32,116,104,101,110, 10, 32,  9,111,117,116,112,117,116,
+     40, 39, 35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,
+    115,112,108,117,115, 92,110, 39, 41, 10,  9,111,117,116,112,
+    117,116, 40, 39, 32, 32,116,111,108,117, 97, 95,112,117,115,
+    104,117,115,101,114,116,121,112,101, 40,116,111,108,117, 97,
+     95, 83, 44, 40,118,111,105,100, 42, 41,115,116, 97,116,105,
+     99, 95, 99, 97,115,116, 60, 39, 46, 46,115,101,108,102, 46,
+    116,121,112,101, 46, 46, 39, 42, 62, 40,115,101,108,102, 41,
+     44, 32, 34, 39, 44,115,101,108,102, 46,116,121,112,101, 44,
+     39, 34, 41, 59, 39, 41, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,101,108,115,101, 92,110, 39, 41, 10,  9,111,117,116,
+    112,117,116, 40, 39, 32, 32,116,111,108,117, 97, 95,112,117,
+    115,104,117,115,101,114,116,121,112,101, 40,116,111,108,117,
+     97, 95, 83, 44, 40,118,111,105,100, 42, 41, 40, 40, 39, 46,
+     46,115,101,108,102, 46,116,121,112,101, 46, 46, 39, 42, 41,
+    115,101,108,102, 41, 44, 32, 34, 39, 44,115,101,108,102, 46,
+    116,121,112,101, 44, 39, 34, 41, 59, 39, 41, 10,  9,111,117,
+    116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39,
+     41, 10, 32,101,108,115,101, 10,  9,108,111, 99, 97,108, 32,
+    116, 44, 99,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,
+    115,101,108,102, 46,116,121,112,101, 41, 10,  9,105,102, 32,
+    116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 32,116,111,108,117, 97, 95,112,117,115,104, 39,
+     46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44,
+     40, 39, 44, 99,116, 44, 39, 41, 39, 46, 46,115,101,108,102,
+     58,103,101,116,118, 97,108,117,101, 40, 99,108, 97,115,115,
+     44,115,116, 97,116,105, 99, 44,112,114,111,112, 95,103,101,
+    116, 41, 46, 46, 39, 41, 59, 39, 41, 10,  9,101,108,115,101,
+     10,  9,  9,116, 32, 61, 32,115,101,108,102, 46,116,121,112,
+    101, 10,  9,  9,105,102, 32,115,101,108,102, 46,112,116,114,
+     32, 61, 61, 32, 39, 38, 39, 32,111,114, 32,115,101,108,102,
+     46,112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110,
+     10,  9,  9,  9,111,117,116,112,117,116, 40, 39, 32, 32,116,
+    111,108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,
+    112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,
+    100, 42, 41, 38, 39, 46, 46,115,101,108,102, 58,103,101,116,
+    118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115,116, 97,
+    116,105, 99, 44,112,114,111,112, 95,103,101,116, 41, 46, 46,
+     39, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10,  9,
+      9,101,108,115,101, 10,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 32,116,111,108,117, 97, 95,112,117,115,104,117,
+    115,101,114,116,121,112,101, 40,116,111,108,117, 97, 95, 83,
+     44, 40,118,111,105,100, 42, 41, 39, 46, 46,115,101,108,102,
+     58,103,101,116,118, 97,108,117,101, 40, 99,108, 97,115,115,
+     44,115,116, 97,116,105, 99, 44,112,114,111,112, 95,103,101,
+    116, 41, 46, 46, 39, 44, 34, 39, 44,116, 44, 39, 34, 41, 59,
+     39, 41, 10,  9,  9,101,110,100, 10,  9,101,110,100, 10, 32,
+    101,110,100, 10, 32,111,117,116,112,117,116, 40, 39, 32,114,
+    101,116,117,114,110, 32, 49, 59, 39, 41, 10, 32,111,117,116,
+    112,117,116, 40, 39,125, 39, 41, 10, 32,111,117,116,112,117,
+    116, 40, 39, 35,101,110,100,105,102, 32, 47, 47, 35,105,102,
+    110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65,
+     66, 76, 69, 92,110, 39, 41, 10, 32,111,117,116,112,117,116,
+     40, 39, 92,110, 39, 41, 10, 10, 32, 45, 45, 32,115,101,116,
+     32,102,117,110, 99,116,105,111,110, 32, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 32,
+    105,102, 32,110,111,116, 32, 40,115,116,114,102,105,110,100,
+     40,115,101,108,102, 46,116,121,112,101, 44, 39, 99,111,110,
+    115,116, 37,115, 43, 39, 41, 32,111,114, 32,115,116,114,105,
+    110,103, 46,102,105,110,100, 40,115,101,108,102, 46,109,111,
+    100, 44, 32, 39,116,111,108,117, 97, 95,114,101, 97,100,111,
+    110,108,121, 39, 41, 32,111,114, 32,115,116,114,105,110,103,
+     46,102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44,
+     32, 39,116,111,108,117, 97, 95,105,110,104,101,114,105,116,
+    115, 39, 41, 41, 32, 32,116,104,101,110, 10, 32, 32,105,102,
+     32, 99,108, 97,115,115, 32,116,104,101,110, 10, 32, 32, 32,
+    111,117,116,112,117,116, 40, 34, 47, 42, 32,115,101,116, 32,
+    102,117,110, 99,116,105,111,110, 58, 34, 44,115,101,108,102,
+     46,110, 97,109,101, 44, 34, 32,111,102, 32, 99,108, 97,115,
+    115, 32, 34, 44, 99,108, 97,115,115, 44, 34, 32, 42, 47, 34,
+     41, 10, 32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,
+    112,117,116, 40, 34, 47, 42, 32,115,101,116, 32,102,117,110,
+     99,116,105,111,110, 58, 34, 44,115,101,108,102, 46,110, 97,
+    109,101, 44, 34, 32, 42, 47, 34, 41, 10, 32, 32,101,110,100,
+     10, 32, 32,115,101,108,102, 46, 99,115,101,116,110, 97,109,
+    101, 32, 61, 32,115,101,108,102, 58, 99,102,117,110, 99,110,
+     97,109,101, 40, 34,116,111,108,117, 97, 95,115,101,116, 34,
+     41, 10, 32, 32,111,117,116,112,117,116, 40, 34, 35,105,102,
+    110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65,
+     66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46, 99,115,101,
+    116,110, 97,109,101, 41, 10, 32, 32,111,117,116,112,117,116,
+     40, 34, 92,110,115,116, 97,116,105, 99, 32,105,110,116, 34,
+     44,115,101,108,102, 46, 99,115,101,116,110, 97,109,101, 44,
+     34, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,
+    108,117, 97, 95, 83, 41, 34, 41, 10, 32, 32,111,117,116,112,
+    117,116, 40, 34,123, 34, 41, 10, 10, 32, 32, 45, 45, 32,100,
+    101, 99,108, 97,114,101, 32,115,101,108,102, 44, 32,105,102,
+     32,116,104,101, 32, 99, 97,115,101, 10, 32, 32,105,102, 32,
+     99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,116,105,
+     99, 61, 61,110,105,108, 32,116,104,101,110, 10, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39, 32, 39, 44,115,101,108,102,
+     46,112, 97,114,101,110,116, 46,116,121,112,101, 44, 39, 42,
+     39, 44, 39,115,101,108,102, 32, 61, 32, 39, 41, 10, 32, 32,
+     32,111,117,116,112,117,116, 40, 39, 40, 39, 44,115,101,108,
+    102, 46,112, 97,114,101,110,116, 46,116,121,112,101, 44, 39,
+     42, 41, 32, 39, 41, 10, 32, 32, 32,111,117,116,112,117,116,
+     40, 39,116,111,108,117, 97, 95,116,111,117,115,101,114,116,
+    121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 49, 44, 48,
+     41, 59, 39, 41, 10, 32, 32, 32, 45, 45, 32, 99,104,101, 99,
+    107, 32,115,101,108,102, 32,118, 97,108,117,101, 10,  9,  9,
+    101,110,100, 10, 32, 32, 45, 45, 32, 99,104,101, 99,107, 32,
+    116,121,112,101,115, 10,  9,  9,111,117,116,112,117,116, 40,
+     39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95,
+     82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 32,116,111,108,117, 97, 95,
+     69,114,114,111,114, 32,116,111,108,117, 97, 95,101,114,114,
+     59, 39, 41, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 32,
+     97,110,100, 32,115,116, 97,116,105, 99, 61, 61,110,105,108,
+     32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 32,105,102, 32, 40, 33,115,101,108,102, 41, 32,
+    116,111,108,117, 97, 95,101,114,114,111,114, 40,116,111,108,
+    117, 97, 95, 83, 44, 34,105,110,118, 97,108,105,100, 32, 92,
+     39,115,101,108,102, 92, 39, 32,105,110, 32, 97, 99, 99,101,
+    115,115,105,110,103, 32,118, 97,114,105, 97, 98,108,101, 32,
+     92, 39, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 46,
+     46, 39, 92, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, 59,
+     10, 32, 32,101,108,115,101,105,102, 32,115,116, 97,116,105,
+     99, 32,116,104,101,110, 10, 32, 32, 32, 95, 44, 95, 44,115,
+    101,108,102, 46,109,111,100, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115,101,108,102, 46,109,111,100, 44, 39, 94, 37,
+    115, 42,115,116, 97,116,105, 99, 37,115, 37,115, 42, 40, 46,
+     42, 41, 39, 41, 10, 32, 32,101,110,100, 10, 10, 32, 32, 45,
+     45, 32, 99,104,101, 99,107, 32,118, 97,114,105, 97, 98,108,
+    101, 32,116,121,112,101, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 32,105,102, 32, 40, 33, 39, 46, 46,115,101,108,
+    102, 58,111,117,116, 99,104,101, 99,107,116,121,112,101, 40,
+     50, 41, 46, 46, 39, 41, 39, 41, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32, 32,116,111,108,117, 97, 95,101,114,
+    114,111,114, 40,116,111,108,117, 97, 95, 83, 44, 34, 35,118,
+    105,110,118, 97,108,105,100, 32,116,121,112,101, 32,105,110,
+     32,118, 97,114,105, 97, 98,108,101, 32, 97,115,115,105,103,
+    110,109,101,110,116, 46, 34, 44, 38,116,111,108,117, 97, 95,
+    101,114,114, 41, 59, 39, 41, 10,  9,  9,111,117,116,112,117,
+    116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 10,
+     32, 32, 45, 45, 32, 97,115,115,105,103,110, 32,118, 97,108,
+    117,101, 10,  9,  9,108,111, 99, 97,108, 32,100,101,102, 32,
+     61, 32, 48, 10,  9,  9,105,102, 32,115,101,108,102, 46,100,
+    101,102, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 32,100,
+    101,102, 32, 61, 32,115,101,108,102, 46,100,101,102, 32,101,
+    110,100, 10,  9,  9,105,102, 32,115,101,108,102, 46,116,121,
+    112,101, 32, 61, 61, 32, 39, 99,104, 97,114, 42, 39, 32, 97,
+    110,100, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 32, 45, 45, 32,105,115, 32,115,
+    116,114,105,110,103, 10,  9,  9, 32,111,117,116,112,117,116,
+     40, 39, 32,115,116,114,110, 99,112,121, 40, 39, 41, 10,  9,
+      9,  9,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,
+    115,116, 97,116,105, 99, 32,116,104,101,110, 10,  9,  9,  9,
+      9,111,117,116,112,117,116, 40,115,101,108,102, 46,112, 97,
+    114,101,110,116, 46,116,121,112,101, 46, 46, 39, 58, 58, 39,
+     46, 46,115,101,108,102, 46,110, 97,109,101, 41, 10,  9,  9,
+      9,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32,116,
+    104,101,110, 10,  9,  9,  9,  9,111,117,116,112,117,116, 40,
+     39,115,101,108,102, 45, 62, 39, 46, 46,115,101,108,102, 46,
+    110, 97,109,101, 41, 10,  9,  9,  9,101,108,115,101, 10,  9,
+      9,  9,  9,111,117,116,112,117,116, 40,115,101,108,102, 46,
+    110, 97,109,101, 41, 10,  9,  9,  9,101,110,100, 10,  9,  9,
+      9,111,117,116,112,117,116, 40, 39, 44,116,111,108,117, 97,
+     95,116,111,115,116,114,105,110,103, 40,116,111,108,117, 97,
+     95, 83, 44, 50, 44, 39, 44,100,101,102, 44, 39, 41, 44, 39,
+     44,115,101,108,102, 46,100,105,109, 44, 39, 45, 49, 41, 59,
+     39, 41, 10,  9,  9,101,108,115,101, 10,  9,  9,  9,108,111,
+     99, 97,108, 32,112,116,114, 32, 61, 32, 39, 39, 10,  9,  9,
+      9,105,102, 32,115,101,108,102, 46,112,116,114,126, 61, 39,
+     39, 32,116,104,101,110, 32,112,116,114, 32, 61, 32, 39, 42,
+     39, 32,101,110,100, 10,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 39, 41, 10,  9,  9,  9,108,111, 99, 97,108, 32,
+    110, 97,109,101, 32, 61, 32,112,114,111,112, 95,115,101,116,
+     32,111,114, 32,115,101,108,102, 46,110, 97,109,101, 10,  9,
+      9,  9,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,
+    115,116, 97,116,105, 99, 32,116,104,101,110, 10,  9,  9,  9,
+      9,111,117,116,112,117,116, 40,115,101,108,102, 46,112, 97,
+    114,101,110,116, 46,116,121,112,101, 46, 46, 39, 58, 58, 39,
+     46, 46,110, 97,109,101, 41, 10,  9,  9,  9,101,108,115,101,
+    105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,  9,
+      9,  9,  9,111,117,116,112,117,116, 40, 39,115,101,108,102,
+     45, 62, 39, 46, 46,110, 97,109,101, 41, 10,  9,  9,  9,101,
+    108,115,101, 10,  9,  9,  9,  9,111,117,116,112,117,116, 40,
+    110, 97,109,101, 41, 10,  9,  9,  9,101,110,100, 10,  9,  9,
+      9,108,111, 99, 97,108, 32,116, 32, 61, 32,105,115, 98, 97,
+    115,105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 10,
+      9,  9,  9,105,102, 32,112,114,111,112, 95,115,101,116, 32,
+    116,104,101,110, 10,  9,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 40, 39, 41, 10,  9,  9,  9,101,108,115,101, 10,  9,
+      9,  9,  9,111,117,116,112,117,116, 40, 39, 32, 61, 32, 39,
+     41, 10,  9,  9,  9,101,110,100, 10,  9,  9,  9,105,102, 32,
+    110,111,116, 32,116, 32, 97,110,100, 32,112,116,114, 61, 61,
+     39, 39, 32,116,104,101,110, 32,111,117,116,112,117,116, 40,
+     39, 42, 39, 41, 32,101,110,100, 10,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39, 40, 40, 39, 44,115,101,108,102, 46,109,
+    111,100, 44,115,101,108,102, 46,116,121,112,101, 41, 10,  9,
+      9,  9,105,102, 32,110,111,116, 32,116, 32,116,104,101,110,
+     10,  9,  9,  9,  9,111,117,116,112,117,116, 40, 39, 42, 39,
+     41, 10,  9,  9,  9,101,110,100, 10,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39, 41, 32, 39, 41, 10,  9,  9,  9,105,102,
+     32,116, 32,116,104,101,110, 10,  9,  9,  9,  9,105,102, 32,
+    105,115,101,110,117,109, 40,115,101,108,102, 46,116,121,112,
+    101, 41, 32,116,104,101,110, 10,  9,  9,  9,  9,  9,111,117,
+    116,112,117,116, 40, 39, 40,105,110,116, 41, 32, 39, 41, 10,
+      9,  9,  9,  9,101,110,100, 10,  9,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39,116,111,108,117, 97, 95,116,111, 39, 46,
+     46,116, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, 50, 44,
+     39, 44,100,101,102, 44, 39, 41, 41, 39, 41, 10,  9,  9,  9,
+    101,108,115,101, 10,  9,  9,  9,  9,111,117,116,112,117,116,
+     40, 39,116,111,108,117, 97, 95,116,111,117,115,101,114,116,
+    121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 39,
+     44,100,101,102, 44, 39, 41, 41, 39, 41, 10,  9,  9,  9,101,
+    110,100, 10,  9,  9,  9,105,102, 32,112,114,111,112, 95,115,
+    101,116, 32,116,104,101,110, 10,  9,  9,  9,  9,111,117,116,
+    112,117,116, 40, 34, 41, 34, 41, 10,  9,  9,  9,101,110,100,
+     10,  9,  9,  9,111,117,116,112,117,116, 40, 34, 59, 34, 41,
+     10,  9,  9,101,110,100, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32,114,101,116,117,114,110, 32, 48, 59, 39, 41, 10,
+     32, 32,111,117,116,112,117,116, 40, 39,125, 39, 41, 10, 32,
+     32,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,102,
+     32, 47, 47, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85,
+     65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10, 32,
+     32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10, 32,
+    101,110,100, 10, 10,101,110,100, 10, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,
+    108,101, 58,114,101,103,105,115,116,101,114, 32, 40,112,114,
+    101, 41, 10, 10,  9,105,102, 32,110,111,116, 32,115,101,108,
+    102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, 95,
+     97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10,  9,
+      9,114,101,116,117,114,110, 10,  9,101,110,100, 10, 32,112,
+    114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, 39, 10,
+     32,108,111, 99, 97,108, 32,112, 97,114,101,110,116, 32, 61,
+     32,115,101,108,102, 58,105,110,109,111,100,117,108,101, 40,
+     41, 32,111,114, 32,115,101,108,102, 58,105,110,110, 97,109,
+    101,115,112, 97, 99,101, 40, 41, 32,111,114, 32,115,101,108,
+    102, 58,105,110, 99,108, 97,115,115, 40, 41, 10, 32,105,102,
+     32,110,111,116, 32,112, 97,114,101,110,116, 32,116,104,101,
+    110, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 86, 97,114,
+    105, 97, 98,108,101, 46, 95,119, 97,114,110,105,110,103, 61,
+     61,110,105,108, 32,116,104,101,110, 10, 32, 32, 32,119, 97,
+    114,110,105,110,103, 40, 34, 77, 97,112,112,105,110,103, 32,
+    118, 97,114,105, 97, 98,108,101, 32,116,111, 32,103,108,111,
+     98, 97,108, 32,109, 97,121, 32,100,101,103,114, 97,100,101,
+     32,112,101,114,102,111,114,109, 97,110, 99,101, 34, 41, 10,
+     32, 32, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,
+    101, 46, 95,119, 97,114,110,105,110,103, 32, 61, 32, 49, 10,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 32,105,102, 32,
+    115,101,108,102, 46, 99,115,101,116,110, 97,109,101, 32,116,
+    104,101,110, 10, 32, 32,111,117,116,112,117,116, 40,112,114,
+    101, 46, 46, 39,116,111,108,117, 97, 95,118, 97,114,105, 97,
+     98,108,101, 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46,
+     46,115,101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 34,
+     44, 39, 46, 46,115,101,108,102, 46, 99,103,101,116,110, 97,
+    109,101, 46, 46, 39, 44, 39, 46, 46,115,101,108,102, 46, 99,
+    115,101,116,110, 97,109,101, 46, 46, 39, 41, 59, 39, 41, 10,
+     32,101,108,115,101, 10, 32, 32,111,117,116,112,117,116, 40,
+    112,114,101, 46, 46, 39,116,111,108,117, 97, 95,118, 97,114,
+    105, 97, 98,108,101, 40,116,111,108,117, 97, 95, 83, 44, 34,
+     39, 46, 46,115,101,108,102, 46,108,110, 97,109,101, 46, 46,
+     39, 34, 44, 39, 46, 46,115,101,108,102, 46, 99,103,101,116,
+    110, 97,109,101, 46, 46, 39, 44, 78, 85, 76, 76, 41, 59, 39,
+     41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114,
+    117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32,
+     95, 86, 97,114,105, 97, 98,108,101, 32, 40,116, 41, 10, 32,
+    115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44,
+     99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 41, 10,
+     32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,
+    117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,
+    111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,
+    120,112,101, 99,116,115, 32, 97, 32,115,116,114,105,110,103,
+     32,114,101,112,114,101,115,101,110,116,105,110,103, 32,116,
+    104,101, 32,118, 97,114,105, 97, 98,108,101, 32,100,101, 99,
+    108, 97,114, 97,116,105,111,110, 46, 10,102,117,110, 99,116,
+    105,111,110, 32, 86, 97,114,105, 97, 98,108,101, 32, 40,115,
+     41, 10, 32,114,101,116,117,114,110, 32, 95, 86, 97,114,105,
+     97, 98,108,101, 32, 40, 68,101, 99,108, 97,114, 97,116,105,
+    111,110, 40,115, 44, 39,118, 97,114, 39, 41, 41, 10,101,110,
+    100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/variable.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 97,114,114, 97,121,
+     32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,
+    101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32,
+     67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,
+    102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,
+    108, 32, 49, 57, 57, 57, 10, 45, 45, 32, 36, 73,100, 58, 32,
+     97,114,114, 97,121, 46,108,117, 97, 44,118, 32, 49, 46, 49,
+     32, 50, 48, 48, 48, 47, 49, 49, 47, 48, 54, 32, 50, 50, 58,
+     48, 51, 58, 53, 55, 32, 99,101,108,101,115, 32, 69,120,112,
+     32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,
+    101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,119,
+     97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,
+    100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,
+    110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116,
+     46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,
+    114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,114,
+    101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110,
+     32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44,
+     32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,
+    104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,
+    103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,105,
+    100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44,
+     32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116,
+    101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,
+    101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105,
+     99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, 32, 65,
+    114,114, 97,121, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,
+    101,112,114,101,115,101,110,116,115, 32, 97, 32,101,120,116,
+    101,114,110, 32, 97,114,114, 97,121, 32,118, 97,114,105, 97,
+     98,108,101, 32,111,114, 32, 97, 32,112,117, 98,108,105, 99,
+     32,109,101,109, 98,101,114, 32,111,102, 32, 97, 32, 99,108,
+     97,115,115, 46, 10, 45, 45, 32, 83,116,111,114,101,115, 32,
+     97,108,108, 32,102,105,101,108,100,115, 32,112,114,101,115,
+    101,110,116, 32,105,110, 32, 97, 32,100,101, 99,108, 97,114,
+     97,116,105,111,110, 46, 10, 99,108, 97,115,115, 65,114,114,
+     97,121, 32, 61, 32,123, 10,125, 10, 99,108, 97,115,115, 65,
+    114,114, 97,121, 46, 95, 95,105,110,100,101,120, 32, 61, 32,
+     99,108, 97,115,115, 65,114,114, 97,121, 10,115,101,116,109,
+    101,116, 97,116, 97, 98,108,101, 40, 99,108, 97,115,115, 65,
+    114,114, 97,121, 44, 99,108, 97,115,115, 68,101, 99,108, 97,
+    114, 97,116,105,111,110, 41, 10, 10, 45, 45, 32, 80,114,105,
+    110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 65,114,114, 97,121, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 65,114,114, 97,121,123, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,116,121,
+    112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,116,
+    121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 32,112,116,114,
+     32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,112,116,
+    114, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,100,101,102, 32, 32, 61,
+     32, 39, 34, 46, 46,115,101,108,102, 46,100,101,102, 46, 46,
+     34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 32,100,105,109, 32, 32, 61, 32, 39,
+     34, 46, 46,115,101,108,102, 46,100,105,109, 46, 46, 34, 39,
+     44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,114,101,116, 32, 32, 61, 32, 39, 34, 46,
+     46,115,101,108,102, 46,114,101,116, 46, 46, 34, 39, 44, 34,
+     41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,
+    100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    105,116, 32,105,115, 32, 97, 32,118, 97,114,105, 97, 98,108,
+    101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 65,114,114, 97,121, 58,105,115,118, 97,114,105, 97, 98,
+    108,101, 32, 40, 41, 10, 32,114,101,116,117,114,110, 32,116,
+    114,117,101, 10,101,110,100, 10, 10, 10, 45, 45, 32,103,101,
+    116, 32,118, 97,114,105, 97, 98,108,101, 32,118, 97,108,117,
+    101, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 65,114,114, 97,121, 58,103,101,116,118, 97,108,117,101,
+     32, 40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99, 41,
+     10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,
+    115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, 32,114,
+    101,116,117,114,110, 32, 99,108, 97,115,115, 46, 46, 39, 58,
+     58, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 46, 46,
+     39, 91,116,111,108,117, 97, 95,105,110,100,101,120, 93, 39,
+     10, 32,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32,
+    116,104,101,110, 10, 32, 32,114,101,116,117,114,110, 32, 39,
+    115,101,108,102, 45, 62, 39, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 39, 91,116,111,108,117, 97, 95,105,110,
+    100,101,120, 93, 39, 10, 32,101,108,115,101, 10, 32, 32,114,
+    101,116,117,114,110, 32,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 39, 91,116,111,108,117, 97, 95,105,110,100,101,120,
+     93, 39, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
+     32, 87,114,105,116,101, 32, 98,105,110,100,105,110,103, 32,
+    102,117,110, 99,116,105,111,110,115, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 65,114,114, 97,121, 58,
+    115,117,112, 99,111,100,101, 32, 40, 41, 10, 32,108,111, 99,
+     97,108, 32, 99,108, 97,115,115, 32, 61, 32,115,101,108,102,
+     58,105,110, 99,108, 97,115,115, 40, 41, 10, 10, 32, 45, 45,
+     32,103,101,116, 32,102,117,110, 99,116,105,111,110, 32, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 10, 32,105,102, 32, 99,108, 97,115,115, 32,116,104,
+    101,110, 10, 32, 32,111,117,116,112,117,116, 40, 34, 47, 42,
+     32,103,101,116, 32,102,117,110, 99,116,105,111,110, 58, 34,
+     44,115,101,108,102, 46,110, 97,109,101, 44, 34, 32,111,102,
+     32, 99,108, 97,115,115, 32, 34, 44, 99,108, 97,115,115, 44,
+     34, 32, 42, 47, 34, 41, 10, 32,101,108,115,101, 10, 32, 32,
+    111,117,116,112,117,116, 40, 34, 47, 42, 32,103,101,116, 32,
+    102,117,110, 99,116,105,111,110, 58, 34, 44,115,101,108,102,
+     46,110, 97,109,101, 44, 34, 32, 42, 47, 34, 41, 10, 32,101,
+    110,100, 10, 32,115,101,108,102, 46, 99,103,101,116,110, 97,
+    109,101, 32, 61, 32,115,101,108,102, 58, 99,102,117,110, 99,
+    110, 97,109,101, 40, 34,116,111,108,117, 97, 95,103,101,116,
+     34, 41, 10, 32,111,117,116,112,117,116, 40, 34, 35,105,102,
+    110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65,
+     66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46, 99,103,101,
+    116,110, 97,109,101, 41, 10, 32,111,117,116,112,117,116, 40,
+     34, 92,110,115,116, 97,116,105, 99, 32,105,110,116, 34, 44,
+    115,101,108,102, 46, 99,103,101,116,110, 97,109,101, 44, 34,
+     40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,108,
+    117, 97, 95, 83, 41, 34, 41, 10, 32,111,117,116,112,117,116,
+     40, 34,123, 34, 41, 10, 32,111,117,116,112,117,116, 40, 34,
+     32,105,110,116, 32,116,111,108,117, 97, 95,105,110,100,101,
+    120, 59, 34, 41, 10, 10, 32, 45, 45, 32,100,101, 99,108, 97,
+    114,101, 32,115,101,108,102, 44, 32,105,102, 32,116,104,101,
+     32, 99, 97,115,101, 10, 32,108,111, 99, 97,108, 32, 95, 44,
+     95, 44,115,116, 97,116,105, 99, 32, 61, 32,115,116,114,102,
+    105,110,100, 40,115,101,108,102, 46,109,111,100, 44, 39, 94,
+     37,115, 42, 40,115,116, 97,116,105, 99, 41, 39, 41, 10, 32,
+    105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116,
+     97,116,105, 99, 61, 61,110,105,108, 32,116,104,101,110, 10,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 39, 44,115,101,
+    108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101, 44,
+     39, 42, 39, 44, 39,115,101,108,102, 59, 39, 41, 10, 32, 32,
+    111,117,116,112,117,116, 40, 39, 32,108,117, 97, 95,112,117,
+    115,104,115,116,114,105,110,103, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 46,115,101,108,102, 34, 41, 59, 39, 41, 10, 32,
+     32,111,117,116,112,117,116, 40, 39, 32,108,117, 97, 95,114,
+     97,119,103,101,116, 40,116,111,108,117, 97, 95, 83, 44, 49,
+     41, 59, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39,
+     32,115,101,108,102, 32, 61, 32, 39, 41, 10, 32, 32,111,117,
+    116,112,117,116, 40, 39, 40, 39, 44,115,101,108,102, 46,112,
+     97,114,101,110,116, 46,116,121,112,101, 44, 39, 42, 41, 32,
+     39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39,108,117,
+     97, 95,116,111,117,115,101,114,100, 97,116, 97, 40,116,111,
+    108,117, 97, 95, 83, 44, 45, 49, 41, 59, 39, 41, 10, 32,101,
+    108,115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104,
+    101,110, 10, 32, 32, 95, 44, 95, 44,115,101,108,102, 46,109,
+    111,100, 32, 61, 32,115,116,114,102,105,110,100, 40,115,101,
+    108,102, 46,109,111,100, 44, 39, 94, 37,115, 42,115,116, 97,
+    116,105, 99, 37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32, 99,104,101, 99,107,
+     32,105,110,100,101,120, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95,
+     82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,  9,111,117,
+    116,112,117,116, 40, 39, 32,123, 39, 41, 10,  9,111,117,116,
+    112,117,116, 40, 39, 32, 32,116,111,108,117, 97, 95, 69,114,
+    114,111,114, 32,116,111,108,117, 97, 95,101,114,114, 59, 39,
+     41, 10, 32,111,117,116,112,117,116, 40, 39, 32, 32,105,102,
+     32, 40, 33,116,111,108,117, 97, 95,105,115,110,117,109, 98,
+    101,114, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 44,
+     38,116,111,108,117, 97, 95,101,114,114, 41, 41, 39, 41, 10,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111,108,
+    117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 35,118,105,110,118, 97,108,105,100, 32,116,121,
+    112,101, 32,105,110, 32, 97,114,114, 97,121, 32,105,110,100,
+    101,120,105,110,103, 46, 34, 44, 38,116,111,108,117, 97, 95,
+    101,114,114, 41, 59, 39, 41, 10,  9,111,117,116,112,117,116,
+     40, 39, 32,125, 39, 41, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10,  9,105,102,
+     32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,104,101,
+    110, 32, 45, 45, 32,102,111,114, 32, 99,111,109,112, 97,116,
+    105, 98,105,108,105,116,121, 32,119,105,116,104, 32,116,111,
+    108,117, 97, 53, 32, 63, 10,  9,  9,111,117,116,112,117,116,
+     40, 39, 32,116,111,108,117, 97, 95,105,110,100,101,120, 32,
+     61, 32, 40,105,110,116, 41,116,111,108,117, 97, 95,116,111,
+    110,117,109, 98,101,114, 40,116,111,108,117, 97, 95, 83, 44,
+     50, 44, 48, 41, 45, 49, 59, 39, 41, 10,  9,101,108,115,101,
+     10,  9,  9,111,117,116,112,117,116, 40, 39, 32,116,111,108,
+    117, 97, 95,105,110,100,101,120, 32, 61, 32, 40,105,110,116,
+     41,116,111,108,117, 97, 95,116,111,110,117,109, 98,101,114,
+     40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 41, 59, 39,
+     41, 10,  9,101,110,100, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95,
+     82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,  9,105,102,
+     32,115,101,108,102, 46,100,105,109, 32, 97,110,100, 32,115,
+    101,108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32,116,
+    104,101,110, 10,  9, 32, 32,111,117,116,112,117,116, 40, 39,
+     32,105,102, 32, 40,116,111,108,117, 97, 95,105,110,100,101,
+    120, 60, 48, 32,124,124, 32,116,111,108,117, 97, 95,105,110,
+    100,101,120, 62, 61, 39, 46, 46,115,101,108,102, 46,100,105,
+    109, 46, 46, 39, 41, 39, 41, 10,  9,101,108,115,101, 10,  9,
+     32, 32,111,117,116,112,117,116, 40, 39, 32,105,102, 32, 40,
+    116,111,108,117, 97, 95,105,110,100,101,120, 60, 48, 41, 39,
+     41, 10,  9,101,110,100, 10, 32,111,117,116,112,117,116, 40,
+     39, 32, 32,116,111,108,117, 97, 95,101,114,114,111,114, 40,
+    116,111,108,117, 97, 95, 83, 44, 34, 97,114,114, 97,121, 32,
+    105,110,100,101,120,105,110,103, 32,111,117,116, 32,111,102,
+     32,114, 97,110,103,101, 46, 34, 44, 78, 85, 76, 76, 41, 59,
+     39, 41, 10,  9,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10, 10, 32, 45, 45, 32,114,101,
+    116,117,114,110, 32,118, 97,108,117,101, 10, 32,108,111, 99,
+     97,108, 32,116, 44, 99,116, 32, 61, 32,105,115, 98, 97,115,
+    105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 10, 32,
+    105,102, 32,116, 32,116,104,101,110, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,
+    104, 39, 46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95,
+     83, 44, 40, 39, 44, 99,116, 44, 39, 41, 39, 46, 46,115,101,
+    108,102, 58,103,101,116,118, 97,108,117,101, 40, 99,108, 97,
+    115,115, 44,115,116, 97,116,105, 99, 41, 46, 46, 39, 41, 59,
+     39, 41, 10, 32,101,108,115,101, 10,  9,  9,116, 32, 61, 32,
+    115,101,108,102, 46,116,121,112,101, 10, 32, 32,105,102, 32,
+    115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 38, 39,
+     32,111,114, 32,115,101,108,102, 46,112,116,114, 32, 61, 61,
+     32, 39, 39, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,
+    104,117,115,101,114,116,121,112,101, 40,116,111,108,117, 97,
+     95, 83, 44, 40,118,111,105,100, 42, 41, 38, 39, 46, 46,115,
+    101,108,102, 58,103,101,116,118, 97,108,117,101, 40, 99,108,
+     97,115,115, 44,115,116, 97,116,105, 99, 41, 46, 46, 39, 44,
+     34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, 32, 32,101,
+    108,115,101, 10, 32, 32, 32,111,117,116,112,117,116, 40, 39,
+     32,116,111,108,117, 97, 95,112,117,115,104,117,115,101,114,
+    116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,118,
+    111,105,100, 42, 41, 39, 46, 46,115,101,108,102, 58,103,101,
+    116,118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115,116,
+     97,116,105, 99, 41, 46, 46, 39, 44, 34, 39, 44,116, 44, 39,
+     34, 41, 59, 39, 41, 10, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 32,111,117,116,112,117,116, 40, 39, 32,114,101,116,
+    117,114,110, 32, 49, 59, 39, 41, 10, 32,111,117,116,112,117,
+    116, 40, 39,125, 39, 41, 10, 32,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 32, 47, 47, 35,105,102,110,100,
+    101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76,
+     69, 92,110, 39, 41, 10, 32,111,117,116,112,117,116, 40, 39,
+     92,110, 39, 41, 10, 10, 32, 45, 45, 32,115,101,116, 32,102,
+    117,110, 99,116,105,111,110, 32, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 32,105,102,
+     32,110,111,116, 32,115,116,114,102,105,110,100, 40,115,101,
+    108,102, 46,116,121,112,101, 44, 39, 99,111,110,115,116, 39,
+     41, 32,116,104,101,110, 10, 32, 32,105,102, 32, 99,108, 97,
+    115,115, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,
+    117,116, 40, 34, 47, 42, 32,115,101,116, 32,102,117,110, 99,
+    116,105,111,110, 58, 34, 44,115,101,108,102, 46,110, 97,109,
+    101, 44, 34, 32,111,102, 32, 99,108, 97,115,115, 32, 34, 44,
+     99,108, 97,115,115, 44, 34, 32, 42, 47, 34, 41, 10, 32, 32,
+    101,108,115,101, 10, 32, 32, 32,111,117,116,112,117,116, 40,
+     34, 47, 42, 32,115,101,116, 32,102,117,110, 99,116,105,111,
+    110, 58, 34, 44,115,101,108,102, 46,110, 97,109,101, 44, 34,
+     32, 42, 47, 34, 41, 10, 32, 32,101,110,100, 10, 32, 32,115,
+    101,108,102, 46, 99,115,101,116,110, 97,109,101, 32, 61, 32,
+    115,101,108,102, 58, 99,102,117,110, 99,110, 97,109,101, 40,
+     34,116,111,108,117, 97, 95,115,101,116, 34, 41, 10, 32, 32,
+    111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101,102,
+     32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95,
+     34, 46, 46,115,101,108,102, 46, 99,115,101,116,110, 97,109,
+    101, 41, 10, 32, 32,111,117,116,112,117,116, 40, 34, 92,110,
+    115,116, 97,116,105, 99, 32,105,110,116, 34, 44,115,101,108,
+    102, 46, 99,115,101,116,110, 97,109,101, 44, 34, 40,108,117,
+     97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117, 97, 95,
+     83, 41, 34, 41, 10, 32, 32,111,117,116,112,117,116, 40, 34,
+    123, 34, 41, 10, 10, 32, 32, 45, 45, 32,100,101, 99,108, 97,
+    114,101, 32,105,110,100,101,120, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32,105,110,116, 32,116,111,108,117, 97, 95,
+    105,110,100,101,120, 59, 39, 41, 10, 10, 32, 32, 45, 45, 32,
+    100,101, 99,108, 97,114,101, 32,115,101,108,102, 44, 32,105,
+    102, 32,116,104,101, 32, 99, 97,115,101, 10, 32, 32,108,111,
+     99, 97,108, 32, 95, 44, 95, 44,115,116, 97,116,105, 99, 32,
+     61, 32,115,116,114,102,105,110,100, 40,115,101,108,102, 46,
+    109,111,100, 44, 39, 94, 37,115, 42, 40,115,116, 97,116,105,
+     99, 41, 39, 41, 10, 32, 32,105,102, 32, 99,108, 97,115,115,
+     32, 97,110,100, 32,115,116, 97,116,105, 99, 61, 61,110,105,
+    108, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32, 39, 44,115,101,108,102, 46,112, 97,114,101,
+    110,116, 46,116,121,112,101, 44, 39, 42, 39, 44, 39,115,101,
+    108,102, 59, 39, 41, 10, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 32,108,117, 97, 95,112,117,115,104,115,116,114,105,
+    110,103, 40,116,111,108,117, 97, 95, 83, 44, 34, 46,115,101,
+    108,102, 34, 41, 59, 39, 41, 10, 32, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32,108,117, 97, 95,114, 97,119,103,101,116,
+     40,116,111,108,117, 97, 95, 83, 44, 49, 41, 59, 39, 41, 10,
+     32, 32, 32,111,117,116,112,117,116, 40, 39, 32,115,101,108,
+    102, 32, 61, 32, 39, 41, 10, 32, 32, 32,111,117,116,112,117,
+    116, 40, 39, 40, 39, 44,115,101,108,102, 46,112, 97,114,101,
+    110,116, 46,116,121,112,101, 44, 39, 42, 41, 32, 39, 41, 10,
+     32, 32, 32,111,117,116,112,117,116, 40, 39,108,117, 97, 95,
+    116,111,117,115,101,114,100, 97,116, 97, 40,116,111,108,117,
+     97, 95, 83, 44, 45, 49, 41, 59, 39, 41, 10, 32, 32,101,108,
+    115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104,101,
+    110, 10, 32, 32, 32, 95, 44, 95, 44,115,101,108,102, 46,109,
+    111,100, 32, 61, 32,115,116,114,102,105,110,100, 40,115,101,
+    108,102, 46,109,111,100, 44, 39, 94, 37,115, 42,115,116, 97,
+    116,105, 99, 37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10,
+     32, 32,101,110,100, 10, 10, 32, 32, 45, 45, 32, 99,104,101,
+     99,107, 32,105,110,100,101,120, 10,  9, 32,111,117,116,112,
+    117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76,
+     85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,
+      9, 32,111,117,116,112,117,116, 40, 39, 32,123, 39, 41, 10,
+      9, 32,111,117,116,112,117,116, 40, 39, 32, 32,116,111,108,
+    117, 97, 95, 69,114,114,111,114, 32,116,111,108,117, 97, 95,
+    101,114,114, 59, 39, 41, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 32,105,102, 32, 40, 33,116,111,108,117, 97, 95,
+    105,115,110,117,109, 98,101,114, 40,116,111,108,117, 97, 95,
+     83, 44, 50, 44, 48, 44, 38,116,111,108,117, 97, 95,101,114,
+    114, 41, 41, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40,
+     39, 32, 32, 32,116,111,108,117, 97, 95,101,114,114,111,114,
+     40,116,111,108,117, 97, 95, 83, 44, 34, 35,118,105,110,118,
+     97,108,105,100, 32,116,121,112,101, 32,105,110, 32, 97,114,
+    114, 97,121, 32,105,110,100,101,120,105,110,103, 46, 34, 44,
+     38,116,111,108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10,
+      9,  9,111,117,116,112,117,116, 40, 39, 32,125, 39, 41, 10,
+      9,  9,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,
+    102, 92,110, 39, 41, 10, 10,  9,105,102, 32,102,108, 97,103,
+    115, 91, 39, 49, 39, 93, 32,116,104,101,110, 32, 45, 45, 32,
+    102,111,114, 32, 99,111,109,112, 97,116,105, 98,105,108,105,
+    116,121, 32,119,105,116,104, 32,116,111,108,117, 97, 53, 32,
+     63, 10,  9,  9,111,117,116,112,117,116, 40, 39, 32,116,111,
+    108,117, 97, 95,105,110,100,101,120, 32, 61, 32, 40,105,110,
+    116, 41,116,111,108,117, 97, 95,116,111,110,117,109, 98,101,
+    114, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 41, 45,
+     49, 59, 39, 41, 10,  9,101,108,115,101, 10,  9,  9,111,117,
+    116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,105,110,
+    100,101,120, 32, 61, 32, 40,105,110,116, 41,116,111,108,117,
+     97, 95,116,111,110,117,109, 98,101,114, 40,116,111,108,117,
+     97, 95, 83, 44, 50, 44, 48, 41, 59, 39, 41, 10,  9,101,110,
+    100, 10, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,105,
+    102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76,
+     69, 65, 83, 69, 92,110, 39, 41, 10,  9,105,102, 32,115,101,
+    108,102, 46,100,105,109, 32, 97,110,100, 32,115,101,108,102,
+     46,100,105,109, 32,126, 61, 32, 39, 39, 32,116,104,101,110,
+     10,  9, 32, 32,111,117,116,112,117,116, 40, 39, 32,105,102,
+     32, 40,116,111,108,117, 97, 95,105,110,100,101,120, 60, 48,
+     32,124,124, 32,116,111,108,117, 97, 95,105,110,100,101,120,
+     62, 61, 39, 46, 46,115,101,108,102, 46,100,105,109, 46, 46,
+     39, 41, 39, 41, 10,  9,101,108,115,101, 10,  9, 32, 32,111,
+    117,116,112,117,116, 40, 39, 32,105,102, 32, 40,116,111,108,
+    117, 97, 95,105,110,100,101,120, 60, 48, 41, 39, 41, 10,  9,
+    101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32,
+     32,116,111,108,117, 97, 95,101,114,114,111,114, 40,116,111,
+    108,117, 97, 95, 83, 44, 34, 97,114,114, 97,121, 32,105,110,
+    100,101,120,105,110,103, 32,111,117,116, 32,111,102, 32,114,
+     97,110,103,101, 46, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41,
+     10,  9,  9,111,117,116,112,117,116, 40, 39, 35,101,110,100,
+    105,102, 92,110, 39, 41, 10, 10, 32, 32, 45, 45, 32, 97,115,
+    115,105,103,110, 32,118, 97,108,117,101, 10, 32, 32,108,111,
+     99, 97,108, 32,112,116,114, 32, 61, 32, 39, 39, 10, 32, 32,
+    105,102, 32,115,101,108,102, 46,112,116,114,126, 61, 39, 39,
+     32,116,104,101,110, 32,112,116,114, 32, 61, 32, 39, 42, 39,
+     32,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 39, 41, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 32,
+     97,110,100, 32,115,116, 97,116,105, 99, 32,116,104,101,110,
+     10, 32, 32, 32,111,117,116,112,117,116, 40, 99,108, 97,115,
+    115, 46, 46, 39, 58, 58, 39, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 39, 91,116,111,108,117, 97, 95,105,110,
+    100,101,120, 93, 39, 41, 10, 32, 32,101,108,115,101,105,102,
+     32, 99,108, 97,115,115, 32,116,104,101,110, 10, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39,115,101,108,102, 45, 62, 39,
+     46, 46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 91,
+    116,111,108,117, 97, 95,105,110,100,101,120, 93, 39, 41, 10,
+     32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,112,117,
+    116, 40,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 91,
+    116,111,108,117, 97, 95,105,110,100,101,120, 93, 39, 41, 10,
+     32, 32,101,110,100, 10, 32, 32,108,111, 99, 97,108, 32,116,
+     32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,102,
+     46,116,121,112,101, 41, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 61, 32, 39, 41, 10, 32, 32,105,102, 32,110,111,
+    116, 32,116, 32, 97,110,100, 32,112,116,114, 61, 61, 39, 39,
+     32,116,104,101,110, 32,111,117,116,112,117,116, 40, 39, 42,
+     39, 41, 32,101,110,100, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 40, 40, 39, 44,115,101,108,102, 46,109,111,100, 44,
+    115,101,108,102, 46,116,121,112,101, 41, 10, 32, 32,105,102,
+     32,110,111,116, 32,116, 32,116,104,101,110, 10, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39, 42, 39, 41, 10, 32, 32,101,
+    110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 41, 32,
+     39, 41, 10, 32, 32,108,111, 99, 97,108, 32,100,101,102, 32,
+     61, 32, 48, 10, 32, 32,105,102, 32,115,101,108,102, 46,100,
+    101,102, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 32,100,
+    101,102, 32, 61, 32,115,101,108,102, 46,100,101,102, 32,101,
+    110,100, 10, 32, 32,105,102, 32,116, 32,116,104,101,110, 10,
+     32, 32, 32,111,117,116,112,117,116, 40, 39,116,111,108,117,
+     97, 95,116,111, 39, 46, 46,116, 44, 39, 40,116,111,108,117,
+     97, 95, 83, 44, 51, 44, 39, 44,100,101,102, 44, 39, 41, 41,
+     59, 39, 41, 10, 32, 32,101,108,115,101, 10, 32, 32, 32,111,
+    117,116,112,117,116, 40, 39,116,111,108,117, 97, 95,116,111,
+    117,115,101,114,116,121,112,101, 40,116,111,108,117, 97, 95,
+     83, 44, 51, 44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39,
+     41, 10, 32, 32,101,110,100, 10, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32,114,101,116,117,114,110, 32, 48, 59, 39, 41,
+     10, 32, 32,111,117,116,112,117,116, 40, 39,125, 39, 41, 10,
+     32, 32,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,
+    102, 32, 47, 47, 35,105,102,110,100,101,102, 32, 84, 79, 76,
+     85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10,
+     32, 32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10,
+     32,101,110,100, 10, 10,101,110,100, 10, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 65,114,114, 97,121,
+     58,114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41,
+     10, 32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32,
+     39, 39, 10, 32,105,102, 32,115,101,108,102, 46, 99,115,101,
+    116,110, 97,109,101, 32,116,104,101,110, 10, 32, 32,111,117,
+    116,112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117,
+     97, 95, 97,114,114, 97,121, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+     46, 46, 39, 34, 44, 39, 46, 46,115,101,108,102, 46, 99,103,
+    101,116,110, 97,109,101, 46, 46, 39, 44, 39, 46, 46,115,101,
+    108,102, 46, 99,115,101,116,110, 97,109,101, 46, 46, 39, 41,
+     59, 39, 41, 10, 32,101,108,115,101, 10, 32, 32,111,117,116,
+    112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97,
+     95, 97,114,114, 97,121, 40,116,111,108,117, 97, 95, 83, 44,
+     34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101, 46,
+     46, 39, 34, 44, 39, 46, 46,115,101,108,102, 46, 99,103,101,
+    116,110, 97,109,101, 46, 46, 39, 44, 78, 85, 76, 76, 41, 59,
+     39, 41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
+     32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,
+    114,117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110,
+     32, 95, 65,114,114, 97,121, 32, 40,116, 41, 10, 32,115,101,
+    116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,108,
+     97,115,115, 65,114,114, 97,121, 41, 10, 32, 97,112,112,101,
+    110,100, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,116,
+     10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116,114,
+    117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99,116,
+    115, 32, 97, 32,115,116,114,105,110,103, 32,114,101,112,114,
+    101,115,101,110,116,105,110,103, 32,116,104,101, 32,118, 97,
+    114,105, 97, 98,108,101, 32,100,101, 99,108, 97,114, 97,116,
+    105,111,110, 46, 10,102,117,110, 99,116,105,111,110, 32, 65,
+    114,114, 97,121, 32, 40,115, 41, 10, 32,114,101,116,117,114,
+    110, 32, 95, 65,114,114, 97,121, 32, 40, 68,101, 99,108, 97,
+    114, 97,116,105,111,110, 40,115, 44, 39,118, 97,114, 39, 41,
+     41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/array.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45,
+     45, 32, 70,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115,
+     32, 97, 32,102,117,110, 99,116,105,111,110, 32,111,114, 32,
+     97, 32, 99,108, 97,115,115, 32,109,101,116,104,111,100, 46,
+     10, 45, 45, 32, 84,104,101, 32,102,111,108,108,111,119,105,
+    110,103, 32,102,105,101,108,100,115, 32, 97,114,101, 32,115,
+    116,111,114,101,100, 58, 10, 45, 45, 32, 32,109,111,100, 32,
+     32, 61, 32,116,121,112,101, 32,109,111,100,105,102,105,101,
+    114,115, 10, 45, 45, 32, 32,116,121,112,101, 32, 61, 32,116,
+    121,112,101, 10, 45, 45, 32, 32,112,116,114, 32, 32, 61, 32,
+     34, 42, 34, 32,111,114, 32, 34, 38, 34, 44, 32,105,102, 32,
+    114,101,112,114,101,115,101,110,116,105,110,103, 32, 97, 32,
+    112,111,105,110,116,101,114, 32,111,114, 32, 97, 32,114,101,
+    102,101,114,101,110, 99,101, 10, 45, 45, 32, 32,110, 97,109,
+    101, 32, 61, 32,110, 97,109,101, 10, 45, 45, 32, 32,108,110,
+     97,109,101, 32, 61, 32,108,117, 97, 32,110, 97,109,101, 10,
+     45, 45, 32, 32, 97,114,103,115, 32, 32, 61, 32,108,105,115,
+    116, 32,111,102, 32, 97,114,103,117,109,101,110,116, 32,100,
+    101, 99,108, 97,114, 97,116,105,111,110,115, 10, 45, 45, 32,
+     32, 99,111,110,115,116, 32, 61, 32,105,102, 32,105,116, 32,
+    105,115, 32, 97, 32,109,101,116,104,111,100, 32,114,101, 99,
+    101,105,118,105,110,103, 32, 97, 32, 99,111,110,115,116, 32,
+     34,116,104,105,115, 34, 46, 10, 99,108, 97,115,115, 70,117,
+    110, 99,116,105,111,110, 32, 61, 32,123, 10, 32,109,111,100,
+     32, 61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32,
+     39, 39, 44, 10, 32,112,116,114, 32, 61, 32, 39, 39, 44, 10,
+     32,110, 97,109,101, 32, 61, 32, 39, 39, 44, 10, 32, 97,114,
+    103,115, 32, 61, 32,123,110, 61, 48,125, 44, 10, 32, 99,111,
+    110,115,116, 32, 61, 32, 39, 39, 44, 10,125, 10, 99,108, 97,
+    115,115, 70,117,110, 99,116,105,111,110, 46, 95, 95,105,110,
+    100,101,120, 32, 61, 32, 99,108, 97,115,115, 70,117,110, 99,
+    116,105,111,110, 10,115,101,116,109,101,116, 97,116, 97, 98,
+    108,101, 40, 99,108, 97,115,115, 70,117,110, 99,116,105,111,
+    110, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 41,
+     10, 10, 45, 45, 32,100,101, 99,108, 97,114,101, 32,116, 97,
+    103,115, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 70,117,110, 99,116,105,111,110, 58,100,101, 99,108,
+    116,121,112,101, 32, 40, 41, 10, 32,115,101,108,102, 46,116,
+    121,112,101, 32, 61, 32,116,121,112,101,118, 97,114, 40,115,
+    101,108,102, 46,116,121,112,101, 41, 10, 32,105,102, 32,115,
+    116,114,102,105,110,100, 40,115,101,108,102, 46,109,111,100,
+     44, 39, 99,111,110,115,116, 39, 41, 32,116,104,101,110, 10,
+      9, 32,115,101,108,102, 46,116,121,112,101, 32, 61, 32, 39,
+     99,111,110,115,116, 32, 39, 46, 46,115,101,108,102, 46,116,
+    121,112,101, 10,  9,  9,115,101,108,102, 46,109,111,100, 32,
+     61, 32,103,115,117, 98, 40,115,101,108,102, 46,109,111,100,
+     44, 39, 99,111,110,115,116, 39, 44, 39, 39, 41, 10,  9,101,
+    110,100, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,
+    119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115,
+     91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 46, 97,
+    114,103,115, 91,105, 93, 58,100,101, 99,108,116,121,112,101,
+     40, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,
+    110,100, 10,101,110,100, 10, 10, 10, 45, 45, 32, 87,114,105,
+    116,101, 32, 98,105,110,100,105,110,103, 32,102,117,110, 99,
+    116,105,111,110, 10, 45, 45, 32, 79,117,116,112,117,116,115,
+     32, 67, 47, 67, 43, 43, 32, 98,105,110,100,105,110,103, 32,
+    102,117,110, 99,116,105,111,110, 46, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,116,105,
+    111,110, 58,115,117,112, 99,111,100,101, 32, 40,108,111, 99,
+     97,108, 95, 99,111,110,115,116,114,117, 99,116,111,114, 41,
+     10, 10, 32,108,111, 99, 97,108, 32,111,118,101,114,108,111,
+     97,100, 32, 61, 32,115,116,114,115,117, 98, 40,115,101,108,
+    102, 46, 99,110, 97,109,101, 44, 45, 50, 44, 45, 49, 41, 32,
+     45, 32, 49, 32, 32, 45, 45, 32,105,110,100,105, 99, 97,116,
+    101, 32,111,118,101,114,108,111, 97,100,101,100, 32,102,117,
+    110, 99, 10, 32,108,111, 99, 97,108, 32,110,114,101,116, 32,
+     61, 32, 48, 32, 32, 32, 32, 32, 32, 45, 45, 32,110,117,109,
+     98,101,114, 32,111,102, 32,114,101,116,117,114,110,101,100,
+     32,118, 97,108,117,101,115, 10, 32,108,111, 99, 97,108, 32,
+     99,108, 97,115,115, 32, 61, 32,115,101,108,102, 58,105,110,
+     99,108, 97,115,115, 40, 41, 10, 32,108,111, 99, 97,108, 32,
+     95, 44, 95, 44,115,116, 97,116,105, 99, 32, 61, 32,115,116,
+    114,102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44,
+     39, 94, 37,115, 42, 40,115,116, 97,116,105, 99, 41, 39, 41,
+     10, 32,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110,
+     10, 10, 32,  9,105,102, 32,115,101,108,102, 46,110, 97,109,
+    101, 32, 61, 61, 32, 39,110,101,119, 39, 32, 97,110,100, 32,
+    115,101,108,102, 46,112, 97,114,101,110,116, 46,102,108, 97,
+    103,115, 46,112,117,114,101, 95,118,105,114,116,117, 97,108,
+     32,116,104,101,110, 10, 32,  9,  9, 45, 45, 32,110,111, 32,
+     99,111,110,115,116,114,117, 99,116,111,114, 32,102,111,114,
+     32, 99,108, 97,115,115,101,115, 32,119,105,116,104, 32,112,
+    117,114,101, 32,118,105,114,116,117, 97,108, 32,109,101,116,
+    104,111,100,115, 10, 32,  9,  9,114,101,116,117,114,110, 10,
+     32,  9,101,110,100, 10, 10, 32,  9,105,102, 32,108,111, 99,
+     97,108, 95, 99,111,110,115,116,114,117, 99,116,111,114, 32,
+    116,104,101,110, 10,  9,  9,111,117,116,112,117,116, 40, 34,
+     47, 42, 32,109,101,116,104,111,100, 58, 32,110,101,119, 95,
+    108,111, 99, 97,108, 32,111,102, 32, 99,108, 97,115,115, 32,
+     34, 44, 99,108, 97,115,115, 44, 34, 32, 42, 47, 34, 41, 10,
+      9,101,108,115,101, 10,  9,  9,111,117,116,112,117,116, 40,
+     34, 47, 42, 32,109,101,116,104,111,100, 58, 34, 44,115,101,
+    108,102, 46,110, 97,109,101, 44, 34, 32,111,102, 32, 99,108,
+     97,115,115, 32, 34, 44, 99,108, 97,115,115, 44, 34, 32, 42,
+     47, 34, 41, 10,  9,101,110,100, 10, 32,101,108,115,101, 10,
+     32, 32,111,117,116,112,117,116, 40, 34, 47, 42, 32,102,117,
+    110, 99,116,105,111,110, 58, 34, 44,115,101,108,102, 46,110,
+     97,109,101, 44, 34, 32, 42, 47, 34, 41, 10, 32,101,110,100,
+     10, 10, 32,105,102, 32,108,111, 99, 97,108, 95, 99,111,110,
+    115,116,114,117, 99,116,111,114, 32,116,104,101,110, 10, 32,
+     32,111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101,
+    102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69,
+     95, 34, 46, 46,115,101,108,102, 46, 99,110, 97,109,101, 46,
+     46, 34, 95,108,111, 99, 97,108, 34, 41, 10, 32, 32,111,117,
+    116,112,117,116, 40, 34, 92,110,115,116, 97,116,105, 99, 32,
+    105,110,116, 34, 44,115,101,108,102, 46, 99,110, 97,109,101,
+     46, 46, 34, 95,108,111, 99, 97,108, 34, 44, 34, 40,108,117,
+     97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117, 97, 95,
+     83, 41, 34, 41, 10, 32,101,108,115,101, 10, 32, 32,111,117,
+    116,112,117,116, 40, 34, 35,105,102,110,100,101,102, 32, 84,
+     79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95, 34, 46,
+     46,115,101,108,102, 46, 99,110, 97,109,101, 41, 10, 32, 32,
+    111,117,116,112,117,116, 40, 34, 92,110,115,116, 97,116,105,
+     99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99,110, 97,
+    109,101, 44, 34, 40,108,117, 97, 95, 83,116, 97,116,101, 42,
+     32,116,111,108,117, 97, 95, 83, 41, 34, 41, 10, 32,101,110,
+    100, 10, 32,111,117,116,112,117,116, 40, 34,123, 34, 41, 10,
+     10, 32, 45, 45, 32, 99,104,101, 99,107, 32,116,121,112,101,
+    115, 10,  9,105,102, 32,111,118,101,114,108,111, 97,100, 32,
+     60, 32, 48, 32,116,104,101,110, 10,  9, 32,111,117,116,112,
+    117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76,
+     85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,
+      9,101,110,100, 10,  9,111,117,116,112,117,116, 40, 39, 32,
+    116,111,108,117, 97, 95, 69,114,114,111,114, 32,116,111,108,
+    117, 97, 95,101,114,114, 59, 39, 41, 10, 32,111,117,116,112,
+    117,116, 40, 39, 32,105,102, 32, 40, 92,110, 39, 41, 10, 32,
+     45, 45, 32, 99,104,101, 99,107, 32,115,101,108,102, 10, 32,
+    108,111, 99, 97,108, 32,110, 97,114,103, 10, 32,105,102, 32,
+     99,108, 97,115,115, 32,116,104,101,110, 32,110, 97,114,103,
+     61, 50, 32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32,
+    101,110,100, 10, 32,105,102, 32, 99,108, 97,115,115, 32,116,
+    104,101,110, 10,  9,  9,108,111, 99, 97,108, 32,102,117,110,
+     99, 32, 61, 32, 39,116,111,108,117, 97, 95,105,115,117,115,
+    101,114,116,121,112,101, 39, 10,  9,  9,108,111, 99, 97,108,
+     32,116,121,112,101, 32, 61, 32,115,101,108,102, 46,112, 97,
+    114,101,110,116, 46,116,121,112,101, 10,  9,  9,105,102, 32,
+    115,101,108,102, 46,110, 97,109,101, 61, 61, 39,110,101,119,
+     39, 32,111,114, 32,115,116, 97,116,105, 99,126, 61,110,105,
+    108, 32,116,104,101,110, 10,  9,  9,  9,102,117,110, 99, 32,
+     61, 32, 39,116,111,108,117, 97, 95,105,115,117,115,101,114,
+    116, 97, 98,108,101, 39, 10,  9,  9,  9,116,121,112,101, 32,
+     61, 32,115,101,108,102, 46,112, 97,114,101,110,116, 46,116,
+    121,112,101, 10,  9,  9,101,110,100, 10,  9,  9,105,102, 32,
+    115,101,108,102, 46, 99,111,110,115,116, 32,126, 61, 32, 39,
+     39, 32,116,104,101,110, 10,  9,  9,  9,116,121,112,101, 32,
+     61, 32, 34, 99,111,110,115,116, 32, 34, 46, 46,116,121,112,
+    101, 10,  9,  9,101,110,100, 10,  9,  9,111,117,116,112,117,
+    116, 40, 39, 32, 32, 32, 32, 32, 33, 39, 46, 46,102,117,110,
+     99, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 49, 44,
+     34, 39, 46, 46,116,121,112,101, 46, 46, 39, 34, 44, 48, 44,
+     38,116,111,108,117, 97, 95,101,114,114, 41, 32,124,124, 92,
+    110, 39, 41, 10, 32,101,110,100, 10, 32, 45, 45, 32, 99,104,
+    101, 99,107, 32, 97,114,103,115, 10, 32,105,102, 32,115,101,
+    108,102, 46, 97,114,103,115, 91, 49, 93, 46,116,121,112,101,
+     32,126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110,
+     10, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,
+    119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115,
+     91,105, 93, 32,100,111, 10, 32, 32, 32,108,111, 99, 97,108,
+     32, 98,116,121,112,101, 32, 61, 32,105,115, 98, 97,115,105,
+     99, 40,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 46,
+    116,121,112,101, 41, 10, 32, 32, 32,105,102, 32, 98,116,121,
+    112,101, 32,126, 61, 32, 39,118, 97,108,117,101, 39, 32, 97,
+    110,100, 32, 98,116,121,112,101, 32,126, 61, 32, 39,115,116,
+     97,116,101, 39, 32,116,104,101,110, 10, 32, 32, 32, 32,111,
+    117,116,112,117,116, 40, 39, 32, 32, 32, 32, 32, 33, 39, 46,
+     46,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 58,111,
+    117,116, 99,104,101, 99,107,116,121,112,101, 40,110, 97,114,
+    103, 41, 46, 46, 39, 32,124,124, 92,110, 39, 41, 10, 32, 32,
+     32,101,110,100, 10, 32, 32, 32,105,102, 32, 98,116,121,112,
+    101, 32,126, 61, 32, 39,115,116, 97,116,101, 39, 32,116,104,
+    101,110, 10,  9, 32, 32, 32,110, 97,114,103, 32, 61, 32,110,
+     97,114,103, 43, 49, 10, 32, 32, 32,101,110,100, 10, 32, 32,
+     32,105, 32, 61, 32,105, 43, 49, 10, 32, 32,101,110,100, 10,
+     32,101,110,100, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,
+    101,110,100, 32,111,102, 32,108,105,115,116, 10, 32,111,117,
+    116,112,117,116, 40, 39, 32, 32, 32, 32, 32, 33,116,111,108,
+    117, 97, 95,105,115,110,111,111, 98,106, 40,116,111,108,117,
+     97, 95, 83, 44, 39, 46, 46,110, 97,114,103, 46, 46, 39, 44,
+     38,116,111,108,117, 97, 95,101,114,114, 41, 92,110, 32, 41,
+     39, 41, 10,  9,111,117,116,112,117,116, 40, 39, 32, 32,103,
+    111,116,111, 32,116,111,108,117, 97, 95,108,101,114,114,111,
+    114, 59, 39, 41, 10, 10, 32,111,117,116,112,117,116, 40, 39,
+     32,101,108,115,101, 92,110, 39, 41, 10,  9,105,102, 32,111,
+    118,101,114,108,111, 97,100, 32, 60, 32, 48, 32,116,104,101,
+    110, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10,  9,101,110,100, 10,  9,111,
+    117,116,112,117,116, 40, 39, 32,123, 39, 41, 10, 10, 32, 45,
+     45, 32,100,101, 99,108, 97,114,101, 32,115,101,108,102, 44,
+     32,105,102, 32,116,104,101, 32, 99, 97,115,101, 10, 32,108,
+    111, 99, 97,108, 32,110, 97,114,103, 10, 32,105,102, 32, 99,
+    108, 97,115,115, 32,116,104,101,110, 32,110, 97,114,103, 61,
+     50, 32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32,101,
+    110,100, 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,
+    100, 32,115,101,108,102, 46,110, 97,109,101,126, 61, 39,110,
+    101,119, 39, 32, 97,110,100, 32,115,116, 97,116,105, 99, 61,
+     61,110,105,108, 32,116,104,101,110, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 39, 44,115,101,108,102, 46, 99,111,
+    110,115,116, 44,115,101,108,102, 46,112, 97,114,101,110,116,
+     46,116,121,112,101, 44, 39, 42, 39, 44, 39,115,101,108,102,
+     32, 61, 32, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40,
+     39, 40, 39, 44,115,101,108,102, 46, 99,111,110,115,116, 44,
+    115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,
+    101, 44, 39, 42, 41, 32, 39, 41, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39,116,111,108,117, 97, 95,116,111,117,115,101,
+    114,116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 49,
+     44, 48, 41, 59, 39, 41, 10, 32,101,108,115,101,105,102, 32,
+    115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, 32, 95,
+     44, 95, 44,115,101,108,102, 46,109,111,100, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115,101,108,102, 46,109,111,100,
+     44, 39, 94, 37,115, 42,115,116, 97,116,105, 99, 37,115, 37,
+    115, 42, 40, 46, 42, 41, 39, 41, 10, 32,101,110,100, 10, 32,
+     45, 45, 32,100,101, 99,108, 97,114,101, 32,112, 97,114, 97,
+    109,101,116,101,114,115, 10, 32,105,102, 32,115,101,108,102,
+     46, 97,114,103,115, 91, 49, 93, 46,116,121,112,101, 32,126,
+     61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10, 32,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,119,104,
+    105,108,101, 32,115,101,108,102, 46, 97,114,103,115, 91,105,
+     93, 32,100,111, 10, 32, 32, 32,115,101,108,102, 46, 97,114,
+    103,115, 91,105, 93, 58,100,101, 99,108, 97,114,101, 40,110,
+     97,114,103, 41, 10, 32, 32, 32,105,102, 32,105,115, 98, 97,
+    115,105, 99, 40,115,101,108,102, 46, 97,114,103,115, 91,105,
+     93, 46,116,121,112,101, 41, 32,126, 61, 32, 34,115,116, 97,
+    116,101, 34, 32,116,104,101,110, 10,  9, 32, 32, 32,110, 97,
+    114,103, 32, 61, 32,110, 97,114,103, 43, 49, 10, 32, 32, 32,
+    101,110,100, 10, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45,
+     32, 99,104,101, 99,107, 32,115,101,108,102, 10, 32,105,102,
+     32, 99,108, 97,115,115, 32, 97,110,100, 32,115,101,108,102,
+     46,110, 97,109,101,126, 61, 39,110,101,119, 39, 32, 97,110,
+    100, 32,115,116, 97,116,105, 99, 61, 61,110,105,108, 32,116,
+    104,101,110, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,
+    105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69,
+     76, 69, 65, 83, 69, 92,110, 39, 41, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32,105,102, 32, 40, 33,115,101,108,
+    102, 41, 32,116,111,108,117, 97, 95,101,114,114,111,114, 40,
+    116,111,108,117, 97, 95, 83, 44, 34,105,110,118, 97,108,105,
+    100, 32, 92, 39,115,101,108,102, 92, 39, 32,105,110, 32,102,
+    117,110, 99,116,105,111,110, 32, 92, 39, 39, 46, 46,115,101,
+    108,102, 46,110, 97,109,101, 46, 46, 39, 92, 39, 34, 44, 78,
+     85, 76, 76, 41, 59, 39, 41, 59, 10,  9, 32,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32,103,101,116, 32, 97,
+    114,114, 97,121, 32,101,108,101,109,101,110,116, 32,118, 97,
+    108,117,101,115, 10, 32,105,102, 32, 99,108, 97,115,115, 32,
+    116,104,101,110, 32,110, 97,114,103, 61, 50, 32,101,108,115,
+    101, 32,110, 97,114,103, 61, 49, 32,101,110,100, 10, 32,105,
+    102, 32,115,101,108,102, 46, 97,114,103,115, 91, 49, 93, 46,
+    116,121,112,101, 32,126, 61, 32, 39,118,111,105,100, 39, 32,
+    116,104,101,110, 10, 32, 32,108,111, 99, 97,108, 32,105, 61,
+     49, 10, 32, 32,119,104,105,108,101, 32,115,101,108,102, 46,
+     97,114,103,115, 91,105, 93, 32,100,111, 10, 32, 32, 32,115,
+    101,108,102, 46, 97,114,103,115, 91,105, 93, 58,103,101,116,
+     97,114,114, 97,121, 40,110, 97,114,103, 41, 10, 32, 32, 32,
+    110, 97,114,103, 32, 61, 32,110, 97,114,103, 43, 49, 10, 32,
+     32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32,101,110,100,
+     10, 32,101,110,100, 10, 10, 32,108,111, 99, 97,108, 32,111,
+    117,116, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,115,101,108,102, 46,109,111,100, 44, 32, 34,116,111,
+    108,117, 97, 95,111,117,116,115,105,100,101, 34, 41, 10, 32,
+     45, 45, 32, 99, 97,108,108, 32,102,117,110, 99,116,105,111,
+    110, 10, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100,
+     32,115,101,108,102, 46,110, 97,109,101, 61, 61, 39,100,101,
+    108,101,116,101, 39, 32,116,104,101,110, 10, 32, 32,111,117,
+    116,112,117,116, 40, 39, 32, 32,100,101,108,101,116,101, 32,
+    115,101,108,102, 59, 39, 41, 10, 32,101,108,115,101,105,102,
+     32, 99,108, 97,115,115, 32, 97,110,100, 32,115,101,108,102,
+     46,110, 97,109,101, 32, 61, 61, 32, 39,111,112,101,114, 97,
+    116,111,114, 38, 91, 93, 39, 32,116,104,101,110, 10, 32, 32,
+    105,102, 32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,
+    104,101,110, 32, 45, 45, 32,102,111,114, 32, 99,111,109,112,
+     97,116,105, 98,105,108,105,116,121, 32,119,105,116,104, 32,
+    116,111,108,117, 97, 53, 32, 63, 10,  9,111,117,116,112,117,
+    116, 40, 39, 32, 32,115,101,108,102, 45, 62,111,112,101,114,
+     97,116,111,114, 91, 93, 40, 39, 44,115,101,108,102, 46, 97,
+    114,103,115, 91, 49, 93, 46,110, 97,109,101, 44, 39, 45, 49,
+     41, 32, 61, 32, 39, 44,115,101,108,102, 46, 97,114,103,115,
+     91, 50, 93, 46,110, 97,109,101, 44, 39, 59, 39, 41, 10, 32,
+     32,101,108,115,101, 10, 32, 32, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32, 32,115,101,108,102, 45, 62,111,112,101,114,
+     97,116,111,114, 91, 93, 40, 39, 44,115,101,108,102, 46, 97,
+    114,103,115, 91, 49, 93, 46,110, 97,109,101, 44, 39, 41, 32,
+     61, 32, 39, 44,115,101,108,102, 46, 97,114,103,115, 91, 50,
+     93, 46,110, 97,109,101, 44, 39, 59, 39, 41, 10, 32, 32,101,
+    110,100, 10, 32,101,108,115,101, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32,123, 39, 41, 10, 32, 32,105,102, 32,
+    115,101,108,102, 46,116,121,112,101, 32,126, 61, 32, 39, 39,
+     32, 97,110,100, 32,115,101,108,102, 46,116,121,112,101, 32,
+    126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10,
+     32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 39, 44,
+    115,101,108,102, 46,109,111,100, 44,115,101,108,102, 46,116,
+    121,112,101, 44,115,101,108,102, 46,112,116,114, 44, 39,116,
+    111,108,117, 97, 95,114,101,116, 32, 61, 32, 39, 41, 10, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 40, 39, 44,115,101,
+    108,102, 46,109,111,100, 44,115,101,108,102, 46,116,121,112,
+    101, 44,115,101,108,102, 46,112,116,114, 44, 39, 41, 32, 39,
+     41, 10, 32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 39, 41, 10, 32, 32,101,110,100,
+     10, 32, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,100,
+     32,115,101,108,102, 46,110, 97,109,101, 61, 61, 39,110,101,
+    119, 39, 32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,
+    117,116, 40, 39,110,101,119, 39, 44,115,101,108,102, 46,116,
+    121,112,101, 44, 39, 40, 39, 41, 10, 32, 32,101,108,115,101,
+    105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116,
+     97,116,105, 99, 32,116,104,101,110, 10,  9,105,102, 32,111,
+    117,116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,
+    116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, 39,
+     41, 10,  9,101,108,115,101, 10,  9,  9,111,117,116,112,117,
+    116, 40, 99,108, 97,115,115, 46, 46, 39, 58, 58, 39, 46, 46,
+    115,101,108,102, 46,110, 97,109,101, 44, 39, 40, 39, 41, 10,
+      9,101,110,100, 10, 32, 32,101,108,115,101,105,102, 32, 99,
+    108, 97,115,115, 32,116,104,101,110, 10,  9,105,102, 32,111,
+    117,116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,
+    116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, 39,
+     41, 10,  9,101,108,115,101, 10,  9, 32, 32,105,102, 32,115,
+    101,108,102, 46, 99, 97,115,116, 95,111,112,101,114, 97,116,
+    111,114, 32,116,104,101,110, 10,  9, 32, 32,  9,111,117,116,
+    112,117,116, 40, 39,115,116, 97,116,105, 99, 95, 99, 97,115,
+    116, 60, 39, 44,115,101,108,102, 46,109,111,100, 44,115,101,
+    108,102, 46,116,121,112,101, 44,115,101,108,102, 46,112,116,
+    114, 44, 39, 62, 40, 42,115,101,108,102, 39, 41, 10,  9, 32,
+     32,101,108,115,101, 10,  9,  9,111,117,116,112,117,116, 40,
+     39,115,101,108,102, 45, 62, 39, 46, 46,115,101,108,102, 46,
+    110, 97,109,101, 44, 39, 40, 39, 41, 10,  9, 32, 32,101,110,
+    100, 10,  9,101,110,100, 10, 32, 32,101,108,115,101, 10, 32,
+     32, 32,111,117,116,112,117,116, 40,115,101,108,102, 46,110,
+     97,109,101, 44, 39, 40, 39, 41, 10, 32, 32,101,110,100, 10,
+     10, 32, 32,105,102, 32,111,117,116, 32, 97,110,100, 32,110,
+    111,116, 32,115,116, 97,116,105, 99, 32,116,104,101,110, 10,
+     32, 32,  9,111,117,116,112,117,116, 40, 39,115,101,108,102,
+     39, 41, 10,  9,105,102, 32,115,101,108,102, 46, 97,114,103,
+    115, 91, 49, 93, 32, 97,110,100, 32,115,101,108,102, 46, 97,
+    114,103,115, 91, 49, 93, 46,110, 97,109,101, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,
+    116, 40, 39, 44, 39, 41, 10,  9,101,110,100, 10, 32, 32,101,
+    110,100, 10, 32, 32, 45, 45, 32,119,114,105,116,101, 32,112,
+     97,114, 97,109,101,116,101,114,115, 10, 32, 32,108,111, 99,
+     97,108, 32,105, 61, 49, 10, 32, 32,119,104,105,108,101, 32,
+    115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,100,111,
+     10, 32, 32, 32,115,101,108,102, 46, 97,114,103,115, 91,105,
+     93, 58,112, 97,115,115,112, 97,114, 40, 41, 10, 32, 32, 32,
+    105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,105,102, 32,115,
+    101,108,102, 46, 97,114,103,115, 91,105, 93, 32,116,104,101,
+    110, 10, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 44,
+     39, 41, 10, 32, 32, 32,101,110,100, 10, 32, 32,101,110,100,
+     10, 10, 32, 32,105,102, 32, 99,108, 97,115,115, 32, 97,110,
+    100, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 61, 32,
+     39,111,112,101,114, 97,116,111,114, 91, 93, 39, 32, 97,110,
+    100, 32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,104,
+    101,110, 10,  9,111,117,116,112,117,116, 40, 39, 45, 49, 41,
+     59, 39, 41, 10, 32, 32,101,108,115,101, 10,  9,111,117,116,
+    112,117,116, 40, 39, 41, 59, 39, 41, 10, 32, 32,101,110,100,
+     10, 10, 32, 32, 45, 45, 32,114,101,116,117,114,110, 32,118,
+     97,108,117,101,115, 10, 32, 32,105,102, 32,115,101,108,102,
+     46,116,121,112,101, 32,126, 61, 32, 39, 39, 32, 97,110,100,
+     32,115,101,108,102, 46,116,121,112,101, 32,126, 61, 32, 39,
+    118,111,105,100, 39, 32,116,104,101,110, 10, 32, 32, 32,110,
+    114,101,116, 32, 61, 32,110,114,101,116, 32, 43, 32, 49, 10,
+     32, 32, 32,108,111, 99, 97,108, 32,116, 44, 99,116, 32, 61,
+     32,105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46,116,
+    121,112,101, 41, 10, 32, 32, 32,105,102, 32,116, 32,116,104,
+    101,110, 10, 32, 32, 32,  9,105,102, 32,115,101,108,102, 46,
+     99, 97,115,116, 95,111,112,101,114, 97,116,111,114, 32, 97,
+    110,100, 32, 95, 98, 97,115,105, 99, 95,114, 97,119, 95,112,
+    117,115,104, 91,116, 93, 32,116,104,101,110, 10,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 32, 32, 39, 44, 95, 98, 97,
+    115,105, 99, 95,114, 97,119, 95,112,117,115,104, 91,116, 93,
+     44, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39, 44, 99,
+    116, 44, 39, 41,116,111,108,117, 97, 95,114,101,116, 41, 59,
+     39, 41, 10, 32, 32, 32,  9,101,108,115,101, 10,  9, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111,
+    108,117, 97, 95,112,117,115,104, 39, 46, 46,116, 46, 46, 39,
+     40,116,111,108,117, 97, 95, 83, 44, 40, 39, 44, 99,116, 44,
+     39, 41,116,111,108,117, 97, 95,114,101,116, 41, 59, 39, 41,
+     10,  9,101,110,100, 10, 32, 32, 32,101,108,115,101, 10,  9,
+      9,  9, 32,116, 32, 61, 32,115,101,108,102, 46,116,121,112,
+    101, 10,  9,  9,  9, 32,110,101,119, 95,116, 32, 61, 32,115,
+    116,114,105,110,103, 46,103,115,117, 98, 40,116, 44, 32, 34,
+     99,111,110,115,116, 37,115, 43, 34, 44, 32, 34, 34, 41, 10,
+     32, 32, 32, 32,105,102, 32,115,101,108,102, 46,112,116,114,
+     32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,123, 39,
+     41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39,
+     35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,115,112,
+    108,117,115, 92,110, 39, 41, 10, 32, 32, 32, 32, 32,111,117,
+    116,112,117,116, 40, 39, 32, 32, 32, 32,118,111,105,100, 42,
+     32,116,111,108,117, 97, 95,111, 98,106, 32, 61, 32,110,101,
+    119, 39, 44,110,101,119, 95,116, 44, 39, 40,116,111,108,117,
+     97, 95,114,101,116, 41, 59, 39, 41, 10, 32, 32, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,116,111,108,
+    117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,101,
+     95, 97,110,100, 95,116, 97,107,101,111,119,110,101,114,115,
+    104,105,112, 40,116,111,108,117, 97, 95, 83, 44,116,111,108,
+    117, 97, 95,111, 98,106, 44, 34, 39, 44,116, 44, 39, 34, 41,
+     59, 39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 35,101,108,115,101, 92,110, 39, 41, 10, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,118,
+    111,105,100, 42, 32,116,111,108,117, 97, 95,111, 98,106, 32,
+     61, 32,116,111,108,117, 97, 95, 99,111,112,121, 40,116,111,
+    108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, 38,116,
+    111,108,117, 97, 95,114,101,116, 44,115,105,122,101,111,102,
+     40, 39, 44,116, 44, 39, 41, 41, 59, 39, 41, 10, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,116,
+    111,108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,
+    112,101, 95, 97,110,100, 95,116, 97,107,101,111,119,110,101,
+    114,115,104,105,112, 40,116,111,108,117, 97, 95, 83, 44,116,
+    111,108,117, 97, 95,111, 98,106, 44, 34, 39, 44,116, 44, 39,
+     34, 41, 59, 39, 41, 10, 32, 32, 32, 32, 32,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+     32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,
+     32,125, 39, 41, 10, 32, 32, 32, 32,101,108,115,101,105,102,
+     32,115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 38,
+     39, 32,116,104,101,110, 10, 32, 32, 32, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32,116,111,108,117, 97, 95,112,
+    117,115,104,117,115,101,114,116,121,112,101, 40,116,111,108,
+    117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, 38,116,111,
+    108,117, 97, 95,114,101,116, 44, 34, 39, 44,116, 44, 39, 34,
+     41, 59, 39, 41, 10, 32, 32, 32, 32,101,108,115,101, 10, 32,
+     32, 32, 32,  9,105,102, 32,108,111, 99, 97,108, 95, 99,111,
+    110,115,116,114,117, 99,116,111,114, 32,116,104,101,110, 10,
+      9, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,
+    111,108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,
+    112,101, 95, 97,110,100, 95,116, 97,107,101,111,119,110,101,
+    114,115,104,105,112, 40,116,111,108,117, 97, 95, 83, 44, 40,
+    118,111,105,100, 32, 42, 41,116,111,108,117, 97, 95,114,101,
+    116, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10, 32,
+     32, 32, 32,  9,101,108,115,101, 10,  9,  9, 32, 32, 32, 32,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111,108,
+    117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,101,
+     40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 42,
+     41,116,111,108,117, 97, 95,114,101,116, 44, 34, 39, 44,116,
+     44, 39, 34, 41, 59, 39, 41, 10,  9, 32, 32, 32, 32,101,110,
+    100, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32,101,110,
+    100, 10, 32, 32,101,110,100, 10, 32, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32, 32,119,104,105,108,101, 32,115,101,
+    108,102, 46, 97,114,103,115, 91,105, 93, 32,100,111, 10, 32,
+     32, 32,110,114,101,116, 32, 61, 32,110,114,101,116, 32, 43,
+     32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 58,114,
+    101,116,118, 97,108,117,101, 40, 41, 10, 32, 32, 32,105, 32,
+     61, 32,105, 43, 49, 10, 32, 32,101,110,100, 10, 32, 32,111,
+    117,116,112,117,116, 40, 39, 32, 32,125, 39, 41, 10, 10, 32,
+     32, 45, 45, 32,115,101,116, 32, 97,114,114, 97,121, 32,101,
+    108,101,109,101,110,116, 32,118, 97,108,117,101,115, 10, 32,
+     32,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 32,
+    110, 97,114,103, 61, 50, 32,101,108,115,101, 32,110, 97,114,
+    103, 61, 49, 32,101,110,100, 10, 32, 32,105,102, 32,115,101,
+    108,102, 46, 97,114,103,115, 91, 49, 93, 46,116,121,112,101,
+     32,126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110,
+     10, 32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,
+     32, 32,119,104,105,108,101, 32,115,101,108,102, 46, 97,114,
+    103,115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32,115,101,
+    108,102, 46, 97,114,103,115, 91,105, 93, 58,115,101,116, 97,
+    114,114, 97,121, 40,110, 97,114,103, 41, 10, 32, 32, 32, 32,
+    110, 97,114,103, 32, 61, 32,110, 97,114,103, 43, 49, 10, 32,
+     32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,101,
+    110,100, 10, 32, 32,101,110,100, 10, 10, 32, 32, 45, 45, 32,
+    102,114,101,101, 32,100,121,110, 97,109,105, 99, 97,108,108,
+    121, 32, 97,108,108,111, 99, 97,116,101,100, 32, 97,114,114,
+     97,121, 10, 32, 32,105,102, 32,115,101,108,102, 46, 97,114,
+    103,115, 91, 49, 93, 46,116,121,112,101, 32,126, 61, 32, 39,
+    118,111,105,100, 39, 32,116,104,101,110, 10, 32, 32, 32,108,
+    111, 99, 97,108, 32,105, 61, 49, 10, 32, 32, 32,119,104,105,
+    108,101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93,
+     32,100,111, 10, 32, 32, 32, 32,115,101,108,102, 46, 97,114,
+    103,115, 91,105, 93, 58,102,114,101,101, 97,114,114, 97,121,
+     40, 41, 10, 32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10,
+     32, 32, 32,101,110,100, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32,111,117,116,112,117,116, 40, 39, 32,125,
+     39, 41, 10, 32,111,117,116,112,117,116, 40, 39, 32,114,101,
+    116,117,114,110, 32, 39, 46, 46,110,114,101,116, 46, 46, 39,
+     59, 39, 41, 10, 10, 32, 45, 45, 32, 99, 97,108,108, 32,111,
+    118,101,114,108,111, 97,100,101,100, 32,102,117,110, 99,116,
+    105,111,110, 32,111,114, 32,103,101,110,101,114, 97,116,101,
+     32,101,114,114,111,114, 10,  9,105,102, 32,111,118,101,114,
+    108,111, 97,100, 32, 60, 32, 48, 32,116,104,101,110, 10, 10,
+      9,  9,111,117,116,112,117,116, 40, 39, 35,105,102,110,100,
+    101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83,
+     69, 92,110, 39, 41, 10,  9,  9,111,117,116,112,117,116, 40,
+     39,116,111,108,117, 97, 95,108,101,114,114,111,114, 58, 92,
+    110, 39, 41, 10,  9,  9,111,117,116,112,117,116, 40, 39, 32,
+    116,111,108,117, 97, 95,101,114,114,111,114, 40,116,111,108,
+    117, 97, 95, 83, 44, 34, 35,102,101,114,114,111,114, 32,105,
+    110, 32,102,117,110, 99,116,105,111,110, 32, 92, 39, 39, 46,
+     46,115,101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 92,
+     39, 46, 34, 44, 38,116,111,108,117, 97, 95,101,114,114, 41,
+     59, 39, 41, 10,  9,  9,111,117,116,112,117,116, 40, 39, 32,
+    114,101,116,117,114,110, 32, 48, 59, 39, 41, 10,  9,  9,111,
+    117,116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110,
+     39, 41, 10,  9,101,108,115,101, 10,  9,  9,108,111, 99, 97,
+    108, 32, 95,108,111, 99, 97,108, 32, 61, 32, 34, 34, 10,  9,
+      9,105,102, 32,108,111, 99, 97,108, 95, 99,111,110,115,116,
+    114,117, 99,116,111,114, 32,116,104,101,110, 10,  9,  9,  9,
+     95,108,111, 99, 97,108, 32, 61, 32, 34, 95,108,111, 99, 97,
+    108, 34, 10,  9,  9,101,110,100, 10,  9,  9,111,117,116,112,
+    117,116, 40, 39,116,111,108,117, 97, 95,108,101,114,114,111,
+    114, 58, 92,110, 39, 41, 10,  9,  9,111,117,116,112,117,116,
+     40, 39, 32,114,101,116,117,114,110, 32, 39, 46, 46,115,116,
+    114,115,117, 98, 40,115,101,108,102, 46, 99,110, 97,109,101,
+     44, 49, 44, 45, 51, 41, 46, 46,102,111,114,109, 97,116, 40,
+     34, 37, 48, 50,100, 34, 44,111,118,101,114,108,111, 97,100,
+     41, 46, 46, 95,108,111, 99, 97,108, 46, 46, 39, 40,116,111,
+    108,117, 97, 95, 83, 41, 59, 39, 41, 10,  9,101,110,100, 10,
+     32,111,117,116,112,117,116, 40, 39,125, 39, 41, 10, 32,111,
+    117,116,112,117,116, 40, 39, 35,101,110,100,105,102, 32, 47,
+     47, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95,
+     68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10, 32,111,117,
+    116,112,117,116, 40, 39, 92,110, 39, 41, 10, 10,  9, 45, 45,
+     32,114,101, 99,117,114,115,105,118,101, 32, 99, 97,108,108,
+     32,116,111, 32,119,114,105,116,101, 32,108,111, 99, 97,108,
+     32, 99,111,110,115,116,114,117, 99,116,111,114, 10,  9,105,
+    102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,101,108,
+    102, 46,110, 97,109,101, 61, 61, 39,110,101,119, 39, 32, 97,
+    110,100, 32,110,111,116, 32,108,111, 99, 97,108, 95, 99,111,
+    110,115,116,114,117, 99,116,111,114, 32,116,104,101,110, 10,
+     10,  9,  9,115,101,108,102, 58,115,117,112, 99,111,100,101,
+     40, 49, 41, 10,  9,101,110,100, 10, 10,101,110,100, 10, 10,
+     10, 45, 45, 32,114,101,103,105,115,116,101,114, 32,102,117,
+    110, 99,116,105,111,110, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 70,117,110, 99,116,105,111,110, 58,
+    114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41, 10,
+     10,  9,105,102, 32,110,111,116, 32,115,101,108,102, 58, 99,
+    104,101, 99,107, 95,112,117, 98,108,105, 99, 95, 97, 99, 99,
+    101,115,115, 40, 41, 32,116,104,101,110, 10,  9,  9,114,101,
+    116,117,114,110, 10,  9,101,110,100, 10, 10, 32,  9,105,102,
+     32,115,101,108,102, 46,110, 97,109,101, 32, 61, 61, 32, 39,
+    110,101,119, 39, 32, 97,110,100, 32,115,101,108,102, 46,112,
+     97,114,101,110,116, 46,102,108, 97,103,115, 46,112,117,114,
+    101, 95,118,105,114,116,117, 97,108, 32,116,104,101,110, 10,
+     32,  9,  9, 45, 45, 32,110,111, 32, 99,111,110,115,116,114,
+    117, 99,116,111,114, 32,102,111,114, 32, 99,108, 97,115,115,
+    101,115, 32,119,105,116,104, 32,112,117,114,101, 32,118,105,
+    114,116,117, 97,108, 32,109,101,116,104,111,100,115, 10, 32,
+      9,  9,114,101,116,117,114,110, 10, 32,  9,101,110,100, 10,
+     10, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46, 39,
+    116,111,108,117, 97, 95,102,117,110, 99,116,105,111,110, 40,
+    116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,
+    102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, 39, 46, 46,
+    115,101,108,102, 46, 99,110, 97,109,101, 46, 46, 39, 41, 59,
+     39, 41, 10, 32, 32,105,102, 32,115,101,108,102, 46,110, 97,
+    109,101, 32, 61, 61, 32, 39,110,101,119, 39, 32,116,104,101,
+    110, 10,  9, 32, 32,111,117,116,112,117,116, 40,112,114,101,
+     46, 46, 39,116,111,108,117, 97, 95,102,117,110, 99,116,105,
+    111,110, 40,116,111,108,117, 97, 95, 83, 44, 34,110,101,119,
+     95,108,111, 99, 97,108, 34, 44, 39, 46, 46,115,101,108,102,
+     46, 99,110, 97,109,101, 46, 46, 39, 95,108,111, 99, 97,108,
+     41, 59, 39, 41, 10,  9, 32, 32,111,117,116,112,117,116, 40,
+    112,114,101, 46, 46, 39,116,111,108,117, 97, 95,102,117,110,
+     99,116,105,111,110, 40,116,111,108,117, 97, 95, 83, 44, 34,
+     46, 99, 97,108,108, 34, 44, 39, 46, 46,115,101,108,102, 46,
+     99,110, 97,109,101, 46, 46, 39, 95,108,111, 99, 97,108, 41,
+     59, 39, 41, 10,  9, 32, 32, 45, 45,111,117,116,112,117,116,
+     40, 39, 32,116,111,108,117, 97, 95,115,101,116, 95, 99, 97,
+    108,108, 95,101,118,101,110,116, 40,116,111,108,117, 97, 95,
+     83, 44, 39, 46, 46,115,101,108,102, 46, 99,110, 97,109,101,
+     46, 46, 39, 95,108,111, 99, 97,108, 44, 32, 34, 39, 46, 46,
+    115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,
+    101, 46, 46, 39, 34, 41, 59, 39, 41, 10, 32, 32,101,110,100,
+     10,101,110,100, 10, 10, 45, 45, 32, 80,114,105,110,116, 32,
+    109,101,116,104,111,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 70,117,110, 99,116,105,111,110, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 70,117,110, 99,116,105,111,110,123, 34,
+     41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,
+    109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 32,108,110, 97,
+    109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,108,
+    110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, 99,111,
+    110,115,116, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,
+     99,111,110,115,116, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,
+    114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32, 99,
+    110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46, 99,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32, 97,114,103,115, 32, 61, 32,123, 34, 41, 10, 32,108,111,
+     99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,101, 32,
+    115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,100,111,
+     10, 32, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93,
+     58,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32, 61, 32,
+    105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 32,125, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,125,
+     34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10, 10,
+     45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,105,116, 32,
+    114,101,116,117,114,110,115, 32, 97,110, 32,111, 98,106,101,
+     99,116, 32, 98,121, 32,118, 97,108,117,101, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,
+    116,105,111,110, 58,114,101,113,117,105,114,101, 99,111,108,
+    108,101, 99,116,105,111,110, 32, 40,116, 41, 10,  9,108,111,
+     99, 97,108, 32,114, 32, 61, 32,102, 97,108,115,101, 10,  9,
+    105,102, 32,115,101,108,102, 46,116,121,112,101, 32,126, 61,
+     32, 39, 39, 32, 97,110,100, 32,110,111,116, 32,105,115, 98,
+     97,115,105, 99, 40,115,101,108,102, 46,116,121,112,101, 41,
+     32, 97,110,100, 32,115,101,108,102, 46,112,116,114, 61, 61,
+     39, 39, 32,116,104,101,110, 10,  9,  9,108,111, 99, 97,108,
+     32,116,121,112,101, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46,116,121,112,101, 44, 34, 37,115, 42, 99,111,110,
+    115,116, 37,115, 43, 34, 44, 34, 34, 41, 10,  9, 32,116, 91,
+    116,121,112,101, 93, 32, 61, 32, 34,116,111,108,117, 97, 95,
+     99,111,108,108,101, 99,116, 95, 34, 32, 46, 46, 32, 99,108,
+    101, 97,110, 95,116,101,109,112,108, 97,116,101, 40,116,121,
+    112,101, 41, 10,  9, 32,114, 32, 61, 32,116,114,117,101, 10,
+      9,101,110,100, 10,  9,108,111, 99, 97,108, 32,105, 61, 49,
+     10,  9,119,104,105,108,101, 32,115,101,108,102, 46, 97,114,
+    103,115, 91,105, 93, 32,100,111, 10,  9,  9,114, 32, 61, 32,
+    115,101,108,102, 46, 97,114,103,115, 91,105, 93, 58,114,101,
+    113,117,105,114,101, 99,111,108,108,101, 99,116,105,111,110,
+     40,116, 41, 32,111,114, 32,114, 10,  9,  9,105, 32, 61, 32,
+    105, 43, 49, 10,  9,101,110,100, 10,  9,114,101,116,117,114,
+    110, 32,114, 10,101,110,100, 10, 10, 45, 45, 32,100,101,116,
+    101,114,109,105,110,101, 32,108,117, 97, 32,102,117,110, 99,
+    116,105,111,110, 32,110, 97,109,101, 32,111,118,101,114,108,
+    111, 97,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 70,117,110, 99,116,105,111,110, 58,111,118,101,
+    114,108,111, 97,100, 32, 40, 41, 10, 32,114,101,116,117,114,
+    110, 32,115,101,108,102, 46,112, 97,114,101,110,116, 58,111,
+    118,101,114,108,111, 97,100, 40,115,101,108,102, 46,108,110,
+     97,109,101, 41, 10,101,110,100, 10, 10, 10,102,117,110, 99,
+    116,105,111,110, 32,112, 97,114, 97,109, 95,111, 98,106,101,
+     99,116, 40,112, 97,114, 41, 32, 45, 45, 32,114,101,116,117,
+    114,110,115, 32,116,114,117,101, 32,105,102, 32,116,104,101,
+     32,112, 97,114, 97,109,101,116,101,114, 32,104, 97,115, 32,
+     97,110, 32,111, 98,106,101, 99,116, 32, 97,115, 32,105,116,
+    115, 32,100,101,102, 97,117,108,116, 32,118, 97,108,117,101,
+     10, 10,  9,105,102, 32,110,111,116, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40,112, 97,114, 44, 32, 39, 61, 39,
+     41, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,102,
+     97,108,115,101, 32,101,110,100, 32, 45, 45, 32,105,116, 32,
+    104, 97,115, 32,110,111, 32,100,101,102, 97,117,108,116, 32,
+    118, 97,108,117,101, 10, 10,  9,108,111, 99, 97,108, 32, 95,
+     44, 95, 44,100,101,102, 32, 61, 32,115,116,114,105,110,103,
+     46,102,105,110,100, 40,112, 97,114, 44, 32, 34, 61, 40, 46,
+     42, 41, 36, 34, 41, 10, 10,  9,105,102, 32,115,116,114,105,
+    110,103, 46,102,105,110,100, 40,112, 97,114, 44, 32, 34,124,
+     34, 41, 32,116,104,101,110, 32, 45, 45, 32, 97, 32,108,105,
+    115,116, 32,111,102, 32,102,108, 97,103,115, 10, 10,  9,  9,
+    114,101,116,117,114,110, 32,116,114,117,101, 10,  9,101,110,
+    100, 10, 10,  9,105,102, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,112, 97,114, 44, 32, 34, 37, 42, 34, 41, 32,
+    116,104,101,110, 32, 45, 45, 32,105,116, 39,115, 32, 97, 32,
+    112,111,105,110,116,101,114, 32,119,105,116,104, 32, 97, 32,
+    100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 10, 10,
+      9,  9,105,102, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,112, 97,114, 44, 32, 39, 61, 37,115, 42,110,101,119,
+     39, 41, 32,116,104,101,110, 32, 45, 45, 32,105,116, 39,115,
+     32, 97, 32,112,111,105,110,116,101,114, 32,119,105,116,104,
+     32, 97,110, 32,105,110,115,116, 97,110, 99,101, 32, 97,115,
+     32,100,101,102, 97,117,108,116, 32,112, 97,114, 97,109,101,
+    116,101,114, 46, 46, 32,105,115, 32,116,104, 97,116, 32,118,
+     97,108,105,100, 63, 10,  9,  9,  9,114,101,116,117,114,110,
+     32,116,114,117,101, 10,  9,  9,101,110,100, 10,  9,  9,114,
+    101,116,117,114,110, 32,102, 97,108,115,101, 32, 45, 45, 32,
+    100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 32,105,
+    115, 32, 39, 78, 85, 76, 76, 39, 32,111,114, 32,115,111,109,
+    101,116,104,105,110,103, 10,  9,101,110,100, 10, 10, 10,  9,
+    105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    112, 97,114, 44, 32, 34, 91, 37, 40, 38, 93, 34, 41, 32,116,
+    104,101,110, 10,  9,  9,114,101,116,117,114,110, 32,116,114,
+    117,101, 10,  9,101,110,100, 32, 45, 45, 32,100,101,102, 97,
+    117,108,116, 32,118, 97,108,117,101, 32,105,115, 32, 97, 32,
+     99,111,110,115,116,114,117, 99,116,111,114, 32, 99, 97,108,
+    108, 32, 40,109,111,115,116, 32,108,105,107,101,108,121, 32,
+    102,111,114, 32, 97, 32, 99,111,110,115,116, 32,114,101,102,
+    101,114,101,110, 99,101, 41, 10, 10,  9, 45, 45,105,102, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114,
+     44, 32, 34, 38, 34, 41, 32,116,104,101,110, 10, 10,  9, 45,
+     45,  9,105,102, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,100,101,102, 44, 32, 34, 58, 34, 41, 32,111,114, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,100,101,102,
+     44, 32, 34, 94, 37,115, 42,110,101,119, 37,115, 43, 34, 41,
+     32,116,104,101,110, 10, 10,  9, 45, 45,  9,  9, 45, 45, 32,
+    105,116, 39,115, 32, 97, 32,114,101,102,101,114,101,110, 99,
+    101, 32,119,105,116,104, 32,100,101,102, 97,117,108,116, 32,
+    116,111, 32,115,111,109,101,116,104,105,110,103, 32,108,105,
+    107,101, 32, 67,108, 97,115,115, 58, 58,109,101,109, 98,101,
+    114, 44, 32,111,114, 32, 39,110,101,119, 32, 67,108, 97,115,
+    115, 39, 10,  9, 45, 45,  9,  9,114,101,116,117,114,110, 32,
+    116,114,117,101, 10,  9, 45, 45,  9,101,110,100, 10,  9, 45,
+     45,101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,102,
+     97,108,115,101, 32, 45, 45, 32, 63, 10,101,110,100, 10, 10,
+    102,117,110, 99,116,105,111,110, 32,115,116,114,105,112, 95,
+    108, 97,115,116, 95, 97,114,103, 40, 97,108,108, 95, 97,114,
+    103,115, 44, 32,108, 97,115,116, 95, 97,114,103, 41, 32, 45,
+     45, 32,115,116,114,105,112,115, 32,116,104,101, 32,100,101,
+    102, 97,117,108,116, 32,118, 97,108,117,101, 32,102,114,111,
+    109, 32,116,104,101, 32,108, 97,115,116, 32, 97,114,103,117,
+    109,101,110,116, 10, 10,  9,108,111, 99, 97,108, 32, 95, 44,
+     95, 44,115, 95, 97,114,103, 32, 61, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40,108, 97,115,116, 95, 97,114,103,
+     44, 32, 34, 94, 40, 91, 94, 61, 93, 43, 41, 34, 41, 10,  9,
+    108, 97,115,116, 95, 97,114,103, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,108, 97,115,116, 95, 97,114,
+    103, 44, 32, 34, 40, 91, 37, 37, 37, 40, 37, 41, 93, 41, 34,
+     44, 32, 34, 37, 37, 37, 49, 34, 41, 59, 10,  9, 97,108,108,
+     95, 97,114,103,115, 32, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40, 97,108,108, 95, 97,114,103,115, 44, 32,
+     34, 37,115, 42, 44, 37,115, 42, 34, 46, 46,108, 97,115,116,
+     95, 97,114,103, 46, 46, 34, 37,115, 42, 37, 41, 37,115, 42,
+     36, 34, 44, 32, 34, 41, 34, 41, 10,  9,114,101,116,117,114,
+    110, 32, 97,108,108, 95, 97,114,103,115, 44, 32,115, 95, 97,
+    114,103, 10,101,110,100, 10, 10, 10, 10, 45, 45, 32, 73,110,
+    116,101,114,110, 97,108, 32, 99,111,110,115,116,114,117, 99,
+    116,111,114, 10,102,117,110, 99,116,105,111,110, 32, 95, 70,
+    117,110, 99,116,105,111,110, 32, 40,116, 41, 10, 32,115,101,
+    116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,108,
+     97,115,115, 70,117,110, 99,116,105,111,110, 41, 10, 10, 32,
+    105,102, 32,116, 46, 99,111,110,115,116, 32,126, 61, 32, 39,
+     99,111,110,115,116, 39, 32, 97,110,100, 32,116, 46, 99,111,
+    110,115,116, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 10,
+     32, 32,101,114,114,111,114, 40, 34, 35,105,110,118, 97,108,
+    105,100, 32, 39, 99,111,110,115,116, 39, 32,115,112,101, 99,
+    105,102,105, 99, 97,116,105,111,110, 34, 41, 10, 32,101,110,
+    100, 10, 10, 32, 97,112,112,101,110,100, 40,116, 41, 10, 32,
+    105,102, 32,116, 58,105,110, 99,108, 97,115,115, 40, 41, 32,
+    116,104,101,110, 10, 32, 45, 45,112,114,105,110,116, 32, 40,
+     39,116, 46,110, 97,109,101, 32,105,115, 32, 39, 46, 46,116,
+     46,110, 97,109,101, 46, 46, 39, 44, 32,112, 97,114,101,110,
+    116, 46,110, 97,109,101, 32,105,115, 32, 39, 46, 46,116, 46,
+    112, 97,114,101,110,116, 46,110, 97,109,101, 41, 10, 32, 32,
+    105,102, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,
+    116, 46,110, 97,109,101, 44, 32, 34, 37, 98, 60, 62, 34, 44,
+     32, 34, 34, 41, 32, 61, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40,116, 46,112, 97,114,101,110,116, 46,111,
+    114,105,103,105,110, 97,108, 95,110, 97,109,101, 32,111,114,
+     32,116, 46,112, 97,114,101,110,116, 46,110, 97,109,101, 44,
+     32, 34, 37, 98, 60, 62, 34, 44, 32, 34, 34, 41, 32,116,104,
+    101,110, 10, 32, 32, 32,116, 46,110, 97,109,101, 32, 61, 32,
+     39,110,101,119, 39, 10, 32, 32, 32,116, 46,108,110, 97,109,
+    101, 32, 61, 32, 39,110,101,119, 39, 10, 32, 32, 32,116, 46,
+    112, 97,114,101,110,116, 46, 95,110,101,119, 32, 61, 32,116,
+    114,117,101, 10, 32, 32, 32,116, 46,116,121,112,101, 32, 61,
+     32,116, 46,112, 97,114,101,110,116, 46,110, 97,109,101, 10,
+     32, 32, 32,116, 46,112,116,114, 32, 61, 32, 39, 42, 39, 10,
+     32, 32,101,108,115,101,105,102, 32,115,116,114,105,110,103,
+     46,103,115,117, 98, 40,116, 46,110, 97,109,101, 44, 32, 34,
+     37, 98, 60, 62, 34, 44, 32, 34, 34, 41, 32, 61, 61, 32, 39,
+    126, 39, 46, 46,115,116,114,105,110,103, 46,103,115,117, 98,
+     40,116, 46,112, 97,114,101,110,116, 46,111,114,105,103,105,
+    110, 97,108, 95,110, 97,109,101, 32,111,114, 32,116, 46,112,
+     97,114,101,110,116, 46,110, 97,109,101, 44, 32, 34, 37, 98,
+     60, 62, 34, 44, 32, 34, 34, 41, 32,116,104,101,110, 10, 32,
+     32, 32,116, 46,110, 97,109,101, 32, 61, 32, 39,100,101,108,
+    101,116,101, 39, 10, 32, 32, 32,116, 46,108,110, 97,109,101,
+     32, 61, 32, 39,100,101,108,101,116,101, 39, 10, 32, 32, 32,
+    116, 46,112, 97,114,101,110,116, 46, 95,100,101,108,101,116,
+    101, 32, 61, 32,116,114,117,101, 10, 32, 32,101,110,100, 10,
+     32,101,110,100, 10, 32,116, 46, 99,110, 97,109,101, 32, 61,
+     32,116, 58, 99,102,117,110, 99,110, 97,109,101, 40, 34,116,
+    111,108,117, 97, 34, 41, 46, 46,116, 58,111,118,101,114,108,
+    111, 97,100, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,
+    116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116,
+    114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99,
+    116,115, 32,116,104,114,101,101, 32,115,116,114,105,110,103,
+    115, 58, 32,111,110,101, 32,114,101,112,114,101,115,101,110,
+    116,105,110,103, 32,116,104,101, 32,102,117,110, 99,116,105,
+    111,110, 32,100,101, 99,108, 97,114, 97,116,105,111,110, 44,
+     10, 45, 45, 32, 97,110,111,116,104,101,114, 32,114,101,112,
+    114,101,115,101,110,116,105,110,103, 32,116,104,101, 32, 97,
+    114,103,117,109,101,110,116, 32,108,105,115,116, 44, 32, 97,
+    110,100, 32,116,104,101, 32,116,104,105,114,100, 32,114,101,
+    112,114,101,115,101,110,116,105,110,103, 10, 45, 45, 32,116,
+    104,101, 32, 34, 99,111,110,115,116, 34, 32,111,114, 32,101,
+    109,112,116,121, 32,115,116,114,105,110,103, 46, 10,102,117,
+    110, 99,116,105,111,110, 32, 70,117,110, 99,116,105,111,110,
+     32, 40,100, 44, 97, 44, 99, 41, 10, 32, 45, 45,108,111, 99,
+     97,108, 32,116, 32, 61, 32,115,112,108,105,116, 40,115,116,
+    114,115,117, 98, 40, 97, 44, 50, 44, 45, 50, 41, 44, 39, 44,
+     39, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 98,114, 97, 99,101,115, 10, 32, 45, 45,108,111, 99, 97,
+    108, 32,116, 32, 61, 32,115,112,108,105,116, 95,112, 97,114,
+     97,109,115, 40,115,116,114,115,117, 98, 40, 97, 44, 50, 44,
+     45, 50, 41, 41, 10, 10,  9,105,102, 32,110,111,116, 32,102,
+    108, 97,103,115, 91, 39, 87, 39, 93, 32, 97,110,100, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40, 97, 44, 32, 34,
+     37, 46, 37, 46, 37, 46, 37,115, 42, 37, 41, 34, 41, 32,116,
+    104,101,110, 10, 10,  9,  9,119, 97,114,110,105,110,103, 40,
+     34, 70,117,110, 99,116,105,111,110,115, 32,119,105,116,104,
+     32,118, 97,114,105, 97, 98,108,101, 32, 97,114,103,117,109,
+    101,110,116,115, 32, 40, 96, 46, 46, 46, 39, 41, 32, 97,114,
+    101, 32,110,111,116, 32,115,117,112,112,111,114,116,101,100,
+     46, 32, 73,103,110,111,114,105,110,103, 32, 34, 46, 46,100,
+     46, 46, 97, 46, 46, 99, 41, 10,  9,  9,114,101,116,117,114,
+    110, 32,110,105,108, 10,  9,101,110,100, 10, 10, 10, 32,108,
+    111, 99, 97,108, 32,105, 61, 49, 10, 32,108,111, 99, 97,108,
+     32,108, 32, 61, 32,123,110, 61, 48,125, 10, 10, 32,  9, 97,
+     32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,
+     97, 44, 32, 34, 37,115, 42, 40, 91, 37, 40, 37, 41, 93, 41,
+     37,115, 42, 34, 44, 32, 34, 37, 49, 34, 41, 10,  9,108,111,
+     99, 97,108, 32,116, 44,115,116,114,105,112, 44,108, 97,115,
+    116, 32, 61, 32,115,116,114,105,112, 95,112, 97,114,115, 40,
+    115,116,114,115,117, 98, 40, 97, 44, 50, 44, 45, 50, 41, 41,
+     59, 10,  9,105,102, 32,115,116,114,105,112, 32,116,104,101,
+    110, 10,  9,  9, 45, 45,108,111, 99, 97,108, 32,110,115, 32,
+     61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,115,116,
+    114,115,117, 98, 40, 97, 44, 49, 44, 45, 50, 41, 44, 32, 49,
+     44, 32, 45, 40,115,116,114,105,110,103, 46,108,101,110, 40,
+    108, 97,115,116, 41, 43, 49, 41, 41, 10,  9,  9,108,111, 99,
+     97,108, 32,110,115, 32, 61, 32,106,111,105,110, 40,116, 44,
+     32, 34, 44, 34, 44, 32, 49, 44, 32,108, 97,115,116, 45, 49,
+     41, 10, 10,  9,  9,110,115, 32, 61, 32, 34, 40, 34, 46, 46,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,110,115, 44,
+     32, 34, 37,115, 42, 44, 37,115, 42, 36, 34, 44, 32, 34, 34,
+     41, 46, 46, 39, 41, 39, 10,  9,  9, 45, 45,110,115, 32, 61,
+     32,115,116,114,105,112, 95,100,101,102, 97,117,108,116,115,
+     40,110,115, 41, 10, 10,  9,  9, 70,117,110, 99,116,105,111,
+    110, 40,100, 44, 32,110,115, 44, 32, 99, 41, 10,  9,  9,102,
+    111,114, 32,105, 61, 49, 44,108, 97,115,116, 32,100,111, 10,
+      9,  9,  9,116, 91,105, 93, 32, 61, 32,115,116,114,105,110,
+    103, 46,103,115,117, 98, 40,116, 91,105, 93, 44, 32, 34, 61,
+     46, 42, 36, 34, 44, 32, 34, 34, 41, 10,  9,  9,101,110,100,
+     10,  9,101,110,100, 10, 10, 32,119,104,105,108,101, 32,116,
+     91,105, 93, 32,100,111, 10, 32, 32,108, 46,110, 32, 61, 32,
+    108, 46,110, 43, 49, 10, 32, 32,108, 91,108, 46,110, 93, 32,
+     61, 32, 68,101, 99,108, 97,114, 97,116,105,111,110, 40,116,
+     91,105, 93, 44, 39,118, 97,114, 39, 44,116,114,117,101, 41,
+     10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100,
+     10, 32,108,111, 99, 97,108, 32,102, 32, 61, 32, 68,101, 99,
+    108, 97,114, 97,116,105,111,110, 40,100, 44, 39,102,117,110,
+     99, 39, 41, 10, 32,102, 46, 97,114,103,115, 32, 61, 32,108,
+     10, 32,102, 46, 99,111,110,115,116, 32, 61, 32, 99, 10, 32,
+    114,101,116,117,114,110, 32, 95, 70,117,110, 99,116,105,111,
+    110, 40,102, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,
+    105,111,110, 32,106,111,105,110, 40,116, 44, 32,115,101,112,
+     44, 32,102,105,114,115,116, 44, 32,108, 97,115,116, 41, 10,
+     10,  9,102,105,114,115,116, 32, 61, 32,102,105,114,115,116,
+     32,111,114, 32, 49, 10,  9,108, 97,115,116, 32, 61, 32,108,
+     97,115,116, 32,111,114, 32,116, 97, 98,108,101, 46,103,101,
+    116,110, 40,116, 41, 10,  9,108,111, 99, 97,108, 32,108,115,
+    101,112, 32, 61, 32, 34, 34, 10,  9,108,111, 99, 97,108, 32,
+    114,101,116, 32, 61, 32, 34, 34, 10,  9,108,111, 99, 97,108,
+     32,108,111,111,112, 32, 61, 32,102, 97,108,115,101, 10,  9,
+    102,111,114, 32,105, 32, 61, 32,102,105,114,115,116, 44,108,
+     97,115,116, 32,100,111, 10, 10,  9,  9,114,101,116, 32, 61,
+     32,114,101,116, 46, 46,108,115,101,112, 46, 46,116, 91,105,
+     93, 10,  9,  9,108,115,101,112, 32, 61, 32,115,101,112, 10,
+      9,  9,108,111,111,112, 32, 61, 32,116,114,117,101, 10,  9,
+    101,110,100, 10,  9,105,102, 32,110,111,116, 32,108,111,111,
+    112, 32,116,104,101,110, 10,  9,  9,114,101,116,117,114,110,
+     32, 34, 34, 10,  9,101,110,100, 10, 10,  9,114,101,116,117,
+    114,110, 32,114,101,116, 10,101,110,100, 10, 10,102,117,110,
+     99,116,105,111,110, 32,115,116,114,105,112, 95,112, 97,114,
+    115, 40,115, 41, 10, 10,  9,108,111, 99, 97,108, 32,116, 32,
+     61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110,
+    115, 40,115, 44, 32, 39, 44, 39, 41, 10,  9,108,111, 99, 97,
+    108, 32,115,116,114,105,112, 32, 61, 32,102, 97,108,115,101,
+     10,  9,108,111, 99, 97,108, 32,108, 97,115,116, 10, 10,  9,
+    102,111,114, 32,105, 61,116, 46,110, 44, 49, 44, 45, 49, 32,
+    100,111, 10, 10,  9,  9,105,102, 32,110,111,116, 32,115,116,
+    114,105,112, 32, 97,110,100, 32,112, 97,114, 97,109, 95,111,
+     98,106,101, 99,116, 40,116, 91,105, 93, 41, 32,116,104,101,
+    110, 10,  9,  9,  9,108, 97,115,116, 32, 61, 32,105, 10,  9,
+      9,  9,115,116,114,105,112, 32, 61, 32,116,114,117,101, 10,
+      9,  9,101,110,100, 10,  9,  9, 45, 45,105,102, 32,115,116,
+    114,105,112, 32,116,104,101,110, 10,  9,  9, 45, 45,  9,116,
+     91,105, 93, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40,116, 91,105, 93, 44, 32, 34, 61, 46, 42, 36, 34,
+     44, 32, 34, 34, 41, 10,  9,  9, 45, 45,101,110,100, 10,  9,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,116, 44,
+    115,116,114,105,112, 44,108, 97,115,116, 10, 10,101,110,100,
+     10, 10,102,117,110, 99,116,105,111,110, 32,115,116,114,105,
+    112, 95,100,101,102, 97,117,108,116,115, 40,115, 41, 10, 10,
+      9,115, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40,115, 44, 32, 34, 94, 37, 40, 34, 44, 32, 34, 34, 41,
+     10,  9,115, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40,115, 44, 32, 34, 37, 41, 36, 34, 44, 32, 34, 34,
+     41, 10, 10,  9,108,111, 99, 97,108, 32,116, 32, 61, 32,115,
+    112,108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115,
+     44, 32, 34, 44, 34, 41, 10,  9,108,111, 99, 97,108, 32,115,
+    101,112, 44, 32,114,101,116, 32, 61, 32, 34, 34, 44, 34, 34,
+     10,  9,102,111,114, 32,105, 61, 49, 44,116, 46,110, 32,100,
+    111, 10,  9,  9,116, 91,105, 93, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,116, 91,105, 93, 44, 32, 34,
+     61, 46, 42, 36, 34, 44, 32, 34, 34, 41, 10,  9,  9,114,101,
+    116, 32, 61, 32,114,101,116, 46, 46,115,101,112, 46, 46,116,
+     91,105, 93, 10,  9,  9,115,101,112, 32, 61, 32, 34, 44, 34,
+     10,  9,101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,
+     34, 40, 34, 46, 46,114,101,116, 46, 46, 34, 41, 34, 10,101,
+    110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/function.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,111,112,101,114, 97,
+    116,111,114, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45,
+     32, 79,112,101,114, 97,116,111,114, 32, 99,108, 97,115,115,
+     10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32,
+     97,110, 32,111,112,101,114, 97,116,111,114, 32,102,117,110,
+     99,116,105,111,110, 32,111,114, 32, 97, 32, 99,108, 97,115,
+    115, 32,111,112,101,114, 97,116,111,114, 32,109,101,116,104,
+    111,100, 46, 10, 45, 45, 32, 73,116, 32,115,116,111,114,101,
+    115, 32,116,104,101, 32,115, 97,109,101, 32,102,105,101,108,
+    100,115, 32, 97,115, 32,102,117,110, 99,116,105,111,110,115,
+     32,100,111, 32,112,108,117,115, 58, 10, 45, 45, 32, 32,107,
+    105,110,100, 32, 61, 32,115,101,116, 32,111,102, 32, 99,104,
+     97,114, 97, 99,116,101,114, 32,114,101,112,114,101,115,101,
+    110,116,105,110,103, 32,116,104,101, 32,111,112,101,114, 97,
+    116,111,114, 32, 40, 97,115, 32,105,116, 32, 97,112,112,101,
+    114,115, 32,105,110, 32, 67, 43, 43, 32, 99,111,100,101, 41,
+     10, 99,108, 97,115,115, 79,112,101,114, 97,116,111,114, 32,
+     61, 32,123, 10, 32,107,105,110,100, 32, 61, 32, 39, 39, 44,
+     10,125, 10, 99,108, 97,115,115, 79,112,101,114, 97,116,111,
+    114, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,
+    115,115, 79,112,101,114, 97,116,111,114, 10,115,101,116,109,
+    101,116, 97,116, 97, 98,108,101, 40, 99,108, 97,115,115, 79,
+    112,101,114, 97,116,111,114, 44, 99,108, 97,115,115, 70,117,
+    110, 99,116,105,111,110, 41, 10, 10, 45, 45, 32,116, 97, 98,
+    108,101, 32,116,111, 32,116,114, 97,110,115,102,111,114,109,
+     32,111,112,101,114, 97,116,111,114, 32,107,105,110,100, 32,
+    105,110,116,111, 32,116,104,101, 32, 97,112,112,114,111,112,
+    114,105, 97,116,101, 32,116, 97,103, 32,109,101,116,104,111,
+    100, 32,110, 97,109,101, 10, 95, 84, 77, 32, 61, 32,123, 91,
+     39, 43, 39, 93, 32, 61, 32, 39, 97,100,100, 39, 44, 10, 32,
+     32, 32, 32, 32, 32, 32, 91, 39, 45, 39, 93, 32, 61, 32, 39,
+    115,117, 98, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39,
+     42, 39, 93, 32, 61, 32, 39,109,117,108, 39, 44, 10, 32, 32,
+     32, 32, 32, 32, 32, 91, 39, 47, 39, 93, 32, 61, 32, 39,100,
+    105,118, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 60,
+     39, 93, 32, 61, 32, 39,108,116, 39, 44, 10, 32, 32, 32, 32,
+     32, 32, 32, 91, 39, 60, 61, 39, 93, 32, 61, 32, 39,108,101,
+     39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 61, 61, 39,
+     93, 32, 61, 32, 39,101,113, 39, 44, 10, 32, 32, 32, 32, 32,
+     32, 32, 91, 39, 91, 93, 39, 93, 32, 61, 32, 39,103,101,116,
+    105, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 38, 91,
+     93, 39, 93, 32, 61, 32, 39,115,101,116,105, 39, 44, 10, 32,
+     32, 32, 32, 32, 32, 32, 45, 45, 91, 39, 45, 62, 39, 93, 32,
+     61, 32, 39,102,108,101, 99,104,105,116, 97, 39, 44, 10, 32,
+     32, 32, 32, 32, 32,125, 10, 10, 10, 45, 45, 32, 80,114,105,
+    110,116, 32,109,101,116,104,111,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 79,112,101,114, 97,116,
+    111,114, 58,112,114,105,110,116, 32, 40,105,100,101,110,116,
+     44, 99,108,111,115,101, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 79,112,101,114, 97,116,111,
+    114,123, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,107,105,110,100, 32, 32, 61, 32, 39,
+     34, 46, 46,115,101,108,102, 46,107,105,110,100, 46, 46, 34,
+     39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44,
+     34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116,
+     46, 46, 34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34,
+     41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+     99,111,110,115,116, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46, 99,111,110,115,116, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32, 99,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,
+    108,102, 46, 99,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41,
+     10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34, 32,108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34,
+     41, 10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32, 97,114,103,115, 32, 61, 32,123, 34, 41, 10, 32,
+    108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,
+    101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,
+    100,111, 10, 32, 32,115,101,108,102, 46, 97,114,103,115, 91,
+    105, 93, 58,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32,
+     61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 32,125, 34, 41,
+     10, 32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100,
+     10, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 79,112,101,114, 97,116,111,114, 58,115,117,112, 99,111,
+    100,101, 95,116,109,112, 40, 41, 10, 10,  9,105,102, 32,110,
+    111,116, 32, 95, 84, 77, 91,115,101,108,102, 46,107,105,110,
+    100, 93, 32,116,104,101,110, 10,  9,  9,114,101,116,117,114,
+    110, 32, 99,108, 97,115,115, 70,117,110, 99,116,105,111,110,
+     46,115,117,112, 99,111,100,101, 40,115,101,108,102, 41, 10,
+      9,101,110,100, 10, 10,  9, 45, 45, 32,110,111, 32,111,118,
+    101,114,108,111, 97,100, 44, 32,110,111, 32,112, 97,114, 97,
+    109,101,116,101,114,115, 44, 32, 97,108,119, 97,121,115, 32,
+    105,110, 99,108, 97,115,115, 10,  9,111,117,116,112,117,116,
+     40, 34, 47, 42, 32,109,101,116,104,111,100, 58, 34, 44,115,
+    101,108,102, 46,110, 97,109,101, 44, 34, 32,111,102, 32, 99,
+    108, 97,115,115, 32, 34, 44,115,101,108,102, 58,105,110, 99,
+    108, 97,115,115, 40, 41, 44, 34, 32, 42, 47, 34, 41, 10, 10,
+      9,111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101,
+    102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69,
+     95, 34, 46, 46,115,101,108,102, 46, 99,110, 97,109,101, 41,
+     10,  9,111,117,116,112,117,116, 40, 34, 92,110,115,116, 97,
+    116,105, 99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99,
+    110, 97,109,101, 44, 34, 40,108,117, 97, 95, 83,116, 97,116,
+    101, 42, 32,116,111,108,117, 97, 95, 83, 41, 34, 41, 10, 10,
+      9,105,102, 32,111,118,101,114,108,111, 97,100, 32, 60, 32,
+     48, 32,116,104,101,110, 10,  9, 32,111,117,116,112,117,116,
+     40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65,
+     95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,  9,101,
+    110,100, 10,  9,111,117,116,112,117,116, 40, 39, 32,116,111,
+    108,117, 97, 95, 69,114,114,111,114, 32,116,111,108,117, 97,
+     95,101,114,114, 59, 39, 41, 10,  9,111,117,116,112,117,116,
+     40, 39, 32,105,102, 32, 40, 92,110, 39, 41, 10,  9, 45, 45,
+     32, 99,104,101, 99,107, 32,115,101,108,102, 10,  9,111,117,
+    116,112,117,116, 40, 39, 32, 32, 32, 32, 32, 33, 39, 46, 46,
+     39,116,111,108,117, 97, 95,105,115,117,115,101,114,116,121,
+    112,101, 40,116,111,108,117, 97, 95, 83, 44, 49, 44, 34, 39,
+     46, 46,115,101,108,102, 46,112, 97,114,101,110,116, 46,116,
+    121,112,101, 46, 46, 39, 34, 44, 48, 44, 38,116,111,108,117,
+     97, 95,101,114,114, 41, 32,124,124, 92,110, 39, 41, 10,  9,
+    111,117,116,112,117,116, 40, 39, 32, 32, 32, 32, 32, 33,116,
+    111,108,117, 97, 95,105,115,110,111,111, 98,106, 40,116,111,
+    108,117, 97, 95, 83, 44, 50, 44, 38,116,111,108,117, 97, 95,
+    101,114,114, 41, 92,110, 32, 41, 39, 41, 10,  9,111,117,116,
+    112,117,116, 40, 39, 32, 32,103,111,116,111, 32,116,111,108,
+    117, 97, 95,108,101,114,114,111,114, 59, 39, 41, 10, 10,  9,
+    111,117,116,112,117,116, 40, 39, 32,101,108,115,101, 92,110,
+     39, 41, 10,  9,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 32, 45, 45, 32,116,111,108,117,
+     97, 95,114,101,108,101, 97,115,101, 10,  9,111,117,116,112,
+    117,116, 40, 39, 32,123, 39, 41, 10, 10,  9, 45, 45, 32,100,
+    101, 99,108, 97,114,101, 32,115,101,108,102, 10,  9,111,117,
+    116,112,117,116, 40, 39, 32, 39, 44,115,101,108,102, 46, 99,
+    111,110,115,116, 44,115,101,108,102, 46,112, 97,114,101,110,
+    116, 46,116,121,112,101, 44, 39, 42, 39, 44, 39,115,101,108,
+    102, 32, 61, 32, 39, 41, 10,  9,111,117,116,112,117,116, 40,
+     39, 40, 39, 44,115,101,108,102, 46, 99,111,110,115,116, 44,
+    115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,
+    101, 44, 39, 42, 41, 32, 39, 41, 10,  9,111,117,116,112,117,
+    116, 40, 39,116,111,108,117, 97, 95,116,111,117,115,101,114,
+    116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 49, 44,
+     48, 41, 59, 39, 41, 10, 10,  9, 45, 45, 32, 99,104,101, 99,
+    107, 32,115,101,108,102, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95,
+     82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,  9,111,117,
+    116,112,117,116, 40, 39, 32, 32,105,102, 32, 40, 33,115,101,
+    108,102, 41, 32,116,111,108,117, 97, 95,101,114,114,111,114,
+     40,116,111,108,117, 97, 95, 83, 44, 34,105,110,118, 97,108,
+    105,100, 32, 92, 39,115,101,108,102, 92, 39, 32,105,110, 32,
+    102,117,110, 99,116,105,111,110, 32, 92, 39, 39, 46, 46,115,
+    101,108,102, 46,110, 97,109,101, 46, 46, 39, 92, 39, 34, 44,
+     78, 85, 76, 76, 41, 59, 39, 41, 59, 10,  9,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+     10,  9, 45, 45, 32, 99, 97,115,116, 32,115,101,108,102, 10,
+      9,111,117,116,112,117,116, 40, 39, 32, 32, 39, 44,115,101,
+    108,102, 46,109,111,100, 44,115,101,108,102, 46,116,121,112,
+    101, 44,115,101,108,102, 46,112,116,114, 44, 39,116,111,108,
+    117, 97, 95,114,101,116, 32, 61, 32, 39, 41, 10,  9,111,117,
+    116,112,117,116, 40, 39, 40, 39, 44,115,101,108,102, 46,109,
+    111,100, 44,115,101,108,102, 46,116,121,112,101, 44,115,101,
+    108,102, 46,112,116,114, 44, 39, 41, 40, 42,115,101,108,102,
+     41, 59, 39, 41, 10, 10,  9, 45, 45, 32,114,101,116,117,114,
+    110, 32,118, 97,108,117,101, 10,  9,108,111, 99, 97,108, 32,
+    116, 44, 99,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,
+    115,101,108,102, 46,116,121,112,101, 41, 10,  9,105,102, 32,
+    116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 32, 32,116,111,108,117, 97, 95,112,117,115,104,
+     39, 46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83,
+     44, 40, 39, 44, 99,116, 44, 39, 41,116,111,108,117, 97, 95,
+    114,101,116, 41, 59, 39, 41, 10,  9,101,108,115,101, 10,  9,
+      9,116, 32, 61, 32,115,101,108,102, 46,116,121,112,101, 10,
+      9,  9,110,101,119, 95,116, 32, 61, 32,115,116,114,105,110,
+    103, 46,103,115,117, 98, 40,116, 44, 32, 34, 99,111,110,115,
+    116, 37,115, 43, 34, 44, 32, 34, 34, 41, 10,  9,  9,105,102,
+     32,115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 39,
+     32,116,104,101,110, 10,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 32, 32,123, 39, 41, 10,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39, 35,105,102,100,101,102, 32, 95, 95, 99,
+    112,108,117,115,112,108,117,115, 92,110, 39, 41, 10,  9,  9,
+      9,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,118,111,
+    105,100, 42, 32,116,111,108,117, 97, 95,111, 98,106, 32, 61,
+     32,110,101,119, 39, 44,110,101,119, 95,116, 44, 39, 40,116,
+    111,108,117, 97, 95,114,101,116, 41, 59, 39, 41, 10,  9,  9,
+      9,111,117,116,112,117,116, 40, 39, 32, 32, 32, 32,116,111,
+    108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,
+    101, 95, 97,110,100, 95,116, 97,107,101,111,119,110,101,114,
+    115,104,105,112, 40,116,111,108,117, 97, 95, 83, 44,116,111,
+    108,117, 97, 95,111, 98,106, 44, 34, 39, 44,116, 44, 39, 34,
+     41, 59, 39, 41, 10,  9,  9,  9,111,117,116,112,117,116, 40,
+     39, 35,101,108,115,101, 92,110, 39, 41, 10,  9,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 32, 32, 32,118,111,105,100,
+     42, 32,116,111,108,117, 97, 95,111, 98,106, 32, 61, 32,116,
+    111,108,117, 97, 95, 99,111,112,121, 40,116,111,108,117, 97,
+     95, 83, 44, 40,118,111,105,100, 42, 41, 38,116,111,108,117,
+     97, 95,114,101,116, 44,115,105,122,101,111,102, 40, 39, 44,
+    116, 44, 39, 41, 41, 59, 39, 41, 10,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32, 32,116,111,108,117, 97, 95,
+    112,117,115,104,117,115,101,114,116,121,112,101, 95, 97,110,
+    100, 95,116, 97,107,101,111,119,110,101,114,115,104,105,112,
+     40,116,111,108,117, 97, 95, 83, 44,116,111,108,117, 97, 95,
+    111, 98,106, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41,
+     10,  9,  9,  9,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10,  9,  9,  9,111,117,116,112,
+    117,116, 40, 39, 32, 32, 32,125, 39, 41, 10,  9,  9,101,108,
+    115,101,105,102, 32,115,101,108,102, 46,112,116,114, 32, 61,
+     61, 32, 39, 38, 39, 32,116,104,101,110, 10,  9,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 32, 32,116,111,108,117, 97,
+     95,112,117,115,104,117,115,101,114,116,121,112,101, 40,116,
+    111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, 38,
+    116,111,108,117, 97, 95,114,101,116, 44, 34, 39, 44,116, 44,
+     39, 34, 41, 59, 39, 41, 10,  9,  9,101,108,115,101, 10,  9,
+      9,  9,105,102, 32,108,111, 99, 97,108, 95, 99,111,110,115,
+    116,114,117, 99,116,111,114, 32,116,104,101,110, 10,  9,  9,
+      9,  9,111,117,116,112,117,116, 40, 39, 32, 32, 32,116,111,
+    108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,
+    101, 95, 97,110,100, 95,116, 97,107,101,111,119,110,101,114,
+    115,104,105,112, 40,116,111,108,117, 97, 95, 83, 44, 40,118,
+    111,105,100, 32, 42, 41,116,111,108,117, 97, 95,114,101,116,
+     44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10,  9,  9,
+      9,101,108,115,101, 10,  9,  9,  9,  9,111,117,116,112,117,
+    116, 40, 39, 32, 32, 32,116,111,108,117, 97, 95,112,117,115,
+    104,117,115,101,114,116,121,112,101, 40,116,111,108,117, 97,
+     95, 83, 44, 40,118,111,105,100, 42, 41,116,111,108,117, 97,
+     95,114,101,116, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39,
+     41, 10,  9,  9,  9,101,110,100, 10,  9,  9,101,110,100, 10,
+      9,101,110,100, 10, 10,  9,111,117,116,112,117,116, 40, 39,
+     32, 32,125, 39, 41, 10,  9,111,117,116,112,117,116, 40, 39,
+     32,114,101,116,117,114,110, 32, 49, 59, 39, 41, 10, 10,  9,
+    111,117,116,112,117,116, 40, 39, 35,105,102,110,100,101,102,
+     32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,
+    110, 39, 41, 10,  9,111,117,116,112,117,116, 40, 39,116,111,
+    108,117, 97, 95,108,101,114,114,111,114, 58, 92,110, 39, 41,
+     10,  9,111,117,116,112,117,116, 40, 39, 32,116,111,108,117,
+     97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 35,102,101,114,114,111,114, 32,105,110, 32,102,117,
+    110, 99,116,105,111,110, 32, 92, 39, 39, 46, 46,115,101,108,
+    102, 46,108,110, 97,109,101, 46, 46, 39, 92, 39, 46, 34, 44,
+     38,116,111,108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10,
+      9,111,117,116,112,117,116, 40, 39, 32,114,101,116,117,114,
+    110, 32, 48, 59, 39, 41, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 10, 10,  9,
+    111,117,116,112,117,116, 40, 39,125, 39, 41, 10,  9,111,117,
+    116,112,117,116, 40, 39, 35,101,110,100,105,102, 32, 47, 47,
+     35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68,
+     73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10,  9,111,117,116,
+    112,117,116, 40, 39, 92,110, 39, 41, 10,101,110,100, 10, 10,
+     45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,
+    115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116,105,
+    111,110, 32, 95, 79,112,101,114, 97,116,111,114, 32, 40,116,
+     41, 10, 32,115,101,116,109,101,116, 97,116, 97, 98,108,101,
+     40,116, 44, 99,108, 97,115,115, 79,112,101,114, 97,116,111,
+    114, 41, 10, 10, 32,105,102, 32,116, 46, 99,111,110,115,116,
+     32,126, 61, 32, 39, 99,111,110,115,116, 39, 32, 97,110,100,
+     32,116, 46, 99,111,110,115,116, 32,126, 61, 32, 39, 39, 32,
+    116,104,101,110, 10, 32, 32,101,114,114,111,114, 40, 34, 35,
+    105,110,118, 97,108,105,100, 32, 39, 99,111,110,115,116, 39,
+     32,115,112,101, 99,105,102,105, 99, 97,116,105,111,110, 34,
+     41, 10, 32,101,110,100, 10, 10, 32, 97,112,112,101,110,100,
+     40,116, 41, 10, 32,105,102, 32,110,111,116, 32,116, 58,105,
+    110, 99,108, 97,115,115, 40, 41, 32,116,104,101,110, 10, 32,
+     32,101,114,114,111,114, 40, 34, 35,111,112,101,114, 97,116,
+    111,114, 32, 99, 97,110, 32,111,110,108,121, 32, 98,101, 32,
+    100,101,102,105,110,101,100, 32, 97,115, 32, 99,108, 97,115,
+    115, 32,109,101,109, 98,101,114, 34, 41, 10, 32,101,110,100,
+     10, 10, 32, 45, 45,116, 46,110, 97,109,101, 32, 61, 32,116,
+     46,110, 97,109,101, 32, 46, 46, 32, 34, 95, 34, 32, 46, 46,
+     32, 40, 95, 84, 77, 91,116, 46,107,105,110,100, 93, 32,111,
+    114, 32,116, 46,107,105,110,100, 41, 10, 32,116, 46, 99,110,
+     97,109,101, 32, 61, 32,116, 58, 99,102,117,110, 99,110, 97,
+    109,101, 40, 34,116,111,108,117, 97, 34, 41, 46, 46,116, 58,
+    111,118,101,114,108,111, 97,100, 40,116, 41, 10, 32,116, 46,
+    110, 97,109,101, 32, 61, 32, 34,111,112,101,114, 97,116,111,
+    114, 34, 32, 46, 46, 32,116, 46,107,105,110,100, 32, 32, 45,
+     45, 32,115,101,116, 32, 97,112,112,114,111,112,114,105, 97,
+    116,101, 32, 99, 97,108,108,105,110,103, 32,110, 97,109,101,
+     10, 32,114,101,116,117,114,110, 32,116, 10,101,110,100, 10,
+     10, 45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114,
+     10,102,117,110, 99,116,105,111,110, 32, 79,112,101,114, 97,
+    116,111,114, 32, 40,100, 44,107, 44, 97, 44, 99, 41, 10, 10,
+      9,108,111, 99, 97,108, 32,111,112, 95,107, 32, 61, 32,115,
+    116,114,105,110,103, 46,103,115,117, 98, 40,107, 44, 32, 34,
+     94, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,  9,111,112, 95,
+    107, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98,
+     40,107, 44, 32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, 41,
+     10,  9, 45, 45,105,102, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,107, 44, 32, 34, 94, 91, 37,119, 95, 58, 37,
+    100, 60, 62, 37, 42, 37, 38, 93, 43, 36, 34, 41, 32,116,104,
+    101,110, 10,  9,105,102, 32,100, 32, 61, 61, 32, 34,111,112,
+    101,114, 97,116,111,114, 34, 32, 97,110,100, 32,107, 32,126,
+     61, 32, 39, 39, 32,116,104,101,110, 10, 10,  9,  9,100, 32,
+     61, 32,107, 46, 46, 34, 32,111,112,101,114, 97,116,111,114,
+     34, 10,  9,101,108,115,101,105,102, 32,110,111,116, 32, 95,
+     84, 77, 91,111,112, 95,107, 93, 32,116,104,101,110, 10, 10,
+      9,  9,105,102, 32,102,108, 97,103,115, 91, 39, 87, 39, 93,
+     32,116,104,101,110, 10,  9,  9,  9,101,114,114,111,114, 40,
+     34,116,111,108,117, 97, 58, 32,110,111, 32,115,117,112,112,
+    111,114,116, 32,102,111,114, 32,111,112,101,114, 97,116,111,
+    114, 34, 32, 46, 46, 32,102, 46,107,105,110,100, 41, 10,  9,
+      9,101,108,115,101, 10,  9,  9,  9,119, 97,114,110,105,110,
+    103, 40, 34, 78,111, 32,115,117,112,112,111,114,116, 32,102,
+    111,114, 32,111,112,101,114, 97,116,111,114, 32, 34, 46, 46,
+    111,112, 95,107, 46, 46, 34, 44, 32,105,103,110,111,114,105,
+    110,103, 34, 41, 10,  9,  9,  9,114,101,116,117,114,110, 32,
+    110,105,108, 10,  9,  9,101,110,100, 10,  9,101,110,100, 10,
+     10,  9,108,111, 99, 97,108, 32,114,101,102, 32, 61, 32, 39,
+     39, 10, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,
+    108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115,116,
+    114,115,117, 98, 40, 97, 44, 50, 44,115,116,114,108,101,110,
+     40, 97, 41, 45, 49, 41, 44, 39, 44, 39, 41, 32, 45, 45, 32,
+    101,108,105,109,105,110, 97,116,101, 32, 98,114, 97, 99,101,
+    115, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,108,
+    111, 99, 97,108, 32,108, 32, 61, 32,123,110, 61, 48,125, 10,
+     32,119,104,105,108,101, 32,116, 91,105, 93, 32,100,111, 10,
+     32, 32,108, 46,110, 32, 61, 32,108, 46,110, 43, 49, 10, 32,
+     32,108, 91,108, 46,110, 93, 32, 61, 32, 68,101, 99,108, 97,
+    114, 97,116,105,111,110, 40,116, 91,105, 93, 44, 39,118, 97,
+    114, 39, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,
+    101,110,100, 10, 32,105,102, 32,107, 32, 61, 61, 32, 39, 91,
+     93, 39, 32,116,104,101,110, 10,  9, 32,108,111, 99, 97,108,
+     32, 95, 10,  9, 32, 95, 44, 32, 95, 44, 32,114,101,102, 32,
+     61, 32,115,116,114,102,105,110,100, 40,100, 44, 39, 40, 38,
+     41, 39, 41, 10, 32, 32,100, 32, 61, 32,103,115,117, 98, 40,
+    100, 44, 39, 38, 39, 44, 39, 39, 41, 10, 32,101,108,115,101,
+    105,102, 32,107, 61, 61, 39, 38, 91, 93, 39, 32,116,104,101,
+    110, 10, 32, 32,108, 46,110, 32, 61, 32,108, 46,110, 43, 49,
+     10, 32, 32,108, 91,108, 46,110, 93, 32, 61, 32, 68,101, 99,
+    108, 97,114, 97,116,105,111,110, 40,100, 44, 39,118, 97,114,
+     39, 41, 10, 32, 32,108, 91,108, 46,110, 93, 46,110, 97,109,
+    101, 32, 61, 32, 39,116,111,108,117, 97, 95,118, 97,108,117,
+    101, 39, 10, 32,101,110,100, 10, 32,108,111, 99, 97,108, 32,
+    102, 32, 61, 32, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     40,100, 44, 39,102,117,110, 99, 39, 41, 10, 32,105,102, 32,
+    107, 32, 61, 61, 32, 39, 91, 93, 39, 32, 97,110,100, 32, 40,
+    108, 91, 49, 93, 61, 61,110,105,108, 32,111,114, 32,105,115,
+     98, 97,115,105, 99, 40,108, 91, 49, 93, 46,116,121,112,101,
+     41,126, 61, 39,110,117,109, 98,101,114, 39, 41, 32,116,104,
+    101,110, 10, 32, 32,101,114,114,111,114, 40, 39,111,112,101,
+    114, 97,116,111,114, 91, 93, 32, 99, 97,110, 32,111,110,108,
+    121, 32, 98,101, 32,100,101,102,105,110,101,100, 32,102,111,
+    114, 32,110,117,109,101,114,105, 99, 32,105,110,100,101,120,
+     46, 39, 41, 10, 32,101,110,100, 10, 32,102, 46, 97,114,103,
+    115, 32, 61, 32,108, 10, 32,102, 46, 99,111,110,115,116, 32,
+     61, 32, 99, 10, 32,102, 46,107,105,110,100, 32, 61, 32,111,
+    112, 95,107, 10, 32,102, 46,108,110, 97,109,101, 32, 61, 32,
+     34, 46, 34, 46, 46, 40, 95, 84, 77, 91,102, 46,107,105,110,
+    100, 93, 32,111,114, 32,102, 46,107,105,110,100, 41, 10, 32,
+    105,102, 32,110,111,116, 32, 95, 84, 77, 91,102, 46,107,105,
+    110,100, 93, 32,116,104,101,110, 10, 32,  9,102, 46, 99, 97,
+    115,116, 95,111,112,101,114, 97,116,111,114, 32, 61, 32,116,
+    114,117,101, 10, 32,101,110,100, 10, 32,105,102, 32,102, 46,
+    107,105,110,100, 32, 61, 61, 32, 39, 91, 93, 39, 32, 97,110,
+    100, 32,114,101,102, 61, 61, 39, 38, 39, 32, 97,110,100, 32,
+    102, 46, 99,111,110,115,116,126, 61, 39, 99,111,110,115,116,
+     39, 32,116,104,101,110, 10, 32, 32, 79,112,101,114, 97,116,
+    111,114, 40,100, 44, 39, 38, 39, 46, 46,107, 44, 97, 44, 99,
+     41, 32,  9, 45, 45, 32, 99,114,101, 97,116,101, 32, 99,111,
+    114,114,101,115,112,111,100,105,110,103, 32,115,101,116, 32,
+    111,112,101,114, 97,116,111,114, 10, 32,101,110,100, 10, 32,
+    114,101,116,117,114,110, 32, 95, 79,112,101,114, 97,116,111,
+    114, 40,102, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/operator.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 99,108, 97,115,115,
+     32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,
+    101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32,
+     67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,
+    102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,
+    108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32,
+     36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101,
+     32,105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,
+    114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,
+    105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,
+    100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46,
+     10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,
+    101, 32,112,114,111,118,105,100,101,100, 32,104,101,114,101,
+    117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32,
+     34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32,
+     97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,
+    111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103,
+     97,116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,
+    101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,
+    115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,
+    115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,
+    110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99,
+     97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, 32, 67,108,
+     97,115,115, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,
+    112,114,101,115,101,110,116,115, 32, 97, 32, 99,108, 97,115,
+    115, 32,100,101,102,105,110,105,116,105,111,110, 46, 10, 45,
+     45, 32, 83,116,111,114,101,115, 32,116,104,101, 32,102,111,
+    108,108,111,119,105,110,103, 32,102,105,101,108,100,115, 58,
+     10, 45, 45, 32, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,
+    108, 97,115,115, 32,110, 97,109,101, 10, 45, 45, 32, 32, 32,
+     32, 98, 97,115,101, 32, 61, 32, 99,108, 97,115,115, 32, 98,
+     97,115,101, 44, 32,105,102, 32, 97,110,121, 32, 40,111,110,
+    108,121, 32,115,105,110,103,108,101, 32,105,110,104,101,114,
+    105,116, 97,110, 99,101, 32,105,115, 32,115,117,112,112,111,
+    114,116,101,100, 41, 10, 45, 45, 32, 32, 32, 32,123,105,125,
+     32, 32, 61, 32,108,105,115,116, 32,111,102, 32,109,101,109,
+     98,101,114,115, 10, 99,108, 97,115,115, 67,108, 97,115,115,
+     32, 61, 32,123, 10, 32, 99,108, 97,115,115,116,121,112,101,
+     32, 61, 32, 39, 99,108, 97,115,115, 39, 44, 10, 32,110, 97,
+    109,101, 32, 61, 32, 39, 39, 44, 10, 32, 98, 97,115,101, 32,
+     61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39,
+     39, 44, 10, 32, 98,116,121,112,101, 32, 61, 32, 39, 39, 44,
+     10, 32, 99,116,121,112,101, 32, 61, 32, 39, 39, 44, 10,125,
+     10, 99,108, 97,115,115, 67,108, 97,115,115, 46, 95, 95,105,
+    110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 67,108, 97,
+    115,115, 10,115,101,116,109,101,116, 97,116, 97, 98,108,101,
+     40, 99,108, 97,115,115, 67,108, 97,115,115, 44, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 41, 10, 10, 10,
+     45, 45, 32,114,101,103,105,115,116,101,114, 32, 99,108, 97,
+    115,115, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 67,108, 97,115,115, 58,114,101,103,105,115,116,101,
+    114, 32, 40,112,114,101, 41, 10,  9,105,102, 32,110,111,116,
+     32,115,101,108,102, 58, 99,104,101, 99,107, 95,112,117, 98,
+    108,105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,
+    101,110, 10,  9,  9,114,101,116,117,114,110, 10,  9,101,110,
+    100, 10, 10, 32,112,114,101, 32, 61, 32,112,114,101, 32,111,
+    114, 32, 39, 39, 10, 32,112,117,115,104, 40,115,101,108,102,
+     41, 10,  9,105,102, 32, 95, 99,111,108,108,101, 99,116, 91,
+    115,101,108,102, 46,116,121,112,101, 93, 32,116,104,101,110,
+     10,  9,  9,111,117,116,112,117,116, 40,112,114,101, 44, 39,
+     35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,115,112,
+    108,117,115, 92,110, 39, 41, 10, 32, 32,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95, 99,
+     99,108, 97,115,115, 40,116,111,108,117, 97, 95, 83, 44, 34,
+     39, 46, 46,115,101,108,102, 46,108,110, 97,109,101, 46, 46,
+     39, 34, 44, 34, 39, 46, 46,115,101,108,102, 46,116,121,112,
+    101, 46, 46, 39, 34, 44, 34, 39, 46, 46,115,101,108,102, 46,
+     98,116,121,112,101, 46, 46, 39, 34, 44, 39, 46, 46, 95, 99,
+    111,108,108,101, 99,116, 91,115,101,108,102, 46,116,121,112,
+    101, 93, 46, 46, 39, 41, 59, 39, 41, 10,  9,  9,111,117,116,
+    112,117,116, 40,112,114,101, 44, 39, 35,101,108,115,101, 92,
+    110, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40,112,114,
+    101, 46, 46, 39,116,111,108,117, 97, 95, 99, 99,108, 97,115,
+    115, 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,
+    101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, 34,
+     39, 46, 46,115,101,108,102, 46,116,121,112,101, 46, 46, 39,
+     34, 44, 34, 39, 46, 46,115,101,108,102, 46, 98,116,121,112,
+    101, 46, 46, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, 10,
+      9,  9,111,117,116,112,117,116, 40,112,114,101, 44, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10,  9,101,108,115,101,
+     10, 32, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46,
+     39,116,111,108,117, 97, 95, 99, 99,108, 97,115,115, 40,116,
+    111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102,
+     46,108,110, 97,109,101, 46, 46, 39, 34, 44, 34, 39, 46, 46,
+    115,101,108,102, 46,116,121,112,101, 46, 46, 39, 34, 44, 34,
+     39, 46, 46,115,101,108,102, 46, 98,116,121,112,101, 46, 46,
+     39, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, 10,  9,101,110,
+    100, 10,  9,105,102, 32,115,101,108,102, 46,101,120,116,114,
+     97, 95, 98, 97,115,101,115, 32,116,104,101,110, 10,  9,  9,
+    102,111,114, 32,107, 44, 98, 97,115,101, 32,105,110, 32,105,
+    112, 97,105,114,115, 40,115,101,108,102, 46,101,120,116,114,
+     97, 95, 98, 97,115,101,115, 41, 32,100,111, 10,  9,  9,  9,
+     45, 45, 32,110,111,116, 32,110,111,119, 10, 32, 32, 32, 45,
+     45,111,117,116,112,117,116, 40,112,114,101, 46, 46, 39, 32,
+    116,111,108,117, 97, 95, 97,100,100, 98, 97,115,101, 40,116,
+    111,108,117, 97, 95, 83, 44, 32, 34, 39, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 39, 34, 44, 32, 34, 39, 46,
+     46, 98, 97,115,101, 46, 46, 39, 34, 41, 59, 39, 41, 10,  9,
+      9,101,110,100, 10,  9,101,110,100, 10, 32,111,117,116,112,
+    117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95,
+     98,101,103,105,110,109,111,100,117,108,101, 40,116,111,108,
+    117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,108,
+    110, 97,109,101, 46, 46, 39, 34, 41, 59, 39, 41, 10, 32,108,
+    111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,101,
+     32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32, 32,115,
+    101,108,102, 91,105, 93, 58,114,101,103,105,115,116,101,114,
+     40,112,114,101, 46, 46, 39, 32, 39, 41, 10, 32, 32,105, 32,
+     61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,111,117,116,
+    112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97,
+     95,101,110,100,109,111,100,117,108,101, 40,116,111,108,117,
+     97, 95, 83, 41, 59, 39, 41, 10,  9,112,111,112, 40, 41, 10,
+    101,110,100, 10, 10, 45, 45, 32,114,101,116,117,114,110, 32,
+     99,111,108,108,101, 99,116,105,111,110, 32,114,101,113,117,
+    105,114,101,109,101,110,116, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 67,108, 97,115,115, 58,114,101,
+    113,117,105,114,101, 99,111,108,108,101, 99,116,105,111,110,
+     32, 40,116, 41, 10,  9,105,102, 32,115,101,108,102, 46,102,
+    108, 97,103,115, 46,112,114,111,116,101, 99,116,101,100, 95,
+    100,101,115,116,114,117, 99,116,111,114, 32,116,104,101,110,
+     10,  9,  9,114,101,116,117,114,110, 32,102, 97,108,115,101,
+     10,  9,101,110,100, 10, 32,112,117,115,104, 40,115,101,108,
+    102, 41, 10,  9,108,111, 99, 97,108, 32,114, 32, 61, 32,102,
+     97,108,115,101, 10, 32,108,111, 99, 97,108, 32,105, 61, 49,
+     10, 32,119,104,105,108,101, 32,115,101,108,102, 91,105, 93,
+     32,100,111, 10, 32, 32,114, 32, 61, 32,115,101,108,102, 91,
+    105, 93, 58,114,101,113,117,105,114,101, 99,111,108,108,101,
+     99,116,105,111,110, 40,116, 41, 32,111,114, 32,114, 10, 32,
+     32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10,  9,
+    112,111,112, 40, 41, 10,  9, 45, 45, 32,111,110,108,121, 32,
+     99,108, 97,115,115, 32,116,104, 97,116, 32,101,120,112,111,
+    114,116,115, 32,100,101,115,116,114,117, 99,116,111,114, 32,
+     99, 97,110, 32, 98,101, 32, 97,112,112,114,111,112,114,105,
+     97,116,101,108,121, 32, 99,111,108,108,101, 99,116,101,100,
+     10,  9, 45, 45, 32, 99,108, 97,115,115,101,115, 32,116,104,
+     97,116, 32,101,120,112,111,114,116, 32, 99,111,110,115,116,
+    114,117, 99,116,111,114,115, 32,110,101,101,100, 32,116,111,
+     32,104, 97,118,101, 32, 97, 32, 99,111,108,108,101, 99,116,
+    111,114, 32, 40,111,118,101,114,114,105,100,101,100, 32, 98,
+    121, 32, 45, 68, 32,102,108, 97,103, 32,111,110, 32, 99,111,
+    109,109, 97,110,100, 32,108,105,110,101, 41, 10,  9,105,102,
+     32,115,101,108,102, 46, 95,100,101,108,101,116,101, 32,111,
+    114, 32, 40, 40,110,111,116, 32,102,108, 97,103,115, 91, 39,
+     68, 39, 93, 41, 32, 97,110,100, 32,115,101,108,102, 46, 95,
+    110,101,119, 41, 32,116,104,101,110, 10,  9,  9, 45, 45,116,
+     91,115,101,108,102, 46,116,121,112,101, 93, 32, 61, 32, 34,
+    116,111,108,117, 97, 95, 99,111,108,108,101, 99,116, 95, 34,
+     32, 46, 46, 32,103,115,117, 98, 40,115,101,108,102, 46,116,
+    121,112,101, 44, 34, 58, 58, 34, 44, 34, 95, 34, 41, 10,  9,
+      9,116, 91,115,101,108,102, 46,116,121,112,101, 93, 32, 61,
+     32, 34,116,111,108,117, 97, 95, 99,111,108,108,101, 99,116,
+     95, 34, 32, 46, 46, 32, 99,108,101, 97,110, 95,116,101,109,
+    112,108, 97,116,101, 40,115,101,108,102, 46,116,121,112,101,
+     41, 10,  9,  9,114, 32, 61, 32,116,114,117,101, 10,  9,101,
+    110,100, 10, 32,114,101,116,117,114,110, 32,114, 10,101,110,
+    100, 10, 10, 45, 45, 32,111,117,116,112,117,116, 32,116, 97,
+    103,115, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 67,108, 97,115,115, 58,100,101, 99,108,116,121,112,
+    101, 32, 40, 41, 10, 32,112,117,115,104, 40,115,101,108,102,
+     41, 10,  9,115,101,108,102, 46,116,121,112,101, 32, 61, 32,
+    114,101,103,116,121,112,101, 40,115,101,108,102, 46,111,114,
+    105,103,105,110, 97,108, 95,110, 97,109,101, 32,111,114, 32,
+    115,101,108,102, 46,110, 97,109,101, 41, 10,  9,115,101,108,
+    102, 46, 98,116,121,112,101, 32, 61, 32,116,121,112,101,118,
+     97,114, 40,115,101,108,102, 46, 98, 97,115,101, 41, 10,  9,
+    115,101,108,102, 46, 99,116,121,112,101, 32, 61, 32, 39, 99,
+    111,110,115,116, 32, 39, 46, 46,115,101,108,102, 46,116,121,
+    112,101, 10,  9,105,102, 32,115,101,108,102, 46,101,120,116,
+    114, 97, 95, 98, 97,115,101,115, 32,116,104,101,110, 10,  9,
+      9,102,111,114, 32,105, 61, 49, 44,116, 97, 98,108,101, 46,
+    103,101,116,110, 40,115,101,108,102, 46,101,120,116,114, 97,
+     95, 98, 97,115,101,115, 41, 32,100,111, 10,  9,  9,  9,115,
+    101,108,102, 46,101,120,116,114, 97, 95, 98, 97,115,101,115,
+     91,105, 93, 32, 61, 32,116,121,112,101,118, 97,114, 40,115,
+    101,108,102, 46,101,120,116,114, 97, 95, 98, 97,115,101,115,
+     91,105, 93, 41, 10,  9,  9,101,110,100, 10,  9,101,110,100,
+     10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,
+    105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,
+     32, 32,115,101,108,102, 91,105, 93, 58,100,101, 99,108,116,
+    121,112,101, 40, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49,
+     10, 32,101,110,100, 10,  9,112,111,112, 40, 41, 10,101,110,
+    100, 10, 10, 10, 45, 45, 32, 80,114,105,110,116, 32,109,101,
+    116,104,111,100, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 67,108, 97,115,115, 58,112,114,105,110,116,
+     32, 40,105,100,101,110,116, 44, 99,108,111,115,101, 41, 10,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     67,108, 97,115,115,123, 34, 41, 10, 32,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32, 98, 97,115,101, 32, 61,
+     32, 39, 34, 46, 46,115,101,108,102, 46, 98, 97,115,101, 46,
+     46, 34, 39, 59, 34, 41, 10, 32,112,114,105,110,116, 40,105,
+    100,101,110,116, 46, 46, 34, 32,108,110, 97,109,101, 32, 61,
+     32, 39, 34, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+     46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,116,121,112,101, 32, 61,
+     32, 39, 34, 46, 46,115,101,108,102, 46,116,121,112,101, 46,
+     46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,
+    100,101,110,116, 46, 46, 34, 32, 98,116,121,112,101, 32, 61,
+     32, 39, 34, 46, 46,115,101,108,102, 46, 98,116,121,112,101,
+     46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32, 99,116,121,112,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46, 99,116,121,112,
+    101, 46, 46, 34, 39, 44, 34, 41, 10, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,
+    105, 93, 58,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46, 46, 99,
+    108,111,115,101, 41, 10,101,110,100, 10, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 67,108, 97,115,115,
+     58,115,101,116, 95,112,114,111,116,101, 99,116,101,100, 95,
+    100,101,115,116,114,117, 99,116,111,114, 40,112, 41, 10,  9,
+    115,101,108,102, 46,102,108, 97,103,115, 46,112,114,111,116,
+    101, 99,116,101,100, 95,100,101,115,116,114,117, 99,116,111,
+    114, 32, 61, 32,115,101,108,102, 46,102,108, 97,103,115, 46,
+    112,114,111,116,101, 99,116,101,100, 95,100,101,115,116,114,
+    117, 99,116,111,114, 32,111,114, 32,112, 10,101,110,100, 10,
+     10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,
+    110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116,
+    105,111,110, 32, 95, 67,108, 97,115,115, 32, 40,116, 41, 10,
+     32,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116,
+     44, 99,108, 97,115,115, 67,108, 97,115,115, 41, 10, 32,116,
+     58, 98,117,105,108,100,110, 97,109,101,115, 40, 41, 10, 32,
+     97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,
+    114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,
+    110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,
+    112,101, 99,116,115, 32,116,104,101, 32,110, 97,109,101, 44,
+     32,116,104,101, 32, 98, 97,115,101, 32, 40, 97,114,114, 97,
+    121, 41, 32, 97,110,100, 32,116,104,101, 32, 98,111,100,121,
+     32,111,102, 32,116,104,101, 32, 99,108, 97,115,115, 46, 10,
+    102,117,110, 99,116,105,111,110, 32, 67,108, 97,115,115, 32,
+     40,110, 44,112, 44, 98, 41, 10, 10,  9,105,102, 32,116, 97,
+     98,108,101, 46,103,101,116,110, 40,112, 41, 32, 62, 32, 49,
+     32,116,104,101,110, 10,  9,  9, 98, 32, 61, 32,115,116,114,
+    105,110,103, 46,115,117, 98, 40, 98, 44, 32, 49, 44, 32, 45,
+     50, 41, 10,  9,  9,102,111,114, 32,105, 61, 50, 44,116, 97,
+     98,108,101, 46,103,101,116,110, 40,112, 41, 44, 49, 32,100,
+    111, 10,  9,  9,  9, 98, 32, 61, 32, 98, 46, 46, 34, 92,110,
+     32,116,111,108,117, 97, 95,105,110,104,101,114,105,116,115,
+     32, 34, 46, 46,112, 91,105, 93, 46, 46, 34, 32, 95, 95, 34,
+     46, 46,112, 91,105, 93, 46, 46, 34, 95, 95, 59, 92,110, 34,
+     10,  9,  9,101,110,100, 10,  9,  9, 98, 32, 61, 32, 98, 46,
+     46, 34, 92,110,125, 34, 10,  9,101,110,100, 10, 10,  9, 45,
+     45, 32, 99,104,101, 99,107, 32,102,111,114, 32,116,101,109,
+    112,108, 97,116,101, 10,  9, 98, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40, 98, 44, 32, 34, 94,123, 37,
+    115, 42, 84, 69, 77, 80, 76, 65, 84, 69, 95, 66, 73, 78, 68,
+     34, 44, 32, 34,123, 92,110, 84, 79, 76, 85, 65, 95, 84, 69,
+     77, 80, 76, 65, 84, 69, 95, 66, 73, 78, 68, 34, 41, 10,  9,
+    108,111, 99, 97,108, 32,116, 44, 95, 44, 84, 44, 73, 32, 61,
+     32,115,116,114,105,110,103, 46,102,105,110,100, 40, 98, 44,
+     32, 34, 94,123, 37,115, 42, 84, 79, 76, 85, 65, 95, 84, 69,
+     77, 80, 76, 65, 84, 69, 95, 66, 73, 78, 68, 37,115, 42, 37,
+     40, 43, 37,115, 42, 92, 34, 63, 40, 91, 94, 92, 34, 44, 93,
+     42, 41, 92, 34, 63, 37,115, 42, 44, 37,115, 42, 40, 91, 94,
+     37, 41, 93, 42, 41, 37,115, 42, 37, 41, 43, 34, 41, 10,  9,
+    105,102, 32,116, 32,116,104,101,110, 10, 10,  9,  9, 45, 45,
+     32,114,101,109,111,118,101, 32,113,117,111,116,101,115, 10,
+      9,  9, 73, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40, 73, 44, 32, 34, 92, 34, 34, 44, 32, 34, 34, 41,
+     10,  9,  9, 84, 32, 61, 32,115,116,114,105,110,103, 46,103,
+    115,117, 98, 40, 84, 44, 32, 34, 92, 34, 34, 44, 32, 34, 34,
+     41, 10,  9,  9, 45, 45, 32,103,101,116, 32,116,121,112,101,
+     32,108,105,115,116, 10,  9,  9,108,111, 99, 97,108, 32,116,
+    121,112,101,115, 32, 61, 32,115,112,108,105,116, 95, 99, 95,
+    116,111,107,101,110,115, 40, 73, 44, 32, 34, 44, 34, 41, 10,
+      9,  9, 45, 45, 32,114,101,109,111,118,101, 32, 84, 69, 77,
+     80, 76, 65, 84, 69, 95, 66, 73, 78, 68, 32,108,105,110,101,
+     10,  9,  9,108,111, 99, 97,108, 32, 98,115, 32, 61, 32,115,
+    116,114,105,110,103, 46,103,115,117, 98, 40, 98, 44, 32, 34,
+     94,123, 37,115, 42, 84, 79, 76, 85, 65, 95, 84, 69, 77, 80,
+     76, 65, 84, 69, 95, 66, 73, 78, 68, 91, 94, 92,110, 93, 42,
+     92,110, 34, 44, 32, 34,123, 92,110, 34, 41, 10, 10,  9,  9,
+     45, 45, 32,114,101,112,108, 97, 99,101, 10,  9,  9,102,111,
+    114, 32,105, 32, 61, 49, 32, 44, 32,116,121,112,101,115, 46,
+    110, 32,100,111, 10, 10,  9,  9,  9,108,111, 99, 97,108, 32,
+     84,108, 32, 61, 32,115,112,108,105,116, 40, 84, 44, 32, 34,
+     32, 34, 41, 10,  9,  9,  9,108,111, 99, 97,108, 32, 73,108,
+     32, 61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,
+    110,115, 40,116,121,112,101,115, 91,105, 93, 44, 32, 34, 32,
+     34, 41, 10,  9,  9,  9,108,111, 99, 97,108, 32, 98, 73, 32,
+     61, 32, 98,115, 10,  9,  9,  9,108,111, 99, 97,108, 32,112,
+     73, 32, 61, 32,123,125, 10,  9,  9,  9,102,111,114, 32,106,
+     32, 61, 32, 49, 44, 84,108, 46,110, 32,100,111, 10,  9,  9,
+      9,  9, 84,108, 91,106, 93, 32, 61, 32,102,105,110,100,116,
+    121,112,101, 40, 84,108, 91,106, 93, 41, 32,111,114, 32, 84,
+    108, 91,106, 93, 10,  9,  9,  9,  9, 98, 73, 32, 61, 32,115,
+    116,114,105,110,103, 46,103,115,117, 98, 40, 98, 73, 44, 32,
+     34, 40, 91, 94, 95, 37,119, 93, 41, 34, 46, 46, 84,108, 91,
+    106, 93, 46, 46, 34, 40, 91, 94, 95, 37,119, 93, 41, 34, 44,
+     32, 34, 37, 49, 34, 46, 46, 73,108, 91,106, 93, 46, 46, 34,
+     37, 50, 34, 41, 10,  9,  9,  9,  9,105,102, 32,112, 32,116,
+    104,101,110, 10,  9,  9,  9,  9,  9,102,111,114, 32,105, 61,
+     49, 44,116, 97, 98,108,101, 46,103,101,116,110, 40,112, 41,
+     32,100,111, 10,  9,  9,  9,  9,  9,  9,112, 73, 91,105, 93,
+     32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,
+    112, 91,105, 93, 44, 32, 34, 40, 91, 94, 95, 37,119, 93, 63,
+     41, 34, 46, 46, 84,108, 91,106, 93, 46, 46, 34, 40, 91, 94,
+     95, 37,119, 93, 63, 41, 34, 44, 32, 34, 37, 49, 34, 46, 46,
+     73,108, 91,106, 93, 46, 46, 34, 37, 50, 34, 41, 10,  9,  9,
+      9,  9,  9,101,110,100, 10,  9,  9,  9,  9,101,110,100, 10,
+      9,  9,  9,101,110,100, 10,  9,  9,  9, 45, 45,108,111, 99,
+     97,108, 32, 97,112,112,101,110,100, 32, 61, 32, 34, 60, 34,
+     46, 46,115,116,114,105,110,103, 46,103,115,117, 98, 40,116,
+    121,112,101,115, 91,105, 93, 44, 32, 34, 37,115, 43, 34, 44,
+     32, 34, 44, 34, 41, 46, 46, 34, 62, 34, 10,  9,  9,  9,108,
+    111, 99, 97,108, 32, 97,112,112,101,110,100, 32, 61, 32, 34,
+     60, 34, 46, 46, 99,111,110, 99, 97,116, 40, 73,108, 44, 32,
+     49, 44, 32,116, 97, 98,108,101, 46,103,101,116,110, 40, 73,
+    108, 41, 44, 32, 34, 44, 34, 41, 46, 46, 34, 62, 34, 10,  9,
+      9,  9, 97,112,112,101,110,100, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40, 97,112,112,101,110,100, 44,
+     32, 34, 37,115, 42, 44, 37,115, 42, 34, 44, 32, 34, 44, 34,
+     41, 10,  9,  9,  9, 97,112,112,101,110,100, 32, 61, 32,115,
+    116,114,105,110,103, 46,103,115,117, 98, 40, 97,112,112,101,
+    110,100, 44, 32, 34, 62, 62, 34, 44, 32, 34, 62, 32, 62, 34,
+     41, 10,  9,  9,  9,102,111,114, 32,105, 61, 49, 44,116, 97,
+     98,108,101, 46,103,101,116,110, 40,112, 73, 41, 32,100,111,
+     10,  9,  9,  9,  9, 45, 45,112, 73, 91,105, 93, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,112, 73, 91,
+    105, 93, 44, 32, 34, 62, 62, 34, 44, 32, 34, 62, 32, 62, 34,
+     41, 10,  9,  9,  9,  9,112, 73, 91,105, 93, 32, 61, 32,114,
+    101,115,111,108,118,101, 95,116,101,109,112,108, 97,116,101,
+     95,116,121,112,101,115, 40,112, 73, 91,105, 93, 41, 10,  9,
+      9,  9,101,110,100, 10,  9,  9,  9, 98, 73, 32, 61, 32,115,
+    116,114,105,110,103, 46,103,115,117, 98, 40, 98, 73, 44, 32,
+     34, 62, 62, 34, 44, 32, 34, 62, 32, 62, 34, 41, 10,  9,  9,
+      9, 67,108, 97,115,115, 40,110, 46, 46, 97,112,112,101,110,
+    100, 44, 32,112, 73, 44, 32, 98, 73, 41, 10,  9,  9,101,110,
+    100, 10,  9,  9,114,101,116,117,114,110, 10,  9,101,110,100,
+     10, 10,  9,108,111, 99, 97,108, 32,109, 98, 97,115,101, 10,
+     10,  9,105,102, 32,112, 32,116,104,101,110, 10,  9,  9,109,
+     98, 97,115,101, 32, 61, 32,116, 97, 98,108,101, 46,114,101,
+    109,111,118,101, 40,112, 44, 32, 49, 41, 10,  9,  9,105,102,
+     32,110,111,116, 32,112, 91, 49, 93, 32,116,104,101,110, 32,
+    112, 32, 61, 32,110,105,108, 32,101,110,100, 10,  9,101,110,
+    100, 10, 10,  9,109, 98, 97,115,101, 32, 61, 32,109, 98, 97,
+    115,101, 32, 97,110,100, 32,114,101,115,111,108,118,101, 95,
+    116,101,109,112,108, 97,116,101, 95,116,121,112,101,115, 40,
+    109, 98, 97,115,101, 41, 10, 10,  9,108,111, 99, 97,108, 32,
+     99, 10,  9,108,111, 99, 97,108, 32,111,110, 97,109,101, 32,
+     61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,110,
+     44, 32, 34, 64, 46, 42, 36, 34, 44, 32, 34, 34, 41, 10,  9,
+    111,110, 97,109,101, 32, 61, 32,103,101,116,110, 97,109,101,
+    115,112, 97, 99,101, 40, 99,108, 97,115,115, 67,111,110,116,
+     97,105,110,101,114, 46, 99,117,114,114, 41, 46, 46,111,110,
+     97,109,101, 10, 10,  9,105,102, 32, 95,103,108,111, 98, 97,
+    108, 95, 99,108, 97,115,115,101,115, 91,111,110, 97,109,101,
+     93, 32,116,104,101,110, 10,  9,  9, 99, 32, 61, 32, 95,103,
+    108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,111,
+    110, 97,109,101, 93, 10,  9,  9,105,102, 32,109, 98, 97,115,
+    101, 32, 97,110,100, 32, 40, 40,110,111,116, 32, 99, 46, 98,
+     97,115,101, 41, 32,111,114, 32, 99, 46, 98, 97,115,101, 32,
+     61, 61, 32, 34, 34, 41, 32,116,104,101,110, 10,  9,  9,  9,
+     99, 46, 98, 97,115,101, 32, 61, 32,109, 98, 97,115,101, 10,
+      9,  9,101,110,100, 10,  9,101,108,115,101, 10,  9,  9, 99,
+     32, 61, 32, 95, 67,108, 97,115,115, 40, 95, 67,111,110,116,
+     97,105,110,101,114,123,110, 97,109,101, 61,110, 44, 32, 98,
+     97,115,101, 61,109, 98, 97,115,101, 44, 32,101,120,116,114,
+     97, 95, 98, 97,115,101,115, 61,112,125, 41, 10, 10,  9,  9,
+    108,111, 99, 97,108, 32,102,116, 32, 61, 32,103,101,116,110,
+     97,109,101,115,112, 97, 99,101, 40, 99, 46,112, 97,114,101,
+    110,116, 41, 46, 46, 99, 46,111,114,105,103,105,110, 97,108,
+     95,110, 97,109,101, 10,  9,  9, 97,112,112,101,110,100, 95,
+    103,108,111, 98, 97,108, 95,116,121,112,101, 40,102,116, 44,
+     32, 99, 41, 10,  9,101,110,100, 10, 10,  9,112,117,115,104,
+     40, 99, 41, 10,  9, 99, 58,112, 97,114,115,101, 40,115,116,
+    114,115,117, 98, 40, 98, 44, 50, 44,115,116,114,108,101,110,
+     40, 98, 41, 45, 49, 41, 41, 32, 45, 45, 32,101,108,105,109,
+    105,110, 97,116,101, 32, 98,114, 97, 99,101,115, 10,  9,112,
+    111,112, 40, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/class.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32,109, 97,114,107, 32,117,112, 32, 99,111,109,109,
+    101,110,116,115, 32, 97,110,100, 32,115,116,114,105,110,103,
+    115, 10, 83, 84, 82, 49, 32, 61, 32, 34, 92, 48, 48, 49, 34,
+     10, 83, 84, 82, 50, 32, 61, 32, 34, 92, 48, 48, 50, 34, 10,
+     83, 84, 82, 51, 32, 61, 32, 34, 92, 48, 48, 51, 34, 10, 83,
+     84, 82, 52, 32, 61, 32, 34, 92, 48, 48, 52, 34, 10, 82, 69,
+     77, 32, 32, 61, 32, 34, 92, 48, 48, 53, 34, 10, 65, 78, 89,
+     32, 32, 61, 32, 34, 40, 91, 92, 48, 48, 49, 45, 92, 48, 48,
+     53, 93, 41, 34, 10, 69, 83, 67, 49, 32, 61, 32, 34, 92, 48,
+     48, 54, 34, 10, 69, 83, 67, 50, 32, 61, 32, 34, 92, 48, 48,
+     55, 34, 10, 10, 77, 65, 83, 75, 32, 61, 32,123, 32, 45, 45,
+     32,116,104,101, 32,115,117, 98,115,116,105,116,117,116,105,
+    111,110, 32,111,114,100,101,114, 32,105,115, 32,105,109,112,
+    111,114,116, 97,110,116, 10, 32,123, 69, 83, 67, 49, 44, 32,
+     34, 92, 92, 39, 34,125, 44, 10, 32,123, 69, 83, 67, 50, 44,
+     32, 39, 92, 92, 34, 39,125, 44, 10, 32,123, 83, 84, 82, 49,
+     44, 32, 34, 39, 34,125, 44, 10, 32,123, 83, 84, 82, 50, 44,
+     32, 39, 34, 39,125, 44, 10, 32,123, 83, 84, 82, 51, 44, 32,
+     34, 37, 91, 37, 91, 34,125, 44, 10, 32,123, 83, 84, 82, 52,
+     44, 32, 34, 37, 93, 37, 93, 34,125, 44, 10, 32,123, 82, 69,
+     77, 32, 44, 32, 34, 37, 45, 37, 45, 34,125, 44, 10,125, 10,
+     10,102,117,110, 99,116,105,111,110, 32,109, 97,115,107, 32,
+     40,115, 41, 10, 32,102,111,114, 32,105, 32, 61, 32, 49, 44,
+    103,101,116,110, 40, 77, 65, 83, 75, 41, 32, 32,100,111, 10,
+     32, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44, 77, 65,
+     83, 75, 91,105, 93, 91, 50, 93, 44, 77, 65, 83, 75, 91,105,
+     93, 91, 49, 93, 41, 10, 32,101,110,100, 10, 32,114,101,116,
+    117,114,110, 32,115, 10,101,110,100, 10, 10,102,117,110, 99,
+    116,105,111,110, 32,117,110,109, 97,115,107, 32, 40,115, 41,
+     10, 32,102,111,114, 32,105, 32, 61, 32, 49, 44,103,101,116,
+    110, 40, 77, 65, 83, 75, 41, 32, 32,100,111, 10, 32, 32,115,
+     32, 61, 32,103,115,117, 98, 40,115, 44, 77, 65, 83, 75, 91,
+    105, 93, 91, 49, 93, 44, 77, 65, 83, 75, 91,105, 93, 91, 50,
+     93, 41, 10, 32,101,110,100, 10, 32,114,101,116,117,114,110,
+     32,115, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108,101, 97,110, 32, 40,115, 41, 10, 32, 45, 45,
+     32, 99,104,101, 99,107, 32,102,111,114, 32, 99,111,109,112,
+    105,108, 97,116,105,111,110, 32,101,114,114,111,114, 10, 32,
+    108,111, 99, 97,108, 32, 99,111,100,101, 32, 61, 32, 34,114,
+    101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 32,
+     40, 41, 92,110, 34, 32, 46, 46, 32,115, 32, 46, 46, 32, 34,
+     92,110, 32,101,110,100, 34, 10, 32,105,102, 32,110,111,116,
+     32,100,111,115,116,114,105,110,103, 40, 99,111,100,101, 41,
+     32,116,104,101,110, 10, 32, 32,114,101,116,117,114,110, 32,
+    110,105,108, 10, 32,101,110,100, 10, 10, 32,105,102, 32,102,
+    108, 97,103,115, 91, 39, 67, 39, 93, 32,116,104,101,110, 10,
+     32,  9,114,101,116,117,114,110, 32,115, 10, 32,101,110,100,
+     10, 10, 32,108,111, 99, 97,108, 32, 83, 32, 61, 32, 34, 34,
+     32, 45, 45, 32,115, 97,118,101,100, 32,115,116,114,105,110,
+    103, 10, 10, 32,115, 32, 61, 32,109, 97,115,107, 40,115, 41,
+     10, 10, 32, 45, 45, 32,114,101,109,111,118,101, 32, 98,108,
+     97,110,107,115, 32, 97,110,100, 32, 99,111,109,109,101,110,
+    116,115, 10, 32,119,104,105,108,101, 32, 49, 32,100,111, 10,
+     32, 32,108,111, 99, 97,108, 32, 98, 44,101, 44,100, 32, 61,
+     32,115,116,114,102,105,110,100, 40,115, 44, 65, 78, 89, 41,
+     10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10, 32, 32,
+     32, 83, 32, 61, 32, 83, 46, 46,115,116,114,115,117, 98, 40,
+    115, 44, 49, 44, 98, 45, 49, 41, 10, 32, 32, 32,115, 32, 61,
+     32,115,116,114,115,117, 98, 40,115, 44, 98, 43, 49, 41, 10,
+     32, 32, 32,105,102, 32,100, 61, 61, 83, 84, 82, 49, 32,111,
+    114, 32,100, 61, 61, 83, 84, 82, 50, 32,116,104,101,110, 10,
+     32, 32, 32, 32,101, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115, 44,100, 41, 10, 32, 32, 32, 32, 83, 32, 61, 32, 83,
+     32, 46, 46,100, 46, 46,115,116,114,115,117, 98, 40,115, 44,
+     49, 44,101, 41, 10, 32, 32, 32, 32,115, 32, 61, 32,115,116,
+    114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32, 32,
+    101,108,115,101,105,102, 32,100, 61, 61, 83, 84, 82, 51, 32,
+    116,104,101,110, 10, 32, 32, 32, 32,101, 32, 61, 32,115,116,
+    114,102,105,110,100, 40,115, 44, 83, 84, 82, 52, 41, 10, 32,
+     32, 32, 32, 83, 32, 61, 32, 83, 46, 46,100, 46, 46,115,116,
+    114,115,117, 98, 40,115, 44, 49, 44,101, 41, 10, 32, 32, 32,
+     32,115, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44,101,
+     43, 49, 41, 10, 32, 32, 32,101,108,115,101,105,102, 32,100,
+     61, 61, 82, 69, 77, 32,116,104,101,110, 10, 32, 32, 32, 32,
+    115, 32, 61, 32,103,115,117, 98, 40,115, 44, 34, 91, 94, 92,
+    110, 93, 42, 40, 92,110, 63, 41, 34, 44, 34, 37, 49, 34, 44,
+     49, 41, 10, 32, 32, 32,101,110,100, 10, 32, 32,101,108,115,
+    101, 10, 32, 32, 32, 83, 32, 61, 32, 83, 46, 46,115, 10, 32,
+     32, 32, 98,114,101, 97,107, 10, 32, 32,101,110,100, 10, 32,
+    101,110,100, 10, 32, 45, 45, 32,101,108,105,109,105,110, 97,
+    116,101, 32,117,110,101, 99,101,115,115, 97,114,121, 32,115,
+    112, 97, 99,101,115, 10, 32, 83, 32, 61, 32,103,115,117, 98,
+     40, 83, 44, 34, 91, 32, 92,116, 93, 43, 34, 44, 34, 32, 34,
+     41, 10, 32, 83, 32, 61, 32,103,115,117, 98, 40, 83, 44, 34,
+     91, 32, 92,116, 93, 42, 92,110, 91, 32, 92,116, 93, 42, 34,
+     44, 34, 92,110, 34, 41, 10,  9, 83, 32, 61, 32,103,115,117,
+     98, 40, 83, 44, 34, 92,110, 43, 34, 44, 34, 92,110, 34, 41,
+     10, 32, 83, 32, 61, 32,117,110,109, 97,115,107, 40, 83, 41,
+     10, 32,114,101,116,117,114,110, 32, 83, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/clean.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    45, 45, 32, 71,101,110,101,114, 97,116,101, 32, 98,105,110,
+    100,105,110,103, 32, 99,111,100,101, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 76, 97,
+    115,116, 32,117,112,100, 97,116,101, 58, 32, 65,112,114, 32,
+     50, 48, 48, 51, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10,
+     10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,
+    105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114,
+    101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105,
+    115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100,
+     47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10,
+     45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101,
+     32,112,114,111,118,105,100,101,100, 32,104,101,114,101,117,
+    110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34,
+     97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,
+    110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111,
+    114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97,
+    116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,101,
+     32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115,
+    117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115,
+     44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110,
+    116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97,
+    116,105,111,110,115, 46, 10, 10,102,117,110, 99,116,105,111,
+    110, 32,112, 97,114,115,101, 95,101,120,116,114, 97, 40, 41,
+     10, 10,  9,102,111,114, 32,107, 44,118, 32,105,110, 32,105,
+    112, 97,105,114,115, 40, 95,101,120,116,114, 97, 95,112, 97,
+    114, 97,109,101,116,101,114,115, 32,111,114, 32,123,125, 41,
+     32,100,111, 10,  9,  9, 10,  9,  9,108,111, 99, 97,108, 32,
+     98, 44,101, 44,110, 97,109,101, 44,118, 97,108,117,101, 32,
+     61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,118,
+     44, 32, 34, 94, 40, 91, 94, 61, 93, 41, 61, 40, 46, 42, 41,
+     36, 34, 41, 10,  9,  9,105,102, 32, 98, 32,116,104,101,110,
+     10,  9,  9,  9, 95,101,120,116,114, 97, 95,112, 97,114, 97,
+    109,101,116,101,114,115, 91,110, 97,109,101, 93, 32, 61, 32,
+    118, 97,108,117,101, 10,  9,  9,101,108,115,101, 10,  9,  9,
+      9, 95,101,120,116,114, 97, 95,112, 97,114, 97,109,101,116,
+    101,114,115, 91,118, 93, 32, 61, 32,116,114,117,101, 10,  9,
+      9,101,110,100, 10,  9,101,110,100, 10,101,110,100, 10, 10,
+    102,117,110, 99,116,105,111,110, 32,100,111,105,116, 32, 40,
+     41, 10,  9, 45, 45, 32,100,101,102,105,110,101, 32,112, 97,
+     99,107, 97,103,101, 32,110, 97,109,101, 44, 32,105,102, 32,
+    110,111,116, 32,112,114,111,118,105,100,101,100, 10,  9,105,
+    102, 32,110,111,116, 32,102,108, 97,103,115, 46,110, 32,116,
+    104,101,110, 10,  9,  9,105,102, 32,102,108, 97,103,115, 46,
+    102, 32,116,104,101,110, 10,  9,  9,  9,102,108, 97,103,115,
+     46,110, 32, 61, 32,103,115,117, 98, 40,102,108, 97,103,115,
+     46,102, 44, 34, 37, 46, 46, 42, 36, 34, 44, 34, 34, 41, 10,
+      9,  9,  9, 95, 44, 95, 44,102,108, 97,103,115, 46,110, 32,
+     61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,102,
+    108, 97,103,115, 46,110, 44, 32, 34, 40, 91, 94, 47, 92, 92,
+     93, 42, 41, 36, 34, 41, 10,  9,  9,101,108,115,101, 10,  9,
+      9,  9,101,114,114,111,114, 40, 34, 35,110,111, 32,112, 97,
+     99,107, 97,103,101, 32,110, 97,109,101, 32,110,111,114, 32,
+    105,110,112,117,116, 32,102,105,108,101, 32,112,114,111,118,
+    105,100,101,100, 34, 41, 10,  9,  9,101,110,100, 10,  9,101,
+    110,100, 10, 10,  9, 45, 45, 32,112, 97,114,115,101, 32,116,
+     97, 98,108,101, 32,119,105,116,104, 32,101,120,116,114, 97,
+     32,112, 97,114, 97,109,116,101,114,115, 10,  9,112, 97,114,
+    115,101, 95,101,120,116,114, 97, 40, 41, 10, 10,  9, 45, 45,
+     32,100,111, 32,116,104,105,115, 32, 97,102,116,101,114, 32,
+    115,101,116,116,105,110,103, 32,116,104,101, 32,112, 97, 99,
+    107, 97,103,101, 32,110, 97,109,101, 10,  9,105,102, 32,102,
+    108, 97,103,115, 91, 39, 76, 39, 93, 32,116,104,101,110, 10,
+      9,  9,100,111,102,105,108,101, 40,102,108, 97,103,115, 91,
+     39, 76, 39, 93, 41, 10,  9,101,110,100, 10, 10,  9, 45, 45,
+     32, 97,100,100, 32, 99,112,112,115,116,114,105,110,103, 10,
+      9,105,102, 32,110,111,116, 32,102,108, 97,103,115, 91, 39,
+     83, 39, 93, 32,116,104,101,110, 10,  9,  9, 95, 98, 97,115,
+    105, 99, 91, 39,115,116,114,105,110,103, 39, 93, 32, 61, 32,
+     39, 99,112,112,115,116,114,105,110,103, 39, 10,  9,  9, 95,
+     98, 97,115,105, 99, 91, 39,115,116,100, 58, 58,115,116,114,
+    105,110,103, 39, 93, 32, 61, 32, 39, 99,112,112,115,116,114,
+    105,110,103, 39, 10,  9,  9, 95, 98, 97,115,105, 99, 95, 99,
+    116,121,112,101, 46, 99,112,112,115,116,114,105,110,103, 32,
+     61, 32, 39, 99,111,110,115,116, 32, 99,104, 97,114, 42, 39,
+     10,  9,101,110,100, 10, 10,  9, 45, 45, 32,112,114,111, 99,
+     99,101,115,115, 32,112, 97, 99,107, 97,103,101, 10,  9,108,
+    111, 99, 97,108, 32,112, 32, 32, 61, 32, 80, 97, 99,107, 97,
+    103,101, 40,102,108, 97,103,115, 46,110, 44,102,108, 97,103,
+    115, 46,102, 41, 10, 10,  9,105,102, 32,102,108, 97,103,115,
+     46,112, 32,116,104,101,110, 10,  9,  9,114,101,116,117,114,
+    110, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32,111,110,108,
+    121, 32,112, 97,114,115,101, 10,  9,101,110,100, 10, 10,  9,
+    105,102, 32,102,108, 97,103,115, 46,111, 32,116,104,101,110,
+     10,  9,  9,108,111, 99, 97,108, 32,115,116, 44,109,115,103,
+     32, 61, 32,119,114,105,116,101,116,111, 40,102,108, 97,103,
+    115, 46,111, 41, 10,  9,  9,105,102, 32,110,111,116, 32,115,
+    116, 32,116,104,101,110, 10,  9,  9,  9,101,114,114,111,114,
+     40, 39, 35, 39, 46, 46,109,115,103, 41, 10,  9,  9,101,110,
+    100, 10,  9,101,110,100, 10, 10,  9,112, 58,100,101, 99,108,
+    116,121,112,101, 40, 41, 10,  9,105,102, 32,102,108, 97,103,
+    115, 46, 80, 32,116,104,101,110, 10,  9,  9,112, 58,112,114,
+    105,110,116, 40, 41, 10,  9,101,108,115,101, 10,  9,  9,112,
+     58,112,114,101, 97,109, 98,108,101, 40, 41, 10,  9,  9,112,
+     58,115,117,112, 99,111,100,101, 40, 41, 10,  9,  9,112, 58,
+    114,101,103,105,115,116,101,114, 40, 41, 10,  9,  9,112,117,
+    115,104, 40,112, 41, 10,  9,  9,112,111,115,116, 95,111,117,
+    116,112,117,116, 95,104,111,111,107, 40,112, 41, 10,  9,  9,
+    112,111,112, 40, 41, 10,  9,101,110,100, 10, 10,  9,105,102,
+     32,102,108, 97,103,115, 46,111, 32,116,104,101,110, 10,  9,
+      9,119,114,105,116,101,116,111, 40, 41, 10,  9,101,110,100,
+     10, 10,  9, 45, 45, 32,119,114,105,116,101, 32,104,101, 97,
+    100,101,114, 32,102,105,108,101, 10,  9,105,102, 32,110,111,
+    116, 32,102,108, 97,103,115, 46, 80, 32,116,104,101,110, 10,
+      9,  9,105,102, 32,102,108, 97,103,115, 46, 72, 32,116,104,
+    101,110, 10,  9,  9,  9,108,111, 99, 97,108, 32,115,116, 44,
+    109,115,103, 32, 61, 32,119,114,105,116,101,116,111, 40,102,
+    108, 97,103,115, 46, 72, 41, 10,  9,  9,  9,105,102, 32,110,
+    111,116, 32,115,116, 32,116,104,101,110, 10,  9,  9,  9,  9,
+    101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,115,103, 41,
+     10,  9,  9,  9,101,110,100, 10,  9,  9,  9,112, 58,104,101,
+     97,100,101,114, 40, 41, 10,  9,  9,  9,119,114,105,116,101,
+    116,111, 40, 41, 10,  9,  9,101,110,100, 10,  9,101,110,100,
+     10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/lua/doit.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10,108,111, 99, 97,108, 32,101,114,114, 44,109,115,103, 32,
+     61, 32,112, 99, 97,108,108, 40,100,111,105,116, 41, 10,105,
+    102, 32,110,111,116, 32,101,114,114, 32,116,104,101,110, 10,
+     32,108,111, 99, 97,108, 32, 95, 44, 95, 44,108, 97, 98,101,
+    108, 44,109,115,103, 32, 61, 32,115,116,114,102,105,110,100,
+     40,109,115,103, 44, 34, 40, 46, 45, 58, 46, 45, 58, 37,115,
+     42, 41, 40, 46, 42, 41, 34, 41, 10, 32,116,111,108,117, 97,
+     95,101,114,114,111,114, 40,109,115,103, 44,108, 97, 98,101,
+    108, 41, 10, 32,112,114,105,110,116, 40,100,101, 98,117,103,
+     46,116,114, 97, 99,101, 98, 97, 99,107, 40, 41, 41, 10,101,
+    110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 22");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+ tolua_endmodule(tolua_S);
+ return 1;
+}
+
+
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
+ int luaopen_tolua (lua_State* tolua_S) {
+ return tolua_tolua_open(tolua_S);
+};
+#endif
+
Index: /code/branches/physics/src/tolua/toluabind.h
===================================================================
--- /code/branches/physics/src/tolua/toluabind.h	(revision 2122)
+++ /code/branches/physics/src/tolua/toluabind.h	(revision 2122)
@@ -0,0 +1,8 @@
+/*
+** Lua binding: tolua
+** Generated automatically by tolua++-1.0.91 on Wed Apr 26 22:30:15 2006.
+*/
+
+/* Exported function */
+TOLUA_API int  tolua_tolua_open (lua_State* tolua_S);
+
Index: /code/branches/physics/src/util/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/util/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/util/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,23 @@
+SET(UTIL_SRC_FILES
+  Clipboard.cc
+  CRC32.cc
+  Exception.cc
+  ExprParser.cc
+  Math.cc
+  MultiType.cc
+  OutputBuffer.cc
+  OutputHandler.cc
+  SignalHandler.cc
+  String.cc
+  SubString.cc
+)
+
+ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES})
+
+IF(TESTING_ENABLED)
+  ADD_SUBDIRECTORY(testing)
+ENDIF(TESTING_ENABLED)
+
+TARGET_LINK_LIBRARIES(util
+  ${OGRE_LIBRARIES}
+)
Index: /code/branches/physics/src/util/CRC32.cc
===================================================================
--- /code/branches/physics/src/util/CRC32.cc	(revision 2122)
+++ /code/branches/physics/src/util/CRC32.cc	(revision 2122)
@@ -0,0 +1,56 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CRC32.h"
+
+
+void calcCRCBit(uint32_t &crc32, int bit){
+    int hbit;
+
+    hbit=(crc32 & 0x80000000) ? 1 : 0;
+    if (hbit != bit)
+      crc32=(crc32<<1) ^ UTIL_CRC32POLY;
+    else
+      crc32=crc32<<1;
+  }
+
+  uint32_t calcCRC(unsigned char *data, unsigned int dataLength){
+    uint32_t crc32=0;
+    for(unsigned int i=0; i<dataLength; i++){
+      calcCRCBit(crc32, (data[i]&0x1)>>0); // 1st bit
+      calcCRCBit(crc32, (data[i]&0x2)>>1); // 2nd bit
+      calcCRCBit(crc32, (data[i]&0x3)>>2); // 3rd bit
+      calcCRCBit(crc32, (data[i]&0x4)>>3); // 4th bit
+      calcCRCBit(crc32, (data[i]&0x5)>>4); // 5th bit
+      calcCRCBit(crc32, (data[i]&0x6)>>5); // 6th bit
+      calcCRCBit(crc32, (data[i]&0x7)>>6); // 7th bit
+      calcCRCBit(crc32, (data[i]&0x8)>>7); // 8th bit
+    }
+    return crc32;
+  }
+
Index: /code/branches/physics/src/util/CRC32.h
===================================================================
--- /code/branches/physics/src/util/CRC32.h	(revision 2122)
+++ /code/branches/physics/src/util/CRC32.h	(revision 2122)
@@ -0,0 +1,43 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Util_CRC_H__
+#define _Util_CRC_H__
+
+#include "UtilPrereqs.h"
+#include <iostream>
+#include "Integers.h"
+
+const unsigned int UTIL_CRC32POLY = 0x04C11DB7; /* CRC-32 Polynom */
+
+_UtilExport void calcCRCBit(uint32_t &crc32, int bit);
+
+_UtilExport uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
+
+
+#endif /* _Util_CRC_H__ */
Index: /code/branches/physics/src/util/Clipboard.cc
===================================================================
--- /code/branches/physics/src/util/Clipboard.cc	(revision 2122)
+++ /code/branches/physics/src/util/Clipboard.cc	(revision 2122)
@@ -0,0 +1,125 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ *   Windows version inspired by "Copy Text To Clipboard" by Laszlo Szathmary, 2007
+ *      http://www.loria.fr/~szathmar/off/projects/C/CopyTextToClipboard/index.php
+ */
+
+/**
+    @file Clipboard.cc
+    @brief OS-specific implementations of the clipboard functions.
+*/
+
+#include "Clipboard.h"
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+    /////////////
+    // Windows //
+    /////////////
+    #include <windows.h>
+    #include "Debug.h"
+
+    /**
+        @brief Puts text into the windows-clipboard
+        @param text The text
+        @return True if the action was successful
+    */
+    bool toClipboard(const std::string& text)
+    {
+        try
+        {
+            if (OpenClipboard(0))
+            {
+                EmptyClipboard();
+                HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, text.size() + 1);
+                char* buffer = (char*)GlobalLock(clipbuffer);
+                strcpy(buffer, text.c_str());
+                GlobalUnlock(clipbuffer);
+                SetClipboardData(CF_TEXT, clipbuffer);
+                CloseClipboard();
+
+                return true;
+            }
+        }
+        catch (...)
+        {
+            COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;
+            COUT(1) << "       \"" << text << "\"" << std::endl;
+        }
+        return false;
+    }
+
+    /**
+        @brief Gets text from the windows-clipboard if there is any text.
+        @return The retrieved text
+    */
+    std::string fromClipboard()
+    {
+        try
+        {
+            if (OpenClipboard(0))
+            {
+                HANDLE hData = GetClipboardData(CF_TEXT);
+                std::string output = (char*)GlobalLock(hData);
+                GlobalUnlock(hData);
+                CloseClipboard();
+
+                return output;
+            }
+        }
+        catch (...)
+        {
+            COUT(1) << "Error: Unable to retrieve text from the clipboard." << std::endl;
+        }
+        return "";
+    }
+#else
+    /////////////
+    // Default //
+    /////////////
+
+    std::string clipboard = ""; //!< Keeps the text of our internal clipboard
+
+    /**
+        @brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard.
+        @param text The text
+        @return True
+    */
+    bool toClipboard(const std::string& text)
+    {
+        clipboard = text;
+        return true;
+    }
+
+    /**
+        @brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard.
+        @return The text
+    */
+    std::string fromClipboard()
+    {
+        return clipboard;
+    }
+#endif
Index: /code/branches/physics/src/util/Clipboard.h
===================================================================
--- /code/branches/physics/src/util/Clipboard.h	(revision 2122)
+++ /code/branches/physics/src/util/Clipboard.h	(revision 2122)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Clipboard.h
+    @brief Some functions to exchange text between the OS clipboard and Orxonox.
+
+    Use fromClipboard() to get text from the clipboard (if there is any text) and
+    toClipboard(text) to put text into the clipboard.
+
+    Those functions can only work properly if there's an OS-specific implementation.
+    If an OS isn't supported, the clipboard only works within Orxonox, but exchange
+    with other programs isn't possible.
+*/
+
+#ifndef _Clipboard_H__
+#define _Clipboard_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+
+
+_UtilExport bool toClipboard(const std::string& text);
+_UtilExport std::string fromClipboard();
+
+
+#endif /* _Clipboard_H__ */
+
Index: /code/branches/physics/src/util/Convert.h
===================================================================
--- /code/branches/physics/src/util/Convert.h	(revision 2122)
+++ /code/branches/physics/src/util/Convert.h	(revision 2122)
@@ -0,0 +1,484 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *      Fabian 'x3n' Landau
+ *      Benjamin Grauer
+ *   Co-authors:
+ *      ...
+ */
+
+/*!
+    @file
+    @brief Definition and Implementation of the Convert class.
+*/
+
+#ifndef _Converter_H__
+#define _Converter_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <sstream>
+#include <istream>
+#include <ostream>
+#include <typeinfo>
+
+#include "Debug.h"
+#include "String.h"
+
+// GCC generates warnings when implicitely casting from float to int for instance.
+// This is however exactly what convertValue does, so we need to suppress these warnings.
+// They only occur when using the ImplicitConversion template.
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_GNUC
+#  pragma GCC system_header
+#endif
+
+
+///////////////////////////////////////////////
+// Static detection for conversion functions //
+///////////////////////////////////////////////
+
+/* The idea to use the sizeof() operator on return functions to determine function existance
+   is described in 'Modern C++ design' by Alexandrescu (2001). */
+
+// disable warnings about possible loss of data
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#  pragma warning(push)
+#  pragma warning(disable:4244)
+#endif
+
+template <class FromType, class ToType>
+class ImplicitConversion
+{
+private:
+    ImplicitConversion(); ImplicitConversion(const ImplicitConversion&); ~ImplicitConversion();
+    // Gets chosen only if there is an implicit conversion from FromType to ToType.
+    static char test(ToType);
+    // Accepts any argument. Why do we not use a template? The reason is that with templates,
+    // the function above is only taken iff it is an exact type match. But since we want to
+    // check for implicit conversion, we have to use the ellipsis.
+    static long long test(...);
+    static FromType object; // helper object to handle private c'tor and d'tor
+public:
+    // test(object) only has 'long long' return type iff the compiler doesn't choose test(...)
+    enum { exists = (sizeof(test(object)) == sizeof(char)) };
+};
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#  pragma warning(pop)
+#endif
+
+
+////////////////////////////////////
+//// ACTUAL CONVERSION SEQUENCE ////
+////////////////////////////////////
+/*
+    There is a distinct priority when choosing the right conversion function:
+    Overwrite:
+    1. (Partial) template specialisation of ConverterExplicit::convert()
+    Fallbacks:
+    2. Any possible implicit conversion. This includes 'FooBar' --> 'int' if FooBar defines operator float().
+    3. Global or member operators for stringstream when converting from or to std::string (or FROM const char*)
+    4. (Partial) template specialisation of ConverterFallback::convert()
+    5. Function that simply displays "Could not convert value" with type information obtained from typeid().
+
+    Notes:
+    There has to be an exact type match when using template specialisations.
+    Template specialisations can be defined after including this file. Any implicit cast function or iostream
+    operator has to be declared BEFORE this file gets parsed.
+
+    Defining your own functions:
+    There are obviously 4 ways to specifiy a user defined conversion. What should I use?
+
+    Usually, ConverterFallback fits quite well. You won't have to deal with the conversion from
+    'MyClass' to 'MyClass' by using another explicit template specialisation to avoid ambiguities.
+
+    However if you want to overwrite an implicit conversion or an iostream operator, you really need to
+    make use of ConverterExplicit.
+*/
+
+namespace
+{
+    //! Little template that maps integers to entire types (Alexandrescu 2001)
+    template <int I>
+    struct Int2Type { };
+}
+
+
+///////////////////
+// No Conversion //
+///////////////////
+
+// Default template. No conversion available at all.
+template <class FromType, class ToType>
+struct ConverterFallback
+{
+    static bool convert(ToType* output, const FromType& input)
+    {
+        COUT(2) << "Could not convert value of type " << typeid(FromType).name()
+                << " to type " << typeid(ToType).name() << std::endl;
+        return false;
+    }
+};
+
+// If all else fails, try a dynamic_cast for pointer types.
+template <class FromType, class ToType>
+struct ConverterFallback<FromType*, ToType*>
+{
+    static bool convert(ToType** output, FromType* const input)
+    {
+        ToType* temp = dynamic_cast<ToType*>(input);
+        if (temp)
+        {
+            *output = temp;
+            return true;
+        }
+        else
+            return false;
+    }
+};
+
+
+///////////////////////
+// ConverterFallback //
+///////////////////////
+
+// Default template for stringstream
+template <class FromType, class ToType>
+struct ConverterStringStream
+{
+    static bool convert(ToType* output, const FromType& input)
+    {
+        return ConverterFallback<FromType, ToType>::convert(output, input);
+    }
+};
+
+
+/////////////
+// OStream //
+/////////////
+
+namespace fallbackTemplates
+{
+    template <class FromType>
+    inline bool operator <<(std::ostream& outstream,  const FromType& input)
+    {
+        std::string temp;
+        if (ConverterFallback<FromType, std::string>::convert(&temp, input))
+        {
+            std::operator <<(outstream, temp);
+            return true;
+        }
+        else
+            return false;
+    }
+}
+
+// template that evaluates whether we can convert to std::string via ostringstream
+template <class FromType>
+struct ConverterStringStream<FromType, std::string>
+{
+    static bool convert(std::string* output, const FromType& input)
+    {
+        using namespace fallbackTemplates;
+        // this operator call only chooses fallbackTemplates::operator<< if there's no other fitting function
+        std::ostringstream oss;
+        if (oss << input)
+        {
+            (*output) = oss.str();
+            return true;
+        }
+        else
+            return false;
+    }
+};
+
+
+/////////////
+// IStream //
+/////////////
+
+namespace fallbackTemplates
+{
+    template <class ToType>
+    inline bool operator >>(std::istream& instream, ToType& output)
+    {
+        return ConverterFallback<std::string, ToType>
+            ::convert(&output, static_cast<std::istringstream&>(instream).str());
+    }
+}
+
+// template that evaluates whether we can convert from std::string via ostringstream
+template <class ToType>
+struct ConverterStringStream<std::string, ToType>
+{
+    static bool convert(ToType* output, const std::string& input)
+    {
+        using namespace fallbackTemplates;
+        std::istringstream iss(input);
+        // this operator call only chooses fallbackTemplates::operator>> if there's no other fitting function
+        if (iss >> (*output))
+        {
+            return true;
+        }
+        else
+            return false;
+    }
+};
+
+
+///////////////////
+// Implicit Cast //
+///////////////////
+
+// implicit cast not possible, try stringstream conversion next
+template <class FromType, class ToType>
+inline bool convertImplicitely(ToType* output, const FromType& input, ::Int2Type<false>)
+{
+    return ConverterStringStream<FromType, ToType>::convert(output, input);
+}
+
+// We can cast implicitely
+template <class FromType, class ToType>
+inline bool convertImplicitely(ToType* output, const FromType& input, ::Int2Type<true>)
+{
+    (*output) = static_cast<ToType>(input);
+    return true;
+}
+
+
+////////////////////////////////
+// ConverterExplicit Fallback //
+////////////////////////////////
+
+// Default template if no specialisation is available
+template <class FromType, class ToType>
+struct ConverterExplicit
+{
+    static bool convert(ToType* output, const FromType& input)
+    {
+        // Try implict cast and probe first. If a simple cast is not possible, it will not compile
+        // We therefore have to out source it into another template function
+        const bool probe = ImplicitConversion<FromType, ToType>::exists;
+        return convertImplicitely(output, input, ::Int2Type<probe>());
+    }
+};
+
+
+//////////////////////
+// Public Functions //
+//////////////////////
+
+/**
+@brief
+    Converts any value to any other as long as there exists a conversion.
+    Otherwise, the conversion will generate a runtime warning and return false.
+    For information about the different conversion methods (user defined too), see the section
+    'Actual conversion sequence' in this file above.
+*/
+template <class FromType, class ToType>
+inline bool convertValue(ToType* output, const FromType& input)
+{
+    return ConverterExplicit<FromType, ToType>::convert(output, input);
+}
+
+// For compatibility reasons. The same, but with capital ConvertValue
+template<class FromType, class ToType>
+inline bool ConvertValue(ToType* output, const FromType& input)
+{
+    return convertValue(output, input);
+}
+
+// Calls convertValue and returns true if the conversion was successful.
+// Otherwise the fallback is used.
+/**
+@brief
+    Converts any value to any other as long as there exists a conversion.
+    Otherwise, the conversion will generate a runtime warning and return false.
+    For information about the different conversion methods (user defined too), see the section
+    'Actual conversion sequence' in this file above.
+    If the conversion doesn't succeed, 'fallback' is written to '*output'.
+@param fallback
+    A default value that gets written to '*output' if there is no conversion.
+*/
+template<class FromType, class ToType>
+inline bool convertValue(ToType* output, const FromType& input, const ToType& fallback)
+{
+    if (convertValue(output, input))
+        return true;
+    else
+    {
+        (*output) = fallback;
+        return false;
+    }
+}
+
+// for compatibility reason. (capital 'c' in ConvertValue)
+template<class FromType, class ToType>
+inline bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback)
+{
+    return convertValue(output, input, fallback);
+}
+
+// Directly returns the converted value, even if the conversion was not successful.
+template<class FromType, class ToType>
+inline ToType getConvertedValue(const FromType& input)
+{
+    ToType output;
+    convertValue(&output, input);
+    return output;
+}
+
+// Directly returns the converted value, but uses the fallback on failure.
+template<class FromType, class ToType>
+inline ToType getConvertedValue(const FromType& input, const ToType& fallback)
+{
+    ToType output;
+    convertValue(&output, input, fallback);
+    return output;
+}
+
+// Like getConvertedValue, but the template argument order is in reverse.
+// That means you can call it exactly like static_cast<ToType>(fromTypeValue).
+template<class ToType, class FromType>
+inline ToType omni_cast(const FromType& input)
+{
+    ToType output;
+    convertValue(&output, input);
+    return output;
+}
+
+// convert to string Shortcut
+template <class FromType>
+inline std::string convertToString(FromType value)
+{
+  return getConvertedValue<FromType, std::string>(value);
+}
+
+// convert from string Shortcut
+template <class ToType>
+inline ToType convertFromString(std::string str)
+{
+  return getConvertedValue<std::string, ToType>(str);
+}
+
+////////////////////////////////
+// Special string conversions //
+////////////////////////////////
+
+// Delegate conversion from const char* to std::string
+template <class ToType>
+struct ConverterExplicit<const char*, ToType>
+{
+    static bool convert(ToType* output, const char* input)
+    {
+        return convertValue<std::string, ToType>(output, input);
+    }
+};
+
+// These conversions would exhibit ambiguous << or >> operators when using stringstream
+template <>
+struct ConverterExplicit<char, std::string>
+{
+    static bool convert(std::string* output, const char input)
+    {
+        *output = std::string(1, input);
+        return true;
+    }
+};
+template <>
+struct ConverterExplicit<unsigned char, std::string>
+{
+    static bool convert(std::string* output, const unsigned char input)
+    {
+        *output = std::string(1, input);
+        return true;
+    }
+};
+template <>
+struct ConverterExplicit<std::string, char>
+{
+    static bool convert(char* output, const std::string input)
+    {
+        if (input != "")
+            *output = input[0];
+        else
+            *output = '\0';
+        return true;
+    }
+};
+template <>
+struct ConverterExplicit<std::string, unsigned char>
+{
+    static bool convert(unsigned char* output, const std::string input)
+    {
+        if (input != "")
+            *output = input[0];
+        else
+            *output = '\0';
+        return true;
+    }
+};
+
+
+// bool to std::string
+template <>
+struct ConverterExplicit<bool, std::string>
+{
+    static bool convert(std::string* output, const bool& input)
+    {
+        if (input)
+          *output = "true";
+        else
+          *output = "false";
+        return false;
+    }
+};
+
+// std::string to bool
+template <>
+struct ConverterExplicit<std::string, bool>
+{
+    static bool convert(bool* output, const std::string& input)
+    {
+        std::string stripped = getLowercase(removeTrailingWhitespaces(input));
+        if (stripped == "true" || stripped == "on" || stripped == "yes")
+        {
+          *output = true;
+          return true;
+        }
+        else if (stripped == "false" || stripped == "off" || stripped == "no")
+        {
+          *output = false;
+          return true;
+        }
+
+        std::istringstream iss(input);
+        if (iss >> (*output))
+            return true;
+        else
+            return false;
+    }
+};
+
+#endif /* _Convert_H__ */
Index: /code/branches/physics/src/util/Debug.h
===================================================================
--- /code/branches/physics/src/util/Debug.h	(revision 2122)
+++ /code/branches/physics/src/util/Debug.h	(revision 2122)
@@ -0,0 +1,262 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Grauer
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+/**
+    @file Debug.h
+    @brief Handles different output-levels of errors, warnings, infos and debug informations.
+
+    The COUT(level) macro acts like std::cout, but the output is only performed if the given
+    level is <= the soft debug level.
+
+    There are two used values in this file:
+     - The hard debug level is used during compiletime. It describes the highest allowed output level.
+     - The soft debug level is used during runtime and is the maximum of the three configurable
+       output-levels for console, logfile and ingame shell.
+
+    The separation between the three devices is done by the OutputHandler.
+
+    Possible levels are:
+     0: Very important output
+     1: Errors
+     2: Warnings
+     3: Informations
+     4: Debug information
+     5: More debug information
+     6: Crazy debug informations
+
+    @example
+    COUT(0) << "Very important output" << std::endl;
+    COUT(1) << "Error: Something went wrong!" << std::endl;
+    COUT(2) << "Warning: There might be a problem." << std::endl;
+    COUT(3) << "Info: It's monday" << std::endl;
+    COUT(4) << "Debug: x is 1.23456" << std::endl;
+ */
+
+#ifndef _Debug_H__
+#define _Debug_H__
+
+#include "UtilPrereqs.h"
+
+#include <stdio.h>
+
+#include "OutputHandler.h"
+
+
+/**
+    @brief Returns the soft debug level, stored in the only existing instance of the OutputHandler class, configured in the config-file.
+    @return The soft debug level
+*/
+static inline int getSoftDebugLevel()
+{
+    return orxonox::OutputHandler::getSoftDebugLevel();
+}
+
+namespace orxonox
+{
+    using std::endl;
+}
+
+// DEFINE ERROR MODES
+#define ORX_NONE            0
+#define ORX_ERROR           1
+#define ORX_WARNING         2
+#define ORX_INFO            3
+#define ORX_DEBUG           4
+#define ORX_VERBOSE         5
+#define ORX_ULTRA           6
+
+//definitions
+#define ORX_PRINT_DEBUG_OUTPUT 1
+#define ORX_HARD_DEBUG_LEVEL ORX_VERBOSE
+
+#define COUT_EXEC(x) orxonox::OutputHandler::getOutStream().setOutputLevel(x)
+
+////////////////////////////////////////////////////////
+///  COUT: just prints output as is with std::cout   ///
+////////////////////////////////////////////////////////
+#define COUTORX_NONE    COUT0
+#define COUTORX_ERROR   COUT1
+#define COUTORX_WARNING COUT2
+#define COUTORX_INFO    COUT3
+#define COUTORX_DEBUG   COUT4
+#define COUTORX_VERBOSE COUT5
+#define COUTORX_ULTRA   COUT6
+
+#ifndef COUT
+ #if ORX_PRINT_DEBUG_OUTPUT
+  #define COUT(x) \
+   COUT ## x
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
+   #define COUT0 \
+    (getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : COUT_EXEC(0)
+  #else
+   #define COUT0 \
+    false ? COUT_EXEC(0) : COUT_EXEC(0)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define COUT1 \
+    (getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : COUT_EXEC(1)
+  #else
+   #define COUT1 \
+    false ? COUT_EXEC(1) : COUT_EXEC(1)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define COUT2 \
+    (getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : COUT_EXEC(2)
+  #else
+   #define COUT2 \
+    false ? COUT_EXEC(2) : COUT_EXEC(2)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define COUT3 \
+    (getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : COUT_EXEC(3)
+  #else
+   #define COUT3 \
+    false ? COUT_EXEC(3) : COUT_EXEC(3)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define COUT4 \
+    (getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : COUT_EXEC(4)
+  #else
+   #define COUT4 \
+    false ? COUT_EXEC(4) : COUT_EXEC(4)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
+   #define COUT5 \
+    (getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : COUT_EXEC(5)
+  #else
+   #define COUT5 \
+    false ? COUT_EXEC(5) : COUT_EXEC(5)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
+   #define COUT6 \
+    (getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : COUT_EXEC(6)
+  #else
+   #define COUT6 \
+    false ? COUT_EXEC(6) : COUT_EXEC(6)
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define COUT(x) \
+    false ? COUT_EXEC(6) : COUT_EXEC(6)
+ #endif /* if ORX_PRINT_DEBUG_OUTPUT */
+
+#endif /* ifndef COUT */
+
+
+/////////////////////////////////////////////////////////////////////
+///  CCOUT: Prints output with std::cout and adds the classname   ///
+/////////////////////////////////////////////////////////////////////
+#define CCOUTORX_NONE    CCOUT0
+#define CCOUTORX_ERROR   CCOUT1
+#define CCOUTORX_WARNING CCOUT2
+#define CCOUTORX_INFO    CCOUT3
+#define CCOUTORX_DEBUG   CCOUT4
+#define CCOUTORX_VERBOSE CCOUT5
+#define CCOUTORX_ULTRA   CCOUT6
+
+#define CCOUT_EXEC(x) \
+  orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
+  << this->getIdentifier()->getName() << ": "
+
+#ifndef CCOUT
+ #if ORX_PRINT_DEBUG_OUTPUT
+  #define CCOUT(x) \
+   CCOUT ## x
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
+   #define CCOUT0 \
+    (getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : CCOUT_EXEC(0)
+  #else
+   #define CCOUT0 \
+    false ? COUT_EXEC(0) : CCOUT_EXEC(0)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define CCOUT1 \
+    (getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : CCOUT_EXEC(1)
+  #else
+   #define CCOUT1 \
+    false ? COUT_EXEC(1) : CCOUT_EXEC(1)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define CCOUT2 \
+    (getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : CCOUT_EXEC(2)
+  #else
+   #define CCOUT2 \
+    false ? COUT_EXEC(2) : CCOUT_EXEC(2)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define CCOUT3 \
+    (getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : CCOUT_EXEC(3)
+  #else
+   #define CCOUT3 \
+    false ? COUT_EXEC(3) : CCOUT_EXEC(3)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define CCOUT4 \
+    (getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : CCOUT_EXEC(4)
+  #else
+   #define CCOUT4 \
+    false ? COUT_EXEC(4) : CCOUT_EXEC(4)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
+   #define CCOUT5 \
+    (getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : CCOUT_EXEC(5)
+  #else
+   #define CCOUT5 \
+    false ? COUT_EXEC(5) : CCOUT_EXEC(5)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
+   #define CCOUT6 \
+    (getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : CCOUT_EXEC(6)
+  #else
+   #define CCOUT6 \
+    false ? COUT_EXEC(6) : CCOUT_EXEC(6)
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define CCOUT(x) \
+   false ? CCOUT_EXEC(6) : CCOUT_EXEC(6)
+ #endif /* if ORX_PRINT_DEBUG_OUTPUT */
+
+#endif /* ifndef CCOUT */
+
+#endif /* _Debug_H__ */
Index: /code/branches/physics/src/util/Exception.cc
===================================================================
--- /code/branches/physics/src/util/Exception.cc	(revision 2122)
+++ /code/branches/physics/src/util/Exception.cc	(revision 2122)
@@ -0,0 +1,85 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the Exception class.
+*/
+
+#include "Exception.h"
+
+namespace orxonox
+{
+    Exception::Exception(const std::string& description, int lineNumber,
+                         const char* filename, const char* functionName)
+        : description_(description)
+        , lineNumber_(lineNumber)
+        , functionName_(functionName)
+        , filename_(filename)
+    { }
+
+    Exception::Exception(const std::string& description)
+        : description_(description)
+        , lineNumber_(0)
+        , functionName_("")
+        , filename_("")
+    { }
+
+    const std::string& Exception::getFullDescription() const
+    {
+        if (fullDescription_ == "")
+        {
+            std::ostringstream fullDesc;
+
+            fullDesc << this->getTypeName() << "_EXCEPTION";
+
+            if (this->filename_ != "")
+            {
+                fullDesc << " in " << this->filename_;
+                if (this->lineNumber_)
+                    fullDesc << "(" << this->lineNumber_ << ")";
+            }
+
+            if (this->functionName_ != "")
+                fullDesc << " in function '" << this->functionName_ << "'";
+
+            fullDesc << ": ";
+            if (this->description_ != "")
+                fullDesc << this->description_;
+            else
+                fullDesc << "No description available.";
+
+            this->fullDescription_ = std::string(fullDesc.str());
+        }
+
+        return fullDescription_;
+    }
+
+
+}
Index: /code/branches/physics/src/util/Exception.h
===================================================================
--- /code/branches/physics/src/util/Exception.h	(revision 2122)
+++ /code/branches/physics/src/util/Exception.h	(revision 2122)
@@ -0,0 +1,158 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Declaration of the Exception class.
+*/
+
+#ifndef _Exception_H__
+#define _Exception_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <exception>
+#include <cassert>
+#include "Debug.h"
+
+// Define some ugly macros to make things more clear
+#define CREATE_ORXONOX_EXCEPTION(name) typedef SpecificException<Exception::name> name##Exception;
+#define RETURN_EXCEPTION_CODE(name) \
+    case Exception::name:           \
+        return #name;
+
+
+namespace orxonox
+{
+    class _UtilExport Exception : public std::exception
+    {
+    public:
+        enum ExceptionType
+        {
+            General,
+            FileNotFound,
+            Argument,
+            PluginsNotFound,
+            InitialisationFailed,
+            NotImplemented,
+            GameState
+        };
+
+        Exception(const std::string& description, int lineNumber,
+                  const char* filename, const char* functionName);
+        Exception(const std::string& description);
+
+        /// Needed for  compatibility with std::exception (from Ogre::Exception)
+        virtual ~Exception() throw() { }
+
+        virtual const std::string& getFullDescription() const;
+        virtual ExceptionType      getType()            const = 0;
+        virtual std::string        getTypeName()        const = 0;
+        virtual const std::string& getDescription()     const { return this->description_; }
+        virtual const int          getLineNumber()      const { return this->lineNumber_; }
+        virtual const std::string& getFunctionName()    const { return this->functionName_; }
+
+        /// Override std::exception::what (from Ogre::Exception)
+        const char* what() const throw() { return getFullDescription().c_str(); }
+
+    protected:
+        std::string description_;
+        int lineNumber_;
+        std::string functionName_;
+        std::string filename_;
+        // mutable because "what()" is a const method
+        mutable std::string fullDescription_;
+    };
+
+
+    template <Exception::ExceptionType Type>
+    class SpecificException : public Exception
+    {
+    public:
+        SpecificException(const std::string& description, int lineNumber,
+                  const char* filename, const char* functionName)
+                  : Exception(description, lineNumber, filename, functionName)
+        {
+            // let the catcher decide whether to display the message below level 4
+            COUT(4) << this->getFullDescription() << std::endl;
+        }
+
+        SpecificException(const std::string& description)
+            : Exception(description)
+        {
+            // let the catcher decide whether to display the message below level 4
+            COUT(4) << this->getFullDescription() << std::endl;
+        }
+
+        ~SpecificException() throw() { }
+
+        ExceptionType getType() const { return Type; }
+        std::string getTypeName() const
+        {
+            // note: break is not necessary due to the return in the macros.
+            switch (Type)
+            {
+            RETURN_EXCEPTION_CODE(General)
+            RETURN_EXCEPTION_CODE(FileNotFound);
+            RETURN_EXCEPTION_CODE(Argument);
+            RETURN_EXCEPTION_CODE(PluginsNotFound);
+            RETURN_EXCEPTION_CODE(InitialisationFailed);
+            RETURN_EXCEPTION_CODE(NotImplemented);
+            RETURN_EXCEPTION_CODE(GameState);
+            default:
+                return "";
+            }
+        }
+    };
+
+    // define the template spcialisations
+    CREATE_ORXONOX_EXCEPTION(General);
+    CREATE_ORXONOX_EXCEPTION(FileNotFound);
+    CREATE_ORXONOX_EXCEPTION(Argument);
+    CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
+    CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
+    CREATE_ORXONOX_EXCEPTION(NotImplemented);
+    CREATE_ORXONOX_EXCEPTION(GameState);
+
+#define ThrowException(type, description) \
+    throw SpecificException<Exception::type>(description, __LINE__, __FILE__, __FUNCTIONNAME__)
+
+    // define an assert macro that can display a message
+#ifndef NDEBUG
+#define OrxAssert(assertion, errorMessage) \
+    assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << errorMessage << std::endl); \
+    assert(assertion)
+#else
+#define OrxAssert(condition, errorMessage)  ((void)0)
+#endif
+
+}
+
+#endif /* _Exception_H__ */
Index: /code/branches/physics/src/util/ExprParser.cc
===================================================================
--- /code/branches/physics/src/util/ExprParser.cc	(revision 2122)
+++ /code/branches/physics/src/util/ExprParser.cc	(revision 2122)
@@ -0,0 +1,450 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Declaration of FloatParser
+*/
+
+#include "ExprParser.h"
+#include <cmath>
+#include <cstring>
+#include <stdlib.h>
+
+// macros for easier if, else statements
+#define CASE_1(var) if (!strcmp(SWITCH,var))
+#define CASE(var) else if (!strcmp(SWITCH,var))
+#define CASE_ELSE else
+
+//! skip white spaces
+#define PARSE_BLANKS while (*reading_stream == ' ') ++reading_stream
+
+ExprParser::ExprParser(const std::string& str)
+{
+    this->failed_ = false;
+    this->reading_stream = str.c_str();
+    if (str.size() == 0 || *reading_stream == '\0')
+    {
+        this->failed_ = true;
+        this->result_ = 0.0;
+    }
+    else
+    {
+        this->result_ = parse_expr_8();
+        this->remains_ = reading_stream;
+    }
+}
+
+//Private functions:
+/******************/
+double ExprParser::parse_argument()
+{
+    double value = parse_expr_8();
+    if (*reading_stream == ',')
+    {
+        ++reading_stream;
+        return value;
+    }
+    else
+    {
+        this->failed_ = true;
+        return 0;
+    }
+}
+
+double ExprParser::parse_last_argument()
+{
+    double value = parse_expr_8();
+    if (*reading_stream == ')')
+    {
+        ++reading_stream;
+        return value;
+    }
+    else
+    {
+        this->failed_ = true;
+        return 0;
+    }
+}
+
+double ExprParser::parse_expr_8()
+{
+    double value = parse_expr_7();
+    for(;;)
+    {
+        switch (op)
+        {
+        case oder:
+            value = parse_expr_7() || value;
+            break;
+        default: return value;
+        }
+    };
+}
+
+
+double ExprParser::parse_expr_7()
+{
+    double value = parse_expr_6();
+    for(;;)
+    {
+        switch (op)
+        {
+        case und:
+            value = value && parse_expr_6();
+            break;
+        default: return value;
+        }
+    };
+}
+
+double ExprParser::parse_expr_6()
+{
+    double value = parse_expr_5();
+    for(;;)
+    {
+        switch (op)
+        {
+        case gleich:
+            value = (value == parse_expr_5());
+            break;
+        case ungleich:
+            value = (value != parse_expr_5());
+            break;
+        default:
+            return value;
+        }
+    };
+}
+
+double ExprParser::parse_expr_5()
+{
+    double value = parse_expr_4();
+    for(;;)
+    {
+        switch (op)
+        {
+        case kleiner:
+            value = (value < parse_expr_4());
+            break;
+        case kleinergleich:
+            value = (value <= parse_expr_4());
+            break;
+        case groesser:
+            value = (value > parse_expr_4());
+            break;
+        case groessergleich:
+            value = (value >= parse_expr_4());
+            break;
+        default:
+            return value;
+        }
+    };
+}
+
+double ExprParser::parse_expr_4()
+{
+    double value = parse_expr_3();
+    for(;;)
+    {
+        switch (op)
+        {
+        case b_plus:
+            value += parse_expr_3();
+            break;
+        case b_minus:
+            value -= parse_expr_3();
+            break;
+        default:
+            return value;
+        }
+    };
+}
+
+double ExprParser::parse_expr_3()
+{
+    double value = parse_expr_2();
+    for(;;)
+    {
+        switch (op)
+        {
+        case mal:
+            value *= parse_expr_2();
+            break;
+        case durch:
+            value /= parse_expr_2();
+            break;
+        case modulo:
+            {
+                double temp = parse_expr_2();
+                value = value - floor(value/temp)*temp;
+                break;
+            }
+        default:
+            return value;
+        }
+    };
+}
+
+double ExprParser::parse_expr_2()
+{
+    double value = parse_expr_1();
+    while (*reading_stream != '\0')
+    {
+        op = parse_binary_operator();
+        switch (op)
+        {
+        case hoch:
+            value = pow(value,parse_expr_1());
+            break;
+        default:
+            return value;
+        }
+    };
+    op = undef;
+    return value;
+}
+
+double ExprParser::parse_expr_1()
+{
+    PARSE_BLANKS;
+    double value;
+
+    unary_operator op = parse_unary_operator();
+    PARSE_BLANKS;
+
+    if (*reading_stream == '\0')
+    {
+        // end of string
+        this->failed_ = true;
+        return 0;
+    }
+    else if (*reading_stream > 47 && *reading_stream < 59 || *reading_stream == 46)
+    {  // number
+        value = strtod(reading_stream, const_cast<char**>(&reading_stream));
+    }
+    else if (*reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)
+    {  // variable or function
+        char* word = new char[256];
+        parse_word(word);
+        PARSE_BLANKS;
+        if (*reading_stream == '(')
+        {
+            ++reading_stream;
+#define SWITCH word
+            CASE_1("sin")
+                value = sin(parse_last_argument());
+            CASE("asin")
+                value = asin(parse_last_argument());
+            CASE("sinh")
+                value = sinh(parse_last_argument());
+            CASE("asinh")
+            {
+                value = parse_last_argument();
+                value = log(sqrt(pow(value, 2) + 1) + value);
+            }
+            CASE("cos")
+                value = cos(parse_last_argument());
+            CASE("acos")
+                value = acos(parse_last_argument());
+            CASE("cosh")
+                value = cosh(parse_last_argument());
+            CASE("acosh")
+            {
+                value = parse_last_argument();
+                value = log(sqrt(pow(value, 2) - 1) + value);
+            }
+            CASE("tan")
+                value = tan(parse_last_argument());
+            CASE("atan")
+                value = atan(parse_last_argument());
+            CASE("atan2")
+                value = atan2(parse_argument(),parse_last_argument());
+            CASE("tanh")
+                value = tanh(parse_last_argument());
+            CASE("atanh")
+            {
+                value = parse_last_argument();
+                value = 0.5*log((value + 1)/(value - 1));
+            }
+            CASE("int")
+                value = floor(parse_last_argument());
+            CASE("floor")
+                value = floor(parse_last_argument());
+            CASE("ceil")
+                value = ceil(parse_last_argument());
+            CASE("abs")
+                value = fabs(parse_last_argument());
+            CASE("exp")
+                value = exp(parse_last_argument());
+            CASE("log")
+                value = log10(parse_last_argument());
+            CASE("ln")
+                value = log(parse_last_argument());
+            CASE("sign")
+            {
+                value = parse_last_argument();
+                value = (value>0 ? 1 : (value<0 ? -1 : 0));
+            }
+            CASE("sqrt")
+                value = sqrt(parse_last_argument());
+            CASE("degrees")
+                value = parse_last_argument()*180/3.1415926535897932;
+            CASE("radians")
+                value = parse_last_argument()*3.1415926535897932/180;
+            CASE("mod")
+            {
+                value = parse_argument();
+                double value2 = parse_last_argument();
+                value = value - floor(value/value2)*value2;
+            }
+            CASE("pow")
+                value = pow(parse_argument(),parse_last_argument());
+            CASE("div")
+                value = floor(parse_argument()/parse_last_argument());
+            CASE("max")
+                value = std::max(parse_argument(),parse_last_argument());
+            CASE("min")
+                value = std::min(parse_argument(),parse_last_argument());
+            CASE_ELSE
+            {
+                this->failed_ = true;
+                delete[] word;
+                return 0;
+            }
+        }
+        else
+        {
+#define SWITCH word
+            CASE_1("pi")
+                value = 3.1415926535897932;
+            CASE("e")
+                value = 2.7182818284590452;
+            CASE_ELSE
+            {
+                this->failed_ = true;
+                delete[] word;
+                return 0;
+            }
+        }
+        delete[] word;
+    }
+    else if (*reading_stream == 40)
+    {  // expresion in paranthesis
+        ++reading_stream;
+        value = parse_last_argument();
+    }
+    else
+    {
+        this->failed_ = true;
+        return 0;
+    }
+
+    PARSE_BLANKS;
+    switch (op)
+    {
+    case u_nicht: return !value;
+    case u_plus:  return  value;
+    case u_minus: return -value;
+    default:
+        this->failed_ = true;
+        return 0;
+    }
+}
+
+char* ExprParser::parse_word(char* str)
+{
+    char* word = str;
+    int counter = 0;
+    while (*reading_stream > 47 && *reading_stream < 58 || *reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)
+    {
+        *word++ = *reading_stream++;
+        counter++;
+        if (counter > 255)
+        {
+            this->failed_ = true;
+            return '\0';
+        }
+    };
+    *word = '\0';
+    return str;
+}
+
+ExprParser::binary_operator ExprParser::parse_binary_operator()
+{
+    binary_operator op;
+    switch (*reading_stream)
+    {
+    case '+': op = b_plus; break;
+    case '-': op = b_minus; break;
+    case '*': op = mal; break;
+    case '/': op = durch; break;
+    case '^': op = hoch; break;
+    case '%': op = modulo; break;
+    case '&': op = und; break;
+    case '|': op = oder; break;
+    case '=': op = gleich; break;
+    case '!': op = b_nicht; break;
+    case '<': op = kleiner; break;
+    case '>': op = groesser; break;
+    default: return undef;
+    }
+    if (*++reading_stream == '=')
+    {
+        if (op > 9)
+        {
+            ++reading_stream;
+            return (binary_operator)(op + 3);
+        }
+        else
+        {
+            --reading_stream;
+            return undef;
+        }
+    }
+    else
+        return op;
+}
+
+ExprParser::unary_operator ExprParser::parse_unary_operator()
+{
+    switch (*reading_stream)
+    {
+    case '!':
+        ++reading_stream;
+        return u_nicht;
+    case '+':
+        ++reading_stream;
+        return u_plus;
+    case '-':
+        ++reading_stream;
+        return u_minus;
+    default :
+        return u_plus;
+    }
+}
Index: /code/branches/physics/src/util/ExprParser.h
===================================================================
--- /code/branches/physics/src/util/ExprParser.h	(revision 2122)
+++ /code/branches/physics/src/util/ExprParser.h	(revision 2122)
@@ -0,0 +1,107 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Declaration of FloatParser
+*/
+
+#ifndef _FloatParser_H__
+#define _FloatParser_H__
+
+#include "UtilPrereqs.h"
+#include <string>
+
+class _UtilExport ExprParser
+{
+public:
+    enum binary_operator
+    {
+        b_plus,
+        b_minus,
+        mal,
+        durch,
+        modulo,
+        hoch,
+        undef,
+        oder,
+        und,
+        gleich,
+        b_nicht,
+        kleiner,
+        groesser,
+        ungleich,
+        kleinergleich,
+        groessergleich
+    };
+
+    enum unary_operator
+    {
+        u_plus,
+        u_minus,
+        u_nicht
+    };
+
+
+    ExprParser(const std::string& str);
+    std::string& getRemains() { return  this->remains_; }
+    double       getResult()  { return  this->result_; }
+    bool         getSuccess() { return !this->failed_; }
+
+private:
+    double parse_expr_1();
+    double parse_expr_2();
+    double parse_expr_3();
+    double parse_expr_4();
+    double parse_expr_5();
+    double parse_expr_6();
+    double parse_expr_7();
+    double parse_expr_8();
+    char* parse_word(char* str);
+    binary_operator parse_binary_operator();
+    unary_operator parse_unary_operator();
+
+    double parse_argument();
+    double parse_last_argument();
+
+    binary_operator op;
+    const char* reading_stream;
+    bool failed_;
+    double result_;
+    std::string remains_;
+
+};
+
+//Endzeichen für float expression: ')', '}', ']', ',', ';'
+_UtilExport bool parse_float(char* const, char**, double*);
+//Endzeichen angegeben
+_UtilExport bool parse_float(char* const, char**, char, double*);
+//Letzter Teil-float eines Vektors parsen (keine Vergleichs- und Logikoperationen)
+_UtilExport bool parse_vector_float(char* const, char**, bool, double*);
+
+#endif /* _FloatParser_H__ */
Index: /code/branches/physics/src/util/Integers.h
===================================================================
--- /code/branches/physics/src/util/Integers.h	(revision 2122)
+++ /code/branches/physics/src/util/Integers.h	(revision 2122)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief
+    Defines fixed with integers
+ */
+
+#ifndef _Integers_H__
+#define _Integers_H__
+
+#include "OrxonoxPlatform.h"
+
+/* Define fixed with integers
+ * Note: This is not in a namespace to make it available everywhere!*/
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+typedef __int8            int8_t;
+typedef __int16           int16_t;
+typedef __int32           int32_t;
+typedef __int64           int64_t;
+typedef unsigned __int8   uint8_t;
+typedef unsigned __int16  uint16_t;
+typedef unsigned __int32  uint32_t;
+typedef unsigned __int64  uint64_t;
+#elif ORXONOX_COMPILER == ORXONOX_COMPILER_GCC
+# include "inttypes.h"
+#endif
+
+#endif /* _Integers_H__ */
Index: /code/branches/physics/src/util/Math.cc
===================================================================
--- /code/branches/physics/src/util/Math.cc	(revision 2122)
+++ /code/branches/physics/src/util/Math.cc	(revision 2122)
@@ -0,0 +1,333 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of several math-functions.
+*/
+
+#include "Math.h"
+
+#include <OgrePlane.h>
+#include "MathConvert.h"
+#include "SubString.h"
+
+/**
+    @brief Function for writing a Radian to a stream.
+*/
+std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian)
+{
+    out << radian.valueRadians();
+    return out;
+}
+
+/**
+    @brief Function for reading a Radian from a stream.
+*/
+std::istream& operator>>(std::istream& in, orxonox::Radian& radian)
+{
+    float temp;
+    in >> temp;
+    radian = temp;
+    return in;
+}
+
+/**
+    @brief Function for writing a Degree to a stream.
+*/
+std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
+{
+    out << degree.valueDegrees();
+    return out;
+}
+
+/**
+    @brief Function for reading a Degree from a stream.
+*/
+std::istream& operator>>(std::istream& in, orxonox::Degree& degree)
+{
+    float temp;
+    in >> temp;
+    degree = temp;
+    return in;
+}
+
+
+/**
+    @brief Gets the angle between my viewing direction and the direction to the position of the other object.
+    @param myposition My position
+    @param mydirection My viewing direction
+    @param otherposition The position of the other object
+    @return The angle
+
+    @example
+    If the other object is exactly in front of me, the function returns 0.
+    If the other object is exactly behind me, the function returns pi.
+    If the other object is exactly right/left to me (or above/below), the function returns pi/2.
+*/
+float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition)
+{
+    orxonox::Vector3 distance = otherposition - myposition;
+    float distancelength = distance.length();
+    if (distancelength == 0)
+        return 0;
+    else
+        return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1));
+}
+
+/**
+    @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object.
+    @param myposition My position
+    @param mydirection My viewing direction
+    @param myorthonormal My orthonormalvector (pointing upwards through my head)
+    @param otherposition The position of the other object
+    @return The viewing direction
+
+    @example
+    If the other object is exactly in front of me, the function returns Vector2(0, 0).
+    If the other object is exactly at my left, the function returns Vector2(-1, 0).
+    If the other object is exactly at my right, the function returns Vector2(1, 0).
+    If the other object is only a bit at my right, the function still returns Vector2(1, 0).
+    If the other object is exactly above me, the function returns Vector2(0, 1).
+*/
+orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
+{
+    orxonox::Vector3 distance = otherposition - myposition;
+
+    // project difference vector on our plane
+    orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
+
+    float projectionlength = projection.length();
+    if (projectionlength == 0) return orxonox::Vector2(0, 0);
+    float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
+
+    if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
+        return orxonox::Vector2(sin(angle), cos(angle));
+    else
+        return orxonox::Vector2(-sin(angle), cos(angle));
+}
+
+/**
+    @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0° = 0, 180° = 1).
+    @param myposition My position
+    @param mydirection My viewing direction
+    @param myorthonormal My orthonormalvector (pointing upwards through my head)
+    @param otherposition The position of the other object
+    @return The viewing direction
+
+    @example
+    If the other object is exactly in front of me, the function returns Vector2(0, 0).
+    If the other object is exactly at my left, the function returns Vector2(-0.5, 0).
+    If the other object is exactly at my right, the function returns Vector2(0.5, 0).
+    If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).
+    If the other object is exactly above me, the function returns Vector2(0, 0.5).
+*/
+orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
+{
+    orxonox::Vector3 distance = otherposition - myposition;
+
+    // project difference vector on our plane
+    orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
+
+    float projectionlength = projection.length();
+    if (projectionlength == 0) return orxonox::Vector2(0, 0);
+    float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
+
+    float distancelength = distance.length();
+    if (distancelength == 0) return orxonox::Vector2(0, 0);
+    float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI;
+
+    if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
+        return orxonox::Vector2(sin(angle) * radius, cos(angle) * radius);
+    else
+        return orxonox::Vector2(-sin(angle) * radius, cos(angle) * radius);
+}
+
+/**
+    @brief Returns the predicted position I have to aim at, if I want to hit a moving target with a moving projectile.
+    @param myposition My position
+    @param projectilespeed The speed of my projectile
+    @param targetposition The position of my target
+    @param targetvelocity The velocity of my target
+    @return The predicted position
+
+    The function predicts the position based on a linear velocity of the target. If the target changes speed or direction, the projectile will miss.
+*/
+orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity)
+{
+    float squaredProjectilespeed = projectilespeed * projectilespeed;
+    orxonox::Vector3 distance = targetposition - myposition;
+    float a = distance.squaredLength();
+    float b = 2 * (distance.x + distance.y + distance.z) * (targetvelocity.x + targetvelocity.y + targetvelocity.z);
+    float c = targetvelocity.squaredLength();
+
+    float temp = 4*squaredProjectilespeed*c + a*a - 4*b*c;
+    if (temp < 0)
+        return orxonox::Vector3::ZERO;
+
+    temp = sqrt(temp);
+    float time = (temp + a) / (2 * (squaredProjectilespeed - b));
+    return (targetposition + targetvelocity * time);
+}
+
+unsigned long getUniqueNumber()
+{
+    static unsigned long aNumber = 135;
+    return aNumber++;
+}
+
+
+//////////////////////////
+// Conversion functions //
+//////////////////////////
+
+// std::string to Vector2
+bool ConverterFallback<std::string, orxonox::Vector2>::convert(orxonox::Vector2* output, const std::string& input)
+{
+    size_t opening_parenthesis, closing_parenthesis = input.find(')');
+    if ((opening_parenthesis = input.find('(')) == std::string::npos)
+        opening_parenthesis = 0;
+    else
+        opening_parenthesis++;
+
+    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
+                     ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+    if (tokens.size() >= 2)
+    {
+        if (!ConvertValue(&(output->x), tokens[0]))
+            return false;
+        if (!ConvertValue(&(output->y), tokens[1]))
+            return false;
+
+        return true;
+    }
+    return false;
+}
+
+// std::string to Vector3
+bool ConverterFallback<std::string, orxonox::Vector3>::convert(orxonox::Vector3* output, const std::string& input)
+{
+    size_t opening_parenthesis, closing_parenthesis = input.find(')');
+    if ((opening_parenthesis = input.find('(')) == std::string::npos)
+        opening_parenthesis = 0;
+    else
+        opening_parenthesis++;
+
+    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
+                     ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+    if (tokens.size() >= 3)
+    {
+        if (!ConvertValue(&(output->x), tokens[0]))
+            return false;
+        if (!ConvertValue(&(output->y), tokens[1]))
+            return false;
+        if (!ConvertValue(&(output->z), tokens[2]))
+            return false;
+
+        return true;
+    }
+    return false;
+}
+
+// std::string to Vector4
+bool ConverterFallback<std::string, orxonox::Vector4>::convert(orxonox::Vector4* output, const std::string& input)
+{
+    size_t opening_parenthesis, closing_parenthesis = input.find(')');
+    if ((opening_parenthesis = input.find('(')) == std::string::npos)
+        opening_parenthesis = 0;
+    else
+        opening_parenthesis++;
+
+    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
+                     ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+    if (tokens.size() >= 4)
+    {
+        if (!ConvertValue(&(output->x), tokens[0]))
+            return false;
+        if (!ConvertValue(&(output->y), tokens[1]))
+            return false;
+        if (!ConvertValue(&(output->z), tokens[2]))
+            return false;
+        if (!ConvertValue(&(output->w), tokens[3]))
+            return false;
+
+        return true;
+    }
+    return false;
+}
+
+// std::string to Quaternion
+bool ConverterFallback<std::string, orxonox::Quaternion>::convert(orxonox::Quaternion* output, const std::string& input)
+{
+    size_t opening_parenthesis, closing_parenthesis = input.find(')');
+    if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+
+    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+    if (tokens.size() >= 4)
+    {
+        if (!ConvertValue(&(output->w), tokens[0]))
+            return false;
+        if (!ConvertValue(&(output->x), tokens[1]))
+            return false;
+        if (!ConvertValue(&(output->y), tokens[2]))
+            return false;
+        if (!ConvertValue(&(output->z), tokens[3]))
+            return false;
+
+        return true;
+    }
+    return false;
+}
+
+// std::string to ColourValue
+bool ConverterFallback<std::string, orxonox::ColourValue>::convert(orxonox::ColourValue* output, const std::string& input)
+{
+    size_t opening_parenthesis, closing_parenthesis = input.find(')');
+    if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+
+    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+    if (tokens.size() >= 3)
+    {
+        if (!ConvertValue(&(output->r), tokens[0]))
+            return false;
+        if (!ConvertValue(&(output->g), tokens[1]))
+            return false;
+        if (!ConvertValue(&(output->b), tokens[2]))
+            return false;
+        if (tokens.size() >= 4)
+        {
+            if (!ConvertValue(&(output->a), tokens[3]))
+                return false;
+        }
+        else
+            output->a = 1.0;
+
+        return true;
+    }
+    return false;
+}
Index: /code/branches/physics/src/util/Math.h
===================================================================
--- /code/branches/physics/src/util/Math.h	(revision 2122)
+++ /code/branches/physics/src/util/Math.h	(revision 2122)
@@ -0,0 +1,297 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Math.h
+    @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
+*/
+
+#ifndef _Util_Math_H__
+#define _Util_Math_H__
+
+#include "UtilPrereqs.h"
+
+#include <ostream>
+#include <string>
+#include <boost/static_assert.hpp>
+
+#include <OgreMath.h>
+#include <OgreVector2.h>
+#include <OgreVector3.h>
+#include <OgreVector4.h>
+#include <OgreMatrix3.h>
+#include <OgreMatrix4.h>
+#include <OgreQuaternion.h>
+#include <OgreColourValue.h>
+
+namespace orxonox
+{
+  typedef Ogre::Radian Radian;
+  typedef Ogre::Degree Degree;
+  typedef Ogre::Vector2 Vector2;
+  typedef Ogre::Vector3 Vector3;
+  typedef Ogre::Vector4 Vector4;
+  typedef Ogre::Matrix3 Matrix3;
+  typedef Ogre::Matrix4 Matrix4;
+  typedef Ogre::Quaternion Quaternion;
+  typedef Ogre::ColourValue ColourValue;
+}
+
+_UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
+_UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
+_UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
+_UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree);
+
+_UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
+_UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
+_UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
+_UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
+
+//Get around Windows hackery
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+#  ifdef max
+#    undef max
+#  endif
+#  ifdef min
+#    undef min
+#  endif
+#endif
+
+/**
+    @brief Returns the sign of the given value.
+    @param x The value
+    @return 1 if the value is positive or zero, -1 if the value is negative
+*/
+template <typename T>
+inline T sgn(T x)
+{
+    return (x >= 0) ? 1 : -1;
+}
+
+/**
+    @brief Returns the smaller of two values.
+*/
+template <typename T>
+inline T min(T a, T b)
+{
+    return (a <= b) ? a : b;
+}
+
+/**
+    @brief Returns the greater of two values.
+*/
+template <typename T>
+inline T max(T a, T b)
+{
+    return (a >= b) ? a : b;
+}
+
+/**
+    @brief Keeps a value between a lower and an upper limit.
+    @param x The value
+    @param min The lower limit
+    @param max The upper limit
+*/
+template <typename T>
+inline T clamp(T x, T min, T max)
+{
+    if (x < min)
+        return min;
+
+    if (x > max)
+        return max;
+
+    return x;
+}
+
+/**
+    @brief Returns the square value (x^2).
+*/
+template <typename T>
+inline T square(T x)
+{
+    return x*x;
+}
+
+/**
+    @brief Returns the cube value (x^3).
+*/
+template <typename T>
+inline T cube(T x)
+{
+    return x*x*x;
+}
+
+/**
+    @brief Rounds the value down.
+*/
+template <typename T>
+inline int floor(T x)
+{
+    return (int)(x);
+}
+
+/**
+    @brief Rounds the value up.
+*/
+template <typename T>
+inline int ceil(T x)
+{
+    int temp = floor(x);
+    return (temp != x) ? (temp + 1) : temp;
+}
+
+/**
+    @brief Rounds the value.
+*/
+template <typename T>
+inline int round(T x)
+{
+    return (int)(x + 0.5);
+}
+
+/**
+    @brief The modulo operation, enhanced to work properly with negative values.
+    @param x The value
+    @param max The operand
+*/
+template <typename T>
+inline int mod(T x, int max)
+{
+    if (x >= 0)
+        return (x % max);
+    else
+        return ((x % max) + max);
+}
+
+template <typename T>
+inline T zeroise()
+{
+    BOOST_STATIC_ASSERT(sizeof(T) == 0);
+    return T();
+}
+
+template <> inline char                 zeroise<char>()                 { return 0; }
+template <> inline unsigned char        zeroise<unsigned char>()        { return 0; }
+template <> inline short                zeroise<short>()                { return 0; }
+template <> inline unsigned short       zeroise<unsigned short>()       { return 0; }
+template <> inline int                  zeroise<int>()                  { return 0; }
+template <> inline unsigned int         zeroise<unsigned int>()         { return 0; }
+template <> inline long                 zeroise<long>()                 { return 0; }
+template <> inline unsigned long        zeroise<unsigned long>()        { return 0; }
+template <> inline long long            zeroise<long long>()            { return 0; }
+template <> inline unsigned long long   zeroise<unsigned long long>()   { return 0; }
+template <> inline float                zeroise<float>()                { return 0; }
+template <> inline double               zeroise<double>()               { return 0; }
+template <> inline long double          zeroise<long double>()          { return 0; }
+template <> inline bool                 zeroise<bool>()                 { return 0; }
+template <> inline void*                zeroise<void*>()                { return 0; }
+template <> inline std::string          zeroise<std::string>()          { return ""; }
+template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
+template <> inline orxonox::Degree      zeroise<orxonox::Degree>()      { return orxonox::Degree(0.0f); }
+template <> inline orxonox::Vector2     zeroise<orxonox::Vector2>()     { return orxonox::Vector2    (0, 0)      ; }
+template <> inline orxonox::Vector3     zeroise<orxonox::Vector3>()     { return orxonox::Vector3    (0, 0, 0)   ; }
+template <> inline orxonox::Vector4     zeroise<orxonox::Vector4>()     { return orxonox::Vector4    (0, 0, 0, 0); }
+template <> inline orxonox::ColourValue zeroise<orxonox::ColourValue>() { return orxonox::ColourValue(0, 0, 0, 0); }
+template <> inline orxonox::Quaternion  zeroise<orxonox::Quaternion>()  { return orxonox::Quaternion (0, 0, 0, 0); }
+
+/**
+    @brief Interpolates between two values for a time between 0 and 1.
+    @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
+    @param start The value at time = 0
+    @param end The value at time = 1
+    @return The interpolation at a given time
+*/
+template <typename T>
+T interpolate(float time, const T& start, const T& end)
+{
+    return time * (end - start) + start;
+}
+
+/**
+    @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again.
+    @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
+    @param start The value at time = 0
+    @param end The value at time = 1
+    @return The smoothed interpolation at a given time
+*/
+template <typename T>
+T interpolateSmooth(float time, const T& start, const T& end)
+{
+    return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start;
+}
+
+/**
+    @brief Returns a random number between 0 and almost 1: 0 <= rnd < 1.
+*/
+inline _UtilExport float rnd()
+{
+    return rand() / (RAND_MAX + 1.0);
+}
+
+/**
+    @brief Returns a random number between 0 and almost max: 0 <= rnd < max.
+    @param max The maximum
+*/
+inline _UtilExport float rnd(float max)
+{
+    return rnd() * max;
+}
+
+/**
+    @brief Returns a random number between min and almost max: min <= rnd < max.
+    @param min The minimum
+    @param max The maximum
+*/
+inline _UtilExport float rnd(float min, float max)
+{
+    return rnd(max - min) + min;
+}
+
+_UtilExport unsigned long getUniqueNumber();
+
+class _UtilExport IntVector2
+{
+public:
+  IntVector2() : x(0), y(0) { }
+  IntVector2(int _x, int _y) : x(_x), y(_y) { }
+  int x;
+  int y;
+};
+
+class _UtilExport IntVector3
+{
+public:
+  IntVector3() : x(0), y(0), z(0) { }
+  IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
+  int x;
+  int y;
+  int z;
+};
+
+#endif /* _Util_Math_H__ */
Index: /code/branches/physics/src/util/MathConvert.h
===================================================================
--- /code/branches/physics/src/util/MathConvert.h	(revision 2122)
+++ /code/branches/physics/src/util/MathConvert.h	(revision 2122)
@@ -0,0 +1,207 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ */
+
+/**
+    @file
+    @brief
+        Math conversion functions. Definitions are in Math.cc
+*/
+
+#ifndef _MathConvert_H__
+#define _MathConvert_H__
+
+#include "UtilPrereqs.h"
+#include "Math.h"
+#include "Convert.h"
+
+
+////////////////////
+// Math to string //
+////////////////////
+
+// Vector2 to std::string
+template <>
+struct ConverterExplicit<orxonox::Vector2, std::string>
+{
+    static bool convert(std::string* output, const orxonox::Vector2& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.x << "," << input.y)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// Vector3 to std::string
+template <>
+struct ConverterExplicit<orxonox::Vector3, std::string>
+{
+    static bool convert(std::string* output, const orxonox::Vector3& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.x << "," << input.y << "," << input.z)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// Vector4 to std::string
+template <>
+struct ConverterExplicit<orxonox::Vector4, std::string>
+{
+    static bool convert(std::string* output, const orxonox::Vector4& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// Quaternion to std::string
+template <>
+struct ConverterExplicit<orxonox::Quaternion, std::string>
+{
+    static bool convert(std::string* output, const orxonox::Quaternion& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// ColourValue to std::string
+template <>
+struct ConverterExplicit<orxonox::ColourValue, std::string>
+{
+    static bool convert(std::string* output, const orxonox::ColourValue& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+
+////////////////////
+// string to Math //
+////////////////////
+
+// std::string to Vector2
+template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector2>
+{ static bool convert(orxonox::Vector2*     output, const std::string& input); };
+// std::string to Vector3
+template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector3>
+{ static bool convert(orxonox::Vector3*     output, const std::string& input); };
+// std::string to Vector4
+template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector4>
+{ static bool convert(orxonox::Vector4*     output, const std::string& input); };
+// std::string to Quaternion
+template <> struct _UtilExport ConverterFallback<std::string, orxonox::Quaternion>
+{ static bool convert(orxonox::Quaternion*  output, const std::string& input); };
+// std::string to ColourValue
+template <> struct _UtilExport ConverterFallback<std::string, orxonox::ColourValue>
+{ static bool convert(orxonox::ColourValue* output, const std::string& input); };
+
+
+///////////////////////////////
+// From and to Radian/Degree //
+///////////////////////////////
+
+// From Radian
+template <class ToType>
+struct ConverterFallback<orxonox::Radian, ToType>
+{
+    static bool convert(ToType* output, const orxonox::Radian& input)
+    {
+        return convertValue<Ogre::Real, ToType>(output, input.valueRadians());
+    }
+};
+
+// From Degree
+template <class ToType>
+struct ConverterFallback<orxonox::Degree, ToType>
+{
+    static bool convert(ToType* output, const orxonox::Degree& input)
+    {
+        return convertValue<Ogre::Real, ToType>(output, input.valueDegrees());
+    }
+};
+
+// To Radian
+template <class FromType>
+struct ConverterFallback<FromType, orxonox::Radian>
+{
+    static bool convert(orxonox::Radian* output, const FromType& input)
+    {
+        float temp;
+        if (convertValue(&temp, input))
+        {
+            *output = temp;
+            return true;
+        }
+        else
+            return false;
+    }
+};
+
+// To Degree
+template <class FromType>
+struct ConverterFallback<FromType, orxonox::Degree>
+{
+    static bool convert(orxonox::Degree* output, const FromType& input)
+    {
+        float temp;
+        if (convertValue(&temp, input))
+        {
+            *output = temp;
+            return true;
+        }
+        else
+            return false;
+    }
+};
+
+#endif /* _MathConvert_H__ */
Index: /code/branches/physics/src/util/MultiType.cc
===================================================================
--- /code/branches/physics/src/util/MultiType.cc	(revision 2122)
+++ /code/branches/physics/src/util/MultiType.cc	(revision 2122)
@@ -0,0 +1,203 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MultiType.cc
+    @brief Implementation of the MultiType.
+*/
+
+#include "MultiType.h"
+#include "MultiTypeValue.h"
+
+/**
+    @brief Converts the current value of the MultiType to a new type.
+    @param type The type
+*/
+bool MultiType::convert(MT_Type type)
+{
+    switch (type)
+    {
+        case MT_char:
+            return this->convert<char>(); break;
+        case MT_uchar:
+            return this->convert<unsigned char>(); break;
+        case MT_short:
+            return this->convert<short>(); break;
+        case MT_ushort:
+            return this->convert<unsigned short>(); break;
+        case MT_int:
+            return this->convert<int>(); break;
+        case MT_uint:
+            return this->convert<unsigned int>(); break;
+        case MT_long:
+            return this->convert<long>(); break;
+        case MT_ulong:
+            return this->convert<unsigned long>(); break;
+        case MT_longlong:
+            return this->convert<long long>(); break;
+        case MT_ulonglong:
+            return this->convert<unsigned long long>(); break;
+        case MT_float:
+            return this->convert<float>(); break;
+        case MT_double:
+            return this->convert<double>(); break;
+        case MT_longdouble:
+            return this->convert<long double>(); break;
+        case MT_bool:
+            return this->convert<bool>(); break;
+        case MT_void:
+            return this->convert<void*>(); break;
+        case MT_string:
+            return this->convert<std::string>(); break;
+        case MT_vector2:
+            return this->convert<orxonox::Vector2>(); break;
+        case MT_vector3:
+            return this->convert<orxonox::Vector3>(); break;
+        case MT_vector4:
+            return this->convert<orxonox::Vector4>(); break;
+        case MT_colourvalue:
+            return this->convert<orxonox::ColourValue>(); break;
+        case MT_quaternion:
+            return this->convert<orxonox::Quaternion>(); break;
+        case MT_radian:
+            return this->convert<orxonox::Radian>(); break;
+        case MT_degree:
+            return this->convert<orxonox::Degree>(); break;
+        default:
+            this->reset(); return false; break;
+    };
+}
+
+/**
+    @brief Returns the name of the current type.
+    @return The name
+*/
+std::string MultiType::getTypename() const
+{
+    MT_Type type = (this->value_) ? this->value_->type_ : MT_null;
+
+    switch (type)
+    {
+        case MT_char:
+            return "char"; break;
+        case MT_uchar:
+            return "unsigned char"; break;
+        case MT_short:
+            return "short"; break;
+        case MT_ushort:
+            return "unsigned short"; break;
+        case MT_int:
+            return "int"; break;
+        case MT_uint:
+            return "unsigned int"; break;
+        case MT_long:
+            return "long"; break;
+        case MT_ulong:
+            return "unsigned long"; break;
+        case MT_longlong:
+            return "long long"; break;
+        case MT_ulonglong:
+            return "unsigned long long"; break;
+        case MT_float:
+            return "float"; break;
+        case MT_double:
+            return "double"; break;
+        case MT_longdouble:
+            return "long double"; break;
+        case MT_bool:
+            return "bool"; break;
+        case MT_void:
+            return "void*"; break;
+        case MT_string:
+            return "std::string"; break;
+        case MT_vector2:
+            return "orxonox::Vector2"; break;
+        case MT_vector3:
+            return "orxonox::Vector3"; break;
+        case MT_vector4:
+            return "orxonox::Vector4"; break;
+        case MT_colourvalue:
+            return "orxonox::ColourValue"; break;
+        case MT_quaternion:
+            return "orxonox::Quaternion"; break;
+        case MT_radian:
+            return "orxonox::Radian"; break;
+        case MT_degree:
+            return "orxonox::Degree"; break;
+        default:
+            return "unknown"; break;
+    };
+}
+
+MultiType::operator char()                 const { return (this->value_) ? ((this->value_->type_ == MT_char       ) ? ((MT_Value<char>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned char()        const { return (this->value_) ? ((this->value_->type_ == MT_uchar      ) ? ((MT_Value<unsigned char>       *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator short()                const { return (this->value_) ? ((this->value_->type_ == MT_short      ) ? ((MT_Value<short>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned short()       const { return (this->value_) ? ((this->value_->type_ == MT_ushort     ) ? ((MT_Value<unsigned short>      *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator int()                  const { return (this->value_) ? ((this->value_->type_ == MT_int        ) ? ((MT_Value<int>                 *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned int()         const { return (this->value_) ? ((this->value_->type_ == MT_uint       ) ? ((MT_Value<unsigned int>        *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator long()                 const { return (this->value_) ? ((this->value_->type_ == MT_long       ) ? ((MT_Value<long>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned long()        const { return (this->value_) ? ((this->value_->type_ == MT_ulong      ) ? ((MT_Value<unsigned long>       *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator long long()            const { return (this->value_) ? ((this->value_->type_ == MT_longlong   ) ? ((MT_Value<long long>           *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned long long()   const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong  ) ? ((MT_Value<unsigned long long>  *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator float()                const { return (this->value_) ? ((this->value_->type_ == MT_float      ) ? ((MT_Value<float>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator double()               const { return (this->value_) ? ((this->value_->type_ == MT_double     ) ? ((MT_Value<double>              *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator long double()          const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double>         *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == MT_bool       ) ? ((MT_Value<bool>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == MT_void       ) ? ((MT_Value<void*>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == MT_string     ) ? ((MT_Value<std::string>         *)this->value_)->value_ : (*this->value_)) : zeroise<std::string>();          } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == MT_vector2    ) ? ((MT_Value<orxonox::Vector2>    *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector2>();     } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == MT_vector3    ) ? ((MT_Value<orxonox::Vector3>    *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector3>();     } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == MT_vector4    ) ? ((MT_Value<orxonox::Vector4>    *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector4>();     } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::ColourValue>(); } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Quaternion>();  } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == MT_radian     ) ? ((MT_Value<orxonox::Radian>     *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Radian>();      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == MT_degree     ) ? ((MT_Value<orxonox::Degree>     *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Degree>();      } /** @brief Returns the current value, converted to the requested type. */
+
+template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, MT_char       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, MT_uchar      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, MT_short      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, MT_ushort     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, MT_int        ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, MT_uint       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, MT_long       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, MT_ulong      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, MT_longlong   ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, MT_ulonglong  ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, MT_float      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, MT_double     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, MT_longdouble ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, MT_bool       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, MT_void       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, MT_string     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, MT_vector2    ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, MT_vector3    ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, MT_vector4    ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, MT_radian     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, MT_degree     ); } /** @brief Creates a new value container for the given type. */
Index: /code/branches/physics/src/util/MultiType.h
===================================================================
--- /code/branches/physics/src/util/MultiType.h	(revision 2122)
+++ /code/branches/physics/src/util/MultiType.h	(revision 2122)
@@ -0,0 +1,525 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MultiType.h
+    @brief Declaration of the MultiType and some helper constructs.
+
+    The MultiType can hold a value of one of the following types:
+     - all primitives
+     - all pointers
+     - string
+     - Vector2, Vector3, Vector4
+     - Quaternion
+     - ColourValue
+     - Radian, Degree
+
+    The MultiType has a "type" determined by the first assigned value, either through
+     - the constructor,
+     - the assignment operator= or
+     - setValue(value).
+    If you assign another value of another type, the MultiType keeps "it's" type and
+    converts the new value to this type.
+
+    If you want to change the type, there are three possibilities:
+     - convert<T>() set's the type to T and converts the currently assigned value
+     - setType<T>() set's the type to T and resets the value
+     - setValue<T>(value) assigns a new value and changes the type to T.
+
+    @example
+    MultiType a = 10;;         // a has now the type int and the value 10
+    a.setValue("3.14");        // a has still the type int and "3.14" gets converted, therefore the value is now 3
+    a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14
+    a.convert<bool>();         // converts 3.14 to bool, which is true
+    a = false;                 // assigns false, this is equivalent to a.setValue(false)
+
+    @note
+    Whenever a value gets converted, there is a boolean return value telling you whether it was
+    successful or not. If it wasn't a zero value is assigned with the help of zeroise<T>().
+*/
+
+#ifndef _MultiType_H__
+#define _MultiType_H__
+
+#include "UtilPrereqs.h"
+
+#include <boost/static_assert.hpp>
+
+#include "Math.h"
+
+/**
+    @brief Enum of all possible types of a MultiType.
+*/
+enum MT_Type
+{
+    MT_null,
+    MT_char,
+    MT_uchar,
+    MT_short,
+    MT_ushort,
+    MT_int,
+    MT_uint,
+    MT_long,
+    MT_ulong,
+    MT_longlong,
+    MT_ulonglong,
+    MT_float,
+    MT_double,
+    MT_longdouble,
+    MT_bool,
+    MT_void,
+    MT_string,
+    MT_vector2,
+    MT_vector3,
+    MT_vector4,
+    MT_colourvalue,
+    MT_quaternion,
+    MT_radian,
+    MT_degree
+};
+
+/**
+    @brief The MultiType can hold a value of many possible types and convert them to other types.
+
+    The following types are supported by the MultiType:
+     - all primitves
+     - all pointers
+     - string
+     - Vector2, Vector3, Vector4
+     - Quaternion
+     - ColourValue
+     - Radian, Degree
+
+    The internal type of a MultiType is determined by the first assigned value, but can be
+    changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned
+    the normal way (operator=, setValue(value)), the value gets converted to the current internal
+    type of the MultiType.
+*/
+class _UtilExport MultiType
+{
+    _UtilExport friend std::ostream& operator<<(std::ostream& outstream, const MultiType& mt);
+    template <typename T> friend struct MT_Value;
+
+    /**
+        @brief MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType.
+        This class is only used within the MultiType.
+    */
+    struct _UtilExport MT_ValueBase
+    {
+        MT_ValueBase(MT_Type type) : type_(type), bHasDefaultValue_(false) {}
+        virtual ~MT_ValueBase() {}
+
+        virtual MT_ValueBase* clone() const = 0;
+
+        virtual void reset() = 0;
+        virtual bool assimilate(const MultiType& other) = 0;
+
+        /** @brief Returns the type of the current value. */
+        const MT_Type& getType() const { return this->type_; }
+
+        /** @brief Checks whether the value is a default one. */
+        bool hasDefaultValue()   const { return this->bHasDefaultValue_; }
+
+        virtual bool setValue(const char& value)                 = 0;
+        virtual bool setValue(const unsigned char& value)        = 0;
+        virtual bool setValue(const short& value)                = 0;
+        virtual bool setValue(const unsigned short& value)       = 0;
+        virtual bool setValue(const int& value)                  = 0;
+        virtual bool setValue(const unsigned int& value)         = 0;
+        virtual bool setValue(const long& value)                 = 0;
+        virtual bool setValue(const unsigned long& value)        = 0;
+        virtual bool setValue(const long long& value)            = 0;
+        virtual bool setValue(const unsigned long long& value)   = 0;
+        virtual bool setValue(const float& value)                = 0;
+        virtual bool setValue(const double& value)               = 0;
+        virtual bool setValue(const long double& value)          = 0;
+        virtual bool setValue(const bool& value)                 = 0;
+        virtual bool setValue(      void* const& value)          = 0;
+        virtual bool setValue(const std::string& value)          = 0;
+        virtual bool setValue(const orxonox::Vector2& value)     = 0;
+        virtual bool setValue(const orxonox::Vector3& value)     = 0;
+        virtual bool setValue(const orxonox::Vector4& value)     = 0;
+        virtual bool setValue(const orxonox::ColourValue& value) = 0;
+        virtual bool setValue(const orxonox::Quaternion& value)  = 0;
+        virtual bool setValue(const orxonox::Radian& value)      = 0;
+        virtual bool setValue(const orxonox::Degree& value)      = 0;
+
+        virtual bool getValue(char*                 value) const = 0;
+        virtual bool getValue(unsigned char*        value) const = 0;
+        virtual bool getValue(short*                value) const = 0;
+        virtual bool getValue(unsigned short*       value) const = 0;
+        virtual bool getValue(int*                  value) const = 0;
+        virtual bool getValue(unsigned int*         value) const = 0;
+        virtual bool getValue(long*                 value) const = 0;
+        virtual bool getValue(unsigned long*        value) const = 0;
+        virtual bool getValue(long long*            value) const = 0;
+        virtual bool getValue(unsigned long long*   value) const = 0;
+        virtual bool getValue(float*                value) const = 0;
+        virtual bool getValue(double*               value) const = 0;
+        virtual bool getValue(long double*          value) const = 0;
+        virtual bool getValue(bool*                 value) const = 0;
+        virtual bool getValue(void**                value) const = 0;
+        virtual bool getValue(std::string*          value) const = 0;
+        virtual bool getValue(orxonox::Vector2*     value) const = 0;
+        virtual bool getValue(orxonox::Vector3*     value) const = 0;
+        virtual bool getValue(orxonox::Vector4*     value) const = 0;
+        virtual bool getValue(orxonox::ColourValue* value) const = 0;
+        virtual bool getValue(orxonox::Quaternion*  value) const = 0;
+        virtual bool getValue(orxonox::Radian*      value) const = 0;
+        virtual bool getValue(orxonox::Degree*      value) const = 0;
+
+        virtual operator char()                 const = 0;
+        virtual operator unsigned char()        const = 0;
+        virtual operator short()                const = 0;
+        virtual operator unsigned short()       const = 0;
+        virtual operator int()                  const = 0;
+        virtual operator unsigned int()         const = 0;
+        virtual operator long()                 const = 0;
+        virtual operator unsigned long()        const = 0;
+        virtual operator long long()            const = 0;
+        virtual operator unsigned long long()   const = 0;
+        virtual operator float()                const = 0;
+        virtual operator double()               const = 0;
+        virtual operator long double()          const = 0;
+        virtual operator bool()                 const = 0;
+        virtual operator void*()                const = 0;
+        virtual operator std::string()          const = 0;
+        virtual operator orxonox::Vector2()     const = 0;
+        virtual operator orxonox::Vector3()     const = 0;
+        virtual operator orxonox::Vector4()     const = 0;
+        virtual operator orxonox::ColourValue() const = 0;
+        virtual operator orxonox::Quaternion()  const = 0;
+        virtual operator orxonox::Radian()      const = 0;
+        virtual operator orxonox::Degree()      const = 0;
+
+        virtual void toString(std::ostream& outstream) const = 0;
+
+        MT_Type type_;          //!< The type of the current value
+        bool bHasDefaultValue_; //!< True if the last conversion wasn't successful
+    };
+
+    public:
+        inline MultiType()                                  : value_(0) {}                                      /** @brief Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. */
+        inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */
+        inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
+        inline MultiType(MT_Type type)                      : value_(0) { this->setType(type); }                /** @brief Constructor: Sets the type, the next assignment will determine the value. */
+
+        /** @brief Destructor: Deletes the MT_Value. */
+        inline ~MultiType() { if (this->value_) { delete this->value_; } }
+
+        template <typename V> inline const MultiType& operator=(const V& value)         { this->setValue(value); return (*this); } /** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */
+        template <typename V> inline const MultiType& operator=(V* value)               { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */
+        inline                       const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } /** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */
+        inline                       const MultiType& operator=(MT_Type type)           { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */
+
+        inline bool                                   setValue(const char& value);
+        inline bool                                   setValue(const unsigned char& value);
+        inline bool                                   setValue(const short& value);
+        inline bool                                   setValue(const unsigned short& value);
+        inline bool                                   setValue(const int& value);
+        inline bool                                   setValue(const unsigned int& value);
+        inline bool                                   setValue(const long& value);
+        inline bool                                   setValue(const unsigned long& value);
+        inline bool                                   setValue(const long long& value);
+        inline bool                                   setValue(const unsigned long long& value);
+        inline bool                                   setValue(const float& value);
+        inline bool                                   setValue(const double& value);
+        inline bool                                   setValue(const long double& value);
+        inline bool                                   setValue(const bool& value);
+        inline bool                                   setValue(      void* const& value);
+        inline bool                                   setValue(const std::string& value);
+        inline bool                                   setValue(const orxonox::Vector2& value);
+        inline bool                                   setValue(const orxonox::Vector3& value);
+        inline bool                                   setValue(const orxonox::Vector4& value);
+        inline bool                                   setValue(const orxonox::ColourValue& value);
+        inline bool                                   setValue(const orxonox::Quaternion& value);
+        inline bool                                   setValue(const orxonox::Radian& value);
+        inline bool                                   setValue(const orxonox::Degree& value);
+        inline bool                                   setValue(const char* value);
+        /** @brief Assigns a pointer. */
+        template <typename V> inline bool             setValue(V* value)               { if (this->value_) { return this->value_->setValue((void*)value); } else { return this->assignValue((void*)value); } }
+        /** @brief Assigns the value of the other MultiType and converts it to the current type. */
+        bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
+        /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */
+        template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
+
+
+        /** @brief Copies the other MultiType by assigning value and type. */
+        inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
+
+        template <typename T> inline bool convert()                       { return this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */
+        inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
+        bool                              convert(MT_Type type);
+
+        /** @brief Current content gets deleted. New type is MT_null */
+        inline void                       reset()                         { if (this->value_) this->value_->reset(); }
+
+        template <typename T> inline void setType()                       { this->assignValue(T());                            } /** @brief Resets the value and changes the internal type to T. */
+        inline void                       setType(const MultiType& other) { this->setType(other.getType());                    } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */
+        inline void                       setType(MT_Type type)           { this->reset(); this->convert(type); this->reset(); } /** @brief Resets the value and changes the internal type to the given type. */
+
+        /** @brief Returns the current type. */
+        inline MT_Type                    getType()                 const { return (this->value_) ? this->value_->type_ : MT_null; }
+        /** @brief Returns true if the current type equals the given type. */
+        inline bool                       isType(MT_Type type)      const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); }
+        /** @brief Returns true if the current type is T. */
+        template <typename T> inline bool isType()                  const { return false; } // Only works for specialized values - see below
+        std::string                       getTypename()             const;
+
+        /** @brief Checks whether the value is a default one. */
+        bool                              hasDefaultValue()         const { return this->value_->hasDefaultValue(); }
+
+        operator char()                  const;
+        operator unsigned char()         const;
+        operator short()                 const;
+        operator unsigned short()        const;
+        operator int()                   const;
+        operator unsigned int()          const;
+        operator long()                  const;
+        operator unsigned long()         const;
+        operator long long()             const;
+        operator unsigned long long()    const;
+        operator float()                 const;
+        operator double()                const;
+        operator long double()           const;
+        operator bool()                  const;
+        operator void*()                 const;
+        operator std::string()           const;
+        operator orxonox::Vector2()      const;
+        operator orxonox::Vector3()      const;
+        operator orxonox::Vector4()      const;
+        operator orxonox::ColourValue()  const;
+        operator orxonox::Quaternion()   const;
+        operator orxonox::Radian()       const;
+        operator orxonox::Degree()       const;
+        /** @brief Returns the current value, converted to a T* pointer. */
+        template <class T> operator T*() const { return ((T*)this->operator void*()); }
+
+        inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(unsigned char*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(short*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(unsigned short*       value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(int*                  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(unsigned int*         value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(long*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(unsigned long*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(long long*            value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(unsigned long long*   value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(float*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(double*               value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(long double*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(bool*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(void**                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(std::string*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(orxonox::Vector2*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(orxonox::Vector3*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(orxonox::Vector4*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(orxonox::Quaternion*  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(orxonox::Radian*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline bool getValue(orxonox::Degree*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+
+        inline char                     getChar()             const { return this->operator char();                 } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } /** @brief Returns the current value, converted to the requested type. */
+        inline short                    getShort()            const { return this->operator short();                } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } /** @brief Returns the current value, converted to the requested type. */
+        inline int                      getInt()              const { return this->operator int();                  } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } /** @brief Returns the current value, converted to the requested type. */
+        inline long                     getLong()             const { return this->operator long();                 } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } /** @brief Returns the current value, converted to the requested type. */
+        inline long long                getLongLong()         const { return this->operator long long();            } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } /** @brief Returns the current value, converted to the requested type. */
+        inline float                    getFloat()            const { return this->operator float();                } /** @brief Returns the current value, converted to the requested type. */
+        inline double                   getDouble()           const { return this->operator double();               } /** @brief Returns the current value, converted to the requested type. */
+        inline long double              getLongDouble()       const { return this->operator long double();          } /** @brief Returns the current value, converted to the requested type. */
+        inline bool                     getBool()             const { return this->operator bool();                 } /** @brief Returns the current value, converted to the requested type. */
+        inline void*                    getVoid()             const { return this->operator void*();                } /** @brief Returns the current value, converted to the requested type. */
+        inline std::string              getString()           const { return this->operator std::string();          } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
+        template <typename T> inline T* getPointer()          const { return ((T*)this->getVoid());                 } /** @brief Returns the current value, converted to a T* pointer. */
+
+    private:
+        inline bool assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_char)        { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_uchar)       { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_short)       { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_ushort)      { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_int)         { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_uint)        { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_long)        { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_ulong)       { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_longlong)    { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_ulonglong)   { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_float)       { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_double)      { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_longdouble)  { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_bool)        { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_void)        { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_string)      { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_vector2)     { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_vector3)     { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_vector4)     { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_quaternion)  { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_radian)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline bool assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_degree)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+
+        /** @brief Changes the value container. */
+        template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
+        /** @brief Creates a new value container (works only with specialized types). */
+        template <typename T>        void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); return false; }
+
+        MT_ValueBase* value_; //!< A pointer to the value container
+};
+
+/** @brief Puts the MultiType on a stream by using the native << operator of the current type. */
+_UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
+
+template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_char);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_uchar);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_short);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_ushort);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_int);         } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_uint);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_long);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_ulong);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_longlong);    } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_ulonglong);   } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_float);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_double);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_longdouble);  } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_bool);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_void);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_string);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_vector2);     } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_vector3);     } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_vector4);     } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_quaternion);  } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_radian);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_degree);      } /** @brief Returns true if the current type equals the given type. */
+
+// Specialization to avoid ambiguities with the conversion operator
+template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } /** @brief Converts the current value to the given type. */
+
+// Specialization to avoid ambiguities with the conversion operator
+template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } /** @brief Converts the current value to the given type. */
+template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } /** @brief Converts the current value to the given type. */
+
+template <> void MultiType::createNewValueContainer(const char& value);
+template <> void MultiType::createNewValueContainer(const unsigned char& value);
+template <> void MultiType::createNewValueContainer(const short& value);
+template <> void MultiType::createNewValueContainer(const unsigned short& value);
+template <> void MultiType::createNewValueContainer(const int& value);
+template <> void MultiType::createNewValueContainer(const unsigned int& value);
+template <> void MultiType::createNewValueContainer(const long& value);
+template <> void MultiType::createNewValueContainer(const unsigned long& value);
+template <> void MultiType::createNewValueContainer(const long long& value);
+template <> void MultiType::createNewValueContainer(const unsigned long long& value);
+template <> void MultiType::createNewValueContainer(const float& value);
+template <> void MultiType::createNewValueContainer(const double& value);
+template <> void MultiType::createNewValueContainer(const bool& value);
+template <> void MultiType::createNewValueContainer(const long double& value);
+template <> void MultiType::createNewValueContainer(      void* const& value);
+template <> void MultiType::createNewValueContainer(const std::string& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value);
+template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Radian& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Degree& value);
+
+inline bool MultiType::setValue(const char& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const unsigned char& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const short& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const unsigned short& value)        { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const int& value)                   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const unsigned int& value)          { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const long& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const unsigned long& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const long long& value)             { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const unsigned long long& value)    { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const float& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const double& value)                { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const long double& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const bool& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(      void* const& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const std::string& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline bool MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+
+inline bool MultiType::setValue(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }  /** @brief Assigns the given value and converts it to the current type. */
+
+#endif /* _MultiType_H__ */
Index: /code/branches/physics/src/util/MultiTypeValue.h
===================================================================
--- /code/branches/physics/src/util/MultiTypeValue.h	(revision 2122)
+++ /code/branches/physics/src/util/MultiTypeValue.h	(revision 2122)
@@ -0,0 +1,150 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MultiTypeValue.h
+    @brief Declaration and Implementation of the MT_Value<T> class.
+
+    The MT_Value<T> class is used to hold a value of type T within a MultiType.
+*/
+
+#ifndef _MultiTypeValue_H__
+#define _MultiTypeValue_H__
+
+#include "UtilPrereqs.h"
+#include "MathConvert.h"
+#include "MultiType.h"
+
+/**
+    @brief The MT_Value<T> class is used to hold a value of type T within a MultiType.
+*/
+template <typename T>
+struct MT_Value : public MultiType::MT_ValueBase
+{
+    /** @brief Constructor: Assigns the value and the type identifier. */
+    MT_Value(const T& value, MT_Type type) : MT_ValueBase(type), value_(value) {}
+
+    /** @brief Creates a copy of itself. */
+    inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
+
+    /** @brief Resets the current value to the default. */
+    inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
+
+    /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */
+    inline bool assimilate(const MultiType& other)
+    {
+        if (other.value_)
+        {
+            return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
+        }
+        else
+        {
+            this->value_ = zeroise<T>();
+            return !(bHasDefaultValue_ = true);
+        }
+    }
+
+    inline bool getValue(char*                 value) const { return ConvertValue<T, char                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(unsigned char*        value) const { return ConvertValue<T, unsigned char       >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(short*                value) const { return ConvertValue<T, short               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(unsigned short*       value) const { return ConvertValue<T, unsigned short      >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(int*                  value) const { return ConvertValue<T, int                 >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(unsigned int*         value) const { return ConvertValue<T, unsigned int        >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(long*                 value) const { return ConvertValue<T, long                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(unsigned long*        value) const { return ConvertValue<T, unsigned long       >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(long long*            value) const { return ConvertValue<T, long long           >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(unsigned long long*   value) const { return ConvertValue<T, unsigned long long  >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(float*                value) const { return ConvertValue<T, float               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(double*               value) const { return ConvertValue<T, double              >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(long double*          value) const { return ConvertValue<T, long double         >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(bool*                 value) const { return ConvertValue<T, bool                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(void**                value) const { return ConvertValue<T, void*               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(std::string*          value) const { return ConvertValue<T, std::string         >(value, value_, zeroise<std::string>         ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(orxonox::Vector2*     value) const { return ConvertValue<T, orxonox::Vector2    >(value, value_, zeroise<orxonox::Vector2>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(orxonox::Vector3*     value) const { return ConvertValue<T, orxonox::Vector3    >(value, value_, zeroise<orxonox::Vector3>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(orxonox::Vector4*     value) const { return ConvertValue<T, orxonox::Vector4    >(value, value_, zeroise<orxonox::Vector4>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(orxonox::ColourValue* value) const { return ConvertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(orxonox::Quaternion*  value) const { return ConvertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(orxonox::Radian*      value) const { return ConvertValue<T, orxonox::Radian     >(value, value_, zeroise<orxonox::Radian>     ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+    inline bool getValue(orxonox::Degree*      value) const { return ConvertValue<T, orxonox::Degree     >(value, value_, zeroise<orxonox::Degree>     ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+
+    inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !ConvertValue<char                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const unsigned char& value)        { return !(bHasDefaultValue_ = !ConvertValue<unsigned char       , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !ConvertValue<short               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const unsigned short& value)       { return !(bHasDefaultValue_ = !ConvertValue<unsigned short      , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !ConvertValue<int                 , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const unsigned int& value)         { return !(bHasDefaultValue_ = !ConvertValue<unsigned int        , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !ConvertValue<long                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const unsigned long& value)        { return !(bHasDefaultValue_ = !ConvertValue<unsigned long       , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const long long& value)            { return !(bHasDefaultValue_ = !ConvertValue<long long           , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const unsigned long long& value)   { return !(bHasDefaultValue_ = !ConvertValue<unsigned long long  , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !ConvertValue<float               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !ConvertValue<double              , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const long double& value)          { return !(bHasDefaultValue_ = !ConvertValue<long double         , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !ConvertValue<bool                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !ConvertValue<void*               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const std::string& value)          { return !(bHasDefaultValue_ = !ConvertValue<std::string         , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const orxonox::Vector2& value)     { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Vector2    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const orxonox::Vector3& value)     { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Vector3    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const orxonox::Vector4& value)     { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Vector4    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !ConvertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const orxonox::Quaternion& value)  { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const orxonox::Radian& value)      { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Radian     , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+    inline bool setValue(const orxonox::Degree& value)      { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Degree     , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
+
+    inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, zeroise<std::string         >()); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, zeroise<orxonox::Vector2    >()); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, zeroise<orxonox::Vector3    >()); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, zeroise<orxonox::Vector4    >()); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, zeroise<orxonox::ColourValue>()); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, zeroise<orxonox::Quaternion >()); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, zeroise<orxonox::Radian     >()); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, zeroise<orxonox::Degree     >()); } /** @brief Returns the current value, converted to the requested type. */
+
+    /** @brief Puts the current value on the stream */
+    inline void toString(std::ostream& outstream) const { outstream << this->value_; }
+
+    T value_; //!< The stored value
+};
+
+#endif /* _MultiTypeValue_H__ */
Index: /code/branches/physics/src/util/OrxonoxPlatform.h
===================================================================
--- /code/branches/physics/src/util/OrxonoxPlatform.h	(revision 2122)
+++ /code/branches/physics/src/util/OrxonoxPlatform.h	(revision 2122)
@@ -0,0 +1,274 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ *   Original code: OgrePlatform.h, licensed under the LGPL. The code
+ *   has changed quite a bit however.
+ *
+ */
+
+/**
+ @file
+ @brief
+    Various constants for compiler, architecture and platform.
+ */
+
+#ifndef _OrxonoxPlatform_H__
+#define _OrxonoxPlatform_H__
+
+/* Initial platform/compiler-related stuff to set. */
+
+#define ORXONOX_PLATFORM_WIN32 1
+#define ORXONOX_PLATFORM_LINUX 2
+#define ORXONOX_PLATFORM_APPLE 3
+
+#define ORXONOX_COMPILER_MSVC 1
+#define ORXONOX_COMPILER_GNUC 2
+#define ORXONOX_COMPILER_BORL 3
+
+#define ORXONOX_ENDIAN_LITTLE 1
+#define ORXONOX_ENDIAN_BIG 2
+
+#define ORXONOX_ARCHITECTURE_32 1
+#define ORXONOX_ARCHITECTURE_64 2
+
+
+/* Finds the compiler type and version. */
+
+#if defined( _MSC_VER )
+#  define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC
+#  define ORXONOX_COMP_VER _MSC_VER
+
+#elif defined( __GNUC__ )
+#  define ORXONOX_COMPILER ORXONOX_COMPILER_GNUC
+#  define ORXONOX_COMP_VER (((__GNUC__)*100) + \
+        (__GNUC_MINOR__*10) + \
+        __GNUC_PATCHLEVEL__)
+
+#elif defined( __BORLANDC__ )
+#  define ORXONOX_COMPILER ORXONOX_COMPILER_BORL
+#  define ORXONOX_COMP_VER __BCPLUSPLUS__
+
+#else
+#  pragma error "No known compiler. Abort! Abort!"
+
+#endif
+
+
+/* See if we can use __forceinline or if we need to use __inline instead */
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#  if ORXONOX_COMP_VER >= 1200
+#    define FORCEINLINE __forceinline
+#  endif
+#elif defined(__MINGW32__)
+#  if !defined(FORCEINLINE)
+#    define FORCEINLINE __inline
+#  endif
+#else
+#  define FORCEINLINE __inline
+#endif
+
+/* Finds the current platform */
+#if defined( __WIN32__ ) || defined( _WIN32 )
+#  define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32
+#elif defined( __APPLE_CC__)
+#  define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE
+#else
+#  define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX
+#endif
+
+/* Find the arch type */
+#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
+#  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64
+#else
+#  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_32
+#endif
+
+/* Try to define function information */
+#ifndef __FUNCTIONNAME__
+#  if ORXONOX_COMPILER == ORXONOX_COMPILER_BORL
+#    define __FUNCTIONNAME__ __FUNC__
+#  elif ORXONOX_COMPILER == ORXONOX_COMPILER_GNUC
+#    define __FUNCTIONNAME__ __PRETTY_FUNCTION__
+#  elif ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#    define __FUNCTIONNAME__ __FUNCTION__
+#  else
+#    define __FUNCTIONNAME__
+#  endif
+#endif
+
+/* Determine whether we're building in debug mode */
+#if defined(_DEBUG) || defined(DEBUG)
+#  define ORXONOX_DEBUG_MODE 1
+#else
+#  define ORXONOX_DEBUG_MODE 0
+#endif
+
+/* Define configurable floating point type */
+namespace orxonox
+{
+#ifdef ORXONOX_DOUBLE_PRECISION
+    typedef double Real;
+#else
+    typedef float  Real;
+#endif
+}
+
+//-----------------------------------------------------------------------
+// Version Information
+//-----------------------------------------------------------------------
+
+#define ORXONOX_VERSION_MAJOR 0
+#define ORXONOX_VERSION_MINOR 1
+#define ORXONOX_VERSION_PATCH 2
+#define ORXONOX_VERSION_SUFFIX ""
+#define ORXONOX_VERSION_NAME "Bellatrix"
+
+#define ORXONOX_VERSION ((ORXONOX_VERSION_MAJOR << 16) | (ORXONOX_VERSION_MINOR << 8) | ORXONOX_VERSION_PATCH)
+
+
+/*---------------------------------
+ * Windows Settings
+ *-------------------------------*/
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+/* Disable unicode support on MingW at the moment, poorly supported in stdlibc++
+ * STLPORT fixes this though so allow if found
+ * MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h */
+#  if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION)
+#    include<_mingw.h>
+#    if defined(__MINGW32_TOOLBOX_UNICODE__)
+#      define ORXONOX_UNICODE_SUPPORT 1
+#    else
+#      define ORXONOX_UNICODE_SUPPORT 0
+#    endif
+#  else
+#    define ORXONOX_UNICODE_SUPPORT 1
+#  endif
+#endif /* Platform Win32 */
+
+
+/*---------------------------------
+ * Linux/Apple Settings
+ *-------------------------------*/
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+
+/* A quick define to overcome different names for the same function */
+#  define stricmp strcasecmp
+
+/* TODO: Check what this actually is and whether we need it or not */
+#if 0
+#  if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+#    define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle"
+#  else
+/* ORXONOX_PLATFORM_LINUX */
+#    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"
+#  endif
+#endif
+
+/* Always enable unicode support for the moment
+ * Perhaps disable in old versions of gcc if necessary */
+#  define ORXONOX_UNICODE_SUPPORT 1
+
+#endif /* Patform Linux/Apple */
+
+
+/*---------------------------------
+ * Apple Settings
+ *-------------------------------*/
+/* For apple, we always have a custom config.h file */
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+#  include "config.h"
+#endif
+
+
+/*---------------------------------
+ * Visual Studio Settings
+ *-------------------------------*/
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+/* Turn off warnings generated by long std templates
+ * This warns about truncation to 255 characters in debug/browse info */
+/*#   pragma warning (disable : 4786)*/
+
+/* Turn off warnings generated by long std templates
+ * This warns about truncation to 255 characters in debug/browse info */
+/*#   pragma warning (disable : 4503)*/
+
+/* disable: conversion from 'double' to 'float', possible loss of data
+ * disable: conversion from 'ogg_int64_t' to 'long', possible loss of data
+ * This has been dealt with in base_properties of the solution since the
+ * warning primarily occurs in library header files (which are mostly
+ * included before OrxonoxPlatform.h is) */
+/*#   pragma warning (disable : 4244)*/
+
+/* disable: "conversion from 'size_t' to 'unsigned int', possible loss of data */
+/*#   pragma warning (disable : 4267)*/
+
+/* disable: "truncation from 'double' to 'float' */
+/*#   pragma warning (disable : 4305)*/
+
+/* set to level 4: "<type> needs to have dll-interface to be used by clients'
+ * Happens on STL member variables which are not public therefore is ok */
+#   pragma warning (disable : 4251)
+
+/* disable: 'MultiTypeString' : multiple assignment operators specified
+ * Used in MultiType and works fine so far */
+/*#   pragma warning (disable : 4522)*/
+
+/* disable: "non dll-interface class used as base for dll-interface class"
+ * Happens when deriving from Singleton because bug in compiler ignores
+ * template export */
+/*#   pragma warning (disable : 4275)*/
+
+/* disable: "C++ Exception Specification ignored"
+ * This is because MSVC 6 did not implement all the C++ exception
+ * specifications in the ANSI C++ draft. */
+/*#   pragma warning( disable : 4290 )*/
+
+/* disable: "no suitable definition provided for explicit template
+ * instantiation request" Occurs in VC7 for no justifiable reason on all
+ * #includes of Singleton */
+/*#   pragma warning( disable: 4661)*/
+
+/* disable: deprecation warnings when using CRT calls in VC8
+ * These show up on all C runtime lib code in VC8, disable since they clutter
+ * the warnings with things we may not be able to do anything about (e.g.
+ * generated code from nvparse etc). I doubt very much that these calls
+ * will ever be actually removed from VC anyway, it would break too much code. */
+/*# pragma warning( disable: 4996)*/
+
+/* disable: "conditional expression constant", always occurs on
+ * ORXONOX_MUTEX_CONDITIONAL when no threading enabled */
+/*#   pragma warning (disable : 201)*/
+
+
+/* Define the english written operators like and, or, xor */
+#include <iso646.h>
+
+/* include visual leak detector to search for memory leaks */
+/* #include <vld.h> */
+
+#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */
+
+#endif /* _OrxonoxPlatform_H__ */
Index: /code/branches/physics/src/util/OutputBuffer.cc
===================================================================
--- /code/branches/physics/src/util/OutputBuffer.cc	(revision 2122)
+++ /code/branches/physics/src/util/OutputBuffer.cc	(revision 2122)
@@ -0,0 +1,132 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputBuffer.cc
+    @brief Implementation of the OutputBuffer.
+*/
+
+#include "OutputBuffer.h"
+
+namespace orxonox
+{
+    const int OUTPUTBUFFER_MAX_LINE_LENGTH = 16384; //! The maximal number of lines that can be stored within the OutputBuffer.
+
+    /**
+        @brief Adds a new listener to the list.
+        @param listener The new listener
+    */
+    void OutputBuffer::registerListener(OutputBufferListener* listener)
+    {
+        this->listeners_.insert(this->listeners_.end(), listener);
+    }
+
+    /**
+        @brief Removes a listener from the list.
+        @param listener The listener
+    */
+    void OutputBuffer::unregisterListener(OutputBufferListener* listener)
+    {
+        for (std::list<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+        {
+            if ((*it) == listener)
+                this->listeners_.erase(it++);
+            else
+                ++it;
+        }
+    }
+
+    /**
+        @brief Puts a stream manipulator to the stream.
+        @param manipulator The manipulator
+    */
+    OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    /**
+        @brief Puts a stream manipulator to the stream.
+        @param manipulator The manipulator
+    */
+    OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    /**
+        @brief Puts a stream manipulator to the stream.
+        @param manipulator The manipulator
+    */
+    OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    /**
+        @brief Removes the first line from the stream and assigns it to a given string object.
+        @param output The string object to assign the first line
+        @return True if there was at least one line in the stream and this line was successfully assigned
+
+        It's important to know the returned line will be removed from the stream. If there are more than one
+        listener, they have to cooperate to avoid conflicts.
+    */
+    bool OutputBuffer::getLine(std::string* output)
+    {
+        char line[OUTPUTBUFFER_MAX_LINE_LENGTH];
+
+        this->stream_.getline(line, OUTPUTBUFFER_MAX_LINE_LENGTH);
+        (*output) = std::string(line);
+
+        bool eof = this->stream_.eof();
+        bool fail = this->stream_.fail();
+
+        if (eof)
+            this->stream_.flush();
+
+        if (eof || fail)
+            this->stream_.clear();
+
+        return (!eof && !fail);
+    }
+
+    /**
+        @brief Calls the outputChanged() function of all registered listeners.
+    */
+    void OutputBuffer::callListeners()
+    {
+        for (std::list<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+            (*it)->outputChanged();
+    }
+}
Index: /code/branches/physics/src/util/OutputBuffer.h
===================================================================
--- /code/branches/physics/src/util/OutputBuffer.h	(revision 2122)
+++ /code/branches/physics/src/util/OutputBuffer.h	(revision 2122)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputBuffer.h
+    @brief Declaration of the OutputBuffer class.
+
+    The OutputBuffer acts almost like std::ostream. You can put text and other values to the
+    OutputBuffer by using the << operator. The OutputBuffer stores the text and calls registerd
+    listeners if new text gets assigned.
+    The listeners are then able to retrieve the text line by line.
+
+    It's important to know that getLine actually removes the line from the OutputBuffer, so it's
+    better to only have one "active" listener.
+*/
+
+#ifndef _OutputBuffer_H__
+#define _OutputBuffer_H__
+
+#include <list>
+#include <sstream>
+#include <iostream>
+
+#include "UtilPrereqs.h"
+
+namespace orxonox
+{
+    /**
+        @brief A pure virtual baseclass for classes that want to register as listener to an OutputBuffer.
+
+        This class is pure virtual, so an inheriting class has to implement the function on it's own.
+        The function get's called, if an instance of the inheriting class registers as a listener at
+        an OutputBuffer and this buffer changes.
+    */
+    class _UtilExport OutputBufferListener
+    {
+        friend class OutputBuffer;
+
+        public:
+            virtual ~OutputBufferListener() {}
+
+        private:
+            virtual void outputChanged() = 0;
+    };
+
+    /**
+        @brief The OutputBuffer acts almost like std::ostream and stores the assigned text.
+
+        If text gets assigned by using the << operator or another function, the OutputBuffer
+        calls it's listeners, allowing them to retrieve the text line by line.
+
+        It's important to know that getLine actually removes the line from the OutputBuffer, so it's
+        better to only have one "active" listener.
+    */
+    class _UtilExport OutputBuffer
+    {
+        public:
+            OutputBuffer() {}
+            ~OutputBuffer() {}
+
+            /**
+                @brief Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners.
+                @param object The object/value to assign
+            */
+            template <class T>
+            inline OutputBuffer& operator<<(T object)
+            {
+                this->stream_ << object;
+                this->callListeners();
+                return *this;
+            }
+
+            /**
+                @brief Reads the stored text of the other OutputBuffer and calls the listeners.
+                @param object The other OutputBuffer
+            */
+            template <const OutputBuffer&>
+            inline OutputBuffer& operator<<(const OutputBuffer& object)
+            {
+                this->stream_ << object.stream_.rdbuf();
+                this->callListeners();
+                return *this;
+            }
+
+            OutputBuffer& operator<<(std::ostream& (*manipulator)(std::ostream&));
+            OutputBuffer& operator<<(std::ios& (*manipulator)(std::ios&));
+            OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
+
+            /**
+                @brief Does the same like operator<<: Assigns the object to the stream and calls the listeners.
+                @param object The object/value
+            */
+            template <class T>
+            inline void add(T object)
+            {
+                this->stream_ << object;
+                this->callListeners();
+            }
+
+            /**
+                @brief Assigns an object/value and adds std::endl.
+                @param object The object/value
+            */
+            template <class T>
+            inline void addLine(T object)
+            {
+                this->stream_ << object << std::endl;
+                this->callListeners();
+            }
+
+            /**
+                @brief Puts std::endl to the stream and calls the listeners.
+            */
+            inline void newline()
+            {
+                this->stream_ << std::endl;
+                this->callListeners();
+            }
+
+            /**
+                @brief Flushes the stored text (~empties the OutputBuffer).
+            */
+            inline void flush()
+            {
+                this->stream_.flush();
+            }
+
+            bool getLine(std::string* output);
+
+            void registerListener(OutputBufferListener* listener);
+            void unregisterListener(OutputBufferListener* listener);
+
+            /**
+                @brief Returns the internal stringstream object.
+            */
+            inline std::stringstream& getStream()
+            {
+                return this->stream_;
+            }
+
+        private:
+            void callListeners();
+
+            std::stringstream stream_;                   //!< The stringstream that stores the assigned text
+            std::list<OutputBufferListener*> listeners_; //!< A list of all listeners
+    };
+}
+
+#endif /* _OutputBuffer_H__ */
Index: /code/branches/physics/src/util/OutputHandler.cc
===================================================================
--- /code/branches/physics/src/util/OutputHandler.cc	(revision 2122)
+++ /code/branches/physics/src/util/OutputHandler.cc	(revision 2122)
@@ -0,0 +1,195 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputHandler.cc
+    @brief Implementation of the OutputHandler class.
+*/
+
+#include "OutputHandler.h"
+#include <time.h>
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Opens the logfile and writes the first line.
+        @param logfilename The name of the logfile
+    */
+    OutputHandler::OutputHandler(const std::string& logfilename)
+    {
+        this->outputBuffer_ = &this->fallbackBuffer_;
+        this->softDebugLevel_[0] = this->softDebugLevel_[1] = this->softDebugLevel_[2] = this->softDebugLevel_[3] = 2;
+        this->logfilename_ = logfilename;
+        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
+
+        time_t rawtime;
+        struct tm* timeinfo;
+        time(&rawtime);
+        timeinfo = localtime(&rawtime);
+
+        this->logfile_ << "Started log at " << asctime(timeinfo) << std::endl;
+        this->logfile_.flush();
+    }
+
+    /**
+        @brief Destructor: Writes the last line to the logfile and closes it.
+    */
+    OutputHandler::~OutputHandler()
+    {
+        this->logfile_ << "Closed log" << std::endl;
+        this->logfile_.close();
+    }
+
+    /**
+        @brief Returns a reference to the only existing instance of the OutputHandler class.
+        @return The instance
+    */
+    OutputHandler& OutputHandler::getOutStream()
+    {
+        static OutputHandler orxout("orxonox.log");
+        return orxout;
+    }
+
+    /**
+        @brief Sets the soft debug level for a given output device.
+        @param device The output device
+        @param level The debug level
+    */
+    void OutputHandler::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
+    {
+        OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device] = level;
+    }
+
+    /**
+        @brief Returns the soft debug level for a given output device.
+        @param device The output device
+        @return The debug level
+    */
+    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
+    {
+        return OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device];
+    }
+
+    /**
+        @brief Sets the OutputBuffer, representing the third output stream.
+        @param buffer The OutputBuffer
+    */
+    void OutputHandler::setOutputBuffer(OutputBuffer& buffer)
+    {
+        buffer.getStream() >> this->outputBuffer_->getStream().rdbuf();
+        this->outputBuffer_ = &buffer;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console and the logfile.
+        @param sb The streambuffer that should be shown in the console
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::streambuf* sb)
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            std::cout << sb;
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            this->logfile_ << sb;
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << sb;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
+        @param manipulator A function, manipulating the outstream.
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::ostream& (*manipulator)(std::ostream&))
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            manipulator(std::cout);
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            manipulator(this->logfile_);
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << manipulator;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
+        @param manipulator A function, manipulating the outstream.
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::ios& (*manipulator)(std::ios&))
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            manipulator(std::cout);
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            manipulator(this->logfile_);
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << manipulator;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
+        @param manipulator A function, manipulating the outstream.
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            manipulator(std::cout);
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            manipulator(this->logfile_);
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << manipulator;
+
+        return *this;
+    }
+}
Index: /code/branches/physics/src/util/OutputHandler.h
===================================================================
--- /code/branches/physics/src/util/OutputHandler.h	(revision 2122)
+++ /code/branches/physics/src/util/OutputHandler.h	(revision 2122)
@@ -0,0 +1,204 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputHandler.h
+    @brief Definition of the OutputHandler class.
+
+    The OutputHandler acts like std::cout, but output isn't only shown in the console,
+    but also written to the logfile and the ingame shell.
+*/
+
+#ifndef _OutputHandler_H__
+#define _OutputHandler_H__
+
+#include "UtilPrereqs.h"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+#include "OutputBuffer.h"
+
+namespace orxonox
+{
+    //! The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell.
+    class _UtilExport OutputHandler
+    {
+        public:
+            enum OutputDevice
+            {
+                LD_All = 0,
+                LD_Console = 1,
+                LD_Logfile = 2,
+                LD_Shell = 3
+            };
+
+            static OutputHandler& getOutStream();
+
+            /** @brief Puts some text on the outstream. @param text The text */
+            static inline std::string log(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(0); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts an error on the outstream. @param text The text */
+            static inline std::string error(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(1); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts a warning on the outstream. @param text The text */
+            static inline std::string warning(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(2); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts an info on the outstream. @param text The text */
+            static inline std::string info(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(3); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts some debug output on the outstream. @param text The text */
+            static inline std::string debug(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(4); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Returns a reference to the logfile. @return The logfile */
+            inline std::ofstream& getLogfile()
+                { return this->logfile_; }
+
+            /** @brief Returns a pointer to the OutputBuffer. @return The OutputBuffer */
+            inline OutputBuffer* getOutputBuffer()
+                { return this->outputBuffer_; }
+
+            /** @brief Sets the level of the incoming output. @param level The level of the incoming output @return The OutputHandler itself */
+            inline OutputHandler& setOutputLevel(int level)
+                { this->outputLevel_ = level; return *this; }
+
+            /** @brief Returns the level of the incoming output. @return The level */
+            inline int getOutputLevel() const
+                { return this->outputLevel_; }
+
+            static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
+            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
+
+            void setOutputBuffer(OutputBuffer& buffer);
+
+            template <class T>
+            OutputHandler& output(const T& output);
+
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned char val)      { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(short val)              { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned short val)     { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(int val)                { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned int val)       { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(long val)               { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned long val)      { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(long long val)          { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned long long val) { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(float val)              { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(double val)             { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(long double val)        { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(const void* val)        { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(bool val)               { return this->output(val); }
+
+            OutputHandler& operator<<(std::streambuf* sb);
+
+            OutputHandler& operator<<(std::ostream& (*manipulator)(std::ostream&));
+            OutputHandler& operator<<(std::ios& (*manipulator)(std::ios&));
+            OutputHandler& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
+
+        private:
+            explicit OutputHandler(const std::string& logfilename);
+            OutputHandler(const OutputHandler& oh);  // don't copy
+            virtual ~OutputHandler();
+
+            std::ofstream logfile_;              //!< The logfile where the output is logged
+            std::string logfilename_;            //!< The name of the logfile
+            OutputBuffer fallbackBuffer_;        //!< The OutputBuffer that gets used if there is no other OutputBuffer
+            OutputBuffer* outputBuffer_;         //!< The OutputBuffer to put output in (usually used by the Shell)
+            int outputLevel_;                    //!< The level of the incoming output
+            int softDebugLevel_[4];              //!< The soft debug level for each OutputDevice - the configurable maximal output level
+    };
+
+    /**
+        @brief Redirects the output to the console and the logfile.
+        @param output The value that should be shown in the console
+        @return A reference to the OutputHandler itself
+    */
+    template<class T>
+    OutputHandler& OutputHandler::output(const T& output)
+    {
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            std::cout << output;
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            this->logfile_ << output;
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << output;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloading of the non-member << operator to redirect the output of classes with self defined '<< to std::ostream' operators to the console and the logfile.
+        @param out The OutputHandler itself
+        @param output The class that should be shown in the console
+        @return The OutputHandler itself
+    */
+    template<class T>
+    OutputHandler& operator<<(OutputHandler& out, const T& output)
+    {
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= out.getOutputLevel())
+            std::cout << output;
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= out.getOutputLevel())
+        {
+            out.getLogfile() << output;
+            out.getLogfile().flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= out.getOutputLevel())
+            (*out.getOutputBuffer()) << output;
+
+        return out;
+    }
+}
+
+#endif /* _OutputHandler_H__ */
Index: /code/branches/physics/src/util/SignalHandler.cc
===================================================================
--- /code/branches/physics/src/util/SignalHandler.cc	(revision 2122)
+++ /code/branches/physics/src/util/SignalHandler.cc	(revision 2122)
@@ -0,0 +1,354 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Christoph Renner
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the SignalHandler class.
+*/
+
+#include "SignalHandler.h"
+#include "Debug.h"
+
+#include <cassert>
+#include <iostream>
+#include <cstdlib>
+#include <cstring>
+
+SignalHandler * SignalHandler::singletonRef = NULL;
+
+#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
+
+#include <wait.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+
+bool SignalHandler::bXAutoKeyRepeatOn_ = false;
+
+SignalHandler::SignalHandler()
+{
+}
+
+/**
+ * register signal handlers for SIGSEGV and SIGABRT
+ * @param appName path to executable eg argv[0]
+ * @param filename filename to append backtrace to
+ */
+void SignalHandler::doCatch( const std::string & appName, const std::string & filename )
+{
+  this->appName = appName;
+  this->filename = filename;
+
+  // prepare for restoring XAutoKeyRepeat
+  Display* display;
+  if ((display = XOpenDisplay(0)))
+  {
+    XKeyboardState oldState;
+    XGetKeyboardControl(display, &oldState);
+    if (oldState.global_auto_repeat == AutoRepeatModeOn)
+      bXAutoKeyRepeatOn_ = true;
+    else
+      bXAutoKeyRepeatOn_ = false;
+    XCloseDisplay(display);
+  }
+  else
+  {
+    std::cout << "Warning: couldn't open X display to restore XAutoKeyRepeat." << std::endl;
+    bXAutoKeyRepeatOn_ = false;
+  }
+
+
+  // make sure doCatch is only called once without calling dontCatch
+  assert( sigRecList.size() == 0 );
+
+  catchSignal( SIGSEGV );
+  catchSignal( SIGABRT );
+  catchSignal( SIGILL );
+}
+
+/**
+ * restore previous signal handlers
+ */
+void SignalHandler::dontCatch()
+{
+  for ( SignalRecList::iterator it = sigRecList.begin(); it != sigRecList.end(); it++ )
+  {
+    signal( it->signal, it->handler );
+  }
+
+  sigRecList.clear();
+}
+
+/**
+ * catch signal sig
+ * @param sig signal to catch
+ */
+void SignalHandler::catchSignal( int sig )
+{
+  sig_t handler = signal( sig, SignalHandler::sigHandler );
+
+  assert( handler != SIG_ERR );
+
+  SignalRec rec;
+  rec.signal = sig;
+  rec.handler = handler;
+
+  sigRecList.push_front( rec );
+}
+
+/**
+ * sigHandler is called when receiving signals
+ * @param sig
+ */
+void SignalHandler::sigHandler( int sig )
+{
+  for ( SignalCallbackList::iterator it = SignalHandler::getInstance()->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++  )
+  {
+    (*(it->cb))( it->someData );
+  }
+
+  std::string sigName = "UNKNOWN";
+
+  switch ( sig )
+  {
+    case SIGSEGV:
+      sigName = "SIGSEGV";
+      break;
+    case SIGABRT:
+      sigName = "SIGABRT";
+      break;
+    case SIGILL:
+      sigName = "SIGILL";
+      break;
+  }
+
+  if (bXAutoKeyRepeatOn_)
+  {
+    std::cout << "Trying to restore XAutoKeyRepeat" << std::endl;
+    Display* display;
+    if ((display = XOpenDisplay(0)))
+    {
+      XAutoRepeatOn(display);
+      XCloseDisplay(display);
+    }
+  }
+
+  COUT(0) << "recieved signal " << sigName.c_str() << std::endl << "try to write backtrace to file orxonox.log" << std::endl;
+
+  int sigPipe[2];
+  if ( pipe(sigPipe) == -1 )
+  {
+    perror("pipe failed!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  int sigPid = fork();
+
+  if ( sigPid == -1 )
+  {
+    perror("fork failed!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  // gdb will be attached to this process
+  if ( sigPid == 0 )
+  {
+    getInstance()->dontCatch();
+    // wait for message from parent when it has attached gdb
+    int someData;
+
+    read( sigPipe[0], &someData, sizeof(someData) );
+
+    if ( someData != 0x12345678 )
+    {
+      COUT(0) << "something went wrong :(" << std::endl;
+    }
+
+    return;
+  }
+
+  int gdbIn[2];
+  int gdbOut[2];
+  int gdbErr[2];
+
+  if ( pipe(gdbIn) == -1 || pipe(gdbOut) == -1 || pipe(gdbErr) == -1 )
+  {
+    perror("pipe failed!\n");
+    kill( sigPid, SIGTERM );
+    waitpid( sigPid, NULL, 0 );
+    exit(EXIT_FAILURE);
+  }
+
+  int gdbPid = fork();
+  // this process will run gdb
+
+  if ( gdbPid == -1 )
+  {
+    perror("fork failed\n");
+    kill( sigPid, SIGTERM );
+    waitpid( sigPid, NULL, 0 );
+    exit(EXIT_FAILURE);
+  }
+
+  if ( gdbPid == 0 )
+  {
+    // start gdb
+
+    close(gdbIn[1]);
+    close(gdbOut[0]);
+    close(gdbErr[0]);
+
+    dup2( gdbIn[0], STDIN_FILENO );
+    dup2( gdbOut[1], STDOUT_FILENO );
+    dup2( gdbErr[1], STDERR_FILENO );
+
+    execlp( "sh", "sh", "-c", "gdb", (void*)NULL);
+  }
+
+  char cmd[256];
+  snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance()->appName.c_str(), sigPid );
+  write( gdbIn[1], cmd, strlen(cmd) );
+
+  int charsFound = 0;
+  int promptFound = 0;
+  char byte;
+  while ( read( gdbOut[0], &byte, 1 ) == 1 )
+  {
+    if (
+      charsFound == 0 && byte == '(' ||
+      charsFound == 1 && byte == 'g' ||
+      charsFound == 2 && byte == 'd' ||
+      charsFound == 3 && byte == 'b' ||
+      charsFound == 4 && byte == ')' ||
+      charsFound == 5 && byte == ' '
+        )
+          charsFound++;
+    else
+      charsFound = 0;
+
+    if ( charsFound == 6 )
+    {
+      promptFound++;
+      charsFound = 0;
+    }
+
+    if ( promptFound == 3 )
+    {
+      break;
+    }
+  }
+
+  int someData = 0x12345678;
+  write( sigPipe[1], &someData, sizeof(someData) );
+
+  write( gdbIn[1], "bt\nk\nq\n", 7 );
+
+
+  charsFound = 0;
+  promptFound = 0;
+  std::string bt;
+  while ( read( gdbOut[0], &byte, 1 ) == 1 )
+  {
+    bt += std::string( &byte, 1 );
+
+    if (
+      charsFound == 0 && byte == '(' ||
+      charsFound == 1 && byte == 'g' ||
+      charsFound == 2 && byte == 'd' ||
+      charsFound == 3 && byte == 'b' ||
+      charsFound == 4 && byte == ')' ||
+      charsFound == 5 && byte == ' '
+        )
+          charsFound++;
+    else
+      charsFound = 0;
+
+    if ( charsFound == 6 )
+    {
+      promptFound++;
+      charsFound = 0;
+      bt += "\n";
+    }
+
+    if ( promptFound == 3 )
+    {
+      break;
+    }
+  }
+
+
+  waitpid( sigPid, NULL, 0 );
+  waitpid( gdbPid, NULL, 0 );
+
+  int wsRemoved = 0;
+
+  while ( wsRemoved < 2 && bt.length() > 0 )
+  {
+    if ( bt[1] == '\n' )
+      wsRemoved++;
+    bt.erase(0, 1);
+  }
+
+  if ( bt.length() > 0 )
+    bt.erase(0, 1);
+
+  time_t now = time(NULL);
+
+  std::string timeString = "\n\n\n\n"
+                     "=======================================================\n"
+                     "= time: " + std::string(ctime(&now)) +
+         "=======================================================\n";
+  bt.insert(0, timeString);
+
+  FILE * f = fopen( getInstance()->filename.c_str(), "a" );
+
+  if ( !f )
+  {
+    perror( ( std::string( "could not append to " ) + getInstance()->filename ).c_str() );
+    exit(EXIT_FAILURE);
+  }
+
+  if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() )
+  {
+    COUT(0) << "could not write " << bt.length() << " byte to " << getInstance()->filename << std::endl;
+    exit(EXIT_FAILURE);
+  }
+
+  exit(EXIT_FAILURE);
+}
+
+void SignalHandler::registerCallback( SignalCallback cb, void * someData )
+{
+  SignalCallbackRec rec;
+  rec.cb = cb;
+  rec.someData = someData;
+
+  callbackList.push_back(rec);
+}
+
+#endif /* ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 */
Index: /code/branches/physics/src/util/SignalHandler.h
===================================================================
--- /code/branches/physics/src/util/SignalHandler.h	(revision 2122)
+++ /code/branches/physics/src/util/SignalHandler.h	(revision 2122)
@@ -0,0 +1,109 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Christoph Renner
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Declaration of the SignalHandler class.
+*/
+
+#ifndef _SignalHandler_H__
+#define _SignalHandler_H__
+
+#include "UtilPrereqs.h"
+
+#include <list>
+#include <string>
+
+typedef int (*SignalCallback)( void * someData );
+
+#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
+#include <signal.h>
+
+struct SignalRec
+{
+  int signal;
+  sig_t handler;
+};
+
+struct SignalCallbackRec
+{
+  SignalCallback cb;
+  void * someData;
+};
+
+
+typedef std::list<SignalRec> SignalRecList;
+typedef std::list<SignalCallbackRec> SignalCallbackList;
+
+class SignalHandler
+{
+  private:
+    SignalHandler();
+  public:
+    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
+    ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
+
+    void registerCallback( SignalCallback cb, void * someData );
+
+    void doCatch( const std::string & appName, const std::string & filename );
+    void dontCatch();
+
+  private:
+    static void sigHandler( int sig );
+
+    void catchSignal( int sig );
+    SignalRecList sigRecList;
+
+    SignalCallbackList callbackList;
+
+    static SignalHandler * singletonRef;
+
+    std::string appName;
+    std::string filename;
+
+    // used to turn on KeyAutoRepeat if OIS crashes
+    static bool bXAutoKeyRepeatOn_;
+};
+
+#else /* ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 */
+
+class _UtilExport SignalHandler
+{
+  public:
+    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
+    void doCatch( const std::string & appName, const std::string & filename ) {};
+    void dontCatch() {};
+    void registerCallback( SignalCallback cb, void * someData ) {};
+
+  private:
+    static SignalHandler * singletonRef;
+};
+
+#endif /* ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 */
+
+#endif /* _SignalHandler_H__ */
Index: /code/branches/physics/src/util/Sleep.h
===================================================================
--- /code/branches/physics/src/util/Sleep.h	(revision 2122)
+++ /code/branches/physics/src/util/Sleep.h	(revision 2122)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief
+    Functions for using sleep() and usleep() under windows.
+ */
+
+#ifndef _Sleep_H__
+#define _Sleep_H__
+
+#include "OrxonoxPlatform.h"
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+#include <winbase.h>
+
+inline void usleep(DWORD dwMicroseconds)
+{
+  Sleep(dwMicroseconds / 1000);
+}
+
+inline void msleep(DWORD dwMilliseconds)
+{
+  Sleep(dwMilliseconds);
+}
+
+inline void sleep(DWORD dwSeconds)
+{
+  Sleep(dwSeconds * 1000);
+}
+
+#else /* Linux/Apple */
+
+#include <unistd.h>
+
+inline void msleep(unsigned long msec)
+{
+  usleep(msec * 1000);
+}
+
+#endif
+
+#endif /* _Sleep_H__ */
Index: /code/branches/physics/src/util/String.cc
===================================================================
--- /code/branches/physics/src/util/String.cc	(revision 2122)
+++ /code/branches/physics/src/util/String.cc	(revision 2122)
@@ -0,0 +1,491 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Benjamin Grauer
+ *
+ */
+
+/**
+    @file String.cc
+    @brief Implementation of several string manipulation functions.
+*/
+
+#include "String.h"
+
+#include <cctype>
+#include <iostream>
+
+#include "Convert.h"
+#include "Math.h"
+
+std::string BLANKSTRING("");
+
+std::string getUniqueNumberString()
+{
+    return convertToString(getUniqueNumber());
+}
+
+/**
+    @brief Removes all whitespaces from a string.
+    @param str The string to strip
+*/
+void strip(std::string* str)
+{
+    size_t pos;
+    while ((pos = (*str).find(" ")) < (*str).length())
+        (*str).erase(pos, 1);
+    while ((pos = (*str).find("\t")) < (*str).length())
+        (*str).erase(pos, 1);
+    while ((pos = (*str).find("\n")) < (*str).length())
+        (*str).erase(pos, 1);
+}
+
+/**
+    @brief Returns a copy of a string without whitespaces.
+    @param str The string to strip
+    @return The stripped line
+*/
+std::string getStripped(const std::string& str)
+{
+    std::string output = std::string(str);
+    strip(&output);
+    return output;
+}
+
+/**
+    @brief Returns a copy of a string without trailing whitespaces.
+    @param str The string
+    @return The modified copy
+*/
+std::string removeTrailingWhitespaces(const std::string& str)
+{
+    size_t pos1 = 0;
+    int pos2 = str.size() - 1;
+    for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
+    for (; pos2 > 0         && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
+    return str.substr(pos1, pos2 - pos1 + 1);
+}
+
+/**
+    @brief Returns the position of the next quote in the string, starting with start.
+    @param str The string
+    @param start The startposition
+    @return The position of the next quote (std::string::npos if there is no next quote)
+*/
+size_t getNextQuote(const std::string& str, size_t start)
+{
+    size_t quote = start - 1;
+
+    while ((quote = str.find('\"', quote + 1)) != std::string::npos)
+    {
+        size_t backslash = quote;
+        size_t numbackslashes = 0;
+        for (; backslash > 0; backslash--, numbackslashes++)
+            if (str[backslash - 1] != '\\')
+                break;
+
+        if (numbackslashes % 2 == 0)
+            break;
+    }
+
+    return quote;
+}
+
+/**
+    @brief Returns true if pos is between two quotes.
+    @param str The string
+    @param pos The position to check
+    @return True if pos is between two quotes
+*/
+bool isBetweenQuotes(const std::string& str, size_t pos)
+{
+    if (pos == std::string::npos)
+        return false;
+
+    size_t quotecount = 0;
+    size_t quote = (size_t)-1;
+    while ((quote = getNextQuote(str, quote + 1)) < pos)
+    {
+        if (quote == pos)
+            return false;
+        quotecount++;
+    }
+
+    if (quote == std::string::npos)
+        return false;
+
+    return ((quotecount % 2) == 1);
+}
+
+/**
+    @brief Returns true if the string contains something like '..."between quotes"...'.
+    @param The string
+    @return True if there is something between quotes
+*/
+bool hasStringBetweenQuotes(const std::string& str)
+{
+    size_t pos1 = getNextQuote(str, 0);
+    size_t pos2 = getNextQuote(str, pos1 + 1);
+    return (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1);
+}
+
+/**
+    @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes).
+    @param The string
+    @param The string between the quotes
+*/
+std::string getStringBetweenQuotes(const std::string& str)
+{
+    size_t pos1 = getNextQuote(str, 0);
+    size_t pos2 = getNextQuote(str, pos1 + 1);
+    if (pos1 != std::string::npos && pos2 != std::string::npos)
+        return str.substr(pos1, pos2 - pos1 + 1);
+    else
+        return "";
+}
+
+/**
+    @brief Removes enclosing quotes if available (including whitespaces at the outside of the quotes).
+    @brief str The string to strip
+    @return The string with removed quotes
+*/
+std::string stripEnclosingQuotes(const std::string& str)
+{
+    size_t start = std::string::npos;
+    size_t end = 0;
+
+    for (size_t pos = 0; (pos < str.size()) && (pos < std::string::npos); pos++)
+    {
+        if (str[pos] == '"')
+        {
+            start = pos;
+            break;
+        }
+
+        if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+            return str;
+    }
+
+    for (size_t pos = str.size() - 1; pos < std::string::npos; pos--)
+    {
+        if (str[pos] == '"')
+        {
+            end = pos;
+            break;
+        }
+
+        if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+            return str;
+    }
+
+    if ((start != std::string::npos) && (end != 0))
+        return str.substr(start + 1, end - start - 1);
+    else
+        return str;
+}
+
+/**
+    @brief Removes enclosing {braces} (braces must be exactly on the beginning and the end of the string).
+    @param str The string to strip
+    @return The striped string
+*/
+std::string stripEnclosingBraces(const std::string& str)
+{
+    std::string output = str;
+
+    while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}')
+        output = output.substr(1, output.size() - 2);
+
+    return output;
+}
+
+/**
+    @brief Determines if a string is a comment (starts with a comment-symbol).
+    @param str The string to check
+    @return True = it's a comment
+
+    A comment is defined by a leading '#', '%', ';' or '//'.
+*/
+bool isComment(const std::string& str)
+{
+    // Strip the line, whitespaces are disturbing
+    std::string teststring = getStripped(str);
+
+    // There are four possible comment-symbols:
+    //  1) #comment in script-language style
+    //  2) %comment in matlab style
+    //  3) ;comment in unreal tournament config-file style
+    //  4) //comment in code style
+    if (teststring.size() >= 2)
+    {
+        if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';' || (teststring[0] == '/' && teststring[1] == '/'))
+            return true;
+    }
+    else if (teststring.size() == 1)
+    {
+        if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';')
+            return true;
+    }
+
+    return false;
+}
+
+/**
+    @brief Determines if a string is empty (contains only whitespaces).
+    @param str The string to check
+    @return True = it's empty
+*/
+bool isEmpty(const std::string& str)
+{
+    std::string temp = getStripped(str);
+    return ((temp == "") || (temp.size() == 0));
+}
+
+/**
+    @brief Determines if a string contains only numbers and maximal one '.'.
+    @param str The string to check
+    @return True = it's a number
+*/
+bool isNumeric(const std::string& str)
+{
+    bool foundPoint = false;
+
+    for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
+    {
+        if (((*it) < '0' || (*it) > '9'))
+        {
+            if ((*it) != '.' && !foundPoint)
+                foundPoint = true;
+            else
+                return false;
+        }
+    }
+
+    return true;
+}
+
+/**
+    @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
+    @param str The string to manipulate
+    @return The string with added slashes
+*/
+std::string addSlashes(const std::string& str)
+{
+    std::string output = str;
+
+    for (size_t pos = 0; (pos = output.find('\\', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\\"); }
+    for (size_t pos = 0; (pos = output.find('\n', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\n"); }
+    for (size_t pos = 0; (pos = output.find('\t', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\t"); }
+    for (size_t pos = 0; (pos = output.find('\v', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\v"); }
+    for (size_t pos = 0; (pos = output.find('\b', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\b"); }
+    for (size_t pos = 0; (pos = output.find('\r', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\r"); }
+    for (size_t pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); }
+    for (size_t pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); }
+    for (size_t pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
+    for (size_t pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); }
+
+    return output;
+}
+
+/**
+    @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash.
+    @param str The string to manipulate
+    @return The string with removed slashes
+*/
+std::string removeSlashes(const std::string& str)
+{
+    if (str.size() <= 1)
+        return str;
+
+    std::string output = "";
+    for (size_t pos = 0; pos < str.size() - 1; )
+    {
+        if (str[pos] == '\\')
+        {
+            if (str[pos + 1] == '\\') { output += '\\'; pos += 2; continue; }
+            else if (str[pos + 1] == 'n') { output += '\n'; pos += 2; continue; }
+            else if (str[pos + 1] == 't') { output += '\t'; pos += 2; continue; }
+            else if (str[pos + 1] == 'v') { output += '\v'; pos += 2; continue; }
+            else if (str[pos + 1] == 'b') { output += '\b'; pos += 2; continue; }
+            else if (str[pos + 1] == 'r') { output += '\r'; pos += 2; continue; }
+            else if (str[pos + 1] == 'f') { output += '\f'; pos += 2; continue; }
+            else if (str[pos + 1] == 'a') { output += '\a'; pos += 2; continue; }
+            else if (str[pos + 1] == '"') { output += '"'; pos += 2; continue; }
+            else if (str[pos + 1] == '0') { output += '\0'; pos += 2; continue; }
+        }
+        output += str[pos];
+        pos++;
+        if (pos == str.size() - 1)
+            output += str[pos];
+    }
+
+    return output;
+}
+
+/**
+    @brief Replaces each char between A and Z with its lowercase equivalent.
+    @param str The string to convert
+*/
+void lowercase(std::string* str)
+{
+    for (size_t i = 0; i < str->size(); ++i)
+    {
+        (*str)[i] = (char)tolower((*str)[i]);
+    }
+}
+
+/**
+    @brief Returns a copy of the given string without uppercase chars.
+    @param str The string
+    @return The copy
+*/
+std::string getLowercase(const std::string& str)
+{
+    std::string output = std::string(str);
+    lowercase(&output);
+    return output;
+}
+
+/**
+    @brief Replaces each char between a and z with its uppercase equivalent.
+    @param str The string to convert
+*/
+void uppercase(std::string* str)
+{
+    for (size_t i = 0; i < str->size(); ++i)
+    {
+        (*str)[i] = (char)toupper((*str)[i]);
+    }
+}
+
+/**
+    @brief Returns a copy of the given string without lowercase chars.
+    @param str The string
+    @return The copy
+*/
+std::string getUppercase(const std::string& str)
+{
+    std::string output = std::string(str);
+    uppercase(&output);
+    return output;
+}
+
+/**
+    @brief Compares two strings ignoring different casing.
+    @param s1 First string
+    @param s2 Second string
+*/
+int nocaseCmp(const std::string& s1, const std::string& s2)
+{
+    std::string::const_iterator it1=s1.begin();
+    std::string::const_iterator it2=s2.begin();
+
+    //stop when either string's end has been reached
+    while ( (it1!=s1.end()) && (it2!=s2.end()) )
+    {
+        if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
+            // return -1 to indicate smaller than, 1 otherwise
+            return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
+        //proceed to the next character in each string
+        ++it1;
+        ++it2;
+    }
+    size_t size1=s1.size(), size2=s2.size();// cache lengths
+    //return -1,0 or 1 according to strings' lengths
+    if (size1==size2)
+        return 0;
+    return (size1<size2) ? -1 : 1;
+}
+
+
+/**
+    @brief Compares the first 'len' chars of two strings ignoring different casing.
+    @param s1 First string
+    @param s2 Second string
+    @param len Maximal number of chars to compare
+*/
+int nocaseCmp(const std::string& s1, const std::string& s2, size_t len)
+{
+    if (len == 0)
+        return 0;
+    std::string::const_iterator it1=s1.begin();
+    std::string::const_iterator it2=s2.begin();
+
+    //stop when either string's end has been reached
+    while ( (it1!=s1.end()) && (it2!=s2.end()) && len-- > 0)
+    {
+        if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
+            // return -1 to indicate smaller than, 1 otherwise
+            return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
+        //proceed to the next character in each string
+        ++it1;
+        ++it2;
+    }
+    return 0;
+}
+
+/**
+    @brief Returns true if the string contains a comment, introduced by #, %, ; or //.
+    @param str The string
+    @return True if the string contains a comment
+*/
+bool hasComment(const std::string& str)
+{
+    return (getCommentPosition(str) != std::string::npos);
+}
+
+/**
+    @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
+    @param str The string
+    @return The comment
+*/
+std::string getComment(const std::string& str)
+{
+    return str.substr(getCommentPosition(str));
+}
+
+/**
+    @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise.
+    @param str The string
+    @return The position
+*/
+size_t getCommentPosition(const std::string& str)
+{
+    return getNextCommentPosition(str, 0);
+}
+
+/**
+    @brief Returns the position of the next comment-symbol, starting with start.
+    @param str The string
+    @param start The startposition
+    @return The position
+*/
+size_t getNextCommentPosition(const std::string& str, size_t start)
+{
+    for (size_t i = start; i < str.size(); i++)
+        if (isComment(str.substr(i)))
+            return i;
+
+    return std::string::npos;
+}
Index: /code/branches/physics/src/util/String.h
===================================================================
--- /code/branches/physics/src/util/String.h	(revision 2122)
+++ /code/branches/physics/src/util/String.h	(revision 2122)
@@ -0,0 +1,80 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file String.h
+    @brief Declaration of several string manipulation functions, used in many parts of the game.
+*/
+
+#ifndef _Util_String_H__
+#define _Util_String_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <sstream>
+
+extern _UtilExport std::string BLANKSTRING;
+_UtilExport std::string getUniqueNumberString();
+
+_UtilExport void        strip(std::string* str);
+_UtilExport std::string getStripped(const std::string& str);
+
+_UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+
+_UtilExport size_t      getNextQuote(const std::string& str, size_t start);
+_UtilExport bool        isBetweenQuotes(const std::string& str, size_t pos);
+
+_UtilExport bool        hasStringBetweenQuotes(const std::string& str);
+_UtilExport std::string getStringBetweenQuotes(const std::string& str);
+
+_UtilExport std::string stripEnclosingQuotes(const std::string& str);
+_UtilExport std::string stripEnclosingBraces(const std::string& str);
+
+_UtilExport bool        isEmpty(const std::string& str);
+_UtilExport bool        isComment(const std::string& str);
+_UtilExport bool        isNumeric(const std::string& str);
+
+_UtilExport std::string addSlashes(const std::string& str);
+_UtilExport std::string removeSlashes(const std::string& str);
+
+_UtilExport void        lowercase(std::string* str);
+_UtilExport std::string getLowercase(const std::string& str);
+
+_UtilExport void        uppercase(std::string* str);
+_UtilExport std::string getUppercase(const std::string& str);
+
+_UtilExport int         nocaseCmp(const std::string& s1, const std::string& s2);
+_UtilExport int         nocaseCmp(const std::string& s1, const std::string& s2, size_t len);
+
+_UtilExport bool        hasComment(const std::string& str);
+_UtilExport std::string getComment(const std::string& str);
+_UtilExport size_t      getCommentPosition(const std::string& str);
+_UtilExport size_t      getNextCommentPosition(const std::string& str, size_t start = 0);
+
+#endif /* _Util_String_H__ */
Index: /code/branches/physics/src/util/SubString.cc
===================================================================
--- /code/branches/physics/src/util/SubString.cc	(revision 2122)
+++ /code/branches/physics/src/util/SubString.cc	(revision 2122)
@@ -0,0 +1,560 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Christian Meyer
+ *   Co-authors:
+ *      Benjamin Grauer
+ *
+
+//
+//  splitLine
+//  STL string tokenizer
+//
+//  Created by Clemens Wacha.
+//  Version 1.0
+//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
+//
+
+ *   Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode.
+ */
+
+#include "SubString.h"
+
+/**
+ * @brief default constructor
+ */
+SubString::SubString()
+{}
+
+
+/**
+ * @brief create a SubString from
+ * @param string the String to Split
+ * @param delimiter the Character at which to split string (delimiter)
+ */
+SubString::SubString(const std::string& string, char delimiter)
+{
+  this->split(string, delimiter);
+}
+
+
+/**
+ * @brief Splits a String into multiple splitters.
+ * @param string the String to split
+ * @param delimiters multiple set of characters at what to split. (delimiters)
+ * @param delimiterNeighbours neighbours of the delimiters, that will be erased only when near a delimiter.
+ * @param emptyEntries If empty entries should be allewed or removed.
+ * @param escapeChar The Escape Character that overrides splitters commends and so on...
+ * @param safemode_char within these characters splitting won't happen
+ * @param comment_char the Comment character.
+ */
+SubString::SubString(const std::string& string,
+                     const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
+                     char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar,
+                     char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
+{
+  SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeEscapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
+}
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subString the SubString to take a set from.
+ * @param subSetBegin the beginning to the end
+ */
+SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+{
+  for (unsigned int i = subSetBegin; i < subString.size(); i++)
+  {
+    this->strings.push_back(subString[i]);
+    this->bInSafemode.push_back(subString.isInSafemode(i));
+  }
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subString the SubString to take a Set from
+ * @param subSetBegin the beginning to the end
+ * @param subSetEnd the end of the SubSet (max subString.size() will be checked internaly)
+ */
+SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd)
+{
+  for (unsigned int i = subSetBegin; i < subString.size() && i < subSetEnd; i++)
+  {
+    this->strings.push_back(subString[i]);
+    this->bInSafemode.push_back(subString.isInSafemode(i));
+  }
+}
+
+/**
+ * @brief creates a Substring from a count and values set.
+ * @param argc: the Arguments Count.
+ * @param argv: Argument Values.
+ */
+SubString::SubString(unsigned int argc, const char** argv)
+{
+  for(unsigned int i = 0; i < argc; ++i)
+  {
+    this->strings.push_back(std::string(argv[i]));
+    this->bInSafemode.push_back(false);
+  }
+}
+
+/**
+ * @brief removes the object from memory
+ */
+SubString::~SubString()
+{ }
+
+/** @brief An empty String */
+// const std::string SubString::emptyString = "";
+/** @brief Helper that gets you a String consisting of all White Spaces */
+const std::string SubString::WhiteSpaces = " \n\t";
+/** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */
+const std::string SubString::WhiteSpacesWithComma = " \n\t,";
+/** An Empty SubString */
+const SubString SubString::NullSubString = SubString();
+
+/**
+ * @brief stores the Value of subString in this SubString
+ * @param subString will be copied into this String.
+ * @returns this SubString.
+ */
+SubString& SubString::operator=(const SubString& subString)
+{
+  this->strings = subString.strings;
+  this->bInSafemode = subString.bInSafemode;
+  return *this;
+}
+
+
+/**
+ * @brief comparator.
+ * @param subString the SubString to compare against this one.
+ * @returns true if the Stored Strings match
+ */
+bool SubString::operator==(const SubString& subString) const
+{
+  return ((this->strings == subString.strings) && (this->bInSafemode == subString.bInSafemode));
+}
+
+/**
+ * @brief comparator.
+ * @param subString the SubString to compare against this one.
+ * @returns true if the Stored Strings match
+ */
+bool SubString::compare(const SubString& subString) const
+{
+  return (*this == subString);
+}
+
+/**
+ * @brief comparator.
+ * @param subString the SubString to compare against this one.
+ * @param length how many entries to compare. (from 0 to length)
+ * @returns true if the Stored Strings match
+ */
+bool SubString::compare(const SubString& subString, unsigned int length) const
+{
+  if (length > this->size() || length > subString.size())
+    return false;
+
+  for (unsigned int i = 0; i < length; i++)
+    if ((this->strings[i] != subString.strings[i]) || (this->bInSafemode[i] != subString.bInSafemode[i]))
+      return false;
+  return true;
+}
+
+
+/**
+ * @brief append operator
+ * @param subString the String to append.
+ * @returns a SubString where this and subString are appended.
+ */
+SubString SubString::operator+(const SubString& subString) const
+{
+  return SubString(*this) += subString;
+}
+
+
+/**
+ * @brief append operator.
+ * @param subString append subString to this SubString.
+ * @returns this substring appended with subString
+ */
+SubString& SubString::operator+=(const SubString& subString)
+{
+  for (unsigned int i = 0; i < subString.size(); i++)
+  {
+    this->strings.push_back(subString[i]);
+    this->bInSafemode.push_back(subString.isInSafemode(i));
+  }
+  return *this;
+}
+
+
+/**
+ * @brief Split the String at
+ * @param string where to split
+ * @param splitter delimiter.
+ */
+unsigned int SubString::split(const std::string& string, char splitter)
+{
+  this->strings.clear();
+  this->bInSafemode.clear();
+  char split[2];
+  split[0] = splitter;
+  split[1] = '\0';
+  SubString::splitLine(this->strings, this->bInSafemode, string, split);
+  return strings.size();
+}
+
+
+/**
+ * @brief Splits a String into multiple splitters.
+ * @param string the String to split
+ * @param delimiters multiple set of characters at what to split. (delimiters)
+ * @param delimiterNeighbours: Neighbours to the Delimiters that will be erased too.
+ * @param emptyEntries: If empty entries are added to the List of SubStrings
+ * @param escapeChar The Escape Character that overrides splitters commends and so on...
+ * @param safemode_char within these characters splitting won't happen
+ * @param comment_char the Comment character.
+ */
+unsigned int SubString::split(const std::string& string,
+                              const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
+                              char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar,
+                              char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
+{
+  this->strings.clear();
+  this->bInSafemode.clear();
+  SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeExcapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
+  return this->strings.size();
+}
+
+
+/**
+ * @brief joins together all Strings of this Substring.
+ * @param delimiter the String between the subStrings.
+ * @returns the joined String.
+ */
+std::string SubString::join(const std::string& delimiter) const
+{
+  if (!this->strings.empty())
+  {
+    std::string retVal = this->strings[0];
+    for (unsigned int i = 1; i < this->strings.size(); i++)
+      retVal += delimiter + this->strings[i];
+    return retVal;
+  }
+  else
+  {
+    static std::string empty;
+    return empty;
+  }
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subSetBegin the beginning to the end
+ * @returns the SubSet
+ *
+ * This function is added for your convenience, and does the same as
+ * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+ */
+SubString SubString::subSet(unsigned int subSetBegin) const
+{
+  return SubString(*this, subSetBegin);
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subSetBegin the beginning to
+ * @param subSetEnd the end of the SubSet to select (if bigger than subString.size() it will be downset.)
+ * @returns the SubSet
+ *
+ * This function is added for your convenience, and does the same as
+ * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+ */
+SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const
+{
+  return SubString(*this, subSetBegin, subSetEnd);
+}
+
+
+/**
+ * @brief splits line into tokens and stores them in ret.
+ * @param ret the Array, where the Splitted strings will be stored in
+ * to the beginning of the current token is stored
+ * @param line the inputLine to split
+ * @param delimiters a String of Delimiters (here the input will be splitted)
+ * @param delimiterNeighbours Naighbours to the Delimitter, that will be removed if they are to the left or the right of a Delimiter.
+ * @param emptyEntries: if empty Strings are added to the List of Strings.
+ * @param escape_char: Escape carater (escapes splitters)
+ * @param safemode_char: the beginning of the safemode is marked with this
+ * @param removeSafemodeChar removes the safemode_char from the beginning and the ending of a token
+ * @param openparenthesis_char the beginning of a safemode is marked with this
+ * @param closeparenthesis_char the ending of a safemode is marked with this
+ * @param removeParenthesisChars removes the parenthesis from the beginning and the ending of a token
+ * @param comment_char: the beginning of a comment is marked with this: (until the end of a Line)
+ * @param start_state: the Initial state on how to parse the String.
+ * @return SPLIT_LINE_STATE the parser was in when returning
+ *
+ * This is the Actual Splitting Algorithm from Clemens Wacha
+ * Supports delimiters, escape characters,
+ * ignores special  characters between safemode_char and between comment_char and linend '\n'.
+ */
+SubString::SPLIT_LINE_STATE
+SubString::splitLine(std::vector<std::string>& ret,
+                     std::vector<bool>& bInSafemode,
+                     const std::string& line,
+                     const std::string& delimiters,
+                     const std::string& delimiterNeighbours,
+                     bool emptyEntries,
+                     char escape_char,
+                     bool removeExcapeChar,
+                     char safemode_char,
+                     bool removeSafemodeChar,
+                     char openparenthesis_char,
+                     char closeparenthesis_char,
+                     bool removeParenthesisChars,
+                     char comment_char,
+                     SPLIT_LINE_STATE start_state)
+{
+  SPLIT_LINE_STATE state = start_state;
+  unsigned int i = 0;
+  unsigned int fallBackNeighbours = 0;
+
+  std::string token;
+  bool inSafemode = false;
+
+  if(start_state != SL_NORMAL && ret.size() > 0)
+  {
+    token = ret[ret.size()-1];
+    ret.pop_back();
+  }
+  if(start_state != SL_NORMAL && bInSafemode.size() > 0)
+  {
+    inSafemode = bInSafemode[bInSafemode.size()-1];
+    bInSafemode.pop_back();
+  }
+
+  while(i < line.size())
+  {
+    switch(state)
+    {
+      case SL_NORMAL:
+        if(line[i] == escape_char)
+        {
+          state = SL_ESCAPE;
+          if (!removeExcapeChar)
+            token += line[i];
+        }
+        else if(line[i] == safemode_char)
+        {
+          state = SL_SAFEMODE;
+          inSafemode = true;
+          if (!removeSafemodeChar)
+            token += line[i];
+        }
+        else if(line[i] == openparenthesis_char)
+        {
+          state = SL_PARENTHESES;
+          inSafemode = true;
+          if (!removeParenthesisChars)
+            token += line[i];
+        }
+        else if(line[i] == comment_char)
+        {
+          if (fallBackNeighbours > 0)
+            token = token.substr(0, token.size() - fallBackNeighbours);
+          /// FINISH
+          if(emptyEntries || token.size() > 0)
+          {
+            ret.push_back(token);
+            token.clear();
+            bInSafemode.push_back(inSafemode);
+            inSafemode = false;
+          }
+          token += line[i];       // EAT
+          state = SL_COMMENT;
+        }
+        else if(delimiters.find(line[i]) != std::string::npos)
+        {
+          // line[i] is a delimiter
+          if (fallBackNeighbours > 0)
+            token = token.substr(0, token.size() - fallBackNeighbours);
+          /// FINISH
+          if(emptyEntries || token.size() > 0)
+          {
+            ret.push_back(token);
+            token.clear();
+            bInSafemode.push_back(inSafemode);
+            inSafemode = false;
+          }
+          state = SL_NORMAL;
+        }
+        else
+        {
+          if (delimiterNeighbours.find(line[i]) != std::string::npos)
+          {
+            if (token.size() > 0)
+              ++fallBackNeighbours;
+            else
+            {
+              i++;
+              continue;
+            }
+          }
+          else
+            fallBackNeighbours = 0;
+          token += line[i];       // EAT
+        }
+        break;
+      case SL_ESCAPE:
+        if (!removeSafemodeChar)
+          token += line[i];
+        else
+        {
+          if(line[i] == 'n') token += '\n';
+          else if(line[i] == 't') token += '\t';
+          else if(line[i] == 'v') token += '\v';
+          else if(line[i] == 'b') token += '\b';
+          else if(line[i] == 'r') token += '\r';
+          else if(line[i] == 'f') token += '\f';
+          else if(line[i] == 'a') token += '\a';
+          else if(line[i] == '?') token += '\?';
+          else token += line[i];  // EAT
+        }
+        state = SL_NORMAL;
+        break;
+      case SL_SAFEMODE:
+        if(line[i] == safemode_char)
+        {
+          state = SL_NORMAL;
+          if (!removeSafemodeChar)
+            token += line[i];
+        }
+        else if(line[i] == escape_char)
+        {
+          state = SL_SAFEESCAPE;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+
+      case SL_SAFEESCAPE:
+        if(line[i] == 'n') token += '\n';
+        else if(line[i] == 't') token += '\t';
+        else if(line[i] == 'v') token += '\v';
+        else if(line[i] == 'b') token += '\b';
+        else if(line[i] == 'r') token += '\r';
+        else if(line[i] == 'f') token += '\f';
+        else if(line[i] == 'a') token += '\a';
+        else if(line[i] == '?') token += '\?';
+        else token += line[i];  // EAT
+        state = SL_SAFEMODE;
+        break;
+
+      case SL_PARENTHESES:
+        if(line[i] == closeparenthesis_char)
+        {
+          state = SL_NORMAL;
+          if (!removeParenthesisChars)
+            token += line[i];
+        }
+        else if(line[i] == escape_char)
+        {
+          state = SL_PARENTHESESESCAPE;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+
+      case SL_PARENTHESESESCAPE:
+        if(line[i] == 'n') token += '\n';
+        else if(line[i] == 't') token += '\t';
+        else if(line[i] == 'v') token += '\v';
+        else if(line[i] == 'b') token += '\b';
+        else if(line[i] == 'r') token += '\r';
+        else if(line[i] == 'f') token += '\f';
+        else if(line[i] == 'a') token += '\a';
+        else if(line[i] == '?') token += '\?';
+        else token += line[i];  // EAT
+        state = SL_PARENTHESES;
+        break;
+
+      case SL_COMMENT:
+        if(line[i] == '\n')
+        {
+          /// FINISH
+          if(token.size() > 0)
+          {
+            ret.push_back(token);
+            token.clear();
+            bInSafemode.push_back(inSafemode);
+            inSafemode = false;
+          }
+          state = SL_NORMAL;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+
+      default:
+        // nothing
+        break;
+    }
+    i++;
+  }
+
+  /// FINISH
+  if (fallBackNeighbours > 0)
+    token = token.substr(0, token.size() - fallBackNeighbours);
+  if(emptyEntries || token.size() > 0)
+  {
+    ret.push_back(token);
+    token.clear();
+    bInSafemode.push_back(inSafemode);
+    inSafemode = false;
+  }
+  return(state);
+}
+
+
+/**
+ * @brief Some nice debug information about this SubString
+ */
+void SubString::debug() const
+{
+  printf("Substring-information::count=%d ::", this->strings.size());
+  for (unsigned int i = 0; i < this->strings.size(); i++)
+    printf("s%d='%s'::", i, this->strings[i].c_str());
+  printf("\n");
+}
Index: /code/branches/physics/src/util/SubString.h
===================================================================
--- /code/branches/physics/src/util/SubString.h	(revision 2122)
+++ /code/branches/physics/src/util/SubString.h	(revision 2122)
@@ -0,0 +1,173 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Christian Meyer
+ *   Co-authors:
+ *      Benjamin Grauer
+ *      Fabian 'x3n' Landau
+ *
+
+//  splitLine
+//  STL string tokenizer
+//
+//  Created by Clemens Wacha.
+//  Version 1.0
+//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
+
+ *   Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode.
+ */
+
+ /*!
+ * @file substring.h
+ * @brief a small class to get the parts of a string separated by commas
+ *
+ * This class is also identified as a Tokenizer. It splits up one long
+ * String into multiple small ones by a designated Delimiter.
+ *
+ * Substring is Advanced, and it is possible, to split a string by ','
+ * but also removing leading and trailing spaces around the comma.
+ *
+ * @example
+ * Split the String std::string st = "1345, The new empire   , is , orxonox"
+ * is splitted with:
+ * SubString(st, ',', " \n\t")
+ * into
+ * "1345", "The new empire", "is", "orxonox"
+ * As you can see, the useless spaces around ',' were removed.
+ */
+
+#ifndef __SubString_H__
+#define __SubString_H__
+
+#include "UtilPrereqs.h"
+
+#include <vector>
+#include <string>
+
+//! A class that can load one string and split it in multipe ones
+/**
+ * SubString is a very Powerfull way to create a SubSet from a String
+ * It can be used, to Split strings append them and join them again.
+ */
+class _UtilExport SubString
+{
+public:
+  //! An enumerator for the State the Parser is in
+  typedef enum {
+    SL_NORMAL,            //!< Normal state
+    SL_ESCAPE,            //!< After an escape character
+    SL_SAFEMODE,          //!< In safe mode (between "" mostly).
+    SL_SAFEESCAPE,        //!< In safe mode with the internal escape character, that escapes even the savemode character.
+    SL_COMMENT,           //!< In Comment mode.
+    SL_PARENTHESES,       //!< Between parentheses (usually '(' and ')')
+    SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character.
+  } SPLIT_LINE_STATE;
+
+
+public:
+  SubString();
+  SubString(const std::string& string, char delimiter = ',');
+  SubString(const std::string& string,
+            const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false,
+            char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
+            char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
+  SubString(unsigned int argc, const char** argv);
+  /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
+  SubString(const SubString& subString) { *this = subString; };
+  SubString(const SubString& subString, unsigned int subSetBegin);
+  SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd);
+  ~SubString();
+
+  // operate on the SubString
+  SubString& operator=(const SubString& subString);
+  bool operator==(const SubString& subString) const;
+  bool compare(const SubString& subString) const;
+  bool compare(const SubString& subString, unsigned int length) const;
+  SubString operator+(const SubString& subString) const;
+  SubString& operator+=(const SubString& subString);
+  /** @param subString the String to append @returns appended String. @brief added for convenience */
+  SubString& append(const SubString subString) { return (*this += subString); };
+
+  /////////////////////////////////////////
+  // Split and Join the any String. ///////
+  unsigned int split(const std::string& string = "", char delimiter = ',');
+  unsigned int split(const std::string& string,
+                     const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false,
+                     char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
+                     char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
+  std::string join(const std::string& delimiter = " ") const;
+  ////////////////////////////////////////
+
+  // retrieve a SubSet from the String
+  SubString subSet(unsigned int subSetBegin) const;
+  SubString subSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
+
+  // retrieve Information from within
+  /** @brief Returns true if the SubString is empty */
+  inline bool empty() const { return this->strings.empty(); };
+  /** @brief Returns the count of Strings stored in this substring */
+  inline unsigned int size() const { return this->strings.size(); };
+  /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */
+  inline const std::string& operator[](unsigned int i) const { return this->strings[i]; };
+  /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */
+  inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
+  /** @brief Returns all Strings as std::vector */
+  inline const std::vector<std::string>& getAllStrings() const { return this->strings; }
+  /** @brief Returns true if the token is in safemode. @param i the i'th token */
+  inline bool isInSafemode(unsigned int i) const { return this->bInSafemode[i]; }
+  /** @brief Returns the front of the StringList. */
+  inline const std::string& front() const { return this->strings.front(); };
+  /** @brief Returns the back of the StringList. */
+  inline const std::string& back() const { return this->strings.back(); };
+  /** @brief removes the back of the strings list. */
+  inline void pop_back() { this->strings.pop_back(); this->bInSafemode.pop_back(); };
+
+  // the almighty algorithm.
+  static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,
+                                    std::vector<bool>& bInSafemode,
+                                    const std::string& line,
+                                    const std::string& delimiters = SubString::WhiteSpaces,
+                                    const std::string& delimiterNeighbours = "",
+                                    bool emptyEntries = false,
+                                    char escape_char = '\\',
+                                    bool removeExcapeChar = true,
+                                    char safemode_char = '"',
+                                    bool removeSafemodeChar = true,
+                                    char openparenthesis_char = '(',
+                                    char closeparenthesis_char = ')',
+                                    bool removeParenthesisChars = true,
+                                    char comment_char = '\0',
+                                    SPLIT_LINE_STATE start_state = SL_NORMAL);
+  // debugging.
+  void debug() const;
+
+public:
+  static const std::string WhiteSpaces;
+  static const std::string WhiteSpacesWithComma;
+  static const SubString   NullSubString;
+
+private:
+  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
+  std::vector<bool>         bInSafemode;
+};
+
+#endif /* __SubString_H__ */
Index: /code/branches/physics/src/util/UtilPrereqs.h
===================================================================
--- /code/branches/physics/src/util/UtilPrereqs.h	(revision 2122)
+++ /code/branches/physics/src/util/UtilPrereqs.h	(revision 2122)
@@ -0,0 +1,75 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _UtilPrereqs_H__
+#define _UtilPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( UTIL_STATIC_BUILD )
+#  ifdef UTIL_SHARED_BUILD
+#    define _UtilExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _UtilExport
+#    else
+#      define _UtilExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _UtilExport  __attribute__ ((visibility("default")))
+#else
+#  define _UtilExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+class ArgReader;
+class Convert;
+class ExprParser;
+class MultiType;
+class SubString;
+namespace orxonox
+{
+    class OutputBuffer;
+    class OutputBufferListener;
+    class Error;
+    class OutputHandler;
+}
+
+#endif /* _UtilPrereqs_H__ */
Index: /code/branches/physics/src/util/testing/CMakeLists.txt
===================================================================
--- /code/branches/physics/src/util/testing/CMakeLists.txt	(revision 2122)
+++ /code/branches/physics/src/util/testing/CMakeLists.txt	(revision 2122)
@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
+	../
+)
+
+ADD_EXECUTABLE(TestConverter
+ TestConverter.cpp
+)
+
+
+ADD_TEST(TestConverter
+	${EXECUTABLE_OUTPUT_PATH}/TestConverter
+)
Index: /code/branches/physics/src/util/testing/TestConverter.cpp
===================================================================
--- /code/branches/physics/src/util/testing/TestConverter.cpp	(revision 2122)
+++ /code/branches/physics/src/util/testing/TestConverter.cpp	(revision 2122)
@@ -0,0 +1,17 @@
+#include "Convert.h"
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+  int input = rand();
+  std::string sub;
+  int output = 0;
+
+  ConvertValue(&sub, input);
+  ConvertValue(&output, sub);
+
+  if (input == output)
+    return 0;
+  else
+    return -1;
+}
Index: /code/branches/physics/updateMedia.sh
===================================================================
--- /code/branches/physics/updateMedia.sh	(revision 2122)
+++ /code/branches/physics/updateMedia.sh	(revision 2122)
@@ -0,0 +1,5 @@
+#!/bin/bash
+dir=${pwd}
+cd ../media
+svn up
+cd $dir
Index: /code/branches/physics/visual_studio/vc8/audio.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/audio.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/audio.vcproj	(revision 2122)
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="audio"
+	ProjectGUID="{4733BD1A-E04C-458D-8BFB-5010250EA497}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\audio.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\audio.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\audio\AudioBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioSource.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioStream.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\audio\AudioBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioIncludes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioSource.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioStream.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/audio.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/audio.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/audio.vsprops	(revision 2122)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="audio"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="AUDIO_SHARED_BUILD"
+		DisableSpecificWarnings="4244"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="vorbisfile$(CS).lib alut$(CS).lib OpenAL32$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/base.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/base.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/base.vsprops	(revision 2122)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="base"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalIncludeDirectories="&quot;$(RootDir)src&quot;;&quot;$(RootDir)src\ceguilua-0.6.1&quot;;&quot;$(LibDir)ogre-1.4.9\include&quot;;&quot;$(LibDir)boost-1.35.0\include&quot;;&quot;$(LibDir)cegui-0.6.1\include&quot;;&quot;$(LibDir)enet-1.2\include&quot;;&quot;$(LibDir)libogg-1.1.3\include&quot;;&quot;$(LibDir)libvorbis-1.2.0\include&quot;;&quot;$(LibDir)openal-1.1\include&quot;;&quot;$(LibDir)freealut-1.1.0\include&quot;;&quot;$(LibDir)tcl-8.5.2\include&quot;;&quot;$(LibDir)zlib-1.2.3\include&quot;;&quot;$(LibDir)ode-0.10.1\include&quot;"
+		PreprocessorDefinitions="WIN32;__WIN32__;_WIN32;_WINDOWS;BOOST_ALL_DYN_LINK;OIS_DYNAMIC_LIB;ZLIB_WINAPI"
+		WarningLevel="3"
+		DisableSpecificWarnings="4522;4251;4800"
+	/>
+	<Tool
+		Name="VCLibrarianTool"
+		OutputFile="$(IntDir)$(ProjectName)$(CS).lib"
+		AdditionalLibraryDirectories="$(LibDir)"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		OutputFile="$(OutDir)$(ProjectName)$(CS).dll"
+		AdditionalLibraryDirectories="&quot;$(LibDir)boost-1.35.0\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)cegui-0.6.1\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)enet-1.2\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)freealut-1.1.0\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)libogg-1.1.3\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)libvorbis-1.2.0\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)ode-0.10.1\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)ogre-1.4.9\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)openal-1.1\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)tcl-8.5.2\lib\$(ConfigurationName)&quot;;&quot;$(LibDir)zlib-1.2.3\lib\$(ConfigurationName)&quot;"
+		SubSystem="1"
+		ImportLibrary="$(IntDir)\$(TargetName).lib"
+		TargetMachine="1"
+	/>
+	<UserMacro
+		Name="CS"
+		Value=""
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/bullet.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/bullet.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/bullet.vsprops	(revision 2122)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="bullet"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalIncludeDirectories="$(RootDir)src\bullet;$(RootDir)src\bullet\BulletCollision;$(RootDir)src\bullet\BulletDynamics;$(RootDir)src\bullet\BulletSoftBody;$(RootDir)src\bullet\LinearMath"
+		TreatWChar_tAsBuiltInType="false"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/bullet_collision.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/bullet_collision.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/bullet_collision.vcproj	(revision 2122)
@@ -0,0 +1,480 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="bullet_collision"
+	ProjectGUID="{BA753941-F455-43A2-925C-7F3E02F6A995}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PrecompiledHeaderThrough="OgreBulletPrecompiled.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btAxisSweep3.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btBoxBoxCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btBoxBoxDetector.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btBoxShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btBroadphaseProxy.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btBvhTriangleMeshShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btCapsuleShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btCollisionDispatcher.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btCollisionObject.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btCollisionShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btCollisionWorld.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btCompoundCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btCompoundShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btConcaveShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btConeShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\btContactProcessing.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btContinuousConvexCollision.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btConvexCast.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btConvexConcaveCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btConvexConvexAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btConvexHullShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btConvexInternalShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btConvexPlaneCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btConvexPointCloudShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btConvexShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btConvexTriangleMeshShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btCylinderShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btDbvt.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btDbvtBroadphase.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btDefaultCollisionConfiguration.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btDispatcher.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btEmptyCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btEmptyShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\btGenericPoolAllocator.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\btGImpactBvh.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\btGImpactCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\btGImpactQuantizedBvh.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\btGImpactShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btGjkConvexCast.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btGjkEpa.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btGjkEpa2.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btGjkEpaPenetrationDepthSolver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btGjkPairDetector.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btHeightfieldTerrainShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btManifoldResult.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btMinkowskiPenetrationDepthSolver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btMinkowskiSumShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btMultimaterialTriangleMeshShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btMultiSapBroadphase.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btMultiSphereShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btOptimizedBvh.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btOverlappingPairCache.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btPersistentManifold.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btPolyhedralConvexShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btQuantizedBvh.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btRaycastCallback.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btScaledBvhTriangleMeshShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btShapeHull.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\BroadphaseCollision\btSimpleBroadphase.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btSimulationIslandManager.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btSphereBoxCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btSphereShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btSphereSphereCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btSphereTriangleCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btStaticPlaneShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btStridingMeshInterface.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btSubSimplexConvexCast.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btTetrahedronShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btTriangleBuffer.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btTriangleCallback.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btTriangleIndexVertexArray.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btTriangleIndexVertexMaterialArray.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btTriangleMesh.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btTriangleMeshShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\btTriangleShapeEx.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionShapes\btUniformScalingShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\btUnionFind.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\NarrowPhaseCollision\btVoronoiSimplexSolver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\gim_box_set.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\gim_contact.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\gim_memory.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\GIMPACT\gim_tri_collision.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletCollision\CollisionDispatch\SphereTriangleDetector.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/bullet_dynamics.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/bullet_dynamics.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/bullet_dynamics.vcproj	(revision 2122)
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="bullet_dynamics"
+	ProjectGUID="{41481057-47FD-4BEF-853B-7EF5F975F05E}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PrecompiledHeaderThrough="OgreBulletPrecompiled.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btConeTwistConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btContactConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\Dynamics\btContinuousDynamicsWorld.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\Dynamics\btDiscreteDynamicsWorld.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btGeneric6DofConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btHingeConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btPoint2PointConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\Vehicle\btRaycastVehicle.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\Dynamics\btRigidBody.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btSequentialImpulseConstraintSolver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\Dynamics\btSimpleDynamicsWorld.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btSliderConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btSolve2LinearConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\ConstraintSolver\btTypedConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\Vehicle\btWheelInfo.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletDynamics\Dynamics\Bullet-C-API.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/bullet_linearmath.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/bullet_linearmath.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/bullet_linearmath.vcproj	(revision 2122)
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="bullet_linearmath"
+	ProjectGUID="{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PrecompiledHeaderThrough="OgreBulletPrecompiled.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\bullet\LinearMath\btAlignedAllocator.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\LinearMath\btConvexHull.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\LinearMath\btGeometryUtil.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\LinearMath\btQuickprof.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/bullet_softbody.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/bullet_softbody.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/bullet_softbody.vcproj	(revision 2122)
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="bullet_softbody"
+	ProjectGUID="{09E86264-CA02-4A60-98EA-61BB3F460160}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PrecompiledHeaderThrough="OgreBulletPrecompiled.h"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\bullet.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\bullet\BulletSoftBody\btSoftBody.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletSoftBody\btSoftBodyConcaveCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletSoftBody\btSoftBodyHelpers.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletSoftBody\btSoftBodyRigidBodyCollisionConfiguration.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletSoftBody\btSoftRigidCollisionAlgorithm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletSoftBody\btSoftRigidDynamicsWorld.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\bullet\BulletSoftBody\btSoftSoftCollisionAlgorithm.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/ceguilua.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/ceguilua.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ceguilua.vcproj	(revision 2122)
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ceguilua"
+	ProjectGUID="{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\ceguilua.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\ceguilua.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\ceguilua-0.6.1\ceguilua\CEGUILua.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ceguilua-0.6.1\ceguilua\CEGUILuaFunctor.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ceguilua-0.6.1\ceguilua\lua_CEGUI.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ceguilua-0.6.1\ceguilua\required.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\ceguilua-0.6.1\ceguilua\CEGUILua.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ceguilua-0.6.1\ceguilua\CEGUILuaFunctor.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ceguilua-0.6.1\ceguilua\required.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/ceguilua.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/ceguilua.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ceguilua.vsprops	(revision 2122)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ceguilua"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="CEGUILUA_EXPORTS"
+		DisableSpecificWarnings="4996"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="CEGUIBase$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/core.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/core.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/core.vcproj	(revision 2122)
@@ -0,0 +1,658 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="core"
+	ProjectGUID="{271715F3-5B90-4110-A552-70C788084A86}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\core.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\core.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\core\Clock.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigFileManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigValueContainer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Core.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Event.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\GameState.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Language.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\LuaBind.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OrxonoxClass.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\RootGameState.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Template.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\XMLNameListener.cc"
+				>
+			</File>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					RelativePath="..\..\src\core\tolua\tolua.pkg"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="Generating tolua bind files..."
+							CommandLine="&quot;$(RootDir)\build\$(SolutionName)\$(ConfigurationName)\toluagen_orxonox\toluagen_orxonox$(CS).exe&quot; -n Core -o $(RootDir)/src/core/tolua/tolua_bind.cc -H $(RootDir)/src/core/tolua/tolua_bind.h $(RootDir)/src/core/tolua/tolua.pkg&#x0D;&#x0A;"
+							AdditionalDependencies="$(RootDir)\src\core\Script.h;$(RootDir)\src\core\CommandExecutor.h"
+							Outputs="$(RootDir)\src\core\tolua\tolua_bind.cc; $(RootDir)\src\core\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="Generating tolua bind files..."
+							CommandLine="&quot;$(RootDir)\build\$(SolutionName)\$(ConfigurationName)\toluagen_orxonox\toluagen_orxonox$(CS).exe&quot; -n Core -o $(RootDir)/src/core/tolua/tolua_bind.cc -H $(RootDir)/src/core/tolua/tolua_bind.h $(RootDir)/src/core/tolua/tolua.pkg&#x0D;&#x0A;"
+							AdditionalDependencies="$(RootDir)\src\core\Script.h;$(RootDir)\src\core\CommandExecutor.h"
+							Outputs="$(RootDir)\src\core\tolua\tolua_bind.cc; $(RootDir)\src\core\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\core\tolua\tolua_bind.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="command"
+				>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompletionFunctions.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandEvaluation.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandExecutor.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandLine.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommand.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommandCompilation.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Executor.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="hierarchy"
+				>
+				<File
+					RelativePath="..\..\src\core\Factory.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Identifier.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\MetaObjectList.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ObjectListBase.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="level"
+				>
+				<File
+					RelativePath="..\..\src\core\BaseObject.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ClassTreeMask.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Loader.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Namespace.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\NamespaceNode.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\XMLPort.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="input"
+				>
+				<File
+					RelativePath="..\..\src\core\input\Button.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\CalibratorCallback.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\ExtendedInputState.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\HalfAxis.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputBuffer.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputCommands.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputManager.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\JoyStickDeviceNumberListener.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyBinder.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyDetector.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\SimpleInputState.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="shell"
+				>
+				<File
+					RelativePath="..\..\src\core\IRC.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Shell.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclBind.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclThreadManager.cc"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\core\Clock.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigFileManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigValueContainer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigValueIncludes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Core.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\CorePrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Event.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\EventIncludes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\GameState.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Language.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\LuaBind.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OrxonoxClass.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\RootGameState.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Super.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Template.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\XMLIncludes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\XMLNameListener.h"
+				>
+			</File>
+			<Filter
+				Name="input"
+				>
+				<File
+					RelativePath="..\..\src\core\input\Button.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\CalibratorCallback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\ExtendedInputState.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\HalfAxis.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputBuffer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputCommands.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputInterfaces.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputState.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\JoyStickDeviceNumberListener.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyBinder.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyDetector.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\SimpleInputState.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="command"
+				>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompleter.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompletionFunctions.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompletionListElement.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandEvaluation.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandExecutor.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandLine.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommand.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommandCompilation.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Executor.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Functor.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="shell"
+				>
+				<File
+					RelativePath="..\..\src\core\IRC.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Shell.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclBind.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclThreadManager.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="hierarchy"
+				>
+				<File
+					RelativePath="..\..\src\core\ClassFactory.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CoreIncludes.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Factory.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Identifier.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Iterator.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\IteratorBase.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\MetaObjectList.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ObjectList.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ObjectListBase.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="level"
+				>
+				<File
+					RelativePath="..\..\src\core\BaseObject.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ClassTreeMask.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Loader.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Namespace.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\NamespaceNode.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\XMLFile.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\XMLPort.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					RelativePath="..\..\src\core\tolua\tolua_bind.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/core.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/core.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/core.vsprops	(revision 2122)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="core"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		PreprocessorDefinitions="CORE_SHARED_BUILD;LUA_BUILD_AS_DLL"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CS).lib tcl85t.lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/cpptcl.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/cpptcl.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/cpptcl.vcproj	(revision 2122)
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="cpptcl"
+	ProjectGUID="{53C56131-E2AA-4A27-B460-7AC05D61A0E6}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\cpptcl.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\cpptcl.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\cpptcl\CppTcl.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\cpptcl\CppTcl.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/cpptcl.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/cpptcl.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/cpptcl.vsprops	(revision 2122)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="cpptcl"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/debug.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/debug.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/debug.vsprops	(revision 2122)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="debug"
+	InheritedPropertySheets=".\base.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		Optimization="0"
+		PreprocessorDefinitions="_DEBUG"
+		MinimalRebuild="true"
+		BasicRuntimeChecks="3"
+		RuntimeLibrary="3"
+		DebugInformationFormat="3"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		LinkIncremental="2"
+		GenerateDebugInformation="true"
+	/>
+	<UserMacro
+		Name="CS"
+		Value="_d"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/directories.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/directories.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/directories.vsprops	(revision 2122)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="directories"
+	OutputDirectory="$(RootDir)bin\$(SolutionName)\$(ConfigurationName)\"
+	IntermediateDirectory="$(RootDir)build\$(SolutionName)\$(ConfigurationName)\$(ProjectName)\"
+	>
+	<UserMacro
+		Name="RootDir"
+		Value="$(SolutionDir)..\..\"
+	/>
+	<UserMacro
+		Name="LibDir"
+		Value="$(RootDir)\dependencies\$(SolutionName)\"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/lua.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/lua.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/lua.vcproj	(revision 2122)
@@ -0,0 +1,372 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="lua"
+	ProjectGUID="{63B3E57A-4382-42F3-85EC-E869CFCCA88F}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\lua.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\lua.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\lua\lapi.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lauxlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lbaselib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lcode.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldblib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldebug.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldo.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldump.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lfunc.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lgc.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\linit.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\liolib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\llex.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lmathlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lmem.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\loadlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lobject.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lopcodes.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\loslib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lparser.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstate.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstring.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstrlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltable.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltablib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltm.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lundump.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lvm.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lzio.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\lua\lapi.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lauxlib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lcode.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldebug.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldo.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lfunc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lgc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\llex.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\llimits.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lmem.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lobject.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lopcodes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lparser.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstate.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstring.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltable.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltm.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lua.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lua.hpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\luaconf.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lualib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lundump.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lvm.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lzio.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/lua.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/lua.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/lua.vsprops	(revision 2122)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="lua"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="LUA_BUILD_AS_DLL"
+		CompileAs="1"
+		DisableSpecificWarnings="4996"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/lua_static.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/lua_static.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/lua_static.vcproj	(revision 2122)
@@ -0,0 +1,354 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="lua_static"
+	ProjectGUID="{8F5B7ED0-D380-4B4F-A744-3A568718176C}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\lua_static.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\lua_static.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\lua\lapi.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lauxlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lbaselib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lcode.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldblib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldebug.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldo.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldump.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lfunc.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lgc.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\linit.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\liolib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\llex.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lmathlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lmem.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\loadlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lobject.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lopcodes.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\loslib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lparser.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstate.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstring.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstrlib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltable.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltablib.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltm.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lundump.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lvm.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lzio.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\lua\lapi.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lauxlib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lcode.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldebug.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ldo.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lfunc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lgc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\llex.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\llimits.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lmem.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lobject.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lopcodes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lparser.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstate.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lstring.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltable.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\ltm.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lua.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lua.hpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\luaconf.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lualib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lundump.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lvm.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\lua\lzio.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/lua_static.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/lua_static.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/lua_static.vsprops	(revision 2122)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="lua_static"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		CompileAs="1"
+		DisableSpecificWarnings="4996"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/network.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/network.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/network.vcproj	(revision 2122)
@@ -0,0 +1,336 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="network"
+	ProjectGUID="{35575B59-E1AE-40E8-89C4-2862B5B09B68}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\network.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\network.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\network\ChatListener.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Client.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientConnection.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientConnectionListener.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientInformation.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ConnectionManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateClient.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateHandler.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Host.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Server.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Synchronisable.cc"
+				>
+			</File>
+			<Filter
+				Name="packet"
+				>
+				<File
+					RelativePath="..\..\src\network\packet\Acknowledgement.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Chat.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\ClassID.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\DeleteObjects.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Gamestate.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Packet.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Welcome.cc"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\network\ChatListener.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Client.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientConnection.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientConnectionListener.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientInformation.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ConnectionManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateClient.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateHandler.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Host.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\NetworkCallback.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\NetworkPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Server.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Synchronisable.h"
+				>
+			</File>
+			<Filter
+				Name="packet"
+				>
+				<File
+					RelativePath="..\..\src\network\packet\Acknowledgement.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Chat.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\ClassID.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\DeleteObjects.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Gamestate.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Packet.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Welcome.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/network.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/network.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/network.vsprops	(revision 2122)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="network"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		PreprocessorDefinitions="NETWORK_SHARED_BUILD"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="enet$(CS).lib zlib$(CS).lib"
+		IgnoreDefaultLibraryNames="LIBCMT;LIBCMTD"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/ogrebullet_collisions.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/ogrebullet_collisions.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ogrebullet_collisions.vcproj	(revision 2122)
@@ -0,0 +1,387 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ogrebullet_collisions"
+	ProjectGUID="{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\ogrebullet_collisions.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\ogrebullet_collisions.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsObject.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsObjectState.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsPrecompiled.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsRay.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsShape.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsWorld.cpp"
+				>
+			</File>
+			<Filter
+				Name="Utils"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Utils\OgreBulletCollisionsMeshToShapeConverter.cpp"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Shapes"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsBoxShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsCapsuleShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsCompoundShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsConeShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsConvexHullShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsCylinderShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsGImpactShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsMinkowskiSumShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsMultiSphereShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsSphereShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsStaticPlaneShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsTriangleShape.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsTrimeshShape.cpp"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Debug"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugContact.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugDrawer.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugLines.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugShape.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisions.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsObject.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsObjectState.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsPreRequisites.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsRay.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsShape.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Collisions\OgreBulletCollisionsWorld.h"
+				>
+			</File>
+			<Filter
+				Name="Utils"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Utils\OgreBulletCollisionsMeshToShapeConverter.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Utils\OgreBulletConverter.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Debug"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugContact.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugDrawer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugLines.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Debug\OgreBulletCollisionsDebugShape.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Shapes"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsBoxShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsCapsuleShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsCompoundShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsConeShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsConvexHullShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsCylinderShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsGImpactShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsMinkowskiSumShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsMultiSphereShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsSphereShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsStaticPlaneShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsTerrainShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsTriangleShape.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Collisions\Shapes\OgreBulletCollisionsTrimeshShape.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/ogrebullet_collisions.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/ogrebullet_collisions.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ogrebullet_collisions.vsprops	(revision 2122)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ogrebullet_collisions"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/Zm200"
+		AdditionalIncludeDirectories="$(RootDir)src\bullet;$(RootDir)src\ogrebullet\Collisions"
+		PreprocessorDefinitions="_PRECOMP"
+		UsePrecompiledHeader="2"
+		PrecompiledHeaderThrough="OgreBulletCollisions.h"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/ogrebullet_dynamics.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/ogrebullet_dynamics.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ogrebullet_dynamics.vcproj	(revision 2122)
@@ -0,0 +1,267 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ogrebullet_dynamics"
+	ProjectGUID="{40511677-D792-42A1-AD87-DEE31D887F67}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\ogrebullet_dynamics.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\ogrebullet_dynamics.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsConstraint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsObjectState.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsPrecompiled.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsRigidBody.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsWorld.cpp"
+				>
+			</File>
+			<Filter
+				Name="Prefab"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Prefab\OgreBulletDynamicsRagDoll.cpp"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Constraints"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamics6DofConstraint.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsConeTwistConstraint.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsHingeConstraint.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsPoint2pointConstraint.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsRaycastVehicle.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamics.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsConstraint.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsObjectState.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsPreRequisites.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsRigidBody.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogrebullet\Dynamics\OgreBulletDynamicsWorld.h"
+				>
+			</File>
+			<Filter
+				Name="Prefab"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Prefab\OgreBulletDynamicsRagDoll.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Constraints"
+				>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamics6DofConstraint.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsConeTwistConstraint.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsHingeConstraint.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsPoint2pointConstraint.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ogrebullet\Dynamics\Constraints\OgreBulletDynamicsRaycastVehicle.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/ogrebullet_dynamics.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/ogrebullet_dynamics.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ogrebullet_dynamics.vsprops	(revision 2122)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ogrebullet_dynamics"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/Zm200"
+		AdditionalIncludeDirectories="$(RootDir)src\bullet;$(RootDir)src\ogrebullet\Collisions;$(RootDir)src\ogrebullet\Dynamics"
+		PreprocessorDefinitions="_PRECOMP"
+		UsePrecompiledHeader="2"
+		PrecompiledHeaderThrough="OgreBulletDynamics.h"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/ogreode.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/ogreode.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ogreode.vcproj	(revision 2122)
@@ -0,0 +1,322 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ogreode"
+	ProjectGUID="{BBA88DC2-CD78-4C00-814B-183899090F3E}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\ogreode.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\ogreode.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="TOLUA_RELEASE"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeBody.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeCollision.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeDebugContact.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeDebugObject.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeEigenSolver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeEntityInformer.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeGeometry.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeJoint.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeMass.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdePrecompiledHeaders.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+						PrecompiledHeaderThrough="OgreOdePrecompiledHeaders.h"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeSpace.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeStepper.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeTriangleMeshData.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeTriangleMeshDataManager.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeUtility.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeWorld.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOde_Core.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeBody.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeCollision.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeDebugContact.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeDebugObject.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeEigenSolver.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeEntityInformer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeFrameListener.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeGeometry.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeJoint.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeMaintainedList.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeMass.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdePrecompiledHeaders.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdePreReqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeSpace.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeStepper.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeTriangleMeshData.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeTriangleMeshDataManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeUtility.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ogreode\OgreOdeWorld.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/ogreode.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/ogreode.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ogreode.vsprops	(revision 2122)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ogreode"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2 /Zm200"
+		PreprocessorDefinitions="OGREODE_EXPORTS;_PRECOMP"
+		UsePrecompiledHeader="2"
+		PrecompiledHeaderThrough="OgreOdePrecompiledHeaders.h"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CS).lib ode_single$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/ois.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/ois.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ois.vcproj	(revision 2122)
@@ -0,0 +1,456 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ois"
+	ProjectGUID="{EA969DF2-70AF-46E6-BBE2-E03112E04CB8}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\ois.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\ois.vsprops"
+			CharacterSet="2"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\ois\OISEffect.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISException.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISForceFeedback.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISInputManager.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISJoyStick.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISKeyboard.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISObject.cpp"
+				>
+			</File>
+			<Filter
+				Name="linux"
+				>
+				<File
+					RelativePath="..\..\src\ois\linux\EventHelpers.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxForceFeedback.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxInputManager.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxKeyboard.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxMouse.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
+			<Filter
+				Name="Win32"
+				>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32ForceFeedback.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32InputManager.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32JoyStick.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32KeyBoard.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32Mouse.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\ois\OIS.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISConfig.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISEvents.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISException.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISFactoryCreator.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISInputManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISJoyStick.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISKeyboard.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISMouse.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISObject.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISPrereqs.h"
+				>
+			</File>
+			<Filter
+				Name="Interface"
+				>
+				<File
+					RelativePath="..\..\src\ois\OISEffect.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\OISForceFeedback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\OISInterface.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Win32"
+				>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32ForceFeedback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32InputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32JoyStick.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32KeyBoard.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32Mouse.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32Prereqs.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="linux"
+				>
+				<File
+					RelativePath="..\..\src\ois\linux\EventHelpers.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxForceFeedback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxInputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxKeyboard.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxMouse.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxPrereqs.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/ois.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/ois.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/ois.vsprops	(revision 2122)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ois"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		AdditionalIncludeDirectories="$(RootDir)src\ois"
+		PreprocessorDefinitions="OIS_NONCLIENT_BUILD;OIS_DYNAMIC_LIB"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="dxguid.lib dinput8.lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/orxonox.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/orxonox.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/orxonox.vcproj	(revision 2122)
@@ -0,0 +1,1294 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="orxonox"
+	ProjectGUID="{0B6C5CFD-F91B-432A-80A3-2610F61E060B}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets=".\debug.vsprops;.\orxonox.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				EntryPointSymbol=""
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets=".\release.vsprops;.\orxonox.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				EntryPointSymbol=""
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\orxonox\CameraManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\GraphicsEngine.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\LevelManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Main.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\PrecompiledHeaderFiles.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Settings.cc"
+				>
+			</File>
+			<Filter
+				Name="objects"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\objects\EventDispatcher.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\EventListener.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\EventTarget.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Radar.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\RadarListener.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\RadarViewable.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Scene.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Script.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Test.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Tickable.cc"
+					>
+				</File>
+				<Filter
+					Name="worldentities"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Backlight.cc"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Billboard.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\BlinkingBillboard.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Camera.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\CameraPosition.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\ControllableEntity.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Light.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Model.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\MovableEntity.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\ParticleEmitter.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\ParticleSpawner.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\WorldEntity.cc"
+						>
+					</File>
+					<Filter
+						Name="pawns"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Pawn.cc"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\pawns\SpaceShip.cc"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Spectator.cc"
+							>
+						</File>
+					</Filter>
+					<Filter
+						Name="triggers"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\triggers\DistanceTrigger.cc"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\triggers\EventTrigger.cc"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.cc"
+							>
+						</File>
+					</Filter>
+				</Filter>
+				<Filter
+					Name="gametypes"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\gametypes\Gametype.cc"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="infos"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\infos\Info.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\infos\Level.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\infos\PlayerInfo.cc"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="controllers"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\controllers\Controller.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\controllers\HumanController.cc"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="weaponSystem"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\Munition.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\Weapon.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponSet.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponSlot.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponSystem.cc"
+						>
+					</File>
+					<Filter
+						Name="munitions"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\munitions\LaserGunMunition.cc"
+							>
+							<FileConfiguration
+								Name="Debug|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+						</File>
+					</Filter>
+					<Filter
+						Name="weapons"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.cc"
+							>
+							<FileConfiguration
+								Name="Debug|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Missile.cc"
+							>
+							<FileConfiguration
+								Name="Debug|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+						</File>
+					</Filter>
+					<Filter
+						Name="projectiles"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\BillboardProjectile.cc"
+							>
+							<FileConfiguration
+								Name="Debug|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\ParticleProjectile.cc"
+							>
+							<FileConfiguration
+								Name="Debug|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\Projectile.cc"
+							>
+							<FileConfiguration
+								Name="Debug|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+							<FileConfiguration
+								Name="Release|Win32"
+								ExcludedFromBuild="true"
+								>
+								<Tool
+									Name="VCCLCompilerTool"
+								/>
+							</FileConfiguration>
+						</File>
+					</Filter>
+				</Filter>
+				<Filter
+					Name="quest"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\AddQuest.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\AddQuestHint.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\AddReward.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\ChangeQuestStatus.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\CompleteQuest.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\FailQuest.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\GlobalQuest.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\LocalQuest.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\Quest.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestDescription.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestEffect.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestHint.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestItem.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestManager.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\Rewardable.cc"
+						>
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="tools"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tools\BillboardSet.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Mesh.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\ParticleInterface.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\TextureGenerator.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Timer.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\WindowEventListener.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tolua\tolua.pkg"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="Generating tolua bind files..."
+							CommandLine="&quot;$(RootDir)\build\$(SolutionName)\$(ConfigurationName)\toluagen_orxonox\toluagen_orxonox$(CS).exe&quot; -n Orxonox -o $(RootDir)/src/orxonox/tolua/tolua_bind.cc -H $(RootDir)/src/orxonox/tolua/tolua_bind.h $(RootDir)/src/orxonox/tolua/tolua.pkg&#x0D;&#x0A;"
+							AdditionalDependencies="$(RootDir)\src\orxonox\gui\GUIManager.h"
+							Outputs="$(RootDir)\src\orxonox\tolua\tolua_bind.cc; $(RootDir)\src\orxonox\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="Generating tolua bind files..."
+							CommandLine="&quot;$(RootDir)\build\$(SolutionName)\$(ConfigurationName)\toluagen_orxonox\toluagen_orxonox$(CS).exe&quot; -n Orxonox -o $(RootDir)/src/orxonox/tolua/tolua_bind.cc -H $(RootDir)/src/orxonox/tolua/tolua_bind.h $(RootDir)/src/orxonox/tolua/tolua.pkg&#x0D;&#x0A;"
+							AdditionalDependencies="$(RootDir)\src\orxonox\gui\GUIManager.h"
+							Outputs="$(RootDir)\src\orxonox\tolua\tolua_bind.cc; $(RootDir)\src\orxonox\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tolua\tolua_bind.cc"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
+			<Filter
+				Name="overlays"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OrxonoxOverlay.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayGroup.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayText.cc"
+					>
+				</File>
+				<Filter
+					Name="console"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\console\InGameConsole.cc"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="hud"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\ChatOverlay.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDRadar.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDSpeedBar.cc"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="debug"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugFPSText.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.cc"
+						>
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="gui"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gui\GUIManager.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIRenderer.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIResourceProvider.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUITexture.cpp"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="gamestates"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSClient.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSDedicated.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGraphics.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGUI.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSIOConsole.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSLevel.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSRoot.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSServer.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSStandalone.cc"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\orxonox\CameraManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\GraphicsEngine.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\LevelManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\OrxonoxPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\OrxonoxStableHeaders.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Settings.h"
+				>
+			</File>
+			<Filter
+				Name="objects"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\objects\EventDispatcher.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\EventListener.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\EventTarget.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Radar.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\RadarListener.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\RadarViewable.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Scene.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Script.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Test.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Tickable.h"
+					>
+				</File>
+				<Filter
+					Name="worldentities"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Backlight.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Billboard.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\BlinkingBillboard.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Camera.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\CameraPosition.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\ControllableEntity.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Light.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\Model.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\MovableEntity.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\ParticleEmitter.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\ParticleSpawner.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\worldentities\WorldEntity.h"
+						>
+					</File>
+					<Filter
+						Name="pawns"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Pawn.h"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\pawns\SpaceShip.h"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Spectator.h"
+							>
+						</File>
+					</Filter>
+					<Filter
+						Name="triggers"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\triggers\DistanceTrigger.h"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\triggers\EventTrigger.h"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.h"
+							>
+						</File>
+					</Filter>
+				</Filter>
+				<Filter
+					Name="gametypes"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\gametypes\Gametype.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="infos"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\infos\Info.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\infos\Level.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\infos\PlayerInfo.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="controllers"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\controllers\Controller.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\controllers\HumanController.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="quest"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\AddQuest.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\AddQuestHint.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\AddReward.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\ChangeQuestStatus.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\CompleteQuest.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\FailQuest.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\GlobalQuest.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\LocalQuest.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\Quest.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestDescription.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestEffect.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestHint.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestItem.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\QuestManager.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\quest\Rewardable.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="weaponSystem"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\Munition.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\Weapon.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponSet.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponSlot.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponSystem.h"
+						>
+					</File>
+					<Filter
+						Name="weapons"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.h"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Missile.h"
+							>
+						</File>
+					</Filter>
+					<Filter
+						Name="munitions"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\munitions\LaserGunMunition.h"
+							>
+						</File>
+					</Filter>
+					<Filter
+						Name="projectiles"
+						>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\BillboardProjectile.h"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\ParticleProjectile.h"
+							>
+						</File>
+						<File
+							RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\Projectile.h"
+							>
+						</File>
+					</Filter>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="tools"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tools\BillboardSet.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Mesh.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\ParticleInterface.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\TextureGenerator.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Timer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\WindowEventListener.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tolua\tolua_bind.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="overlays"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OrxonoxOverlay.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayGroup.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayText.h"
+					>
+				</File>
+				<Filter
+					Name="hud"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\ChatOverlay.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDRadar.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDSpeedBar.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="console"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\console\InGameConsole.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="debug"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugFPSText.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.h"
+						>
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="gui"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gui\GUIManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIRenderer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIResourceProvider.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUITexture.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="gamestates"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSClient.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSDedicated.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGraphics.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGUI.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSIOConsole.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSLevel.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSRoot.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSServer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSStandalone.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/orxonox.vcproj.user
===================================================================
--- /code/branches/physics/visual_studio/vc8/orxonox.vcproj.user	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/orxonox.vcproj.user	(revision 2122)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="8.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="$(OutDir)"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="$(OutDir)"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>
Index: /code/branches/physics/visual_studio/vc8/orxonox.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/orxonox.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/orxonox.vsprops	(revision 2122)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="orxonox"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2 /Zm200"
+		AdditionalIncludeDirectories="$(RootDir)src\orxonox"
+		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;ORXONOX_ENABLE_PCH;LUA_BUILD_AS_DLL"
+		UsePrecompiledHeader="2"
+		PrecompiledHeaderThrough="OrxonoxStableHeaders.h"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CS).lib tcl85t.lib enet$(CS).lib zlib$(CS).lib CEGUIBase$(CS).lib"
+		OutputFile="$(OutDir)$(ProjectName)$(CS).exe"
+		IgnoreDefaultLibraryNames=""
+	/>
+	<Tool
+		Name="VCPostBuildEventTool"
+		Description="Copying files from init folder..."
+		CommandLine="for %%a in ($(RootDir)\init\$(SolutionName)\$(ConfigurationName)\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;for %%a in ($(RootDir)\init\common\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/orxonox_vc8.sln
===================================================================
--- /code/branches/physics/visual_studio/vc8/orxonox_vc8.sln	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/orxonox_vc8.sln	(revision 2122)
@@ -0,0 +1,310 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "orxonox", "orxonox.vcproj", "{0B6C5CFD-F91B-432A-80A3-2610F61E060B}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{4733BD1A-E04C-458D-8BFB-5010250EA497} = {4733BD1A-E04C-458D-8BFB-5010250EA497}
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68}
+		{40511677-D792-42A1-AD87-DEE31D887F67} = {40511677-D792-42A1-AD87-DEE31D887F67}
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+		{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD} = {77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}
+		{09E86264-CA02-4A60-98EA-61BB3F460160} = {09E86264-CA02-4A60-98EA-61BB3F460160}
+		{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} = {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}
+		{41481057-47FD-4BEF-853B-7EF5F975F05E} = {41481057-47FD-4BEF-853B-7EF5F975F05E}
+		{BA753941-F455-43A2-925C-7F3E02F6A995} = {BA753941-F455-43A2-925C-7F3E02F6A995}
+		{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} = {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}
+		{BBA88DC2-CD78-4C00-814B-183899090F3E} = {BBA88DC2-CD78-4C00-814B-183899090F3E}
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpptcl", "cpptcl.vcproj", "{53C56131-E2AA-4A27-B460-7AC05D61A0E6}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml.vcproj", "{F101C2F0-1CB9-4A57-827B-6C399A99B28F}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen_orxonox", "toluagen_orxonox.vcproj", "{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34} = {A0724246-CB7C-420B-BCF0-68EF205AFE34}
+		{C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402}
+		{8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen", "toluagen.vcproj", "{A0724246-CB7C-420B-BCF0-68EF205AFE34}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402}
+		{8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6}
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
+		{EA969DF2-70AF-46E6-BBE2-E03112E04CB8} = {EA969DF2-70AF-46E6-BBE2-E03112E04CB8}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "audio.vcproj", "{4733BD1A-E04C-458D-8BFB-5010250EA497}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "network.vcproj", "{35575B59-E1AE-40E8-89C4-2862B5B09B68}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "lua.vcproj", "{63B3E57A-4382-42F3-85EC-E869CFCCA88F}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ceguilua", "ceguilua.vcproj", "{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ois", "ois.vcproj", "{EA969DF2-70AF-46E6-BBE2-E03112E04CB8}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "externals", "externals", "{B9D56701-B4DB-43F8-9920-241CA418C1CE}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua_static", "tolua_static.vcproj", "{C6692661-9160-49E6-B109-A155F9485402}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua_static", "lua_static.vcproj", "{8F5B7ED0-D380-4B4F-A744-3A568718176C}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ogreode", "ogreode.vcproj", "{BBA88DC2-CD78-4C00-814B-183899090F3E}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ogrebullet_collisions", "ogrebullet_collisions.vcproj", "{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ogrebullet_dynamics", "ogrebullet_dynamics.vcproj", "{40511677-D792-42A1-AD87-DEE31D887F67}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_collision", "bullet_collision.vcproj", "{BA753941-F455-43A2-925C-7F3E02F6A995}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_dynamics", "bullet_dynamics.vcproj", "{41481057-47FD-4BEF-853B-7EF5F975F05E}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_linearmath", "bullet_linearmath.vcproj", "{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_softbody", "bullet_softbody.vcproj", "{09E86264-CA02-4A60-98EA-61BB3F460160}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.Build.0 = Debug|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.ActiveCfg = Release|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.Build.0 = Release|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.ActiveCfg = Debug|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.Build.0 = Debug|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Release|Win32.ActiveCfg = Release|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Release|Win32.Build.0 = Release|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.ActiveCfg = Debug|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.Build.0 = Debug|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.ActiveCfg = Release|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.Build.0 = Release|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Debug|Win32.ActiveCfg = Debug|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Debug|Win32.Build.0 = Debug|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.ActiveCfg = Release|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.Build.0 = Release|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Debug|Win32.ActiveCfg = Debug|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Debug|Win32.Build.0 = Debug|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Release|Win32.ActiveCfg = Release|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Release|Win32.Build.0 = Release|Win32
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Debug|Win32.ActiveCfg = Debug|Win32
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Debug|Win32.Build.0 = Debug|Win32
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Release|Win32.ActiveCfg = Release|Win32
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Release|Win32.Build.0 = Release|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Debug|Win32.ActiveCfg = Debug|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Debug|Win32.Build.0 = Debug|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Release|Win32.ActiveCfg = Release|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Release|Win32.Build.0 = Release|Win32
+		{271715F3-5B90-4110-A552-70C788084A86}.Debug|Win32.ActiveCfg = Debug|Win32
+		{271715F3-5B90-4110-A552-70C788084A86}.Debug|Win32.Build.0 = Debug|Win32
+		{271715F3-5B90-4110-A552-70C788084A86}.Release|Win32.ActiveCfg = Release|Win32
+		{271715F3-5B90-4110-A552-70C788084A86}.Release|Win32.Build.0 = Release|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.ActiveCfg = Debug|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.Build.0 = Debug|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.ActiveCfg = Release|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.Build.0 = Release|Win32
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.ActiveCfg = Debug|Win32
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.Build.0 = Debug|Win32
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.ActiveCfg = Release|Win32
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.Build.0 = Release|Win32
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Debug|Win32.ActiveCfg = Debug|Win32
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Debug|Win32.Build.0 = Debug|Win32
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Release|Win32.ActiveCfg = Release|Win32
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Release|Win32.Build.0 = Release|Win32
+		{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}.Debug|Win32.ActiveCfg = Debug|Win32
+		{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}.Debug|Win32.Build.0 = Debug|Win32
+		{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}.Release|Win32.ActiveCfg = Release|Win32
+		{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}.Release|Win32.Build.0 = Release|Win32
+		{EA969DF2-70AF-46E6-BBE2-E03112E04CB8}.Debug|Win32.ActiveCfg = Debug|Win32
+		{EA969DF2-70AF-46E6-BBE2-E03112E04CB8}.Debug|Win32.Build.0 = Debug|Win32
+		{EA969DF2-70AF-46E6-BBE2-E03112E04CB8}.Release|Win32.ActiveCfg = Release|Win32
+		{EA969DF2-70AF-46E6-BBE2-E03112E04CB8}.Release|Win32.Build.0 = Release|Win32
+		{C6692661-9160-49E6-B109-A155F9485402}.Debug|Win32.ActiveCfg = Debug|Win32
+		{C6692661-9160-49E6-B109-A155F9485402}.Debug|Win32.Build.0 = Debug|Win32
+		{C6692661-9160-49E6-B109-A155F9485402}.Release|Win32.ActiveCfg = Release|Win32
+		{C6692661-9160-49E6-B109-A155F9485402}.Release|Win32.Build.0 = Release|Win32
+		{8F5B7ED0-D380-4B4F-A744-3A568718176C}.Debug|Win32.ActiveCfg = Debug|Win32
+		{8F5B7ED0-D380-4B4F-A744-3A568718176C}.Debug|Win32.Build.0 = Debug|Win32
+		{8F5B7ED0-D380-4B4F-A744-3A568718176C}.Release|Win32.ActiveCfg = Release|Win32
+		{8F5B7ED0-D380-4B4F-A744-3A568718176C}.Release|Win32.Build.0 = Release|Win32
+		{BBA88DC2-CD78-4C00-814B-183899090F3E}.Debug|Win32.ActiveCfg = Debug|Win32
+		{BBA88DC2-CD78-4C00-814B-183899090F3E}.Debug|Win32.Build.0 = Debug|Win32
+		{BBA88DC2-CD78-4C00-814B-183899090F3E}.Release|Win32.ActiveCfg = Release|Win32
+		{BBA88DC2-CD78-4C00-814B-183899090F3E}.Release|Win32.Build.0 = Release|Win32
+		{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Debug|Win32.ActiveCfg = Debug|Win32
+		{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Debug|Win32.Build.0 = Debug|Win32
+		{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Release|Win32.ActiveCfg = Release|Win32
+		{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Release|Win32.Build.0 = Release|Win32
+		{40511677-D792-42A1-AD87-DEE31D887F67}.Debug|Win32.ActiveCfg = Debug|Win32
+		{40511677-D792-42A1-AD87-DEE31D887F67}.Debug|Win32.Build.0 = Debug|Win32
+		{40511677-D792-42A1-AD87-DEE31D887F67}.Release|Win32.ActiveCfg = Release|Win32
+		{40511677-D792-42A1-AD87-DEE31D887F67}.Release|Win32.Build.0 = Release|Win32
+		{BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.ActiveCfg = Debug|Win32
+		{BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.Build.0 = Debug|Win32
+		{BA753941-F455-43A2-925C-7F3E02F6A995}.Release|Win32.ActiveCfg = Release|Win32
+		{BA753941-F455-43A2-925C-7F3E02F6A995}.Release|Win32.Build.0 = Release|Win32
+		{41481057-47FD-4BEF-853B-7EF5F975F05E}.Debug|Win32.ActiveCfg = Debug|Win32
+		{41481057-47FD-4BEF-853B-7EF5F975F05E}.Debug|Win32.Build.0 = Debug|Win32
+		{41481057-47FD-4BEF-853B-7EF5F975F05E}.Release|Win32.ActiveCfg = Release|Win32
+		{41481057-47FD-4BEF-853B-7EF5F975F05E}.Release|Win32.Build.0 = Release|Win32
+		{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Debug|Win32.ActiveCfg = Debug|Win32
+		{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Debug|Win32.Build.0 = Debug|Win32
+		{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Release|Win32.ActiveCfg = Release|Win32
+		{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Release|Win32.Build.0 = Release|Win32
+		{09E86264-CA02-4A60-98EA-61BB3F460160}.Debug|Win32.ActiveCfg = Debug|Win32
+		{09E86264-CA02-4A60-98EA-61BB3F460160}.Debug|Win32.Build.0 = Debug|Win32
+		{09E86264-CA02-4A60-98EA-61BB3F460160}.Release|Win32.ActiveCfg = Release|Win32
+		{09E86264-CA02-4A60-98EA-61BB3F460160}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{EA969DF2-70AF-46E6-BBE2-E03112E04CB8} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{C6692661-9160-49E6-B109-A155F9485402} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{8F5B7ED0-D380-4B4F-A744-3A568718176C} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{BBA88DC2-CD78-4C00-814B-183899090F3E} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{40511677-D792-42A1-AD87-DEE31D887F67} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{BA753941-F455-43A2-925C-7F3E02F6A995} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{41481057-47FD-4BEF-853B-7EF5F975F05E} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+		{09E86264-CA02-4A60-98EA-61BB3F460160} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
+	EndGlobalSection
+EndGlobal
Index: /code/branches/physics/visual_studio/vc8/release.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/release.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/release.vsprops	(revision 2122)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="release"
+	InheritedPropertySheets=".\base.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		Optimization="2"
+		PreprocessorDefinitions="NDEBUG"
+		RuntimeLibrary="2"
+		DebugInformationFormat="3"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		LinkIncremental="1"
+		GenerateDebugInformation="true"
+		OptimizeReferences="2"
+		EnableCOMDATFolding="2"
+	/>
+	<UserMacro
+		Name="CS"
+		Value=""
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/tinyxml.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/tinyxml.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/tinyxml.vcproj	(revision 2122)
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tinyxml"
+	ProjectGUID="{F101C2F0-1CB9-4A57-827B-6C399A99B28F}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\tinyxml.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\tinyxml.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\tinyxml\ticpp.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinystr.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxml.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxmlerror.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxmlparser.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\tinyxml\ticpp.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\ticpprc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinystr.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxml.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/tinyxml.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/tinyxml.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/tinyxml.vsprops	(revision 2122)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tinyxml"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/tolua.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/tolua.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/tolua.vcproj	(revision 2122)
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua"
+	ProjectGUID="{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\tolua.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\tolua.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua_event.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_is.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_map.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_push.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_to.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua++.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_event.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/tolua.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/tolua.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/tolua.vsprops	(revision 2122)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="TOLUA_SHARED_BUILD"
+		CompileAs="1"
+		DisableSpecificWarnings="4996"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/tolua_static.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/tolua_static.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/tolua_static.vcproj	(revision 2122)
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_static"
+	ProjectGUID="{C6692661-9160-49E6-B109-A155F9485402}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\debug.vsprops;.\tolua_static.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets=".\release.vsprops;.\tolua_static.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua_event.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_is.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_map.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_push.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_to.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua++.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_event.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/tolua_static.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/tolua_static.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/tolua_static.vsprops	(revision 2122)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_static"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="TOLUA_STATIC_BUILD"
+		CompileAs="1"
+		DisableSpecificWarnings="4996"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/toluagen.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/toluagen.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/toluagen.vcproj	(revision 2122)
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="toluagen"
+	ProjectGUID="{A0724246-CB7C-420B-BCF0-68EF205AFE34}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets=".\debug.vsprops;.\toluagen.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets=".\release.vsprops;.\toluagen.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua++.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/toluagen.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/toluagen.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/toluagen.vsprops	(revision 2122)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="toluagen"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="TOLUA_STATIC_BUILD"
+		CompileAs="1"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		OutputFile="$(IntDir)$(ProjectName)$(CS).exe"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/toluagen_orxonox.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/toluagen_orxonox.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/toluagen_orxonox.vcproj	(revision 2122)
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="toluagen_orxonox"
+	ProjectGUID="{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets=".\debug.vsprops;.\toluagen_orxonox.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets=".\release.vsprops;.\toluagen_orxonox.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua-5.1.pkg"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Generating tolua bind files..."
+						CommandLine="&quot;$(RootDir)\build\$(SolutionName)\$(ConfigurationName)\toluagen\toluagen$(CS).exe&quot; -n tolua -o $(RootDir)/src/tolua/toluabind_orxonox.c -H $(RootDir)/src/tolua/toluabind_orxonox.h $(RootDir)/src/tolua/tolua-5.1.pkg&#x0D;&#x0A;"
+						AdditionalDependencies="$(RootDir)\src\tolua\lua\compat-5.1.lua;$(RootDir)\src\tolua\lua\compat.lua;$(RootDir)\src\tolua\lua\basic.lua;$(RootDir)\src\tolua\lua\feature.lua;$(RootDir)\src\tolua\lua\verbatim.lua;$(RootDir)\src\tolua\lua\code.lua;$(RootDir)\src\tolua\lua\typedef.lua;$(RootDir)\src\tolua\lua\container.lua;$(RootDir)\src\tolua\lua\package.lua;$(RootDir)\src\tolua\lua\module.lua;$(RootDir)\src\tolua\lua\namespace.lua;$(RootDir)\src\tolua\lua\define.lua;$(RootDir)\src\tolua\lua\enumerate.lua;$(RootDir)\src\tolua\lua\declaration.lua;$(RootDir)\src\tolua\lua\variable.lua;$(RootDir)\src\tolua\lua\array.lua;$(RootDir)\src\tolua\lua\function.lua;$(RootDir)\src\tolua\lua\operator.lua;$(RootDir)\src\tolua\lua\class.lua;$(RootDir)\src\tolua\lua\clean.lua;$(RootDir)\src\tolua\lua\doit.lua"
+						Outputs="$(RootDir)\src\tolua\toluabind_orxonox.c; $(RootDir)\src\tolua\toluabind_orxonox.h"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Generating tolua bind files..."
+						CommandLine="&quot;$(RootDir)\build\$(SolutionName)\$(ConfigurationName)\toluagen\toluagen$(CS).exe&quot; -n tolua -o $(RootDir)/src/tolua/toluabind_orxonox.c -H $(RootDir)/src/tolua/toluabind_orxonox.h $(RootDir)/src/tolua/tolua-5.1.pkg&#x0D;&#x0A;"
+						AdditionalDependencies="$(RootDir)\src\tolua\lua\compat-5.1.lua;$(RootDir)\src\tolua\lua\compat.lua;$(RootDir)\src\tolua\lua\basic.lua;$(RootDir)\src\tolua\lua\feature.lua;$(RootDir)\src\tolua\lua\verbatim.lua;$(RootDir)\src\tolua\lua\code.lua;$(RootDir)\src\tolua\lua\typedef.lua;$(RootDir)\src\tolua\lua\container.lua;$(RootDir)\src\tolua\lua\package.lua;$(RootDir)\src\tolua\lua\module.lua;$(RootDir)\src\tolua\lua\namespace.lua;$(RootDir)\src\tolua\lua\define.lua;$(RootDir)\src\tolua\lua\enumerate.lua;$(RootDir)\src\tolua\lua\declaration.lua;$(RootDir)\src\tolua\lua\variable.lua;$(RootDir)\src\tolua\lua\array.lua;$(RootDir)\src\tolua\lua\function.lua;$(RootDir)\src\tolua\lua\operator.lua;$(RootDir)\src\tolua\lua\class.lua;$(RootDir)\src\tolua\lua\clean.lua;$(RootDir)\src\tolua\lua\doit.lua"
+						Outputs="$(RootDir)\src\tolua\toluabind_orxonox.c; $(RootDir)\src\tolua\toluabind_orxonox.h"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind_orxonox.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua++.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind_orxonox.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/toluagen_orxonox.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/toluagen_orxonox.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/toluagen_orxonox.vsprops	(revision 2122)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="toluagen_orxonox"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="TOLUA_STATIC_BUILD"
+		CompileAs="1"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		OutputFile="$(IntDir)$(ProjectName)$(CS).exe"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/physics/visual_studio/vc8/util.vcproj
===================================================================
--- /code/branches/physics/visual_studio/vc8/util.vcproj	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/util.vcproj	(revision 2122)
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="util"
+	ProjectGUID="{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
+	RootNamespace="orxonox"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\debug.vsprops;.\util.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets=".\release.vsprops;.\util.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\util\Clipboard.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\CRC32.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Exception.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\ExprParser.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Math.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiType.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputHandler.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\SignalHandler.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\String.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\SubString.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\util\Clipboard.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Convert.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\CRC32.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Debug.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Exception.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\ExprParser.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Integers.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Math.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MathConvert.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiType.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypeValue.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OrxonoxPlatform.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputHandler.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\SignalHandler.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Sleep.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\String.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\SubString.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\UtilPrereqs.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/physics/visual_studio/vc8/util.vsprops
===================================================================
--- /code/branches/physics/visual_studio/vc8/util.vsprops	(revision 2122)
+++ /code/branches/physics/visual_studio/vc8/util.vsprops	(revision 2122)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="util"
+	InheritedPropertySheets=".\directories.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		PreprocessorDefinitions="UTIL_SHARED_BUILD"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
